From 538c9e28483f0167517ef457d98489173ce94f47 Mon Sep 17 00:00:00 2001 From: Travis CI Date: Fri, 29 Sep 2017 12:47:19 -0700 Subject: [PATCH 001/242] Initial npm branch commit --- LICENSE | 30 + PATENTS | 11 + README.md | 537 +++ bower.json | 39 + dist/immutable-nonambient.d.ts | 4502 ++++++++++++++++++++++++++ dist/immutable.d.ts | 4506 ++++++++++++++++++++++++++ dist/immutable.es.js | 5535 +++++++++++++++++++++++++++++++ dist/immutable.js | 5567 ++++++++++++++++++++++++++++++++ dist/immutable.js.flow | 1272 ++++++++ dist/immutable.min.js | 39 + package.json | 127 + 11 files changed, 22165 insertions(+) create mode 100644 LICENSE create mode 100644 PATENTS create mode 100644 README.md create mode 100644 bower.json create mode 100644 dist/immutable-nonambient.d.ts create mode 100644 dist/immutable.d.ts create mode 100644 dist/immutable.es.js create mode 100644 dist/immutable.js create mode 100644 dist/immutable.js.flow create mode 100644 dist/immutable.min.js create mode 100644 package.json diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000000..c6a207cd5e --- /dev/null +++ b/LICENSE @@ -0,0 +1,30 @@ +BSD License + +For Immutable JS software + +Copyright (c) 2014-2015, Facebook, Inc. All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + * Neither the name Facebook nor the names of its contributors may be used to + endorse or promote products derived from this software without specific + prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/PATENTS b/PATENTS new file mode 100644 index 0000000000..b145145264 --- /dev/null +++ b/PATENTS @@ -0,0 +1,11 @@ +Additional Grant of Patent Rights Version 2 + +"Software" means the Immutable JS software distributed by Facebook, Inc. + +Facebook, Inc. (“Facebook”) hereby grants to each recipient of the Software (“you”) a perpetual, worldwide, royalty-free, non-exclusive, irrevocable (subject to the termination provision below) license under any Necessary Claims, to make, have made, use, sell, offer to sell, import, and otherwise transfer the Software. For avoidance of doubt, no license is granted under Facebook’s rights in any patent claims that are infringed by (i) modifications to the Software made by you or any third party or (ii) the Software in combination with any software or other technology. + +The license granted hereunder will terminate, automatically and without notice, if you (or any of your subsidiaries, corporate affiliates or agents) initiate directly or indirectly, or take a direct financial interest in, any Patent Assertion: (i) against Facebook or any of its subsidiaries or corporate affiliates, (ii) against any party if such Patent Assertion arises in whole or in part from any software, technology, product or service of Facebook or any of its subsidiaries or corporate affiliates, or (iii) against any party relating to the Software. Notwithstanding the foregoing, if Facebook or any of its subsidiaries or corporate affiliates files a lawsuit alleging patent infringement against you in the first instance, and you respond by filing a patent infringement counterclaim in that lawsuit against that party that is unrelated to the Software, the license granted hereunder will not terminate under section (i) of this paragraph due to such counterclaim. + +A “Necessary Claim” is a claim of a patent owned by Facebook that is necessarily infringed by the Software standing alone. + +A “Patent Assertion” is any lawsuit or other action alleging direct, indirect, or contributory infringement or inducement to infringe any patent, including a cross-claim or counterclaim. diff --git a/README.md b/README.md new file mode 100644 index 0000000000..182f7be172 --- /dev/null +++ b/README.md @@ -0,0 +1,537 @@ +Immutable collections for JavaScript +==================================== + +[![Build Status](https://travis-ci.org/facebook/immutable-js.svg?branch=master)](https://travis-ci.org/facebook/immutable-js) + +[Immutable][] data cannot be changed once created, leading to much simpler +application development, no defensive copying, and enabling advanced memoization +and change detection techniques with simple logic. [Persistent][] data presents +a mutative API which does not update the data in-place, but instead always +yields new updated data. + +Immutable.js provides many Persistent Immutable data structures including: +`List`, `Stack`, `Map`, `OrderedMap`, `Set`, `OrderedSet` and `Record`. + +These data structures are highly efficient on modern JavaScript VMs by using +structural sharing via [hash maps tries][] and [vector tries][] as popularized +by Clojure and Scala, minimizing the need to copy or cache data. + +Immutable.js also provides a lazy `Seq`, allowing efficient +chaining of collection methods like `map` and `filter` without creating +intermediate representations. Create some `Seq` with `Range` and `Repeat`. + +Want to hear more? Watch the presentation about Immutable.js: + + + +[Persistent]: http://en.wikipedia.org/wiki/Persistent_data_structure +[Immutable]: http://en.wikipedia.org/wiki/Immutable_object +[hash maps tries]: http://en.wikipedia.org/wiki/Hash_array_mapped_trie +[vector tries]: http://hypirion.com/musings/understanding-persistent-vector-pt-1 + + +Getting started +--------------- + +Install `immutable` using npm. + +```shell +npm install immutable +``` + +Then require it into any module. + + +```js +const { Map } = require('immutable') +const map1 = Map({ a: 1, b: 2, c: 3 }) +const map2 = map1.set('b', 50) +map1.get('b') + " vs. " + map2.get('b') // 2 vs. 50 +``` + +### Browser + +To use Immutable.js from a browser, download [dist/immutable.min.js](https://github.com/facebook/immutable-js/blob/master/dist/immutable.min.js) +or use a CDN such as [CDNJS](https://cdnjs.com/libraries/immutable) +or [jsDelivr](http://www.jsdelivr.com/#!immutable.js). + +Then, add it as a script tag to your page: + +```html + + +``` + +Or use an AMD loader (such as [RequireJS](http://requirejs.org/)): + +```js +require(['./immutable.min.js'], function (Immutable) { + var map1 = Immutable.Map({a:1, b:2, c:3}); + var map2 = map1.set('b', 50); + map1.get('b'); // 2 + map2.get('b'); // 50 +}); +``` + +If you're using [webpack](https://webpack.github.io/) or +[browserify](http://browserify.org/), the `immutable` npm module also works +from the browser. + +### Flow & TypeScript + +Use these Immutable collections and sequences as you would use native +collections in your [Flowtype](https://flowtype.org/) or [TypeScript](http://typescriptlang.org) programs while still taking +advantage of type generics, error detection, and auto-complete in your IDE. + +Installing `immutable` via npm brings with it type definitions for Flow (v0.39.0 or higher) +and TypeScript (v2.1.0 or higher), so you shouldn't need to do anything at all! + +#### Using TypeScript with Immutable.js v4 + +Immutable.js type definitions embrace ES2015. While Immutable.js itself supports +legacy browsers and environments, its type definitions require TypeScript's 2015 +lib. Include either `"target": "es2015"` or `"lib": "es2015"` in your +`tsconfig.json`, or provide `--target es2015` or `--lib es2015` to the +`tsc` command. + + +```js +const { Map } = require("immutable"); +const map1 = Map({ a: 1, b: 2, c: 3 }); +const map2 = map1.set('b', 50); +map1.get('b') + " vs. " + map2.get('b') // 2 vs. 50 +``` + +#### Using TypeScript with Immutable.js v3 and earlier: + +Previous versions of Immutable.js include a reference file which you can include +via relative path to the type definitions at the top of your file. + +```js +/// +import Immutable from require('immutable'); +var map1: Immutable.Map; +map1 = Immutable.Map({a:1, b:2, c:3}); +var map2 = map1.set('b', 50); +map1.get('b'); // 2 +map2.get('b'); // 50 +``` + + +The case for Immutability +------------------------- + +Much of what makes application development difficult is tracking mutation and +maintaining state. Developing with immutable data encourages you to think +differently about how data flows through your application. + +Subscribing to data events throughout your application creates a huge overhead of +book-keeping which can hurt performance, sometimes dramatically, and creates +opportunities for areas of your application to get out of sync with each other +due to easy to make programmer error. Since immutable data never changes, +subscribing to changes throughout the model is a dead-end and new data can only +ever be passed from above. + +This model of data flow aligns well with the architecture of [React][] +and especially well with an application designed using the ideas of [Flux][]. + +When data is passed from above rather than being subscribed to, and you're only +interested in doing work when something has changed, you can use equality. + +Immutable collections should be treated as *values* rather than *objects*. While +objects represent some thing which could change over time, a value represents +the state of that thing at a particular instance of time. This principle is most +important to understanding the appropriate use of immutable data. In order to +treat Immutable.js collections as values, it's important to use the +`Immutable.is()` function or `.equals()` method to determine value equality +instead of the `===` operator which determines object reference identity. + + +```js +const { Map } = require('immutable') +const map1 = Map( {a: 1, b: 2, c: 3 }) +const map2 = map1.set('b', 2) +assert.equal(map1, map2) // uses map1.equals +assert.strictEqual(map1, map2) // uses === +const map3 = map1.set('b', 50) +assert.notEqual(map1, map3) // uses map1.equals +``` + +Note: As a performance optimization Immutable.js attempts to return the existing +collection when an operation would result in an identical collection, allowing +for using `===` reference equality to determine if something definitely has not +changed. This can be extremely useful when used within a memoization function +which would prefer to re-run the function if a deeper equality check could +potentially be more costly. The `===` equality check is also used internally by +`Immutable.is` and `.equals()` as a performance optimization. + +If an object is immutable, it can be "copied" simply by making another reference +to it instead of copying the entire object. Because a reference is much smaller +than the object itself, this results in memory savings and a potential boost in +execution speed for programs which rely on copies (such as an undo-stack). + + +```js +const { Map } = require('immutable') +const map1 = Map({ a: 1, b: 2, c: 3 }) +const clone = map1; +``` + +[React]: http://facebook.github.io/react/ +[Flux]: http://facebook.github.io/flux/docs/overview.html + + +JavaScript-first API +-------------------- + +While Immutable.js is inspired by Clojure, Scala, Haskell and other functional +programming environments, it's designed to bring these powerful concepts to +JavaScript, and therefore has an Object-Oriented API that closely mirrors that +of [ES2015][] [Array][], [Map][], and [Set][]. + +[ES2015]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/New_in_JavaScript/ECMAScript_6_support_in_Mozilla +[Array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array +[Map]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map +[Set]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set + +The difference for the immutable collections is that methods which would mutate +the collection, like `push`, `set`, `unshift` or `splice`, instead return a new +immutable collection. Methods which return new arrays, like `slice` or `concat`, +instead return new immutable collections. + + +```js +const { List } = require('immutable') +const list1 = List([ 1, 2 ]); +const list2 = list1.push(3, 4, 5); +const list3 = list2.unshift(0); +const list4 = list1.concat(list2, list3); +assert.equal(list1.size, 2); +assert.equal(list2.size, 5); +assert.equal(list3.size, 6); +assert.equal(list4.size, 13); +assert.equal(list4.get(0), 1); +``` + +Almost all of the methods on [Array][] will be found in similar form on +`Immutable.List`, those of [Map][] found on `Immutable.Map`, and those of [Set][] +found on `Immutable.Set`, including collection operations like `forEach()` +and `map()`. + + +```js +const { Map } = require('immutable') +const alpha = Map({ a: 1, b: 2, c: 3, d: 4 }); +alpha.map((v, k) => k.toUpperCase()).join(); +// 'A,B,C,D' +``` + +### Accepts raw JavaScript objects. + +Designed to inter-operate with your existing JavaScript, Immutable.js +accepts plain JavaScript Arrays and Objects anywhere a method expects an +`Collection`. + + +```js +const { Map } = require('immutable') +const map1 = Map({ a: 1, b: 2, c: 3, d: 4 }) +const map2 = Map({ c: 10, a: 20, t: 30 }) +const obj = { d: 100, o: 200, g: 300 } +const map3 = map1.merge(map2, obj); +// Map { a: 20, b: 2, c: 10, d: 100, t: 30, o: 200, g: 300 } +``` + +This is possible because Immutable.js can treat any JavaScript Array or Object +as a Collection. You can take advantage of this in order to get sophisticated +collection methods on JavaScript Objects, which otherwise have a very sparse +native API. Because Seq evaluates lazily and does not cache intermediate +results, these operations can be extremely efficient. + + +```js +const { Seq } = require('immutable') +const myObject = { a: 1, b: 2, c: 3 } +Seq(myObject).map(x => x * x).toObject(); +// { a: 1, b: 4, c: 9 } +``` + +Keep in mind, when using JS objects to construct Immutable Maps, that +JavaScript Object properties are always strings, even if written in a quote-less +shorthand, while Immutable Maps accept keys of any type. + + +```js +const { fromJS } = require('immutable') + +const obj = { 1: "one" } +Object.keys(obj) // [ "1" ] +assert.equal(obj["1"], obj[1]) // "one" === "one" + +const map = fromJS(obj) +assert.notEqual(map.get("1"), map.get(1)) // "one" !== undefined +``` + +Property access for JavaScript Objects first converts the key to a string, but +since Immutable Map keys can be of any type the argument to `get()` is +not altered. + + +### Converts back to raw JavaScript objects. + +All Immutable.js Collections can be converted to plain JavaScript Arrays and +Objects shallowly with `toArray()` and `toObject()` or deeply with `toJS()`. +All Immutable Collections also implement `toJSON()` allowing them to be passed +to `JSON.stringify` directly. + + +```js +const { Map, List } = require('immutable') +const deep = Map({ a: 1, b: 2, c: List([ 3, 4, 5 ]) }) +console.log(deep.toObject()) // { a: 1, b: 2, c: List [ 3, 4, 5 ] } +console.log(deep.toArray()) // [ 1, 2, List [ 3, 4, 5 ] ] +console.log(deep.toJS()) // { a: 1, b: 2, c: [ 3, 4, 5 ] } +JSON.stringify(deep) // '{"a":1,"b":2,"c":[3,4,5]}' +``` + +### Embraces ES2015 + +Immutable.js supports all JavaScript environments, including legacy +browsers (even IE8). However it also takes advantage of features added to +JavaScript in [ES2015][], the latest standard version of JavaScript, including +[Iterators][], [Arrow Functions][], [Classes][], and [Modules][]. It's inspired +by the native [Map][] and [Set][] collections added to ES2015. + +All examples in the Documentation are presented in ES2015. To run in all +browsers, they need to be translated to ES5. + +```js +// ES2015 +const mapped = foo.map(x => x * x); +// ES5 +var mapped = foo.map(function (x) { return x * x; }); +``` + +[Iterators]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/The_Iterator_protocol +[Arrow Functions]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions +[Classes]: http://wiki.ecmascript.org/doku.php?id=strawman:maximally_minimal_classes +[Modules]: http://www.2ality.com/2014/09/es6-modules-final.html + + +Nested Structures +----------------- + +The collections in Immutable.js are intended to be nested, allowing for deep +trees of data, similar to JSON. + + +```js +const { fromJS } = require('immutable') +const nested = fromJS({ a: { b: { c: [ 3, 4, 5 ] } } }) +// Map { a: Map { b: Map { c: List [ 3, 4, 5 ] } } } +``` + +A few power-tools allow for reading and operating on nested data. The +most useful are `mergeDeep`, `getIn`, `setIn`, and `updateIn`, found on `List`, +`Map` and `OrderedMap`. + + +```js +const { fromJS } = require('immutable') +const nested = fromJS({ a: { b: { c: [ 3, 4, 5 ] } } }) + +const nested2 = nested.mergeDeep({ a: { b: { d: 6 } } }) +// Map { a: Map { b: Map { c: List [ 3, 4, 5 ], d: 6 } } } + +console.log(nested2.getIn([ 'a', 'b', 'd' ])) // 6 + +const nested3 = nested2.updateIn([ 'a', 'b', 'd' ], value => value + 1) +console.log(nested3); +// Map { a: Map { b: Map { c: List [ 3, 4, 5 ], d: 7 } } } + +const nested4 = nested3.updateIn([ 'a', 'b', 'c' ], list => list.push(6)) +// Map { a: Map { b: Map { c: List [ 3, 4, 5, 6 ], d: 7 } } } +``` + + +Lazy Seq +-------- + +`Seq` describes a lazy operation, allowing them to efficiently chain +use of all the sequence methods (such as `map` and `filter`). + +**Seq is immutable** — Once a Seq is created, it cannot be +changed, appended to, rearranged or otherwise modified. Instead, any mutative +method called on a Seq will return a new Seq. + +**Seq is lazy** — Seq does as little work as necessary to respond to any +method call. + +For example, the following does not perform any work, because the resulting +Seq is never used: + +```js +const { Seq } = require('immutable') +const oddSquares = Seq([ 1, 2, 3, 4, 5, 6, 7, 8 ]) + .filter(x => x % 2) + .map(x => x * x) +``` + +Once the Seq is used, it performs only the work necessary. In this +example, no intermediate arrays are ever created, filter is called three times, +and map is only called once: + +```js +console.log(oddSquares.get(1)); // 9 +``` + +Any collection can be converted to a lazy Seq with `.toSeq()`. + + +```js +const { Map } = require('immutable') +const seq = Map({ a: 1, b: 2, c: 3 }).toSeq() +``` + +Seq allows for the efficient chaining of sequence operations, especially when +converting to a different concrete type (such as to a JS object): + +```js +seq.flip().map(key => key.toUpperCase()).flip().toObject(); +// { A: 1, B: 2, C: 3 } +``` + +As well as expressing logic that would otherwise seem memory-limited: + + +```js +const { Range } = require('immutable') +Range(1, Infinity) + .skip(1000) + .map(n => -n) + .filter(n => n % 2 === 0) + .take(2) + .reduce((r, n) => r * n, 1); +// 1006008 +``` + +Note: A Collection is always iterated in the same order, however that order may +not always be well defined, as is the case for the `Map`. + + +Equality treats Collections as Data +----------------------------------- + +Immutable.js provides equality which treats immutable data structures as pure +data, performing a deep equality check if necessary. + + +```js +const { Map, is } = require('immutable') +const map1 = Map({ a: 1, b: 2, c: 3 }) +const map2 = Map({ a: 1, b: 2, c: 3 }) +assert.equal(map1 !== map2, true) // two different instances +assert.equal(is(map1, map2), true) // have equivalent values +assert.equal(map1.equals(map2), true) // alternatively use the equals method +``` + +`Immutable.is()` uses the same measure of equality as [Object.is][] +including if both are immutable and all keys and values are equal +using the same measure of equality. + +[Object.is]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is + + +Batching Mutations +------------------ + +> If a tree falls in the woods, does it make a sound? +> +> If a pure function mutates some local data in order to produce an immutable +> return value, is that ok? +> +> — Rich Hickey, Clojure + +Applying a mutation to create a new immutable object results in some overhead, +which can add up to a minor performance penalty. If you need to apply a series +of mutations locally before returning, Immutable.js gives you the ability to +create a temporary mutable (transient) copy of a collection and apply a batch of +mutations in a performant manner by using `withMutations`. In fact, this is +exactly how Immutable.js applies complex mutations itself. + +As an example, building `list2` results in the creation of 1, not 3, new +immutable Lists. + + +```js +const { List } = require('immutable') +const list1 = List([ 1, 2, 3 ]); +const list2 = list1.withMutations(function (list) { + list.push(4).push(5).push(6); +}); +assert.equal(list1.size, 3); +assert.equal(list2.size, 6); +``` + +Note: Immutable.js also provides `asMutable` and `asImmutable`, but only +encourages their use when `withMutations` will not suffice. Use caution to not +return a mutable copy, which could result in undesired behavior. + +*Important!*: Only a select few methods can be used in `withMutations` including +`set`, `push` and `pop`. These methods can be applied directly against a +persistent data-structure where other methods like `map`, `filter`, `sort`, +and `splice` will always return new immutable data-structures and never mutate +a mutable collection. + + +Documentation +------------- + +[Read the docs](http://facebook.github.io/immutable-js/docs/) and eat your vegetables. + +Docs are automatically generated from [Immutable.d.ts](https://github.com/facebook/immutable-js/blob/master/type-definitions/Immutable.d.ts). +Please contribute! + +Also, don't miss the [Wiki](https://github.com/facebook/immutable-js/wiki) which +contains articles on specific topics. Can't find something? Open an [issue](https://github.com/facebook/immutable-js/issues). + + +Testing +------- + +If you are using the [Chai Assertion Library](http://chaijs.com/), [Chai Immutable](https://github.com/astorije/chai-immutable) provides a set of assertions to use against Immutable.js collections. + + +Contribution +------------ + +Use [Github issues](https://github.com/facebook/immutable-js/issues) for requests. + +We actively welcome pull requests, learn how to [contribute](./CONTRIBUTING.md). + + +Changelog +--------- + +Changes are tracked as [Github releases](https://github.com/facebook/immutable-js/releases). + + +Thanks +------ + +[Phil Bagwell](https://www.youtube.com/watch?v=K2NYwP90bNs), for his inspiration +and research in persistent data structures. + +[Hugh Jackson](https://github.com/hughfdjackson/), for providing the npm package +name. If you're looking for his unsupported package, see [this repository](https://github.com/hughfdjackson/immutable). + + +License +------- + +Immutable.js is [BSD-licensed](https://github.com/facebook/immutable-js/blob/master/LICENSE). We also provide an additional [patent grant](https://github.com/facebook/immutable-js/blob/master/PATENTS). diff --git a/bower.json b/bower.json new file mode 100644 index 0000000000..c1a3fd8284 --- /dev/null +++ b/bower.json @@ -0,0 +1,39 @@ +{ + "name": "immutable", + "description": "Immutable Data Collections", + "homepage": "https://github.com/facebook/immutable-js", + "author": { + "name": "Lee Byron", + "homepage": "https://github.com/leebyron" + }, + "repository": { + "type": "git", + "url": "git://github.com/facebook/immutable-js.git" + }, + "main": "dist/immutable.js", + "typescript": { + "definition": "dist/immutable.d.ts" + }, + "ignore": [ + "**/.*", + "__tests__", + "resources", + "src", + "type-definitions", + "package.json", + "Gruntfile.js" + ], + "keywords": [ + "immutable", + "persistent", + "lazy", + "data", + "datastructure", + "functional", + "collection", + "stateless", + "sequence", + "iteration" + ], + "license": "BSD" +} diff --git a/dist/immutable-nonambient.d.ts b/dist/immutable-nonambient.d.ts new file mode 100644 index 0000000000..21e57fb499 --- /dev/null +++ b/dist/immutable-nonambient.d.ts @@ -0,0 +1,4502 @@ +/** + * Copyright (c) 2014-2015, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + +/** + * Immutable data encourages pure functions (data-in, data-out) and lends itself + * to much simpler application development and enabling techniques from + * functional programming such as lazy evaluation. + * + * While designed to bring these powerful functional concepts to JavaScript, it + * presents an Object-Oriented API familiar to Javascript engineers and closely + * mirroring that of Array, Map, and Set. It is easy and efficient to convert to + * and from plain Javascript types. + * + * ## How to read these docs + * + * In order to better explain what kinds of values the Immutable.js API expects + * and produces, this documentation is presented in a statically typed dialect of + * JavaScript (like [Flow][] or [TypeScript][]). You *don't need* to use these + * type checking tools in order to use Immutable.js, however becoming familiar + * with their syntax will help you get a deeper understanding of this API. + * + * **A few examples and how to read them.** + * + * All methods describe the kinds of data they accept and the kinds of data + * they return. For example a function which accepts two numbers and returns + * a number would look like this: + * + * ```js + * sum(first: number, second: number): number + * ``` + * + * Sometimes, methods can accept different kinds of data or return different + * kinds of data, and this is described with a *type variable*, which is + * typically in all-caps. For example, a function which always returns the same + * kind of data it was provided would look like this: + * + * ```js + * identity(value: T): T + * ``` + * + * Type variables are defined with classes and referred to in methods. For + * example, a class that holds onto a value for you might look like this: + * + * ```js + * class Box { + * constructor(value: T) + * getValue(): T + * } + * ``` + * + * In order to manipulate Immutable data, methods that we're used to affecting + * a Collection instead return a new Collection of the same type. The type + * `this` refers to the same kind of class. For example, a List which returns + * new Lists when you `push` a value onto it might look like: + * + * ```js + * class List { + * push(value: T): this + * } + * ``` + * + * Many methods in Immutable.js accept values which implement the JavaScript + * [Iterable][] protocol, and might appear like `Iterable` for something + * which represents sequence of strings. Typically in JavaScript we use plain + * Arrays (`[]`) when an Iterable is expected, but also all of the Immutable.js + * collections are iterable themselves! + * + * For example, to get a value deep within a structure of data, we might use + * `getIn` which expects an `Iterable` path: + * + * ``` + * getIn(path: Iterable): any + * ``` + * + * To use this method, we could pass an array: `data.getIn([ "key", 2 ])`. + * + * + * Note: All examples are presented in the modern [ES2015][] version of + * JavaScript. To run in older browsers, they need to be translated to ES3. + * + * For example: + * + * ```js + * // ES2015 + * const mappedFoo = foo.map(x => x * x); + * // ES3 + * var mappedFoo = foo.map(function (x) { return x * x; }); + * ``` + * + * [ES2015]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/New_in_JavaScript/ECMAScript_6_support_in_Mozilla + * [TypeScript]: http://www.typescriptlang.org/ + * [Flow]: https://flowtype.org/ + * [Iterable]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols + */ + + + + /** + * Deeply converts plain JS objects and arrays to Immutable Maps and Lists. + * + * If a `reviver` is optionally provided, it will be called with every + * collection as a Seq (beginning with the most nested collections + * and proceeding to the top-level collection itself), along with the key + * refering to each collection and the parent JS object provided as `this`. + * For the top level, object, the key will be `""`. This `reviver` is expected + * to return a new Immutable Collection, allowing for custom conversions from + * deep JS objects. Finally, a `path` is provided which is the sequence of + * keys to this value from the starting value. + * + * `reviver` acts similarly to the [same parameter in `JSON.parse`][1]. + * + * If `reviver` is not provided, the default behavior will convert Objects + * into Maps and Arrays into Lists like so: + * + * ```js + * const { fromJS, isKeyed } = require('immutable') + * function (key, value) { + * return isKeyed(value) ? value.Map() : value.toList() + * } + * ``` + * + * `fromJS` is conservative in its conversion. It will only convert + * arrays which pass `Array.isArray` to Lists, and only raw objects (no custom + * prototype) to Map. + * + * Accordingly, this example converts native JS data to OrderedMap and List: + * + * ```js + * const { fromJS, isKeyed } = require('immutable') + * fromJS({ a: {b: [10, 20, 30]}, c: 40}, function (key, value, path) { + * console.log(key, value, path) + * return isKeyed(value) ? value.toOrderedMap() : value.toList() + * }) + * + * > "b", [ 10, 20, 30 ], [ "a", "b" ] + * > "a", {b: [10, 20, 30]}, [ "a" ] + * > "", {a: {b: [10, 20, 30]}, c: 40}, [] + * ``` + * + * Keep in mind, when using JS objects to construct Immutable Maps, that + * JavaScript Object properties are always strings, even if written in a + * quote-less shorthand, while Immutable Maps accept keys of any type. + * + * + * ```js + * let obj = { 1: "one" }; + * Object.keys(obj); // [ "1" ] + * assert.equal(obj["1"], obj[1]); // "one" === "one" + * + * let map = Map(obj); + * assert.notEqual(map.get("1"), map.get(1)); // "one" !== undefined + * ``` + * + * Property access for JavaScript Objects first converts the key to a string, + * but since Immutable Map keys can be of any type the argument to `get()` is + * not altered. + * + * [1]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse#Example.3A_Using_the_reviver_parameter + * "Using the reviver parameter" + */ + export function fromJS( + jsValue: any, + reviver?: ( + key: string | number, + sequence: Collection.Keyed | Collection.Indexed, + path?: Array + ) => any + ): any; + + + /** + * Value equality check with semantics similar to `Object.is`, but treats + * Immutable `Collection`s as values, equal if the second `Collection` includes + * equivalent values. + * + * It's used throughout Immutable when checking for equality, including `Map` + * key equality and `Set` membership. + * + * + * ```js + * const { Map, is } = require('immutable') + * const map1 = Map({ a: 1, b: 1, c: 1 }) + * const map2 = Map({ a: 1, b: 1, c: 1 }) + * assert.equal(map1 !== map2, true) + * assert.equal(Object.is(map1, map2), false) + * assert.equal(is(map1, map2), true) + * ``` + * + * `is()` compares primitive types like strings and numbers, Immutable.js + * collections like `Map` and `List`, but also any custom object which + * implements `ValueObject` by providing `equals()` and `hashCode()` methods. + * + * Note: Unlike `Object.is`, `Immutable.is` assumes `0` and `-0` are the same + * value, matching the behavior of ES6 Map key equality. + */ + export function is(first: any, second: any): boolean; + + + /** + * The `hash()` function is an important part of how Immutable determines if + * two values are equivalent and is used to determine how to store those + * values. Provided with any value, `hash()` will return a 31-bit integer. + * + * When designing Objects which may be equal, it's important than when a + * `.equals()` method returns true, that both values `.hashCode()` method + * return the same value. `hash()` may be used to produce those values. + * + * Note that `hash()` attempts to balance between speed and avoiding + * collisions, however it makes no attempt to produce secure hashes. + * + * *New in Version 4.0* + */ + export function hash(value: any): number; + + /** + * True if `maybeImmutable` is an Immutable Collection or Record. + * + * ```js + * const { isImmutable, Map, List, Stack } = require('immutable'); + * isImmutable([]); // false + * isImmutable({}); // false + * isImmutable(Map()); // true + * isImmutable(List()); // true + * isImmutable(Stack()); // true + * isImmutable(Map().asMutable()); // false + * ``` + */ + export function isImmutable(maybeImmutable: any): maybeImmutable is Collection; + + /** + * True if `maybeCollection` is a Collection, or any of its subclasses. + * + * ```js + * const { isCollection, Map, List, Stack } = require('immutable'); + * isCollection([]); // false + * isCollection({}); // false + * isCollection(Map()); // true + * isCollection(List()); // true + * isCollection(Stack()); // true + * ``` + */ + export function isCollection(maybeCollection: any): maybeCollection is Collection; + + /** + * True if `maybeKeyed` is a Collection.Keyed, or any of its subclasses. + * + * ```js + * const { isKeyed, Map, List, Stack } = require('immutable'); + * isKeyed([]); // false + * isKeyed({}); // false + * isKeyed(Map()); // true + * isKeyed(List()); // false + * isKeyed(Stack()); // false + * ``` + */ + export function isKeyed(maybeKeyed: any): maybeKeyed is Collection.Keyed; + + /** + * True if `maybeIndexed` is a Collection.Indexed, or any of its subclasses. + * + * ```js + * const { isIndexed, Map, List, Stack, Set } = require('immutable'); + * isIndexed([]); // false + * isIndexed({}); // false + * isIndexed(Map()); // false + * isIndexed(List()); // true + * isIndexed(Stack()); // true + * isIndexed(Set()); // false + * ``` + */ + export function isIndexed(maybeIndexed: any): maybeIndexed is Collection.Indexed; + + /** + * True if `maybeAssociative` is either a Keyed or Indexed Collection. + * + * ```js + * const { isAssociative, Map, List, Stack, Set } = require('immutable'); + * isAssociative([]); // false + * isAssociative({}); // false + * isAssociative(Map()); // true + * isAssociative(List()); // true + * isAssociative(Stack()); // true + * isAssociative(Set()); // false + * ``` + */ + export function isAssociative(maybeAssociative: any): maybeAssociative is Collection.Keyed | Collection.Indexed; + + /** + * True if `maybeOrdered` is a Collection where iteration order is well + * defined. True for Collection.Indexed as well as OrderedMap and OrderedSet. + * + * ```js + * const { isOrdered, Map, OrderedMap, List, Set } = require('immutable'); + * isOrdered([]); // false + * isOrdered({}); // false + * isOrdered(Map()); // false + * isOrdered(OrderedMap()); // true + * isOrdered(List()); // true + * isOrdered(Set()); // false + * ``` + */ + export function isOrdered(maybeOrdered: any): boolean; + + /** + * True if `maybeValue` is a JavaScript Object which has *both* `equals()` + * and `hashCode()` methods. + * + * Any two instances of *value objects* can be compared for value equality with + * `Immutable.is()` and can be used as keys in a `Map` or members in a `Set`. + */ + export function isValueObject(maybeValue: any): maybeValue is ValueObject; + + /** + * The interface to fulfill to qualify as a Value Object. + */ + export interface ValueObject { + /** + * True if this and the other Collection have value equality, as defined + * by `Immutable.is()`. + * + * Note: This is equivalent to `Immutable.is(this, other)`, but provided to + * allow for chained expressions. + */ + equals(other: any): boolean; + + /** + * Computes and returns the hashed identity for this Collection. + * + * The `hashCode` of a Collection is used to determine potential equality, + * and is used when adding this to a `Set` or as a key in a `Map`, enabling + * lookup via a different instance. + * + * + * ```js + * const a = List([ 1, 2, 3 ]); + * const b = List([ 1, 2, 3 ]); + * assert.notStrictEqual(a, b); // different instances + * const set = Set([ a ]); + * assert.equal(set.has(b), true); + * ``` + * + * Note: hashCode() MUST return a Uint32 number. The easiest way to + * guarantee this is to return `myHash | 0` from a custom implementation. + * + * If two values have the same `hashCode`, they are [not guaranteed + * to be equal][Hash Collision]. If two values have different `hashCode`s, + * they must not be equal. + * + * [Hash Collision]: http://en.wikipedia.org/wiki/Collision_(computer_science) + */ + hashCode(): number; + } + + /** + * Lists are ordered indexed dense collections, much like a JavaScript + * Array. + * + * Lists are immutable and fully persistent with O(log32 N) gets and sets, + * and O(1) push and pop. + * + * Lists implement Deque, with efficient addition and removal from both the + * end (`push`, `pop`) and beginning (`unshift`, `shift`). + * + * Unlike a JavaScript Array, there is no distinction between an + * "unset" index and an index set to `undefined`. `List#forEach` visits all + * indices from 0 to size, regardless of whether they were explicitly defined. + */ + export module List { + + /** + * True if the provided value is a List + * + * + * ```js + * List.isList([]); // false + * List.isList(List()); // true + * ``` + */ + function isList(maybeList: any): maybeList is List; + + /** + * Creates a new List containing `values`. + * + * + * ```js + * List.of(1, 2, 3, 4) + * // List [ 1, 2, 3, 4 ] + * ``` + * + * Note: Values are not altered or converted in any way. + * + * + * ```js + * List.of({x:1}, 2, [3], 4) + * // List [ { x: 1 }, 2, [ 3 ], 4 ] + * ``` + */ + function of(...values: Array): List; + } + + /** + * Create a new immutable List containing the values of the provided + * collection-like. + * + * + * ```js + * const { List, Set } = require('immutable') + * + * const emptyList = List() + * // List [] + * + * const plainArray = [ 1, 2, 3, 4 ] + * const listFromPlainArray = List(plainArray) + * // List [ 1, 2, 3, 4 ] + * + * const plainSet = Set([ 1, 2, 3, 4 ]) + * const listFromPlainSet = List(plainSet) + * // List [ 1, 2, 3, 4 ] + * + * const arrayIterator = plainArray[Symbol.iterator]() + * const listFromCollectionArray = List(arrayIterator) + * // List [ 1, 2, 3, 4 ] + * + * listFromPlainArray.equals(listFromCollectionArray) // true + * listFromPlainSet.equals(listFromCollectionArray) // true + * listFromPlainSet.equals(listFromPlainArray) // true + * ``` + */ + export function List(): List; + export function List(): List; + export function List(collection: Iterable): List; + + export interface List extends Collection.Indexed { + + /** + * The number of items in this List. + */ + readonly size: number; + + // Persistent changes + + /** + * Returns a new List which includes `value` at `index`. If `index` already + * exists in this List, it will be replaced. + * + * `index` may be a negative number, which indexes back from the end of the + * List. `v.set(-1, "value")` sets the last item in the List. + * + * If `index` larger than `size`, the returned List's `size` will be large + * enough to include the `index`. + * + * + * ```js + * const originalList = List([ 0 ]); + * // List [ 0 ] + * originalList.set(1, 1); + * // List [ 0, 1 ] + * originalList.set(0, 'overwritten'); + * // List [ "overwritten" ] + * originalList.set(2, 2); + * // List [ 0, undefined, 2 ] + * + * List().set(50000, 'value').size; + * // 50001 + * ``` + * + * Note: `set` can be used in `withMutations`. + */ + set(index: number, value: T): List; + + /** + * Returns a new List which excludes this `index` and with a size 1 less + * than this List. Values at indices above `index` are shifted down by 1 to + * fill the position. + * + * This is synonymous with `list.splice(index, 1)`. + * + * `index` may be a negative number, which indexes back from the end of the + * List. `v.delete(-1)` deletes the last item in the List. + * + * Note: `delete` cannot be safely used in IE8 + * + * + * ```js + * List([ 0, 1, 2, 3, 4 ]).delete(0); + * // List [ 1, 2, 3, 4 ] + * ``` + * + * Note: `delete` *cannot* be used in `withMutations`. + * + * @alias remove + */ + delete(index: number): List; + remove(index: number): List; + + /** + * Returns a new List with `value` at `index` with a size 1 more than this + * List. Values at indices above `index` are shifted over by 1. + * + * This is synonymous with `list.splice(index, 0, value)`. + * + * + * ```js + * List([ 0, 1, 2, 3, 4 ]).insert(6, 5) + * // List [ 0, 1, 2, 3, 4, 5 ] + * ``` + * + * Note: `insert` *cannot* be used in `withMutations`. + */ + insert(index: number, value: T): List; + + /** + * Returns a new List with 0 size and no values. + * + * + * ```js + * List([ 1, 2, 3, 4 ]).clear() + * // List [] + * ``` + * + * Note: `clear` can be used in `withMutations`. + */ + clear(): List; + + /** + * Returns a new List with the provided `values` appended, starting at this + * List's `size`. + * + * + * ```js + * List([ 1, 2, 3, 4 ]).push(5) + * // List [ 1, 2, 3, 4, 5 ] + * ``` + * + * Note: `push` can be used in `withMutations`. + */ + push(...values: Array): List; + + /** + * Returns a new List with a size ones less than this List, excluding + * the last index in this List. + * + * Note: this differs from `Array#pop` because it returns a new + * List rather than the removed value. Use `last()` to get the last value + * in this List. + * + * ```js + * List([ 1, 2, 3, 4 ]).pop() + * // List[ 1, 2, 3 ] + * ``` + * + * Note: `pop` can be used in `withMutations`. + */ + pop(): List; + + /** + * Returns a new List with the provided `values` prepended, shifting other + * values ahead to higher indices. + * + * + * ```js + * List([ 2, 3, 4]).unshift(1); + * // List [ 1, 2, 3, 4 ] + * ``` + * + * Note: `unshift` can be used in `withMutations`. + */ + unshift(...values: Array): List; + + /** + * Returns a new List with a size ones less than this List, excluding + * the first index in this List, shifting all other values to a lower index. + * + * Note: this differs from `Array#shift` because it returns a new + * List rather than the removed value. Use `first()` to get the first + * value in this List. + * + * + * ```js + * List([ 0, 1, 2, 3, 4 ]).shift(); + * // List [ 1, 2, 3, 4 ] + * ``` + * + * Note: `shift` can be used in `withMutations`. + */ + shift(): List; + + /** + * Returns a new List with an updated value at `index` with the return + * value of calling `updater` with the existing value, or `notSetValue` if + * `index` was not set. If called with a single argument, `updater` is + * called with the List itself. + * + * `index` may be a negative number, which indexes back from the end of the + * List. `v.update(-1)` updates the last item in the List. + * + * + * ```js + * const list = List([ 'a', 'b', 'c' ]) + * const result = list.update(2, val => val.toUpperCase()) + * // List [ "a", "b", "C" ] + * ``` + * + * This can be very useful as a way to "chain" a normal function into a + * sequence of methods. RxJS calls this "let" and lodash calls it "thru". + * + * For example, to sum a List after mapping and filtering: + * + * + * ```js + * function sum(collection) { + * return collection.reduce((sum, x) => sum + x, 0) + * } + * + * List([ 1, 2, 3 ]) + * .map(x => x + 1) + * .filter(x => x % 2 === 0) + * .update(sum) + * // 6 + * ``` + * + * Note: `update(index)` can be used in `withMutations`. + * + * @see `Map#update` + */ + update(index: number, notSetValue: T, updater: (value: T) => T): this; + update(index: number, updater: (value: T) => T): this; + update(updater: (value: this) => R): R; + + /** + * Note: `merge` can be used in `withMutations`. + * + * @see `Map#merge` + */ + merge(...collections: Array | Array>): this; + + /** + * Note: `mergeWith` can be used in `withMutations`. + * + * @see `Map#mergeWith` + */ + mergeWith( + merger: (oldVal: T, newVal: T, key: number) => T, + ...collections: Array | Array> + ): this; + + /** + * Note: `mergeDeep` can be used in `withMutations`. + * + * @see `Map#mergeDeep` + */ + mergeDeep(...collections: Array | Array>): this; + + /** + * Note: `mergeDeepWith` can be used in `withMutations`. + * @see `Map#mergeDeepWith` + */ + mergeDeepWith( + merger: (oldVal: T, newVal: T, key: number) => T, + ...collections: Array | Array> + ): this; + + /** + * Returns a new List with size `size`. If `size` is less than this + * List's size, the new List will exclude values at the higher indices. + * If `size` is greater than this List's size, the new List will have + * undefined values for the newly available indices. + * + * When building a new List and the final size is known up front, `setSize` + * used in conjunction with `withMutations` may result in the more + * performant construction. + */ + setSize(size: number): List; + + + // Deep persistent changes + + /** + * Returns a new List having set `value` at this `keyPath`. If any keys in + * `keyPath` do not exist, a new immutable Map will be created at that key. + * + * Index numbers are used as keys to determine the path to follow in + * the List. + * + * + * ```js + * const { List } = require("immutable") + * const list = List([ 0, 1, 2, List([ 3, 4 ])]) + * list.setIn([3, 0], 999); + * // List [ 0, 1, 2, List [ 999, 4 ] ] + * ``` + * + * Note: `setIn` can be used in `withMutations`. + */ + setIn(keyPath: Iterable, value: any): this; + + /** + * Returns a new List having removed the value at this `keyPath`. If any + * keys in `keyPath` do not exist, no change will occur. + * + * + * ```js + * const { List } = require("immutable") + * const list = List([ 0, 1, 2, List([ 3, 4 ])]) + * list.deleteIn([3, 0]); + * // List [ 0, 1, 2, List [ 4 ] ] + * ``` + * + * Note: `deleteIn` *cannot* be safely used in `withMutations`. + * + * @alias removeIn + */ + deleteIn(keyPath: Iterable): this; + removeIn(keyPath: Iterable): this; + + /** + * Note: `updateIn` can be used in `withMutations`. + * + * @see `Map#updateIn` + */ + updateIn(keyPath: Iterable, notSetValue: any, updater: (value: any) => any): this; + updateIn(keyPath: Iterable, updater: (value: any) => any): this; + + /** + * Note: `mergeIn` can be used in `withMutations`. + * + * @see `Map#mergeIn` + */ + mergeIn(keyPath: Iterable, ...collections: Array): this; + + /** + * Note: `mergeDeepIn` can be used in `withMutations`. + * + * @see `Map#mergeDeepIn` + */ + mergeDeepIn(keyPath: Iterable, ...collections: Array): this; + + // Transient changes + + /** + * Note: Not all methods can be safely used on a mutable collection or within + * `withMutations`! Check the documentation for each method to see if it + * allows being used in `withMutations`. + * + * @see `Map#withMutations` + */ + withMutations(mutator: (mutable: this) => any): this; + + /** + * An alternative API for withMutations() + * + * Note: Not all methods can be safely used on a mutable collection or within + * `withMutations`! Check the documentation for each method to see if it + * allows being used in `withMutations`. + * + * @see `Map#asMutable` + */ + asMutable(): this; + + /** + * @see `Map#asImmutable` + */ + asImmutable(): this; + + // Sequence algorithms + + /** + * Returns a new List with other values or collections concatenated to this one. + */ + concat(...valuesOrCollections: Array | C>): List; + + /** + * Returns a new List with values passed through a + * `mapper` function. + * + * + * ```js + * List([ 1, 2 ]).map(x => 10 * x) + * // List [ 10, 20 ] + * ``` + * + * Note: `map()` always returns a new instance, even if it produced the same + * value at every step. + */ + map( + mapper: (value: T, key: number, iter: this) => M, + context?: any + ): List; + + /** + * Flat-maps the List, returning a new List. + * + * Similar to `list.map(...).flatten(true)`. + */ + flatMap( + mapper: (value: T, key: number, iter: this) => Iterable, + context?: any + ): List; + + /** + * Returns a new List with only the values for which the `predicate` + * function returns true. + * + * Note: `filter()` always returns a new instance, even if it results in + * not filtering out any values. + */ + filter( + predicate: (value: T, index: number, iter: this) => value is F, + context?: any + ): List; + filter( + predicate: (value: T, index: number, iter: this) => any, + context?: any + ): this; + + /** + * Returns a List "zipped" with the provided collection. + * + * Like `zipWith`, but using the default `zipper`: creating an `Array`. + * + * ```js + * const a = List([ 1, 2, 3 ]); + * const b = List([ 4, 5, 6 ]); + * const c = a.zip(b); // List [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] + * ``` + */ + zip(other: Collection): List<[T,U]>; + + /** + * Returns a List "zipped" with the provided collection. + * + * Like `zipWith`, but using the default `zipper`: creating an `Array`. + * + * ```js + * const a = List([ 1, 2, 3 ]); + * const b = List([ 4, 5, 6 ]); + * const c = a.zip(b); // List [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] + * ``` + */ + zip(other: Collection, other2: Collection): List<[T,U,V]>; + + /** + * Returns a List "zipped" with the provided collections. + * + * Like `zipWith`, but using the default `zipper`: creating an `Array`. + * + * + * ```js + * const a = List([ 1, 2, 3 ]); + * const b = List([ 4, 5, 6 ]); + * const c = a.zip(b); // List [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] + * ``` + */ + zip(...collections: Array>): List; + + /** + * Returns a List "zipped" with the provided collections by using a + * custom `zipper` function. + * + * + * ```js + * const a = List([ 1, 2, 3 ]); + * const b = List([ 4, 5, 6 ]); + * const c = a.zipWith((a, b) => a + b, b); + * // List [ 5, 7, 9 ] + * ``` + */ + zipWith( + zipper: (value: T, otherValue: U) => Z, + otherCollection: Collection + ): List; + zipWith( + zipper: (value: T, otherValue: U, thirdValue: V) => Z, + otherCollection: Collection, + thirdCollection: Collection + ): List; + zipWith( + zipper: (...any: Array) => Z, + ...collections: Array> + ): List; + } + + + /** + * Immutable Map is an unordered Collection.Keyed of (key, value) pairs with + * `O(log32 N)` gets and `O(log32 N)` persistent sets. + * + * Iteration order of a Map is undefined, however is stable. Multiple + * iterations of the same Map will iterate in the same order. + * + * Map's keys can be of any type, and use `Immutable.is` to determine key + * equality. This allows the use of any value (including NaN) as a key. + * + * Because `Immutable.is` returns equality based on value semantics, and + * Immutable collections are treated as values, any Immutable collection may + * be used as a key. + * + * + * ```js + * const { Map, List } = require('immutable'); + * Map().set(List([ 1 ]), 'listofone').get(List([ 1 ])); + * // 'listofone' + * ``` + * + * Any JavaScript object may be used as a key, however strict identity is used + * to evaluate key equality. Two similar looking objects will represent two + * different keys. + * + * Implemented by a hash-array mapped trie. + */ + export module Map { + + /** + * True if the provided value is a Map + * + * ```js + * const { Map } = require('immutable') + * Map.isMap({}) // false + * Map.isMap(Map()) // true + * ``` + */ + function isMap(maybeMap: any): maybeMap is Map; + + /** + * Creates a new Map from alternating keys and values + * + * + * ```js + * const { Map } = require('immutable') + * Map.of( + * 'key', 'value', + * 'numerical value', 3, + * 0, 'numerical key' + * ) + * // Map { 0: "numerical key", "key": "value", "numerical value": 3 } + * ``` + * + * @deprecated Use Map([ [ 'k', 'v' ] ]) or Map({ k: 'v' }) + */ + function of(...keyValues: Array): Map; + } + + /** + * Creates a new Immutable Map. + * + * Created with the same key value pairs as the provided Collection.Keyed or + * JavaScript Object or expects a Collection of [K, V] tuple entries. + * + * + * ```js + * const { Map } = require('immutable') + * Map({ key: "value" }) + * Map([ [ "key", "value" ] ]) + * ``` + * + * Keep in mind, when using JS objects to construct Immutable Maps, that + * JavaScript Object properties are always strings, even if written in a + * quote-less shorthand, while Immutable Maps accept keys of any type. + * + * + * ```js + * let obj = { 1: "one" } + * Object.keys(obj) // [ "1" ] + * assert.equal(obj["1"], obj[1]) // "one" === "one" + * + * let map = Map(obj) + * assert.notEqual(map.get("1"), map.get(1)) // "one" !== undefined + * ``` + * + * Property access for JavaScript Objects first converts the key to a string, + * but since Immutable Map keys can be of any type the argument to `get()` is + * not altered. + */ + export function Map(collection: Iterable<[K, V]>): Map; + export function Map(collection: Iterable>): Map; + export function Map(obj: {[key: string]: V}): Map; + export function Map(): Map; + export function Map(): Map; + + export interface Map extends Collection.Keyed { + + /** + * The number of entries in this Map. + */ + readonly size: number; + + // Persistent changes + + /** + * Returns a new Map also containing the new key, value pair. If an equivalent + * key already exists in this Map, it will be replaced. + * + * + * ```js + * const { Map } = require('immutable') + * const originalMap = Map() + * const newerMap = originalMap.set('key', 'value') + * const newestMap = newerMap.set('key', 'newer value') + * + * originalMap + * // Map {} + * newerMap + * // Map { "key": "value" } + * newestMap + * // Map { "key": "newer value" } + * ``` + * + * Note: `set` can be used in `withMutations`. + */ + set(key: K, value: V): this; + + /** + * Returns a new Map which excludes this `key`. + * + * Note: `delete` cannot be safely used in IE8, but is provided to mirror + * the ES6 collection API. + * + * + * ```js + * const { Map } = require('immutable') + * const originalMap = Map({ + * key: 'value', + * otherKey: 'other value' + * }) + * // Map { "key": "value", "otherKey": "other value" } + * originalMap.delete('otherKey') + * // Map { "key": "value" } + * ``` + * + * Note: `delete` can be used in `withMutations`. + * + * @alias remove + */ + delete(key: K): this; + remove(key: K): this; + + /** + * Returns a new Map which excludes the provided `keys`. + * + * ```js + * const { Map } = require('immutable') + * const names = Map({ a: "Aaron", b: "Barry", c: "Connor" }) + * names.deleteAll([ 'a', 'c' ]) + * // Map { "b": "Barry" } + * ``` + * + * Note: `deleteAll` can be used in `withMutations`. + * + * @alias removeAll + */ + deleteAll(keys: Iterable): this; + removeAll(keys: Iterable): this; + + /** + * Returns a new Map containing no keys or values. + * + * + * ```js + * const { Map } = require('immutable') + * Map({ key: 'value' }).clear() + * // Map {} + * ``` + * + * Note: `clear` can be used in `withMutations`. + */ + clear(): this; + + /** + * Returns a new Map having updated the value at this `key` with the return + * value of calling `updater` with the existing value. + * + * Similar to: `map.set(key, updater(map.get(key)))`. + * + * + * ```js + * const { Map } = require('immutable') + * const aMap = Map({ key: 'value' }) + * const newMap = aMap.update('key', value => value + value) + * // Map { "key": "valuevalue" } + * ``` + * + * This is most commonly used to call methods on collections within a + * structure of data. For example, in order to `.push()` onto a nested `List`, + * `update` and `push` can be used together: + * + * + * ```js + * const aMap = Map({ nestedList: List([ 1, 2, 3 ]) }) + * const newMap = aMap.update('nestedList', list => list.push(4)) + * // Map { "nestedList": List [ 1, 2, 3, 4 ] } + * ``` + * + * When a `notSetValue` is provided, it is provided to the `updater` + * function when the value at the key does not exist in the Map. + * + * + * ```js + * const aMap = Map({ key: 'value' }) + * const newMap = aMap.update('noKey', 'no value', value => value + value) + * // Map { "key": "value", "noKey": "no valueno value" } + * ``` + * + * However, if the `updater` function returns the same value it was called + * with, then no change will occur. This is still true if `notSetValue` + * is provided. + * + * + * ```js + * const aMap = Map({ apples: 10 }) + * const newMap = aMap.update('oranges', 0, val => val) + * // Map { "apples": 10 } + * assert.strictEqual(newMap, map); + * ``` + * + * For code using ES2015 or later, using `notSetValue` is discourged in + * favor of function parameter default values. This helps to avoid any + * potential confusion with identify functions as described above. + * + * The previous example behaves differently when written with default values: + * + * + * ```js + * const aMap = Map({ apples: 10 }) + * const newMap = aMap.update('oranges', (val = 0) => val) + * // Map { "apples": 10, "oranges": 0 } + * ``` + * + * If no key is provided, then the `updater` function return value is + * returned as well. + * + * + * ```js + * const aMap = Map({ key: 'value' }) + * const result = aMap.update(aMap => aMap.get('key')) + * // "value" + * ``` + * + * This can be very useful as a way to "chain" a normal function into a + * sequence of methods. RxJS calls this "let" and lodash calls it "thru". + * + * For example, to sum the values in a Map + * + * + * ```js + * function sum(collection) { + * return collection.reduce((sum, x) => sum + x, 0) + * } + * + * Map({ x: 1, y: 2, z: 3 }) + * .map(x => x + 1) + * .filter(x => x % 2 === 0) + * .update(sum) + * // 6 + * ``` + * + * Note: `update(key)` can be used in `withMutations`. + */ + update(key: K, notSetValue: V, updater: (value: V) => V): this; + update(key: K, updater: (value: V) => V): this; + update(updater: (value: this) => R): R; + + /** + * Returns a new Map resulting from merging the provided Collections + * (or JS objects) into this Map. In other words, this takes each entry of + * each collection and sets it on this Map. + * + * If any of the values provided to `merge` are not Collection (would return + * false for `isCollection`) then they are deeply converted + * via `fromJS` before being merged. However, if the value is an + * Collection but includes non-collection JS objects or arrays, those nested + * values will be preserved. + * + * + * ```js + * const { Map } = require('immutable') + * const one = Map({ a: 10, b: 20, c: 30 }) + * const two = Map({ b: 40, a: 50, d: 60 }) + * one.merge(two) // Map { "a": 50, "b": 40, "c": 30, "d": 60 } + * two.merge(one) // Map { "b": 20, "a": 10, "d": 60, "c": 30 } + * ``` + * + * Note: `merge` can be used in `withMutations`. + */ + merge(...collections: Array | {[key: string]: V}>): this; + + /** + * Like `merge()`, `mergeWith()` returns a new Map resulting from merging + * the provided Collections (or JS objects) into this Map, but uses the + * `merger` function for dealing with conflicts. + * + * + * ```js + * const { Map } = require('immutable') + * const one = Map({ a: 10, b: 20, c: 30 }) + * const two = Map({ b: 40, a: 50, d: 60 }) + * one.mergeWith((oldVal, newVal) => oldVal / newVal, two) + * // { "a": 0.2, "b": 0.5, "c": 30, "d": 60 } + * two.mergeWith((oldVal, newVal) => oldVal / newVal, one) + * // { "b": 2, "a": 5, "d": 60, "c": 30 } + * ``` + * + * Note: `mergeWith` can be used in `withMutations`. + */ + mergeWith( + merger: (oldVal: V, newVal: V, key: K) => V, + ...collections: Array | {[key: string]: V}> + ): this; + + /** + * Like `merge()`, but when two Collections conflict, it merges them as well, + * recursing deeply through the nested data. + * + * + * ```js + * const { Map } = require('immutable') + * const one = Map({ a: Map({ x: 10, y: 10 }), b: Map({ x: 20, y: 50 }) }) + * const two = Map({ a: Map({ x: 2 }), b: Map({ y: 5 }), c: Map({ z: 3 }) }) + * one.mergeDeep(two) + * // Map { + * // "a": Map { "x": 2, "y": 10 }, + * // "b": Map { "x": 20, "y": 5 }, + * // "c": Map { "z": 3 } + * // } + * ``` + * + * Note: `mergeDeep` can be used in `withMutations`. + */ + mergeDeep(...collections: Array | {[key: string]: V}>): this; + + /** + * Like `mergeDeep()`, but when two non-Collections conflict, it uses the + * `merger` function to determine the resulting value. + * + * + * ```js + * const { Map } = require('immutable') + * const one = Map({ a: Map({ x: 10, y: 10 }), b: Map({ x: 20, y: 50 }) }) + * const two = Map({ a: Map({ x: 2 }), b: Map({ y: 5 }), c: Map({ z: 3 }) }) + * one.mergeDeepWith((oldVal, newVal) => oldVal / newVal, two) + * // Map { + * // "a": Map { "x": 5, "y": 10 }, + * // "b": Map { "x": 20, "y": 10 }, + * // "c": Map { "z": 3 } + * // } + * ``` + + * Note: `mergeDeepWith` can be used in `withMutations`. + */ + mergeDeepWith( + merger: (oldVal: V, newVal: V, key: K) => V, + ...collections: Array | {[key: string]: V}> + ): this; + + + // Deep persistent changes + + /** + * Returns a new Map having set `value` at this `keyPath`. If any keys in + * `keyPath` do not exist, a new immutable Map will be created at that key. + * + * + * ```js + * const { Map } = require('immutable') + * const originalMap = Map({ + * subObject: Map({ + * subKey: 'subvalue', + * subSubObject: Map({ + * subSubKey: 'subSubValue' + * }) + * }) + * }) + * + * const newMap = originalMap.setIn(['subObject', 'subKey'], 'ha ha!') + * // Map { + * // "subObject": Map { + * // "subKey": "ha ha!", + * // "subSubObject": Map { "subSubKey": "subSubValue" } + * // } + * // } + * + * const newerMap = originalMap.setIn( + * ['subObject', 'subSubObject', 'subSubKey'], + * 'ha ha ha!' + * ) + * // Map { + * // "subObject": Map { + * // "subKey": "ha ha!", + * // "subSubObject": Map { "subSubKey": "ha ha ha!" } + * // } + * // } + * ``` + * + * If any key in the path exists but does not have a `.set()` method + * (such as Map and List), an error will be throw. + * + * Note: `setIn` can be used in `withMutations`. + */ + setIn(keyPath: Iterable, value: any): this; + + /** + * Returns a new Map having removed the value at this `keyPath`. If any keys + * in `keyPath` do not exist, no change will occur. + * + * Note: `deleteIn` can be used in `withMutations`. + * + * @alias removeIn + */ + deleteIn(keyPath: Iterable): this; + removeIn(keyPath: Iterable): this; + + /** + * Returns a new Map having applied the `updater` to the entry found at the + * keyPath. + * + * This is most commonly used to call methods on collections nested within a + * structure of data. For example, in order to `.push()` onto a nested `List`, + * `updateIn` and `push` can be used together: + * + * + * ```js + * const { Map, List } = require('immutable') + * const map = Map({ inMap: Map({ inList: List([ 1, 2, 3 ]) }) }) + * const newMap = map.updateIn(['inMap', 'inList'], list => list.push(4)) + * // Map { "inMap": Map { "inList": List [ 1, 2, 3, 4 ] } } + * ``` + * + * If any keys in `keyPath` do not exist, new Immutable `Map`s will + * be created at those keys. If the `keyPath` does not already contain a + * value, the `updater` function will be called with `notSetValue`, if + * provided, otherwise `undefined`. + * + * + * ```js + * const map = Map({ a: Map({ b: Map({ c: 10 }) }) }) + * const newMap = map.updateIn(['a', 'b', 'c'], val => val * 2) + * // Map { "a": Map { "b": Map { "c": 20 } } } + * ``` + * + * If the `updater` function returns the same value it was called with, then + * no change will occur. This is still true if `notSetValue` is provided. + * + * + * ```js + * const map = Map({ a: Map({ b: Map({ c: 10 }) }) }) + * const newMap = map.updateIn(['a', 'b', 'x'], 100, val => val) + * // Map { "a": Map { "b": Map { "c": 10 } } } + * assert.strictEqual(newMap, aMap) + * ``` + * + * For code using ES2015 or later, using `notSetValue` is discourged in + * favor of function parameter default values. This helps to avoid any + * potential confusion with identify functions as described above. + * + * The previous example behaves differently when written with default values: + * + * + * ```js + * const map = Map({ a: Map({ b: Map({ c: 10 }) }) }) + * const newMap = map.updateIn(['a', 'b', 'x'], (val = 100) => val) + * // Map { "a": Map { "b": Map { "c": 10, "x": 100 } } } + * ``` + * + * If any key in the path exists but does not have a .set() method (such as + * Map and List), an error will be thrown. + */ + updateIn(keyPath: Iterable, notSetValue: any, updater: (value: any) => any): this; + updateIn(keyPath: Iterable, updater: (value: any) => any): this; + + /** + * A combination of `updateIn` and `merge`, returning a new Map, but + * performing the merge at a point arrived at by following the keyPath. + * In other words, these two lines are equivalent: + * + * ```js + * map.updateIn(['a', 'b', 'c'], abc => abc.merge(y)) + * map.mergeIn(['a', 'b', 'c'], y) + * ``` + * + * Note: `mergeIn` can be used in `withMutations`. + */ + mergeIn(keyPath: Iterable, ...collections: Array): this; + + /** + * A combination of `updateIn` and `mergeDeep`, returning a new Map, but + * performing the deep merge at a point arrived at by following the keyPath. + * In other words, these two lines are equivalent: + * + * ```js + * map.updateIn(['a', 'b', 'c'], abc => abc.mergeDeep(y)) + * map.mergeDeepIn(['a', 'b', 'c'], y) + * ``` + * + * Note: `mergeDeepIn` can be used in `withMutations`. + */ + mergeDeepIn(keyPath: Iterable, ...collections: Array): this; + + // Transient changes + + /** + * Every time you call one of the above functions, a new immutable Map is + * created. If a pure function calls a number of these to produce a final + * return value, then a penalty on performance and memory has been paid by + * creating all of the intermediate immutable Maps. + * + * If you need to apply a series of mutations to produce a new immutable + * Map, `withMutations()` creates a temporary mutable copy of the Map which + * can apply mutations in a highly performant manner. In fact, this is + * exactly how complex mutations like `merge` are done. + * + * As an example, this results in the creation of 2, not 4, new Maps: + * + * + * ```js + * const { Map } = require('immutable') + * const map1 = Map() + * const map2 = map1.withMutations(map => { + * map.set('a', 1).set('b', 2).set('c', 3) + * }) + * assert.equal(map1.size, 0) + * assert.equal(map2.size, 3) + * ``` + * + * Note: Not all methods can be used on a mutable collection or within + * `withMutations`! Read the documentation for each method to see if it + * is safe to use in `withMutations`. + */ + withMutations(mutator: (mutable: this) => any): this; + + /** + * Another way to avoid creation of intermediate Immutable maps is to create + * a mutable copy of this collection. Mutable copies *always* return `this`, + * and thus shouldn't be used for equality. Your function should never return + * a mutable copy of a collection, only use it internally to create a new + * collection. If possible, use `withMutations` as it provides an easier to + * use API. + * + * Note: if the collection is already mutable, `asMutable` returns itself. + * + * Note: Not all methods can be used on a mutable collection or within + * `withMutations`! Read the documentation for each method to see if it + * is safe to use in `withMutations`. + */ + asMutable(): this; + + /** + * The yin to `asMutable`'s yang. Because it applies to mutable collections, + * this operation is *mutable* and returns itself. Once performed, the mutable + * copy has become immutable and can be safely returned from a function. + */ + asImmutable(): this; + + // Sequence algorithms + + /** + * Returns a new Map with other collections concatenated to this one. + */ + concat(...collections: Array>): Map; + concat(...collections: Array<{[key: string]: C}>): Map; + + /** + * Returns a new Map with values passed through a + * `mapper` function. + * + * Map({ a: 1, b: 2 }).map(x => 10 * x) + * // Map { a: 10, b: 20 } + * + * Note: `map()` always returns a new instance, even if it produced the same + * value at every step. + */ + map( + mapper: (value: V, key: K, iter: this) => M, + context?: any + ): Map; + + /** + * @see Collection.Keyed.mapKeys + */ + mapKeys( + mapper: (key: K, value: V, iter: this) => M, + context?: any + ): Map; + + /** + * @see Collection.Keyed.mapEntries + */ + mapEntries( + mapper: (entry: [K, V], index: number, iter: this) => [KM, VM], + context?: any + ): Map; + + /** + * Flat-maps the Map, returning a new Map. + * + * Similar to `data.map(...).flatten(true)`. + */ + flatMap( + mapper: (value: V, key: K, iter: this) => Iterable<[KM, VM]>, + context?: any + ): Map; + + /** + * Returns a new Map with only the entries for which the `predicate` + * function returns true. + * + * Note: `filter()` always returns a new instance, even if it results in + * not filtering out any values. + */ + filter( + predicate: (value: V, key: K, iter: this) => value is F, + context?: any + ): Map; + filter( + predicate: (value: V, key: K, iter: this) => any, + context?: any + ): this; + } + + + /** + * A type of Map that has the additional guarantee that the iteration order of + * entries will be the order in which they were set(). + * + * The iteration behavior of OrderedMap is the same as native ES6 Map and + * JavaScript Object. + * + * Note that `OrderedMap` are more expensive than non-ordered `Map` and may + * consume more memory. `OrderedMap#set` is amortized O(log32 N), but not + * stable. + */ + + export module OrderedMap { + + /** + * True if the provided value is an OrderedMap. + */ + function isOrderedMap(maybeOrderedMap: any): maybeOrderedMap is OrderedMap; + } + + /** + * Creates a new Immutable OrderedMap. + * + * Created with the same key value pairs as the provided Collection.Keyed or + * JavaScript Object or expects a Collection of [K, V] tuple entries. + * + * The iteration order of key-value pairs provided to this constructor will + * be preserved in the OrderedMap. + * + * let newOrderedMap = OrderedMap({key: "value"}) + * let newOrderedMap = OrderedMap([["key", "value"]]) + * + */ + export function OrderedMap(collection: Iterable<[K, V]>): OrderedMap; + export function OrderedMap(collection: Iterable>): OrderedMap; + export function OrderedMap(obj: {[key: string]: V}): OrderedMap; + export function OrderedMap(): OrderedMap; + export function OrderedMap(): OrderedMap; + + export interface OrderedMap extends Map { + + /** + * The number of entries in this OrderedMap. + */ + readonly size: number; + + // Sequence algorithms + + /** + * Returns a new OrderedMap with other collections concatenated to this one. + */ + concat(...collections: Array>): OrderedMap; + concat(...collections: Array<{[key: string]: C}>): OrderedMap; + + /** + * Returns a new OrderedMap with values passed through a + * `mapper` function. + * + * OrderedMap({ a: 1, b: 2 }).map(x => 10 * x) + * // OrderedMap { "a": 10, "b": 20 } + * + * Note: `map()` always returns a new instance, even if it produced the same + * value at every step. + */ + map( + mapper: (value: V, key: K, iter: this) => M, + context?: any + ): OrderedMap; + + /** + * @see Collection.Keyed.mapKeys + */ + mapKeys( + mapper: (key: K, value: V, iter: this) => M, + context?: any + ): OrderedMap; + + /** + * @see Collection.Keyed.mapEntries + */ + mapEntries( + mapper: (entry: [K, V], index: number, iter: this) => [KM, VM], + context?: any + ): OrderedMap; + + /** + * Flat-maps the OrderedMap, returning a new OrderedMap. + * + * Similar to `data.map(...).flatten(true)`. + */ + flatMap( + mapper: (value: V, key: K, iter: this) => Iterable<[KM, VM]>, + context?: any + ): OrderedMap; + + /** + * Returns a new OrderedMap with only the entries for which the `predicate` + * function returns true. + * + * Note: `filter()` always returns a new instance, even if it results in + * not filtering out any values. + */ + filter( + predicate: (value: V, key: K, iter: this) => value is F, + context?: any + ): OrderedMap; + filter( + predicate: (value: V, key: K, iter: this) => any, + context?: any + ): this; + } + + + /** + * A Collection of unique values with `O(log32 N)` adds and has. + * + * When iterating a Set, the entries will be (value, value) pairs. Iteration + * order of a Set is undefined, however is stable. Multiple iterations of the + * same Set will iterate in the same order. + * + * Set values, like Map keys, may be of any type. Equality is determined using + * `Immutable.is`, enabling Sets to uniquely include other Immutable + * collections, custom value types, and NaN. + */ + export module Set { + + /** + * True if the provided value is a Set + */ + function isSet(maybeSet: any): maybeSet is Set; + + /** + * Creates a new Set containing `values`. + */ + function of(...values: Array): Set; + + /** + * `Set.fromKeys()` creates a new immutable Set containing the keys from + * this Collection or JavaScript Object. + */ + function fromKeys(iter: Collection): Set; + function fromKeys(obj: {[key: string]: any}): Set; + + /** + * `Set.intersect()` creates a new immutable Set that is the intersection of + * a collection of other sets. + * + * ```js + * const { Set } = require('immutable') + * const intersected = Set.intersect([ + * Set([ 'a', 'b', 'c' ]) + * Set([ 'c', 'a', 't' ]) + * ]) + * // Set [ "a", "c"" ] + * ``` + */ + function intersect(sets: Iterable>): Set; + + /** + * `Set.union()` creates a new immutable Set that is the union of a + * collection of other sets. + * + * ```js + * const { Set } = require('immutable') + * const unioned = Set.union([ + * Set([ 'a', 'b', 'c' ]) + * Set([ 'c', 'a', 't' ]) + * ]) + * // Set [ "a", "b", "c", "t"" ] + * ``` + */ + function union(sets: Iterable>): Set; + } + + /** + * Create a new immutable Set containing the values of the provided + * collection-like. + */ + export function Set(): Set; + export function Set(): Set; + export function Set(collection: Iterable): Set; + + export interface Set extends Collection.Set { + + /** + * The number of items in this Set. + */ + readonly size: number; + + // Persistent changes + + /** + * Returns a new Set which also includes this value. + * + * Note: `add` can be used in `withMutations`. + */ + add(value: T): this; + + /** + * Returns a new Set which excludes this value. + * + * Note: `delete` can be used in `withMutations`. + * + * Note: `delete` **cannot** be safely used in IE8, use `remove` if + * supporting old browsers. + * + * @alias remove + */ + delete(value: T): this; + remove(value: T): this; + + /** + * Returns a new Set containing no values. + * + * Note: `clear` can be used in `withMutations`. + */ + clear(): this; + + /** + * Returns a Set including any value from `collections` that does not already + * exist in this Set. + * + * Note: `union` can be used in `withMutations`. + * @alias merge + */ + union(...collections: Array | Array>): this; + merge(...collections: Array | Array>): this; + + /** + * Returns a Set which has removed any values not also contained + * within `collections`. + * + * Note: `intersect` can be used in `withMutations`. + */ + intersect(...collections: Array | Array>): this; + + /** + * Returns a Set excluding any values contained within `collections`. + * + * Note: `subtract` can be used in `withMutations`. + */ + subtract(...collections: Array | Array>): this; + + + // Transient changes + + /** + * Note: Not all methods can be used on a mutable collection or within + * `withMutations`! Check the documentation for each method to see if it + * mentions being safe to use in `withMutations`. + * + * @see `Map#withMutations` + */ + withMutations(mutator: (mutable: this) => any): this; + + /** + * Note: Not all methods can be used on a mutable collection or within + * `withMutations`! Check the documentation for each method to see if it + * mentions being safe to use in `withMutations`. + * + * @see `Map#asMutable` + */ + asMutable(): this; + + /** + * @see `Map#asImmutable` + */ + asImmutable(): this; + + // Sequence algorithms + + /** + * Returns a new Set with other collections concatenated to this one. + */ + concat(...valuesOrCollections: Array | C>): Set; + + /** + * Returns a new Set with values passed through a + * `mapper` function. + * + * Set([1,2]).map(x => 10 * x) + * // Set [10,20] + * + * Note: `map()` always returns a new instance, even if it produced the same + * value at every step. + */ + map( + mapper: (value: T, key: T, iter: this) => M, + context?: any + ): Set; + + /** + * Flat-maps the Set, returning a new Set. + * + * Similar to `set.map(...).flatten(true)`. + */ + flatMap( + mapper: (value: T, key: T, iter: this) => Iterable, + context?: any + ): Set; + + /** + * Returns a new Set with only the values for which the `predicate` + * function returns true. + * + * Note: `filter()` always returns a new instance, even if it results in + * not filtering out any values. + */ + filter( + predicate: (value: T, key: T, iter: this) => value is F, + context?: any + ): Set; + filter( + predicate: (value: T, key: T, iter: this) => any, + context?: any + ): this; + } + + + /** + * A type of Set that has the additional guarantee that the iteration order of + * values will be the order in which they were `add`ed. + * + * The iteration behavior of OrderedSet is the same as native ES6 Set. + * + * Note that `OrderedSet` are more expensive than non-ordered `Set` and may + * consume more memory. `OrderedSet#add` is amortized O(log32 N), but not + * stable. + */ + export module OrderedSet { + + /** + * True if the provided value is an OrderedSet. + */ + function isOrderedSet(maybeOrderedSet: any): boolean; + + /** + * Creates a new OrderedSet containing `values`. + */ + function of(...values: Array): OrderedSet; + + /** + * `OrderedSet.fromKeys()` creates a new immutable OrderedSet containing + * the keys from this Collection or JavaScript Object. + */ + function fromKeys(iter: Collection): OrderedSet; + function fromKeys(obj: {[key: string]: any}): OrderedSet; + } + + /** + * Create a new immutable OrderedSet containing the values of the provided + * collection-like. + */ + export function OrderedSet(): OrderedSet; + export function OrderedSet(): OrderedSet; + export function OrderedSet(collection: Iterable): OrderedSet; + + export interface OrderedSet extends Set { + + /** + * The number of items in this OrderedSet. + */ + readonly size: number; + + // Sequence algorithms + + /** + * Returns a new OrderedSet with other collections concatenated to this one. + */ + concat(...valuesOrCollections: Array | C>): OrderedSet; + + /** + * Returns a new Set with values passed through a + * `mapper` function. + * + * OrderedSet([ 1, 2 ]).map(x => 10 * x) + * // OrderedSet [10, 20] + * + * Note: `map()` always returns a new instance, even if it produced the same + * value at every step. + */ + map( + mapper: (value: T, key: T, iter: this) => M, + context?: any + ): OrderedSet; + + /** + * Flat-maps the OrderedSet, returning a new OrderedSet. + * + * Similar to `set.map(...).flatten(true)`. + */ + flatMap( + mapper: (value: T, key: T, iter: this) => Iterable, + context?: any + ): OrderedSet; + + /** + * Returns a new OrderedSet with only the values for which the `predicate` + * function returns true. + * + * Note: `filter()` always returns a new instance, even if it results in + * not filtering out any values. + */ + filter( + predicate: (value: T, key: T, iter: this) => value is F, + context?: any + ): OrderedSet; + filter( + predicate: (value: T, key: T, iter: this) => any, + context?: any + ): this; + + /** + * Returns an OrderedSet of the same type "zipped" with the provided + * collections. + * + * @see IndexedIterator.zip + * + * Like `zipWith`, but using the default `zipper`: creating an `Array`. + * + * ```js + * const a = OrderedSet([ 1, 2, 3 ]) + * const b = OrderedSet([ 4, 5, 6 ]) + * const c = a.zip(b) + * // OrderedSet [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] + * ``` + */ + zip(other: Collection): OrderedSet<[T,U]>; + + /** + * Returns an OrderedSet of the same type "zipped" with the provided + * collections. + * + * @see IndexedIterator.zip + * + * Like `zipWith`, but using the default `zipper`: creating an `Array`. + * + * ```js + * const a = OrderedSet([ 1, 2, 3 ]) + * const b = OrderedSet([ 4, 5, 6 ]) + * const c = a.zip(b) + * // OrderedSet [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] + * ``` + */ + zip(other1: Collection, other2: Collection): OrderedSet<[T,U,V]>; + + /** + * Returns an OrderedSet of the same type "zipped" with the provided + * collections. + * + * @see IndexedIterator.zip + * + * Like `zipWith`, but using the default `zipper`: creating an `Array`. + * + * ```js + * const a = OrderedSet([ 1, 2, 3 ]) + * const b = OrderedSet([ 4, 5, 6 ]) + * const c = a.zip(b) + * // OrderedSet [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] + * ``` + */ + zip(...collections: Array>): OrderedSet; + + /** + * Returns an OrderedSet of the same type "zipped" with the provided + * collections by using a custom `zipper` function. + * + * @see IndexedIterator.zipWith + */ + zipWith( + zipper: (value: T, otherValue: U) => Z, + otherCollection: Collection + ): OrderedSet; + zipWith( + zipper: (value: T, otherValue: U, thirdValue: V) => Z, + otherCollection: Collection, + thirdCollection: Collection + ): OrderedSet; + zipWith( + zipper: (...any: Array) => Z, + ...collections: Array> + ): OrderedSet; + + } + + + /** + * Stacks are indexed collections which support very efficient O(1) addition + * and removal from the front using `unshift(v)` and `shift()`. + * + * For familiarity, Stack also provides `push(v)`, `pop()`, and `peek()`, but + * be aware that they also operate on the front of the list, unlike List or + * a JavaScript Array. + * + * Note: `reverse()` or any inherent reverse traversal (`reduceRight`, + * `lastIndexOf`, etc.) is not efficient with a Stack. + * + * Stack is implemented with a Single-Linked List. + */ + export module Stack { + + /** + * True if the provided value is a Stack + */ + function isStack(maybeStack: any): maybeStack is Stack; + + /** + * Creates a new Stack containing `values`. + */ + function of(...values: Array): Stack; + } + + /** + * Create a new immutable Stack containing the values of the provided + * collection-like. + * + * The iteration order of the provided collection is preserved in the + * resulting `Stack`. + */ + export function Stack(): Stack; + export function Stack(): Stack; + export function Stack(collection: Iterable): Stack; + + export interface Stack extends Collection.Indexed { + + /** + * The number of items in this Stack. + */ + readonly size: number; + + // Reading values + + /** + * Alias for `Stack.first()`. + */ + peek(): T | undefined; + + + // Persistent changes + + /** + * Returns a new Stack with 0 size and no values. + * + * Note: `clear` can be used in `withMutations`. + */ + clear(): Stack; + + /** + * Returns a new Stack with the provided `values` prepended, shifting other + * values ahead to higher indices. + * + * This is very efficient for Stack. + * + * Note: `unshift` can be used in `withMutations`. + */ + unshift(...values: Array): Stack; + + /** + * Like `Stack#unshift`, but accepts a collection rather than varargs. + * + * Note: `unshiftAll` can be used in `withMutations`. + */ + unshiftAll(iter: Iterable): Stack; + + /** + * Returns a new Stack with a size ones less than this Stack, excluding + * the first item in this Stack, shifting all other values to a lower index. + * + * Note: this differs from `Array#shift` because it returns a new + * Stack rather than the removed value. Use `first()` or `peek()` to get the + * first value in this Stack. + * + * Note: `shift` can be used in `withMutations`. + */ + shift(): Stack; + + /** + * Alias for `Stack#unshift` and is not equivalent to `List#push`. + */ + push(...values: Array): Stack; + + /** + * Alias for `Stack#unshiftAll`. + */ + pushAll(iter: Iterable): Stack; + + /** + * Alias for `Stack#shift` and is not equivalent to `List#pop`. + */ + pop(): Stack; + + + // Transient changes + + /** + * Note: Not all methods can be used on a mutable collection or within + * `withMutations`! Check the documentation for each method to see if it + * mentions being safe to use in `withMutations`. + * + * @see `Map#withMutations` + */ + withMutations(mutator: (mutable: this) => any): this; + + /** + * Note: Not all methods can be used on a mutable collection or within + * `withMutations`! Check the documentation for each method to see if it + * mentions being safe to use in `withMutations`. + * + * @see `Map#asMutable` + */ + asMutable(): this; + + /** + * @see `Map#asImmutable` + */ + asImmutable(): this; + + // Sequence algorithms + + /** + * Returns a new Stack with other collections concatenated to this one. + */ + concat(...valuesOrCollections: Array | C>): Stack; + + /** + * Returns a new Stack with values passed through a + * `mapper` function. + * + * Stack([ 1, 2 ]).map(x => 10 * x) + * // Stack [ 10, 20 ] + * + * Note: `map()` always returns a new instance, even if it produced the same + * value at every step. + */ + map( + mapper: (value: T, key: number, iter: this) => M, + context?: any + ): Stack; + + /** + * Flat-maps the Stack, returning a new Stack. + * + * Similar to `stack.map(...).flatten(true)`. + */ + flatMap( + mapper: (value: T, key: number, iter: this) => M, + context?: any + ): Stack; + + /** + * Returns a new Set with only the values for which the `predicate` + * function returns true. + * + * Note: `filter()` always returns a new instance, even if it results in + * not filtering out any values. + */ + filter( + predicate: (value: T, index: number, iter: this) => value is F, + context?: any + ): Set; + filter( + predicate: (value: T, index: number, iter: this) => any, + context?: any + ): this; + + /** + * Returns a Stack "zipped" with the provided collections. + * + * Like `zipWith`, but using the default `zipper`: creating an `Array`. + * + * ```js + * const a = Stack([ 1, 2, 3 ]); + * const b = Stack([ 4, 5, 6 ]); + * const c = a.zip(b); // Stack [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] + * ``` + */ + zip(other: Collection): Stack<[T,U]>; + + /** + * Returns a Stack "zipped" with the provided collections. + * + * Like `zipWith`, but using the default `zipper`: creating an `Array`. + * + * ```js + * const a = Stack([ 1, 2, 3 ]); + * const b = Stack([ 4, 5, 6 ]); + * const c = a.zip(b); // Stack [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] + * ``` + */ + zip(other: Collection, other2: Collection): Stack<[T,U,V]>; + + /** + * Returns a Stack "zipped" with the provided collections. + * + * Like `zipWith`, but using the default `zipper`: creating an `Array`. + * + * ```js + * const a = Stack([ 1, 2, 3 ]); + * const b = Stack([ 4, 5, 6 ]); + * const c = a.zip(b); // Stack [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] + * ``` + */ + zip(...collections: Array>): Stack; + + /** + * Returns a Stack "zipped" with the provided collections by using a + * custom `zipper` function. + * + * ```js + * const a = Stack([ 1, 2, 3 ]); + * const b = Stack([ 4, 5, 6 ]); + * const c = a.zipWith((a, b) => a + b, b); + * // Stack [ 5, 7, 9 ] + * ``` + */ + zipWith( + zipper: (value: T, otherValue: U) => Z, + otherCollection: Collection + ): Stack; + zipWith( + zipper: (value: T, otherValue: U, thirdValue: V) => Z, + otherCollection: Collection, + thirdCollection: Collection + ): Stack; + zipWith( + zipper: (...any: Array) => Z, + ...collections: Array> + ): Stack; + } + + + /** + * Returns a Seq.Indexed of numbers from `start` (inclusive) to `end` + * (exclusive), by `step`, where `start` defaults to 0, `step` to 1, and `end` to + * infinity. When `start` is equal to `end`, returns empty range. + * + * ```js + * const { Range } = require('immutable') + * Range() // [ 0, 1, 2, 3, ... ] + * Range(10) // [ 10, 11, 12, 13, ... ] + * Range(10, 15) // [ 10, 11, 12, 13, 14 ] + * Range(10, 30, 5) // [ 10, 15, 20, 25 ] + * Range(30, 10, 5) // [ 30, 25, 20, 15 ] + * Range(30, 30, 5) // [] + * ``` + */ + export function Range(start?: number, end?: number, step?: number): Seq.Indexed; + + + /** + * Returns a Seq.Indexed of `value` repeated `times` times. When `times` is + * not defined, returns an infinite `Seq` of `value`. + * + * ```js + * const { Repeat } = require('immutable') + * Repeat('foo') // [ 'foo', 'foo', 'foo', ... ] + * Repeat('bar', 4) // [ 'bar', 'bar', 'bar', 'bar' ] + * ``` + */ + export function Repeat(value: T, times?: number): Seq.Indexed; + + + /** + * Creates a new Class which produces Record instances. A record is similar to + * a JS object, but enforces a specific set of allowed string keys, and has + * default values. + * + * ```js + * const { Record } = require('immutable') + * const ABRecord = Record({ a: 1, b: 2 }) + * const myRecord = new ABRecord({ b: 3 }) + * ``` + * + * Records always have a value for the keys they define. `remove`ing a key + * from a record simply resets it to the default value for that key. + * + * ```js + * myRecord.size // 2 + * myRecord.get('a') // 1 + * myRecord.get('b') // 3 + * const myRecordWithoutB = myRecord.remove('b') + * myRecordWithoutB.get('b') // 2 + * myRecordWithoutB.size // 2 + * ``` + * + * Values provided to the constructor not found in the Record type will + * be ignored. For example, in this case, ABRecord is provided a key "x" even + * though only "a" and "b" have been defined. The value for "x" will be + * ignored for this record. + * + * ```js + * const myRecord = new ABRecord({ b: 3, x: 10 }) + * myRecord.get('x') // undefined + * ``` + * + * Because Records have a known set of string keys, property get access works + * as expected, however property sets will throw an Error. + * + * Note: IE8 does not support property access. Only use `get()` when + * supporting IE8. + * + * ```js + * myRecord.b // 3 + * myRecord.b = 5 // throws Error + * ``` + * + * Record Classes can be extended as well, allowing for custom methods on your + * Record. This is not a common pattern in functional environments, but is in + * many JS programs. + * + * ``` + * class ABRecord extends Record({ a: 1, b: 2 }) { + * getAB() { + * return this.a + this.b; + * } + * } + * + * var myRecord = new ABRecord({b: 3}) + * myRecord.getAB() // 4 + * ``` + */ + export module Record { + + /** + * True if `maybeRecord` is an instance of a Record. + */ + export function isRecord(maybeRecord: any): maybeRecord is Record.Instance; + + /** + * Records allow passing a second parameter to supply a descriptive name + * that appears when converting a Record to a string or in any error + * messages. A descriptive name for any record can be accessed by using this + * method. If one was not provided, the string "Record" is returned. + * + * ```js + * const { Record } = require('immutable') + * const Person = Record({ + * name: null + * }, 'Person') + * + * var me = Person({ name: 'My Name' }) + * me.toString() // "Person { "name": "My Name" }" + * Record.getDescriptiveName(me) // "Person" + * ``` + */ + export function getDescriptiveName(record: Instance): string; + + export interface Class { + (values?: Partial | Iterable<[string, any]>): Instance & Readonly; + new (values?: Partial | Iterable<[string, any]>): Instance & Readonly; + } + + export interface Instance { + + // Reading values + + has(key: string): key is keyof T; + get(key: K): T[K]; + + // Reading deep values + + hasIn(keyPath: Iterable): boolean; + getIn(keyPath: Iterable): any; + + // Value equality + + equals(other: any): boolean; + hashCode(): number; + + // Persistent changes + + set(key: K, value: T[K]): this; + update(key: K, updater: (value: T[K]) => T[K]): this; + merge(...collections: Array | Iterable<[string, any]>>): this; + mergeDeep(...collections: Array | Iterable<[string, any]>>): this; + + mergeWith( + merger: (oldVal: any, newVal: any, key: keyof T) => any, + ...collections: Array | Iterable<[string, any]>> + ): this; + mergeDeepWith( + merger: (oldVal: any, newVal: any, key: any) => any, + ...collections: Array | Iterable<[string, any]>> + ): this; + + /** + * Returns a new instance of this Record type with the value for the + * specific key set to its default value. + * + * @alias remove + */ + delete(key: K): this; + remove(key: K): this; + + /** + * Returns a new instance of this Record type with all values set + * to their default values. + */ + clear(): this; + + // Deep persistent changes + + setIn(keyPath: Iterable, value: any): this; + updateIn(keyPath: Iterable, updater: (value: any) => any): this; + mergeIn(keyPath: Iterable, ...collections: Array): this; + mergeDeepIn(keyPath: Iterable, ...collections: Array): this; + + /** + * @alias removeIn + */ + deleteIn(keyPath: Iterable): this; + removeIn(keyPath: Iterable): this; + + // Conversion to JavaScript types + + /** + * Deeply converts this Record to equivalent native JavaScript Object. + */ + toJS(): { [K in keyof T]: any }; + + /** + * Shallowly converts this Record to equivalent native JavaScript Object. + */ + toJSON(): T; + + /** + * Shallowly converts this Record to equivalent JavaScript Object. + */ + toObject(): T; + + // Transient changes + + /** + * Note: Not all methods can be used on a mutable collection or within + * `withMutations`! Only `set` may be used mutatively. + * + * @see `Map#withMutations` + */ + withMutations(mutator: (mutable: this) => any): this; + + /** + * @see `Map#asMutable` + */ + asMutable(): this; + + /** + * @see `Map#asImmutable` + */ + asImmutable(): this; + + // Sequence algorithms + + toSeq(): Seq.Keyed; + + [Symbol.iterator](): IterableIterator<[keyof T, T[keyof T]]>; + } + } + + export function Record(defaultValues: T, name?: string): Record.Class; + + + /** + * Represents a sequence of values, but may not be backed by a concrete data + * structure. + * + * **Seq is immutable** — Once a Seq is created, it cannot be + * changed, appended to, rearranged or otherwise modified. Instead, any + * mutative method called on a `Seq` will return a new `Seq`. + * + * **Seq is lazy** — Seq does as little work as necessary to respond to any + * method call. Values are often created during iteration, including implicit + * iteration when reducing or converting to a concrete data structure such as + * a `List` or JavaScript `Array`. + * + * For example, the following performs no work, because the resulting + * Seq's values are never iterated: + * + * ```js + * const { Seq } = require('immutable') + * const oddSquares = Seq([ 1, 2, 3, 4, 5, 6, 7, 8 ]) + * .filter(x => x % 2 !== 0) + * .map(x => x * x) + * ``` + * + * Once the Seq is used, it performs only the work necessary. In this + * example, no intermediate data structures are ever created, filter is only + * called three times, and map is only called once: + * + * ``` + * oddSquares.get(1)); // 9 + * ``` + * + * Seq allows for the efficient chaining of operations, + * allowing for the expression of logic that can otherwise be very tedious: + * + * ``` + * Seq({ a: 1, b: 1, c: 1}) + * .flip() + * .map(key => key.toUpperCase()) + * .flip() + * // Seq { A: 1, B: 1, C: 1 } + * ``` + * + * As well as expressing logic that would otherwise be memory or time limited: + * + * ```js + * const { Range } = require('immutable') + * Range(1, Infinity) + * .skip(1000) + * .map(n => -n) + * .filter(n => n % 2 === 0) + * .take(2) + * .reduce((r, n) => r * n, 1) + * // 1006008 + * ``` + * + * Seq is often used to provide a rich collection API to JavaScript Object. + * + * ```js + * Seq({ x: 0, y: 1, z: 2 }).map(v => v * 2).toObject(); + * // { x: 0, y: 2, z: 4 } + * ``` + */ + + export module Seq { + /** + * True if `maybeSeq` is a Seq, it is not backed by a concrete + * structure such as Map, List, or Set. + */ + function isSeq(maybeSeq: any): maybeSeq is Seq.Indexed | Seq.Keyed; + + + /** + * `Seq` which represents key-value pairs. + */ + export module Keyed {} + + /** + * Always returns a Seq.Keyed, if input is not keyed, expects an + * collection of [K, V] tuples. + */ + export function Keyed(collection: Iterable<[K, V]>): Seq.Keyed; + export function Keyed(obj: {[key: string]: V}): Seq.Keyed; + export function Keyed(): Seq.Keyed; + export function Keyed(): Seq.Keyed; + + export interface Keyed extends Seq, Collection.Keyed { + /** + * Deeply converts this Keyed Seq to equivalent native JavaScript Object. + * + * Converts keys to Strings. + */ + toJS(): Object; + + /** + * Shallowly converts this Keyed Seq to equivalent native JavaScript Object. + * + * Converts keys to Strings. + */ + toJSON(): { [key: string]: V }; + + /** + * Returns itself + */ + toSeq(): this; + + /** + * Returns a new Seq with other collections concatenated to this one. + * + * All entries will be present in the resulting Seq, even if they + * have the same key. + */ + concat(...collections: Array>): Seq.Keyed; + concat(...collections: Array<{[key: string]: C}>): Seq.Keyed; + + /** + * Returns a new Seq.Keyed with values passed through a + * `mapper` function. + * + * ```js + * const { Seq } = require('immutable') + * Seq.Keyed({ a: 1, b: 2 }).map(x => 10 * x) + * // Seq { "a": 10, "b": 20 } + * ``` + * + * Note: `map()` always returns a new instance, even if it produced the + * same value at every step. + */ + map( + mapper: (value: V, key: K, iter: this) => M, + context?: any + ): Seq.Keyed; + + /** + * @see Collection.Keyed.mapKeys + */ + mapKeys( + mapper: (key: K, value: V, iter: this) => M, + context?: any + ): Seq.Keyed; + + /** + * @see Collection.Keyed.mapEntries + */ + mapEntries( + mapper: (entry: [K, V], index: number, iter: this) => [KM, VM], + context?: any + ): Seq.Keyed; + + /** + * Flat-maps the Seq, returning a Seq of the same type. + * + * Similar to `seq.map(...).flatten(true)`. + */ + flatMap( + mapper: (value: V, key: K, iter: this) => Iterable<[KM, VM]>, + context?: any + ): Seq.Keyed; + + /** + * Returns a new Seq with only the entries for which the `predicate` + * function returns true. + * + * Note: `filter()` always returns a new instance, even if it results in + * not filtering out any values. + */ + filter( + predicate: (value: V, key: K, iter: this) => value is F, + context?: any + ): Seq.Keyed; + filter( + predicate: (value: V, key: K, iter: this) => any, + context?: any + ): this; + } + + + /** + * `Seq` which represents an ordered indexed list of values. + */ + module Indexed { + + /** + * Provides an Seq.Indexed of the values provided. + */ + function of(...values: Array): Seq.Indexed; + } + + /** + * Always returns Seq.Indexed, discarding associated keys and + * supplying incrementing indices. + */ + export function Indexed(): Seq.Indexed; + export function Indexed(): Seq.Indexed; + export function Indexed(collection: Iterable): Seq.Indexed; + + export interface Indexed extends Seq, Collection.Indexed { + /** + * Deeply converts this Indexed Seq to equivalent native JavaScript Array. + */ + toJS(): Array; + + /** + * Shallowly converts this Indexed Seq to equivalent native JavaScript Array. + */ + toJSON(): Array; + + /** + * Returns itself + */ + toSeq(): this + + /** + * Returns a new Seq with other collections concatenated to this one. + */ + concat(...valuesOrCollections: Array | C>): Seq.Indexed; + + /** + * Returns a new Seq.Indexed with values passed through a + * `mapper` function. + * + * ```js + * const { Seq } = require('immutable') + * Seq.Indexed([ 1, 2 ]).map(x => 10 * x) + * // Seq [ 10, 20 ] + * ``` + * + * Note: `map()` always returns a new instance, even if it produced the + * same value at every step. + */ + map( + mapper: (value: T, key: number, iter: this) => M, + context?: any + ): Seq.Indexed; + + /** + * Flat-maps the Seq, returning a a Seq of the same type. + * + * Similar to `seq.map(...).flatten(true)`. + */ + flatMap( + mapper: (value: T, key: number, iter: this) => Iterable, + context?: any + ): Seq.Indexed; + + /** + * Returns a new Seq with only the values for which the `predicate` + * function returns true. + * + * Note: `filter()` always returns a new instance, even if it results in + * not filtering out any values. + */ + filter( + predicate: (value: T, index: number, iter: this) => value is F, + context?: any + ): Seq.Indexed; + filter( + predicate: (value: T, index: number, iter: this) => any, + context?: any + ): this; + + /** + * Returns a Seq "zipped" with the provided collections. + * + * Like `zipWith`, but using the default `zipper`: creating an `Array`. + * + * ```js + * const a = Seq([ 1, 2, 3 ]); + * const b = Seq([ 4, 5, 6 ]); + * const c = a.zip(b); // Seq [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] + * ``` + */ + zip(other: Collection): Seq.Indexed<[T,U]>; + + /** + * Returns a Seq "zipped" with the provided collections. + * + * Like `zipWith`, but using the default `zipper`: creating an `Array`. + * + * ```js + * const a = Seq([ 1, 2, 3 ]); + * const b = Seq([ 4, 5, 6 ]); + * const c = a.zip(b); // Seq [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] + * ``` + */ + zip(other: Collection, other2: Collection): Seq.Indexed<[T,U,V]>; + + /** + * Returns a Seq "zipped" with the provided collections. + * + * Like `zipWith`, but using the default `zipper`: creating an `Array`. + * + * ```js + * const a = Seq([ 1, 2, 3 ]); + * const b = Seq([ 4, 5, 6 ]); + * const c = a.zip(b); // Seq [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] + * ``` + */ + zip(...collections: Array>): Seq.Indexed; + + /** + * Returns a Seq "zipped" with the provided collections by using a + * custom `zipper` function. + * + * ```js + * const a = Seq([ 1, 2, 3 ]); + * const b = Seq([ 4, 5, 6 ]); + * const c = a.zipWith((a, b) => a + b, b); + * // Seq [ 5, 7, 9 ] + * ``` + */ + zipWith( + zipper: (value: T, otherValue: U) => Z, + otherCollection: Collection + ): Seq.Indexed; + zipWith( + zipper: (value: T, otherValue: U, thirdValue: V) => Z, + otherCollection: Collection, + thirdCollection: Collection + ): Seq.Indexed; + zipWith( + zipper: (...any: Array) => Z, + ...collections: Array> + ): Seq.Indexed; + } + + + /** + * `Seq` which represents a set of values. + * + * Because `Seq` are often lazy, `Seq.Set` does not provide the same guarantee + * of value uniqueness as the concrete `Set`. + */ + export module Set { + + /** + * Returns a Seq.Set of the provided values + */ + function of(...values: Array): Seq.Set; + } + + /** + * Always returns a Seq.Set, discarding associated indices or keys. + */ + export function Set(): Seq.Set; + export function Set(): Seq.Set; + export function Set(collection: Iterable): Seq.Set; + + export interface Set extends Seq, Collection.Set { + /** + * Deeply converts this Set Seq to equivalent native JavaScript Array. + */ + toJS(): Array; + + /** + * Shallowly converts this Set Seq to equivalent native JavaScript Array. + */ + toJSON(): Array; + + /** + * Returns itself + */ + toSeq(): this + + /** + * Returns a new Seq with other collections concatenated to this one. + * + * All entries will be present in the resulting Seq, even if they + * are duplicates. + */ + concat(...valuesOrCollections: Array | C>): Seq.Set; + + /** + * Returns a new Seq.Set with values passed through a + * `mapper` function. + * + * ```js + * Seq.Set([ 1, 2 ]).map(x => 10 * x) + * // Seq { 10, 20 } + * ``` + * + * Note: `map()` always returns a new instance, even if it produced the + * same value at every step. + */ + map( + mapper: (value: T, key: T, iter: this) => M, + context?: any + ): Seq.Set; + + /** + * Flat-maps the Seq, returning a Seq of the same type. + * + * Similar to `seq.map(...).flatten(true)`. + */ + flatMap( + mapper: (value: T, key: T, iter: this) => Iterable, + context?: any + ): Seq.Set; + + /** + * Returns a new Seq with only the values for which the `predicate` + * function returns true. + * + * Note: `filter()` always returns a new instance, even if it results in + * not filtering out any values. + */ + filter( + predicate: (value: T, key: T, iter: this) => value is F, + context?: any + ): Seq.Set; + filter( + predicate: (value: T, key: T, iter: this) => any, + context?: any + ): this; + } + + } + + /** + * Creates a Seq. + * + * Returns a particular kind of `Seq` based on the input. + * + * * If a `Seq`, that same `Seq`. + * * If an `Collection`, a `Seq` of the same kind (Keyed, Indexed, or Set). + * * If an Array-like, an `Seq.Indexed`. + * * If an Object with an Iterator, an `Seq.Indexed`. + * * If an Iterator, an `Seq.Indexed`. + * * If an Object, a `Seq.Keyed`. + * + */ + export function Seq>(seq: S): S; + export function Seq(collection: Collection.Keyed): Seq.Keyed; + export function Seq(collection: Collection.Indexed): Seq.Indexed; + export function Seq(collection: Collection.Set): Seq.Set; + export function Seq(collection: Iterable): Seq.Indexed; + export function Seq(obj: {[key: string]: V}): Seq.Keyed; + export function Seq(): Seq; + + export interface Seq extends Collection { + + /** + * Some Seqs can describe their size lazily. When this is the case, + * size will be an integer. Otherwise it will be undefined. + * + * For example, Seqs returned from `map()` or `reverse()` + * preserve the size of the original `Seq` while `filter()` does not. + * + * Note: `Range`, `Repeat` and `Seq`s made from `Array`s and `Object`s will + * always have a size. + */ + readonly size: number | undefined; + + + // Force evaluation + + /** + * Because Sequences are lazy and designed to be chained together, they do + * not cache their results. For example, this map function is called a total + * of 6 times, as each `join` iterates the Seq of three values. + * + * var squares = Seq([ 1, 2, 3 ]).map(x => x * x) + * squares.join() + squares.join() + * + * If you know a `Seq` will be used multiple times, it may be more + * efficient to first cache it in memory. Here, the map function is called + * only 3 times. + * + * var squares = Seq([ 1, 2, 3 ]).map(x => x * x).cacheResult() + * squares.join() + squares.join() + * + * Use this method judiciously, as it must fully evaluate a Seq which can be + * a burden on memory and possibly performance. + * + * Note: after calling `cacheResult`, a Seq will always have a `size`. + */ + cacheResult(): this; + + // Sequence algorithms + + /** + * Returns a new Seq with values passed through a + * `mapper` function. + * + * ```js + * const { Seq } = require('immutable') + * Seq([ 1, 2 ]).map(x => 10 * x) + * // Seq [ 10, 20 ] + * ``` + * + * Note: `map()` always returns a new instance, even if it produced the same + * value at every step. + */ + map( + mapper: (value: V, key: K, iter: this) => M, + context?: any + ): Seq; + + /** + * Flat-maps the Seq, returning a Seq of the same type. + * + * Similar to `seq.map(...).flatten(true)`. + */ + flatMap( + mapper: (value: V, key: K, iter: this) => Iterable, + context?: any + ): Seq; + + /** + * Returns a new Seq with only the values for which the `predicate` + * function returns true. + * + * Note: `filter()` always returns a new instance, even if it results in + * not filtering out any values. + */ + filter( + predicate: (value: V, key: K, iter: this) => value is F, + context?: any + ): Seq; + filter( + predicate: (value: V, key: K, iter: this) => any, + context?: any + ): this; + } + + /** + * The `Collection` is a set of (key, value) entries which can be iterated, and + * is the base class for all collections in `immutable`, allowing them to + * make use of all the Collection methods (such as `map` and `filter`). + * + * Note: A collection is always iterated in the same order, however that order + * may not always be well defined, as is the case for the `Map` and `Set`. + * + * Collection is the abstract base class for concrete data structures. It + * cannot be constructed directly. + * + * Implementations should extend one of the subclasses, `Collection.Keyed`, + * `Collection.Indexed`, or `Collection.Set`. + */ + export module Collection { + + /** + * @deprecated use `const { isKeyed } = require('immutable')` + */ + function isKeyed(maybeKeyed: any): maybeKeyed is Collection.Keyed; + + /** + * @deprecated use `const { isIndexed } = require('immutable')` + */ + function isIndexed(maybeIndexed: any): maybeIndexed is Collection.Indexed; + + /** + * @deprecated use `const { isAssociative } = require('immutable')` + */ + function isAssociative(maybeAssociative: any): maybeAssociative is Collection.Keyed | Collection.Indexed; + + /** + * @deprecated use `const { isOrdered } = require('immutable')` + */ + function isOrdered(maybeOrdered: any): boolean; + + + /** + * Keyed Collections have discrete keys tied to each value. + * + * When iterating `Collection.Keyed`, each iteration will yield a `[K, V]` + * tuple, in other words, `Collection#entries` is the default iterator for + * Keyed Collections. + */ + export module Keyed {} + + /** + * Creates a Collection.Keyed + * + * Similar to `Collection()`, however it expects collection-likes of [K, V] + * tuples if not constructed from a Collection.Keyed or JS Object. + */ + export function Keyed(collection: Iterable<[K, V]>): Collection.Keyed; + export function Keyed(obj: {[key: string]: V}): Collection.Keyed; + + export interface Keyed extends Collection { + /** + * Deeply converts this Keyed collection to equivalent native JavaScript Object. + * + * Converts keys to Strings. + */ + toJS(): Object; + + /** + * Shallowly converts this Keyed collection to equivalent native JavaScript Object. + * + * Converts keys to Strings. + */ + toJSON(): { [key: string]: V }; + + /** + * Returns Seq.Keyed. + * @override + */ + toSeq(): Seq.Keyed; + + + // Sequence functions + + /** + * Returns a new Collection.Keyed of the same type where the keys and values + * have been flipped. + * + * + * ```js + * const { Map } = require('immutable') + * Map({ a: 'z', b: 'y' }).flip() + * // Map { "z": "a", "y": "b" } + * ``` + */ + flip(): this; + + /** + * Returns a new Collection with other collections concatenated to this one. + */ + concat(...collections: Array>): Collection.Keyed; + concat(...collections: Array<{[key: string]: C}>): Collection.Keyed; + + /** + * Returns a new Collection.Keyed with values passed through a + * `mapper` function. + * + * ```js + * const { Collection } = require('immutable') + * Collection.Keyed({ a: 1, b: 2 }).map(x => 10 * x) + * // Seq { "a": 10, "b": 20 } + * ``` + * + * Note: `map()` always returns a new instance, even if it produced the + * same value at every step. + */ + map( + mapper: (value: V, key: K, iter: this) => M, + context?: any + ): Collection.Keyed; + + /** + * Returns a new Collection.Keyed of the same type with keys passed through + * a `mapper` function. + * + * + * ```js + * const { Map } = require('immutable') + * Map({ a: 1, b: 2 }).mapKeys(x => x.toUpperCase()) + * // Map { "A": 1, "B": 2 } + * ``` + * + * Note: `mapKeys()` always returns a new instance, even if it produced + * the same key at every step. + */ + mapKeys( + mapper: (key: K, value: V, iter: this) => M, + context?: any + ): Collection.Keyed; + + /** + * Returns a new Collection.Keyed of the same type with entries + * ([key, value] tuples) passed through a `mapper` function. + * + * + * ```js + * const { Map } = require('immutable') + * Map({ a: 1, b: 2 }) + * .mapEntries(([ k, v ]) => [ k.toUpperCase(), v * 2 ]) + * // Map { "A": 2, "B": 4 } + * ``` + * + * Note: `mapEntries()` always returns a new instance, even if it produced + * the same entry at every step. + */ + mapEntries( + mapper: (entry: [K, V], index: number, iter: this) => [KM, VM], + context?: any + ): Collection.Keyed; + + /** + * Flat-maps the Collection, returning a Collection of the same type. + * + * Similar to `collection.map(...).flatten(true)`. + */ + flatMap( + mapper: (value: V, key: K, iter: this) => Iterable<[KM, VM]>, + context?: any + ): Collection.Keyed; + + /** + * Returns a new Collection with only the values for which the `predicate` + * function returns true. + * + * Note: `filter()` always returns a new instance, even if it results in + * not filtering out any values. + */ + filter( + predicate: (value: V, key: K, iter: this) => value is F, + context?: any + ): Collection.Keyed; + filter( + predicate: (value: V, key: K, iter: this) => any, + context?: any + ): this; + + [Symbol.iterator](): IterableIterator<[K, V]>; + } + + + /** + * Indexed Collections have incrementing numeric keys. They exhibit + * slightly different behavior than `Collection.Keyed` for some methods in order + * to better mirror the behavior of JavaScript's `Array`, and add methods + * which do not make sense on non-indexed Collections such as `indexOf`. + * + * Unlike JavaScript arrays, `Collection.Indexed`s are always dense. "Unset" + * indices and `undefined` indices are indistinguishable, and all indices from + * 0 to `size` are visited when iterated. + * + * All Collection.Indexed methods return re-indexed Collections. In other words, + * indices always start at 0 and increment until size. If you wish to + * preserve indices, using them as keys, convert to a Collection.Keyed by + * calling `toKeyedSeq`. + */ + export module Indexed {} + + /** + * Creates a new Collection.Indexed. + */ + export function Indexed(collection: Iterable): Collection.Indexed; + + export interface Indexed extends Collection { + /** + * Deeply converts this Indexed collection to equivalent native JavaScript Array. + */ + toJS(): Array; + + /** + * Shallowly converts this Indexed collection to equivalent native JavaScript Array. + */ + toJSON(): Array; + + // Reading values + + /** + * Returns the value associated with the provided index, or notSetValue if + * the index is beyond the bounds of the Collection. + * + * `index` may be a negative number, which indexes back from the end of the + * Collection. `s.get(-1)` gets the last item in the Collection. + */ + get(index: number, notSetValue: NSV): T | NSV; + get(index: number): T | undefined; + + + // Conversion to Seq + + /** + * Returns Seq.Indexed. + * @override + */ + toSeq(): Seq.Indexed; + + /** + * If this is a collection of [key, value] entry tuples, it will return a + * Seq.Keyed of those entries. + */ + fromEntrySeq(): Seq.Keyed; + + + // Combination + + /** + * Returns a Collection of the same type with `separator` between each item + * in this Collection. + */ + interpose(separator: T): this; + + /** + * Returns a Collection of the same type with the provided `collections` + * interleaved into this collection. + * + * The resulting Collection includes the first item from each, then the + * second from each, etc. + * + * + * ```js + * const { List } = require('immutable') + * List([ 1, 2, 3 ]).interleave(List([ 'A', 'B', 'C' ])) + * // List [ 1, "A", 2, "B", 3, "C"" ] + * ``` + * + * The shortest Collection stops interleave. + * + * + * ```js + * List([ 1, 2, 3 ]).interleave( + * List([ 'A', 'B' ]), + * List([ 'X', 'Y', 'Z' ]) + * ) + * // List [ 1, "A", "X", 2, "B", "Y"" ] + * ``` + */ + interleave(...collections: Array>): this; + + /** + * Splice returns a new indexed Collection by replacing a region of this + * Collection with new values. If values are not provided, it only skips the + * region to be removed. + * + * `index` may be a negative number, which indexes back from the end of the + * Collection. `s.splice(-2)` splices after the second to last item. + * + * + * ```js + * const { List } = require('immutable') + * List([ 'a', 'b', 'c', 'd' ]).splice(1, 2, 'q', 'r', 's') + * // List [ "a", "q", "r", "s", "d" ] + * ``` + */ + splice( + index: number, + removeNum: number, + ...values: Array + ): this; + + /** + * Returns a Collection of the same type "zipped" with the provided + * collections. + * + * Like `zipWith`, but using the default `zipper`: creating an `Array`. + * + * + * + * ```js + * const a = List([ 1, 2, 3 ]); + * const b = List([ 4, 5, 6 ]); + * const c = a.zip(b); // List [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] + * ``` + */ + zip(other: Collection): Collection.Indexed<[T,U]>; + + /** + * Returns a Collection of the same type "zipped" with the provided + * collections. + * + * Like `zipWith`, but using the default `zipper`: creating an `Array`. + * + * ```js + * const a = List([ 1, 2, 3 ]); + * const b = List([ 4, 5, 6 ]); + * const c = a.zip(b); // List [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] + * ``` + */ + zip(other: Collection, other2: Collection): Collection.Indexed<[T,U,V]>; + + /** + * Returns a Collection of the same type "zipped" with the provided + * collections. + * + * Like `zipWith`, but using the default `zipper`: creating an `Array`. + * + * ```js + * const a = List([ 1, 2, 3 ]); + * const b = List([ 4, 5, 6 ]); + * const c = a.zip(b); // List [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] + * ``` + */ + zip(...collections: Array>): Collection.Indexed; + + /** + * Returns a Collection of the same type "zipped" with the provided + * collections by using a custom `zipper` function. + * + * + * ```js + * const a = List([ 1, 2, 3 ]); + * const b = List([ 4, 5, 6 ]); + * const c = a.zipWith((a, b) => a + b, b); + * // List [ 5, 7, 9 ] + * ``` + */ + zipWith( + zipper: (value: T, otherValue: U) => Z, + otherCollection: Collection + ): Collection.Indexed; + zipWith( + zipper: (value: T, otherValue: U, thirdValue: V) => Z, + otherCollection: Collection, + thirdCollection: Collection + ): Collection.Indexed; + zipWith( + zipper: (...any: Array) => Z, + ...collections: Array> + ): Collection.Indexed; + + + // Search for value + + /** + * Returns the first index at which a given value can be found in the + * Collection, or -1 if it is not present. + */ + indexOf(searchValue: T): number; + + /** + * Returns the last index at which a given value can be found in the + * Collection, or -1 if it is not present. + */ + lastIndexOf(searchValue: T): number; + + /** + * Returns the first index in the Collection where a value satisfies the + * provided predicate function. Otherwise -1 is returned. + */ + findIndex( + predicate: (value: T, index: number, iter: this) => boolean, + context?: any + ): number; + + /** + * Returns the last index in the Collection where a value satisfies the + * provided predicate function. Otherwise -1 is returned. + */ + findLastIndex( + predicate: (value: T, index: number, iter: this) => boolean, + context?: any + ): number; + + // Sequence algorithms + + /** + * Returns a new Collection with other collections concatenated to this one. + */ + concat(...valuesOrCollections: Array | C>): Collection.Indexed; + + /** + * Returns a new Collection.Indexed with values passed through a + * `mapper` function. + * + * ```js + * const { Collection } = require('immutable') + * Collection.Indexed([1,2]).map(x => 10 * x) + * // Seq [ 1, 2 ] + * ``` + * + * Note: `map()` always returns a new instance, even if it produced the + * same value at every step. + */ + map( + mapper: (value: T, key: number, iter: this) => M, + context?: any + ): Collection.Indexed; + + /** + * Flat-maps the Collection, returning a Collection of the same type. + * + * Similar to `collection.map(...).flatten(true)`. + */ + flatMap( + mapper: (value: T, key: number, iter: this) => Iterable, + context?: any + ): Collection.Indexed; + + /** + * Returns a new Collection with only the values for which the `predicate` + * function returns true. + * + * Note: `filter()` always returns a new instance, even if it results in + * not filtering out any values. + */ + filter( + predicate: (value: T, index: number, iter: this) => value is F, + context?: any + ): Collection.Indexed; + filter( + predicate: (value: T, index: number, iter: this) => any, + context?: any + ): this; + + [Symbol.iterator](): IterableIterator; + } + + + /** + * Set Collections only represent values. They have no associated keys or + * indices. Duplicate values are possible in the lazy `Seq.Set`s, however + * the concrete `Set` Collection does not allow duplicate values. + * + * Collection methods on Collection.Set such as `map` and `forEach` will provide + * the value as both the first and second arguments to the provided function. + * + * ```js + * const { Collection } = require('immutable') + * const seq = Collection.Set([ 'A', 'B', 'C' ]) + * // Seq { "A", "B", "C" } + * seq.forEach((v, k) => + * assert.equal(v, k) + * ) + * ``` + */ + export module Set {} + + /** + * Similar to `Collection()`, but always returns a Collection.Set. + */ + export function Set(collection: Iterable): Collection.Set; + + export interface Set extends Collection { + /** + * Deeply converts this Set collection to equivalent native JavaScript Array. + */ + toJS(): Array; + + /** + * Shallowly converts this Set collection to equivalent native JavaScript Array. + */ + toJSON(): Array; + + /** + * Returns Seq.Set. + * @override + */ + toSeq(): Seq.Set; + + // Sequence algorithms + + /** + * Returns a new Collection with other collections concatenated to this one. + */ + concat(...valuesOrCollections: Array | C>): Collection.Set; + + /** + * Returns a new Collection.Set with values passed through a + * `mapper` function. + * + * ``` + * Collection.Set([ 1, 2 ]).map(x => 10 * x) + * // Seq { 1, 2 } + * ``` + * + * Note: `map()` always returns a new instance, even if it produced the + * same value at every step. + */ + map( + mapper: (value: T, key: T, iter: this) => M, + context?: any + ): Collection.Set; + + /** + * Flat-maps the Collection, returning a Collection of the same type. + * + * Similar to `collection.map(...).flatten(true)`. + */ + flatMap( + mapper: (value: T, key: T, iter: this) => Iterable, + context?: any + ): Collection.Set; + + /** + * Returns a new Collection with only the values for which the `predicate` + * function returns true. + * + * Note: `filter()` always returns a new instance, even if it results in + * not filtering out any values. + */ + filter( + predicate: (value: T, key: T, iter: this) => value is F, + context?: any + ): Collection.Set; + filter( + predicate: (value: T, key: T, iter: this) => any, + context?: any + ): this; + + [Symbol.iterator](): IterableIterator; + } + + } + + /** + * Creates a Collection. + * + * The type of Collection created is based on the input. + * + * * If an `Collection`, that same `Collection`. + * * If an Array-like, an `Collection.Indexed`. + * * If an Object with an Iterator, an `Collection.Indexed`. + * * If an Iterator, an `Collection.Indexed`. + * * If an Object, an `Collection.Keyed`. + * + * This methods forces the conversion of Objects and Strings to Collections. + * If you want to ensure that a Collection of one item is returned, use + * `Seq.of`. + */ + export function Collection>(collection: I): I; + export function Collection(collection: Iterable): Collection.Indexed; + export function Collection(obj: {[key: string]: V}): Collection.Keyed; + + export interface Collection extends ValueObject { + + // Value equality + + /** + * True if this and the other Collection have value equality, as defined + * by `Immutable.is()`. + * + * Note: This is equivalent to `Immutable.is(this, other)`, but provided to + * allow for chained expressions. + */ + equals(other: any): boolean; + + /** + * Computes and returns the hashed identity for this Collection. + * + * The `hashCode` of a Collection is used to determine potential equality, + * and is used when adding this to a `Set` or as a key in a `Map`, enabling + * lookup via a different instance. + * + * + * ```js + * const a = List([ 1, 2, 3 ]); + * const b = List([ 1, 2, 3 ]); + * assert.notStrictEqual(a, b); // different instances + * const set = Set([ a ]); + * assert.equal(set.has(b), true); + * ``` + * + * If two values have the same `hashCode`, they are [not guaranteed + * to be equal][Hash Collision]. If two values have different `hashCode`s, + * they must not be equal. + * + * [Hash Collision]: http://en.wikipedia.org/wiki/Collision_(computer_science) + */ + hashCode(): number; + + + // Reading values + + /** + * Returns the value associated with the provided key, or notSetValue if + * the Collection does not contain this key. + * + * Note: it is possible a key may be associated with an `undefined` value, + * so if `notSetValue` is not provided and this method returns `undefined`, + * that does not guarantee the key was not found. + */ + get(key: K, notSetValue: NSV): V | NSV; + get(key: K): V | undefined; + + /** + * True if a key exists within this `Collection`, using `Immutable.is` + * to determine equality + */ + has(key: K): boolean; + + /** + * True if a value exists within this `Collection`, using `Immutable.is` + * to determine equality + * @alias contains + */ + includes(value: V): boolean; + contains(value: V): boolean; + + /** + * The first value in the Collection. + */ + first(): V | undefined; + + /** + * The last value in the Collection. + */ + last(): V | undefined; + + + // Reading deep values + + /** + * Returns the value found by following a path of keys or indices through + * nested Collections. + */ + getIn(searchKeyPath: Iterable, notSetValue?: any): any; + + /** + * True if the result of following a path of keys or indices through nested + * Collections results in a set value. + */ + hasIn(searchKeyPath: Iterable): boolean; + + // Persistent changes + + /** + * This can be very useful as a way to "chain" a normal function into a + * sequence of methods. RxJS calls this "let" and lodash calls it "thru". + * + * For example, to sum a Seq after mapping and filtering: + * + * ```js + * const { Seq } = require('immutable') + * + * function sum(collection) { + * return collection.reduce((sum, x) => sum + x, 0) + * } + * + * Seq([ 1, 2, 3 ]) + * .map(x => x + 1) + * .filter(x => x % 2 === 0) + * .update(sum) + * // 6 + * ``` + */ + update(updater: (value: this) => R): R; + + + // Conversion to JavaScript types + + /** + * Deeply converts this Collection to equivalent native JavaScript Array or Object. + * + * `Collection.Indexed`, and `Collection.Set` become `Array`, while + * `Collection.Keyed` become `Object`, converting keys to Strings. + */ + toJS(): Array | { [key: string]: any }; + + /** + * Shallowly converts this Collection to equivalent native JavaScript Array or Object. + * + * `Collection.Indexed`, and `Collection.Set` become `Array`, while + * `Collection.Keyed` become `Object`, converting keys to Strings. + */ + toJSON(): Array | { [key: string]: V }; + + /** + * Shallowly converts this collection to an Array, discarding keys. + */ + toArray(): Array; + + /** + * Shallowly converts this Collection to an Object. + * + * Converts keys to Strings. + */ + toObject(): { [key: string]: V }; + + + // Conversion to Collections + + /** + * Converts this Collection to a Map, Throws if keys are not hashable. + * + * Note: This is equivalent to `Map(this.toKeyedSeq())`, but provided + * for convenience and to allow for chained expressions. + */ + toMap(): Map; + + /** + * Converts this Collection to a Map, maintaining the order of iteration. + * + * Note: This is equivalent to `OrderedMap(this.toKeyedSeq())`, but + * provided for convenience and to allow for chained expressions. + */ + toOrderedMap(): OrderedMap; + + /** + * Converts this Collection to a Set, discarding keys. Throws if values + * are not hashable. + * + * Note: This is equivalent to `Set(this)`, but provided to allow for + * chained expressions. + */ + toSet(): Set; + + /** + * Converts this Collection to a Set, maintaining the order of iteration and + * discarding keys. + * + * Note: This is equivalent to `OrderedSet(this.valueSeq())`, but provided + * for convenience and to allow for chained expressions. + */ + toOrderedSet(): OrderedSet; + + /** + * Converts this Collection to a List, discarding keys. + * + * This is similar to `List(collection)`, but provided to allow for chained + * expressions. However, when called on `Map` or other keyed collections, + * `collection.toList()` discards the keys and creates a list of only the + * values, whereas `List(collection)` creates a list of entry tuples. + * + * + * ```js + * const { Map, List } = require('immutable') + * var myMap = Map({ a: 'Apple', b: 'Banana' }) + * List(myMap) // List [ [ "a", "Apple" ], [ "b", "Banana" ] ] + * myMap.toList() // List [ "Apple", "Banana" ] + * ``` + */ + toList(): List; + + /** + * Converts this Collection to a Stack, discarding keys. Throws if values + * are not hashable. + * + * Note: This is equivalent to `Stack(this)`, but provided to allow for + * chained expressions. + */ + toStack(): Stack; + + + // Conversion to Seq + + /** + * Converts this Collection to a Seq of the same kind (indexed, + * keyed, or set). + */ + toSeq(): Seq; + + /** + * Returns a Seq.Keyed from this Collection where indices are treated as keys. + * + * This is useful if you want to operate on an + * Collection.Indexed and preserve the [index, value] pairs. + * + * The returned Seq will have identical iteration order as + * this Collection. + * + * ```js + * const { Seq } = require('immutable') + * const indexedSeq = Seq([ 'A', 'B', 'C' ]) + * // Seq [ "A", "B", "C" ] + * indexedSeq.filter(v => v === 'B') + * // Seq [ "B" ] + * const keyedSeq = indexedSeq.toKeyedSeq() + * // Seq { 0: "A", 1: "B", 2: "C" } + * keyedSeq.filter(v => v === 'B') + * // Seq { 1: "B" } + * ``` + */ + toKeyedSeq(): Seq.Keyed; + + /** + * Returns an Seq.Indexed of the values of this Collection, discarding keys. + */ + toIndexedSeq(): Seq.Indexed; + + /** + * Returns a Seq.Set of the values of this Collection, discarding keys. + */ + toSetSeq(): Seq.Set; + + + // Iterators + + /** + * An iterator of this `Collection`'s keys. + * + * Note: this will return an ES6 iterator which does not support + * Immutable.js sequence algorithms. Use `keySeq` instead, if this is + * what you want. + */ + keys(): IterableIterator; + + /** + * An iterator of this `Collection`'s values. + * + * Note: this will return an ES6 iterator which does not support + * Immutable.js sequence algorithms. Use `valueSeq` instead, if this is + * what you want. + */ + values(): IterableIterator; + + /** + * An iterator of this `Collection`'s entries as `[ key, value ]` tuples. + * + * Note: this will return an ES6 iterator which does not support + * Immutable.js sequence algorithms. Use `entrySeq` instead, if this is + * what you want. + */ + entries(): IterableIterator<[K, V]>; + + + // Collections (Seq) + + /** + * Returns a new Seq.Indexed of the keys of this Collection, + * discarding values. + */ + keySeq(): Seq.Indexed; + + /** + * Returns an Seq.Indexed of the values of this Collection, discarding keys. + */ + valueSeq(): Seq.Indexed; + + /** + * Returns a new Seq.Indexed of [key, value] tuples. + */ + entrySeq(): Seq.Indexed<[K, V]>; + + + // Sequence algorithms + + /** + * Returns a new Collection of the same type with values passed through a + * `mapper` function. + * + * ```js + * const { Collection } = require('immutable') + * Collection({ a: 1, b: 2 }).map(x => 10 * x) + * // Seq { "a": 10, "b": 20 } + * ``` + * + * Note: `map()` always returns a new instance, even if it produced the same + * value at every step. + */ + map( + mapper: (value: V, key: K, iter: this) => M, + context?: any + ): Collection; + + /** + * Returns a new Collection of the same type with only the entries for which + * the `predicate` function returns true. + * + * + * ```js + * const { Map } = require('immutable') + * Map({ a: 1, b: 2, c: 3, d: 4}).filter(x => x % 2 === 0) + * // Map { "b": 2, "d": 4 } + * ``` + * + * Note: `filter()` always returns a new instance, even if it results in + * not filtering out any values. + */ + filter( + predicate: (value: V, key: K, iter: this) => value is F, + context?: any + ): Collection; + filter( + predicate: (value: V, key: K, iter: this) => any, + context?: any + ): this; + + /** + * Returns a new Collection of the same type with only the entries for which + * the `predicate` function returns false. + * + * + * ```js + * const { Map } = require('immutable') + * Map({ a: 1, b: 2, c: 3, d: 4}).filterNot(x => x % 2 === 0) + * // Map { "a": 1, "c": 3 } + * ``` + * + * Note: `filterNot()` always returns a new instance, even if it results in + * not filtering out any values. + */ + filterNot( + predicate: (value: V, key: K, iter: this) => boolean, + context?: any + ): this; + + /** + * Returns a new Collection of the same type in reverse order. + */ + reverse(): this; + + /** + * Returns a new Collection of the same type which includes the same entries, + * stably sorted by using a `comparator`. + * + * If a `comparator` is not provided, a default comparator uses `<` and `>`. + * + * `comparator(valueA, valueB)`: + * + * * Returns `0` if the elements should not be swapped. + * * Returns `-1` (or any negative number) if `valueA` comes before `valueB` + * * Returns `1` (or any positive number) if `valueA` comes after `valueB` + * * Is pure, i.e. it must always return the same value for the same pair + * of values. + * + * When sorting collections which have no defined order, their ordered + * equivalents will be returned. e.g. `map.sort()` returns OrderedMap. + * + * ```js + * const { Map } = require('immutable') + * Map({ "c": 3, "a": 1, "b": 2 }).sort((a, b) => { + * if (a < b) { return -1; } + * if (a > b) { return 1; } + * if (a === b) { return 0; } + * }); + * // OrderedMap { "a": 1, "b": 2, "c": 3 } + * ``` + * + * Note: `sort()` Always returns a new instance, even if the original was + * already sorted. + */ + sort(comparator?: (valueA: V, valueB: V) => number): this; + + /** + * Like `sort`, but also accepts a `comparatorValueMapper` which allows for + * sorting by more sophisticated means: + * + * hitters.sortBy(hitter => hitter.avgHits) + * + * Note: `sortBy()` Always returns a new instance, even if the original was + * already sorted. + */ + sortBy( + comparatorValueMapper: (value: V, key: K, iter: this) => C, + comparator?: (valueA: C, valueB: C) => number + ): this; + + /** + * Returns a `Collection.Keyed` of `Collection.Keyeds`, grouped by the return + * value of the `grouper` function. + * + * Note: This is always an eager operation. + * + * ```js + * const { List, Map } = require('immutable') + * const listOfMaps = List([ + * Map({ v: 0 }), + * Map({ v: 1 }), + * Map({ v: 1 }), + * Map({ v: 0 }), + * Map({ v: 2 }) + * ]) + * const groupsOfMaps = listOfMaps.groupBy(x => x.get('v')) + * // Map { + * // 0: List [ Map{ "v": 0 }, Map { "v": 0 } ], + * // 1: List [ Map{ "v": 1 }, Map { "v": 1 } ], + * // 2: List [ Map{ "v": 2 } ], + * // } + * ``` + */ + groupBy( + grouper: (value: V, key: K, iter: this) => G, + context?: any + ): /*Map*/Seq.Keyed>; + + + // Side effects + + /** + * The `sideEffect` is executed for every entry in the Collection. + * + * Unlike `Array#forEach`, if any call of `sideEffect` returns + * `false`, the iteration will stop. Returns the number of entries iterated + * (including the last iteration which returned false). + */ + forEach( + sideEffect: (value: V, key: K, iter: this) => any, + context?: any + ): number; + + + // Creating subsets + + /** + * Returns a new Collection of the same type representing a portion of this + * Collection from start up to but not including end. + * + * If begin is negative, it is offset from the end of the Collection. e.g. + * `slice(-2)` returns a Collection of the last two entries. If it is not + * provided the new Collection will begin at the beginning of this Collection. + * + * If end is negative, it is offset from the end of the Collection. e.g. + * `slice(0, -1)` returns a Collection of everything but the last entry. If + * it is not provided, the new Collection will continue through the end of + * this Collection. + * + * If the requested slice is equivalent to the current Collection, then it + * will return itself. + */ + slice(begin?: number, end?: number): this; + + /** + * Returns a new Collection of the same type containing all entries except + * the first. + */ + rest(): this; + + /** + * Returns a new Collection of the same type containing all entries except + * the last. + */ + butLast(): this; + + /** + * Returns a new Collection of the same type which excludes the first `amount` + * entries from this Collection. + */ + skip(amount: number): this; + + /** + * Returns a new Collection of the same type which excludes the last `amount` + * entries from this Collection. + */ + skipLast(amount: number): this; + + /** + * Returns a new Collection of the same type which includes entries starting + * from when `predicate` first returns false. + * + * + * ```js + * const { List } = require('immutable') + * List([ 'dog', 'frog', 'cat', 'hat', 'god' ]) + * .skipWhile(x => x.match(/g/)) + * // List [ "cat", "hat", "god"" ] + * ``` + */ + skipWhile( + predicate: (value: V, key: K, iter: this) => boolean, + context?: any + ): this; + + /** + * Returns a new Collection of the same type which includes entries starting + * from when `predicate` first returns true. + * + * + * ```js + * const { List } = require('immutable') + * List([ 'dog', 'frog', 'cat', 'hat', 'god' ]) + * .skipUntil(x => x.match(/hat/)) + * // List [ "hat", "god"" ] + * ``` + */ + skipUntil( + predicate: (value: V, key: K, iter: this) => boolean, + context?: any + ): this; + + /** + * Returns a new Collection of the same type which includes the first `amount` + * entries from this Collection. + */ + take(amount: number): this; + + /** + * Returns a new Collection of the same type which includes the last `amount` + * entries from this Collection. + */ + takeLast(amount: number): this; + + /** + * Returns a new Collection of the same type which includes entries from this + * Collection as long as the `predicate` returns true. + * + * + * ```js + * const { List } = require('immutable') + * List([ 'dog', 'frog', 'cat', 'hat', 'god' ]) + * .takeWhile(x => x.match(/o/)) + * // List [ "dog", "frog" ] + * ``` + */ + takeWhile( + predicate: (value: V, key: K, iter: this) => boolean, + context?: any + ): this; + + /** + * Returns a new Collection of the same type which includes entries from this + * Collection as long as the `predicate` returns false. + * + * + * ```js + * const { List } = require('immutable') + * List([ 'dog', 'frog', 'cat', 'hat', 'god' ]) + * .takeUntil(x => x.match(/at/)) + * // List [ "dog", "frog" ] + * ``` + */ + takeUntil( + predicate: (value: V, key: K, iter: this) => boolean, + context?: any + ): this; + + + // Combination + + /** + * Returns a new Collection of the same type with other values and + * collection-like concatenated to this one. + * + * For Seqs, all entries will be present in the resulting Seq, even if they + * have the same key. + */ + concat(...valuesOrCollections: Array): Collection; + + /** + * Flattens nested Collections. + * + * Will deeply flatten the Collection by default, returning a Collection of the + * same type, but a `depth` can be provided in the form of a number or + * boolean (where true means to shallowly flatten one level). A depth of 0 + * (or shallow: false) will deeply flatten. + * + * Flattens only others Collection, not Arrays or Objects. + * + * Note: `flatten(true)` operates on Collection> and + * returns Collection + */ + flatten(depth?: number): Collection; + flatten(shallow?: boolean): Collection; + + /** + * Flat-maps the Collection, returning a Collection of the same type. + * + * Similar to `collection.map(...).flatten(true)`. + */ + flatMap( + mapper: (value: V, key: K, iter: this) => Iterable, + context?: any + ): Collection; + + // Reducing a value + + /** + * Reduces the Collection to a value by calling the `reducer` for every entry + * in the Collection and passing along the reduced value. + * + * If `initialReduction` is not provided, the first item in the + * Collection will be used. + * + * @see `Array#reduce`. + */ + reduce( + reducer: (reduction: R, value: V, key: K, iter: this) => R, + initialReduction: R, + context?: any + ): R; + reduce( + reducer: (reduction: V | R, value: V, key: K, iter: this) => R + ): R; + + /** + * Reduces the Collection in reverse (from the right side). + * + * Note: Similar to this.reverse().reduce(), and provided for parity + * with `Array#reduceRight`. + */ + reduceRight( + reducer: (reduction: R, value: V, key: K, iter: this) => R, + initialReduction: R, + context?: any + ): R; + reduceRight( + reducer: (reduction: V | R, value: V, key: K, iter: this) => R + ): R; + + /** + * True if `predicate` returns true for all entries in the Collection. + */ + every( + predicate: (value: V, key: K, iter: this) => boolean, + context?: any + ): boolean; + + /** + * True if `predicate` returns true for any entry in the Collection. + */ + some( + predicate: (value: V, key: K, iter: this) => boolean, + context?: any + ): boolean; + + /** + * Joins values together as a string, inserting a separator between each. + * The default separator is `","`. + */ + join(separator?: string): string; + + /** + * Returns true if this Collection includes no values. + * + * For some lazy `Seq`, `isEmpty` might need to iterate to determine + * emptiness. At most one iteration will occur. + */ + isEmpty(): boolean; + + /** + * Returns the size of this Collection. + * + * Regardless of if this Collection can describe its size lazily (some Seqs + * cannot), this method will always return the correct size. E.g. it + * evaluates a lazy `Seq` if necessary. + * + * If `predicate` is provided, then this returns the count of entries in the + * Collection for which the `predicate` returns true. + */ + count(): number; + count( + predicate: (value: V, key: K, iter: this) => boolean, + context?: any + ): number; + + /** + * Returns a `Seq.Keyed` of counts, grouped by the return value of + * the `grouper` function. + * + * Note: This is not a lazy operation. + */ + countBy( + grouper: (value: V, key: K, iter: this) => G, + context?: any + ): Map; + + + // Search for value + + /** + * Returns the first value for which the `predicate` returns true. + */ + find( + predicate: (value: V, key: K, iter: this) => boolean, + context?: any, + notSetValue?: V + ): V | undefined; + + /** + * Returns the last value for which the `predicate` returns true. + * + * Note: `predicate` will be called for each entry in reverse. + */ + findLast( + predicate: (value: V, key: K, iter: this) => boolean, + context?: any, + notSetValue?: V + ): V | undefined; + + /** + * Returns the first [key, value] entry for which the `predicate` returns true. + */ + findEntry( + predicate: (value: V, key: K, iter: this) => boolean, + context?: any, + notSetValue?: V + ): [K, V] | undefined; + + /** + * Returns the last [key, value] entry for which the `predicate` + * returns true. + * + * Note: `predicate` will be called for each entry in reverse. + */ + findLastEntry( + predicate: (value: V, key: K, iter: this) => boolean, + context?: any, + notSetValue?: V + ): [K, V] | undefined; + + /** + * Returns the key for which the `predicate` returns true. + */ + findKey( + predicate: (value: V, key: K, iter: this) => boolean, + context?: any + ): K | undefined; + + /** + * Returns the last key for which the `predicate` returns true. + * + * Note: `predicate` will be called for each entry in reverse. + */ + findLastKey( + predicate: (value: V, key: K, iter: this) => boolean, + context?: any + ): K | undefined; + + /** + * Returns the key associated with the search value, or undefined. + */ + keyOf(searchValue: V): K | undefined; + + /** + * Returns the last key associated with the search value, or undefined. + */ + lastKeyOf(searchValue: V): K | undefined; + + /** + * Returns the maximum value in this collection. If any values are + * comparatively equivalent, the first one found will be returned. + * + * The `comparator` is used in the same way as `Collection#sort`. If it is not + * provided, the default comparator is `>`. + * + * When two values are considered equivalent, the first encountered will be + * returned. Otherwise, `max` will operate independent of the order of input + * as long as the comparator is commutative. The default comparator `>` is + * commutative *only* when types do not differ. + * + * If `comparator` returns 0 and either value is NaN, undefined, or null, + * that value will be returned. + */ + max(comparator?: (valueA: V, valueB: V) => number): V | undefined; + + /** + * Like `max`, but also accepts a `comparatorValueMapper` which allows for + * comparing by more sophisticated means: + * + * hitters.maxBy(hitter => hitter.avgHits); + * + */ + maxBy( + comparatorValueMapper: (value: V, key: K, iter: this) => C, + comparator?: (valueA: C, valueB: C) => number + ): V | undefined; + + /** + * Returns the minimum value in this collection. If any values are + * comparatively equivalent, the first one found will be returned. + * + * The `comparator` is used in the same way as `Collection#sort`. If it is not + * provided, the default comparator is `<`. + * + * When two values are considered equivalent, the first encountered will be + * returned. Otherwise, `min` will operate independent of the order of input + * as long as the comparator is commutative. The default comparator `<` is + * commutative *only* when types do not differ. + * + * If `comparator` returns 0 and either value is NaN, undefined, or null, + * that value will be returned. + */ + min(comparator?: (valueA: V, valueB: V) => number): V | undefined; + + /** + * Like `min`, but also accepts a `comparatorValueMapper` which allows for + * comparing by more sophisticated means: + * + * hitters.minBy(hitter => hitter.avgHits); + * + */ + minBy( + comparatorValueMapper: (value: V, key: K, iter: this) => C, + comparator?: (valueA: C, valueB: C) => number + ): V | undefined; + + + // Comparison + + /** + * True if `iter` includes every value in this Collection. + */ + isSubset(iter: Iterable): boolean; + + /** + * True if this Collection includes every value in `iter`. + */ + isSuperset(iter: Iterable): boolean; + } + diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts new file mode 100644 index 0000000000..35c9ecd64b --- /dev/null +++ b/dist/immutable.d.ts @@ -0,0 +1,4506 @@ +/** + * Copyright (c) 2014-2015, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + +/** + * Immutable data encourages pure functions (data-in, data-out) and lends itself + * to much simpler application development and enabling techniques from + * functional programming such as lazy evaluation. + * + * While designed to bring these powerful functional concepts to JavaScript, it + * presents an Object-Oriented API familiar to Javascript engineers and closely + * mirroring that of Array, Map, and Set. It is easy and efficient to convert to + * and from plain Javascript types. + * + * ## How to read these docs + * + * In order to better explain what kinds of values the Immutable.js API expects + * and produces, this documentation is presented in a statically typed dialect of + * JavaScript (like [Flow][] or [TypeScript][]). You *don't need* to use these + * type checking tools in order to use Immutable.js, however becoming familiar + * with their syntax will help you get a deeper understanding of this API. + * + * **A few examples and how to read them.** + * + * All methods describe the kinds of data they accept and the kinds of data + * they return. For example a function which accepts two numbers and returns + * a number would look like this: + * + * ```js + * sum(first: number, second: number): number + * ``` + * + * Sometimes, methods can accept different kinds of data or return different + * kinds of data, and this is described with a *type variable*, which is + * typically in all-caps. For example, a function which always returns the same + * kind of data it was provided would look like this: + * + * ```js + * identity(value: T): T + * ``` + * + * Type variables are defined with classes and referred to in methods. For + * example, a class that holds onto a value for you might look like this: + * + * ```js + * class Box { + * constructor(value: T) + * getValue(): T + * } + * ``` + * + * In order to manipulate Immutable data, methods that we're used to affecting + * a Collection instead return a new Collection of the same type. The type + * `this` refers to the same kind of class. For example, a List which returns + * new Lists when you `push` a value onto it might look like: + * + * ```js + * class List { + * push(value: T): this + * } + * ``` + * + * Many methods in Immutable.js accept values which implement the JavaScript + * [Iterable][] protocol, and might appear like `Iterable` for something + * which represents sequence of strings. Typically in JavaScript we use plain + * Arrays (`[]`) when an Iterable is expected, but also all of the Immutable.js + * collections are iterable themselves! + * + * For example, to get a value deep within a structure of data, we might use + * `getIn` which expects an `Iterable` path: + * + * ``` + * getIn(path: Iterable): any + * ``` + * + * To use this method, we could pass an array: `data.getIn([ "key", 2 ])`. + * + * + * Note: All examples are presented in the modern [ES2015][] version of + * JavaScript. To run in older browsers, they need to be translated to ES3. + * + * For example: + * + * ```js + * // ES2015 + * const mappedFoo = foo.map(x => x * x); + * // ES3 + * var mappedFoo = foo.map(function (x) { return x * x; }); + * ``` + * + * [ES2015]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/New_in_JavaScript/ECMAScript_6_support_in_Mozilla + * [TypeScript]: http://www.typescriptlang.org/ + * [Flow]: https://flowtype.org/ + * [Iterable]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols + */ + +declare module Immutable { + + /** + * Deeply converts plain JS objects and arrays to Immutable Maps and Lists. + * + * If a `reviver` is optionally provided, it will be called with every + * collection as a Seq (beginning with the most nested collections + * and proceeding to the top-level collection itself), along with the key + * refering to each collection and the parent JS object provided as `this`. + * For the top level, object, the key will be `""`. This `reviver` is expected + * to return a new Immutable Collection, allowing for custom conversions from + * deep JS objects. Finally, a `path` is provided which is the sequence of + * keys to this value from the starting value. + * + * `reviver` acts similarly to the [same parameter in `JSON.parse`][1]. + * + * If `reviver` is not provided, the default behavior will convert Objects + * into Maps and Arrays into Lists like so: + * + * ```js + * const { fromJS, isKeyed } = require('immutable') + * function (key, value) { + * return isKeyed(value) ? value.Map() : value.toList() + * } + * ``` + * + * `fromJS` is conservative in its conversion. It will only convert + * arrays which pass `Array.isArray` to Lists, and only raw objects (no custom + * prototype) to Map. + * + * Accordingly, this example converts native JS data to OrderedMap and List: + * + * ```js + * const { fromJS, isKeyed } = require('immutable') + * fromJS({ a: {b: [10, 20, 30]}, c: 40}, function (key, value, path) { + * console.log(key, value, path) + * return isKeyed(value) ? value.toOrderedMap() : value.toList() + * }) + * + * > "b", [ 10, 20, 30 ], [ "a", "b" ] + * > "a", {b: [10, 20, 30]}, [ "a" ] + * > "", {a: {b: [10, 20, 30]}, c: 40}, [] + * ``` + * + * Keep in mind, when using JS objects to construct Immutable Maps, that + * JavaScript Object properties are always strings, even if written in a + * quote-less shorthand, while Immutable Maps accept keys of any type. + * + * + * ```js + * let obj = { 1: "one" }; + * Object.keys(obj); // [ "1" ] + * assert.equal(obj["1"], obj[1]); // "one" === "one" + * + * let map = Map(obj); + * assert.notEqual(map.get("1"), map.get(1)); // "one" !== undefined + * ``` + * + * Property access for JavaScript Objects first converts the key to a string, + * but since Immutable Map keys can be of any type the argument to `get()` is + * not altered. + * + * [1]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse#Example.3A_Using_the_reviver_parameter + * "Using the reviver parameter" + */ + export function fromJS( + jsValue: any, + reviver?: ( + key: string | number, + sequence: Collection.Keyed | Collection.Indexed, + path?: Array + ) => any + ): any; + + + /** + * Value equality check with semantics similar to `Object.is`, but treats + * Immutable `Collection`s as values, equal if the second `Collection` includes + * equivalent values. + * + * It's used throughout Immutable when checking for equality, including `Map` + * key equality and `Set` membership. + * + * + * ```js + * const { Map, is } = require('immutable') + * const map1 = Map({ a: 1, b: 1, c: 1 }) + * const map2 = Map({ a: 1, b: 1, c: 1 }) + * assert.equal(map1 !== map2, true) + * assert.equal(Object.is(map1, map2), false) + * assert.equal(is(map1, map2), true) + * ``` + * + * `is()` compares primitive types like strings and numbers, Immutable.js + * collections like `Map` and `List`, but also any custom object which + * implements `ValueObject` by providing `equals()` and `hashCode()` methods. + * + * Note: Unlike `Object.is`, `Immutable.is` assumes `0` and `-0` are the same + * value, matching the behavior of ES6 Map key equality. + */ + export function is(first: any, second: any): boolean; + + + /** + * The `hash()` function is an important part of how Immutable determines if + * two values are equivalent and is used to determine how to store those + * values. Provided with any value, `hash()` will return a 31-bit integer. + * + * When designing Objects which may be equal, it's important than when a + * `.equals()` method returns true, that both values `.hashCode()` method + * return the same value. `hash()` may be used to produce those values. + * + * Note that `hash()` attempts to balance between speed and avoiding + * collisions, however it makes no attempt to produce secure hashes. + * + * *New in Version 4.0* + */ + export function hash(value: any): number; + + /** + * True if `maybeImmutable` is an Immutable Collection or Record. + * + * ```js + * const { isImmutable, Map, List, Stack } = require('immutable'); + * isImmutable([]); // false + * isImmutable({}); // false + * isImmutable(Map()); // true + * isImmutable(List()); // true + * isImmutable(Stack()); // true + * isImmutable(Map().asMutable()); // false + * ``` + */ + export function isImmutable(maybeImmutable: any): maybeImmutable is Collection; + + /** + * True if `maybeCollection` is a Collection, or any of its subclasses. + * + * ```js + * const { isCollection, Map, List, Stack } = require('immutable'); + * isCollection([]); // false + * isCollection({}); // false + * isCollection(Map()); // true + * isCollection(List()); // true + * isCollection(Stack()); // true + * ``` + */ + export function isCollection(maybeCollection: any): maybeCollection is Collection; + + /** + * True if `maybeKeyed` is a Collection.Keyed, or any of its subclasses. + * + * ```js + * const { isKeyed, Map, List, Stack } = require('immutable'); + * isKeyed([]); // false + * isKeyed({}); // false + * isKeyed(Map()); // true + * isKeyed(List()); // false + * isKeyed(Stack()); // false + * ``` + */ + export function isKeyed(maybeKeyed: any): maybeKeyed is Collection.Keyed; + + /** + * True if `maybeIndexed` is a Collection.Indexed, or any of its subclasses. + * + * ```js + * const { isIndexed, Map, List, Stack, Set } = require('immutable'); + * isIndexed([]); // false + * isIndexed({}); // false + * isIndexed(Map()); // false + * isIndexed(List()); // true + * isIndexed(Stack()); // true + * isIndexed(Set()); // false + * ``` + */ + export function isIndexed(maybeIndexed: any): maybeIndexed is Collection.Indexed; + + /** + * True if `maybeAssociative` is either a Keyed or Indexed Collection. + * + * ```js + * const { isAssociative, Map, List, Stack, Set } = require('immutable'); + * isAssociative([]); // false + * isAssociative({}); // false + * isAssociative(Map()); // true + * isAssociative(List()); // true + * isAssociative(Stack()); // true + * isAssociative(Set()); // false + * ``` + */ + export function isAssociative(maybeAssociative: any): maybeAssociative is Collection.Keyed | Collection.Indexed; + + /** + * True if `maybeOrdered` is a Collection where iteration order is well + * defined. True for Collection.Indexed as well as OrderedMap and OrderedSet. + * + * ```js + * const { isOrdered, Map, OrderedMap, List, Set } = require('immutable'); + * isOrdered([]); // false + * isOrdered({}); // false + * isOrdered(Map()); // false + * isOrdered(OrderedMap()); // true + * isOrdered(List()); // true + * isOrdered(Set()); // false + * ``` + */ + export function isOrdered(maybeOrdered: any): boolean; + + /** + * True if `maybeValue` is a JavaScript Object which has *both* `equals()` + * and `hashCode()` methods. + * + * Any two instances of *value objects* can be compared for value equality with + * `Immutable.is()` and can be used as keys in a `Map` or members in a `Set`. + */ + export function isValueObject(maybeValue: any): maybeValue is ValueObject; + + /** + * The interface to fulfill to qualify as a Value Object. + */ + export interface ValueObject { + /** + * True if this and the other Collection have value equality, as defined + * by `Immutable.is()`. + * + * Note: This is equivalent to `Immutable.is(this, other)`, but provided to + * allow for chained expressions. + */ + equals(other: any): boolean; + + /** + * Computes and returns the hashed identity for this Collection. + * + * The `hashCode` of a Collection is used to determine potential equality, + * and is used when adding this to a `Set` or as a key in a `Map`, enabling + * lookup via a different instance. + * + * + * ```js + * const a = List([ 1, 2, 3 ]); + * const b = List([ 1, 2, 3 ]); + * assert.notStrictEqual(a, b); // different instances + * const set = Set([ a ]); + * assert.equal(set.has(b), true); + * ``` + * + * Note: hashCode() MUST return a Uint32 number. The easiest way to + * guarantee this is to return `myHash | 0` from a custom implementation. + * + * If two values have the same `hashCode`, they are [not guaranteed + * to be equal][Hash Collision]. If two values have different `hashCode`s, + * they must not be equal. + * + * [Hash Collision]: http://en.wikipedia.org/wiki/Collision_(computer_science) + */ + hashCode(): number; + } + + /** + * Lists are ordered indexed dense collections, much like a JavaScript + * Array. + * + * Lists are immutable and fully persistent with O(log32 N) gets and sets, + * and O(1) push and pop. + * + * Lists implement Deque, with efficient addition and removal from both the + * end (`push`, `pop`) and beginning (`unshift`, `shift`). + * + * Unlike a JavaScript Array, there is no distinction between an + * "unset" index and an index set to `undefined`. `List#forEach` visits all + * indices from 0 to size, regardless of whether they were explicitly defined. + */ + export module List { + + /** + * True if the provided value is a List + * + * + * ```js + * List.isList([]); // false + * List.isList(List()); // true + * ``` + */ + function isList(maybeList: any): maybeList is List; + + /** + * Creates a new List containing `values`. + * + * + * ```js + * List.of(1, 2, 3, 4) + * // List [ 1, 2, 3, 4 ] + * ``` + * + * Note: Values are not altered or converted in any way. + * + * + * ```js + * List.of({x:1}, 2, [3], 4) + * // List [ { x: 1 }, 2, [ 3 ], 4 ] + * ``` + */ + function of(...values: Array): List; + } + + /** + * Create a new immutable List containing the values of the provided + * collection-like. + * + * + * ```js + * const { List, Set } = require('immutable') + * + * const emptyList = List() + * // List [] + * + * const plainArray = [ 1, 2, 3, 4 ] + * const listFromPlainArray = List(plainArray) + * // List [ 1, 2, 3, 4 ] + * + * const plainSet = Set([ 1, 2, 3, 4 ]) + * const listFromPlainSet = List(plainSet) + * // List [ 1, 2, 3, 4 ] + * + * const arrayIterator = plainArray[Symbol.iterator]() + * const listFromCollectionArray = List(arrayIterator) + * // List [ 1, 2, 3, 4 ] + * + * listFromPlainArray.equals(listFromCollectionArray) // true + * listFromPlainSet.equals(listFromCollectionArray) // true + * listFromPlainSet.equals(listFromPlainArray) // true + * ``` + */ + export function List(): List; + export function List(): List; + export function List(collection: Iterable): List; + + export interface List extends Collection.Indexed { + + /** + * The number of items in this List. + */ + readonly size: number; + + // Persistent changes + + /** + * Returns a new List which includes `value` at `index`. If `index` already + * exists in this List, it will be replaced. + * + * `index` may be a negative number, which indexes back from the end of the + * List. `v.set(-1, "value")` sets the last item in the List. + * + * If `index` larger than `size`, the returned List's `size` will be large + * enough to include the `index`. + * + * + * ```js + * const originalList = List([ 0 ]); + * // List [ 0 ] + * originalList.set(1, 1); + * // List [ 0, 1 ] + * originalList.set(0, 'overwritten'); + * // List [ "overwritten" ] + * originalList.set(2, 2); + * // List [ 0, undefined, 2 ] + * + * List().set(50000, 'value').size; + * // 50001 + * ``` + * + * Note: `set` can be used in `withMutations`. + */ + set(index: number, value: T): List; + + /** + * Returns a new List which excludes this `index` and with a size 1 less + * than this List. Values at indices above `index` are shifted down by 1 to + * fill the position. + * + * This is synonymous with `list.splice(index, 1)`. + * + * `index` may be a negative number, which indexes back from the end of the + * List. `v.delete(-1)` deletes the last item in the List. + * + * Note: `delete` cannot be safely used in IE8 + * + * + * ```js + * List([ 0, 1, 2, 3, 4 ]).delete(0); + * // List [ 1, 2, 3, 4 ] + * ``` + * + * Note: `delete` *cannot* be used in `withMutations`. + * + * @alias remove + */ + delete(index: number): List; + remove(index: number): List; + + /** + * Returns a new List with `value` at `index` with a size 1 more than this + * List. Values at indices above `index` are shifted over by 1. + * + * This is synonymous with `list.splice(index, 0, value)`. + * + * + * ```js + * List([ 0, 1, 2, 3, 4 ]).insert(6, 5) + * // List [ 0, 1, 2, 3, 4, 5 ] + * ``` + * + * Note: `insert` *cannot* be used in `withMutations`. + */ + insert(index: number, value: T): List; + + /** + * Returns a new List with 0 size and no values. + * + * + * ```js + * List([ 1, 2, 3, 4 ]).clear() + * // List [] + * ``` + * + * Note: `clear` can be used in `withMutations`. + */ + clear(): List; + + /** + * Returns a new List with the provided `values` appended, starting at this + * List's `size`. + * + * + * ```js + * List([ 1, 2, 3, 4 ]).push(5) + * // List [ 1, 2, 3, 4, 5 ] + * ``` + * + * Note: `push` can be used in `withMutations`. + */ + push(...values: Array): List; + + /** + * Returns a new List with a size ones less than this List, excluding + * the last index in this List. + * + * Note: this differs from `Array#pop` because it returns a new + * List rather than the removed value. Use `last()` to get the last value + * in this List. + * + * ```js + * List([ 1, 2, 3, 4 ]).pop() + * // List[ 1, 2, 3 ] + * ``` + * + * Note: `pop` can be used in `withMutations`. + */ + pop(): List; + + /** + * Returns a new List with the provided `values` prepended, shifting other + * values ahead to higher indices. + * + * + * ```js + * List([ 2, 3, 4]).unshift(1); + * // List [ 1, 2, 3, 4 ] + * ``` + * + * Note: `unshift` can be used in `withMutations`. + */ + unshift(...values: Array): List; + + /** + * Returns a new List with a size ones less than this List, excluding + * the first index in this List, shifting all other values to a lower index. + * + * Note: this differs from `Array#shift` because it returns a new + * List rather than the removed value. Use `first()` to get the first + * value in this List. + * + * + * ```js + * List([ 0, 1, 2, 3, 4 ]).shift(); + * // List [ 1, 2, 3, 4 ] + * ``` + * + * Note: `shift` can be used in `withMutations`. + */ + shift(): List; + + /** + * Returns a new List with an updated value at `index` with the return + * value of calling `updater` with the existing value, or `notSetValue` if + * `index` was not set. If called with a single argument, `updater` is + * called with the List itself. + * + * `index` may be a negative number, which indexes back from the end of the + * List. `v.update(-1)` updates the last item in the List. + * + * + * ```js + * const list = List([ 'a', 'b', 'c' ]) + * const result = list.update(2, val => val.toUpperCase()) + * // List [ "a", "b", "C" ] + * ``` + * + * This can be very useful as a way to "chain" a normal function into a + * sequence of methods. RxJS calls this "let" and lodash calls it "thru". + * + * For example, to sum a List after mapping and filtering: + * + * + * ```js + * function sum(collection) { + * return collection.reduce((sum, x) => sum + x, 0) + * } + * + * List([ 1, 2, 3 ]) + * .map(x => x + 1) + * .filter(x => x % 2 === 0) + * .update(sum) + * // 6 + * ``` + * + * Note: `update(index)` can be used in `withMutations`. + * + * @see `Map#update` + */ + update(index: number, notSetValue: T, updater: (value: T) => T): this; + update(index: number, updater: (value: T) => T): this; + update(updater: (value: this) => R): R; + + /** + * Note: `merge` can be used in `withMutations`. + * + * @see `Map#merge` + */ + merge(...collections: Array | Array>): this; + + /** + * Note: `mergeWith` can be used in `withMutations`. + * + * @see `Map#mergeWith` + */ + mergeWith( + merger: (oldVal: T, newVal: T, key: number) => T, + ...collections: Array | Array> + ): this; + + /** + * Note: `mergeDeep` can be used in `withMutations`. + * + * @see `Map#mergeDeep` + */ + mergeDeep(...collections: Array | Array>): this; + + /** + * Note: `mergeDeepWith` can be used in `withMutations`. + * @see `Map#mergeDeepWith` + */ + mergeDeepWith( + merger: (oldVal: T, newVal: T, key: number) => T, + ...collections: Array | Array> + ): this; + + /** + * Returns a new List with size `size`. If `size` is less than this + * List's size, the new List will exclude values at the higher indices. + * If `size` is greater than this List's size, the new List will have + * undefined values for the newly available indices. + * + * When building a new List and the final size is known up front, `setSize` + * used in conjunction with `withMutations` may result in the more + * performant construction. + */ + setSize(size: number): List; + + + // Deep persistent changes + + /** + * Returns a new List having set `value` at this `keyPath`. If any keys in + * `keyPath` do not exist, a new immutable Map will be created at that key. + * + * Index numbers are used as keys to determine the path to follow in + * the List. + * + * + * ```js + * const { List } = require("immutable") + * const list = List([ 0, 1, 2, List([ 3, 4 ])]) + * list.setIn([3, 0], 999); + * // List [ 0, 1, 2, List [ 999, 4 ] ] + * ``` + * + * Note: `setIn` can be used in `withMutations`. + */ + setIn(keyPath: Iterable, value: any): this; + + /** + * Returns a new List having removed the value at this `keyPath`. If any + * keys in `keyPath` do not exist, no change will occur. + * + * + * ```js + * const { List } = require("immutable") + * const list = List([ 0, 1, 2, List([ 3, 4 ])]) + * list.deleteIn([3, 0]); + * // List [ 0, 1, 2, List [ 4 ] ] + * ``` + * + * Note: `deleteIn` *cannot* be safely used in `withMutations`. + * + * @alias removeIn + */ + deleteIn(keyPath: Iterable): this; + removeIn(keyPath: Iterable): this; + + /** + * Note: `updateIn` can be used in `withMutations`. + * + * @see `Map#updateIn` + */ + updateIn(keyPath: Iterable, notSetValue: any, updater: (value: any) => any): this; + updateIn(keyPath: Iterable, updater: (value: any) => any): this; + + /** + * Note: `mergeIn` can be used in `withMutations`. + * + * @see `Map#mergeIn` + */ + mergeIn(keyPath: Iterable, ...collections: Array): this; + + /** + * Note: `mergeDeepIn` can be used in `withMutations`. + * + * @see `Map#mergeDeepIn` + */ + mergeDeepIn(keyPath: Iterable, ...collections: Array): this; + + // Transient changes + + /** + * Note: Not all methods can be safely used on a mutable collection or within + * `withMutations`! Check the documentation for each method to see if it + * allows being used in `withMutations`. + * + * @see `Map#withMutations` + */ + withMutations(mutator: (mutable: this) => any): this; + + /** + * An alternative API for withMutations() + * + * Note: Not all methods can be safely used on a mutable collection or within + * `withMutations`! Check the documentation for each method to see if it + * allows being used in `withMutations`. + * + * @see `Map#asMutable` + */ + asMutable(): this; + + /** + * @see `Map#asImmutable` + */ + asImmutable(): this; + + // Sequence algorithms + + /** + * Returns a new List with other values or collections concatenated to this one. + */ + concat(...valuesOrCollections: Array | C>): List; + + /** + * Returns a new List with values passed through a + * `mapper` function. + * + * + * ```js + * List([ 1, 2 ]).map(x => 10 * x) + * // List [ 10, 20 ] + * ``` + * + * Note: `map()` always returns a new instance, even if it produced the same + * value at every step. + */ + map( + mapper: (value: T, key: number, iter: this) => M, + context?: any + ): List; + + /** + * Flat-maps the List, returning a new List. + * + * Similar to `list.map(...).flatten(true)`. + */ + flatMap( + mapper: (value: T, key: number, iter: this) => Iterable, + context?: any + ): List; + + /** + * Returns a new List with only the values for which the `predicate` + * function returns true. + * + * Note: `filter()` always returns a new instance, even if it results in + * not filtering out any values. + */ + filter( + predicate: (value: T, index: number, iter: this) => value is F, + context?: any + ): List; + filter( + predicate: (value: T, index: number, iter: this) => any, + context?: any + ): this; + + /** + * Returns a List "zipped" with the provided collection. + * + * Like `zipWith`, but using the default `zipper`: creating an `Array`. + * + * ```js + * const a = List([ 1, 2, 3 ]); + * const b = List([ 4, 5, 6 ]); + * const c = a.zip(b); // List [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] + * ``` + */ + zip(other: Collection): List<[T,U]>; + + /** + * Returns a List "zipped" with the provided collection. + * + * Like `zipWith`, but using the default `zipper`: creating an `Array`. + * + * ```js + * const a = List([ 1, 2, 3 ]); + * const b = List([ 4, 5, 6 ]); + * const c = a.zip(b); // List [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] + * ``` + */ + zip(other: Collection, other2: Collection): List<[T,U,V]>; + + /** + * Returns a List "zipped" with the provided collections. + * + * Like `zipWith`, but using the default `zipper`: creating an `Array`. + * + * + * ```js + * const a = List([ 1, 2, 3 ]); + * const b = List([ 4, 5, 6 ]); + * const c = a.zip(b); // List [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] + * ``` + */ + zip(...collections: Array>): List; + + /** + * Returns a List "zipped" with the provided collections by using a + * custom `zipper` function. + * + * + * ```js + * const a = List([ 1, 2, 3 ]); + * const b = List([ 4, 5, 6 ]); + * const c = a.zipWith((a, b) => a + b, b); + * // List [ 5, 7, 9 ] + * ``` + */ + zipWith( + zipper: (value: T, otherValue: U) => Z, + otherCollection: Collection + ): List; + zipWith( + zipper: (value: T, otherValue: U, thirdValue: V) => Z, + otherCollection: Collection, + thirdCollection: Collection + ): List; + zipWith( + zipper: (...any: Array) => Z, + ...collections: Array> + ): List; + } + + + /** + * Immutable Map is an unordered Collection.Keyed of (key, value) pairs with + * `O(log32 N)` gets and `O(log32 N)` persistent sets. + * + * Iteration order of a Map is undefined, however is stable. Multiple + * iterations of the same Map will iterate in the same order. + * + * Map's keys can be of any type, and use `Immutable.is` to determine key + * equality. This allows the use of any value (including NaN) as a key. + * + * Because `Immutable.is` returns equality based on value semantics, and + * Immutable collections are treated as values, any Immutable collection may + * be used as a key. + * + * + * ```js + * const { Map, List } = require('immutable'); + * Map().set(List([ 1 ]), 'listofone').get(List([ 1 ])); + * // 'listofone' + * ``` + * + * Any JavaScript object may be used as a key, however strict identity is used + * to evaluate key equality. Two similar looking objects will represent two + * different keys. + * + * Implemented by a hash-array mapped trie. + */ + export module Map { + + /** + * True if the provided value is a Map + * + * ```js + * const { Map } = require('immutable') + * Map.isMap({}) // false + * Map.isMap(Map()) // true + * ``` + */ + function isMap(maybeMap: any): maybeMap is Map; + + /** + * Creates a new Map from alternating keys and values + * + * + * ```js + * const { Map } = require('immutable') + * Map.of( + * 'key', 'value', + * 'numerical value', 3, + * 0, 'numerical key' + * ) + * // Map { 0: "numerical key", "key": "value", "numerical value": 3 } + * ``` + * + * @deprecated Use Map([ [ 'k', 'v' ] ]) or Map({ k: 'v' }) + */ + function of(...keyValues: Array): Map; + } + + /** + * Creates a new Immutable Map. + * + * Created with the same key value pairs as the provided Collection.Keyed or + * JavaScript Object or expects a Collection of [K, V] tuple entries. + * + * + * ```js + * const { Map } = require('immutable') + * Map({ key: "value" }) + * Map([ [ "key", "value" ] ]) + * ``` + * + * Keep in mind, when using JS objects to construct Immutable Maps, that + * JavaScript Object properties are always strings, even if written in a + * quote-less shorthand, while Immutable Maps accept keys of any type. + * + * + * ```js + * let obj = { 1: "one" } + * Object.keys(obj) // [ "1" ] + * assert.equal(obj["1"], obj[1]) // "one" === "one" + * + * let map = Map(obj) + * assert.notEqual(map.get("1"), map.get(1)) // "one" !== undefined + * ``` + * + * Property access for JavaScript Objects first converts the key to a string, + * but since Immutable Map keys can be of any type the argument to `get()` is + * not altered. + */ + export function Map(collection: Iterable<[K, V]>): Map; + export function Map(collection: Iterable>): Map; + export function Map(obj: {[key: string]: V}): Map; + export function Map(): Map; + export function Map(): Map; + + export interface Map extends Collection.Keyed { + + /** + * The number of entries in this Map. + */ + readonly size: number; + + // Persistent changes + + /** + * Returns a new Map also containing the new key, value pair. If an equivalent + * key already exists in this Map, it will be replaced. + * + * + * ```js + * const { Map } = require('immutable') + * const originalMap = Map() + * const newerMap = originalMap.set('key', 'value') + * const newestMap = newerMap.set('key', 'newer value') + * + * originalMap + * // Map {} + * newerMap + * // Map { "key": "value" } + * newestMap + * // Map { "key": "newer value" } + * ``` + * + * Note: `set` can be used in `withMutations`. + */ + set(key: K, value: V): this; + + /** + * Returns a new Map which excludes this `key`. + * + * Note: `delete` cannot be safely used in IE8, but is provided to mirror + * the ES6 collection API. + * + * + * ```js + * const { Map } = require('immutable') + * const originalMap = Map({ + * key: 'value', + * otherKey: 'other value' + * }) + * // Map { "key": "value", "otherKey": "other value" } + * originalMap.delete('otherKey') + * // Map { "key": "value" } + * ``` + * + * Note: `delete` can be used in `withMutations`. + * + * @alias remove + */ + delete(key: K): this; + remove(key: K): this; + + /** + * Returns a new Map which excludes the provided `keys`. + * + * ```js + * const { Map } = require('immutable') + * const names = Map({ a: "Aaron", b: "Barry", c: "Connor" }) + * names.deleteAll([ 'a', 'c' ]) + * // Map { "b": "Barry" } + * ``` + * + * Note: `deleteAll` can be used in `withMutations`. + * + * @alias removeAll + */ + deleteAll(keys: Iterable): this; + removeAll(keys: Iterable): this; + + /** + * Returns a new Map containing no keys or values. + * + * + * ```js + * const { Map } = require('immutable') + * Map({ key: 'value' }).clear() + * // Map {} + * ``` + * + * Note: `clear` can be used in `withMutations`. + */ + clear(): this; + + /** + * Returns a new Map having updated the value at this `key` with the return + * value of calling `updater` with the existing value. + * + * Similar to: `map.set(key, updater(map.get(key)))`. + * + * + * ```js + * const { Map } = require('immutable') + * const aMap = Map({ key: 'value' }) + * const newMap = aMap.update('key', value => value + value) + * // Map { "key": "valuevalue" } + * ``` + * + * This is most commonly used to call methods on collections within a + * structure of data. For example, in order to `.push()` onto a nested `List`, + * `update` and `push` can be used together: + * + * + * ```js + * const aMap = Map({ nestedList: List([ 1, 2, 3 ]) }) + * const newMap = aMap.update('nestedList', list => list.push(4)) + * // Map { "nestedList": List [ 1, 2, 3, 4 ] } + * ``` + * + * When a `notSetValue` is provided, it is provided to the `updater` + * function when the value at the key does not exist in the Map. + * + * + * ```js + * const aMap = Map({ key: 'value' }) + * const newMap = aMap.update('noKey', 'no value', value => value + value) + * // Map { "key": "value", "noKey": "no valueno value" } + * ``` + * + * However, if the `updater` function returns the same value it was called + * with, then no change will occur. This is still true if `notSetValue` + * is provided. + * + * + * ```js + * const aMap = Map({ apples: 10 }) + * const newMap = aMap.update('oranges', 0, val => val) + * // Map { "apples": 10 } + * assert.strictEqual(newMap, map); + * ``` + * + * For code using ES2015 or later, using `notSetValue` is discourged in + * favor of function parameter default values. This helps to avoid any + * potential confusion with identify functions as described above. + * + * The previous example behaves differently when written with default values: + * + * + * ```js + * const aMap = Map({ apples: 10 }) + * const newMap = aMap.update('oranges', (val = 0) => val) + * // Map { "apples": 10, "oranges": 0 } + * ``` + * + * If no key is provided, then the `updater` function return value is + * returned as well. + * + * + * ```js + * const aMap = Map({ key: 'value' }) + * const result = aMap.update(aMap => aMap.get('key')) + * // "value" + * ``` + * + * This can be very useful as a way to "chain" a normal function into a + * sequence of methods. RxJS calls this "let" and lodash calls it "thru". + * + * For example, to sum the values in a Map + * + * + * ```js + * function sum(collection) { + * return collection.reduce((sum, x) => sum + x, 0) + * } + * + * Map({ x: 1, y: 2, z: 3 }) + * .map(x => x + 1) + * .filter(x => x % 2 === 0) + * .update(sum) + * // 6 + * ``` + * + * Note: `update(key)` can be used in `withMutations`. + */ + update(key: K, notSetValue: V, updater: (value: V) => V): this; + update(key: K, updater: (value: V) => V): this; + update(updater: (value: this) => R): R; + + /** + * Returns a new Map resulting from merging the provided Collections + * (or JS objects) into this Map. In other words, this takes each entry of + * each collection and sets it on this Map. + * + * If any of the values provided to `merge` are not Collection (would return + * false for `isCollection`) then they are deeply converted + * via `fromJS` before being merged. However, if the value is an + * Collection but includes non-collection JS objects or arrays, those nested + * values will be preserved. + * + * + * ```js + * const { Map } = require('immutable') + * const one = Map({ a: 10, b: 20, c: 30 }) + * const two = Map({ b: 40, a: 50, d: 60 }) + * one.merge(two) // Map { "a": 50, "b": 40, "c": 30, "d": 60 } + * two.merge(one) // Map { "b": 20, "a": 10, "d": 60, "c": 30 } + * ``` + * + * Note: `merge` can be used in `withMutations`. + */ + merge(...collections: Array | {[key: string]: V}>): this; + + /** + * Like `merge()`, `mergeWith()` returns a new Map resulting from merging + * the provided Collections (or JS objects) into this Map, but uses the + * `merger` function for dealing with conflicts. + * + * + * ```js + * const { Map } = require('immutable') + * const one = Map({ a: 10, b: 20, c: 30 }) + * const two = Map({ b: 40, a: 50, d: 60 }) + * one.mergeWith((oldVal, newVal) => oldVal / newVal, two) + * // { "a": 0.2, "b": 0.5, "c": 30, "d": 60 } + * two.mergeWith((oldVal, newVal) => oldVal / newVal, one) + * // { "b": 2, "a": 5, "d": 60, "c": 30 } + * ``` + * + * Note: `mergeWith` can be used in `withMutations`. + */ + mergeWith( + merger: (oldVal: V, newVal: V, key: K) => V, + ...collections: Array | {[key: string]: V}> + ): this; + + /** + * Like `merge()`, but when two Collections conflict, it merges them as well, + * recursing deeply through the nested data. + * + * + * ```js + * const { Map } = require('immutable') + * const one = Map({ a: Map({ x: 10, y: 10 }), b: Map({ x: 20, y: 50 }) }) + * const two = Map({ a: Map({ x: 2 }), b: Map({ y: 5 }), c: Map({ z: 3 }) }) + * one.mergeDeep(two) + * // Map { + * // "a": Map { "x": 2, "y": 10 }, + * // "b": Map { "x": 20, "y": 5 }, + * // "c": Map { "z": 3 } + * // } + * ``` + * + * Note: `mergeDeep` can be used in `withMutations`. + */ + mergeDeep(...collections: Array | {[key: string]: V}>): this; + + /** + * Like `mergeDeep()`, but when two non-Collections conflict, it uses the + * `merger` function to determine the resulting value. + * + * + * ```js + * const { Map } = require('immutable') + * const one = Map({ a: Map({ x: 10, y: 10 }), b: Map({ x: 20, y: 50 }) }) + * const two = Map({ a: Map({ x: 2 }), b: Map({ y: 5 }), c: Map({ z: 3 }) }) + * one.mergeDeepWith((oldVal, newVal) => oldVal / newVal, two) + * // Map { + * // "a": Map { "x": 5, "y": 10 }, + * // "b": Map { "x": 20, "y": 10 }, + * // "c": Map { "z": 3 } + * // } + * ``` + + * Note: `mergeDeepWith` can be used in `withMutations`. + */ + mergeDeepWith( + merger: (oldVal: V, newVal: V, key: K) => V, + ...collections: Array | {[key: string]: V}> + ): this; + + + // Deep persistent changes + + /** + * Returns a new Map having set `value` at this `keyPath`. If any keys in + * `keyPath` do not exist, a new immutable Map will be created at that key. + * + * + * ```js + * const { Map } = require('immutable') + * const originalMap = Map({ + * subObject: Map({ + * subKey: 'subvalue', + * subSubObject: Map({ + * subSubKey: 'subSubValue' + * }) + * }) + * }) + * + * const newMap = originalMap.setIn(['subObject', 'subKey'], 'ha ha!') + * // Map { + * // "subObject": Map { + * // "subKey": "ha ha!", + * // "subSubObject": Map { "subSubKey": "subSubValue" } + * // } + * // } + * + * const newerMap = originalMap.setIn( + * ['subObject', 'subSubObject', 'subSubKey'], + * 'ha ha ha!' + * ) + * // Map { + * // "subObject": Map { + * // "subKey": "ha ha!", + * // "subSubObject": Map { "subSubKey": "ha ha ha!" } + * // } + * // } + * ``` + * + * If any key in the path exists but does not have a `.set()` method + * (such as Map and List), an error will be throw. + * + * Note: `setIn` can be used in `withMutations`. + */ + setIn(keyPath: Iterable, value: any): this; + + /** + * Returns a new Map having removed the value at this `keyPath`. If any keys + * in `keyPath` do not exist, no change will occur. + * + * Note: `deleteIn` can be used in `withMutations`. + * + * @alias removeIn + */ + deleteIn(keyPath: Iterable): this; + removeIn(keyPath: Iterable): this; + + /** + * Returns a new Map having applied the `updater` to the entry found at the + * keyPath. + * + * This is most commonly used to call methods on collections nested within a + * structure of data. For example, in order to `.push()` onto a nested `List`, + * `updateIn` and `push` can be used together: + * + * + * ```js + * const { Map, List } = require('immutable') + * const map = Map({ inMap: Map({ inList: List([ 1, 2, 3 ]) }) }) + * const newMap = map.updateIn(['inMap', 'inList'], list => list.push(4)) + * // Map { "inMap": Map { "inList": List [ 1, 2, 3, 4 ] } } + * ``` + * + * If any keys in `keyPath` do not exist, new Immutable `Map`s will + * be created at those keys. If the `keyPath` does not already contain a + * value, the `updater` function will be called with `notSetValue`, if + * provided, otherwise `undefined`. + * + * + * ```js + * const map = Map({ a: Map({ b: Map({ c: 10 }) }) }) + * const newMap = map.updateIn(['a', 'b', 'c'], val => val * 2) + * // Map { "a": Map { "b": Map { "c": 20 } } } + * ``` + * + * If the `updater` function returns the same value it was called with, then + * no change will occur. This is still true if `notSetValue` is provided. + * + * + * ```js + * const map = Map({ a: Map({ b: Map({ c: 10 }) }) }) + * const newMap = map.updateIn(['a', 'b', 'x'], 100, val => val) + * // Map { "a": Map { "b": Map { "c": 10 } } } + * assert.strictEqual(newMap, aMap) + * ``` + * + * For code using ES2015 or later, using `notSetValue` is discourged in + * favor of function parameter default values. This helps to avoid any + * potential confusion with identify functions as described above. + * + * The previous example behaves differently when written with default values: + * + * + * ```js + * const map = Map({ a: Map({ b: Map({ c: 10 }) }) }) + * const newMap = map.updateIn(['a', 'b', 'x'], (val = 100) => val) + * // Map { "a": Map { "b": Map { "c": 10, "x": 100 } } } + * ``` + * + * If any key in the path exists but does not have a .set() method (such as + * Map and List), an error will be thrown. + */ + updateIn(keyPath: Iterable, notSetValue: any, updater: (value: any) => any): this; + updateIn(keyPath: Iterable, updater: (value: any) => any): this; + + /** + * A combination of `updateIn` and `merge`, returning a new Map, but + * performing the merge at a point arrived at by following the keyPath. + * In other words, these two lines are equivalent: + * + * ```js + * map.updateIn(['a', 'b', 'c'], abc => abc.merge(y)) + * map.mergeIn(['a', 'b', 'c'], y) + * ``` + * + * Note: `mergeIn` can be used in `withMutations`. + */ + mergeIn(keyPath: Iterable, ...collections: Array): this; + + /** + * A combination of `updateIn` and `mergeDeep`, returning a new Map, but + * performing the deep merge at a point arrived at by following the keyPath. + * In other words, these two lines are equivalent: + * + * ```js + * map.updateIn(['a', 'b', 'c'], abc => abc.mergeDeep(y)) + * map.mergeDeepIn(['a', 'b', 'c'], y) + * ``` + * + * Note: `mergeDeepIn` can be used in `withMutations`. + */ + mergeDeepIn(keyPath: Iterable, ...collections: Array): this; + + // Transient changes + + /** + * Every time you call one of the above functions, a new immutable Map is + * created. If a pure function calls a number of these to produce a final + * return value, then a penalty on performance and memory has been paid by + * creating all of the intermediate immutable Maps. + * + * If you need to apply a series of mutations to produce a new immutable + * Map, `withMutations()` creates a temporary mutable copy of the Map which + * can apply mutations in a highly performant manner. In fact, this is + * exactly how complex mutations like `merge` are done. + * + * As an example, this results in the creation of 2, not 4, new Maps: + * + * + * ```js + * const { Map } = require('immutable') + * const map1 = Map() + * const map2 = map1.withMutations(map => { + * map.set('a', 1).set('b', 2).set('c', 3) + * }) + * assert.equal(map1.size, 0) + * assert.equal(map2.size, 3) + * ``` + * + * Note: Not all methods can be used on a mutable collection or within + * `withMutations`! Read the documentation for each method to see if it + * is safe to use in `withMutations`. + */ + withMutations(mutator: (mutable: this) => any): this; + + /** + * Another way to avoid creation of intermediate Immutable maps is to create + * a mutable copy of this collection. Mutable copies *always* return `this`, + * and thus shouldn't be used for equality. Your function should never return + * a mutable copy of a collection, only use it internally to create a new + * collection. If possible, use `withMutations` as it provides an easier to + * use API. + * + * Note: if the collection is already mutable, `asMutable` returns itself. + * + * Note: Not all methods can be used on a mutable collection or within + * `withMutations`! Read the documentation for each method to see if it + * is safe to use in `withMutations`. + */ + asMutable(): this; + + /** + * The yin to `asMutable`'s yang. Because it applies to mutable collections, + * this operation is *mutable* and returns itself. Once performed, the mutable + * copy has become immutable and can be safely returned from a function. + */ + asImmutable(): this; + + // Sequence algorithms + + /** + * Returns a new Map with other collections concatenated to this one. + */ + concat(...collections: Array>): Map; + concat(...collections: Array<{[key: string]: C}>): Map; + + /** + * Returns a new Map with values passed through a + * `mapper` function. + * + * Map({ a: 1, b: 2 }).map(x => 10 * x) + * // Map { a: 10, b: 20 } + * + * Note: `map()` always returns a new instance, even if it produced the same + * value at every step. + */ + map( + mapper: (value: V, key: K, iter: this) => M, + context?: any + ): Map; + + /** + * @see Collection.Keyed.mapKeys + */ + mapKeys( + mapper: (key: K, value: V, iter: this) => M, + context?: any + ): Map; + + /** + * @see Collection.Keyed.mapEntries + */ + mapEntries( + mapper: (entry: [K, V], index: number, iter: this) => [KM, VM], + context?: any + ): Map; + + /** + * Flat-maps the Map, returning a new Map. + * + * Similar to `data.map(...).flatten(true)`. + */ + flatMap( + mapper: (value: V, key: K, iter: this) => Iterable<[KM, VM]>, + context?: any + ): Map; + + /** + * Returns a new Map with only the entries for which the `predicate` + * function returns true. + * + * Note: `filter()` always returns a new instance, even if it results in + * not filtering out any values. + */ + filter( + predicate: (value: V, key: K, iter: this) => value is F, + context?: any + ): Map; + filter( + predicate: (value: V, key: K, iter: this) => any, + context?: any + ): this; + } + + + /** + * A type of Map that has the additional guarantee that the iteration order of + * entries will be the order in which they were set(). + * + * The iteration behavior of OrderedMap is the same as native ES6 Map and + * JavaScript Object. + * + * Note that `OrderedMap` are more expensive than non-ordered `Map` and may + * consume more memory. `OrderedMap#set` is amortized O(log32 N), but not + * stable. + */ + + export module OrderedMap { + + /** + * True if the provided value is an OrderedMap. + */ + function isOrderedMap(maybeOrderedMap: any): maybeOrderedMap is OrderedMap; + } + + /** + * Creates a new Immutable OrderedMap. + * + * Created with the same key value pairs as the provided Collection.Keyed or + * JavaScript Object or expects a Collection of [K, V] tuple entries. + * + * The iteration order of key-value pairs provided to this constructor will + * be preserved in the OrderedMap. + * + * let newOrderedMap = OrderedMap({key: "value"}) + * let newOrderedMap = OrderedMap([["key", "value"]]) + * + */ + export function OrderedMap(collection: Iterable<[K, V]>): OrderedMap; + export function OrderedMap(collection: Iterable>): OrderedMap; + export function OrderedMap(obj: {[key: string]: V}): OrderedMap; + export function OrderedMap(): OrderedMap; + export function OrderedMap(): OrderedMap; + + export interface OrderedMap extends Map { + + /** + * The number of entries in this OrderedMap. + */ + readonly size: number; + + // Sequence algorithms + + /** + * Returns a new OrderedMap with other collections concatenated to this one. + */ + concat(...collections: Array>): OrderedMap; + concat(...collections: Array<{[key: string]: C}>): OrderedMap; + + /** + * Returns a new OrderedMap with values passed through a + * `mapper` function. + * + * OrderedMap({ a: 1, b: 2 }).map(x => 10 * x) + * // OrderedMap { "a": 10, "b": 20 } + * + * Note: `map()` always returns a new instance, even if it produced the same + * value at every step. + */ + map( + mapper: (value: V, key: K, iter: this) => M, + context?: any + ): OrderedMap; + + /** + * @see Collection.Keyed.mapKeys + */ + mapKeys( + mapper: (key: K, value: V, iter: this) => M, + context?: any + ): OrderedMap; + + /** + * @see Collection.Keyed.mapEntries + */ + mapEntries( + mapper: (entry: [K, V], index: number, iter: this) => [KM, VM], + context?: any + ): OrderedMap; + + /** + * Flat-maps the OrderedMap, returning a new OrderedMap. + * + * Similar to `data.map(...).flatten(true)`. + */ + flatMap( + mapper: (value: V, key: K, iter: this) => Iterable<[KM, VM]>, + context?: any + ): OrderedMap; + + /** + * Returns a new OrderedMap with only the entries for which the `predicate` + * function returns true. + * + * Note: `filter()` always returns a new instance, even if it results in + * not filtering out any values. + */ + filter( + predicate: (value: V, key: K, iter: this) => value is F, + context?: any + ): OrderedMap; + filter( + predicate: (value: V, key: K, iter: this) => any, + context?: any + ): this; + } + + + /** + * A Collection of unique values with `O(log32 N)` adds and has. + * + * When iterating a Set, the entries will be (value, value) pairs. Iteration + * order of a Set is undefined, however is stable. Multiple iterations of the + * same Set will iterate in the same order. + * + * Set values, like Map keys, may be of any type. Equality is determined using + * `Immutable.is`, enabling Sets to uniquely include other Immutable + * collections, custom value types, and NaN. + */ + export module Set { + + /** + * True if the provided value is a Set + */ + function isSet(maybeSet: any): maybeSet is Set; + + /** + * Creates a new Set containing `values`. + */ + function of(...values: Array): Set; + + /** + * `Set.fromKeys()` creates a new immutable Set containing the keys from + * this Collection or JavaScript Object. + */ + function fromKeys(iter: Collection): Set; + function fromKeys(obj: {[key: string]: any}): Set; + + /** + * `Set.intersect()` creates a new immutable Set that is the intersection of + * a collection of other sets. + * + * ```js + * const { Set } = require('immutable') + * const intersected = Set.intersect([ + * Set([ 'a', 'b', 'c' ]) + * Set([ 'c', 'a', 't' ]) + * ]) + * // Set [ "a", "c"" ] + * ``` + */ + function intersect(sets: Iterable>): Set; + + /** + * `Set.union()` creates a new immutable Set that is the union of a + * collection of other sets. + * + * ```js + * const { Set } = require('immutable') + * const unioned = Set.union([ + * Set([ 'a', 'b', 'c' ]) + * Set([ 'c', 'a', 't' ]) + * ]) + * // Set [ "a", "b", "c", "t"" ] + * ``` + */ + function union(sets: Iterable>): Set; + } + + /** + * Create a new immutable Set containing the values of the provided + * collection-like. + */ + export function Set(): Set; + export function Set(): Set; + export function Set(collection: Iterable): Set; + + export interface Set extends Collection.Set { + + /** + * The number of items in this Set. + */ + readonly size: number; + + // Persistent changes + + /** + * Returns a new Set which also includes this value. + * + * Note: `add` can be used in `withMutations`. + */ + add(value: T): this; + + /** + * Returns a new Set which excludes this value. + * + * Note: `delete` can be used in `withMutations`. + * + * Note: `delete` **cannot** be safely used in IE8, use `remove` if + * supporting old browsers. + * + * @alias remove + */ + delete(value: T): this; + remove(value: T): this; + + /** + * Returns a new Set containing no values. + * + * Note: `clear` can be used in `withMutations`. + */ + clear(): this; + + /** + * Returns a Set including any value from `collections` that does not already + * exist in this Set. + * + * Note: `union` can be used in `withMutations`. + * @alias merge + */ + union(...collections: Array | Array>): this; + merge(...collections: Array | Array>): this; + + /** + * Returns a Set which has removed any values not also contained + * within `collections`. + * + * Note: `intersect` can be used in `withMutations`. + */ + intersect(...collections: Array | Array>): this; + + /** + * Returns a Set excluding any values contained within `collections`. + * + * Note: `subtract` can be used in `withMutations`. + */ + subtract(...collections: Array | Array>): this; + + + // Transient changes + + /** + * Note: Not all methods can be used on a mutable collection or within + * `withMutations`! Check the documentation for each method to see if it + * mentions being safe to use in `withMutations`. + * + * @see `Map#withMutations` + */ + withMutations(mutator: (mutable: this) => any): this; + + /** + * Note: Not all methods can be used on a mutable collection or within + * `withMutations`! Check the documentation for each method to see if it + * mentions being safe to use in `withMutations`. + * + * @see `Map#asMutable` + */ + asMutable(): this; + + /** + * @see `Map#asImmutable` + */ + asImmutable(): this; + + // Sequence algorithms + + /** + * Returns a new Set with other collections concatenated to this one. + */ + concat(...valuesOrCollections: Array | C>): Set; + + /** + * Returns a new Set with values passed through a + * `mapper` function. + * + * Set([1,2]).map(x => 10 * x) + * // Set [10,20] + * + * Note: `map()` always returns a new instance, even if it produced the same + * value at every step. + */ + map( + mapper: (value: T, key: T, iter: this) => M, + context?: any + ): Set; + + /** + * Flat-maps the Set, returning a new Set. + * + * Similar to `set.map(...).flatten(true)`. + */ + flatMap( + mapper: (value: T, key: T, iter: this) => Iterable, + context?: any + ): Set; + + /** + * Returns a new Set with only the values for which the `predicate` + * function returns true. + * + * Note: `filter()` always returns a new instance, even if it results in + * not filtering out any values. + */ + filter( + predicate: (value: T, key: T, iter: this) => value is F, + context?: any + ): Set; + filter( + predicate: (value: T, key: T, iter: this) => any, + context?: any + ): this; + } + + + /** + * A type of Set that has the additional guarantee that the iteration order of + * values will be the order in which they were `add`ed. + * + * The iteration behavior of OrderedSet is the same as native ES6 Set. + * + * Note that `OrderedSet` are more expensive than non-ordered `Set` and may + * consume more memory. `OrderedSet#add` is amortized O(log32 N), but not + * stable. + */ + export module OrderedSet { + + /** + * True if the provided value is an OrderedSet. + */ + function isOrderedSet(maybeOrderedSet: any): boolean; + + /** + * Creates a new OrderedSet containing `values`. + */ + function of(...values: Array): OrderedSet; + + /** + * `OrderedSet.fromKeys()` creates a new immutable OrderedSet containing + * the keys from this Collection or JavaScript Object. + */ + function fromKeys(iter: Collection): OrderedSet; + function fromKeys(obj: {[key: string]: any}): OrderedSet; + } + + /** + * Create a new immutable OrderedSet containing the values of the provided + * collection-like. + */ + export function OrderedSet(): OrderedSet; + export function OrderedSet(): OrderedSet; + export function OrderedSet(collection: Iterable): OrderedSet; + + export interface OrderedSet extends Set { + + /** + * The number of items in this OrderedSet. + */ + readonly size: number; + + // Sequence algorithms + + /** + * Returns a new OrderedSet with other collections concatenated to this one. + */ + concat(...valuesOrCollections: Array | C>): OrderedSet; + + /** + * Returns a new Set with values passed through a + * `mapper` function. + * + * OrderedSet([ 1, 2 ]).map(x => 10 * x) + * // OrderedSet [10, 20] + * + * Note: `map()` always returns a new instance, even if it produced the same + * value at every step. + */ + map( + mapper: (value: T, key: T, iter: this) => M, + context?: any + ): OrderedSet; + + /** + * Flat-maps the OrderedSet, returning a new OrderedSet. + * + * Similar to `set.map(...).flatten(true)`. + */ + flatMap( + mapper: (value: T, key: T, iter: this) => Iterable, + context?: any + ): OrderedSet; + + /** + * Returns a new OrderedSet with only the values for which the `predicate` + * function returns true. + * + * Note: `filter()` always returns a new instance, even if it results in + * not filtering out any values. + */ + filter( + predicate: (value: T, key: T, iter: this) => value is F, + context?: any + ): OrderedSet; + filter( + predicate: (value: T, key: T, iter: this) => any, + context?: any + ): this; + + /** + * Returns an OrderedSet of the same type "zipped" with the provided + * collections. + * + * @see IndexedIterator.zip + * + * Like `zipWith`, but using the default `zipper`: creating an `Array`. + * + * ```js + * const a = OrderedSet([ 1, 2, 3 ]) + * const b = OrderedSet([ 4, 5, 6 ]) + * const c = a.zip(b) + * // OrderedSet [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] + * ``` + */ + zip(other: Collection): OrderedSet<[T,U]>; + + /** + * Returns an OrderedSet of the same type "zipped" with the provided + * collections. + * + * @see IndexedIterator.zip + * + * Like `zipWith`, but using the default `zipper`: creating an `Array`. + * + * ```js + * const a = OrderedSet([ 1, 2, 3 ]) + * const b = OrderedSet([ 4, 5, 6 ]) + * const c = a.zip(b) + * // OrderedSet [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] + * ``` + */ + zip(other1: Collection, other2: Collection): OrderedSet<[T,U,V]>; + + /** + * Returns an OrderedSet of the same type "zipped" with the provided + * collections. + * + * @see IndexedIterator.zip + * + * Like `zipWith`, but using the default `zipper`: creating an `Array`. + * + * ```js + * const a = OrderedSet([ 1, 2, 3 ]) + * const b = OrderedSet([ 4, 5, 6 ]) + * const c = a.zip(b) + * // OrderedSet [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] + * ``` + */ + zip(...collections: Array>): OrderedSet; + + /** + * Returns an OrderedSet of the same type "zipped" with the provided + * collections by using a custom `zipper` function. + * + * @see IndexedIterator.zipWith + */ + zipWith( + zipper: (value: T, otherValue: U) => Z, + otherCollection: Collection + ): OrderedSet; + zipWith( + zipper: (value: T, otherValue: U, thirdValue: V) => Z, + otherCollection: Collection, + thirdCollection: Collection + ): OrderedSet; + zipWith( + zipper: (...any: Array) => Z, + ...collections: Array> + ): OrderedSet; + + } + + + /** + * Stacks are indexed collections which support very efficient O(1) addition + * and removal from the front using `unshift(v)` and `shift()`. + * + * For familiarity, Stack also provides `push(v)`, `pop()`, and `peek()`, but + * be aware that they also operate on the front of the list, unlike List or + * a JavaScript Array. + * + * Note: `reverse()` or any inherent reverse traversal (`reduceRight`, + * `lastIndexOf`, etc.) is not efficient with a Stack. + * + * Stack is implemented with a Single-Linked List. + */ + export module Stack { + + /** + * True if the provided value is a Stack + */ + function isStack(maybeStack: any): maybeStack is Stack; + + /** + * Creates a new Stack containing `values`. + */ + function of(...values: Array): Stack; + } + + /** + * Create a new immutable Stack containing the values of the provided + * collection-like. + * + * The iteration order of the provided collection is preserved in the + * resulting `Stack`. + */ + export function Stack(): Stack; + export function Stack(): Stack; + export function Stack(collection: Iterable): Stack; + + export interface Stack extends Collection.Indexed { + + /** + * The number of items in this Stack. + */ + readonly size: number; + + // Reading values + + /** + * Alias for `Stack.first()`. + */ + peek(): T | undefined; + + + // Persistent changes + + /** + * Returns a new Stack with 0 size and no values. + * + * Note: `clear` can be used in `withMutations`. + */ + clear(): Stack; + + /** + * Returns a new Stack with the provided `values` prepended, shifting other + * values ahead to higher indices. + * + * This is very efficient for Stack. + * + * Note: `unshift` can be used in `withMutations`. + */ + unshift(...values: Array): Stack; + + /** + * Like `Stack#unshift`, but accepts a collection rather than varargs. + * + * Note: `unshiftAll` can be used in `withMutations`. + */ + unshiftAll(iter: Iterable): Stack; + + /** + * Returns a new Stack with a size ones less than this Stack, excluding + * the first item in this Stack, shifting all other values to a lower index. + * + * Note: this differs from `Array#shift` because it returns a new + * Stack rather than the removed value. Use `first()` or `peek()` to get the + * first value in this Stack. + * + * Note: `shift` can be used in `withMutations`. + */ + shift(): Stack; + + /** + * Alias for `Stack#unshift` and is not equivalent to `List#push`. + */ + push(...values: Array): Stack; + + /** + * Alias for `Stack#unshiftAll`. + */ + pushAll(iter: Iterable): Stack; + + /** + * Alias for `Stack#shift` and is not equivalent to `List#pop`. + */ + pop(): Stack; + + + // Transient changes + + /** + * Note: Not all methods can be used on a mutable collection or within + * `withMutations`! Check the documentation for each method to see if it + * mentions being safe to use in `withMutations`. + * + * @see `Map#withMutations` + */ + withMutations(mutator: (mutable: this) => any): this; + + /** + * Note: Not all methods can be used on a mutable collection or within + * `withMutations`! Check the documentation for each method to see if it + * mentions being safe to use in `withMutations`. + * + * @see `Map#asMutable` + */ + asMutable(): this; + + /** + * @see `Map#asImmutable` + */ + asImmutable(): this; + + // Sequence algorithms + + /** + * Returns a new Stack with other collections concatenated to this one. + */ + concat(...valuesOrCollections: Array | C>): Stack; + + /** + * Returns a new Stack with values passed through a + * `mapper` function. + * + * Stack([ 1, 2 ]).map(x => 10 * x) + * // Stack [ 10, 20 ] + * + * Note: `map()` always returns a new instance, even if it produced the same + * value at every step. + */ + map( + mapper: (value: T, key: number, iter: this) => M, + context?: any + ): Stack; + + /** + * Flat-maps the Stack, returning a new Stack. + * + * Similar to `stack.map(...).flatten(true)`. + */ + flatMap( + mapper: (value: T, key: number, iter: this) => M, + context?: any + ): Stack; + + /** + * Returns a new Set with only the values for which the `predicate` + * function returns true. + * + * Note: `filter()` always returns a new instance, even if it results in + * not filtering out any values. + */ + filter( + predicate: (value: T, index: number, iter: this) => value is F, + context?: any + ): Set; + filter( + predicate: (value: T, index: number, iter: this) => any, + context?: any + ): this; + + /** + * Returns a Stack "zipped" with the provided collections. + * + * Like `zipWith`, but using the default `zipper`: creating an `Array`. + * + * ```js + * const a = Stack([ 1, 2, 3 ]); + * const b = Stack([ 4, 5, 6 ]); + * const c = a.zip(b); // Stack [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] + * ``` + */ + zip(other: Collection): Stack<[T,U]>; + + /** + * Returns a Stack "zipped" with the provided collections. + * + * Like `zipWith`, but using the default `zipper`: creating an `Array`. + * + * ```js + * const a = Stack([ 1, 2, 3 ]); + * const b = Stack([ 4, 5, 6 ]); + * const c = a.zip(b); // Stack [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] + * ``` + */ + zip(other: Collection, other2: Collection): Stack<[T,U,V]>; + + /** + * Returns a Stack "zipped" with the provided collections. + * + * Like `zipWith`, but using the default `zipper`: creating an `Array`. + * + * ```js + * const a = Stack([ 1, 2, 3 ]); + * const b = Stack([ 4, 5, 6 ]); + * const c = a.zip(b); // Stack [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] + * ``` + */ + zip(...collections: Array>): Stack; + + /** + * Returns a Stack "zipped" with the provided collections by using a + * custom `zipper` function. + * + * ```js + * const a = Stack([ 1, 2, 3 ]); + * const b = Stack([ 4, 5, 6 ]); + * const c = a.zipWith((a, b) => a + b, b); + * // Stack [ 5, 7, 9 ] + * ``` + */ + zipWith( + zipper: (value: T, otherValue: U) => Z, + otherCollection: Collection + ): Stack; + zipWith( + zipper: (value: T, otherValue: U, thirdValue: V) => Z, + otherCollection: Collection, + thirdCollection: Collection + ): Stack; + zipWith( + zipper: (...any: Array) => Z, + ...collections: Array> + ): Stack; + } + + + /** + * Returns a Seq.Indexed of numbers from `start` (inclusive) to `end` + * (exclusive), by `step`, where `start` defaults to 0, `step` to 1, and `end` to + * infinity. When `start` is equal to `end`, returns empty range. + * + * ```js + * const { Range } = require('immutable') + * Range() // [ 0, 1, 2, 3, ... ] + * Range(10) // [ 10, 11, 12, 13, ... ] + * Range(10, 15) // [ 10, 11, 12, 13, 14 ] + * Range(10, 30, 5) // [ 10, 15, 20, 25 ] + * Range(30, 10, 5) // [ 30, 25, 20, 15 ] + * Range(30, 30, 5) // [] + * ``` + */ + export function Range(start?: number, end?: number, step?: number): Seq.Indexed; + + + /** + * Returns a Seq.Indexed of `value` repeated `times` times. When `times` is + * not defined, returns an infinite `Seq` of `value`. + * + * ```js + * const { Repeat } = require('immutable') + * Repeat('foo') // [ 'foo', 'foo', 'foo', ... ] + * Repeat('bar', 4) // [ 'bar', 'bar', 'bar', 'bar' ] + * ``` + */ + export function Repeat(value: T, times?: number): Seq.Indexed; + + + /** + * Creates a new Class which produces Record instances. A record is similar to + * a JS object, but enforces a specific set of allowed string keys, and has + * default values. + * + * ```js + * const { Record } = require('immutable') + * const ABRecord = Record({ a: 1, b: 2 }) + * const myRecord = new ABRecord({ b: 3 }) + * ``` + * + * Records always have a value for the keys they define. `remove`ing a key + * from a record simply resets it to the default value for that key. + * + * ```js + * myRecord.size // 2 + * myRecord.get('a') // 1 + * myRecord.get('b') // 3 + * const myRecordWithoutB = myRecord.remove('b') + * myRecordWithoutB.get('b') // 2 + * myRecordWithoutB.size // 2 + * ``` + * + * Values provided to the constructor not found in the Record type will + * be ignored. For example, in this case, ABRecord is provided a key "x" even + * though only "a" and "b" have been defined. The value for "x" will be + * ignored for this record. + * + * ```js + * const myRecord = new ABRecord({ b: 3, x: 10 }) + * myRecord.get('x') // undefined + * ``` + * + * Because Records have a known set of string keys, property get access works + * as expected, however property sets will throw an Error. + * + * Note: IE8 does not support property access. Only use `get()` when + * supporting IE8. + * + * ```js + * myRecord.b // 3 + * myRecord.b = 5 // throws Error + * ``` + * + * Record Classes can be extended as well, allowing for custom methods on your + * Record. This is not a common pattern in functional environments, but is in + * many JS programs. + * + * ``` + * class ABRecord extends Record({ a: 1, b: 2 }) { + * getAB() { + * return this.a + this.b; + * } + * } + * + * var myRecord = new ABRecord({b: 3}) + * myRecord.getAB() // 4 + * ``` + */ + export module Record { + + /** + * True if `maybeRecord` is an instance of a Record. + */ + export function isRecord(maybeRecord: any): maybeRecord is Record.Instance; + + /** + * Records allow passing a second parameter to supply a descriptive name + * that appears when converting a Record to a string or in any error + * messages. A descriptive name for any record can be accessed by using this + * method. If one was not provided, the string "Record" is returned. + * + * ```js + * const { Record } = require('immutable') + * const Person = Record({ + * name: null + * }, 'Person') + * + * var me = Person({ name: 'My Name' }) + * me.toString() // "Person { "name": "My Name" }" + * Record.getDescriptiveName(me) // "Person" + * ``` + */ + export function getDescriptiveName(record: Instance): string; + + export interface Class { + (values?: Partial | Iterable<[string, any]>): Instance & Readonly; + new (values?: Partial | Iterable<[string, any]>): Instance & Readonly; + } + + export interface Instance { + + // Reading values + + has(key: string): key is keyof T; + get(key: K): T[K]; + + // Reading deep values + + hasIn(keyPath: Iterable): boolean; + getIn(keyPath: Iterable): any; + + // Value equality + + equals(other: any): boolean; + hashCode(): number; + + // Persistent changes + + set(key: K, value: T[K]): this; + update(key: K, updater: (value: T[K]) => T[K]): this; + merge(...collections: Array | Iterable<[string, any]>>): this; + mergeDeep(...collections: Array | Iterable<[string, any]>>): this; + + mergeWith( + merger: (oldVal: any, newVal: any, key: keyof T) => any, + ...collections: Array | Iterable<[string, any]>> + ): this; + mergeDeepWith( + merger: (oldVal: any, newVal: any, key: any) => any, + ...collections: Array | Iterable<[string, any]>> + ): this; + + /** + * Returns a new instance of this Record type with the value for the + * specific key set to its default value. + * + * @alias remove + */ + delete(key: K): this; + remove(key: K): this; + + /** + * Returns a new instance of this Record type with all values set + * to their default values. + */ + clear(): this; + + // Deep persistent changes + + setIn(keyPath: Iterable, value: any): this; + updateIn(keyPath: Iterable, updater: (value: any) => any): this; + mergeIn(keyPath: Iterable, ...collections: Array): this; + mergeDeepIn(keyPath: Iterable, ...collections: Array): this; + + /** + * @alias removeIn + */ + deleteIn(keyPath: Iterable): this; + removeIn(keyPath: Iterable): this; + + // Conversion to JavaScript types + + /** + * Deeply converts this Record to equivalent native JavaScript Object. + */ + toJS(): { [K in keyof T]: any }; + + /** + * Shallowly converts this Record to equivalent native JavaScript Object. + */ + toJSON(): T; + + /** + * Shallowly converts this Record to equivalent JavaScript Object. + */ + toObject(): T; + + // Transient changes + + /** + * Note: Not all methods can be used on a mutable collection or within + * `withMutations`! Only `set` may be used mutatively. + * + * @see `Map#withMutations` + */ + withMutations(mutator: (mutable: this) => any): this; + + /** + * @see `Map#asMutable` + */ + asMutable(): this; + + /** + * @see `Map#asImmutable` + */ + asImmutable(): this; + + // Sequence algorithms + + toSeq(): Seq.Keyed; + + [Symbol.iterator](): IterableIterator<[keyof T, T[keyof T]]>; + } + } + + export function Record(defaultValues: T, name?: string): Record.Class; + + + /** + * Represents a sequence of values, but may not be backed by a concrete data + * structure. + * + * **Seq is immutable** — Once a Seq is created, it cannot be + * changed, appended to, rearranged or otherwise modified. Instead, any + * mutative method called on a `Seq` will return a new `Seq`. + * + * **Seq is lazy** — Seq does as little work as necessary to respond to any + * method call. Values are often created during iteration, including implicit + * iteration when reducing or converting to a concrete data structure such as + * a `List` or JavaScript `Array`. + * + * For example, the following performs no work, because the resulting + * Seq's values are never iterated: + * + * ```js + * const { Seq } = require('immutable') + * const oddSquares = Seq([ 1, 2, 3, 4, 5, 6, 7, 8 ]) + * .filter(x => x % 2 !== 0) + * .map(x => x * x) + * ``` + * + * Once the Seq is used, it performs only the work necessary. In this + * example, no intermediate data structures are ever created, filter is only + * called three times, and map is only called once: + * + * ``` + * oddSquares.get(1)); // 9 + * ``` + * + * Seq allows for the efficient chaining of operations, + * allowing for the expression of logic that can otherwise be very tedious: + * + * ``` + * Seq({ a: 1, b: 1, c: 1}) + * .flip() + * .map(key => key.toUpperCase()) + * .flip() + * // Seq { A: 1, B: 1, C: 1 } + * ``` + * + * As well as expressing logic that would otherwise be memory or time limited: + * + * ```js + * const { Range } = require('immutable') + * Range(1, Infinity) + * .skip(1000) + * .map(n => -n) + * .filter(n => n % 2 === 0) + * .take(2) + * .reduce((r, n) => r * n, 1) + * // 1006008 + * ``` + * + * Seq is often used to provide a rich collection API to JavaScript Object. + * + * ```js + * Seq({ x: 0, y: 1, z: 2 }).map(v => v * 2).toObject(); + * // { x: 0, y: 2, z: 4 } + * ``` + */ + + export module Seq { + /** + * True if `maybeSeq` is a Seq, it is not backed by a concrete + * structure such as Map, List, or Set. + */ + function isSeq(maybeSeq: any): maybeSeq is Seq.Indexed | Seq.Keyed; + + + /** + * `Seq` which represents key-value pairs. + */ + export module Keyed {} + + /** + * Always returns a Seq.Keyed, if input is not keyed, expects an + * collection of [K, V] tuples. + */ + export function Keyed(collection: Iterable<[K, V]>): Seq.Keyed; + export function Keyed(obj: {[key: string]: V}): Seq.Keyed; + export function Keyed(): Seq.Keyed; + export function Keyed(): Seq.Keyed; + + export interface Keyed extends Seq, Collection.Keyed { + /** + * Deeply converts this Keyed Seq to equivalent native JavaScript Object. + * + * Converts keys to Strings. + */ + toJS(): Object; + + /** + * Shallowly converts this Keyed Seq to equivalent native JavaScript Object. + * + * Converts keys to Strings. + */ + toJSON(): { [key: string]: V }; + + /** + * Returns itself + */ + toSeq(): this; + + /** + * Returns a new Seq with other collections concatenated to this one. + * + * All entries will be present in the resulting Seq, even if they + * have the same key. + */ + concat(...collections: Array>): Seq.Keyed; + concat(...collections: Array<{[key: string]: C}>): Seq.Keyed; + + /** + * Returns a new Seq.Keyed with values passed through a + * `mapper` function. + * + * ```js + * const { Seq } = require('immutable') + * Seq.Keyed({ a: 1, b: 2 }).map(x => 10 * x) + * // Seq { "a": 10, "b": 20 } + * ``` + * + * Note: `map()` always returns a new instance, even if it produced the + * same value at every step. + */ + map( + mapper: (value: V, key: K, iter: this) => M, + context?: any + ): Seq.Keyed; + + /** + * @see Collection.Keyed.mapKeys + */ + mapKeys( + mapper: (key: K, value: V, iter: this) => M, + context?: any + ): Seq.Keyed; + + /** + * @see Collection.Keyed.mapEntries + */ + mapEntries( + mapper: (entry: [K, V], index: number, iter: this) => [KM, VM], + context?: any + ): Seq.Keyed; + + /** + * Flat-maps the Seq, returning a Seq of the same type. + * + * Similar to `seq.map(...).flatten(true)`. + */ + flatMap( + mapper: (value: V, key: K, iter: this) => Iterable<[KM, VM]>, + context?: any + ): Seq.Keyed; + + /** + * Returns a new Seq with only the entries for which the `predicate` + * function returns true. + * + * Note: `filter()` always returns a new instance, even if it results in + * not filtering out any values. + */ + filter( + predicate: (value: V, key: K, iter: this) => value is F, + context?: any + ): Seq.Keyed; + filter( + predicate: (value: V, key: K, iter: this) => any, + context?: any + ): this; + } + + + /** + * `Seq` which represents an ordered indexed list of values. + */ + module Indexed { + + /** + * Provides an Seq.Indexed of the values provided. + */ + function of(...values: Array): Seq.Indexed; + } + + /** + * Always returns Seq.Indexed, discarding associated keys and + * supplying incrementing indices. + */ + export function Indexed(): Seq.Indexed; + export function Indexed(): Seq.Indexed; + export function Indexed(collection: Iterable): Seq.Indexed; + + export interface Indexed extends Seq, Collection.Indexed { + /** + * Deeply converts this Indexed Seq to equivalent native JavaScript Array. + */ + toJS(): Array; + + /** + * Shallowly converts this Indexed Seq to equivalent native JavaScript Array. + */ + toJSON(): Array; + + /** + * Returns itself + */ + toSeq(): this + + /** + * Returns a new Seq with other collections concatenated to this one. + */ + concat(...valuesOrCollections: Array | C>): Seq.Indexed; + + /** + * Returns a new Seq.Indexed with values passed through a + * `mapper` function. + * + * ```js + * const { Seq } = require('immutable') + * Seq.Indexed([ 1, 2 ]).map(x => 10 * x) + * // Seq [ 10, 20 ] + * ``` + * + * Note: `map()` always returns a new instance, even if it produced the + * same value at every step. + */ + map( + mapper: (value: T, key: number, iter: this) => M, + context?: any + ): Seq.Indexed; + + /** + * Flat-maps the Seq, returning a a Seq of the same type. + * + * Similar to `seq.map(...).flatten(true)`. + */ + flatMap( + mapper: (value: T, key: number, iter: this) => Iterable, + context?: any + ): Seq.Indexed; + + /** + * Returns a new Seq with only the values for which the `predicate` + * function returns true. + * + * Note: `filter()` always returns a new instance, even if it results in + * not filtering out any values. + */ + filter( + predicate: (value: T, index: number, iter: this) => value is F, + context?: any + ): Seq.Indexed; + filter( + predicate: (value: T, index: number, iter: this) => any, + context?: any + ): this; + + /** + * Returns a Seq "zipped" with the provided collections. + * + * Like `zipWith`, but using the default `zipper`: creating an `Array`. + * + * ```js + * const a = Seq([ 1, 2, 3 ]); + * const b = Seq([ 4, 5, 6 ]); + * const c = a.zip(b); // Seq [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] + * ``` + */ + zip(other: Collection): Seq.Indexed<[T,U]>; + + /** + * Returns a Seq "zipped" with the provided collections. + * + * Like `zipWith`, but using the default `zipper`: creating an `Array`. + * + * ```js + * const a = Seq([ 1, 2, 3 ]); + * const b = Seq([ 4, 5, 6 ]); + * const c = a.zip(b); // Seq [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] + * ``` + */ + zip(other: Collection, other2: Collection): Seq.Indexed<[T,U,V]>; + + /** + * Returns a Seq "zipped" with the provided collections. + * + * Like `zipWith`, but using the default `zipper`: creating an `Array`. + * + * ```js + * const a = Seq([ 1, 2, 3 ]); + * const b = Seq([ 4, 5, 6 ]); + * const c = a.zip(b); // Seq [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] + * ``` + */ + zip(...collections: Array>): Seq.Indexed; + + /** + * Returns a Seq "zipped" with the provided collections by using a + * custom `zipper` function. + * + * ```js + * const a = Seq([ 1, 2, 3 ]); + * const b = Seq([ 4, 5, 6 ]); + * const c = a.zipWith((a, b) => a + b, b); + * // Seq [ 5, 7, 9 ] + * ``` + */ + zipWith( + zipper: (value: T, otherValue: U) => Z, + otherCollection: Collection + ): Seq.Indexed; + zipWith( + zipper: (value: T, otherValue: U, thirdValue: V) => Z, + otherCollection: Collection, + thirdCollection: Collection + ): Seq.Indexed; + zipWith( + zipper: (...any: Array) => Z, + ...collections: Array> + ): Seq.Indexed; + } + + + /** + * `Seq` which represents a set of values. + * + * Because `Seq` are often lazy, `Seq.Set` does not provide the same guarantee + * of value uniqueness as the concrete `Set`. + */ + export module Set { + + /** + * Returns a Seq.Set of the provided values + */ + function of(...values: Array): Seq.Set; + } + + /** + * Always returns a Seq.Set, discarding associated indices or keys. + */ + export function Set(): Seq.Set; + export function Set(): Seq.Set; + export function Set(collection: Iterable): Seq.Set; + + export interface Set extends Seq, Collection.Set { + /** + * Deeply converts this Set Seq to equivalent native JavaScript Array. + */ + toJS(): Array; + + /** + * Shallowly converts this Set Seq to equivalent native JavaScript Array. + */ + toJSON(): Array; + + /** + * Returns itself + */ + toSeq(): this + + /** + * Returns a new Seq with other collections concatenated to this one. + * + * All entries will be present in the resulting Seq, even if they + * are duplicates. + */ + concat(...valuesOrCollections: Array | C>): Seq.Set; + + /** + * Returns a new Seq.Set with values passed through a + * `mapper` function. + * + * ```js + * Seq.Set([ 1, 2 ]).map(x => 10 * x) + * // Seq { 10, 20 } + * ``` + * + * Note: `map()` always returns a new instance, even if it produced the + * same value at every step. + */ + map( + mapper: (value: T, key: T, iter: this) => M, + context?: any + ): Seq.Set; + + /** + * Flat-maps the Seq, returning a Seq of the same type. + * + * Similar to `seq.map(...).flatten(true)`. + */ + flatMap( + mapper: (value: T, key: T, iter: this) => Iterable, + context?: any + ): Seq.Set; + + /** + * Returns a new Seq with only the values for which the `predicate` + * function returns true. + * + * Note: `filter()` always returns a new instance, even if it results in + * not filtering out any values. + */ + filter( + predicate: (value: T, key: T, iter: this) => value is F, + context?: any + ): Seq.Set; + filter( + predicate: (value: T, key: T, iter: this) => any, + context?: any + ): this; + } + + } + + /** + * Creates a Seq. + * + * Returns a particular kind of `Seq` based on the input. + * + * * If a `Seq`, that same `Seq`. + * * If an `Collection`, a `Seq` of the same kind (Keyed, Indexed, or Set). + * * If an Array-like, an `Seq.Indexed`. + * * If an Object with an Iterator, an `Seq.Indexed`. + * * If an Iterator, an `Seq.Indexed`. + * * If an Object, a `Seq.Keyed`. + * + */ + export function Seq>(seq: S): S; + export function Seq(collection: Collection.Keyed): Seq.Keyed; + export function Seq(collection: Collection.Indexed): Seq.Indexed; + export function Seq(collection: Collection.Set): Seq.Set; + export function Seq(collection: Iterable): Seq.Indexed; + export function Seq(obj: {[key: string]: V}): Seq.Keyed; + export function Seq(): Seq; + + export interface Seq extends Collection { + + /** + * Some Seqs can describe their size lazily. When this is the case, + * size will be an integer. Otherwise it will be undefined. + * + * For example, Seqs returned from `map()` or `reverse()` + * preserve the size of the original `Seq` while `filter()` does not. + * + * Note: `Range`, `Repeat` and `Seq`s made from `Array`s and `Object`s will + * always have a size. + */ + readonly size: number | undefined; + + + // Force evaluation + + /** + * Because Sequences are lazy and designed to be chained together, they do + * not cache their results. For example, this map function is called a total + * of 6 times, as each `join` iterates the Seq of three values. + * + * var squares = Seq([ 1, 2, 3 ]).map(x => x * x) + * squares.join() + squares.join() + * + * If you know a `Seq` will be used multiple times, it may be more + * efficient to first cache it in memory. Here, the map function is called + * only 3 times. + * + * var squares = Seq([ 1, 2, 3 ]).map(x => x * x).cacheResult() + * squares.join() + squares.join() + * + * Use this method judiciously, as it must fully evaluate a Seq which can be + * a burden on memory and possibly performance. + * + * Note: after calling `cacheResult`, a Seq will always have a `size`. + */ + cacheResult(): this; + + // Sequence algorithms + + /** + * Returns a new Seq with values passed through a + * `mapper` function. + * + * ```js + * const { Seq } = require('immutable') + * Seq([ 1, 2 ]).map(x => 10 * x) + * // Seq [ 10, 20 ] + * ``` + * + * Note: `map()` always returns a new instance, even if it produced the same + * value at every step. + */ + map( + mapper: (value: V, key: K, iter: this) => M, + context?: any + ): Seq; + + /** + * Flat-maps the Seq, returning a Seq of the same type. + * + * Similar to `seq.map(...).flatten(true)`. + */ + flatMap( + mapper: (value: V, key: K, iter: this) => Iterable, + context?: any + ): Seq; + + /** + * Returns a new Seq with only the values for which the `predicate` + * function returns true. + * + * Note: `filter()` always returns a new instance, even if it results in + * not filtering out any values. + */ + filter( + predicate: (value: V, key: K, iter: this) => value is F, + context?: any + ): Seq; + filter( + predicate: (value: V, key: K, iter: this) => any, + context?: any + ): this; + } + + /** + * The `Collection` is a set of (key, value) entries which can be iterated, and + * is the base class for all collections in `immutable`, allowing them to + * make use of all the Collection methods (such as `map` and `filter`). + * + * Note: A collection is always iterated in the same order, however that order + * may not always be well defined, as is the case for the `Map` and `Set`. + * + * Collection is the abstract base class for concrete data structures. It + * cannot be constructed directly. + * + * Implementations should extend one of the subclasses, `Collection.Keyed`, + * `Collection.Indexed`, or `Collection.Set`. + */ + export module Collection { + + /** + * @deprecated use `const { isKeyed } = require('immutable')` + */ + function isKeyed(maybeKeyed: any): maybeKeyed is Collection.Keyed; + + /** + * @deprecated use `const { isIndexed } = require('immutable')` + */ + function isIndexed(maybeIndexed: any): maybeIndexed is Collection.Indexed; + + /** + * @deprecated use `const { isAssociative } = require('immutable')` + */ + function isAssociative(maybeAssociative: any): maybeAssociative is Collection.Keyed | Collection.Indexed; + + /** + * @deprecated use `const { isOrdered } = require('immutable')` + */ + function isOrdered(maybeOrdered: any): boolean; + + + /** + * Keyed Collections have discrete keys tied to each value. + * + * When iterating `Collection.Keyed`, each iteration will yield a `[K, V]` + * tuple, in other words, `Collection#entries` is the default iterator for + * Keyed Collections. + */ + export module Keyed {} + + /** + * Creates a Collection.Keyed + * + * Similar to `Collection()`, however it expects collection-likes of [K, V] + * tuples if not constructed from a Collection.Keyed or JS Object. + */ + export function Keyed(collection: Iterable<[K, V]>): Collection.Keyed; + export function Keyed(obj: {[key: string]: V}): Collection.Keyed; + + export interface Keyed extends Collection { + /** + * Deeply converts this Keyed collection to equivalent native JavaScript Object. + * + * Converts keys to Strings. + */ + toJS(): Object; + + /** + * Shallowly converts this Keyed collection to equivalent native JavaScript Object. + * + * Converts keys to Strings. + */ + toJSON(): { [key: string]: V }; + + /** + * Returns Seq.Keyed. + * @override + */ + toSeq(): Seq.Keyed; + + + // Sequence functions + + /** + * Returns a new Collection.Keyed of the same type where the keys and values + * have been flipped. + * + * + * ```js + * const { Map } = require('immutable') + * Map({ a: 'z', b: 'y' }).flip() + * // Map { "z": "a", "y": "b" } + * ``` + */ + flip(): this; + + /** + * Returns a new Collection with other collections concatenated to this one. + */ + concat(...collections: Array>): Collection.Keyed; + concat(...collections: Array<{[key: string]: C}>): Collection.Keyed; + + /** + * Returns a new Collection.Keyed with values passed through a + * `mapper` function. + * + * ```js + * const { Collection } = require('immutable') + * Collection.Keyed({ a: 1, b: 2 }).map(x => 10 * x) + * // Seq { "a": 10, "b": 20 } + * ``` + * + * Note: `map()` always returns a new instance, even if it produced the + * same value at every step. + */ + map( + mapper: (value: V, key: K, iter: this) => M, + context?: any + ): Collection.Keyed; + + /** + * Returns a new Collection.Keyed of the same type with keys passed through + * a `mapper` function. + * + * + * ```js + * const { Map } = require('immutable') + * Map({ a: 1, b: 2 }).mapKeys(x => x.toUpperCase()) + * // Map { "A": 1, "B": 2 } + * ``` + * + * Note: `mapKeys()` always returns a new instance, even if it produced + * the same key at every step. + */ + mapKeys( + mapper: (key: K, value: V, iter: this) => M, + context?: any + ): Collection.Keyed; + + /** + * Returns a new Collection.Keyed of the same type with entries + * ([key, value] tuples) passed through a `mapper` function. + * + * + * ```js + * const { Map } = require('immutable') + * Map({ a: 1, b: 2 }) + * .mapEntries(([ k, v ]) => [ k.toUpperCase(), v * 2 ]) + * // Map { "A": 2, "B": 4 } + * ``` + * + * Note: `mapEntries()` always returns a new instance, even if it produced + * the same entry at every step. + */ + mapEntries( + mapper: (entry: [K, V], index: number, iter: this) => [KM, VM], + context?: any + ): Collection.Keyed; + + /** + * Flat-maps the Collection, returning a Collection of the same type. + * + * Similar to `collection.map(...).flatten(true)`. + */ + flatMap( + mapper: (value: V, key: K, iter: this) => Iterable<[KM, VM]>, + context?: any + ): Collection.Keyed; + + /** + * Returns a new Collection with only the values for which the `predicate` + * function returns true. + * + * Note: `filter()` always returns a new instance, even if it results in + * not filtering out any values. + */ + filter( + predicate: (value: V, key: K, iter: this) => value is F, + context?: any + ): Collection.Keyed; + filter( + predicate: (value: V, key: K, iter: this) => any, + context?: any + ): this; + + [Symbol.iterator](): IterableIterator<[K, V]>; + } + + + /** + * Indexed Collections have incrementing numeric keys. They exhibit + * slightly different behavior than `Collection.Keyed` for some methods in order + * to better mirror the behavior of JavaScript's `Array`, and add methods + * which do not make sense on non-indexed Collections such as `indexOf`. + * + * Unlike JavaScript arrays, `Collection.Indexed`s are always dense. "Unset" + * indices and `undefined` indices are indistinguishable, and all indices from + * 0 to `size` are visited when iterated. + * + * All Collection.Indexed methods return re-indexed Collections. In other words, + * indices always start at 0 and increment until size. If you wish to + * preserve indices, using them as keys, convert to a Collection.Keyed by + * calling `toKeyedSeq`. + */ + export module Indexed {} + + /** + * Creates a new Collection.Indexed. + */ + export function Indexed(collection: Iterable): Collection.Indexed; + + export interface Indexed extends Collection { + /** + * Deeply converts this Indexed collection to equivalent native JavaScript Array. + */ + toJS(): Array; + + /** + * Shallowly converts this Indexed collection to equivalent native JavaScript Array. + */ + toJSON(): Array; + + // Reading values + + /** + * Returns the value associated with the provided index, or notSetValue if + * the index is beyond the bounds of the Collection. + * + * `index` may be a negative number, which indexes back from the end of the + * Collection. `s.get(-1)` gets the last item in the Collection. + */ + get(index: number, notSetValue: NSV): T | NSV; + get(index: number): T | undefined; + + + // Conversion to Seq + + /** + * Returns Seq.Indexed. + * @override + */ + toSeq(): Seq.Indexed; + + /** + * If this is a collection of [key, value] entry tuples, it will return a + * Seq.Keyed of those entries. + */ + fromEntrySeq(): Seq.Keyed; + + + // Combination + + /** + * Returns a Collection of the same type with `separator` between each item + * in this Collection. + */ + interpose(separator: T): this; + + /** + * Returns a Collection of the same type with the provided `collections` + * interleaved into this collection. + * + * The resulting Collection includes the first item from each, then the + * second from each, etc. + * + * + * ```js + * const { List } = require('immutable') + * List([ 1, 2, 3 ]).interleave(List([ 'A', 'B', 'C' ])) + * // List [ 1, "A", 2, "B", 3, "C"" ] + * ``` + * + * The shortest Collection stops interleave. + * + * + * ```js + * List([ 1, 2, 3 ]).interleave( + * List([ 'A', 'B' ]), + * List([ 'X', 'Y', 'Z' ]) + * ) + * // List [ 1, "A", "X", 2, "B", "Y"" ] + * ``` + */ + interleave(...collections: Array>): this; + + /** + * Splice returns a new indexed Collection by replacing a region of this + * Collection with new values. If values are not provided, it only skips the + * region to be removed. + * + * `index` may be a negative number, which indexes back from the end of the + * Collection. `s.splice(-2)` splices after the second to last item. + * + * + * ```js + * const { List } = require('immutable') + * List([ 'a', 'b', 'c', 'd' ]).splice(1, 2, 'q', 'r', 's') + * // List [ "a", "q", "r", "s", "d" ] + * ``` + */ + splice( + index: number, + removeNum: number, + ...values: Array + ): this; + + /** + * Returns a Collection of the same type "zipped" with the provided + * collections. + * + * Like `zipWith`, but using the default `zipper`: creating an `Array`. + * + * + * + * ```js + * const a = List([ 1, 2, 3 ]); + * const b = List([ 4, 5, 6 ]); + * const c = a.zip(b); // List [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] + * ``` + */ + zip(other: Collection): Collection.Indexed<[T,U]>; + + /** + * Returns a Collection of the same type "zipped" with the provided + * collections. + * + * Like `zipWith`, but using the default `zipper`: creating an `Array`. + * + * ```js + * const a = List([ 1, 2, 3 ]); + * const b = List([ 4, 5, 6 ]); + * const c = a.zip(b); // List [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] + * ``` + */ + zip(other: Collection, other2: Collection): Collection.Indexed<[T,U,V]>; + + /** + * Returns a Collection of the same type "zipped" with the provided + * collections. + * + * Like `zipWith`, but using the default `zipper`: creating an `Array`. + * + * ```js + * const a = List([ 1, 2, 3 ]); + * const b = List([ 4, 5, 6 ]); + * const c = a.zip(b); // List [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] + * ``` + */ + zip(...collections: Array>): Collection.Indexed; + + /** + * Returns a Collection of the same type "zipped" with the provided + * collections by using a custom `zipper` function. + * + * + * ```js + * const a = List([ 1, 2, 3 ]); + * const b = List([ 4, 5, 6 ]); + * const c = a.zipWith((a, b) => a + b, b); + * // List [ 5, 7, 9 ] + * ``` + */ + zipWith( + zipper: (value: T, otherValue: U) => Z, + otherCollection: Collection + ): Collection.Indexed; + zipWith( + zipper: (value: T, otherValue: U, thirdValue: V) => Z, + otherCollection: Collection, + thirdCollection: Collection + ): Collection.Indexed; + zipWith( + zipper: (...any: Array) => Z, + ...collections: Array> + ): Collection.Indexed; + + + // Search for value + + /** + * Returns the first index at which a given value can be found in the + * Collection, or -1 if it is not present. + */ + indexOf(searchValue: T): number; + + /** + * Returns the last index at which a given value can be found in the + * Collection, or -1 if it is not present. + */ + lastIndexOf(searchValue: T): number; + + /** + * Returns the first index in the Collection where a value satisfies the + * provided predicate function. Otherwise -1 is returned. + */ + findIndex( + predicate: (value: T, index: number, iter: this) => boolean, + context?: any + ): number; + + /** + * Returns the last index in the Collection where a value satisfies the + * provided predicate function. Otherwise -1 is returned. + */ + findLastIndex( + predicate: (value: T, index: number, iter: this) => boolean, + context?: any + ): number; + + // Sequence algorithms + + /** + * Returns a new Collection with other collections concatenated to this one. + */ + concat(...valuesOrCollections: Array | C>): Collection.Indexed; + + /** + * Returns a new Collection.Indexed with values passed through a + * `mapper` function. + * + * ```js + * const { Collection } = require('immutable') + * Collection.Indexed([1,2]).map(x => 10 * x) + * // Seq [ 1, 2 ] + * ``` + * + * Note: `map()` always returns a new instance, even if it produced the + * same value at every step. + */ + map( + mapper: (value: T, key: number, iter: this) => M, + context?: any + ): Collection.Indexed; + + /** + * Flat-maps the Collection, returning a Collection of the same type. + * + * Similar to `collection.map(...).flatten(true)`. + */ + flatMap( + mapper: (value: T, key: number, iter: this) => Iterable, + context?: any + ): Collection.Indexed; + + /** + * Returns a new Collection with only the values for which the `predicate` + * function returns true. + * + * Note: `filter()` always returns a new instance, even if it results in + * not filtering out any values. + */ + filter( + predicate: (value: T, index: number, iter: this) => value is F, + context?: any + ): Collection.Indexed; + filter( + predicate: (value: T, index: number, iter: this) => any, + context?: any + ): this; + + [Symbol.iterator](): IterableIterator; + } + + + /** + * Set Collections only represent values. They have no associated keys or + * indices. Duplicate values are possible in the lazy `Seq.Set`s, however + * the concrete `Set` Collection does not allow duplicate values. + * + * Collection methods on Collection.Set such as `map` and `forEach` will provide + * the value as both the first and second arguments to the provided function. + * + * ```js + * const { Collection } = require('immutable') + * const seq = Collection.Set([ 'A', 'B', 'C' ]) + * // Seq { "A", "B", "C" } + * seq.forEach((v, k) => + * assert.equal(v, k) + * ) + * ``` + */ + export module Set {} + + /** + * Similar to `Collection()`, but always returns a Collection.Set. + */ + export function Set(collection: Iterable): Collection.Set; + + export interface Set extends Collection { + /** + * Deeply converts this Set collection to equivalent native JavaScript Array. + */ + toJS(): Array; + + /** + * Shallowly converts this Set collection to equivalent native JavaScript Array. + */ + toJSON(): Array; + + /** + * Returns Seq.Set. + * @override + */ + toSeq(): Seq.Set; + + // Sequence algorithms + + /** + * Returns a new Collection with other collections concatenated to this one. + */ + concat(...valuesOrCollections: Array | C>): Collection.Set; + + /** + * Returns a new Collection.Set with values passed through a + * `mapper` function. + * + * ``` + * Collection.Set([ 1, 2 ]).map(x => 10 * x) + * // Seq { 1, 2 } + * ``` + * + * Note: `map()` always returns a new instance, even if it produced the + * same value at every step. + */ + map( + mapper: (value: T, key: T, iter: this) => M, + context?: any + ): Collection.Set; + + /** + * Flat-maps the Collection, returning a Collection of the same type. + * + * Similar to `collection.map(...).flatten(true)`. + */ + flatMap( + mapper: (value: T, key: T, iter: this) => Iterable, + context?: any + ): Collection.Set; + + /** + * Returns a new Collection with only the values for which the `predicate` + * function returns true. + * + * Note: `filter()` always returns a new instance, even if it results in + * not filtering out any values. + */ + filter( + predicate: (value: T, key: T, iter: this) => value is F, + context?: any + ): Collection.Set; + filter( + predicate: (value: T, key: T, iter: this) => any, + context?: any + ): this; + + [Symbol.iterator](): IterableIterator; + } + + } + + /** + * Creates a Collection. + * + * The type of Collection created is based on the input. + * + * * If an `Collection`, that same `Collection`. + * * If an Array-like, an `Collection.Indexed`. + * * If an Object with an Iterator, an `Collection.Indexed`. + * * If an Iterator, an `Collection.Indexed`. + * * If an Object, an `Collection.Keyed`. + * + * This methods forces the conversion of Objects and Strings to Collections. + * If you want to ensure that a Collection of one item is returned, use + * `Seq.of`. + */ + export function Collection>(collection: I): I; + export function Collection(collection: Iterable): Collection.Indexed; + export function Collection(obj: {[key: string]: V}): Collection.Keyed; + + export interface Collection extends ValueObject { + + // Value equality + + /** + * True if this and the other Collection have value equality, as defined + * by `Immutable.is()`. + * + * Note: This is equivalent to `Immutable.is(this, other)`, but provided to + * allow for chained expressions. + */ + equals(other: any): boolean; + + /** + * Computes and returns the hashed identity for this Collection. + * + * The `hashCode` of a Collection is used to determine potential equality, + * and is used when adding this to a `Set` or as a key in a `Map`, enabling + * lookup via a different instance. + * + * + * ```js + * const a = List([ 1, 2, 3 ]); + * const b = List([ 1, 2, 3 ]); + * assert.notStrictEqual(a, b); // different instances + * const set = Set([ a ]); + * assert.equal(set.has(b), true); + * ``` + * + * If two values have the same `hashCode`, they are [not guaranteed + * to be equal][Hash Collision]. If two values have different `hashCode`s, + * they must not be equal. + * + * [Hash Collision]: http://en.wikipedia.org/wiki/Collision_(computer_science) + */ + hashCode(): number; + + + // Reading values + + /** + * Returns the value associated with the provided key, or notSetValue if + * the Collection does not contain this key. + * + * Note: it is possible a key may be associated with an `undefined` value, + * so if `notSetValue` is not provided and this method returns `undefined`, + * that does not guarantee the key was not found. + */ + get(key: K, notSetValue: NSV): V | NSV; + get(key: K): V | undefined; + + /** + * True if a key exists within this `Collection`, using `Immutable.is` + * to determine equality + */ + has(key: K): boolean; + + /** + * True if a value exists within this `Collection`, using `Immutable.is` + * to determine equality + * @alias contains + */ + includes(value: V): boolean; + contains(value: V): boolean; + + /** + * The first value in the Collection. + */ + first(): V | undefined; + + /** + * The last value in the Collection. + */ + last(): V | undefined; + + + // Reading deep values + + /** + * Returns the value found by following a path of keys or indices through + * nested Collections. + */ + getIn(searchKeyPath: Iterable, notSetValue?: any): any; + + /** + * True if the result of following a path of keys or indices through nested + * Collections results in a set value. + */ + hasIn(searchKeyPath: Iterable): boolean; + + // Persistent changes + + /** + * This can be very useful as a way to "chain" a normal function into a + * sequence of methods. RxJS calls this "let" and lodash calls it "thru". + * + * For example, to sum a Seq after mapping and filtering: + * + * ```js + * const { Seq } = require('immutable') + * + * function sum(collection) { + * return collection.reduce((sum, x) => sum + x, 0) + * } + * + * Seq([ 1, 2, 3 ]) + * .map(x => x + 1) + * .filter(x => x % 2 === 0) + * .update(sum) + * // 6 + * ``` + */ + update(updater: (value: this) => R): R; + + + // Conversion to JavaScript types + + /** + * Deeply converts this Collection to equivalent native JavaScript Array or Object. + * + * `Collection.Indexed`, and `Collection.Set` become `Array`, while + * `Collection.Keyed` become `Object`, converting keys to Strings. + */ + toJS(): Array | { [key: string]: any }; + + /** + * Shallowly converts this Collection to equivalent native JavaScript Array or Object. + * + * `Collection.Indexed`, and `Collection.Set` become `Array`, while + * `Collection.Keyed` become `Object`, converting keys to Strings. + */ + toJSON(): Array | { [key: string]: V }; + + /** + * Shallowly converts this collection to an Array, discarding keys. + */ + toArray(): Array; + + /** + * Shallowly converts this Collection to an Object. + * + * Converts keys to Strings. + */ + toObject(): { [key: string]: V }; + + + // Conversion to Collections + + /** + * Converts this Collection to a Map, Throws if keys are not hashable. + * + * Note: This is equivalent to `Map(this.toKeyedSeq())`, but provided + * for convenience and to allow for chained expressions. + */ + toMap(): Map; + + /** + * Converts this Collection to a Map, maintaining the order of iteration. + * + * Note: This is equivalent to `OrderedMap(this.toKeyedSeq())`, but + * provided for convenience and to allow for chained expressions. + */ + toOrderedMap(): OrderedMap; + + /** + * Converts this Collection to a Set, discarding keys. Throws if values + * are not hashable. + * + * Note: This is equivalent to `Set(this)`, but provided to allow for + * chained expressions. + */ + toSet(): Set; + + /** + * Converts this Collection to a Set, maintaining the order of iteration and + * discarding keys. + * + * Note: This is equivalent to `OrderedSet(this.valueSeq())`, but provided + * for convenience and to allow for chained expressions. + */ + toOrderedSet(): OrderedSet; + + /** + * Converts this Collection to a List, discarding keys. + * + * This is similar to `List(collection)`, but provided to allow for chained + * expressions. However, when called on `Map` or other keyed collections, + * `collection.toList()` discards the keys and creates a list of only the + * values, whereas `List(collection)` creates a list of entry tuples. + * + * + * ```js + * const { Map, List } = require('immutable') + * var myMap = Map({ a: 'Apple', b: 'Banana' }) + * List(myMap) // List [ [ "a", "Apple" ], [ "b", "Banana" ] ] + * myMap.toList() // List [ "Apple", "Banana" ] + * ``` + */ + toList(): List; + + /** + * Converts this Collection to a Stack, discarding keys. Throws if values + * are not hashable. + * + * Note: This is equivalent to `Stack(this)`, but provided to allow for + * chained expressions. + */ + toStack(): Stack; + + + // Conversion to Seq + + /** + * Converts this Collection to a Seq of the same kind (indexed, + * keyed, or set). + */ + toSeq(): Seq; + + /** + * Returns a Seq.Keyed from this Collection where indices are treated as keys. + * + * This is useful if you want to operate on an + * Collection.Indexed and preserve the [index, value] pairs. + * + * The returned Seq will have identical iteration order as + * this Collection. + * + * ```js + * const { Seq } = require('immutable') + * const indexedSeq = Seq([ 'A', 'B', 'C' ]) + * // Seq [ "A", "B", "C" ] + * indexedSeq.filter(v => v === 'B') + * // Seq [ "B" ] + * const keyedSeq = indexedSeq.toKeyedSeq() + * // Seq { 0: "A", 1: "B", 2: "C" } + * keyedSeq.filter(v => v === 'B') + * // Seq { 1: "B" } + * ``` + */ + toKeyedSeq(): Seq.Keyed; + + /** + * Returns an Seq.Indexed of the values of this Collection, discarding keys. + */ + toIndexedSeq(): Seq.Indexed; + + /** + * Returns a Seq.Set of the values of this Collection, discarding keys. + */ + toSetSeq(): Seq.Set; + + + // Iterators + + /** + * An iterator of this `Collection`'s keys. + * + * Note: this will return an ES6 iterator which does not support + * Immutable.js sequence algorithms. Use `keySeq` instead, if this is + * what you want. + */ + keys(): IterableIterator; + + /** + * An iterator of this `Collection`'s values. + * + * Note: this will return an ES6 iterator which does not support + * Immutable.js sequence algorithms. Use `valueSeq` instead, if this is + * what you want. + */ + values(): IterableIterator; + + /** + * An iterator of this `Collection`'s entries as `[ key, value ]` tuples. + * + * Note: this will return an ES6 iterator which does not support + * Immutable.js sequence algorithms. Use `entrySeq` instead, if this is + * what you want. + */ + entries(): IterableIterator<[K, V]>; + + + // Collections (Seq) + + /** + * Returns a new Seq.Indexed of the keys of this Collection, + * discarding values. + */ + keySeq(): Seq.Indexed; + + /** + * Returns an Seq.Indexed of the values of this Collection, discarding keys. + */ + valueSeq(): Seq.Indexed; + + /** + * Returns a new Seq.Indexed of [key, value] tuples. + */ + entrySeq(): Seq.Indexed<[K, V]>; + + + // Sequence algorithms + + /** + * Returns a new Collection of the same type with values passed through a + * `mapper` function. + * + * ```js + * const { Collection } = require('immutable') + * Collection({ a: 1, b: 2 }).map(x => 10 * x) + * // Seq { "a": 10, "b": 20 } + * ``` + * + * Note: `map()` always returns a new instance, even if it produced the same + * value at every step. + */ + map( + mapper: (value: V, key: K, iter: this) => M, + context?: any + ): Collection; + + /** + * Returns a new Collection of the same type with only the entries for which + * the `predicate` function returns true. + * + * + * ```js + * const { Map } = require('immutable') + * Map({ a: 1, b: 2, c: 3, d: 4}).filter(x => x % 2 === 0) + * // Map { "b": 2, "d": 4 } + * ``` + * + * Note: `filter()` always returns a new instance, even if it results in + * not filtering out any values. + */ + filter( + predicate: (value: V, key: K, iter: this) => value is F, + context?: any + ): Collection; + filter( + predicate: (value: V, key: K, iter: this) => any, + context?: any + ): this; + + /** + * Returns a new Collection of the same type with only the entries for which + * the `predicate` function returns false. + * + * + * ```js + * const { Map } = require('immutable') + * Map({ a: 1, b: 2, c: 3, d: 4}).filterNot(x => x % 2 === 0) + * // Map { "a": 1, "c": 3 } + * ``` + * + * Note: `filterNot()` always returns a new instance, even if it results in + * not filtering out any values. + */ + filterNot( + predicate: (value: V, key: K, iter: this) => boolean, + context?: any + ): this; + + /** + * Returns a new Collection of the same type in reverse order. + */ + reverse(): this; + + /** + * Returns a new Collection of the same type which includes the same entries, + * stably sorted by using a `comparator`. + * + * If a `comparator` is not provided, a default comparator uses `<` and `>`. + * + * `comparator(valueA, valueB)`: + * + * * Returns `0` if the elements should not be swapped. + * * Returns `-1` (or any negative number) if `valueA` comes before `valueB` + * * Returns `1` (or any positive number) if `valueA` comes after `valueB` + * * Is pure, i.e. it must always return the same value for the same pair + * of values. + * + * When sorting collections which have no defined order, their ordered + * equivalents will be returned. e.g. `map.sort()` returns OrderedMap. + * + * ```js + * const { Map } = require('immutable') + * Map({ "c": 3, "a": 1, "b": 2 }).sort((a, b) => { + * if (a < b) { return -1; } + * if (a > b) { return 1; } + * if (a === b) { return 0; } + * }); + * // OrderedMap { "a": 1, "b": 2, "c": 3 } + * ``` + * + * Note: `sort()` Always returns a new instance, even if the original was + * already sorted. + */ + sort(comparator?: (valueA: V, valueB: V) => number): this; + + /** + * Like `sort`, but also accepts a `comparatorValueMapper` which allows for + * sorting by more sophisticated means: + * + * hitters.sortBy(hitter => hitter.avgHits) + * + * Note: `sortBy()` Always returns a new instance, even if the original was + * already sorted. + */ + sortBy( + comparatorValueMapper: (value: V, key: K, iter: this) => C, + comparator?: (valueA: C, valueB: C) => number + ): this; + + /** + * Returns a `Collection.Keyed` of `Collection.Keyeds`, grouped by the return + * value of the `grouper` function. + * + * Note: This is always an eager operation. + * + * ```js + * const { List, Map } = require('immutable') + * const listOfMaps = List([ + * Map({ v: 0 }), + * Map({ v: 1 }), + * Map({ v: 1 }), + * Map({ v: 0 }), + * Map({ v: 2 }) + * ]) + * const groupsOfMaps = listOfMaps.groupBy(x => x.get('v')) + * // Map { + * // 0: List [ Map{ "v": 0 }, Map { "v": 0 } ], + * // 1: List [ Map{ "v": 1 }, Map { "v": 1 } ], + * // 2: List [ Map{ "v": 2 } ], + * // } + * ``` + */ + groupBy( + grouper: (value: V, key: K, iter: this) => G, + context?: any + ): /*Map*/Seq.Keyed>; + + + // Side effects + + /** + * The `sideEffect` is executed for every entry in the Collection. + * + * Unlike `Array#forEach`, if any call of `sideEffect` returns + * `false`, the iteration will stop. Returns the number of entries iterated + * (including the last iteration which returned false). + */ + forEach( + sideEffect: (value: V, key: K, iter: this) => any, + context?: any + ): number; + + + // Creating subsets + + /** + * Returns a new Collection of the same type representing a portion of this + * Collection from start up to but not including end. + * + * If begin is negative, it is offset from the end of the Collection. e.g. + * `slice(-2)` returns a Collection of the last two entries. If it is not + * provided the new Collection will begin at the beginning of this Collection. + * + * If end is negative, it is offset from the end of the Collection. e.g. + * `slice(0, -1)` returns a Collection of everything but the last entry. If + * it is not provided, the new Collection will continue through the end of + * this Collection. + * + * If the requested slice is equivalent to the current Collection, then it + * will return itself. + */ + slice(begin?: number, end?: number): this; + + /** + * Returns a new Collection of the same type containing all entries except + * the first. + */ + rest(): this; + + /** + * Returns a new Collection of the same type containing all entries except + * the last. + */ + butLast(): this; + + /** + * Returns a new Collection of the same type which excludes the first `amount` + * entries from this Collection. + */ + skip(amount: number): this; + + /** + * Returns a new Collection of the same type which excludes the last `amount` + * entries from this Collection. + */ + skipLast(amount: number): this; + + /** + * Returns a new Collection of the same type which includes entries starting + * from when `predicate` first returns false. + * + * + * ```js + * const { List } = require('immutable') + * List([ 'dog', 'frog', 'cat', 'hat', 'god' ]) + * .skipWhile(x => x.match(/g/)) + * // List [ "cat", "hat", "god"" ] + * ``` + */ + skipWhile( + predicate: (value: V, key: K, iter: this) => boolean, + context?: any + ): this; + + /** + * Returns a new Collection of the same type which includes entries starting + * from when `predicate` first returns true. + * + * + * ```js + * const { List } = require('immutable') + * List([ 'dog', 'frog', 'cat', 'hat', 'god' ]) + * .skipUntil(x => x.match(/hat/)) + * // List [ "hat", "god"" ] + * ``` + */ + skipUntil( + predicate: (value: V, key: K, iter: this) => boolean, + context?: any + ): this; + + /** + * Returns a new Collection of the same type which includes the first `amount` + * entries from this Collection. + */ + take(amount: number): this; + + /** + * Returns a new Collection of the same type which includes the last `amount` + * entries from this Collection. + */ + takeLast(amount: number): this; + + /** + * Returns a new Collection of the same type which includes entries from this + * Collection as long as the `predicate` returns true. + * + * + * ```js + * const { List } = require('immutable') + * List([ 'dog', 'frog', 'cat', 'hat', 'god' ]) + * .takeWhile(x => x.match(/o/)) + * // List [ "dog", "frog" ] + * ``` + */ + takeWhile( + predicate: (value: V, key: K, iter: this) => boolean, + context?: any + ): this; + + /** + * Returns a new Collection of the same type which includes entries from this + * Collection as long as the `predicate` returns false. + * + * + * ```js + * const { List } = require('immutable') + * List([ 'dog', 'frog', 'cat', 'hat', 'god' ]) + * .takeUntil(x => x.match(/at/)) + * // List [ "dog", "frog" ] + * ``` + */ + takeUntil( + predicate: (value: V, key: K, iter: this) => boolean, + context?: any + ): this; + + + // Combination + + /** + * Returns a new Collection of the same type with other values and + * collection-like concatenated to this one. + * + * For Seqs, all entries will be present in the resulting Seq, even if they + * have the same key. + */ + concat(...valuesOrCollections: Array): Collection; + + /** + * Flattens nested Collections. + * + * Will deeply flatten the Collection by default, returning a Collection of the + * same type, but a `depth` can be provided in the form of a number or + * boolean (where true means to shallowly flatten one level). A depth of 0 + * (or shallow: false) will deeply flatten. + * + * Flattens only others Collection, not Arrays or Objects. + * + * Note: `flatten(true)` operates on Collection> and + * returns Collection + */ + flatten(depth?: number): Collection; + flatten(shallow?: boolean): Collection; + + /** + * Flat-maps the Collection, returning a Collection of the same type. + * + * Similar to `collection.map(...).flatten(true)`. + */ + flatMap( + mapper: (value: V, key: K, iter: this) => Iterable, + context?: any + ): Collection; + + // Reducing a value + + /** + * Reduces the Collection to a value by calling the `reducer` for every entry + * in the Collection and passing along the reduced value. + * + * If `initialReduction` is not provided, the first item in the + * Collection will be used. + * + * @see `Array#reduce`. + */ + reduce( + reducer: (reduction: R, value: V, key: K, iter: this) => R, + initialReduction: R, + context?: any + ): R; + reduce( + reducer: (reduction: V | R, value: V, key: K, iter: this) => R + ): R; + + /** + * Reduces the Collection in reverse (from the right side). + * + * Note: Similar to this.reverse().reduce(), and provided for parity + * with `Array#reduceRight`. + */ + reduceRight( + reducer: (reduction: R, value: V, key: K, iter: this) => R, + initialReduction: R, + context?: any + ): R; + reduceRight( + reducer: (reduction: V | R, value: V, key: K, iter: this) => R + ): R; + + /** + * True if `predicate` returns true for all entries in the Collection. + */ + every( + predicate: (value: V, key: K, iter: this) => boolean, + context?: any + ): boolean; + + /** + * True if `predicate` returns true for any entry in the Collection. + */ + some( + predicate: (value: V, key: K, iter: this) => boolean, + context?: any + ): boolean; + + /** + * Joins values together as a string, inserting a separator between each. + * The default separator is `","`. + */ + join(separator?: string): string; + + /** + * Returns true if this Collection includes no values. + * + * For some lazy `Seq`, `isEmpty` might need to iterate to determine + * emptiness. At most one iteration will occur. + */ + isEmpty(): boolean; + + /** + * Returns the size of this Collection. + * + * Regardless of if this Collection can describe its size lazily (some Seqs + * cannot), this method will always return the correct size. E.g. it + * evaluates a lazy `Seq` if necessary. + * + * If `predicate` is provided, then this returns the count of entries in the + * Collection for which the `predicate` returns true. + */ + count(): number; + count( + predicate: (value: V, key: K, iter: this) => boolean, + context?: any + ): number; + + /** + * Returns a `Seq.Keyed` of counts, grouped by the return value of + * the `grouper` function. + * + * Note: This is not a lazy operation. + */ + countBy( + grouper: (value: V, key: K, iter: this) => G, + context?: any + ): Map; + + + // Search for value + + /** + * Returns the first value for which the `predicate` returns true. + */ + find( + predicate: (value: V, key: K, iter: this) => boolean, + context?: any, + notSetValue?: V + ): V | undefined; + + /** + * Returns the last value for which the `predicate` returns true. + * + * Note: `predicate` will be called for each entry in reverse. + */ + findLast( + predicate: (value: V, key: K, iter: this) => boolean, + context?: any, + notSetValue?: V + ): V | undefined; + + /** + * Returns the first [key, value] entry for which the `predicate` returns true. + */ + findEntry( + predicate: (value: V, key: K, iter: this) => boolean, + context?: any, + notSetValue?: V + ): [K, V] | undefined; + + /** + * Returns the last [key, value] entry for which the `predicate` + * returns true. + * + * Note: `predicate` will be called for each entry in reverse. + */ + findLastEntry( + predicate: (value: V, key: K, iter: this) => boolean, + context?: any, + notSetValue?: V + ): [K, V] | undefined; + + /** + * Returns the key for which the `predicate` returns true. + */ + findKey( + predicate: (value: V, key: K, iter: this) => boolean, + context?: any + ): K | undefined; + + /** + * Returns the last key for which the `predicate` returns true. + * + * Note: `predicate` will be called for each entry in reverse. + */ + findLastKey( + predicate: (value: V, key: K, iter: this) => boolean, + context?: any + ): K | undefined; + + /** + * Returns the key associated with the search value, or undefined. + */ + keyOf(searchValue: V): K | undefined; + + /** + * Returns the last key associated with the search value, or undefined. + */ + lastKeyOf(searchValue: V): K | undefined; + + /** + * Returns the maximum value in this collection. If any values are + * comparatively equivalent, the first one found will be returned. + * + * The `comparator` is used in the same way as `Collection#sort`. If it is not + * provided, the default comparator is `>`. + * + * When two values are considered equivalent, the first encountered will be + * returned. Otherwise, `max` will operate independent of the order of input + * as long as the comparator is commutative. The default comparator `>` is + * commutative *only* when types do not differ. + * + * If `comparator` returns 0 and either value is NaN, undefined, or null, + * that value will be returned. + */ + max(comparator?: (valueA: V, valueB: V) => number): V | undefined; + + /** + * Like `max`, but also accepts a `comparatorValueMapper` which allows for + * comparing by more sophisticated means: + * + * hitters.maxBy(hitter => hitter.avgHits); + * + */ + maxBy( + comparatorValueMapper: (value: V, key: K, iter: this) => C, + comparator?: (valueA: C, valueB: C) => number + ): V | undefined; + + /** + * Returns the minimum value in this collection. If any values are + * comparatively equivalent, the first one found will be returned. + * + * The `comparator` is used in the same way as `Collection#sort`. If it is not + * provided, the default comparator is `<`. + * + * When two values are considered equivalent, the first encountered will be + * returned. Otherwise, `min` will operate independent of the order of input + * as long as the comparator is commutative. The default comparator `<` is + * commutative *only* when types do not differ. + * + * If `comparator` returns 0 and either value is NaN, undefined, or null, + * that value will be returned. + */ + min(comparator?: (valueA: V, valueB: V) => number): V | undefined; + + /** + * Like `min`, but also accepts a `comparatorValueMapper` which allows for + * comparing by more sophisticated means: + * + * hitters.minBy(hitter => hitter.avgHits); + * + */ + minBy( + comparatorValueMapper: (value: V, key: K, iter: this) => C, + comparator?: (valueA: C, valueB: C) => number + ): V | undefined; + + + // Comparison + + /** + * True if `iter` includes every value in this Collection. + */ + isSubset(iter: Iterable): boolean; + + /** + * True if this Collection includes every value in `iter`. + */ + isSuperset(iter: Iterable): boolean; + } +} + +declare module "immutable" { + export = Immutable +} diff --git a/dist/immutable.es.js b/dist/immutable.es.js new file mode 100644 index 0000000000..1a40d2a78e --- /dev/null +++ b/dist/immutable.es.js @@ -0,0 +1,5535 @@ +/** + * Copyright (c) 2014-2015, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + +// Used for setting prototype methods that IE8 chokes on. +var DELETE = 'delete'; + +// Constants describing the size of trie nodes. +var SHIFT = 5; // Resulted in best performance after ______? +var SIZE = 1 << SHIFT; +var MASK = SIZE - 1; + +// A consistent shared value representing "not set" which equals nothing other +// than itself, and nothing that could be provided externally. +var NOT_SET = {}; + +// Boolean references, Rough equivalent of `bool &`. +var CHANGE_LENGTH = { value: false }; +var DID_ALTER = { value: false }; + +function MakeRef(ref) { + ref.value = false; + return ref; +} + +function SetRef(ref) { + ref && (ref.value = true); +} + +// A function which returns a value representing an "owner" for transient writes +// to tries. The return value will only ever equal itself, and will not equal +// the return of any subsequent call of this function. +function OwnerID() {} + +// http://jsperf.com/copy-array-inline +function arrCopy(arr, offset) { + offset = offset || 0; + var len = Math.max(0, arr.length - offset); + var newArr = new Array(len); + for (var ii = 0; ii < len; ii++) { + newArr[ii] = arr[ii + offset]; + } + return newArr; +} + +function ensureSize(iter) { + if (iter.size === undefined) { + iter.size = iter.__iterate(returnTrue); + } + return iter.size; +} + +function wrapIndex(iter, index) { + // This implements "is array index" which the ECMAString spec defines as: + // + // A String property name P is an array index if and only if + // ToString(ToUint32(P)) is equal to P and ToUint32(P) is not equal + // to 2^32−1. + // + // http://www.ecma-international.org/ecma-262/6.0/#sec-array-exotic-objects + if (typeof index !== 'number') { + var uint32Index = index >>> 0; // N >>> 0 is shorthand for ToUint32 + if ('' + uint32Index !== index || uint32Index === 4294967295) { + return NaN; + } + index = uint32Index; + } + return index < 0 ? ensureSize(iter) + index : index; +} + +function returnTrue() { + return true; +} + +function wholeSlice(begin, end, size) { + return ((begin === 0 && !isNeg(begin)) || + (size !== undefined && begin <= -size)) && + (end === undefined || (size !== undefined && end >= size)); +} + +function resolveBegin(begin, size) { + return resolveIndex(begin, size, 0); +} + +function resolveEnd(end, size) { + return resolveIndex(end, size, size); +} + +function resolveIndex(index, size, defaultIndex) { + // Sanitize indices using this shorthand for ToInt32(argument) + // http://www.ecma-international.org/ecma-262/6.0/#sec-toint32 + return index === undefined + ? defaultIndex + : isNeg(index) + ? size === Infinity ? size : Math.max(0, size + index) | 0 + : size === undefined || size === index + ? index + : Math.min(size, index) | 0; +} + +function isNeg(value) { + // Account for -0 which is negative, but not less than 0. + return value < 0 || (value === 0 && 1 / value === -Infinity); +} + +function isImmutable(maybeImmutable) { + return (isCollection(maybeImmutable) || isRecord(maybeImmutable)) && + !maybeImmutable.__ownerID; +} + +function isCollection(maybeCollection) { + return !!(maybeCollection && maybeCollection[IS_ITERABLE_SENTINEL]); +} + +function isKeyed(maybeKeyed) { + return !!(maybeKeyed && maybeKeyed[IS_KEYED_SENTINEL]); +} + +function isIndexed(maybeIndexed) { + return !!(maybeIndexed && maybeIndexed[IS_INDEXED_SENTINEL]); +} + +function isAssociative(maybeAssociative) { + return isKeyed(maybeAssociative) || isIndexed(maybeAssociative); +} + +function isOrdered(maybeOrdered) { + return !!(maybeOrdered && maybeOrdered[IS_ORDERED_SENTINEL]); +} + +function isRecord(maybeRecord) { + return !!(maybeRecord && maybeRecord[IS_RECORD_SENTINEL]); +} + +function isValueObject(maybeValue) { + return !!(maybeValue && + typeof maybeValue.equals === 'function' && + typeof maybeValue.hashCode === 'function'); +} + +var IS_ITERABLE_SENTINEL = '@@__IMMUTABLE_ITERABLE__@@'; +var IS_KEYED_SENTINEL = '@@__IMMUTABLE_KEYED__@@'; +var IS_INDEXED_SENTINEL = '@@__IMMUTABLE_INDEXED__@@'; +var IS_ORDERED_SENTINEL = '@@__IMMUTABLE_ORDERED__@@'; +var IS_RECORD_SENTINEL = '@@__IMMUTABLE_RECORD__@@'; + +var Collection = function Collection(value) { + return isCollection(value) ? value : Seq(value); +}; + +var KeyedCollection = (function (Collection) { + function KeyedCollection(value) { + return isKeyed(value) ? value : KeyedSeq(value); + } + + if ( Collection ) KeyedCollection.__proto__ = Collection; + KeyedCollection.prototype = Object.create( Collection && Collection.prototype ); + KeyedCollection.prototype.constructor = KeyedCollection; + + return KeyedCollection; +}(Collection)); + +var IndexedCollection = (function (Collection) { + function IndexedCollection(value) { + return isIndexed(value) ? value : IndexedSeq(value); + } + + if ( Collection ) IndexedCollection.__proto__ = Collection; + IndexedCollection.prototype = Object.create( Collection && Collection.prototype ); + IndexedCollection.prototype.constructor = IndexedCollection; + + return IndexedCollection; +}(Collection)); + +var SetCollection = (function (Collection) { + function SetCollection(value) { + return isCollection(value) && !isAssociative(value) ? value : SetSeq(value); + } + + if ( Collection ) SetCollection.__proto__ = Collection; + SetCollection.prototype = Object.create( Collection && Collection.prototype ); + SetCollection.prototype.constructor = SetCollection; + + return SetCollection; +}(Collection)); + +Collection.Keyed = KeyedCollection; +Collection.Indexed = IndexedCollection; +Collection.Set = SetCollection; + +var ITERATE_KEYS = 0; +var ITERATE_VALUES = 1; +var ITERATE_ENTRIES = 2; + +var REAL_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator; +var FAUX_ITERATOR_SYMBOL = '@@iterator'; + +var ITERATOR_SYMBOL = REAL_ITERATOR_SYMBOL || FAUX_ITERATOR_SYMBOL; + +var Iterator = function Iterator(next) { + this.next = next; +}; + +Iterator.prototype.toString = function toString () { + return '[Iterator]'; +}; + +Iterator.KEYS = ITERATE_KEYS; +Iterator.VALUES = ITERATE_VALUES; +Iterator.ENTRIES = ITERATE_ENTRIES; + +Iterator.prototype.inspect = (Iterator.prototype.toSource = function() { + return this.toString(); +}); +Iterator.prototype[ITERATOR_SYMBOL] = function() { + return this; +}; + +function iteratorValue(type, k, v, iteratorResult) { + var value = type === 0 ? k : type === 1 ? v : [k, v]; + iteratorResult + ? (iteratorResult.value = value) + : (iteratorResult = { + value: value, + done: false + }); + return iteratorResult; +} + +function iteratorDone() { + return { value: undefined, done: true }; +} + +function hasIterator(maybeIterable) { + return !!getIteratorFn(maybeIterable); +} + +function isIterator(maybeIterator) { + return maybeIterator && typeof maybeIterator.next === 'function'; +} + +function getIterator(iterable) { + var iteratorFn = getIteratorFn(iterable); + return iteratorFn && iteratorFn.call(iterable); +} + +function getIteratorFn(iterable) { + var iteratorFn = iterable && + ((REAL_ITERATOR_SYMBOL && iterable[REAL_ITERATOR_SYMBOL]) || + iterable[FAUX_ITERATOR_SYMBOL]); + if (typeof iteratorFn === 'function') { + return iteratorFn; + } +} + +function isArrayLike(value) { + return value && typeof value.length === 'number'; +} + +var Seq = (function (Collection$$1) { + function Seq(value) { + return value === null || value === undefined + ? emptySequence() + : isCollection(value) || isRecord(value) + ? value.toSeq() + : seqFromValue(value); + } + + if ( Collection$$1 ) Seq.__proto__ = Collection$$1; + Seq.prototype = Object.create( Collection$$1 && Collection$$1.prototype ); + Seq.prototype.constructor = Seq; + + Seq.prototype.toSeq = function toSeq () { + return this; + }; + + Seq.prototype.toString = function toString () { + return this.__toString('Seq {', '}'); + }; + + Seq.prototype.cacheResult = function cacheResult () { + if (!this._cache && this.__iterateUncached) { + this._cache = this.entrySeq().toArray(); + this.size = this._cache.length; + } + return this; + }; + + // abstract __iterateUncached(fn, reverse) + + Seq.prototype.__iterate = function __iterate (fn, reverse) { + var this$1 = this; + + var cache = this._cache; + if (cache) { + var size = cache.length; + var i = 0; + while (i !== size) { + var entry = cache[reverse ? size - ++i : i++]; + if (fn(entry[1], entry[0], this$1) === false) { + break; + } + } + return i; + } + return this.__iterateUncached(fn, reverse); + }; + + // abstract __iteratorUncached(type, reverse) + + Seq.prototype.__iterator = function __iterator (type, reverse) { + var cache = this._cache; + if (cache) { + var size = cache.length; + var i = 0; + return new Iterator(function () { + if (i === size) { + return iteratorDone(); + } + var entry = cache[reverse ? size - ++i : i++]; + return iteratorValue(type, entry[0], entry[1]); + }); + } + return this.__iteratorUncached(type, reverse); + }; + + return Seq; +}(Collection)); + +var KeyedSeq = (function (Seq) { + function KeyedSeq(value) { + return value === null || value === undefined + ? emptySequence().toKeyedSeq() + : isCollection(value) + ? isKeyed(value) ? value.toSeq() : value.fromEntrySeq() + : isRecord(value) ? value.toSeq() : keyedSeqFromValue(value); + } + + if ( Seq ) KeyedSeq.__proto__ = Seq; + KeyedSeq.prototype = Object.create( Seq && Seq.prototype ); + KeyedSeq.prototype.constructor = KeyedSeq; + + KeyedSeq.prototype.toKeyedSeq = function toKeyedSeq () { + return this; + }; + + return KeyedSeq; +}(Seq)); + +var IndexedSeq = (function (Seq) { + function IndexedSeq(value) { + return value === null || value === undefined + ? emptySequence() + : isCollection(value) + ? isKeyed(value) ? value.entrySeq() : value.toIndexedSeq() + : isRecord(value) + ? value.toSeq().entrySeq() + : indexedSeqFromValue(value); + } + + if ( Seq ) IndexedSeq.__proto__ = Seq; + IndexedSeq.prototype = Object.create( Seq && Seq.prototype ); + IndexedSeq.prototype.constructor = IndexedSeq; + + IndexedSeq.of = function of (/*...values*/) { + return IndexedSeq(arguments); + }; + + IndexedSeq.prototype.toIndexedSeq = function toIndexedSeq () { + return this; + }; + + IndexedSeq.prototype.toString = function toString () { + return this.__toString('Seq [', ']'); + }; + + return IndexedSeq; +}(Seq)); + +var SetSeq = (function (Seq) { + function SetSeq(value) { + return (isCollection(value) && !isAssociative(value) + ? value + : IndexedSeq(value)).toSetSeq(); + } + + if ( Seq ) SetSeq.__proto__ = Seq; + SetSeq.prototype = Object.create( Seq && Seq.prototype ); + SetSeq.prototype.constructor = SetSeq; + + SetSeq.of = function of (/*...values*/) { + return SetSeq(arguments); + }; + + SetSeq.prototype.toSetSeq = function toSetSeq () { + return this; + }; + + return SetSeq; +}(Seq)); + +Seq.isSeq = isSeq; +Seq.Keyed = KeyedSeq; +Seq.Set = SetSeq; +Seq.Indexed = IndexedSeq; + +var IS_SEQ_SENTINEL = '@@__IMMUTABLE_SEQ__@@'; + +Seq.prototype[IS_SEQ_SENTINEL] = true; + +// #pragma Root Sequences + +var ArraySeq = (function (IndexedSeq) { + function ArraySeq(array) { + this._array = array; + this.size = array.length; + } + + if ( IndexedSeq ) ArraySeq.__proto__ = IndexedSeq; + ArraySeq.prototype = Object.create( IndexedSeq && IndexedSeq.prototype ); + ArraySeq.prototype.constructor = ArraySeq; + + ArraySeq.prototype.get = function get (index, notSetValue) { + return this.has(index) ? this._array[wrapIndex(this, index)] : notSetValue; + }; + + ArraySeq.prototype.__iterate = function __iterate (fn, reverse) { + var this$1 = this; + + var array = this._array; + var size = array.length; + var i = 0; + while (i !== size) { + var ii = reverse ? size - ++i : i++; + if (fn(array[ii], ii, this$1) === false) { + break; + } + } + return i; + }; + + ArraySeq.prototype.__iterator = function __iterator (type, reverse) { + var array = this._array; + var size = array.length; + var i = 0; + return new Iterator(function () { + if (i === size) { + return iteratorDone(); + } + var ii = reverse ? size - ++i : i++; + return iteratorValue(type, ii, array[ii]); + }); + }; + + return ArraySeq; +}(IndexedSeq)); + +var ObjectSeq = (function (KeyedSeq) { + function ObjectSeq(object) { + var keys = Object.keys(object); + this._object = object; + this._keys = keys; + this.size = keys.length; + } + + if ( KeyedSeq ) ObjectSeq.__proto__ = KeyedSeq; + ObjectSeq.prototype = Object.create( KeyedSeq && KeyedSeq.prototype ); + ObjectSeq.prototype.constructor = ObjectSeq; + + ObjectSeq.prototype.get = function get (key, notSetValue) { + if (notSetValue !== undefined && !this.has(key)) { + return notSetValue; + } + return this._object[key]; + }; + + ObjectSeq.prototype.has = function has (key) { + return this._object.hasOwnProperty(key); + }; + + ObjectSeq.prototype.__iterate = function __iterate (fn, reverse) { + var this$1 = this; + + var object = this._object; + var keys = this._keys; + var size = keys.length; + var i = 0; + while (i !== size) { + var key = keys[reverse ? size - ++i : i++]; + if (fn(object[key], key, this$1) === false) { + break; + } + } + return i; + }; + + ObjectSeq.prototype.__iterator = function __iterator (type, reverse) { + var object = this._object; + var keys = this._keys; + var size = keys.length; + var i = 0; + return new Iterator(function () { + if (i === size) { + return iteratorDone(); + } + var key = keys[reverse ? size - ++i : i++]; + return iteratorValue(type, key, object[key]); + }); + }; + + return ObjectSeq; +}(KeyedSeq)); +ObjectSeq.prototype[IS_ORDERED_SENTINEL] = true; + +var CollectionSeq = (function (IndexedSeq) { + function CollectionSeq(collection) { + this._collection = collection; + this.size = collection.length || collection.size; + } + + if ( IndexedSeq ) CollectionSeq.__proto__ = IndexedSeq; + CollectionSeq.prototype = Object.create( IndexedSeq && IndexedSeq.prototype ); + CollectionSeq.prototype.constructor = CollectionSeq; + + CollectionSeq.prototype.__iterateUncached = function __iterateUncached (fn, reverse) { + var this$1 = this; + + if (reverse) { + return this.cacheResult().__iterate(fn, reverse); + } + var collection = this._collection; + var iterator = getIterator(collection); + var iterations = 0; + if (isIterator(iterator)) { + var step; + while (!(step = iterator.next()).done) { + if (fn(step.value, iterations++, this$1) === false) { + break; + } + } + } + return iterations; + }; + + CollectionSeq.prototype.__iteratorUncached = function __iteratorUncached (type, reverse) { + if (reverse) { + return this.cacheResult().__iterator(type, reverse); + } + var collection = this._collection; + var iterator = getIterator(collection); + if (!isIterator(iterator)) { + return new Iterator(iteratorDone); + } + var iterations = 0; + return new Iterator(function () { + var step = iterator.next(); + return step.done ? step : iteratorValue(type, iterations++, step.value); + }); + }; + + return CollectionSeq; +}(IndexedSeq)); + +var IteratorSeq = (function (IndexedSeq) { + function IteratorSeq(iterator) { + this._iterator = iterator; + this._iteratorCache = []; + } + + if ( IndexedSeq ) IteratorSeq.__proto__ = IndexedSeq; + IteratorSeq.prototype = Object.create( IndexedSeq && IndexedSeq.prototype ); + IteratorSeq.prototype.constructor = IteratorSeq; + + IteratorSeq.prototype.__iterateUncached = function __iterateUncached (fn, reverse) { + var this$1 = this; + + if (reverse) { + return this.cacheResult().__iterate(fn, reverse); + } + var iterator = this._iterator; + var cache = this._iteratorCache; + var iterations = 0; + while (iterations < cache.length) { + if (fn(cache[iterations], iterations++, this$1) === false) { + return iterations; + } + } + var step; + while (!(step = iterator.next()).done) { + var val = step.value; + cache[iterations] = val; + if (fn(val, iterations++, this$1) === false) { + break; + } + } + return iterations; + }; + + IteratorSeq.prototype.__iteratorUncached = function __iteratorUncached (type, reverse) { + if (reverse) { + return this.cacheResult().__iterator(type, reverse); + } + var iterator = this._iterator; + var cache = this._iteratorCache; + var iterations = 0; + return new Iterator(function () { + if (iterations >= cache.length) { + var step = iterator.next(); + if (step.done) { + return step; + } + cache[iterations] = step.value; + } + return iteratorValue(type, iterations, cache[iterations++]); + }); + }; + + return IteratorSeq; +}(IndexedSeq)); + +// # pragma Helper functions + +function isSeq(maybeSeq) { + return !!(maybeSeq && maybeSeq[IS_SEQ_SENTINEL]); +} + +var EMPTY_SEQ; + +function emptySequence() { + return EMPTY_SEQ || (EMPTY_SEQ = new ArraySeq([])); +} + +function keyedSeqFromValue(value) { + var seq = Array.isArray(value) + ? new ArraySeq(value) + : isIterator(value) + ? new IteratorSeq(value) + : hasIterator(value) ? new CollectionSeq(value) : undefined; + if (seq) { + return seq.fromEntrySeq(); + } + if (typeof value === 'object') { + return new ObjectSeq(value); + } + throw new TypeError( + 'Expected Array or collection object of [k, v] entries, or keyed object: ' + + value + ); +} + +function indexedSeqFromValue(value) { + var seq = maybeIndexedSeqFromValue(value); + if (seq) { + return seq; + } + throw new TypeError( + 'Expected Array or collection object of values: ' + value + ); +} + +function seqFromValue(value) { + var seq = maybeIndexedSeqFromValue(value); + if (seq) { + return seq; + } + if (typeof value === 'object') { + return new ObjectSeq(value); + } + throw new TypeError( + 'Expected Array or collection object of values, or keyed object: ' + value + ); +} + +function maybeIndexedSeqFromValue(value) { + return isArrayLike(value) + ? new ArraySeq(value) + : isIterator(value) + ? new IteratorSeq(value) + : hasIterator(value) ? new CollectionSeq(value) : undefined; +} + +/** + * An extension of the "same-value" algorithm as [described for use by ES6 Map + * and Set](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map#Key_equality) + * + * NaN is considered the same as NaN, however -0 and 0 are considered the same + * value, which is different from the algorithm described by + * [`Object.is`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is). + * + * This is extended further to allow Objects to describe the values they + * represent, by way of `valueOf` or `equals` (and `hashCode`). + * + * Note: because of this extension, the key equality of Immutable.Map and the + * value equality of Immutable.Set will differ from ES6 Map and Set. + * + * ### Defining custom values + * + * The easiest way to describe the value an object represents is by implementing + * `valueOf`. For example, `Date` represents a value by returning a unix + * timestamp for `valueOf`: + * + * var date1 = new Date(1234567890000); // Fri Feb 13 2009 ... + * var date2 = new Date(1234567890000); + * date1.valueOf(); // 1234567890000 + * assert( date1 !== date2 ); + * assert( Immutable.is( date1, date2 ) ); + * + * Note: overriding `valueOf` may have other implications if you use this object + * where JavaScript expects a primitive, such as implicit string coercion. + * + * For more complex types, especially collections, implementing `valueOf` may + * not be performant. An alternative is to implement `equals` and `hashCode`. + * + * `equals` takes another object, presumably of similar type, and returns true + * if it is equal. Equality is symmetrical, so the same result should be + * returned if this and the argument are flipped. + * + * assert( a.equals(b) === b.equals(a) ); + * + * `hashCode` returns a 32bit integer number representing the object which will + * be used to determine how to store the value object in a Map or Set. You must + * provide both or neither methods, one must not exist without the other. + * + * Also, an important relationship between these methods must be upheld: if two + * values are equal, they *must* return the same hashCode. If the values are not + * equal, they might have the same hashCode; this is called a hash collision, + * and while undesirable for performance reasons, it is acceptable. + * + * if (a.equals(b)) { + * assert( a.hashCode() === b.hashCode() ); + * } + * + * All Immutable collections are Value Objects: they implement `equals()` + * and `hashCode()`. + */ +function is(valueA, valueB) { + if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) { + return true; + } + if (!valueA || !valueB) { + return false; + } + if ( + typeof valueA.valueOf === 'function' && typeof valueB.valueOf === 'function' + ) { + valueA = valueA.valueOf(); + valueB = valueB.valueOf(); + if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) { + return true; + } + if (!valueA || !valueB) { + return false; + } + } + return !!(isValueObject(valueA) && + isValueObject(valueB) && + valueA.equals(valueB)); +} + +function fromJS(value, converter) { + return fromJSWith( + [], + converter || defaultConverter, + value, + '', + converter && converter.length > 2 ? [] : undefined, + { '': value } + ); +} + +function fromJSWith(stack, converter, value, key, keyPath, parentValue) { + var toSeq = Array.isArray(value) + ? IndexedSeq + : isPlainObj(value) ? KeyedSeq : null; + if (toSeq) { + if (~stack.indexOf(value)) { + throw new TypeError('Cannot convert circular structure to Immutable'); + } + stack.push(value); + keyPath && key !== '' && keyPath.push(key); + var converted = converter.call( + parentValue, + key, + toSeq(value).map(function (v, k) { return fromJSWith(stack, converter, v, k, keyPath, value); }), + keyPath && keyPath.slice() + ); + stack.pop(); + keyPath && keyPath.pop(); + return converted; + } + return value; +} + +function defaultConverter(k, v) { + return isKeyed(v) ? v.toMap() : v.toList(); +} + +function isPlainObj(value) { + return value && + (value.constructor === Object || value.constructor === undefined); +} + +var imul = typeof Math.imul === 'function' && + Math.imul(0xffffffff, 2) === -2 + ? Math.imul + : function imul(a, b) { + a |= 0; // int + b |= 0; // int + var c = a & 0xffff; + var d = b & 0xffff; + // Shift by 0 fixes the sign on the high part. + return c * d + ((a >>> 16) * d + c * (b >>> 16) << 16 >>> 0) | 0; // int + }; + +// v8 has an optimization for storing 31-bit signed numbers. +// Values which have either 00 or 11 as the high order bits qualify. +// This function drops the highest order bit in a signed number, maintaining +// the sign bit. +function smi(i32) { + return i32 >>> 1 & 0x40000000 | i32 & 0xbfffffff; +} + +function hash(o) { + if (o === false || o === null || o === undefined) { + return 0; + } + if (typeof o.valueOf === 'function') { + o = o.valueOf(); + if (o === false || o === null || o === undefined) { + return 0; + } + } + if (o === true) { + return 1; + } + var type = typeof o; + if (type === 'number') { + if (o !== o || o === Infinity) { + return 0; + } + var h = o | 0; + if (h !== o) { + h ^= o * 0xffffffff; + } + while (o > 0xffffffff) { + o /= 0xffffffff; + h ^= o; + } + return smi(h); + } + if (type === 'string') { + return o.length > STRING_HASH_CACHE_MIN_STRLEN + ? cachedHashString(o) + : hashString(o); + } + if (typeof o.hashCode === 'function') { + // Drop any high bits from accidentally long hash codes. + return smi(o.hashCode()); + } + if (type === 'object') { + return hashJSObj(o); + } + if (typeof o.toString === 'function') { + return hashString(o.toString()); + } + throw new Error('Value type ' + type + ' cannot be hashed.'); +} + +function cachedHashString(string) { + var hashed = stringHashCache[string]; + if (hashed === undefined) { + hashed = hashString(string); + if (STRING_HASH_CACHE_SIZE === STRING_HASH_CACHE_MAX_SIZE) { + STRING_HASH_CACHE_SIZE = 0; + stringHashCache = {}; + } + STRING_HASH_CACHE_SIZE++; + stringHashCache[string] = hashed; + } + return hashed; +} + +// http://jsperf.com/hashing-strings +function hashString(string) { + // This is the hash from JVM + // The hash code for a string is computed as + // s[0] * 31 ^ (n - 1) + s[1] * 31 ^ (n - 2) + ... + s[n - 1], + // where s[i] is the ith character of the string and n is the length of + // the string. We "mod" the result to make it between 0 (inclusive) and 2^31 + // (exclusive) by dropping high bits. + var hashed = 0; + for (var ii = 0; ii < string.length; ii++) { + hashed = 31 * hash + string.charCodeAt(ii) | 0; + } + return smi(hashed); +} + +function hashJSObj(obj) { + var hashed; + if (usingWeakMap) { + hashed = weakMap.get(obj); + if (hashed !== undefined) { + return hashed; + } + } + + hashed = obj[UID_HASH_KEY]; + if (hash !== undefined) { + return hashed; + } + + if (!canDefineProperty) { + hashed = obj.propertyIsEnumerable && obj.propertyIsEnumerable[UID_HASH_KEY]; + if (hashed !== undefined) { + return hashed; + } + + hashed = getIENodeHash(obj); + if (hashed !== undefined) { + return hashed; + } + } + + hashed = ++objHashUID; + if (objHashUID & 0x40000000) { + objHashUID = 0; + } + + if (usingWeakMap) { + weakMap.set(obj, hashed); + } else if (isExtensible !== undefined && isExtensible(obj) === false) { + throw new Error('Non-extensible objects are not allowed as keys.'); + } else if (canDefineProperty) { + Object.defineProperty(obj, UID_HASH_KEY, { + enumerable: false, + configurable: false, + writable: false, + value: hashed + }); + } else if ( + obj.propertyIsEnumerable !== undefined && + obj.propertyIsEnumerable === obj.constructor.prototype.propertyIsEnumerable + ) { + // Since we can't define a non-enumerable property on the object + // we'll hijack one of the less-used non-enumerable properties to + // save our hash on it. Since this is a function it will not show up in + // `JSON.stringify` which is what we want. + obj.propertyIsEnumerable = function() { + return this.constructor.prototype.propertyIsEnumerable.apply( + this, + arguments + ); + }; + obj.propertyIsEnumerable[UID_HASH_KEY] = hashed; + } else if (obj.nodeType !== undefined) { + // At this point we couldn't get the IE `uniqueID` to use as a hash + // and we couldn't use a non-enumerable property to exploit the + // dontEnum bug so we simply add the `UID_HASH_KEY` on the node + // itself. + obj[UID_HASH_KEY] = hashed; + } else { + throw new Error('Unable to set a non-enumerable property on object.'); + } + + return hashed; +} + +// Get references to ES5 object methods. +var isExtensible = Object.isExtensible; + +// True if Object.defineProperty works as expected. IE8 fails this test. +var canDefineProperty = (function() { + try { + Object.defineProperty({}, '@', {}); + return true; + } catch (e) { + return false; + } +})(); + +// IE has a `uniqueID` property on DOM nodes. We can construct the hash from it +// and avoid memory leaks from the IE cloneNode bug. +function getIENodeHash(node) { + if (node && node.nodeType > 0) { + switch (node.nodeType) { + case 1: // Element + return node.uniqueID; + case 9: // Document + return node.documentElement && node.documentElement.uniqueID; + } + } +} + +// If possible, use a WeakMap. +var usingWeakMap = typeof WeakMap === 'function'; +var weakMap; +if (usingWeakMap) { + weakMap = new WeakMap(); +} + +var objHashUID = 0; + +var UID_HASH_KEY = '__immutablehash__'; +if (typeof Symbol === 'function') { + UID_HASH_KEY = Symbol(UID_HASH_KEY); +} + +var STRING_HASH_CACHE_MIN_STRLEN = 16; +var STRING_HASH_CACHE_MAX_SIZE = 255; +var STRING_HASH_CACHE_SIZE = 0; +var stringHashCache = {}; + +var ToKeyedSequence = (function (KeyedSeq$$1) { + function ToKeyedSequence(indexed, useKeys) { + this._iter = indexed; + this._useKeys = useKeys; + this.size = indexed.size; + } + + if ( KeyedSeq$$1 ) ToKeyedSequence.__proto__ = KeyedSeq$$1; + ToKeyedSequence.prototype = Object.create( KeyedSeq$$1 && KeyedSeq$$1.prototype ); + ToKeyedSequence.prototype.constructor = ToKeyedSequence; + + ToKeyedSequence.prototype.get = function get (key, notSetValue) { + return this._iter.get(key, notSetValue); + }; + + ToKeyedSequence.prototype.has = function has (key) { + return this._iter.has(key); + }; + + ToKeyedSequence.prototype.valueSeq = function valueSeq () { + return this._iter.valueSeq(); + }; + + ToKeyedSequence.prototype.reverse = function reverse () { + var this$1 = this; + + var reversedSequence = reverseFactory(this, true); + if (!this._useKeys) { + reversedSequence.valueSeq = function () { return this$1._iter.toSeq().reverse(); }; + } + return reversedSequence; + }; + + ToKeyedSequence.prototype.map = function map (mapper, context) { + var this$1 = this; + + var mappedSequence = mapFactory(this, mapper, context); + if (!this._useKeys) { + mappedSequence.valueSeq = function () { return this$1._iter.toSeq().map(mapper, context); }; + } + return mappedSequence; + }; + + ToKeyedSequence.prototype.__iterate = function __iterate (fn, reverse) { + var this$1 = this; + + return this._iter.__iterate(function (v, k) { return fn(v, k, this$1); }, reverse); + }; + + ToKeyedSequence.prototype.__iterator = function __iterator (type, reverse) { + return this._iter.__iterator(type, reverse); + }; + + return ToKeyedSequence; +}(KeyedSeq)); +ToKeyedSequence.prototype[IS_ORDERED_SENTINEL] = true; + +var ToIndexedSequence = (function (IndexedSeq$$1) { + function ToIndexedSequence(iter) { + this._iter = iter; + this.size = iter.size; + } + + if ( IndexedSeq$$1 ) ToIndexedSequence.__proto__ = IndexedSeq$$1; + ToIndexedSequence.prototype = Object.create( IndexedSeq$$1 && IndexedSeq$$1.prototype ); + ToIndexedSequence.prototype.constructor = ToIndexedSequence; + + ToIndexedSequence.prototype.includes = function includes (value) { + return this._iter.includes(value); + }; + + ToIndexedSequence.prototype.__iterate = function __iterate (fn, reverse) { + var this$1 = this; + + var i = 0; + reverse && ensureSize(this); + return this._iter.__iterate( + function (v) { return fn(v, reverse ? this$1.size - ++i : i++, this$1); }, + reverse + ); + }; + + ToIndexedSequence.prototype.__iterator = function __iterator (type, reverse) { + var this$1 = this; + + var iterator = this._iter.__iterator(ITERATE_VALUES, reverse); + var i = 0; + reverse && ensureSize(this); + return new Iterator(function () { + var step = iterator.next(); + return step.done + ? step + : iteratorValue( + type, + reverse ? this$1.size - ++i : i++, + step.value, + step + ); + }); + }; + + return ToIndexedSequence; +}(IndexedSeq)); + +var ToSetSequence = (function (SetSeq$$1) { + function ToSetSequence(iter) { + this._iter = iter; + this.size = iter.size; + } + + if ( SetSeq$$1 ) ToSetSequence.__proto__ = SetSeq$$1; + ToSetSequence.prototype = Object.create( SetSeq$$1 && SetSeq$$1.prototype ); + ToSetSequence.prototype.constructor = ToSetSequence; + + ToSetSequence.prototype.has = function has (key) { + return this._iter.includes(key); + }; + + ToSetSequence.prototype.__iterate = function __iterate (fn, reverse) { + var this$1 = this; + + return this._iter.__iterate(function (v) { return fn(v, v, this$1); }, reverse); + }; + + ToSetSequence.prototype.__iterator = function __iterator (type, reverse) { + var iterator = this._iter.__iterator(ITERATE_VALUES, reverse); + return new Iterator(function () { + var step = iterator.next(); + return step.done + ? step + : iteratorValue(type, step.value, step.value, step); + }); + }; + + return ToSetSequence; +}(SetSeq)); + +var FromEntriesSequence = (function (KeyedSeq$$1) { + function FromEntriesSequence(entries) { + this._iter = entries; + this.size = entries.size; + } + + if ( KeyedSeq$$1 ) FromEntriesSequence.__proto__ = KeyedSeq$$1; + FromEntriesSequence.prototype = Object.create( KeyedSeq$$1 && KeyedSeq$$1.prototype ); + FromEntriesSequence.prototype.constructor = FromEntriesSequence; + + FromEntriesSequence.prototype.entrySeq = function entrySeq () { + return this._iter.toSeq(); + }; + + FromEntriesSequence.prototype.__iterate = function __iterate (fn, reverse) { + var this$1 = this; + + return this._iter.__iterate( + function (entry) { + // Check if entry exists first so array access doesn't throw for holes + // in the parent iteration. + if (entry) { + validateEntry(entry); + var indexedCollection = isCollection(entry); + return fn( + indexedCollection ? entry.get(1) : entry[1], + indexedCollection ? entry.get(0) : entry[0], + this$1 + ); + } + }, + reverse + ); + }; + + FromEntriesSequence.prototype.__iterator = function __iterator (type, reverse) { + var iterator = this._iter.__iterator(ITERATE_VALUES, reverse); + return new Iterator(function () { + while (true) { + var step = iterator.next(); + if (step.done) { + return step; + } + var entry = step.value; + // Check if entry exists first so array access doesn't throw for holes + // in the parent iteration. + if (entry) { + validateEntry(entry); + var indexedCollection = isCollection(entry); + return iteratorValue( + type, + indexedCollection ? entry.get(0) : entry[0], + indexedCollection ? entry.get(1) : entry[1], + step + ); + } + } + }); + }; + + return FromEntriesSequence; +}(KeyedSeq)); + +ToIndexedSequence.prototype.cacheResult = (ToKeyedSequence.prototype.cacheResult = (ToSetSequence.prototype.cacheResult = (FromEntriesSequence.prototype.cacheResult = cacheResultThrough))); + +function flipFactory(collection) { + var flipSequence = makeSequence(collection); + flipSequence._iter = collection; + flipSequence.size = collection.size; + flipSequence.flip = function () { return collection; }; + flipSequence.reverse = function() { + var reversedSequence = collection.reverse.apply(this); // super.reverse() + reversedSequence.flip = function () { return collection.reverse(); }; + return reversedSequence; + }; + flipSequence.has = function (key) { return collection.includes(key); }; + flipSequence.includes = function (key) { return collection.has(key); }; + flipSequence.cacheResult = cacheResultThrough; + flipSequence.__iterateUncached = function(fn, reverse) { + var this$1 = this; + + return collection.__iterate(function (v, k) { return fn(k, v, this$1) !== false; }, reverse); + }; + flipSequence.__iteratorUncached = function(type, reverse) { + if (type === ITERATE_ENTRIES) { + var iterator = collection.__iterator(type, reverse); + return new Iterator(function () { + var step = iterator.next(); + if (!step.done) { + var k = step.value[0]; + step.value[0] = step.value[1]; + step.value[1] = k; + } + return step; + }); + } + return collection.__iterator( + type === ITERATE_VALUES ? ITERATE_KEYS : ITERATE_VALUES, + reverse + ); + }; + return flipSequence; +} + +function mapFactory(collection, mapper, context) { + var mappedSequence = makeSequence(collection); + mappedSequence.size = collection.size; + mappedSequence.has = function (key) { return collection.has(key); }; + mappedSequence.get = function (key, notSetValue) { + var v = collection.get(key, NOT_SET); + return v === NOT_SET + ? notSetValue + : mapper.call(context, v, key, collection); + }; + mappedSequence.__iterateUncached = function(fn, reverse) { + var this$1 = this; + + return collection.__iterate( + function (v, k, c) { return fn(mapper.call(context, v, k, c), k, this$1) !== false; }, + reverse + ); + }; + mappedSequence.__iteratorUncached = function(type, reverse) { + var iterator = collection.__iterator(ITERATE_ENTRIES, reverse); + return new Iterator(function () { + var step = iterator.next(); + if (step.done) { + return step; + } + var entry = step.value; + var key = entry[0]; + return iteratorValue( + type, + key, + mapper.call(context, entry[1], key, collection), + step + ); + }); + }; + return mappedSequence; +} + +function reverseFactory(collection, useKeys) { + var this$1 = this; + + var reversedSequence = makeSequence(collection); + reversedSequence._iter = collection; + reversedSequence.size = collection.size; + reversedSequence.reverse = function () { return collection; }; + if (collection.flip) { + reversedSequence.flip = function() { + var flipSequence = flipFactory(collection); + flipSequence.reverse = function () { return collection.flip(); }; + return flipSequence; + }; + } + reversedSequence.get = function (key, notSetValue) { return collection.get(useKeys ? key : -1 - key, notSetValue); }; + reversedSequence.has = function (key) { return collection.has(useKeys ? key : -1 - key); }; + reversedSequence.includes = function (value) { return collection.includes(value); }; + reversedSequence.cacheResult = cacheResultThrough; + reversedSequence.__iterate = function(fn, reverse) { + var this$1 = this; + + var i = 0; + reverse && ensureSize(collection); + return collection.__iterate( + function (v, k) { return fn(v, useKeys ? k : reverse ? this$1.size - ++i : i++, this$1); }, + !reverse + ); + }; + reversedSequence.__iterator = function (type, reverse) { + var i = 0; + reverse && ensureSize(collection); + var iterator = collection.__iterator(ITERATE_ENTRIES, !reverse); + return new Iterator(function () { + var step = iterator.next(); + if (step.done) { + return step; + } + var entry = step.value; + return iteratorValue( + type, + useKeys ? entry[0] : reverse ? this$1.size - ++i : i++, + entry[1], + step + ); + }); + }; + return reversedSequence; +} + +function filterFactory(collection, predicate, context, useKeys) { + var filterSequence = makeSequence(collection); + if (useKeys) { + filterSequence.has = function (key) { + var v = collection.get(key, NOT_SET); + return v !== NOT_SET && !!predicate.call(context, v, key, collection); + }; + filterSequence.get = function (key, notSetValue) { + var v = collection.get(key, NOT_SET); + return v !== NOT_SET && predicate.call(context, v, key, collection) + ? v + : notSetValue; + }; + } + filterSequence.__iterateUncached = function(fn, reverse) { + var this$1 = this; + + var iterations = 0; + collection.__iterate( + function (v, k, c) { + if (predicate.call(context, v, k, c)) { + iterations++; + return fn(v, useKeys ? k : iterations - 1, this$1); + } + }, + reverse + ); + return iterations; + }; + filterSequence.__iteratorUncached = function(type, reverse) { + var iterator = collection.__iterator(ITERATE_ENTRIES, reverse); + var iterations = 0; + return new Iterator(function () { + while (true) { + var step = iterator.next(); + if (step.done) { + return step; + } + var entry = step.value; + var key = entry[0]; + var value = entry[1]; + if (predicate.call(context, value, key, collection)) { + return iteratorValue(type, useKeys ? key : iterations++, value, step); + } + } + }); + }; + return filterSequence; +} + +function countByFactory(collection, grouper, context) { + var groups = Map().asMutable(); + collection.__iterate(function (v, k) { + groups.update(grouper.call(context, v, k, collection), 0, function (a) { return a + 1; }); + }); + return groups.asImmutable(); +} + +function groupByFactory(collection, grouper, context) { + var isKeyedIter = isKeyed(collection); + var groups = (isOrdered(collection) ? OrderedMap() : Map()).asMutable(); + collection.__iterate(function (v, k) { + groups.update( + grouper.call(context, v, k, collection), + function (a) { return ((a = a || []), a.push(isKeyedIter ? [k, v] : v), a); } + ); + }); + var coerce = collectionClass(collection); + return groups.map(function (arr) { return reify(collection, coerce(arr)); }); +} + +function sliceFactory(collection, begin, end, useKeys) { + var originalSize = collection.size; + + if (wholeSlice(begin, end, originalSize)) { + return collection; + } + + var resolvedBegin = resolveBegin(begin, originalSize); + var resolvedEnd = resolveEnd(end, originalSize); + + // begin or end will be NaN if they were provided as negative numbers and + // this collection's size is unknown. In that case, cache first so there is + // a known size and these do not resolve to NaN. + if (resolvedBegin !== resolvedBegin || resolvedEnd !== resolvedEnd) { + return sliceFactory(collection.toSeq().cacheResult(), begin, end, useKeys); + } + + // Note: resolvedEnd is undefined when the original sequence's length is + // unknown and this slice did not supply an end and should contain all + // elements after resolvedBegin. + // In that case, resolvedSize will be NaN and sliceSize will remain undefined. + var resolvedSize = resolvedEnd - resolvedBegin; + var sliceSize; + if (resolvedSize === resolvedSize) { + sliceSize = resolvedSize < 0 ? 0 : resolvedSize; + } + + var sliceSeq = makeSequence(collection); + + // If collection.size is undefined, the size of the realized sliceSeq is + // unknown at this point unless the number of items to slice is 0 + sliceSeq.size = sliceSize === 0 + ? sliceSize + : (collection.size && sliceSize) || undefined; + + if (!useKeys && isSeq(collection) && sliceSize >= 0) { + sliceSeq.get = function(index, notSetValue) { + index = wrapIndex(this, index); + return index >= 0 && index < sliceSize + ? collection.get(index + resolvedBegin, notSetValue) + : notSetValue; + }; + } + + sliceSeq.__iterateUncached = function(fn, reverse) { + var this$1 = this; + + if (sliceSize === 0) { + return 0; + } + if (reverse) { + return this.cacheResult().__iterate(fn, reverse); + } + var skipped = 0; + var isSkipping = true; + var iterations = 0; + collection.__iterate(function (v, k) { + if (!(isSkipping && (isSkipping = skipped++ < resolvedBegin))) { + iterations++; + return fn(v, useKeys ? k : iterations - 1, this$1) !== false && + iterations !== sliceSize; + } + }); + return iterations; + }; + + sliceSeq.__iteratorUncached = function(type, reverse) { + if (sliceSize !== 0 && reverse) { + return this.cacheResult().__iterator(type, reverse); + } + // Don't bother instantiating parent iterator if taking 0. + if (sliceSize === 0) { + return new Iterator(iteratorDone); + } + var iterator = collection.__iterator(type, reverse); + var skipped = 0; + var iterations = 0; + return new Iterator(function () { + while (skipped++ < resolvedBegin) { + iterator.next(); + } + if (++iterations > sliceSize) { + return iteratorDone(); + } + var step = iterator.next(); + if (useKeys || type === ITERATE_VALUES) { + return step; + } + if (type === ITERATE_KEYS) { + return iteratorValue(type, iterations - 1, undefined, step); + } + return iteratorValue(type, iterations - 1, step.value[1], step); + }); + }; + + return sliceSeq; +} + +function takeWhileFactory(collection, predicate, context) { + var takeSequence = makeSequence(collection); + takeSequence.__iterateUncached = function(fn, reverse) { + var this$1 = this; + + if (reverse) { + return this.cacheResult().__iterate(fn, reverse); + } + var iterations = 0; + collection.__iterate( + function (v, k, c) { return predicate.call(context, v, k, c) && ++iterations && fn(v, k, this$1); } + ); + return iterations; + }; + takeSequence.__iteratorUncached = function(type, reverse) { + var this$1 = this; + + if (reverse) { + return this.cacheResult().__iterator(type, reverse); + } + var iterator = collection.__iterator(ITERATE_ENTRIES, reverse); + var iterating = true; + return new Iterator(function () { + if (!iterating) { + return iteratorDone(); + } + var step = iterator.next(); + if (step.done) { + return step; + } + var entry = step.value; + var k = entry[0]; + var v = entry[1]; + if (!predicate.call(context, v, k, this$1)) { + iterating = false; + return iteratorDone(); + } + return type === ITERATE_ENTRIES ? step : iteratorValue(type, k, v, step); + }); + }; + return takeSequence; +} + +function skipWhileFactory(collection, predicate, context, useKeys) { + var skipSequence = makeSequence(collection); + skipSequence.__iterateUncached = function(fn, reverse) { + var this$1 = this; + + if (reverse) { + return this.cacheResult().__iterate(fn, reverse); + } + var isSkipping = true; + var iterations = 0; + collection.__iterate(function (v, k, c) { + if (!(isSkipping && (isSkipping = predicate.call(context, v, k, c)))) { + iterations++; + return fn(v, useKeys ? k : iterations - 1, this$1); + } + }); + return iterations; + }; + skipSequence.__iteratorUncached = function(type, reverse) { + var this$1 = this; + + if (reverse) { + return this.cacheResult().__iterator(type, reverse); + } + var iterator = collection.__iterator(ITERATE_ENTRIES, reverse); + var skipping = true; + var iterations = 0; + return new Iterator(function () { + var step; + var k; + var v; + do { + step = iterator.next(); + if (step.done) { + if (useKeys || type === ITERATE_VALUES) { + return step; + } + if (type === ITERATE_KEYS) { + return iteratorValue(type, iterations++, undefined, step); + } + return iteratorValue(type, iterations++, step.value[1], step); + } + var entry = step.value; + k = entry[0]; + v = entry[1]; + skipping && (skipping = predicate.call(context, v, k, this$1)); + } while (skipping); + return type === ITERATE_ENTRIES ? step : iteratorValue(type, k, v, step); + }); + }; + return skipSequence; +} + +function concatFactory(collection, values) { + var isKeyedCollection = isKeyed(collection); + var iters = [collection] + .concat(values) + .map(function (v) { + if (!isCollection(v)) { + v = isKeyedCollection + ? keyedSeqFromValue(v) + : indexedSeqFromValue(Array.isArray(v) ? v : [v]); + } else if (isKeyedCollection) { + v = KeyedCollection(v); + } + return v; + }) + .filter(function (v) { return v.size !== 0; }); + + if (iters.length === 0) { + return collection; + } + + if (iters.length === 1) { + var singleton = iters[0]; + if ( + singleton === collection || + (isKeyedCollection && isKeyed(singleton)) || + (isIndexed(collection) && isIndexed(singleton)) + ) { + return singleton; + } + } + + var concatSeq = new ArraySeq(iters); + if (isKeyedCollection) { + concatSeq = concatSeq.toKeyedSeq(); + } else if (!isIndexed(collection)) { + concatSeq = concatSeq.toSetSeq(); + } + concatSeq = concatSeq.flatten(true); + concatSeq.size = iters.reduce( + function (sum, seq) { + if (sum !== undefined) { + var size = seq.size; + if (size !== undefined) { + return sum + size; + } + } + }, + 0 + ); + return concatSeq; +} + +function flattenFactory(collection, depth, useKeys) { + var flatSequence = makeSequence(collection); + flatSequence.__iterateUncached = function(fn, reverse) { + if (reverse) { + return this.cacheResult().__iterate(fn, reverse); + } + var iterations = 0; + var stopped = false; + function flatDeep(iter, currentDepth) { + iter.__iterate( + function (v, k) { + if ((!depth || currentDepth < depth) && isCollection(v)) { + flatDeep(v, currentDepth + 1); + } else { + iterations++; + if (fn(v, useKeys ? k : iterations - 1, flatSequence) === false) { + stopped = true; + } + } + return !stopped; + }, + reverse + ); + } + flatDeep(collection, 0); + return iterations; + }; + flatSequence.__iteratorUncached = function(type, reverse) { + if (reverse) { + return this.cacheResult().__iterator(type, reverse); + } + var iterator = collection.__iterator(type, reverse); + var stack = []; + var iterations = 0; + return new Iterator(function () { + while (iterator) { + var step = iterator.next(); + if (step.done !== false) { + iterator = stack.pop(); + continue; + } + var v = step.value; + if (type === ITERATE_ENTRIES) { + v = v[1]; + } + if ((!depth || stack.length < depth) && isCollection(v)) { + stack.push(iterator); + iterator = v.__iterator(type, reverse); + } else { + return useKeys ? step : iteratorValue(type, iterations++, v, step); + } + } + return iteratorDone(); + }); + }; + return flatSequence; +} + +function flatMapFactory(collection, mapper, context) { + var coerce = collectionClass(collection); + return collection + .toSeq() + .map(function (v, k) { return coerce(mapper.call(context, v, k, collection)); }) + .flatten(true); +} + +function interposeFactory(collection, separator) { + var interposedSequence = makeSequence(collection); + interposedSequence.size = collection.size && collection.size * 2 - 1; + interposedSequence.__iterateUncached = function(fn, reverse) { + var this$1 = this; + + var iterations = 0; + collection.__iterate( + function (v) { return (!iterations || fn(separator, iterations++, this$1) !== false) && + fn(v, iterations++, this$1) !== false; }, + reverse + ); + return iterations; + }; + interposedSequence.__iteratorUncached = function(type, reverse) { + var iterator = collection.__iterator(ITERATE_VALUES, reverse); + var iterations = 0; + var step; + return new Iterator(function () { + if (!step || iterations % 2) { + step = iterator.next(); + if (step.done) { + return step; + } + } + return iterations % 2 + ? iteratorValue(type, iterations++, separator) + : iteratorValue(type, iterations++, step.value, step); + }); + }; + return interposedSequence; +} + +function sortFactory(collection, comparator, mapper) { + if (!comparator) { + comparator = defaultComparator; + } + var isKeyedCollection = isKeyed(collection); + var index = 0; + var entries = collection + .toSeq() + .map(function (v, k) { return [k, v, index++, mapper ? mapper(v, k, collection) : v]; }) + .toArray(); + entries.sort(function (a, b) { return comparator(a[3], b[3]) || a[2] - b[2]; }).forEach( + isKeyedCollection + ? function (v, i) { + entries[i].length = 2; + } + : function (v, i) { + entries[i] = v[1]; + } + ); + return isKeyedCollection + ? KeyedSeq(entries) + : isIndexed(collection) ? IndexedSeq(entries) : SetSeq(entries); +} + +function maxFactory(collection, comparator, mapper) { + if (!comparator) { + comparator = defaultComparator; + } + if (mapper) { + var entry = collection + .toSeq() + .map(function (v, k) { return [v, mapper(v, k, collection)]; }) + .reduce(function (a, b) { return maxCompare(comparator, a[1], b[1]) ? b : a; }); + return entry && entry[0]; + } + return collection.reduce(function (a, b) { return maxCompare(comparator, a, b) ? b : a; }); +} + +function maxCompare(comparator, a, b) { + var comp = comparator(b, a); + // b is considered the new max if the comparator declares them equal, but + // they are not equal and b is in fact a nullish value. + return (comp === 0 && + b !== a && + (b === undefined || b === null || b !== b)) || + comp > 0; +} + +function zipWithFactory(keyIter, zipper, iters) { + var zipSequence = makeSequence(keyIter); + zipSequence.size = new ArraySeq(iters).map(function (i) { return i.size; }).min(); + // Note: this a generic base implementation of __iterate in terms of + // __iterator which may be more generically useful in the future. + zipSequence.__iterate = function(fn, reverse) { + var this$1 = this; + + /* generic: + var iterator = this.__iterator(ITERATE_ENTRIES, reverse); + var step; + var iterations = 0; + while (!(step = iterator.next()).done) { + iterations++; + if (fn(step.value[1], step.value[0], this) === false) { + break; + } + } + return iterations; + */ + // indexed: + var iterator = this.__iterator(ITERATE_VALUES, reverse); + var step; + var iterations = 0; + while (!(step = iterator.next()).done) { + if (fn(step.value, iterations++, this$1) === false) { + break; + } + } + return iterations; + }; + zipSequence.__iteratorUncached = function(type, reverse) { + var iterators = iters.map( + function (i) { return ((i = Collection(i)), getIterator(reverse ? i.reverse() : i)); } + ); + var iterations = 0; + var isDone = false; + return new Iterator(function () { + var steps; + if (!isDone) { + steps = iterators.map(function (i) { return i.next(); }); + isDone = steps.some(function (s) { return s.done; }); + } + if (isDone) { + return iteratorDone(); + } + return iteratorValue( + type, + iterations++, + zipper.apply(null, steps.map(function (s) { return s.value; })) + ); + }); + }; + return zipSequence; +} + +// #pragma Helper Functions + +function reify(iter, seq) { + return iter === seq ? iter : isSeq(iter) ? seq : iter.constructor(seq); +} + +function validateEntry(entry) { + if (entry !== Object(entry)) { + throw new TypeError('Expected [K, V] tuple: ' + entry); + } +} + +function collectionClass(collection) { + return isKeyed(collection) + ? KeyedCollection + : isIndexed(collection) ? IndexedCollection : SetCollection; +} + +function makeSequence(collection) { + return Object.create( + (isKeyed(collection) + ? KeyedSeq + : isIndexed(collection) ? IndexedSeq : SetSeq).prototype + ); +} + +function cacheResultThrough() { + if (this._iter.cacheResult) { + this._iter.cacheResult(); + this.size = this._iter.size; + return this; + } + return Seq.prototype.cacheResult.call(this); +} + +function defaultComparator(a, b) { + if (a === undefined && b === undefined) { + return 0; + } + + if (a === undefined) { + return 1; + } + + if (b === undefined) { + return -1; + } + + return a > b ? 1 : a < b ? -1 : 0; +} + +function coerceKeyPath(keyPath) { + if (isArrayLike(keyPath) && typeof keyPath !== 'string') { + return keyPath; + } + if (isOrdered(keyPath)) { + return keyPath.toArray(); + } + throw new TypeError( + 'Invalid keyPath: expected Ordered Collection or Array: ' + keyPath + ); +} + +function invariant(condition, error) { + if (!condition) { throw new Error(error); } +} + +function assertNotInfinite(size) { + invariant( + size !== Infinity, + 'Cannot perform this action with an infinite size.' + ); +} + +/** + * Converts a value to a string, adding quotes if a string was provided. + */ +function quoteString(value) { + return typeof value === 'string' ? JSON.stringify(value) : String(value); +} + +var Map = (function (KeyedCollection$$1) { + function Map(value) { + return value === null || value === undefined + ? emptyMap() + : isMap(value) && !isOrdered(value) + ? value + : emptyMap().withMutations(function (map) { + var iter = KeyedCollection$$1(value); + assertNotInfinite(iter.size); + iter.forEach(function (v, k) { return map.set(k, v); }); + }); + } + + if ( KeyedCollection$$1 ) Map.__proto__ = KeyedCollection$$1; + Map.prototype = Object.create( KeyedCollection$$1 && KeyedCollection$$1.prototype ); + Map.prototype.constructor = Map; + + Map.of = function of () { + var keyValues = [], len = arguments.length; + while ( len-- ) keyValues[ len ] = arguments[ len ]; + + return emptyMap().withMutations(function (map) { + for (var i = 0; i < keyValues.length; i += 2) { + if (i + 1 >= keyValues.length) { + throw new Error('Missing value for key: ' + keyValues[i]); + } + map.set(keyValues[i], keyValues[i + 1]); + } + }); + }; + + Map.prototype.toString = function toString () { + return this.__toString('Map {', '}'); + }; + + // @pragma Access + + Map.prototype.get = function get (k, notSetValue) { + return this._root + ? this._root.get(0, undefined, k, notSetValue) + : notSetValue; + }; + + // @pragma Modification + + Map.prototype.set = function set (k, v) { + return updateMap(this, k, v); + }; + + Map.prototype.setIn = function setIn (keyPath, v) { + return this.updateIn(keyPath, NOT_SET, function () { return v; }); + }; + + Map.prototype.remove = function remove (k) { + return updateMap(this, k, NOT_SET); + }; + + Map.prototype.deleteIn = function deleteIn (keyPath) { + keyPath = [].concat( coerceKeyPath(keyPath) ); + if (keyPath.length) { + var lastKey = keyPath.pop(); + return this.updateIn(keyPath, function (c) { return c && c.remove(lastKey); }); + } + }; + + Map.prototype.deleteAll = function deleteAll (keys) { + var collection = Collection(keys); + + if (collection.size === 0) { + return this; + } + + return this.withMutations(function (map) { + collection.forEach(function (key) { return map.remove(key); }); + }); + }; + + Map.prototype.update = function update (k, notSetValue, updater) { + return arguments.length === 1 + ? k(this) + : this.updateIn([k], notSetValue, updater); + }; + + Map.prototype.updateIn = function updateIn (keyPath, notSetValue, updater) { + if (!updater) { + updater = notSetValue; + notSetValue = undefined; + } + var updatedValue = updateInDeepMap( + this, + coerceKeyPath(keyPath), + 0, + notSetValue, + updater + ); + return updatedValue === NOT_SET ? notSetValue : updatedValue; + }; + + Map.prototype.clear = function clear () { + if (this.size === 0) { + return this; + } + if (this.__ownerID) { + this.size = 0; + this._root = null; + this.__hash = undefined; + this.__altered = true; + return this; + } + return emptyMap(); + }; + + // @pragma Composition + + Map.prototype.merge = function merge (/*...iters*/) { + return mergeIntoMapWith(this, undefined, arguments); + }; + + Map.prototype.mergeWith = function mergeWith (merger) { + var iters = [], len = arguments.length - 1; + while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; + + return mergeIntoMapWith(this, merger, iters); + }; + + Map.prototype.mergeIn = function mergeIn (keyPath) { + var iters = [], len = arguments.length - 1; + while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; + + return this.updateIn( + keyPath, + emptyMap(), + function (m) { return typeof m.merge === 'function' + ? m.merge.apply(m, iters) + : iters[iters.length - 1]; } + ); + }; + + Map.prototype.mergeDeep = function mergeDeep (/*...iters*/) { + return mergeIntoMapWith(this, deepMerger, arguments); + }; + + Map.prototype.mergeDeepWith = function mergeDeepWith (merger) { + var iters = [], len = arguments.length - 1; + while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; + + return mergeIntoMapWith(this, deepMergerWith(merger), iters); + }; + + Map.prototype.mergeDeepIn = function mergeDeepIn (keyPath) { + var iters = [], len = arguments.length - 1; + while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; + + return this.updateIn( + keyPath, + emptyMap(), + function (m) { return typeof m.mergeDeep === 'function' + ? m.mergeDeep.apply(m, iters) + : iters[iters.length - 1]; } + ); + }; + + Map.prototype.sort = function sort (comparator) { + // Late binding + return OrderedMap(sortFactory(this, comparator)); + }; + + Map.prototype.sortBy = function sortBy (mapper, comparator) { + // Late binding + return OrderedMap(sortFactory(this, comparator, mapper)); + }; + + // @pragma Mutability + + Map.prototype.withMutations = function withMutations (fn) { + var mutable = this.asMutable(); + fn(mutable); + return mutable.wasAltered() ? mutable.__ensureOwner(this.__ownerID) : this; + }; + + Map.prototype.asMutable = function asMutable () { + return this.__ownerID ? this : this.__ensureOwner(new OwnerID()); + }; + + Map.prototype.asImmutable = function asImmutable () { + return this.__ensureOwner(); + }; + + Map.prototype.wasAltered = function wasAltered () { + return this.__altered; + }; + + Map.prototype.__iterator = function __iterator (type, reverse) { + return new MapIterator(this, type, reverse); + }; + + Map.prototype.__iterate = function __iterate (fn, reverse) { + var this$1 = this; + + var iterations = 0; + this._root && + this._root.iterate( + function (entry) { + iterations++; + return fn(entry[1], entry[0], this$1); + }, + reverse + ); + return iterations; + }; + + Map.prototype.__ensureOwner = function __ensureOwner (ownerID) { + if (ownerID === this.__ownerID) { + return this; + } + if (!ownerID) { + if (this.size === 0) { + return emptyMap(); + } + this.__ownerID = ownerID; + this.__altered = false; + return this; + } + return makeMap(this.size, this._root, ownerID, this.__hash); + }; + + return Map; +}(KeyedCollection)); + +function isMap(maybeMap) { + return !!(maybeMap && maybeMap[IS_MAP_SENTINEL]); +} + +Map.isMap = isMap; + +var IS_MAP_SENTINEL = '@@__IMMUTABLE_MAP__@@'; + +var MapPrototype = Map.prototype; +MapPrototype[IS_MAP_SENTINEL] = true; +MapPrototype[DELETE] = MapPrototype.remove; +MapPrototype.removeIn = MapPrototype.deleteIn; +MapPrototype.removeAll = MapPrototype.deleteAll; +MapPrototype['@@transducer/init'] = MapPrototype.asMutable; +MapPrototype['@@transducer/step'] = function(result, arr) { + return result.set(arr[0], arr[1]); +}; +MapPrototype['@@transducer/result'] = function(obj) { + return obj.asImmutable(); +}; + +// #pragma Trie Nodes + +var ArrayMapNode = function ArrayMapNode(ownerID, entries) { + this.ownerID = ownerID; + this.entries = entries; +}; + +ArrayMapNode.prototype.get = function get (shift, keyHash, key, notSetValue) { + var entries = this.entries; + for (var ii = 0, len = entries.length; ii < len; ii++) { + if (is(key, entries[ii][0])) { + return entries[ii][1]; + } + } + return notSetValue; +}; + +ArrayMapNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { + var removed = value === NOT_SET; + + var entries = this.entries; + var idx = 0; + var len = entries.length; + for (; idx < len; idx++) { + if (is(key, entries[idx][0])) { + break; + } + } + var exists = idx < len; + + if (exists ? entries[idx][1] === value : removed) { + return this; + } + + SetRef(didAlter); + (removed || !exists) && SetRef(didChangeSize); + + if (removed && entries.length === 1) { + return; // undefined + } + + if (!exists && !removed && entries.length >= MAX_ARRAY_MAP_SIZE) { + return createNodes(ownerID, entries, key, value); + } + + var isEditable = ownerID && ownerID === this.ownerID; + var newEntries = isEditable ? entries : arrCopy(entries); + + if (exists) { + if (removed) { + idx === len - 1 + ? newEntries.pop() + : (newEntries[idx] = newEntries.pop()); + } else { + newEntries[idx] = [key, value]; + } + } else { + newEntries.push([key, value]); + } + + if (isEditable) { + this.entries = newEntries; + return this; + } + + return new ArrayMapNode(ownerID, newEntries); +}; + +var BitmapIndexedNode = function BitmapIndexedNode(ownerID, bitmap, nodes) { + this.ownerID = ownerID; + this.bitmap = bitmap; + this.nodes = nodes; +}; + +BitmapIndexedNode.prototype.get = function get (shift, keyHash, key, notSetValue) { + if (keyHash === undefined) { + keyHash = hash(key); + } + var bit = 1 << ((shift === 0 ? keyHash : keyHash >>> shift) & MASK); + var bitmap = this.bitmap; + return (bitmap & bit) === 0 + ? notSetValue + : this.nodes[popCount(bitmap & bit - 1)].get( + shift + SHIFT, + keyHash, + key, + notSetValue + ); +}; + +BitmapIndexedNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { + if (keyHash === undefined) { + keyHash = hash(key); + } + var keyHashFrag = (shift === 0 ? keyHash : keyHash >>> shift) & MASK; + var bit = 1 << keyHashFrag; + var bitmap = this.bitmap; + var exists = (bitmap & bit) !== 0; + + if (!exists && value === NOT_SET) { + return this; + } + + var idx = popCount(bitmap & bit - 1); + var nodes = this.nodes; + var node = exists ? nodes[idx] : undefined; + var newNode = updateNode( + node, + ownerID, + shift + SHIFT, + keyHash, + key, + value, + didChangeSize, + didAlter + ); + + if (newNode === node) { + return this; + } + + if (!exists && newNode && nodes.length >= MAX_BITMAP_INDEXED_SIZE) { + return expandNodes(ownerID, nodes, bitmap, keyHashFrag, newNode); + } + + if ( + exists && !newNode && nodes.length === 2 && isLeafNode(nodes[idx ^ 1]) + ) { + return nodes[idx ^ 1]; + } + + if (exists && newNode && nodes.length === 1 && isLeafNode(newNode)) { + return newNode; + } + + var isEditable = ownerID && ownerID === this.ownerID; + var newBitmap = exists ? newNode ? bitmap : bitmap ^ bit : bitmap | bit; + var newNodes = exists + ? newNode + ? setIn(nodes, idx, newNode, isEditable) + : spliceOut(nodes, idx, isEditable) + : spliceIn(nodes, idx, newNode, isEditable); + + if (isEditable) { + this.bitmap = newBitmap; + this.nodes = newNodes; + return this; + } + + return new BitmapIndexedNode(ownerID, newBitmap, newNodes); +}; + +var HashArrayMapNode = function HashArrayMapNode(ownerID, count, nodes) { + this.ownerID = ownerID; + this.count = count; + this.nodes = nodes; +}; + +HashArrayMapNode.prototype.get = function get (shift, keyHash, key, notSetValue) { + if (keyHash === undefined) { + keyHash = hash(key); + } + var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK; + var node = this.nodes[idx]; + return node + ? node.get(shift + SHIFT, keyHash, key, notSetValue) + : notSetValue; +}; + +HashArrayMapNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { + if (keyHash === undefined) { + keyHash = hash(key); + } + var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK; + var removed = value === NOT_SET; + var nodes = this.nodes; + var node = nodes[idx]; + + if (removed && !node) { + return this; + } + + var newNode = updateNode( + node, + ownerID, + shift + SHIFT, + keyHash, + key, + value, + didChangeSize, + didAlter + ); + if (newNode === node) { + return this; + } + + var newCount = this.count; + if (!node) { + newCount++; + } else if (!newNode) { + newCount--; + if (newCount < MIN_HASH_ARRAY_MAP_SIZE) { + return packNodes(ownerID, nodes, newCount, idx); + } + } + + var isEditable = ownerID && ownerID === this.ownerID; + var newNodes = setIn(nodes, idx, newNode, isEditable); + + if (isEditable) { + this.count = newCount; + this.nodes = newNodes; + return this; + } + + return new HashArrayMapNode(ownerID, newCount, newNodes); +}; + +var HashCollisionNode = function HashCollisionNode(ownerID, keyHash, entries) { + this.ownerID = ownerID; + this.keyHash = keyHash; + this.entries = entries; +}; + +HashCollisionNode.prototype.get = function get (shift, keyHash, key, notSetValue) { + var entries = this.entries; + for (var ii = 0, len = entries.length; ii < len; ii++) { + if (is(key, entries[ii][0])) { + return entries[ii][1]; + } + } + return notSetValue; +}; + +HashCollisionNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { + if (keyHash === undefined) { + keyHash = hash(key); + } + + var removed = value === NOT_SET; + + if (keyHash !== this.keyHash) { + if (removed) { + return this; + } + SetRef(didAlter); + SetRef(didChangeSize); + return mergeIntoNode(this, ownerID, shift, keyHash, [key, value]); + } + + var entries = this.entries; + var idx = 0; + var len = entries.length; + for (; idx < len; idx++) { + if (is(key, entries[idx][0])) { + break; + } + } + var exists = idx < len; + + if (exists ? entries[idx][1] === value : removed) { + return this; + } + + SetRef(didAlter); + (removed || !exists) && SetRef(didChangeSize); + + if (removed && len === 2) { + return new ValueNode(ownerID, this.keyHash, entries[idx ^ 1]); + } + + var isEditable = ownerID && ownerID === this.ownerID; + var newEntries = isEditable ? entries : arrCopy(entries); + + if (exists) { + if (removed) { + idx === len - 1 + ? newEntries.pop() + : (newEntries[idx] = newEntries.pop()); + } else { + newEntries[idx] = [key, value]; + } + } else { + newEntries.push([key, value]); + } + + if (isEditable) { + this.entries = newEntries; + return this; + } + + return new HashCollisionNode(ownerID, this.keyHash, newEntries); +}; + +var ValueNode = function ValueNode(ownerID, keyHash, entry) { + this.ownerID = ownerID; + this.keyHash = keyHash; + this.entry = entry; +}; + +ValueNode.prototype.get = function get (shift, keyHash, key, notSetValue) { + return is(key, this.entry[0]) ? this.entry[1] : notSetValue; +}; + +ValueNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { + var removed = value === NOT_SET; + var keyMatch = is(key, this.entry[0]); + if (keyMatch ? value === this.entry[1] : removed) { + return this; + } + + SetRef(didAlter); + + if (removed) { + SetRef(didChangeSize); + return; // undefined + } + + if (keyMatch) { + if (ownerID && ownerID === this.ownerID) { + this.entry[1] = value; + return this; + } + return new ValueNode(ownerID, this.keyHash, [key, value]); + } + + SetRef(didChangeSize); + return mergeIntoNode(this, ownerID, shift, hash(key), [key, value]); +}; + +// #pragma Iterators + +ArrayMapNode.prototype.iterate = (HashCollisionNode.prototype.iterate = function( + fn, + reverse +) { + var entries = this.entries; + for (var ii = 0, maxIndex = entries.length - 1; ii <= maxIndex; ii++) { + if (fn(entries[reverse ? maxIndex - ii : ii]) === false) { + return false; + } + } +}); + +BitmapIndexedNode.prototype.iterate = (HashArrayMapNode.prototype.iterate = function( + fn, + reverse +) { + var nodes = this.nodes; + for (var ii = 0, maxIndex = nodes.length - 1; ii <= maxIndex; ii++) { + var node = nodes[reverse ? maxIndex - ii : ii]; + if (node && node.iterate(fn, reverse) === false) { + return false; + } + } +}); + +// eslint-disable-next-line no-unused-vars +ValueNode.prototype.iterate = function(fn, reverse) { + return fn(this.entry); +}; + +var MapIterator = (function (Iterator$$1) { + function MapIterator(map, type, reverse) { + this._type = type; + this._reverse = reverse; + this._stack = map._root && mapIteratorFrame(map._root); + } + + if ( Iterator$$1 ) MapIterator.__proto__ = Iterator$$1; + MapIterator.prototype = Object.create( Iterator$$1 && Iterator$$1.prototype ); + MapIterator.prototype.constructor = MapIterator; + + MapIterator.prototype.next = function next () { + var this$1 = this; + + var type = this._type; + var stack = this._stack; + while (stack) { + var node = stack.node; + var index = stack.index++; + var maxIndex = (void 0); + if (node.entry) { + if (index === 0) { + return mapIteratorValue(type, node.entry); + } + } else if (node.entries) { + maxIndex = node.entries.length - 1; + if (index <= maxIndex) { + return mapIteratorValue( + type, + node.entries[this$1._reverse ? maxIndex - index : index] + ); + } + } else { + maxIndex = node.nodes.length - 1; + if (index <= maxIndex) { + var subNode = node.nodes[this$1._reverse ? maxIndex - index : index]; + if (subNode) { + if (subNode.entry) { + return mapIteratorValue(type, subNode.entry); + } + stack = (this$1._stack = mapIteratorFrame(subNode, stack)); + } + continue; + } + } + stack = (this$1._stack = this$1._stack.__prev); + } + return iteratorDone(); + }; + + return MapIterator; +}(Iterator)); + +function mapIteratorValue(type, entry) { + return iteratorValue(type, entry[0], entry[1]); +} + +function mapIteratorFrame(node, prev) { + return { + node: node, + index: 0, + __prev: prev + }; +} + +function makeMap(size, root, ownerID, hash$$1) { + var map = Object.create(MapPrototype); + map.size = size; + map._root = root; + map.__ownerID = ownerID; + map.__hash = hash$$1; + map.__altered = false; + return map; +} + +var EMPTY_MAP; +function emptyMap() { + return EMPTY_MAP || (EMPTY_MAP = makeMap(0)); +} + +function updateMap(map, k, v) { + var newRoot; + var newSize; + if (!map._root) { + if (v === NOT_SET) { + return map; + } + newSize = 1; + newRoot = new ArrayMapNode(map.__ownerID, [[k, v]]); + } else { + var didChangeSize = MakeRef(CHANGE_LENGTH); + var didAlter = MakeRef(DID_ALTER); + newRoot = updateNode( + map._root, + map.__ownerID, + 0, + undefined, + k, + v, + didChangeSize, + didAlter + ); + if (!didAlter.value) { + return map; + } + newSize = map.size + (didChangeSize.value ? v === NOT_SET ? -1 : 1 : 0); + } + if (map.__ownerID) { + map.size = newSize; + map._root = newRoot; + map.__hash = undefined; + map.__altered = true; + return map; + } + return newRoot ? makeMap(newSize, newRoot) : emptyMap(); +} + +function updateNode( + node, + ownerID, + shift, + keyHash, + key, + value, + didChangeSize, + didAlter +) { + if (!node) { + if (value === NOT_SET) { + return node; + } + SetRef(didAlter); + SetRef(didChangeSize); + return new ValueNode(ownerID, keyHash, [key, value]); + } + return node.update( + ownerID, + shift, + keyHash, + key, + value, + didChangeSize, + didAlter + ); +} + +function isLeafNode(node) { + return node.constructor === ValueNode || + node.constructor === HashCollisionNode; +} + +function mergeIntoNode(node, ownerID, shift, keyHash, entry) { + if (node.keyHash === keyHash) { + return new HashCollisionNode(ownerID, keyHash, [node.entry, entry]); + } + + var idx1 = (shift === 0 ? node.keyHash : node.keyHash >>> shift) & MASK; + var idx2 = (shift === 0 ? keyHash : keyHash >>> shift) & MASK; + + var newNode; + var nodes = idx1 === idx2 + ? [mergeIntoNode(node, ownerID, shift + SHIFT, keyHash, entry)] + : ((newNode = new ValueNode(ownerID, keyHash, entry)), idx1 < idx2 + ? [node, newNode] + : [newNode, node]); + + return new BitmapIndexedNode(ownerID, 1 << idx1 | 1 << idx2, nodes); +} + +function createNodes(ownerID, entries, key, value) { + if (!ownerID) { + ownerID = new OwnerID(); + } + var node = new ValueNode(ownerID, hash(key), [key, value]); + for (var ii = 0; ii < entries.length; ii++) { + var entry = entries[ii]; + node = node.update(ownerID, 0, undefined, entry[0], entry[1]); + } + return node; +} + +function packNodes(ownerID, nodes, count, excluding) { + var bitmap = 0; + var packedII = 0; + var packedNodes = new Array(count); + for (var ii = 0, bit = 1, len = nodes.length; ii < len; ii++, (bit <<= 1)) { + var node = nodes[ii]; + if (node !== undefined && ii !== excluding) { + bitmap |= bit; + packedNodes[packedII++] = node; + } + } + return new BitmapIndexedNode(ownerID, bitmap, packedNodes); +} + +function expandNodes(ownerID, nodes, bitmap, including, node) { + var count = 0; + var expandedNodes = new Array(SIZE); + for (var ii = 0; bitmap !== 0; ii++, (bitmap >>>= 1)) { + expandedNodes[ii] = bitmap & 1 ? nodes[count++] : undefined; + } + expandedNodes[including] = node; + return new HashArrayMapNode(ownerID, count + 1, expandedNodes); +} + +function mergeIntoMapWith(map, merger, collections) { + var iters = []; + for (var ii = 0; ii < collections.length; ii++) { + var value = collections[ii]; + var iter = KeyedCollection(value); + if (!isCollection(value)) { + iter = iter.map(function (v) { return fromJS(v); }); + } + iters.push(iter); + } + return mergeIntoCollectionWith(map, merger, iters); +} + +function deepMerger(oldVal, newVal) { + return oldVal && oldVal.mergeDeep && isCollection(newVal) + ? oldVal.mergeDeep(newVal) + : is(oldVal, newVal) ? oldVal : newVal; +} + +function deepMergerWith(merger) { + return function (oldVal, newVal, key) { + if (oldVal && oldVal.mergeDeepWith && isCollection(newVal)) { + return oldVal.mergeDeepWith(merger, newVal); + } + var nextValue = merger(oldVal, newVal, key); + return is(oldVal, nextValue) ? oldVal : nextValue; + }; +} + +function mergeIntoCollectionWith(collection, merger, iters) { + iters = iters.filter(function (x) { return x.size !== 0; }); + if (iters.length === 0) { + return collection; + } + if (collection.size === 0 && !collection.__ownerID && iters.length === 1) { + return collection.constructor(iters[0]); + } + return collection.withMutations(function (collection) { + var mergeIntoMap = merger + ? function (value, key) { + collection.update( + key, + NOT_SET, + function (oldVal) { return oldVal === NOT_SET ? value : merger(oldVal, value, key); } + ); + } + : function (value, key) { + collection.set(key, value); + }; + for (var ii = 0; ii < iters.length; ii++) { + iters[ii].forEach(mergeIntoMap); + } + }); +} + +function updateInDeepMap(existing, keyPath, i, notSetValue, updater) { + var isNotSet = existing === NOT_SET; + if (i === keyPath.length) { + var existingValue = isNotSet ? notSetValue : existing; + var newValue = updater(existingValue); + return newValue === existingValue ? existing : newValue; + } + if (!(isNotSet || (existing && existing.set))) { + throw new TypeError( + 'Invalid keyPath: Value at [' + + keyPath.slice(0, i).map(quoteString) + + '] does not have a .set() method and cannot be updated: ' + + existing + ); + } + var key = keyPath[i]; + var nextExisting = isNotSet ? NOT_SET : existing.get(key, NOT_SET); + var nextUpdated = updateInDeepMap( + nextExisting, + keyPath, + i + 1, + notSetValue, + updater + ); + return nextUpdated === nextExisting + ? existing + : nextUpdated === NOT_SET + ? existing.remove(key) + : (isNotSet ? emptyMap() : existing).set(key, nextUpdated); +} + +function popCount(x) { + x -= x >> 1 & 0x55555555; + x = (x & 0x33333333) + (x >> 2 & 0x33333333); + x = x + (x >> 4) & 0x0f0f0f0f; + x += x >> 8; + x += x >> 16; + return x & 0x7f; +} + +function setIn(array, idx, val, canEdit) { + var newArray = canEdit ? array : arrCopy(array); + newArray[idx] = val; + return newArray; +} + +function spliceIn(array, idx, val, canEdit) { + var newLen = array.length + 1; + if (canEdit && idx + 1 === newLen) { + array[idx] = val; + return array; + } + var newArray = new Array(newLen); + var after = 0; + for (var ii = 0; ii < newLen; ii++) { + if (ii === idx) { + newArray[ii] = val; + after = -1; + } else { + newArray[ii] = array[ii + after]; + } + } + return newArray; +} + +function spliceOut(array, idx, canEdit) { + var newLen = array.length - 1; + if (canEdit && idx === newLen) { + array.pop(); + return array; + } + var newArray = new Array(newLen); + var after = 0; + for (var ii = 0; ii < newLen; ii++) { + if (ii === idx) { + after = 1; + } + newArray[ii] = array[ii + after]; + } + return newArray; +} + +var MAX_ARRAY_MAP_SIZE = SIZE / 4; +var MAX_BITMAP_INDEXED_SIZE = SIZE / 2; +var MIN_HASH_ARRAY_MAP_SIZE = SIZE / 4; + +var List = (function (IndexedCollection$$1) { + function List(value) { + var empty = emptyList(); + if (value === null || value === undefined) { + return empty; + } + if (isList(value)) { + return value; + } + var iter = IndexedCollection$$1(value); + var size = iter.size; + if (size === 0) { + return empty; + } + assertNotInfinite(size); + if (size > 0 && size < SIZE) { + return makeList(0, size, SHIFT, null, new VNode(iter.toArray())); + } + return empty.withMutations(function (list) { + list.setSize(size); + iter.forEach(function (v, i) { return list.set(i, v); }); + }); + } + + if ( IndexedCollection$$1 ) List.__proto__ = IndexedCollection$$1; + List.prototype = Object.create( IndexedCollection$$1 && IndexedCollection$$1.prototype ); + List.prototype.constructor = List; + + List.of = function of (/*...values*/) { + return this(arguments); + }; + + List.prototype.toString = function toString () { + return this.__toString('List [', ']'); + }; + + // @pragma Access + + List.prototype.get = function get (index, notSetValue) { + index = wrapIndex(this, index); + if (index >= 0 && index < this.size) { + index += this._origin; + var node = listNodeFor(this, index); + return node && node.array[index & MASK]; + } + return notSetValue; + }; + + // @pragma Modification + + List.prototype.set = function set (index, value) { + return updateList(this, index, value); + }; + + List.prototype.remove = function remove (index) { + return !this.has(index) + ? this + : index === 0 + ? this.shift() + : index === this.size - 1 ? this.pop() : this.splice(index, 1); + }; + + List.prototype.insert = function insert (index, value) { + return this.splice(index, 0, value); + }; + + List.prototype.clear = function clear () { + if (this.size === 0) { + return this; + } + if (this.__ownerID) { + this.size = (this._origin = (this._capacity = 0)); + this._level = SHIFT; + this._root = (this._tail = null); + this.__hash = undefined; + this.__altered = true; + return this; + } + return emptyList(); + }; + + List.prototype.push = function push (/*...values*/) { + var values = arguments; + var oldSize = this.size; + return this.withMutations(function (list) { + setListBounds(list, 0, oldSize + values.length); + for (var ii = 0; ii < values.length; ii++) { + list.set(oldSize + ii, values[ii]); + } + }); + }; + + List.prototype.pop = function pop () { + return setListBounds(this, 0, -1); + }; + + List.prototype.unshift = function unshift (/*...values*/) { + var values = arguments; + return this.withMutations(function (list) { + setListBounds(list, -values.length); + for (var ii = 0; ii < values.length; ii++) { + list.set(ii, values[ii]); + } + }); + }; + + List.prototype.shift = function shift () { + return setListBounds(this, 1); + }; + + // @pragma Composition + + List.prototype.merge = function merge (/*...iters*/) { + return mergeIntoListWith(this, undefined, arguments); + }; + + List.prototype.mergeWith = function mergeWith (merger) { + var iters = [], len = arguments.length - 1; + while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; + + return mergeIntoListWith(this, merger, iters); + }; + + List.prototype.mergeDeep = function mergeDeep (/*...iters*/) { + return mergeIntoListWith(this, deepMerger, arguments); + }; + + List.prototype.mergeDeepWith = function mergeDeepWith (merger) { + var iters = [], len = arguments.length - 1; + while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; + + return mergeIntoListWith(this, deepMergerWith(merger), iters); + }; + + List.prototype.setSize = function setSize (size) { + return setListBounds(this, 0, size); + }; + + // @pragma Iteration + + List.prototype.slice = function slice (begin, end) { + var size = this.size; + if (wholeSlice(begin, end, size)) { + return this; + } + return setListBounds( + this, + resolveBegin(begin, size), + resolveEnd(end, size) + ); + }; + + List.prototype.__iterator = function __iterator (type, reverse) { + var index = reverse ? this.size : 0; + var values = iterateList(this, reverse); + return new Iterator(function () { + var value = values(); + return value === DONE + ? iteratorDone() + : iteratorValue(type, reverse ? --index : index++, value); + }); + }; + + List.prototype.__iterate = function __iterate (fn, reverse) { + var this$1 = this; + + var index = reverse ? this.size : 0; + var values = iterateList(this, reverse); + var value; + while ((value = values()) !== DONE) { + if (fn(value, reverse ? --index : index++, this$1) === false) { + break; + } + } + return index; + }; + + List.prototype.__ensureOwner = function __ensureOwner (ownerID) { + if (ownerID === this.__ownerID) { + return this; + } + if (!ownerID) { + if (this.size === 0) { + return emptyList(); + } + this.__ownerID = ownerID; + return this; + } + return makeList( + this._origin, + this._capacity, + this._level, + this._root, + this._tail, + ownerID, + this.__hash + ); + }; + + return List; +}(IndexedCollection)); + +function isList(maybeList) { + return !!(maybeList && maybeList[IS_LIST_SENTINEL]); +} + +List.isList = isList; + +var IS_LIST_SENTINEL = '@@__IMMUTABLE_LIST__@@'; + +var ListPrototype = List.prototype; +ListPrototype[IS_LIST_SENTINEL] = true; +ListPrototype[DELETE] = ListPrototype.remove; +ListPrototype.setIn = MapPrototype.setIn; +ListPrototype.deleteIn = (ListPrototype.removeIn = MapPrototype.removeIn); +ListPrototype.update = MapPrototype.update; +ListPrototype.updateIn = MapPrototype.updateIn; +ListPrototype.mergeIn = MapPrototype.mergeIn; +ListPrototype.mergeDeepIn = MapPrototype.mergeDeepIn; +ListPrototype.withMutations = MapPrototype.withMutations; +ListPrototype.asMutable = MapPrototype.asMutable; +ListPrototype.asImmutable = MapPrototype.asImmutable; +ListPrototype.wasAltered = MapPrototype.wasAltered; +ListPrototype['@@transducer/init'] = ListPrototype.asMutable; +ListPrototype['@@transducer/step'] = function(result, arr) { + return result.push(arr); +}; +ListPrototype['@@transducer/result'] = MapPrototype['@@transducer/result']; + +var VNode = function VNode(array, ownerID) { + this.array = array; + this.ownerID = ownerID; +}; + +// TODO: seems like these methods are very similar + +VNode.prototype.removeBefore = function removeBefore (ownerID, level, index) { + if (index === level ? 1 << level : 0 || this.array.length === 0) { + return this; + } + var originIndex = index >>> level & MASK; + if (originIndex >= this.array.length) { + return new VNode([], ownerID); + } + var removingFirst = originIndex === 0; + var newChild; + if (level > 0) { + var oldChild = this.array[originIndex]; + newChild = oldChild && + oldChild.removeBefore(ownerID, level - SHIFT, index); + if (newChild === oldChild && removingFirst) { + return this; + } + } + if (removingFirst && !newChild) { + return this; + } + var editable = editableVNode(this, ownerID); + if (!removingFirst) { + for (var ii = 0; ii < originIndex; ii++) { + editable.array[ii] = undefined; + } + } + if (newChild) { + editable.array[originIndex] = newChild; + } + return editable; +}; + +VNode.prototype.removeAfter = function removeAfter (ownerID, level, index) { + if (index === (level ? 1 << level : 0) || this.array.length === 0) { + return this; + } + var sizeIndex = index - 1 >>> level & MASK; + if (sizeIndex >= this.array.length) { + return this; + } + + var newChild; + if (level > 0) { + var oldChild = this.array[sizeIndex]; + newChild = oldChild && + oldChild.removeAfter(ownerID, level - SHIFT, index); + if (newChild === oldChild && sizeIndex === this.array.length - 1) { + return this; + } + } + + var editable = editableVNode(this, ownerID); + editable.array.splice(sizeIndex + 1); + if (newChild) { + editable.array[sizeIndex] = newChild; + } + return editable; +}; + +var DONE = {}; + +function iterateList(list, reverse) { + var left = list._origin; + var right = list._capacity; + var tailPos = getTailOffset(right); + var tail = list._tail; + + return iterateNodeOrLeaf(list._root, list._level, 0); + + function iterateNodeOrLeaf(node, level, offset) { + return level === 0 + ? iterateLeaf(node, offset) + : iterateNode(node, level, offset); + } + + function iterateLeaf(node, offset) { + var array = offset === tailPos ? tail && tail.array : node && node.array; + var from = offset > left ? 0 : left - offset; + var to = right - offset; + if (to > SIZE) { + to = SIZE; + } + return function () { + if (from === to) { + return DONE; + } + var idx = reverse ? --to : from++; + return array && array[idx]; + }; + } + + function iterateNode(node, level, offset) { + var values; + var array = node && node.array; + var from = offset > left ? 0 : left - offset >> level; + var to = (right - offset >> level) + 1; + if (to > SIZE) { + to = SIZE; + } + return function () { + while (true) { + if (values) { + var value = values(); + if (value !== DONE) { + return value; + } + values = null; + } + if (from === to) { + return DONE; + } + var idx = reverse ? --to : from++; + values = iterateNodeOrLeaf( + array && array[idx], + level - SHIFT, + offset + (idx << level) + ); + } + }; + } +} + +function makeList(origin, capacity, level, root, tail, ownerID, hash) { + var list = Object.create(ListPrototype); + list.size = capacity - origin; + list._origin = origin; + list._capacity = capacity; + list._level = level; + list._root = root; + list._tail = tail; + list.__ownerID = ownerID; + list.__hash = hash; + list.__altered = false; + return list; +} + +var EMPTY_LIST; +function emptyList() { + return EMPTY_LIST || (EMPTY_LIST = makeList(0, 0, SHIFT)); +} + +function updateList(list, index, value) { + index = wrapIndex(list, index); + + if (index !== index) { + return list; + } + + if (index >= list.size || index < 0) { + return list.withMutations(function (list) { + index < 0 + ? setListBounds(list, index).set(0, value) + : setListBounds(list, 0, index + 1).set(index, value); + }); + } + + index += list._origin; + + var newTail = list._tail; + var newRoot = list._root; + var didAlter = MakeRef(DID_ALTER); + if (index >= getTailOffset(list._capacity)) { + newTail = updateVNode(newTail, list.__ownerID, 0, index, value, didAlter); + } else { + newRoot = updateVNode( + newRoot, + list.__ownerID, + list._level, + index, + value, + didAlter + ); + } + + if (!didAlter.value) { + return list; + } + + if (list.__ownerID) { + list._root = newRoot; + list._tail = newTail; + list.__hash = undefined; + list.__altered = true; + return list; + } + return makeList(list._origin, list._capacity, list._level, newRoot, newTail); +} + +function updateVNode(node, ownerID, level, index, value, didAlter) { + var idx = index >>> level & MASK; + var nodeHas = node && idx < node.array.length; + if (!nodeHas && value === undefined) { + return node; + } + + var newNode; + + if (level > 0) { + var lowerNode = node && node.array[idx]; + var newLowerNode = updateVNode( + lowerNode, + ownerID, + level - SHIFT, + index, + value, + didAlter + ); + if (newLowerNode === lowerNode) { + return node; + } + newNode = editableVNode(node, ownerID); + newNode.array[idx] = newLowerNode; + return newNode; + } + + if (nodeHas && node.array[idx] === value) { + return node; + } + + SetRef(didAlter); + + newNode = editableVNode(node, ownerID); + if (value === undefined && idx === newNode.array.length - 1) { + newNode.array.pop(); + } else { + newNode.array[idx] = value; + } + return newNode; +} + +function editableVNode(node, ownerID) { + if (ownerID && node && ownerID === node.ownerID) { + return node; + } + return new VNode(node ? node.array.slice() : [], ownerID); +} + +function listNodeFor(list, rawIndex) { + if (rawIndex >= getTailOffset(list._capacity)) { + return list._tail; + } + if (rawIndex < 1 << list._level + SHIFT) { + var node = list._root; + var level = list._level; + while (node && level > 0) { + node = node.array[rawIndex >>> level & MASK]; + level -= SHIFT; + } + return node; + } +} + +function setListBounds(list, begin, end) { + // Sanitize begin & end using this shorthand for ToInt32(argument) + // http://www.ecma-international.org/ecma-262/6.0/#sec-toint32 + if (begin !== undefined) { + begin |= 0; + } + if (end !== undefined) { + end |= 0; + } + var owner = list.__ownerID || new OwnerID(); + var oldOrigin = list._origin; + var oldCapacity = list._capacity; + var newOrigin = oldOrigin + begin; + var newCapacity = end === undefined + ? oldCapacity + : end < 0 ? oldCapacity + end : oldOrigin + end; + if (newOrigin === oldOrigin && newCapacity === oldCapacity) { + return list; + } + + // If it's going to end after it starts, it's empty. + if (newOrigin >= newCapacity) { + return list.clear(); + } + + var newLevel = list._level; + var newRoot = list._root; + + // New origin might need creating a higher root. + var offsetShift = 0; + while (newOrigin + offsetShift < 0) { + newRoot = new VNode( + newRoot && newRoot.array.length ? [undefined, newRoot] : [], + owner + ); + newLevel += SHIFT; + offsetShift += 1 << newLevel; + } + if (offsetShift) { + newOrigin += offsetShift; + oldOrigin += offsetShift; + newCapacity += offsetShift; + oldCapacity += offsetShift; + } + + var oldTailOffset = getTailOffset(oldCapacity); + var newTailOffset = getTailOffset(newCapacity); + + // New size might need creating a higher root. + while (newTailOffset >= 1 << newLevel + SHIFT) { + newRoot = new VNode( + newRoot && newRoot.array.length ? [newRoot] : [], + owner + ); + newLevel += SHIFT; + } + + // Locate or create the new tail. + var oldTail = list._tail; + var newTail = newTailOffset < oldTailOffset + ? listNodeFor(list, newCapacity - 1) + : newTailOffset > oldTailOffset ? new VNode([], owner) : oldTail; + + // Merge Tail into tree. + if ( + oldTail && + newTailOffset > oldTailOffset && + newOrigin < oldCapacity && + oldTail.array.length + ) { + newRoot = editableVNode(newRoot, owner); + var node = newRoot; + for (var level = newLevel; level > SHIFT; level -= SHIFT) { + var idx = oldTailOffset >>> level & MASK; + node = (node.array[idx] = editableVNode(node.array[idx], owner)); + } + node.array[oldTailOffset >>> SHIFT & MASK] = oldTail; + } + + // If the size has been reduced, there's a chance the tail needs to be trimmed. + if (newCapacity < oldCapacity) { + newTail = newTail && newTail.removeAfter(owner, 0, newCapacity); + } + + // If the new origin is within the tail, then we do not need a root. + if (newOrigin >= newTailOffset) { + newOrigin -= newTailOffset; + newCapacity -= newTailOffset; + newLevel = SHIFT; + newRoot = null; + newTail = newTail && newTail.removeBefore(owner, 0, newOrigin); + + // Otherwise, if the root has been trimmed, garbage collect. + } else if (newOrigin > oldOrigin || newTailOffset < oldTailOffset) { + offsetShift = 0; + + // Identify the new top root node of the subtree of the old root. + while (newRoot) { + var beginIndex = newOrigin >>> newLevel & MASK; + if (beginIndex !== newTailOffset >>> newLevel & MASK) { + break; + } + if (beginIndex) { + offsetShift += (1 << newLevel) * beginIndex; + } + newLevel -= SHIFT; + newRoot = newRoot.array[beginIndex]; + } + + // Trim the new sides of the new root. + if (newRoot && newOrigin > oldOrigin) { + newRoot = newRoot.removeBefore(owner, newLevel, newOrigin - offsetShift); + } + if (newRoot && newTailOffset < oldTailOffset) { + newRoot = newRoot.removeAfter( + owner, + newLevel, + newTailOffset - offsetShift + ); + } + if (offsetShift) { + newOrigin -= offsetShift; + newCapacity -= offsetShift; + } + } + + if (list.__ownerID) { + list.size = newCapacity - newOrigin; + list._origin = newOrigin; + list._capacity = newCapacity; + list._level = newLevel; + list._root = newRoot; + list._tail = newTail; + list.__hash = undefined; + list.__altered = true; + return list; + } + return makeList(newOrigin, newCapacity, newLevel, newRoot, newTail); +} + +function mergeIntoListWith(list, merger, collections) { + var iters = []; + var maxSize = 0; + for (var ii = 0; ii < collections.length; ii++) { + var value = collections[ii]; + var iter = IndexedCollection(value); + if (iter.size > maxSize) { + maxSize = iter.size; + } + if (!isCollection(value)) { + iter = iter.map(function (v) { return fromJS(v); }); + } + iters.push(iter); + } + if (maxSize > list.size) { + list = list.setSize(maxSize); + } + return mergeIntoCollectionWith(list, merger, iters); +} + +function getTailOffset(size) { + return size < SIZE ? 0 : size - 1 >>> SHIFT << SHIFT; +} + +var OrderedMap = (function (Map$$1) { + function OrderedMap(value) { + return value === null || value === undefined + ? emptyOrderedMap() + : isOrderedMap(value) + ? value + : emptyOrderedMap().withMutations(function (map) { + var iter = KeyedCollection(value); + assertNotInfinite(iter.size); + iter.forEach(function (v, k) { return map.set(k, v); }); + }); + } + + if ( Map$$1 ) OrderedMap.__proto__ = Map$$1; + OrderedMap.prototype = Object.create( Map$$1 && Map$$1.prototype ); + OrderedMap.prototype.constructor = OrderedMap; + + OrderedMap.of = function of (/*...values*/) { + return this(arguments); + }; + + OrderedMap.prototype.toString = function toString () { + return this.__toString('OrderedMap {', '}'); + }; + + // @pragma Access + + OrderedMap.prototype.get = function get (k, notSetValue) { + var index = this._map.get(k); + return index !== undefined ? this._list.get(index)[1] : notSetValue; + }; + + // @pragma Modification + + OrderedMap.prototype.clear = function clear () { + if (this.size === 0) { + return this; + } + if (this.__ownerID) { + this.size = 0; + this._map.clear(); + this._list.clear(); + return this; + } + return emptyOrderedMap(); + }; + + OrderedMap.prototype.set = function set (k, v) { + return updateOrderedMap(this, k, v); + }; + + OrderedMap.prototype.remove = function remove (k) { + return updateOrderedMap(this, k, NOT_SET); + }; + + OrderedMap.prototype.wasAltered = function wasAltered () { + return this._map.wasAltered() || this._list.wasAltered(); + }; + + OrderedMap.prototype.__iterate = function __iterate (fn, reverse) { + var this$1 = this; + + return this._list.__iterate( + function (entry) { return entry && fn(entry[1], entry[0], this$1); }, + reverse + ); + }; + + OrderedMap.prototype.__iterator = function __iterator (type, reverse) { + return this._list.fromEntrySeq().__iterator(type, reverse); + }; + + OrderedMap.prototype.__ensureOwner = function __ensureOwner (ownerID) { + if (ownerID === this.__ownerID) { + return this; + } + var newMap = this._map.__ensureOwner(ownerID); + var newList = this._list.__ensureOwner(ownerID); + if (!ownerID) { + if (this.size === 0) { + return emptyOrderedMap(); + } + this.__ownerID = ownerID; + this._map = newMap; + this._list = newList; + return this; + } + return makeOrderedMap(newMap, newList, ownerID, this.__hash); + }; + + return OrderedMap; +}(Map)); + +function isOrderedMap(maybeOrderedMap) { + return isMap(maybeOrderedMap) && isOrdered(maybeOrderedMap); +} + +OrderedMap.isOrderedMap = isOrderedMap; + +OrderedMap.prototype[IS_ORDERED_SENTINEL] = true; +OrderedMap.prototype[DELETE] = OrderedMap.prototype.remove; + +function makeOrderedMap(map, list, ownerID, hash) { + var omap = Object.create(OrderedMap.prototype); + omap.size = map ? map.size : 0; + omap._map = map; + omap._list = list; + omap.__ownerID = ownerID; + omap.__hash = hash; + return omap; +} + +var EMPTY_ORDERED_MAP; +function emptyOrderedMap() { + return EMPTY_ORDERED_MAP || + (EMPTY_ORDERED_MAP = makeOrderedMap(emptyMap(), emptyList())); +} + +function updateOrderedMap(omap, k, v) { + var map = omap._map; + var list = omap._list; + var i = map.get(k); + var has = i !== undefined; + var newMap; + var newList; + if (v === NOT_SET) { + // removed + if (!has) { + return omap; + } + if (list.size >= SIZE && list.size >= map.size * 2) { + newList = list.filter(function (entry, idx) { return entry !== undefined && i !== idx; }); + newMap = newList.toKeyedSeq().map(function (entry) { return entry[0]; }).flip().toMap(); + if (omap.__ownerID) { + newMap.__ownerID = (newList.__ownerID = omap.__ownerID); + } + } else { + newMap = map.remove(k); + newList = i === list.size - 1 ? list.pop() : list.set(i, undefined); + } + } else if (has) { + if (v === list.get(i)[1]) { + return omap; + } + newMap = map; + newList = list.set(i, [k, v]); + } else { + newMap = map.set(k, list.size); + newList = list.set(list.size, [k, v]); + } + if (omap.__ownerID) { + omap.size = newMap.size; + omap._map = newMap; + omap._list = newList; + omap.__hash = undefined; + return omap; + } + return makeOrderedMap(newMap, newList); +} + +var Stack = (function (IndexedCollection$$1) { + function Stack(value) { + return value === null || value === undefined + ? emptyStack() + : isStack(value) ? value : emptyStack().pushAll(value); + } + + if ( IndexedCollection$$1 ) Stack.__proto__ = IndexedCollection$$1; + Stack.prototype = Object.create( IndexedCollection$$1 && IndexedCollection$$1.prototype ); + Stack.prototype.constructor = Stack; + + Stack.of = function of (/*...values*/) { + return this(arguments); + }; + + Stack.prototype.toString = function toString () { + return this.__toString('Stack [', ']'); + }; + + // @pragma Access + + Stack.prototype.get = function get (index, notSetValue) { + var head = this._head; + index = wrapIndex(this, index); + while (head && index--) { + head = head.next; + } + return head ? head.value : notSetValue; + }; + + Stack.prototype.peek = function peek () { + return this._head && this._head.value; + }; + + // @pragma Modification + + Stack.prototype.push = function push (/*...values*/) { + var arguments$1 = arguments; + + if (arguments.length === 0) { + return this; + } + var newSize = this.size + arguments.length; + var head = this._head; + for (var ii = arguments.length - 1; ii >= 0; ii--) { + head = { + value: arguments$1[ii], + next: head + }; + } + if (this.__ownerID) { + this.size = newSize; + this._head = head; + this.__hash = undefined; + this.__altered = true; + return this; + } + return makeStack(newSize, head); + }; + + Stack.prototype.pushAll = function pushAll (iter) { + iter = IndexedCollection$$1(iter); + if (iter.size === 0) { + return this; + } + if (this.size === 0 && isStack(iter)) { + return iter; + } + assertNotInfinite(iter.size); + var newSize = this.size; + var head = this._head; + iter.__iterate( + function (value) { + newSize++; + head = { + value: value, + next: head + }; + }, + /* reverse */ true + ); + if (this.__ownerID) { + this.size = newSize; + this._head = head; + this.__hash = undefined; + this.__altered = true; + return this; + } + return makeStack(newSize, head); + }; + + Stack.prototype.pop = function pop () { + return this.slice(1); + }; + + Stack.prototype.clear = function clear () { + if (this.size === 0) { + return this; + } + if (this.__ownerID) { + this.size = 0; + this._head = undefined; + this.__hash = undefined; + this.__altered = true; + return this; + } + return emptyStack(); + }; + + Stack.prototype.slice = function slice (begin, end) { + if (wholeSlice(begin, end, this.size)) { + return this; + } + var resolvedBegin = resolveBegin(begin, this.size); + var resolvedEnd = resolveEnd(end, this.size); + if (resolvedEnd !== this.size) { + // super.slice(begin, end); + return IndexedCollection$$1.prototype.slice.call(this, begin, end); + } + var newSize = this.size - resolvedBegin; + var head = this._head; + while (resolvedBegin--) { + head = head.next; + } + if (this.__ownerID) { + this.size = newSize; + this._head = head; + this.__hash = undefined; + this.__altered = true; + return this; + } + return makeStack(newSize, head); + }; + + // @pragma Mutability + + Stack.prototype.__ensureOwner = function __ensureOwner (ownerID) { + if (ownerID === this.__ownerID) { + return this; + } + if (!ownerID) { + if (this.size === 0) { + return emptyStack(); + } + this.__ownerID = ownerID; + this.__altered = false; + return this; + } + return makeStack(this.size, this._head, ownerID, this.__hash); + }; + + // @pragma Iteration + + Stack.prototype.__iterate = function __iterate (fn, reverse) { + var this$1 = this; + + if (reverse) { + return new ArraySeq(this.toArray()).__iterate( + function (v, k) { return fn(v, k, this$1); }, + reverse + ); + } + var iterations = 0; + var node = this._head; + while (node) { + if (fn(node.value, iterations++, this$1) === false) { + break; + } + node = node.next; + } + return iterations; + }; + + Stack.prototype.__iterator = function __iterator (type, reverse) { + if (reverse) { + return new ArraySeq(this.toArray()).__iterator(type, reverse); + } + var iterations = 0; + var node = this._head; + return new Iterator(function () { + if (node) { + var value = node.value; + node = node.next; + return iteratorValue(type, iterations++, value); + } + return iteratorDone(); + }); + }; + + return Stack; +}(IndexedCollection)); + +function isStack(maybeStack) { + return !!(maybeStack && maybeStack[IS_STACK_SENTINEL]); +} + +Stack.isStack = isStack; + +var IS_STACK_SENTINEL = '@@__IMMUTABLE_STACK__@@'; + +var StackPrototype = Stack.prototype; +StackPrototype[IS_STACK_SENTINEL] = true; +StackPrototype.withMutations = MapPrototype.withMutations; +StackPrototype.asMutable = MapPrototype.asMutable; +StackPrototype.asImmutable = MapPrototype.asImmutable; +StackPrototype.wasAltered = MapPrototype.wasAltered; +StackPrototype.shift = StackPrototype.pop; +StackPrototype.unshift = StackPrototype.push; +StackPrototype.unshiftAll = StackPrototype.pushAll; +StackPrototype['@@transducer/init'] = StackPrototype.asMutable; +StackPrototype['@@transducer/step'] = function(result, arr) { + return result.unshift(arr); +}; +StackPrototype['@@transducer/result'] = MapPrototype['@@transducer/result']; + +function makeStack(size, head, ownerID, hash) { + var map = Object.create(StackPrototype); + map.size = size; + map._head = head; + map.__ownerID = ownerID; + map.__hash = hash; + map.__altered = false; + return map; +} + +var EMPTY_STACK; +function emptyStack() { + return EMPTY_STACK || (EMPTY_STACK = makeStack(0)); +} + +function deepEqual(a, b) { + if (a === b) { + return true; + } + + if ( + !isCollection(b) || + (a.size !== undefined && b.size !== undefined && a.size !== b.size) || + (a.__hash !== undefined && + b.__hash !== undefined && + a.__hash !== b.__hash) || + isKeyed(a) !== isKeyed(b) || + isIndexed(a) !== isIndexed(b) || + isOrdered(a) !== isOrdered(b) + ) { + return false; + } + + if (a.size === 0 && b.size === 0) { + return true; + } + + var notAssociative = !isAssociative(a); + + if (isOrdered(a)) { + var entries = a.entries(); + return b.every(function (v, k) { + var entry = entries.next().value; + return entry && is(entry[1], v) && (notAssociative || is(entry[0], k)); + }) && entries.next().done; + } + + var flipped = false; + + if (a.size === undefined) { + if (b.size === undefined) { + if (typeof a.cacheResult === 'function') { + a.cacheResult(); + } + } else { + flipped = true; + var _ = a; + a = b; + b = _; + } + } + + var allEqual = true; + var bSize = b.__iterate(function (v, k) { + if ( + notAssociative + ? !a.has(v) + : flipped ? !is(v, a.get(k, NOT_SET)) : !is(a.get(k, NOT_SET), v) + ) { + allEqual = false; + return false; + } + }); + + return allEqual && a.size === bSize; +} + +/** + * Contributes additional methods to a constructor + */ +function mixin(ctor, methods) { + var keyCopier = function (key) { + ctor.prototype[key] = methods[key]; + }; + Object.keys(methods).forEach(keyCopier); + Object.getOwnPropertySymbols && + Object.getOwnPropertySymbols(methods).forEach(keyCopier); + return ctor; +} + +var Set = (function (SetCollection$$1) { + function Set(value) { + return value === null || value === undefined + ? emptySet() + : isSet(value) && !isOrdered(value) + ? value + : emptySet().withMutations(function (set) { + var iter = SetCollection$$1(value); + assertNotInfinite(iter.size); + iter.forEach(function (v) { return set.add(v); }); + }); + } + + if ( SetCollection$$1 ) Set.__proto__ = SetCollection$$1; + Set.prototype = Object.create( SetCollection$$1 && SetCollection$$1.prototype ); + Set.prototype.constructor = Set; + + Set.of = function of (/*...values*/) { + return this(arguments); + }; + + Set.fromKeys = function fromKeys (value) { + return this(KeyedCollection(value).keySeq()); + }; + + Set.intersect = function intersect (sets) { + sets = Collection(sets).toArray(); + return sets.length + ? SetPrototype.intersect.apply(Set(sets.pop()), sets) + : emptySet(); + }; + + Set.union = function union (sets) { + sets = Collection(sets).toArray(); + return sets.length + ? SetPrototype.union.apply(Set(sets.pop()), sets) + : emptySet(); + }; + + Set.prototype.toString = function toString () { + return this.__toString('Set {', '}'); + }; + + // @pragma Access + + Set.prototype.has = function has (value) { + return this._map.has(value); + }; + + // @pragma Modification + + Set.prototype.add = function add (value) { + return updateSet(this, this._map.set(value, true)); + }; + + Set.prototype.remove = function remove (value) { + return updateSet(this, this._map.remove(value)); + }; + + Set.prototype.clear = function clear () { + return updateSet(this, this._map.clear()); + }; + + // @pragma Composition + + Set.prototype.union = function union () { + var iters = [], len = arguments.length; + while ( len-- ) iters[ len ] = arguments[ len ]; + + iters = iters.filter(function (x) { return x.size !== 0; }); + if (iters.length === 0) { + return this; + } + if (this.size === 0 && !this.__ownerID && iters.length === 1) { + return this.constructor(iters[0]); + } + return this.withMutations(function (set) { + for (var ii = 0; ii < iters.length; ii++) { + SetCollection$$1(iters[ii]).forEach(function (value) { return set.add(value); }); + } + }); + }; + + Set.prototype.intersect = function intersect () { + var iters = [], len = arguments.length; + while ( len-- ) iters[ len ] = arguments[ len ]; + + if (iters.length === 0) { + return this; + } + iters = iters.map(function (iter) { return SetCollection$$1(iter); }); + var toRemove = []; + this.forEach(function (value) { + if (!iters.every(function (iter) { return iter.includes(value); })) { + toRemove.push(value); + } + }); + return this.withMutations(function (set) { + toRemove.forEach(function (value) { + set.remove(value); + }); + }); + }; + + Set.prototype.subtract = function subtract () { + var iters = [], len = arguments.length; + while ( len-- ) iters[ len ] = arguments[ len ]; + + if (iters.length === 0) { + return this; + } + var toRemove = []; + this.forEach(function (value) { + if (iters.some(function (iter) { return iter.includes(value); })) { + toRemove.push(value); + } + }); + return this.withMutations(function (set) { + toRemove.forEach(function (value) { + set.remove(value); + }); + }); + }; + + Set.prototype.merge = function merge () { + return this.union.apply(this, arguments); + }; + + Set.prototype.mergeWith = function mergeWith (merger) { + var iters = [], len = arguments.length - 1; + while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; + + return this.union.apply(this, iters); + }; + + Set.prototype.sort = function sort (comparator) { + // Late binding + return OrderedSet(sortFactory(this, comparator)); + }; + + Set.prototype.sortBy = function sortBy (mapper, comparator) { + // Late binding + return OrderedSet(sortFactory(this, comparator, mapper)); + }; + + Set.prototype.wasAltered = function wasAltered () { + return this._map.wasAltered(); + }; + + Set.prototype.__iterate = function __iterate (fn, reverse) { + var this$1 = this; + + return this._map.__iterate(function (_, k) { return fn(k, k, this$1); }, reverse); + }; + + Set.prototype.__iterator = function __iterator (type, reverse) { + return this._map.map(function (_, k) { return k; }).__iterator(type, reverse); + }; + + Set.prototype.__ensureOwner = function __ensureOwner (ownerID) { + if (ownerID === this.__ownerID) { + return this; + } + var newMap = this._map.__ensureOwner(ownerID); + if (!ownerID) { + if (this.size === 0) { + return emptySet(); + } + this.__ownerID = ownerID; + this._map = newMap; + return this; + } + return this.__make(newMap, ownerID); + }; + + return Set; +}(SetCollection)); + +function isSet(maybeSet) { + return !!(maybeSet && maybeSet[IS_SET_SENTINEL]); +} + +Set.isSet = isSet; + +var IS_SET_SENTINEL = '@@__IMMUTABLE_SET__@@'; + +var SetPrototype = Set.prototype; +SetPrototype[IS_SET_SENTINEL] = true; +SetPrototype[DELETE] = SetPrototype.remove; +SetPrototype.mergeDeep = SetPrototype.merge; +SetPrototype.mergeDeepWith = SetPrototype.mergeWith; +SetPrototype.withMutations = MapPrototype.withMutations; +SetPrototype.asMutable = MapPrototype.asMutable; +SetPrototype.asImmutable = MapPrototype.asImmutable; +SetPrototype['@@transducer/init'] = SetPrototype.asMutable; +SetPrototype['@@transducer/step'] = function(result, arr) { + return result.add(arr); +}; +SetPrototype['@@transducer/result'] = MapPrototype['@@transducer/result']; + +SetPrototype.__empty = emptySet; +SetPrototype.__make = makeSet; + +function updateSet(set, newMap) { + if (set.__ownerID) { + set.size = newMap.size; + set._map = newMap; + return set; + } + return newMap === set._map + ? set + : newMap.size === 0 ? set.__empty() : set.__make(newMap); +} + +function makeSet(map, ownerID) { + var set = Object.create(SetPrototype); + set.size = map ? map.size : 0; + set._map = map; + set.__ownerID = ownerID; + return set; +} + +var EMPTY_SET; +function emptySet() { + return EMPTY_SET || (EMPTY_SET = makeSet(emptyMap())); +} + +/** + * Returns a lazy seq of nums from start (inclusive) to end + * (exclusive), by step, where start defaults to 0, step to 1, and end to + * infinity. When start is equal to end, returns empty list. + */ +var Range = (function (IndexedSeq$$1) { + function Range(start, end, step) { + if (!(this instanceof Range)) { + return new Range(start, end, step); + } + invariant(step !== 0, 'Cannot step a Range by 0'); + start = start || 0; + if (end === undefined) { + end = Infinity; + } + step = step === undefined ? 1 : Math.abs(step); + if (end < start) { + step = -step; + } + this._start = start; + this._end = end; + this._step = step; + this.size = Math.max(0, Math.ceil((end - start) / step - 1) + 1); + if (this.size === 0) { + if (EMPTY_RANGE) { + return EMPTY_RANGE; + } + EMPTY_RANGE = this; + } + } + + if ( IndexedSeq$$1 ) Range.__proto__ = IndexedSeq$$1; + Range.prototype = Object.create( IndexedSeq$$1 && IndexedSeq$$1.prototype ); + Range.prototype.constructor = Range; + + Range.prototype.toString = function toString () { + if (this.size === 0) { + return 'Range []'; + } + return 'Range [ ' + + this._start + + '...' + + this._end + + (this._step !== 1 ? ' by ' + this._step : '') + + ' ]'; + }; + + Range.prototype.get = function get (index, notSetValue) { + return this.has(index) + ? this._start + wrapIndex(this, index) * this._step + : notSetValue; + }; + + Range.prototype.includes = function includes (searchValue) { + var possibleIndex = (searchValue - this._start) / this._step; + return possibleIndex >= 0 && + possibleIndex < this.size && + possibleIndex === Math.floor(possibleIndex); + }; + + Range.prototype.slice = function slice (begin, end) { + if (wholeSlice(begin, end, this.size)) { + return this; + } + begin = resolveBegin(begin, this.size); + end = resolveEnd(end, this.size); + if (end <= begin) { + return new Range(0, 0); + } + return new Range( + this.get(begin, this._end), + this.get(end, this._end), + this._step + ); + }; + + Range.prototype.indexOf = function indexOf (searchValue) { + var offsetValue = searchValue - this._start; + if (offsetValue % this._step === 0) { + var index = offsetValue / this._step; + if (index >= 0 && index < this.size) { + return index; + } + } + return -1; + }; + + Range.prototype.lastIndexOf = function lastIndexOf (searchValue) { + return this.indexOf(searchValue); + }; + + Range.prototype.__iterate = function __iterate (fn, reverse) { + var this$1 = this; + + var size = this.size; + var step = this._step; + var value = reverse ? this._start + (size - 1) * step : this._start; + var i = 0; + while (i !== size) { + if (fn(value, reverse ? size - ++i : i++, this$1) === false) { + break; + } + value += reverse ? -step : step; + } + return i; + }; + + Range.prototype.__iterator = function __iterator (type, reverse) { + var size = this.size; + var step = this._step; + var value = reverse ? this._start + (size - 1) * step : this._start; + var i = 0; + return new Iterator(function () { + if (i === size) { + return iteratorDone(); + } + var v = value; + value += reverse ? -step : step; + return iteratorValue(type, reverse ? size - ++i : i++, v); + }); + }; + + Range.prototype.equals = function equals (other) { + return other instanceof Range + ? this._start === other._start && + this._end === other._end && + this._step === other._step + : deepEqual(this, other); + }; + + return Range; +}(IndexedSeq)); + +var EMPTY_RANGE; + +// Note: all of these methods are deprecated. +Collection.isIterable = isCollection; +Collection.isKeyed = isKeyed; +Collection.isIndexed = isIndexed; +Collection.isAssociative = isAssociative; +Collection.isOrdered = isOrdered; + +Collection.Iterator = Iterator; + +mixin(Collection, { + // ### Conversion to other types + + toArray: function toArray() { + assertNotInfinite(this.size); + var array = new Array(this.size || 0); + this.valueSeq().__iterate(function (v, i) { + array[i] = v; + }); + return array; + }, + + toIndexedSeq: function toIndexedSeq() { + return new ToIndexedSequence(this); + }, + + toJS: function toJS$1() { + return this.toSeq().map(toJS).toJSON(); + }, + + toKeyedSeq: function toKeyedSeq() { + return new ToKeyedSequence(this, true); + }, + + toMap: function toMap() { + // Use Late Binding here to solve the circular dependency. + return Map(this.toKeyedSeq()); + }, + + toObject: function toObject() { + assertNotInfinite(this.size); + var object = {}; + this.__iterate(function (v, k) { + object[k] = v; + }); + return object; + }, + + toOrderedMap: function toOrderedMap() { + // Use Late Binding here to solve the circular dependency. + return OrderedMap(this.toKeyedSeq()); + }, + + toOrderedSet: function toOrderedSet() { + // Use Late Binding here to solve the circular dependency. + return OrderedSet(isKeyed(this) ? this.valueSeq() : this); + }, + + toSet: function toSet() { + // Use Late Binding here to solve the circular dependency. + return Set(isKeyed(this) ? this.valueSeq() : this); + }, + + toSetSeq: function toSetSeq() { + return new ToSetSequence(this); + }, + + toSeq: function toSeq() { + return isIndexed(this) + ? this.toIndexedSeq() + : isKeyed(this) ? this.toKeyedSeq() : this.toSetSeq(); + }, + + toStack: function toStack() { + // Use Late Binding here to solve the circular dependency. + return Stack(isKeyed(this) ? this.valueSeq() : this); + }, + + toList: function toList() { + // Use Late Binding here to solve the circular dependency. + return List(isKeyed(this) ? this.valueSeq() : this); + }, + + // ### Common JavaScript methods and properties + + toString: function toString() { + return '[Collection]'; + }, + + __toString: function __toString(head, tail) { + if (this.size === 0) { + return head + tail; + } + return head + + ' ' + + this.toSeq().map(this.__toStringMapper).join(', ') + + ' ' + + tail; + }, + + // ### ES6 Collection methods (ES6 Array and Map) + + concat: function concat() { + var values = [], len = arguments.length; + while ( len-- ) values[ len ] = arguments[ len ]; + + return reify(this, concatFactory(this, values)); + }, + + includes: function includes(searchValue) { + return this.some(function (value) { return is(value, searchValue); }); + }, + + entries: function entries() { + return this.__iterator(ITERATE_ENTRIES); + }, + + every: function every(predicate, context) { + assertNotInfinite(this.size); + var returnValue = true; + this.__iterate(function (v, k, c) { + if (!predicate.call(context, v, k, c)) { + returnValue = false; + return false; + } + }); + return returnValue; + }, + + filter: function filter(predicate, context) { + return reify(this, filterFactory(this, predicate, context, true)); + }, + + find: function find(predicate, context, notSetValue) { + var entry = this.findEntry(predicate, context); + return entry ? entry[1] : notSetValue; + }, + + forEach: function forEach(sideEffect, context) { + assertNotInfinite(this.size); + return this.__iterate(context ? sideEffect.bind(context) : sideEffect); + }, + + join: function join(separator) { + assertNotInfinite(this.size); + separator = separator !== undefined ? '' + separator : ','; + var joined = ''; + var isFirst = true; + this.__iterate(function (v) { + isFirst ? (isFirst = false) : (joined += separator); + joined += v !== null && v !== undefined ? v.toString() : ''; + }); + return joined; + }, + + keys: function keys() { + return this.__iterator(ITERATE_KEYS); + }, + + map: function map(mapper, context) { + return reify(this, mapFactory(this, mapper, context)); + }, + + reduce: function reduce$1(reducer, initialReduction, context) { + return reduce( + this, + reducer, + initialReduction, + context, + arguments.length < 2, + false + ); + }, + + reduceRight: function reduceRight(reducer, initialReduction, context) { + return reduce( + this, + reducer, + initialReduction, + context, + arguments.length < 2, + true + ); + }, + + reverse: function reverse() { + return reify(this, reverseFactory(this, true)); + }, + + slice: function slice(begin, end) { + return reify(this, sliceFactory(this, begin, end, true)); + }, + + some: function some(predicate, context) { + return !this.every(not(predicate), context); + }, + + sort: function sort(comparator) { + return reify(this, sortFactory(this, comparator)); + }, + + values: function values() { + return this.__iterator(ITERATE_VALUES); + }, + + // ### More sequential methods + + butLast: function butLast() { + return this.slice(0, -1); + }, + + isEmpty: function isEmpty() { + return this.size !== undefined ? this.size === 0 : !this.some(function () { return true; }); + }, + + count: function count(predicate, context) { + return ensureSize( + predicate ? this.toSeq().filter(predicate, context) : this + ); + }, + + countBy: function countBy(grouper, context) { + return countByFactory(this, grouper, context); + }, + + equals: function equals(other) { + return deepEqual(this, other); + }, + + entrySeq: function entrySeq() { + var collection = this; + if (collection._cache) { + // We cache as an entries array, so we can just return the cache! + return new ArraySeq(collection._cache); + } + var entriesSequence = collection.toSeq().map(entryMapper).toIndexedSeq(); + entriesSequence.fromEntrySeq = function () { return collection.toSeq(); }; + + // Entries are plain Array, which do not define toJS, so it must + // manually converts keys and values before conversion. + entriesSequence.toJS = function() { + return this.map(function (entry) { return [toJS(entry[0]), toJS(entry[1])]; }).toJSON(); + }; + + return entriesSequence; + }, + + filterNot: function filterNot(predicate, context) { + return this.filter(not(predicate), context); + }, + + findEntry: function findEntry(predicate, context, notSetValue) { + var found = notSetValue; + this.__iterate(function (v, k, c) { + if (predicate.call(context, v, k, c)) { + found = [k, v]; + return false; + } + }); + return found; + }, + + findKey: function findKey(predicate, context) { + var entry = this.findEntry(predicate, context); + return entry && entry[0]; + }, + + findLast: function findLast(predicate, context, notSetValue) { + return this.toKeyedSeq().reverse().find(predicate, context, notSetValue); + }, + + findLastEntry: function findLastEntry(predicate, context, notSetValue) { + return this.toKeyedSeq() + .reverse() + .findEntry(predicate, context, notSetValue); + }, + + findLastKey: function findLastKey(predicate, context) { + return this.toKeyedSeq().reverse().findKey(predicate, context); + }, + + first: function first() { + return this.find(returnTrue); + }, + + flatMap: function flatMap(mapper, context) { + return reify(this, flatMapFactory(this, mapper, context)); + }, + + flatten: function flatten(depth) { + return reify(this, flattenFactory(this, depth, true)); + }, + + fromEntrySeq: function fromEntrySeq() { + return new FromEntriesSequence(this); + }, + + get: function get(searchKey, notSetValue) { + return this.find(function (_, key) { return is(key, searchKey); }, undefined, notSetValue); + }, + + getIn: function getIn(searchKeyPath, notSetValue) { + var nested = this; + var keyPath = coerceKeyPath(searchKeyPath); + var i = 0; + while (i !== keyPath.length) { + if (!nested || !nested.get) { + warn( + 'Invalid keyPath: Value at [' + + keyPath.slice(0, i).map(quoteString) + + '] does not have a .get() method: ' + + nested + + '\nThis warning will throw in a future version' + ); + return notSetValue; + } + nested = nested.get(keyPath[i++], NOT_SET); + if (nested === NOT_SET) { + return notSetValue; + } + } + return nested; + }, + + groupBy: function groupBy(grouper, context) { + return groupByFactory(this, grouper, context); + }, + + has: function has(searchKey) { + return this.get(searchKey, NOT_SET) !== NOT_SET; + }, + + hasIn: function hasIn(searchKeyPath) { + return this.getIn(searchKeyPath, NOT_SET) !== NOT_SET; + }, + + isSubset: function isSubset(iter) { + iter = typeof iter.includes === 'function' ? iter : Collection(iter); + return this.every(function (value) { return iter.includes(value); }); + }, + + isSuperset: function isSuperset(iter) { + iter = typeof iter.isSubset === 'function' ? iter : Collection(iter); + return iter.isSubset(this); + }, + + keyOf: function keyOf(searchValue) { + return this.findKey(function (value) { return is(value, searchValue); }); + }, + + keySeq: function keySeq() { + return this.toSeq().map(keyMapper).toIndexedSeq(); + }, + + last: function last() { + return this.toSeq().reverse().first(); + }, + + lastKeyOf: function lastKeyOf(searchValue) { + return this.toKeyedSeq().reverse().keyOf(searchValue); + }, + + max: function max(comparator) { + return maxFactory(this, comparator); + }, + + maxBy: function maxBy(mapper, comparator) { + return maxFactory(this, comparator, mapper); + }, + + min: function min(comparator) { + return maxFactory( + this, + comparator ? neg(comparator) : defaultNegComparator + ); + }, + + minBy: function minBy(mapper, comparator) { + return maxFactory( + this, + comparator ? neg(comparator) : defaultNegComparator, + mapper + ); + }, + + rest: function rest() { + return this.slice(1); + }, + + skip: function skip(amount) { + return amount === 0 ? this : this.slice(Math.max(0, amount)); + }, + + skipLast: function skipLast(amount) { + return amount === 0 ? this : this.slice(0, -Math.max(0, amount)); + }, + + skipWhile: function skipWhile(predicate, context) { + return reify(this, skipWhileFactory(this, predicate, context, true)); + }, + + skipUntil: function skipUntil(predicate, context) { + return this.skipWhile(not(predicate), context); + }, + + sortBy: function sortBy(mapper, comparator) { + return reify(this, sortFactory(this, comparator, mapper)); + }, + + take: function take(amount) { + return this.slice(0, Math.max(0, amount)); + }, + + takeLast: function takeLast(amount) { + return this.slice(-Math.max(0, amount)); + }, + + takeWhile: function takeWhile(predicate, context) { + return reify(this, takeWhileFactory(this, predicate, context)); + }, + + takeUntil: function takeUntil(predicate, context) { + return this.takeWhile(not(predicate), context); + }, + + update: function update(fn) { + return fn(this); + }, + + valueSeq: function valueSeq() { + return this.toIndexedSeq(); + }, + + // ### Hashable Object + + hashCode: function hashCode() { + return this.__hash || (this.__hash = hashCollection(this)); + } + + // ### Internal + + // abstract __iterate(fn, reverse) + + // abstract __iterator(type, reverse) +}); + +var CollectionPrototype = Collection.prototype; +CollectionPrototype[IS_ITERABLE_SENTINEL] = true; +CollectionPrototype[ITERATOR_SYMBOL] = CollectionPrototype.values; +CollectionPrototype.toJSON = CollectionPrototype.toArray; +CollectionPrototype.__toStringMapper = quoteString; +CollectionPrototype.inspect = (CollectionPrototype.toSource = function() { + return this.toString(); +}); +CollectionPrototype.chain = CollectionPrototype.flatMap; +CollectionPrototype.contains = CollectionPrototype.includes; + +mixin(KeyedCollection, { + // ### More sequential methods + + flip: function flip() { + return reify(this, flipFactory(this)); + }, + + mapEntries: function mapEntries(mapper, context) { + var this$1 = this; + + var iterations = 0; + return reify( + this, + this.toSeq() + .map(function (v, k) { return mapper.call(context, [k, v], iterations++, this$1); }) + .fromEntrySeq() + ); + }, + + mapKeys: function mapKeys(mapper, context) { + var this$1 = this; + + return reify( + this, + this.toSeq().flip().map(function (k, v) { return mapper.call(context, k, v, this$1); }).flip() + ); + } +}); + +var KeyedCollectionPrototype = KeyedCollection.prototype; +KeyedCollectionPrototype[IS_KEYED_SENTINEL] = true; +KeyedCollectionPrototype[ITERATOR_SYMBOL] = CollectionPrototype.entries; +KeyedCollectionPrototype.toJSON = CollectionPrototype.toObject; +KeyedCollectionPrototype.__toStringMapper = function (v, k) { return quoteString(k) + ': ' + quoteString(v); }; + +mixin(IndexedCollection, { + // ### Conversion to other types + + toKeyedSeq: function toKeyedSeq() { + return new ToKeyedSequence(this, false); + }, + + // ### ES6 Collection methods (ES6 Array and Map) + + filter: function filter(predicate, context) { + return reify(this, filterFactory(this, predicate, context, false)); + }, + + findIndex: function findIndex(predicate, context) { + var entry = this.findEntry(predicate, context); + return entry ? entry[0] : -1; + }, + + indexOf: function indexOf(searchValue) { + var key = this.keyOf(searchValue); + return key === undefined ? -1 : key; + }, + + lastIndexOf: function lastIndexOf(searchValue) { + var key = this.lastKeyOf(searchValue); + return key === undefined ? -1 : key; + }, + + reverse: function reverse() { + return reify(this, reverseFactory(this, false)); + }, + + slice: function slice(begin, end) { + return reify(this, sliceFactory(this, begin, end, false)); + }, + + splice: function splice(index, removeNum /*, ...values*/) { + var numArgs = arguments.length; + removeNum = Math.max(removeNum || 0, 0); + if (numArgs === 0 || (numArgs === 2 && !removeNum)) { + return this; + } + // If index is negative, it should resolve relative to the size of the + // collection. However size may be expensive to compute if not cached, so + // only call count() if the number is in fact negative. + index = resolveBegin(index, index < 0 ? this.count() : this.size); + var spliced = this.slice(0, index); + return reify( + this, + numArgs === 1 + ? spliced + : spliced.concat(arrCopy(arguments, 2), this.slice(index + removeNum)) + ); + }, + + // ### More collection methods + + findLastIndex: function findLastIndex(predicate, context) { + var entry = this.findLastEntry(predicate, context); + return entry ? entry[0] : -1; + }, + + first: function first() { + return this.get(0); + }, + + flatten: function flatten(depth) { + return reify(this, flattenFactory(this, depth, false)); + }, + + get: function get(index, notSetValue) { + index = wrapIndex(this, index); + return index < 0 || + (this.size === Infinity || (this.size !== undefined && index > this.size)) + ? notSetValue + : this.find(function (_, key) { return key === index; }, undefined, notSetValue); + }, + + has: function has(index) { + index = wrapIndex(this, index); + return index >= 0 && + (this.size !== undefined + ? this.size === Infinity || index < this.size + : this.indexOf(index) !== -1); + }, + + interpose: function interpose(separator) { + return reify(this, interposeFactory(this, separator)); + }, + + interleave: function interleave(/*...collections*/) { + var collections = [this].concat(arrCopy(arguments)); + var zipped = zipWithFactory(this.toSeq(), IndexedSeq.of, collections); + var interleaved = zipped.flatten(true); + if (zipped.size) { + interleaved.size = zipped.size * collections.length; + } + return reify(this, interleaved); + }, + + keySeq: function keySeq() { + return Range(0, this.size); + }, + + last: function last() { + return this.get(-1); + }, + + skipWhile: function skipWhile(predicate, context) { + return reify(this, skipWhileFactory(this, predicate, context, false)); + }, + + zip: function zip(/*, ...collections */) { + var collections = [this].concat(arrCopy(arguments)); + return reify(this, zipWithFactory(this, defaultZipper, collections)); + }, + + zipWith: function zipWith(zipper /*, ...collections */) { + var collections = arrCopy(arguments); + collections[0] = this; + return reify(this, zipWithFactory(this, zipper, collections)); + } +}); + +var IndexedCollectionPrototype = IndexedCollection.prototype; +IndexedCollectionPrototype[IS_INDEXED_SENTINEL] = true; +IndexedCollectionPrototype[IS_ORDERED_SENTINEL] = true; + +mixin(SetCollection, { + // ### ES6 Collection methods (ES6 Array and Map) + + get: function get(value, notSetValue) { + return this.has(value) ? value : notSetValue; + }, + + includes: function includes(value) { + return this.has(value); + }, + + // ### More sequential methods + + keySeq: function keySeq() { + return this.valueSeq(); + } +}); + +SetCollection.prototype.has = CollectionPrototype.includes; +SetCollection.prototype.contains = SetCollection.prototype.includes; + +// Mixin subclasses + +mixin(KeyedSeq, KeyedCollection.prototype); +mixin(IndexedSeq, IndexedCollection.prototype); +mixin(SetSeq, SetCollection.prototype); + +// #pragma Helper functions + +function reduce(collection, reducer, reduction, context, useFirst, reverse) { + assertNotInfinite(collection.size); + collection.__iterate( + function (v, k, c) { + if (useFirst) { + useFirst = false; + reduction = v; + } else { + reduction = reducer.call(context, reduction, v, k, c); + } + }, + reverse + ); + return reduction; +} + +function keyMapper(v, k) { + return k; +} + +function entryMapper(v, k) { + return [k, v]; +} + +function toJS(value) { + return value && typeof value.toJS === 'function' ? value.toJS() : value; +} + +function not(predicate) { + return function() { + return !predicate.apply(this, arguments); + }; +} + +function neg(predicate) { + return function() { + return -predicate.apply(this, arguments); + }; +} + +function defaultZipper() { + return arrCopy(arguments); +} + +function defaultNegComparator(a, b) { + return a < b ? 1 : a > b ? -1 : 0; +} + +function hashCollection(collection) { + if (collection.size === Infinity) { + return 0; + } + var ordered = isOrdered(collection); + var keyed = isKeyed(collection); + var h = ordered ? 1 : 0; + var size = collection.__iterate( + keyed + ? ordered + ? function (v, k) { + h = 31 * h + hashMerge(hash(v), hash(k)) | 0; + } + : function (v, k) { + h = h + hashMerge(hash(v), hash(k)) | 0; + } + : ordered + ? function (v) { + h = 31 * h + hash(v) | 0; + } + : function (v) { + h = h + hash(v) | 0; + } + ); + return murmurHashOfSize(size, h); +} + +function murmurHashOfSize(size, h) { + h = imul(h, 0xcc9e2d51); + h = imul(h << 15 | h >>> -15, 0x1b873593); + h = imul(h << 13 | h >>> -13, 5); + h = (h + 0xe6546b64 | 0) ^ size; + h = imul(h ^ h >>> 16, 0x85ebca6b); + h = imul(h ^ h >>> 13, 0xc2b2ae35); + h = smi(h ^ h >>> 16); + return h; +} + +function hashMerge(a, b) { + return a ^ b + 0x9e3779b9 + (a << 6) + (a >> 2) | 0; // int +} + +function warn(message) { + /* eslint-disable no-console */ + if (typeof console === 'object' && console.warn) { + console.warn(message); + } else { + throw new Error(message); + } + /* eslint-enable no-console */ +} + +var OrderedSet = (function (Set$$1) { + function OrderedSet(value) { + return value === null || value === undefined + ? emptyOrderedSet() + : isOrderedSet(value) + ? value + : emptyOrderedSet().withMutations(function (set) { + var iter = SetCollection(value); + assertNotInfinite(iter.size); + iter.forEach(function (v) { return set.add(v); }); + }); + } + + if ( Set$$1 ) OrderedSet.__proto__ = Set$$1; + OrderedSet.prototype = Object.create( Set$$1 && Set$$1.prototype ); + OrderedSet.prototype.constructor = OrderedSet; + + OrderedSet.of = function of (/*...values*/) { + return this(arguments); + }; + + OrderedSet.fromKeys = function fromKeys (value) { + return this(KeyedCollection(value).keySeq()); + }; + + OrderedSet.prototype.toString = function toString () { + return this.__toString('OrderedSet {', '}'); + }; + + return OrderedSet; +}(Set)); + +function isOrderedSet(maybeOrderedSet) { + return isSet(maybeOrderedSet) && isOrdered(maybeOrderedSet); +} + +OrderedSet.isOrderedSet = isOrderedSet; + +var OrderedSetPrototype = OrderedSet.prototype; +OrderedSetPrototype[IS_ORDERED_SENTINEL] = true; +OrderedSetPrototype.zip = IndexedCollectionPrototype.zip; +OrderedSetPrototype.zipWith = IndexedCollectionPrototype.zipWith; + +OrderedSetPrototype.__empty = emptyOrderedSet; +OrderedSetPrototype.__make = makeOrderedSet; + +function makeOrderedSet(map, ownerID) { + var set = Object.create(OrderedSetPrototype); + set.size = map ? map.size : 0; + set._map = map; + set.__ownerID = ownerID; + return set; +} + +var EMPTY_ORDERED_SET; +function emptyOrderedSet() { + return EMPTY_ORDERED_SET || + (EMPTY_ORDERED_SET = makeOrderedSet(emptyOrderedMap())); +} + +var Record = function Record(defaultValues, name) { + var hasInitialized; + + var RecordType = function Record(values) { + var this$1 = this; + + if (values instanceof RecordType) { + return values; + } + if (!(this instanceof RecordType)) { + return new RecordType(values); + } + if (!hasInitialized) { + hasInitialized = true; + var keys = Object.keys(defaultValues); + var indices = (RecordTypePrototype._indices = {}); + RecordTypePrototype._name = name; + RecordTypePrototype._keys = keys; + RecordTypePrototype._defaultValues = defaultValues; + for (var i = 0; i < keys.length; i++) { + var propName = keys[i]; + indices[propName] = i; + if (RecordTypePrototype[propName]) { + /* eslint-disable no-console */ + typeof console === 'object' && + console.warn && + console.warn( + 'Cannot define ' + + recordName(this$1) + + ' with property "' + + propName + + '" since that property name is part of the Record API.' + ); + /* eslint-enable no-console */ + } else { + setProp(RecordTypePrototype, propName); + } + } + } + this.__ownerID = undefined; + this._values = List().withMutations(function (l) { + l.setSize(this$1._keys.length); + KeyedCollection(values).forEach(function (v, k) { + l.set(this$1._indices[k], v === this$1._defaultValues[k] ? undefined : v); + }); + }); + }; + + var RecordTypePrototype = (RecordType.prototype = Object.create( + RecordPrototype + )); + RecordTypePrototype.constructor = RecordType; + + return RecordType; +}; + +Record.prototype.toString = function toString () { + var this$1 = this; + + var str = recordName(this) + ' { '; + var keys = this._keys; + var k; + for (var i = 0, l = keys.length; i !== l; i++) { + k = keys[i]; + str += (i ? ', ' : '') + k + ': ' + quoteString(this$1.get(k)); + } + return str + ' }'; +}; + +Record.prototype.equals = function equals (other) { + return this === other || + (other && + this._keys === other._keys && + recordSeq(this).equals(recordSeq(other))); +}; + +Record.prototype.hashCode = function hashCode () { + return recordSeq(this).hashCode(); +}; + +// @pragma Access + +Record.prototype.has = function has (k) { + return this._indices.hasOwnProperty(k); +}; + +Record.prototype.get = function get (k, notSetValue) { + if (!this.has(k)) { + return notSetValue; + } + var index = this._indices[k]; + var value = this._values.get(index); + return value === undefined ? this._defaultValues[k] : value; +}; + +// @pragma Modification + +Record.prototype.set = function set (k, v) { + if (this.has(k)) { + var newValues = this._values.set( + this._indices[k], + v === this._defaultValues[k] ? undefined : v + ); + if (newValues !== this._values && !this.__ownerID) { + return makeRecord(this, newValues); + } + } + return this; +}; + +Record.prototype.remove = function remove (k) { + return this.set(k); +}; + +Record.prototype.clear = function clear () { + var newValues = this._values.clear().setSize(this._keys.length); + return this.__ownerID ? this : makeRecord(this, newValues); +}; + +Record.prototype.wasAltered = function wasAltered () { + return this._values.wasAltered(); +}; + +Record.prototype.toSeq = function toSeq () { + return recordSeq(this); +}; + +Record.prototype.toJS = function toJS () { + return recordSeq(this).toJS(); +}; + +Record.prototype.__iterator = function __iterator (type, reverse) { + return recordSeq(this).__iterator(type, reverse); +}; + +Record.prototype.__iterate = function __iterate (fn, reverse) { + return recordSeq(this).__iterate(fn, reverse); +}; + +Record.prototype.__ensureOwner = function __ensureOwner (ownerID) { + if (ownerID === this.__ownerID) { + return this; + } + var newValues = this._values.__ensureOwner(ownerID); + if (!ownerID) { + this.__ownerID = ownerID; + this._values = newValues; + return this; + } + return makeRecord(this, newValues, ownerID); +}; + +Record.isRecord = isRecord; +Record.getDescriptiveName = recordName; +var RecordPrototype = Record.prototype; +RecordPrototype[IS_RECORD_SENTINEL] = true; +RecordPrototype[DELETE] = RecordPrototype.remove; +RecordPrototype.deleteIn = (RecordPrototype.removeIn = MapPrototype.removeIn); +RecordPrototype.getIn = CollectionPrototype.getIn; +RecordPrototype.hasIn = CollectionPrototype.hasIn; +RecordPrototype.merge = MapPrototype.merge; +RecordPrototype.mergeWith = MapPrototype.mergeWith; +RecordPrototype.mergeIn = MapPrototype.mergeIn; +RecordPrototype.mergeDeep = MapPrototype.mergeDeep; +RecordPrototype.mergeDeepWith = MapPrototype.mergeDeepWith; +RecordPrototype.mergeDeepIn = MapPrototype.mergeDeepIn; +RecordPrototype.setIn = MapPrototype.setIn; +RecordPrototype.update = MapPrototype.update; +RecordPrototype.updateIn = MapPrototype.updateIn; +RecordPrototype.withMutations = MapPrototype.withMutations; +RecordPrototype.asMutable = MapPrototype.asMutable; +RecordPrototype.asImmutable = MapPrototype.asImmutable; +RecordPrototype[ITERATOR_SYMBOL] = CollectionPrototype.entries; +RecordPrototype.toJSON = (RecordPrototype.toObject = CollectionPrototype.toObject); +RecordPrototype.inspect = (RecordPrototype.toSource = CollectionPrototype.toSource); + +function makeRecord(likeRecord, values, ownerID) { + var record = Object.create(Object.getPrototypeOf(likeRecord)); + record._values = values; + record.__ownerID = ownerID; + return record; +} + +function recordName(record) { + return record._name || record.constructor.name || 'Record'; +} + +function recordSeq(record) { + return keyedSeqFromValue(record._keys.map(function (k) { return [k, record.get(k)]; })); +} + +function setProp(prototype, name) { + try { + Object.defineProperty(prototype, name, { + get: function() { + return this.get(name); + }, + set: function(value) { + invariant(this.__ownerID, 'Cannot set on an immutable record.'); + this.set(name, value); + } + }); + } catch (error) { + // Object.defineProperty failed. Probably IE8. + } +} + +/** + * Returns a lazy Seq of `value` repeated `times` times. When `times` is + * undefined, returns an infinite sequence of `value`. + */ +var Repeat = (function (IndexedSeq$$1) { + function Repeat(value, times) { + if (!(this instanceof Repeat)) { + return new Repeat(value, times); + } + this._value = value; + this.size = times === undefined ? Infinity : Math.max(0, times); + if (this.size === 0) { + if (EMPTY_REPEAT) { + return EMPTY_REPEAT; + } + EMPTY_REPEAT = this; + } + } + + if ( IndexedSeq$$1 ) Repeat.__proto__ = IndexedSeq$$1; + Repeat.prototype = Object.create( IndexedSeq$$1 && IndexedSeq$$1.prototype ); + Repeat.prototype.constructor = Repeat; + + Repeat.prototype.toString = function toString () { + if (this.size === 0) { + return 'Repeat []'; + } + return 'Repeat [ ' + this._value + ' ' + this.size + ' times ]'; + }; + + Repeat.prototype.get = function get (index, notSetValue) { + return this.has(index) ? this._value : notSetValue; + }; + + Repeat.prototype.includes = function includes (searchValue) { + return is(this._value, searchValue); + }; + + Repeat.prototype.slice = function slice (begin, end) { + var size = this.size; + return wholeSlice(begin, end, size) + ? this + : new Repeat( + this._value, + resolveEnd(end, size) - resolveBegin(begin, size) + ); + }; + + Repeat.prototype.reverse = function reverse () { + return this; + }; + + Repeat.prototype.indexOf = function indexOf (searchValue) { + if (is(this._value, searchValue)) { + return 0; + } + return -1; + }; + + Repeat.prototype.lastIndexOf = function lastIndexOf (searchValue) { + if (is(this._value, searchValue)) { + return this.size; + } + return -1; + }; + + Repeat.prototype.__iterate = function __iterate (fn, reverse) { + var this$1 = this; + + var size = this.size; + var i = 0; + while (i !== size) { + if (fn(this$1._value, reverse ? size - ++i : i++, this$1) === false) { + break; + } + } + return i; + }; + + Repeat.prototype.__iterator = function __iterator (type, reverse) { + var this$1 = this; + + var size = this.size; + var i = 0; + return new Iterator( + function () { return i === size + ? iteratorDone() + : iteratorValue(type, reverse ? size - ++i : i++, this$1._value); } + ); + }; + + Repeat.prototype.equals = function equals (other) { + return other instanceof Repeat + ? is(this._value, other._value) + : deepEqual(other); + }; + + return Repeat; +}(IndexedSeq)); + +var EMPTY_REPEAT; + +var Immutable = { + Collection: Collection, + // Note: Iterable is deprecated + Iterable: Collection, + + Seq: Seq, + Map: Map, + OrderedMap: OrderedMap, + List: List, + Stack: Stack, + Set: Set, + OrderedSet: OrderedSet, + + Record: Record, + Range: Range, + Repeat: Repeat, + + is: is, + fromJS: fromJS, + hash: hash, + + isImmutable: isImmutable, + isCollection: isCollection, + isKeyed: isKeyed, + isIndexed: isIndexed, + isAssociative: isAssociative, + isOrdered: isOrdered, + isValueObject: isValueObject +}; + +// Note: Iterable is deprecated +var Iterable = Collection; + +export { Collection, Iterable, Seq, Map, OrderedMap, List, Stack, Set, OrderedSet, Record, Range, Repeat, is, fromJS, hash, isImmutable, isCollection, isKeyed, isIndexed, isAssociative, isOrdered, isValueObject };export default Immutable; diff --git a/dist/immutable.js b/dist/immutable.js new file mode 100644 index 0000000000..11ab6097ff --- /dev/null +++ b/dist/immutable.js @@ -0,0 +1,5567 @@ +/** + * Copyright (c) 2014-2015, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : + typeof define === 'function' && define.amd ? define(['exports'], factory) : + (factory((global.Immutable = global.Immutable || {}))); +}(this, (function (exports) { 'use strict'; + +// Used for setting prototype methods that IE8 chokes on. +var DELETE = 'delete'; + +// Constants describing the size of trie nodes. +var SHIFT = 5; // Resulted in best performance after ______? +var SIZE = 1 << SHIFT; +var MASK = SIZE - 1; + +// A consistent shared value representing "not set" which equals nothing other +// than itself, and nothing that could be provided externally. +var NOT_SET = {}; + +// Boolean references, Rough equivalent of `bool &`. +var CHANGE_LENGTH = { value: false }; +var DID_ALTER = { value: false }; + +function MakeRef(ref) { + ref.value = false; + return ref; +} + +function SetRef(ref) { + ref && (ref.value = true); +} + +// A function which returns a value representing an "owner" for transient writes +// to tries. The return value will only ever equal itself, and will not equal +// the return of any subsequent call of this function. +function OwnerID() {} + +// http://jsperf.com/copy-array-inline +function arrCopy(arr, offset) { + offset = offset || 0; + var len = Math.max(0, arr.length - offset); + var newArr = new Array(len); + for (var ii = 0; ii < len; ii++) { + newArr[ii] = arr[ii + offset]; + } + return newArr; +} + +function ensureSize(iter) { + if (iter.size === undefined) { + iter.size = iter.__iterate(returnTrue); + } + return iter.size; +} + +function wrapIndex(iter, index) { + // This implements "is array index" which the ECMAString spec defines as: + // + // A String property name P is an array index if and only if + // ToString(ToUint32(P)) is equal to P and ToUint32(P) is not equal + // to 2^32−1. + // + // http://www.ecma-international.org/ecma-262/6.0/#sec-array-exotic-objects + if (typeof index !== 'number') { + var uint32Index = index >>> 0; // N >>> 0 is shorthand for ToUint32 + if ('' + uint32Index !== index || uint32Index === 4294967295) { + return NaN; + } + index = uint32Index; + } + return index < 0 ? ensureSize(iter) + index : index; +} + +function returnTrue() { + return true; +} + +function wholeSlice(begin, end, size) { + return ((begin === 0 && !isNeg(begin)) || + (size !== undefined && begin <= -size)) && + (end === undefined || (size !== undefined && end >= size)); +} + +function resolveBegin(begin, size) { + return resolveIndex(begin, size, 0); +} + +function resolveEnd(end, size) { + return resolveIndex(end, size, size); +} + +function resolveIndex(index, size, defaultIndex) { + // Sanitize indices using this shorthand for ToInt32(argument) + // http://www.ecma-international.org/ecma-262/6.0/#sec-toint32 + return index === undefined + ? defaultIndex + : isNeg(index) + ? size === Infinity ? size : Math.max(0, size + index) | 0 + : size === undefined || size === index + ? index + : Math.min(size, index) | 0; +} + +function isNeg(value) { + // Account for -0 which is negative, but not less than 0. + return value < 0 || (value === 0 && 1 / value === -Infinity); +} + +function isImmutable(maybeImmutable) { + return (isCollection(maybeImmutable) || isRecord(maybeImmutable)) && + !maybeImmutable.__ownerID; +} + +function isCollection(maybeCollection) { + return !!(maybeCollection && maybeCollection[IS_ITERABLE_SENTINEL]); +} + +function isKeyed(maybeKeyed) { + return !!(maybeKeyed && maybeKeyed[IS_KEYED_SENTINEL]); +} + +function isIndexed(maybeIndexed) { + return !!(maybeIndexed && maybeIndexed[IS_INDEXED_SENTINEL]); +} + +function isAssociative(maybeAssociative) { + return isKeyed(maybeAssociative) || isIndexed(maybeAssociative); +} + +function isOrdered(maybeOrdered) { + return !!(maybeOrdered && maybeOrdered[IS_ORDERED_SENTINEL]); +} + +function isRecord(maybeRecord) { + return !!(maybeRecord && maybeRecord[IS_RECORD_SENTINEL]); +} + +function isValueObject(maybeValue) { + return !!(maybeValue && + typeof maybeValue.equals === 'function' && + typeof maybeValue.hashCode === 'function'); +} + +var IS_ITERABLE_SENTINEL = '@@__IMMUTABLE_ITERABLE__@@'; +var IS_KEYED_SENTINEL = '@@__IMMUTABLE_KEYED__@@'; +var IS_INDEXED_SENTINEL = '@@__IMMUTABLE_INDEXED__@@'; +var IS_ORDERED_SENTINEL = '@@__IMMUTABLE_ORDERED__@@'; +var IS_RECORD_SENTINEL = '@@__IMMUTABLE_RECORD__@@'; + +var Collection = function Collection(value) { + return isCollection(value) ? value : Seq(value); +}; + +var KeyedCollection = (function (Collection) { + function KeyedCollection(value) { + return isKeyed(value) ? value : KeyedSeq(value); + } + + if ( Collection ) KeyedCollection.__proto__ = Collection; + KeyedCollection.prototype = Object.create( Collection && Collection.prototype ); + KeyedCollection.prototype.constructor = KeyedCollection; + + return KeyedCollection; +}(Collection)); + +var IndexedCollection = (function (Collection) { + function IndexedCollection(value) { + return isIndexed(value) ? value : IndexedSeq(value); + } + + if ( Collection ) IndexedCollection.__proto__ = Collection; + IndexedCollection.prototype = Object.create( Collection && Collection.prototype ); + IndexedCollection.prototype.constructor = IndexedCollection; + + return IndexedCollection; +}(Collection)); + +var SetCollection = (function (Collection) { + function SetCollection(value) { + return isCollection(value) && !isAssociative(value) ? value : SetSeq(value); + } + + if ( Collection ) SetCollection.__proto__ = Collection; + SetCollection.prototype = Object.create( Collection && Collection.prototype ); + SetCollection.prototype.constructor = SetCollection; + + return SetCollection; +}(Collection)); + +Collection.Keyed = KeyedCollection; +Collection.Indexed = IndexedCollection; +Collection.Set = SetCollection; + +var ITERATE_KEYS = 0; +var ITERATE_VALUES = 1; +var ITERATE_ENTRIES = 2; + +var REAL_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator; +var FAUX_ITERATOR_SYMBOL = '@@iterator'; + +var ITERATOR_SYMBOL = REAL_ITERATOR_SYMBOL || FAUX_ITERATOR_SYMBOL; + +var Iterator = function Iterator(next) { + this.next = next; +}; + +Iterator.prototype.toString = function toString () { + return '[Iterator]'; +}; + +Iterator.KEYS = ITERATE_KEYS; +Iterator.VALUES = ITERATE_VALUES; +Iterator.ENTRIES = ITERATE_ENTRIES; + +Iterator.prototype.inspect = (Iterator.prototype.toSource = function() { + return this.toString(); +}); +Iterator.prototype[ITERATOR_SYMBOL] = function() { + return this; +}; + +function iteratorValue(type, k, v, iteratorResult) { + var value = type === 0 ? k : type === 1 ? v : [k, v]; + iteratorResult + ? (iteratorResult.value = value) + : (iteratorResult = { + value: value, + done: false + }); + return iteratorResult; +} + +function iteratorDone() { + return { value: undefined, done: true }; +} + +function hasIterator(maybeIterable) { + return !!getIteratorFn(maybeIterable); +} + +function isIterator(maybeIterator) { + return maybeIterator && typeof maybeIterator.next === 'function'; +} + +function getIterator(iterable) { + var iteratorFn = getIteratorFn(iterable); + return iteratorFn && iteratorFn.call(iterable); +} + +function getIteratorFn(iterable) { + var iteratorFn = iterable && + ((REAL_ITERATOR_SYMBOL && iterable[REAL_ITERATOR_SYMBOL]) || + iterable[FAUX_ITERATOR_SYMBOL]); + if (typeof iteratorFn === 'function') { + return iteratorFn; + } +} + +function isArrayLike(value) { + return value && typeof value.length === 'number'; +} + +var Seq = (function (Collection$$1) { + function Seq(value) { + return value === null || value === undefined + ? emptySequence() + : isCollection(value) || isRecord(value) + ? value.toSeq() + : seqFromValue(value); + } + + if ( Collection$$1 ) Seq.__proto__ = Collection$$1; + Seq.prototype = Object.create( Collection$$1 && Collection$$1.prototype ); + Seq.prototype.constructor = Seq; + + Seq.prototype.toSeq = function toSeq () { + return this; + }; + + Seq.prototype.toString = function toString () { + return this.__toString('Seq {', '}'); + }; + + Seq.prototype.cacheResult = function cacheResult () { + if (!this._cache && this.__iterateUncached) { + this._cache = this.entrySeq().toArray(); + this.size = this._cache.length; + } + return this; + }; + + // abstract __iterateUncached(fn, reverse) + + Seq.prototype.__iterate = function __iterate (fn, reverse) { + var this$1 = this; + + var cache = this._cache; + if (cache) { + var size = cache.length; + var i = 0; + while (i !== size) { + var entry = cache[reverse ? size - ++i : i++]; + if (fn(entry[1], entry[0], this$1) === false) { + break; + } + } + return i; + } + return this.__iterateUncached(fn, reverse); + }; + + // abstract __iteratorUncached(type, reverse) + + Seq.prototype.__iterator = function __iterator (type, reverse) { + var cache = this._cache; + if (cache) { + var size = cache.length; + var i = 0; + return new Iterator(function () { + if (i === size) { + return iteratorDone(); + } + var entry = cache[reverse ? size - ++i : i++]; + return iteratorValue(type, entry[0], entry[1]); + }); + } + return this.__iteratorUncached(type, reverse); + }; + + return Seq; +}(Collection)); + +var KeyedSeq = (function (Seq) { + function KeyedSeq(value) { + return value === null || value === undefined + ? emptySequence().toKeyedSeq() + : isCollection(value) + ? isKeyed(value) ? value.toSeq() : value.fromEntrySeq() + : isRecord(value) ? value.toSeq() : keyedSeqFromValue(value); + } + + if ( Seq ) KeyedSeq.__proto__ = Seq; + KeyedSeq.prototype = Object.create( Seq && Seq.prototype ); + KeyedSeq.prototype.constructor = KeyedSeq; + + KeyedSeq.prototype.toKeyedSeq = function toKeyedSeq () { + return this; + }; + + return KeyedSeq; +}(Seq)); + +var IndexedSeq = (function (Seq) { + function IndexedSeq(value) { + return value === null || value === undefined + ? emptySequence() + : isCollection(value) + ? isKeyed(value) ? value.entrySeq() : value.toIndexedSeq() + : isRecord(value) + ? value.toSeq().entrySeq() + : indexedSeqFromValue(value); + } + + if ( Seq ) IndexedSeq.__proto__ = Seq; + IndexedSeq.prototype = Object.create( Seq && Seq.prototype ); + IndexedSeq.prototype.constructor = IndexedSeq; + + IndexedSeq.of = function of (/*...values*/) { + return IndexedSeq(arguments); + }; + + IndexedSeq.prototype.toIndexedSeq = function toIndexedSeq () { + return this; + }; + + IndexedSeq.prototype.toString = function toString () { + return this.__toString('Seq [', ']'); + }; + + return IndexedSeq; +}(Seq)); + +var SetSeq = (function (Seq) { + function SetSeq(value) { + return (isCollection(value) && !isAssociative(value) + ? value + : IndexedSeq(value)).toSetSeq(); + } + + if ( Seq ) SetSeq.__proto__ = Seq; + SetSeq.prototype = Object.create( Seq && Seq.prototype ); + SetSeq.prototype.constructor = SetSeq; + + SetSeq.of = function of (/*...values*/) { + return SetSeq(arguments); + }; + + SetSeq.prototype.toSetSeq = function toSetSeq () { + return this; + }; + + return SetSeq; +}(Seq)); + +Seq.isSeq = isSeq; +Seq.Keyed = KeyedSeq; +Seq.Set = SetSeq; +Seq.Indexed = IndexedSeq; + +var IS_SEQ_SENTINEL = '@@__IMMUTABLE_SEQ__@@'; + +Seq.prototype[IS_SEQ_SENTINEL] = true; + +// #pragma Root Sequences + +var ArraySeq = (function (IndexedSeq) { + function ArraySeq(array) { + this._array = array; + this.size = array.length; + } + + if ( IndexedSeq ) ArraySeq.__proto__ = IndexedSeq; + ArraySeq.prototype = Object.create( IndexedSeq && IndexedSeq.prototype ); + ArraySeq.prototype.constructor = ArraySeq; + + ArraySeq.prototype.get = function get (index, notSetValue) { + return this.has(index) ? this._array[wrapIndex(this, index)] : notSetValue; + }; + + ArraySeq.prototype.__iterate = function __iterate (fn, reverse) { + var this$1 = this; + + var array = this._array; + var size = array.length; + var i = 0; + while (i !== size) { + var ii = reverse ? size - ++i : i++; + if (fn(array[ii], ii, this$1) === false) { + break; + } + } + return i; + }; + + ArraySeq.prototype.__iterator = function __iterator (type, reverse) { + var array = this._array; + var size = array.length; + var i = 0; + return new Iterator(function () { + if (i === size) { + return iteratorDone(); + } + var ii = reverse ? size - ++i : i++; + return iteratorValue(type, ii, array[ii]); + }); + }; + + return ArraySeq; +}(IndexedSeq)); + +var ObjectSeq = (function (KeyedSeq) { + function ObjectSeq(object) { + var keys = Object.keys(object); + this._object = object; + this._keys = keys; + this.size = keys.length; + } + + if ( KeyedSeq ) ObjectSeq.__proto__ = KeyedSeq; + ObjectSeq.prototype = Object.create( KeyedSeq && KeyedSeq.prototype ); + ObjectSeq.prototype.constructor = ObjectSeq; + + ObjectSeq.prototype.get = function get (key, notSetValue) { + if (notSetValue !== undefined && !this.has(key)) { + return notSetValue; + } + return this._object[key]; + }; + + ObjectSeq.prototype.has = function has (key) { + return this._object.hasOwnProperty(key); + }; + + ObjectSeq.prototype.__iterate = function __iterate (fn, reverse) { + var this$1 = this; + + var object = this._object; + var keys = this._keys; + var size = keys.length; + var i = 0; + while (i !== size) { + var key = keys[reverse ? size - ++i : i++]; + if (fn(object[key], key, this$1) === false) { + break; + } + } + return i; + }; + + ObjectSeq.prototype.__iterator = function __iterator (type, reverse) { + var object = this._object; + var keys = this._keys; + var size = keys.length; + var i = 0; + return new Iterator(function () { + if (i === size) { + return iteratorDone(); + } + var key = keys[reverse ? size - ++i : i++]; + return iteratorValue(type, key, object[key]); + }); + }; + + return ObjectSeq; +}(KeyedSeq)); +ObjectSeq.prototype[IS_ORDERED_SENTINEL] = true; + +var CollectionSeq = (function (IndexedSeq) { + function CollectionSeq(collection) { + this._collection = collection; + this.size = collection.length || collection.size; + } + + if ( IndexedSeq ) CollectionSeq.__proto__ = IndexedSeq; + CollectionSeq.prototype = Object.create( IndexedSeq && IndexedSeq.prototype ); + CollectionSeq.prototype.constructor = CollectionSeq; + + CollectionSeq.prototype.__iterateUncached = function __iterateUncached (fn, reverse) { + var this$1 = this; + + if (reverse) { + return this.cacheResult().__iterate(fn, reverse); + } + var collection = this._collection; + var iterator = getIterator(collection); + var iterations = 0; + if (isIterator(iterator)) { + var step; + while (!(step = iterator.next()).done) { + if (fn(step.value, iterations++, this$1) === false) { + break; + } + } + } + return iterations; + }; + + CollectionSeq.prototype.__iteratorUncached = function __iteratorUncached (type, reverse) { + if (reverse) { + return this.cacheResult().__iterator(type, reverse); + } + var collection = this._collection; + var iterator = getIterator(collection); + if (!isIterator(iterator)) { + return new Iterator(iteratorDone); + } + var iterations = 0; + return new Iterator(function () { + var step = iterator.next(); + return step.done ? step : iteratorValue(type, iterations++, step.value); + }); + }; + + return CollectionSeq; +}(IndexedSeq)); + +var IteratorSeq = (function (IndexedSeq) { + function IteratorSeq(iterator) { + this._iterator = iterator; + this._iteratorCache = []; + } + + if ( IndexedSeq ) IteratorSeq.__proto__ = IndexedSeq; + IteratorSeq.prototype = Object.create( IndexedSeq && IndexedSeq.prototype ); + IteratorSeq.prototype.constructor = IteratorSeq; + + IteratorSeq.prototype.__iterateUncached = function __iterateUncached (fn, reverse) { + var this$1 = this; + + if (reverse) { + return this.cacheResult().__iterate(fn, reverse); + } + var iterator = this._iterator; + var cache = this._iteratorCache; + var iterations = 0; + while (iterations < cache.length) { + if (fn(cache[iterations], iterations++, this$1) === false) { + return iterations; + } + } + var step; + while (!(step = iterator.next()).done) { + var val = step.value; + cache[iterations] = val; + if (fn(val, iterations++, this$1) === false) { + break; + } + } + return iterations; + }; + + IteratorSeq.prototype.__iteratorUncached = function __iteratorUncached (type, reverse) { + if (reverse) { + return this.cacheResult().__iterator(type, reverse); + } + var iterator = this._iterator; + var cache = this._iteratorCache; + var iterations = 0; + return new Iterator(function () { + if (iterations >= cache.length) { + var step = iterator.next(); + if (step.done) { + return step; + } + cache[iterations] = step.value; + } + return iteratorValue(type, iterations, cache[iterations++]); + }); + }; + + return IteratorSeq; +}(IndexedSeq)); + +// # pragma Helper functions + +function isSeq(maybeSeq) { + return !!(maybeSeq && maybeSeq[IS_SEQ_SENTINEL]); +} + +var EMPTY_SEQ; + +function emptySequence() { + return EMPTY_SEQ || (EMPTY_SEQ = new ArraySeq([])); +} + +function keyedSeqFromValue(value) { + var seq = Array.isArray(value) + ? new ArraySeq(value) + : isIterator(value) + ? new IteratorSeq(value) + : hasIterator(value) ? new CollectionSeq(value) : undefined; + if (seq) { + return seq.fromEntrySeq(); + } + if (typeof value === 'object') { + return new ObjectSeq(value); + } + throw new TypeError( + 'Expected Array or collection object of [k, v] entries, or keyed object: ' + + value + ); +} + +function indexedSeqFromValue(value) { + var seq = maybeIndexedSeqFromValue(value); + if (seq) { + return seq; + } + throw new TypeError( + 'Expected Array or collection object of values: ' + value + ); +} + +function seqFromValue(value) { + var seq = maybeIndexedSeqFromValue(value); + if (seq) { + return seq; + } + if (typeof value === 'object') { + return new ObjectSeq(value); + } + throw new TypeError( + 'Expected Array or collection object of values, or keyed object: ' + value + ); +} + +function maybeIndexedSeqFromValue(value) { + return isArrayLike(value) + ? new ArraySeq(value) + : isIterator(value) + ? new IteratorSeq(value) + : hasIterator(value) ? new CollectionSeq(value) : undefined; +} + +/** + * An extension of the "same-value" algorithm as [described for use by ES6 Map + * and Set](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map#Key_equality) + * + * NaN is considered the same as NaN, however -0 and 0 are considered the same + * value, which is different from the algorithm described by + * [`Object.is`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is). + * + * This is extended further to allow Objects to describe the values they + * represent, by way of `valueOf` or `equals` (and `hashCode`). + * + * Note: because of this extension, the key equality of Immutable.Map and the + * value equality of Immutable.Set will differ from ES6 Map and Set. + * + * ### Defining custom values + * + * The easiest way to describe the value an object represents is by implementing + * `valueOf`. For example, `Date` represents a value by returning a unix + * timestamp for `valueOf`: + * + * var date1 = new Date(1234567890000); // Fri Feb 13 2009 ... + * var date2 = new Date(1234567890000); + * date1.valueOf(); // 1234567890000 + * assert( date1 !== date2 ); + * assert( Immutable.is( date1, date2 ) ); + * + * Note: overriding `valueOf` may have other implications if you use this object + * where JavaScript expects a primitive, such as implicit string coercion. + * + * For more complex types, especially collections, implementing `valueOf` may + * not be performant. An alternative is to implement `equals` and `hashCode`. + * + * `equals` takes another object, presumably of similar type, and returns true + * if it is equal. Equality is symmetrical, so the same result should be + * returned if this and the argument are flipped. + * + * assert( a.equals(b) === b.equals(a) ); + * + * `hashCode` returns a 32bit integer number representing the object which will + * be used to determine how to store the value object in a Map or Set. You must + * provide both or neither methods, one must not exist without the other. + * + * Also, an important relationship between these methods must be upheld: if two + * values are equal, they *must* return the same hashCode. If the values are not + * equal, they might have the same hashCode; this is called a hash collision, + * and while undesirable for performance reasons, it is acceptable. + * + * if (a.equals(b)) { + * assert( a.hashCode() === b.hashCode() ); + * } + * + * All Immutable collections are Value Objects: they implement `equals()` + * and `hashCode()`. + */ +function is(valueA, valueB) { + if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) { + return true; + } + if (!valueA || !valueB) { + return false; + } + if ( + typeof valueA.valueOf === 'function' && typeof valueB.valueOf === 'function' + ) { + valueA = valueA.valueOf(); + valueB = valueB.valueOf(); + if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) { + return true; + } + if (!valueA || !valueB) { + return false; + } + } + return !!(isValueObject(valueA) && + isValueObject(valueB) && + valueA.equals(valueB)); +} + +function fromJS(value, converter) { + return fromJSWith( + [], + converter || defaultConverter, + value, + '', + converter && converter.length > 2 ? [] : undefined, + { '': value } + ); +} + +function fromJSWith(stack, converter, value, key, keyPath, parentValue) { + var toSeq = Array.isArray(value) + ? IndexedSeq + : isPlainObj(value) ? KeyedSeq : null; + if (toSeq) { + if (~stack.indexOf(value)) { + throw new TypeError('Cannot convert circular structure to Immutable'); + } + stack.push(value); + keyPath && key !== '' && keyPath.push(key); + var converted = converter.call( + parentValue, + key, + toSeq(value).map(function (v, k) { return fromJSWith(stack, converter, v, k, keyPath, value); }), + keyPath && keyPath.slice() + ); + stack.pop(); + keyPath && keyPath.pop(); + return converted; + } + return value; +} + +function defaultConverter(k, v) { + return isKeyed(v) ? v.toMap() : v.toList(); +} + +function isPlainObj(value) { + return value && + (value.constructor === Object || value.constructor === undefined); +} + +var imul = typeof Math.imul === 'function' && + Math.imul(0xffffffff, 2) === -2 + ? Math.imul + : function imul(a, b) { + a |= 0; // int + b |= 0; // int + var c = a & 0xffff; + var d = b & 0xffff; + // Shift by 0 fixes the sign on the high part. + return c * d + ((a >>> 16) * d + c * (b >>> 16) << 16 >>> 0) | 0; // int + }; + +// v8 has an optimization for storing 31-bit signed numbers. +// Values which have either 00 or 11 as the high order bits qualify. +// This function drops the highest order bit in a signed number, maintaining +// the sign bit. +function smi(i32) { + return i32 >>> 1 & 0x40000000 | i32 & 0xbfffffff; +} + +function hash(o) { + if (o === false || o === null || o === undefined) { + return 0; + } + if (typeof o.valueOf === 'function') { + o = o.valueOf(); + if (o === false || o === null || o === undefined) { + return 0; + } + } + if (o === true) { + return 1; + } + var type = typeof o; + if (type === 'number') { + if (o !== o || o === Infinity) { + return 0; + } + var h = o | 0; + if (h !== o) { + h ^= o * 0xffffffff; + } + while (o > 0xffffffff) { + o /= 0xffffffff; + h ^= o; + } + return smi(h); + } + if (type === 'string') { + return o.length > STRING_HASH_CACHE_MIN_STRLEN + ? cachedHashString(o) + : hashString(o); + } + if (typeof o.hashCode === 'function') { + // Drop any high bits from accidentally long hash codes. + return smi(o.hashCode()); + } + if (type === 'object') { + return hashJSObj(o); + } + if (typeof o.toString === 'function') { + return hashString(o.toString()); + } + throw new Error('Value type ' + type + ' cannot be hashed.'); +} + +function cachedHashString(string) { + var hashed = stringHashCache[string]; + if (hashed === undefined) { + hashed = hashString(string); + if (STRING_HASH_CACHE_SIZE === STRING_HASH_CACHE_MAX_SIZE) { + STRING_HASH_CACHE_SIZE = 0; + stringHashCache = {}; + } + STRING_HASH_CACHE_SIZE++; + stringHashCache[string] = hashed; + } + return hashed; +} + +// http://jsperf.com/hashing-strings +function hashString(string) { + // This is the hash from JVM + // The hash code for a string is computed as + // s[0] * 31 ^ (n - 1) + s[1] * 31 ^ (n - 2) + ... + s[n - 1], + // where s[i] is the ith character of the string and n is the length of + // the string. We "mod" the result to make it between 0 (inclusive) and 2^31 + // (exclusive) by dropping high bits. + var hashed = 0; + for (var ii = 0; ii < string.length; ii++) { + hashed = 31 * hash + string.charCodeAt(ii) | 0; + } + return smi(hashed); +} + +function hashJSObj(obj) { + var hashed; + if (usingWeakMap) { + hashed = weakMap.get(obj); + if (hashed !== undefined) { + return hashed; + } + } + + hashed = obj[UID_HASH_KEY]; + if (hash !== undefined) { + return hashed; + } + + if (!canDefineProperty) { + hashed = obj.propertyIsEnumerable && obj.propertyIsEnumerable[UID_HASH_KEY]; + if (hashed !== undefined) { + return hashed; + } + + hashed = getIENodeHash(obj); + if (hashed !== undefined) { + return hashed; + } + } + + hashed = ++objHashUID; + if (objHashUID & 0x40000000) { + objHashUID = 0; + } + + if (usingWeakMap) { + weakMap.set(obj, hashed); + } else if (isExtensible !== undefined && isExtensible(obj) === false) { + throw new Error('Non-extensible objects are not allowed as keys.'); + } else if (canDefineProperty) { + Object.defineProperty(obj, UID_HASH_KEY, { + enumerable: false, + configurable: false, + writable: false, + value: hashed + }); + } else if ( + obj.propertyIsEnumerable !== undefined && + obj.propertyIsEnumerable === obj.constructor.prototype.propertyIsEnumerable + ) { + // Since we can't define a non-enumerable property on the object + // we'll hijack one of the less-used non-enumerable properties to + // save our hash on it. Since this is a function it will not show up in + // `JSON.stringify` which is what we want. + obj.propertyIsEnumerable = function() { + return this.constructor.prototype.propertyIsEnumerable.apply( + this, + arguments + ); + }; + obj.propertyIsEnumerable[UID_HASH_KEY] = hashed; + } else if (obj.nodeType !== undefined) { + // At this point we couldn't get the IE `uniqueID` to use as a hash + // and we couldn't use a non-enumerable property to exploit the + // dontEnum bug so we simply add the `UID_HASH_KEY` on the node + // itself. + obj[UID_HASH_KEY] = hashed; + } else { + throw new Error('Unable to set a non-enumerable property on object.'); + } + + return hashed; +} + +// Get references to ES5 object methods. +var isExtensible = Object.isExtensible; + +// True if Object.defineProperty works as expected. IE8 fails this test. +var canDefineProperty = (function() { + try { + Object.defineProperty({}, '@', {}); + return true; + } catch (e) { + return false; + } +})(); + +// IE has a `uniqueID` property on DOM nodes. We can construct the hash from it +// and avoid memory leaks from the IE cloneNode bug. +function getIENodeHash(node) { + if (node && node.nodeType > 0) { + switch (node.nodeType) { + case 1: // Element + return node.uniqueID; + case 9: // Document + return node.documentElement && node.documentElement.uniqueID; + } + } +} + +// If possible, use a WeakMap. +var usingWeakMap = typeof WeakMap === 'function'; +var weakMap; +if (usingWeakMap) { + weakMap = new WeakMap(); +} + +var objHashUID = 0; + +var UID_HASH_KEY = '__immutablehash__'; +if (typeof Symbol === 'function') { + UID_HASH_KEY = Symbol(UID_HASH_KEY); +} + +var STRING_HASH_CACHE_MIN_STRLEN = 16; +var STRING_HASH_CACHE_MAX_SIZE = 255; +var STRING_HASH_CACHE_SIZE = 0; +var stringHashCache = {}; + +var ToKeyedSequence = (function (KeyedSeq$$1) { + function ToKeyedSequence(indexed, useKeys) { + this._iter = indexed; + this._useKeys = useKeys; + this.size = indexed.size; + } + + if ( KeyedSeq$$1 ) ToKeyedSequence.__proto__ = KeyedSeq$$1; + ToKeyedSequence.prototype = Object.create( KeyedSeq$$1 && KeyedSeq$$1.prototype ); + ToKeyedSequence.prototype.constructor = ToKeyedSequence; + + ToKeyedSequence.prototype.get = function get (key, notSetValue) { + return this._iter.get(key, notSetValue); + }; + + ToKeyedSequence.prototype.has = function has (key) { + return this._iter.has(key); + }; + + ToKeyedSequence.prototype.valueSeq = function valueSeq () { + return this._iter.valueSeq(); + }; + + ToKeyedSequence.prototype.reverse = function reverse () { + var this$1 = this; + + var reversedSequence = reverseFactory(this, true); + if (!this._useKeys) { + reversedSequence.valueSeq = function () { return this$1._iter.toSeq().reverse(); }; + } + return reversedSequence; + }; + + ToKeyedSequence.prototype.map = function map (mapper, context) { + var this$1 = this; + + var mappedSequence = mapFactory(this, mapper, context); + if (!this._useKeys) { + mappedSequence.valueSeq = function () { return this$1._iter.toSeq().map(mapper, context); }; + } + return mappedSequence; + }; + + ToKeyedSequence.prototype.__iterate = function __iterate (fn, reverse) { + var this$1 = this; + + return this._iter.__iterate(function (v, k) { return fn(v, k, this$1); }, reverse); + }; + + ToKeyedSequence.prototype.__iterator = function __iterator (type, reverse) { + return this._iter.__iterator(type, reverse); + }; + + return ToKeyedSequence; +}(KeyedSeq)); +ToKeyedSequence.prototype[IS_ORDERED_SENTINEL] = true; + +var ToIndexedSequence = (function (IndexedSeq$$1) { + function ToIndexedSequence(iter) { + this._iter = iter; + this.size = iter.size; + } + + if ( IndexedSeq$$1 ) ToIndexedSequence.__proto__ = IndexedSeq$$1; + ToIndexedSequence.prototype = Object.create( IndexedSeq$$1 && IndexedSeq$$1.prototype ); + ToIndexedSequence.prototype.constructor = ToIndexedSequence; + + ToIndexedSequence.prototype.includes = function includes (value) { + return this._iter.includes(value); + }; + + ToIndexedSequence.prototype.__iterate = function __iterate (fn, reverse) { + var this$1 = this; + + var i = 0; + reverse && ensureSize(this); + return this._iter.__iterate( + function (v) { return fn(v, reverse ? this$1.size - ++i : i++, this$1); }, + reverse + ); + }; + + ToIndexedSequence.prototype.__iterator = function __iterator (type, reverse) { + var this$1 = this; + + var iterator = this._iter.__iterator(ITERATE_VALUES, reverse); + var i = 0; + reverse && ensureSize(this); + return new Iterator(function () { + var step = iterator.next(); + return step.done + ? step + : iteratorValue( + type, + reverse ? this$1.size - ++i : i++, + step.value, + step + ); + }); + }; + + return ToIndexedSequence; +}(IndexedSeq)); + +var ToSetSequence = (function (SetSeq$$1) { + function ToSetSequence(iter) { + this._iter = iter; + this.size = iter.size; + } + + if ( SetSeq$$1 ) ToSetSequence.__proto__ = SetSeq$$1; + ToSetSequence.prototype = Object.create( SetSeq$$1 && SetSeq$$1.prototype ); + ToSetSequence.prototype.constructor = ToSetSequence; + + ToSetSequence.prototype.has = function has (key) { + return this._iter.includes(key); + }; + + ToSetSequence.prototype.__iterate = function __iterate (fn, reverse) { + var this$1 = this; + + return this._iter.__iterate(function (v) { return fn(v, v, this$1); }, reverse); + }; + + ToSetSequence.prototype.__iterator = function __iterator (type, reverse) { + var iterator = this._iter.__iterator(ITERATE_VALUES, reverse); + return new Iterator(function () { + var step = iterator.next(); + return step.done + ? step + : iteratorValue(type, step.value, step.value, step); + }); + }; + + return ToSetSequence; +}(SetSeq)); + +var FromEntriesSequence = (function (KeyedSeq$$1) { + function FromEntriesSequence(entries) { + this._iter = entries; + this.size = entries.size; + } + + if ( KeyedSeq$$1 ) FromEntriesSequence.__proto__ = KeyedSeq$$1; + FromEntriesSequence.prototype = Object.create( KeyedSeq$$1 && KeyedSeq$$1.prototype ); + FromEntriesSequence.prototype.constructor = FromEntriesSequence; + + FromEntriesSequence.prototype.entrySeq = function entrySeq () { + return this._iter.toSeq(); + }; + + FromEntriesSequence.prototype.__iterate = function __iterate (fn, reverse) { + var this$1 = this; + + return this._iter.__iterate( + function (entry) { + // Check if entry exists first so array access doesn't throw for holes + // in the parent iteration. + if (entry) { + validateEntry(entry); + var indexedCollection = isCollection(entry); + return fn( + indexedCollection ? entry.get(1) : entry[1], + indexedCollection ? entry.get(0) : entry[0], + this$1 + ); + } + }, + reverse + ); + }; + + FromEntriesSequence.prototype.__iterator = function __iterator (type, reverse) { + var iterator = this._iter.__iterator(ITERATE_VALUES, reverse); + return new Iterator(function () { + while (true) { + var step = iterator.next(); + if (step.done) { + return step; + } + var entry = step.value; + // Check if entry exists first so array access doesn't throw for holes + // in the parent iteration. + if (entry) { + validateEntry(entry); + var indexedCollection = isCollection(entry); + return iteratorValue( + type, + indexedCollection ? entry.get(0) : entry[0], + indexedCollection ? entry.get(1) : entry[1], + step + ); + } + } + }); + }; + + return FromEntriesSequence; +}(KeyedSeq)); + +ToIndexedSequence.prototype.cacheResult = (ToKeyedSequence.prototype.cacheResult = (ToSetSequence.prototype.cacheResult = (FromEntriesSequence.prototype.cacheResult = cacheResultThrough))); + +function flipFactory(collection) { + var flipSequence = makeSequence(collection); + flipSequence._iter = collection; + flipSequence.size = collection.size; + flipSequence.flip = function () { return collection; }; + flipSequence.reverse = function() { + var reversedSequence = collection.reverse.apply(this); // super.reverse() + reversedSequence.flip = function () { return collection.reverse(); }; + return reversedSequence; + }; + flipSequence.has = function (key) { return collection.includes(key); }; + flipSequence.includes = function (key) { return collection.has(key); }; + flipSequence.cacheResult = cacheResultThrough; + flipSequence.__iterateUncached = function(fn, reverse) { + var this$1 = this; + + return collection.__iterate(function (v, k) { return fn(k, v, this$1) !== false; }, reverse); + }; + flipSequence.__iteratorUncached = function(type, reverse) { + if (type === ITERATE_ENTRIES) { + var iterator = collection.__iterator(type, reverse); + return new Iterator(function () { + var step = iterator.next(); + if (!step.done) { + var k = step.value[0]; + step.value[0] = step.value[1]; + step.value[1] = k; + } + return step; + }); + } + return collection.__iterator( + type === ITERATE_VALUES ? ITERATE_KEYS : ITERATE_VALUES, + reverse + ); + }; + return flipSequence; +} + +function mapFactory(collection, mapper, context) { + var mappedSequence = makeSequence(collection); + mappedSequence.size = collection.size; + mappedSequence.has = function (key) { return collection.has(key); }; + mappedSequence.get = function (key, notSetValue) { + var v = collection.get(key, NOT_SET); + return v === NOT_SET + ? notSetValue + : mapper.call(context, v, key, collection); + }; + mappedSequence.__iterateUncached = function(fn, reverse) { + var this$1 = this; + + return collection.__iterate( + function (v, k, c) { return fn(mapper.call(context, v, k, c), k, this$1) !== false; }, + reverse + ); + }; + mappedSequence.__iteratorUncached = function(type, reverse) { + var iterator = collection.__iterator(ITERATE_ENTRIES, reverse); + return new Iterator(function () { + var step = iterator.next(); + if (step.done) { + return step; + } + var entry = step.value; + var key = entry[0]; + return iteratorValue( + type, + key, + mapper.call(context, entry[1], key, collection), + step + ); + }); + }; + return mappedSequence; +} + +function reverseFactory(collection, useKeys) { + var this$1 = this; + + var reversedSequence = makeSequence(collection); + reversedSequence._iter = collection; + reversedSequence.size = collection.size; + reversedSequence.reverse = function () { return collection; }; + if (collection.flip) { + reversedSequence.flip = function() { + var flipSequence = flipFactory(collection); + flipSequence.reverse = function () { return collection.flip(); }; + return flipSequence; + }; + } + reversedSequence.get = function (key, notSetValue) { return collection.get(useKeys ? key : -1 - key, notSetValue); }; + reversedSequence.has = function (key) { return collection.has(useKeys ? key : -1 - key); }; + reversedSequence.includes = function (value) { return collection.includes(value); }; + reversedSequence.cacheResult = cacheResultThrough; + reversedSequence.__iterate = function(fn, reverse) { + var this$1 = this; + + var i = 0; + reverse && ensureSize(collection); + return collection.__iterate( + function (v, k) { return fn(v, useKeys ? k : reverse ? this$1.size - ++i : i++, this$1); }, + !reverse + ); + }; + reversedSequence.__iterator = function (type, reverse) { + var i = 0; + reverse && ensureSize(collection); + var iterator = collection.__iterator(ITERATE_ENTRIES, !reverse); + return new Iterator(function () { + var step = iterator.next(); + if (step.done) { + return step; + } + var entry = step.value; + return iteratorValue( + type, + useKeys ? entry[0] : reverse ? this$1.size - ++i : i++, + entry[1], + step + ); + }); + }; + return reversedSequence; +} + +function filterFactory(collection, predicate, context, useKeys) { + var filterSequence = makeSequence(collection); + if (useKeys) { + filterSequence.has = function (key) { + var v = collection.get(key, NOT_SET); + return v !== NOT_SET && !!predicate.call(context, v, key, collection); + }; + filterSequence.get = function (key, notSetValue) { + var v = collection.get(key, NOT_SET); + return v !== NOT_SET && predicate.call(context, v, key, collection) + ? v + : notSetValue; + }; + } + filterSequence.__iterateUncached = function(fn, reverse) { + var this$1 = this; + + var iterations = 0; + collection.__iterate( + function (v, k, c) { + if (predicate.call(context, v, k, c)) { + iterations++; + return fn(v, useKeys ? k : iterations - 1, this$1); + } + }, + reverse + ); + return iterations; + }; + filterSequence.__iteratorUncached = function(type, reverse) { + var iterator = collection.__iterator(ITERATE_ENTRIES, reverse); + var iterations = 0; + return new Iterator(function () { + while (true) { + var step = iterator.next(); + if (step.done) { + return step; + } + var entry = step.value; + var key = entry[0]; + var value = entry[1]; + if (predicate.call(context, value, key, collection)) { + return iteratorValue(type, useKeys ? key : iterations++, value, step); + } + } + }); + }; + return filterSequence; +} + +function countByFactory(collection, grouper, context) { + var groups = Map().asMutable(); + collection.__iterate(function (v, k) { + groups.update(grouper.call(context, v, k, collection), 0, function (a) { return a + 1; }); + }); + return groups.asImmutable(); +} + +function groupByFactory(collection, grouper, context) { + var isKeyedIter = isKeyed(collection); + var groups = (isOrdered(collection) ? OrderedMap() : Map()).asMutable(); + collection.__iterate(function (v, k) { + groups.update( + grouper.call(context, v, k, collection), + function (a) { return ((a = a || []), a.push(isKeyedIter ? [k, v] : v), a); } + ); + }); + var coerce = collectionClass(collection); + return groups.map(function (arr) { return reify(collection, coerce(arr)); }); +} + +function sliceFactory(collection, begin, end, useKeys) { + var originalSize = collection.size; + + if (wholeSlice(begin, end, originalSize)) { + return collection; + } + + var resolvedBegin = resolveBegin(begin, originalSize); + var resolvedEnd = resolveEnd(end, originalSize); + + // begin or end will be NaN if they were provided as negative numbers and + // this collection's size is unknown. In that case, cache first so there is + // a known size and these do not resolve to NaN. + if (resolvedBegin !== resolvedBegin || resolvedEnd !== resolvedEnd) { + return sliceFactory(collection.toSeq().cacheResult(), begin, end, useKeys); + } + + // Note: resolvedEnd is undefined when the original sequence's length is + // unknown and this slice did not supply an end and should contain all + // elements after resolvedBegin. + // In that case, resolvedSize will be NaN and sliceSize will remain undefined. + var resolvedSize = resolvedEnd - resolvedBegin; + var sliceSize; + if (resolvedSize === resolvedSize) { + sliceSize = resolvedSize < 0 ? 0 : resolvedSize; + } + + var sliceSeq = makeSequence(collection); + + // If collection.size is undefined, the size of the realized sliceSeq is + // unknown at this point unless the number of items to slice is 0 + sliceSeq.size = sliceSize === 0 + ? sliceSize + : (collection.size && sliceSize) || undefined; + + if (!useKeys && isSeq(collection) && sliceSize >= 0) { + sliceSeq.get = function(index, notSetValue) { + index = wrapIndex(this, index); + return index >= 0 && index < sliceSize + ? collection.get(index + resolvedBegin, notSetValue) + : notSetValue; + }; + } + + sliceSeq.__iterateUncached = function(fn, reverse) { + var this$1 = this; + + if (sliceSize === 0) { + return 0; + } + if (reverse) { + return this.cacheResult().__iterate(fn, reverse); + } + var skipped = 0; + var isSkipping = true; + var iterations = 0; + collection.__iterate(function (v, k) { + if (!(isSkipping && (isSkipping = skipped++ < resolvedBegin))) { + iterations++; + return fn(v, useKeys ? k : iterations - 1, this$1) !== false && + iterations !== sliceSize; + } + }); + return iterations; + }; + + sliceSeq.__iteratorUncached = function(type, reverse) { + if (sliceSize !== 0 && reverse) { + return this.cacheResult().__iterator(type, reverse); + } + // Don't bother instantiating parent iterator if taking 0. + if (sliceSize === 0) { + return new Iterator(iteratorDone); + } + var iterator = collection.__iterator(type, reverse); + var skipped = 0; + var iterations = 0; + return new Iterator(function () { + while (skipped++ < resolvedBegin) { + iterator.next(); + } + if (++iterations > sliceSize) { + return iteratorDone(); + } + var step = iterator.next(); + if (useKeys || type === ITERATE_VALUES) { + return step; + } + if (type === ITERATE_KEYS) { + return iteratorValue(type, iterations - 1, undefined, step); + } + return iteratorValue(type, iterations - 1, step.value[1], step); + }); + }; + + return sliceSeq; +} + +function takeWhileFactory(collection, predicate, context) { + var takeSequence = makeSequence(collection); + takeSequence.__iterateUncached = function(fn, reverse) { + var this$1 = this; + + if (reverse) { + return this.cacheResult().__iterate(fn, reverse); + } + var iterations = 0; + collection.__iterate( + function (v, k, c) { return predicate.call(context, v, k, c) && ++iterations && fn(v, k, this$1); } + ); + return iterations; + }; + takeSequence.__iteratorUncached = function(type, reverse) { + var this$1 = this; + + if (reverse) { + return this.cacheResult().__iterator(type, reverse); + } + var iterator = collection.__iterator(ITERATE_ENTRIES, reverse); + var iterating = true; + return new Iterator(function () { + if (!iterating) { + return iteratorDone(); + } + var step = iterator.next(); + if (step.done) { + return step; + } + var entry = step.value; + var k = entry[0]; + var v = entry[1]; + if (!predicate.call(context, v, k, this$1)) { + iterating = false; + return iteratorDone(); + } + return type === ITERATE_ENTRIES ? step : iteratorValue(type, k, v, step); + }); + }; + return takeSequence; +} + +function skipWhileFactory(collection, predicate, context, useKeys) { + var skipSequence = makeSequence(collection); + skipSequence.__iterateUncached = function(fn, reverse) { + var this$1 = this; + + if (reverse) { + return this.cacheResult().__iterate(fn, reverse); + } + var isSkipping = true; + var iterations = 0; + collection.__iterate(function (v, k, c) { + if (!(isSkipping && (isSkipping = predicate.call(context, v, k, c)))) { + iterations++; + return fn(v, useKeys ? k : iterations - 1, this$1); + } + }); + return iterations; + }; + skipSequence.__iteratorUncached = function(type, reverse) { + var this$1 = this; + + if (reverse) { + return this.cacheResult().__iterator(type, reverse); + } + var iterator = collection.__iterator(ITERATE_ENTRIES, reverse); + var skipping = true; + var iterations = 0; + return new Iterator(function () { + var step; + var k; + var v; + do { + step = iterator.next(); + if (step.done) { + if (useKeys || type === ITERATE_VALUES) { + return step; + } + if (type === ITERATE_KEYS) { + return iteratorValue(type, iterations++, undefined, step); + } + return iteratorValue(type, iterations++, step.value[1], step); + } + var entry = step.value; + k = entry[0]; + v = entry[1]; + skipping && (skipping = predicate.call(context, v, k, this$1)); + } while (skipping); + return type === ITERATE_ENTRIES ? step : iteratorValue(type, k, v, step); + }); + }; + return skipSequence; +} + +function concatFactory(collection, values) { + var isKeyedCollection = isKeyed(collection); + var iters = [collection] + .concat(values) + .map(function (v) { + if (!isCollection(v)) { + v = isKeyedCollection + ? keyedSeqFromValue(v) + : indexedSeqFromValue(Array.isArray(v) ? v : [v]); + } else if (isKeyedCollection) { + v = KeyedCollection(v); + } + return v; + }) + .filter(function (v) { return v.size !== 0; }); + + if (iters.length === 0) { + return collection; + } + + if (iters.length === 1) { + var singleton = iters[0]; + if ( + singleton === collection || + (isKeyedCollection && isKeyed(singleton)) || + (isIndexed(collection) && isIndexed(singleton)) + ) { + return singleton; + } + } + + var concatSeq = new ArraySeq(iters); + if (isKeyedCollection) { + concatSeq = concatSeq.toKeyedSeq(); + } else if (!isIndexed(collection)) { + concatSeq = concatSeq.toSetSeq(); + } + concatSeq = concatSeq.flatten(true); + concatSeq.size = iters.reduce( + function (sum, seq) { + if (sum !== undefined) { + var size = seq.size; + if (size !== undefined) { + return sum + size; + } + } + }, + 0 + ); + return concatSeq; +} + +function flattenFactory(collection, depth, useKeys) { + var flatSequence = makeSequence(collection); + flatSequence.__iterateUncached = function(fn, reverse) { + if (reverse) { + return this.cacheResult().__iterate(fn, reverse); + } + var iterations = 0; + var stopped = false; + function flatDeep(iter, currentDepth) { + iter.__iterate( + function (v, k) { + if ((!depth || currentDepth < depth) && isCollection(v)) { + flatDeep(v, currentDepth + 1); + } else { + iterations++; + if (fn(v, useKeys ? k : iterations - 1, flatSequence) === false) { + stopped = true; + } + } + return !stopped; + }, + reverse + ); + } + flatDeep(collection, 0); + return iterations; + }; + flatSequence.__iteratorUncached = function(type, reverse) { + if (reverse) { + return this.cacheResult().__iterator(type, reverse); + } + var iterator = collection.__iterator(type, reverse); + var stack = []; + var iterations = 0; + return new Iterator(function () { + while (iterator) { + var step = iterator.next(); + if (step.done !== false) { + iterator = stack.pop(); + continue; + } + var v = step.value; + if (type === ITERATE_ENTRIES) { + v = v[1]; + } + if ((!depth || stack.length < depth) && isCollection(v)) { + stack.push(iterator); + iterator = v.__iterator(type, reverse); + } else { + return useKeys ? step : iteratorValue(type, iterations++, v, step); + } + } + return iteratorDone(); + }); + }; + return flatSequence; +} + +function flatMapFactory(collection, mapper, context) { + var coerce = collectionClass(collection); + return collection + .toSeq() + .map(function (v, k) { return coerce(mapper.call(context, v, k, collection)); }) + .flatten(true); +} + +function interposeFactory(collection, separator) { + var interposedSequence = makeSequence(collection); + interposedSequence.size = collection.size && collection.size * 2 - 1; + interposedSequence.__iterateUncached = function(fn, reverse) { + var this$1 = this; + + var iterations = 0; + collection.__iterate( + function (v) { return (!iterations || fn(separator, iterations++, this$1) !== false) && + fn(v, iterations++, this$1) !== false; }, + reverse + ); + return iterations; + }; + interposedSequence.__iteratorUncached = function(type, reverse) { + var iterator = collection.__iterator(ITERATE_VALUES, reverse); + var iterations = 0; + var step; + return new Iterator(function () { + if (!step || iterations % 2) { + step = iterator.next(); + if (step.done) { + return step; + } + } + return iterations % 2 + ? iteratorValue(type, iterations++, separator) + : iteratorValue(type, iterations++, step.value, step); + }); + }; + return interposedSequence; +} + +function sortFactory(collection, comparator, mapper) { + if (!comparator) { + comparator = defaultComparator; + } + var isKeyedCollection = isKeyed(collection); + var index = 0; + var entries = collection + .toSeq() + .map(function (v, k) { return [k, v, index++, mapper ? mapper(v, k, collection) : v]; }) + .toArray(); + entries.sort(function (a, b) { return comparator(a[3], b[3]) || a[2] - b[2]; }).forEach( + isKeyedCollection + ? function (v, i) { + entries[i].length = 2; + } + : function (v, i) { + entries[i] = v[1]; + } + ); + return isKeyedCollection + ? KeyedSeq(entries) + : isIndexed(collection) ? IndexedSeq(entries) : SetSeq(entries); +} + +function maxFactory(collection, comparator, mapper) { + if (!comparator) { + comparator = defaultComparator; + } + if (mapper) { + var entry = collection + .toSeq() + .map(function (v, k) { return [v, mapper(v, k, collection)]; }) + .reduce(function (a, b) { return maxCompare(comparator, a[1], b[1]) ? b : a; }); + return entry && entry[0]; + } + return collection.reduce(function (a, b) { return maxCompare(comparator, a, b) ? b : a; }); +} + +function maxCompare(comparator, a, b) { + var comp = comparator(b, a); + // b is considered the new max if the comparator declares them equal, but + // they are not equal and b is in fact a nullish value. + return (comp === 0 && + b !== a && + (b === undefined || b === null || b !== b)) || + comp > 0; +} + +function zipWithFactory(keyIter, zipper, iters) { + var zipSequence = makeSequence(keyIter); + zipSequence.size = new ArraySeq(iters).map(function (i) { return i.size; }).min(); + // Note: this a generic base implementation of __iterate in terms of + // __iterator which may be more generically useful in the future. + zipSequence.__iterate = function(fn, reverse) { + var this$1 = this; + + /* generic: + var iterator = this.__iterator(ITERATE_ENTRIES, reverse); + var step; + var iterations = 0; + while (!(step = iterator.next()).done) { + iterations++; + if (fn(step.value[1], step.value[0], this) === false) { + break; + } + } + return iterations; + */ + // indexed: + var iterator = this.__iterator(ITERATE_VALUES, reverse); + var step; + var iterations = 0; + while (!(step = iterator.next()).done) { + if (fn(step.value, iterations++, this$1) === false) { + break; + } + } + return iterations; + }; + zipSequence.__iteratorUncached = function(type, reverse) { + var iterators = iters.map( + function (i) { return ((i = Collection(i)), getIterator(reverse ? i.reverse() : i)); } + ); + var iterations = 0; + var isDone = false; + return new Iterator(function () { + var steps; + if (!isDone) { + steps = iterators.map(function (i) { return i.next(); }); + isDone = steps.some(function (s) { return s.done; }); + } + if (isDone) { + return iteratorDone(); + } + return iteratorValue( + type, + iterations++, + zipper.apply(null, steps.map(function (s) { return s.value; })) + ); + }); + }; + return zipSequence; +} + +// #pragma Helper Functions + +function reify(iter, seq) { + return iter === seq ? iter : isSeq(iter) ? seq : iter.constructor(seq); +} + +function validateEntry(entry) { + if (entry !== Object(entry)) { + throw new TypeError('Expected [K, V] tuple: ' + entry); + } +} + +function collectionClass(collection) { + return isKeyed(collection) + ? KeyedCollection + : isIndexed(collection) ? IndexedCollection : SetCollection; +} + +function makeSequence(collection) { + return Object.create( + (isKeyed(collection) + ? KeyedSeq + : isIndexed(collection) ? IndexedSeq : SetSeq).prototype + ); +} + +function cacheResultThrough() { + if (this._iter.cacheResult) { + this._iter.cacheResult(); + this.size = this._iter.size; + return this; + } + return Seq.prototype.cacheResult.call(this); +} + +function defaultComparator(a, b) { + if (a === undefined && b === undefined) { + return 0; + } + + if (a === undefined) { + return 1; + } + + if (b === undefined) { + return -1; + } + + return a > b ? 1 : a < b ? -1 : 0; +} + +function coerceKeyPath(keyPath) { + if (isArrayLike(keyPath) && typeof keyPath !== 'string') { + return keyPath; + } + if (isOrdered(keyPath)) { + return keyPath.toArray(); + } + throw new TypeError( + 'Invalid keyPath: expected Ordered Collection or Array: ' + keyPath + ); +} + +function invariant(condition, error) { + if (!condition) { throw new Error(error); } +} + +function assertNotInfinite(size) { + invariant( + size !== Infinity, + 'Cannot perform this action with an infinite size.' + ); +} + +/** + * Converts a value to a string, adding quotes if a string was provided. + */ +function quoteString(value) { + return typeof value === 'string' ? JSON.stringify(value) : String(value); +} + +var Map = (function (KeyedCollection$$1) { + function Map(value) { + return value === null || value === undefined + ? emptyMap() + : isMap(value) && !isOrdered(value) + ? value + : emptyMap().withMutations(function (map) { + var iter = KeyedCollection$$1(value); + assertNotInfinite(iter.size); + iter.forEach(function (v, k) { return map.set(k, v); }); + }); + } + + if ( KeyedCollection$$1 ) Map.__proto__ = KeyedCollection$$1; + Map.prototype = Object.create( KeyedCollection$$1 && KeyedCollection$$1.prototype ); + Map.prototype.constructor = Map; + + Map.of = function of () { + var keyValues = [], len = arguments.length; + while ( len-- ) keyValues[ len ] = arguments[ len ]; + + return emptyMap().withMutations(function (map) { + for (var i = 0; i < keyValues.length; i += 2) { + if (i + 1 >= keyValues.length) { + throw new Error('Missing value for key: ' + keyValues[i]); + } + map.set(keyValues[i], keyValues[i + 1]); + } + }); + }; + + Map.prototype.toString = function toString () { + return this.__toString('Map {', '}'); + }; + + // @pragma Access + + Map.prototype.get = function get (k, notSetValue) { + return this._root + ? this._root.get(0, undefined, k, notSetValue) + : notSetValue; + }; + + // @pragma Modification + + Map.prototype.set = function set (k, v) { + return updateMap(this, k, v); + }; + + Map.prototype.setIn = function setIn (keyPath, v) { + return this.updateIn(keyPath, NOT_SET, function () { return v; }); + }; + + Map.prototype.remove = function remove (k) { + return updateMap(this, k, NOT_SET); + }; + + Map.prototype.deleteIn = function deleteIn (keyPath) { + keyPath = [].concat( coerceKeyPath(keyPath) ); + if (keyPath.length) { + var lastKey = keyPath.pop(); + return this.updateIn(keyPath, function (c) { return c && c.remove(lastKey); }); + } + }; + + Map.prototype.deleteAll = function deleteAll (keys) { + var collection = Collection(keys); + + if (collection.size === 0) { + return this; + } + + return this.withMutations(function (map) { + collection.forEach(function (key) { return map.remove(key); }); + }); + }; + + Map.prototype.update = function update (k, notSetValue, updater) { + return arguments.length === 1 + ? k(this) + : this.updateIn([k], notSetValue, updater); + }; + + Map.prototype.updateIn = function updateIn (keyPath, notSetValue, updater) { + if (!updater) { + updater = notSetValue; + notSetValue = undefined; + } + var updatedValue = updateInDeepMap( + this, + coerceKeyPath(keyPath), + 0, + notSetValue, + updater + ); + return updatedValue === NOT_SET ? notSetValue : updatedValue; + }; + + Map.prototype.clear = function clear () { + if (this.size === 0) { + return this; + } + if (this.__ownerID) { + this.size = 0; + this._root = null; + this.__hash = undefined; + this.__altered = true; + return this; + } + return emptyMap(); + }; + + // @pragma Composition + + Map.prototype.merge = function merge (/*...iters*/) { + return mergeIntoMapWith(this, undefined, arguments); + }; + + Map.prototype.mergeWith = function mergeWith (merger) { + var iters = [], len = arguments.length - 1; + while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; + + return mergeIntoMapWith(this, merger, iters); + }; + + Map.prototype.mergeIn = function mergeIn (keyPath) { + var iters = [], len = arguments.length - 1; + while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; + + return this.updateIn( + keyPath, + emptyMap(), + function (m) { return typeof m.merge === 'function' + ? m.merge.apply(m, iters) + : iters[iters.length - 1]; } + ); + }; + + Map.prototype.mergeDeep = function mergeDeep (/*...iters*/) { + return mergeIntoMapWith(this, deepMerger, arguments); + }; + + Map.prototype.mergeDeepWith = function mergeDeepWith (merger) { + var iters = [], len = arguments.length - 1; + while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; + + return mergeIntoMapWith(this, deepMergerWith(merger), iters); + }; + + Map.prototype.mergeDeepIn = function mergeDeepIn (keyPath) { + var iters = [], len = arguments.length - 1; + while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; + + return this.updateIn( + keyPath, + emptyMap(), + function (m) { return typeof m.mergeDeep === 'function' + ? m.mergeDeep.apply(m, iters) + : iters[iters.length - 1]; } + ); + }; + + Map.prototype.sort = function sort (comparator) { + // Late binding + return OrderedMap(sortFactory(this, comparator)); + }; + + Map.prototype.sortBy = function sortBy (mapper, comparator) { + // Late binding + return OrderedMap(sortFactory(this, comparator, mapper)); + }; + + // @pragma Mutability + + Map.prototype.withMutations = function withMutations (fn) { + var mutable = this.asMutable(); + fn(mutable); + return mutable.wasAltered() ? mutable.__ensureOwner(this.__ownerID) : this; + }; + + Map.prototype.asMutable = function asMutable () { + return this.__ownerID ? this : this.__ensureOwner(new OwnerID()); + }; + + Map.prototype.asImmutable = function asImmutable () { + return this.__ensureOwner(); + }; + + Map.prototype.wasAltered = function wasAltered () { + return this.__altered; + }; + + Map.prototype.__iterator = function __iterator (type, reverse) { + return new MapIterator(this, type, reverse); + }; + + Map.prototype.__iterate = function __iterate (fn, reverse) { + var this$1 = this; + + var iterations = 0; + this._root && + this._root.iterate( + function (entry) { + iterations++; + return fn(entry[1], entry[0], this$1); + }, + reverse + ); + return iterations; + }; + + Map.prototype.__ensureOwner = function __ensureOwner (ownerID) { + if (ownerID === this.__ownerID) { + return this; + } + if (!ownerID) { + if (this.size === 0) { + return emptyMap(); + } + this.__ownerID = ownerID; + this.__altered = false; + return this; + } + return makeMap(this.size, this._root, ownerID, this.__hash); + }; + + return Map; +}(KeyedCollection)); + +function isMap(maybeMap) { + return !!(maybeMap && maybeMap[IS_MAP_SENTINEL]); +} + +Map.isMap = isMap; + +var IS_MAP_SENTINEL = '@@__IMMUTABLE_MAP__@@'; + +var MapPrototype = Map.prototype; +MapPrototype[IS_MAP_SENTINEL] = true; +MapPrototype[DELETE] = MapPrototype.remove; +MapPrototype.removeIn = MapPrototype.deleteIn; +MapPrototype.removeAll = MapPrototype.deleteAll; +MapPrototype['@@transducer/init'] = MapPrototype.asMutable; +MapPrototype['@@transducer/step'] = function(result, arr) { + return result.set(arr[0], arr[1]); +}; +MapPrototype['@@transducer/result'] = function(obj) { + return obj.asImmutable(); +}; + +// #pragma Trie Nodes + +var ArrayMapNode = function ArrayMapNode(ownerID, entries) { + this.ownerID = ownerID; + this.entries = entries; +}; + +ArrayMapNode.prototype.get = function get (shift, keyHash, key, notSetValue) { + var entries = this.entries; + for (var ii = 0, len = entries.length; ii < len; ii++) { + if (is(key, entries[ii][0])) { + return entries[ii][1]; + } + } + return notSetValue; +}; + +ArrayMapNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { + var removed = value === NOT_SET; + + var entries = this.entries; + var idx = 0; + var len = entries.length; + for (; idx < len; idx++) { + if (is(key, entries[idx][0])) { + break; + } + } + var exists = idx < len; + + if (exists ? entries[idx][1] === value : removed) { + return this; + } + + SetRef(didAlter); + (removed || !exists) && SetRef(didChangeSize); + + if (removed && entries.length === 1) { + return; // undefined + } + + if (!exists && !removed && entries.length >= MAX_ARRAY_MAP_SIZE) { + return createNodes(ownerID, entries, key, value); + } + + var isEditable = ownerID && ownerID === this.ownerID; + var newEntries = isEditable ? entries : arrCopy(entries); + + if (exists) { + if (removed) { + idx === len - 1 + ? newEntries.pop() + : (newEntries[idx] = newEntries.pop()); + } else { + newEntries[idx] = [key, value]; + } + } else { + newEntries.push([key, value]); + } + + if (isEditable) { + this.entries = newEntries; + return this; + } + + return new ArrayMapNode(ownerID, newEntries); +}; + +var BitmapIndexedNode = function BitmapIndexedNode(ownerID, bitmap, nodes) { + this.ownerID = ownerID; + this.bitmap = bitmap; + this.nodes = nodes; +}; + +BitmapIndexedNode.prototype.get = function get (shift, keyHash, key, notSetValue) { + if (keyHash === undefined) { + keyHash = hash(key); + } + var bit = 1 << ((shift === 0 ? keyHash : keyHash >>> shift) & MASK); + var bitmap = this.bitmap; + return (bitmap & bit) === 0 + ? notSetValue + : this.nodes[popCount(bitmap & bit - 1)].get( + shift + SHIFT, + keyHash, + key, + notSetValue + ); +}; + +BitmapIndexedNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { + if (keyHash === undefined) { + keyHash = hash(key); + } + var keyHashFrag = (shift === 0 ? keyHash : keyHash >>> shift) & MASK; + var bit = 1 << keyHashFrag; + var bitmap = this.bitmap; + var exists = (bitmap & bit) !== 0; + + if (!exists && value === NOT_SET) { + return this; + } + + var idx = popCount(bitmap & bit - 1); + var nodes = this.nodes; + var node = exists ? nodes[idx] : undefined; + var newNode = updateNode( + node, + ownerID, + shift + SHIFT, + keyHash, + key, + value, + didChangeSize, + didAlter + ); + + if (newNode === node) { + return this; + } + + if (!exists && newNode && nodes.length >= MAX_BITMAP_INDEXED_SIZE) { + return expandNodes(ownerID, nodes, bitmap, keyHashFrag, newNode); + } + + if ( + exists && !newNode && nodes.length === 2 && isLeafNode(nodes[idx ^ 1]) + ) { + return nodes[idx ^ 1]; + } + + if (exists && newNode && nodes.length === 1 && isLeafNode(newNode)) { + return newNode; + } + + var isEditable = ownerID && ownerID === this.ownerID; + var newBitmap = exists ? newNode ? bitmap : bitmap ^ bit : bitmap | bit; + var newNodes = exists + ? newNode + ? setIn(nodes, idx, newNode, isEditable) + : spliceOut(nodes, idx, isEditable) + : spliceIn(nodes, idx, newNode, isEditable); + + if (isEditable) { + this.bitmap = newBitmap; + this.nodes = newNodes; + return this; + } + + return new BitmapIndexedNode(ownerID, newBitmap, newNodes); +}; + +var HashArrayMapNode = function HashArrayMapNode(ownerID, count, nodes) { + this.ownerID = ownerID; + this.count = count; + this.nodes = nodes; +}; + +HashArrayMapNode.prototype.get = function get (shift, keyHash, key, notSetValue) { + if (keyHash === undefined) { + keyHash = hash(key); + } + var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK; + var node = this.nodes[idx]; + return node + ? node.get(shift + SHIFT, keyHash, key, notSetValue) + : notSetValue; +}; + +HashArrayMapNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { + if (keyHash === undefined) { + keyHash = hash(key); + } + var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK; + var removed = value === NOT_SET; + var nodes = this.nodes; + var node = nodes[idx]; + + if (removed && !node) { + return this; + } + + var newNode = updateNode( + node, + ownerID, + shift + SHIFT, + keyHash, + key, + value, + didChangeSize, + didAlter + ); + if (newNode === node) { + return this; + } + + var newCount = this.count; + if (!node) { + newCount++; + } else if (!newNode) { + newCount--; + if (newCount < MIN_HASH_ARRAY_MAP_SIZE) { + return packNodes(ownerID, nodes, newCount, idx); + } + } + + var isEditable = ownerID && ownerID === this.ownerID; + var newNodes = setIn(nodes, idx, newNode, isEditable); + + if (isEditable) { + this.count = newCount; + this.nodes = newNodes; + return this; + } + + return new HashArrayMapNode(ownerID, newCount, newNodes); +}; + +var HashCollisionNode = function HashCollisionNode(ownerID, keyHash, entries) { + this.ownerID = ownerID; + this.keyHash = keyHash; + this.entries = entries; +}; + +HashCollisionNode.prototype.get = function get (shift, keyHash, key, notSetValue) { + var entries = this.entries; + for (var ii = 0, len = entries.length; ii < len; ii++) { + if (is(key, entries[ii][0])) { + return entries[ii][1]; + } + } + return notSetValue; +}; + +HashCollisionNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { + if (keyHash === undefined) { + keyHash = hash(key); + } + + var removed = value === NOT_SET; + + if (keyHash !== this.keyHash) { + if (removed) { + return this; + } + SetRef(didAlter); + SetRef(didChangeSize); + return mergeIntoNode(this, ownerID, shift, keyHash, [key, value]); + } + + var entries = this.entries; + var idx = 0; + var len = entries.length; + for (; idx < len; idx++) { + if (is(key, entries[idx][0])) { + break; + } + } + var exists = idx < len; + + if (exists ? entries[idx][1] === value : removed) { + return this; + } + + SetRef(didAlter); + (removed || !exists) && SetRef(didChangeSize); + + if (removed && len === 2) { + return new ValueNode(ownerID, this.keyHash, entries[idx ^ 1]); + } + + var isEditable = ownerID && ownerID === this.ownerID; + var newEntries = isEditable ? entries : arrCopy(entries); + + if (exists) { + if (removed) { + idx === len - 1 + ? newEntries.pop() + : (newEntries[idx] = newEntries.pop()); + } else { + newEntries[idx] = [key, value]; + } + } else { + newEntries.push([key, value]); + } + + if (isEditable) { + this.entries = newEntries; + return this; + } + + return new HashCollisionNode(ownerID, this.keyHash, newEntries); +}; + +var ValueNode = function ValueNode(ownerID, keyHash, entry) { + this.ownerID = ownerID; + this.keyHash = keyHash; + this.entry = entry; +}; + +ValueNode.prototype.get = function get (shift, keyHash, key, notSetValue) { + return is(key, this.entry[0]) ? this.entry[1] : notSetValue; +}; + +ValueNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { + var removed = value === NOT_SET; + var keyMatch = is(key, this.entry[0]); + if (keyMatch ? value === this.entry[1] : removed) { + return this; + } + + SetRef(didAlter); + + if (removed) { + SetRef(didChangeSize); + return; // undefined + } + + if (keyMatch) { + if (ownerID && ownerID === this.ownerID) { + this.entry[1] = value; + return this; + } + return new ValueNode(ownerID, this.keyHash, [key, value]); + } + + SetRef(didChangeSize); + return mergeIntoNode(this, ownerID, shift, hash(key), [key, value]); +}; + +// #pragma Iterators + +ArrayMapNode.prototype.iterate = (HashCollisionNode.prototype.iterate = function( + fn, + reverse +) { + var entries = this.entries; + for (var ii = 0, maxIndex = entries.length - 1; ii <= maxIndex; ii++) { + if (fn(entries[reverse ? maxIndex - ii : ii]) === false) { + return false; + } + } +}); + +BitmapIndexedNode.prototype.iterate = (HashArrayMapNode.prototype.iterate = function( + fn, + reverse +) { + var nodes = this.nodes; + for (var ii = 0, maxIndex = nodes.length - 1; ii <= maxIndex; ii++) { + var node = nodes[reverse ? maxIndex - ii : ii]; + if (node && node.iterate(fn, reverse) === false) { + return false; + } + } +}); + +// eslint-disable-next-line no-unused-vars +ValueNode.prototype.iterate = function(fn, reverse) { + return fn(this.entry); +}; + +var MapIterator = (function (Iterator$$1) { + function MapIterator(map, type, reverse) { + this._type = type; + this._reverse = reverse; + this._stack = map._root && mapIteratorFrame(map._root); + } + + if ( Iterator$$1 ) MapIterator.__proto__ = Iterator$$1; + MapIterator.prototype = Object.create( Iterator$$1 && Iterator$$1.prototype ); + MapIterator.prototype.constructor = MapIterator; + + MapIterator.prototype.next = function next () { + var this$1 = this; + + var type = this._type; + var stack = this._stack; + while (stack) { + var node = stack.node; + var index = stack.index++; + var maxIndex = (void 0); + if (node.entry) { + if (index === 0) { + return mapIteratorValue(type, node.entry); + } + } else if (node.entries) { + maxIndex = node.entries.length - 1; + if (index <= maxIndex) { + return mapIteratorValue( + type, + node.entries[this$1._reverse ? maxIndex - index : index] + ); + } + } else { + maxIndex = node.nodes.length - 1; + if (index <= maxIndex) { + var subNode = node.nodes[this$1._reverse ? maxIndex - index : index]; + if (subNode) { + if (subNode.entry) { + return mapIteratorValue(type, subNode.entry); + } + stack = (this$1._stack = mapIteratorFrame(subNode, stack)); + } + continue; + } + } + stack = (this$1._stack = this$1._stack.__prev); + } + return iteratorDone(); + }; + + return MapIterator; +}(Iterator)); + +function mapIteratorValue(type, entry) { + return iteratorValue(type, entry[0], entry[1]); +} + +function mapIteratorFrame(node, prev) { + return { + node: node, + index: 0, + __prev: prev + }; +} + +function makeMap(size, root, ownerID, hash$$1) { + var map = Object.create(MapPrototype); + map.size = size; + map._root = root; + map.__ownerID = ownerID; + map.__hash = hash$$1; + map.__altered = false; + return map; +} + +var EMPTY_MAP; +function emptyMap() { + return EMPTY_MAP || (EMPTY_MAP = makeMap(0)); +} + +function updateMap(map, k, v) { + var newRoot; + var newSize; + if (!map._root) { + if (v === NOT_SET) { + return map; + } + newSize = 1; + newRoot = new ArrayMapNode(map.__ownerID, [[k, v]]); + } else { + var didChangeSize = MakeRef(CHANGE_LENGTH); + var didAlter = MakeRef(DID_ALTER); + newRoot = updateNode( + map._root, + map.__ownerID, + 0, + undefined, + k, + v, + didChangeSize, + didAlter + ); + if (!didAlter.value) { + return map; + } + newSize = map.size + (didChangeSize.value ? v === NOT_SET ? -1 : 1 : 0); + } + if (map.__ownerID) { + map.size = newSize; + map._root = newRoot; + map.__hash = undefined; + map.__altered = true; + return map; + } + return newRoot ? makeMap(newSize, newRoot) : emptyMap(); +} + +function updateNode( + node, + ownerID, + shift, + keyHash, + key, + value, + didChangeSize, + didAlter +) { + if (!node) { + if (value === NOT_SET) { + return node; + } + SetRef(didAlter); + SetRef(didChangeSize); + return new ValueNode(ownerID, keyHash, [key, value]); + } + return node.update( + ownerID, + shift, + keyHash, + key, + value, + didChangeSize, + didAlter + ); +} + +function isLeafNode(node) { + return node.constructor === ValueNode || + node.constructor === HashCollisionNode; +} + +function mergeIntoNode(node, ownerID, shift, keyHash, entry) { + if (node.keyHash === keyHash) { + return new HashCollisionNode(ownerID, keyHash, [node.entry, entry]); + } + + var idx1 = (shift === 0 ? node.keyHash : node.keyHash >>> shift) & MASK; + var idx2 = (shift === 0 ? keyHash : keyHash >>> shift) & MASK; + + var newNode; + var nodes = idx1 === idx2 + ? [mergeIntoNode(node, ownerID, shift + SHIFT, keyHash, entry)] + : ((newNode = new ValueNode(ownerID, keyHash, entry)), idx1 < idx2 + ? [node, newNode] + : [newNode, node]); + + return new BitmapIndexedNode(ownerID, 1 << idx1 | 1 << idx2, nodes); +} + +function createNodes(ownerID, entries, key, value) { + if (!ownerID) { + ownerID = new OwnerID(); + } + var node = new ValueNode(ownerID, hash(key), [key, value]); + for (var ii = 0; ii < entries.length; ii++) { + var entry = entries[ii]; + node = node.update(ownerID, 0, undefined, entry[0], entry[1]); + } + return node; +} + +function packNodes(ownerID, nodes, count, excluding) { + var bitmap = 0; + var packedII = 0; + var packedNodes = new Array(count); + for (var ii = 0, bit = 1, len = nodes.length; ii < len; ii++, (bit <<= 1)) { + var node = nodes[ii]; + if (node !== undefined && ii !== excluding) { + bitmap |= bit; + packedNodes[packedII++] = node; + } + } + return new BitmapIndexedNode(ownerID, bitmap, packedNodes); +} + +function expandNodes(ownerID, nodes, bitmap, including, node) { + var count = 0; + var expandedNodes = new Array(SIZE); + for (var ii = 0; bitmap !== 0; ii++, (bitmap >>>= 1)) { + expandedNodes[ii] = bitmap & 1 ? nodes[count++] : undefined; + } + expandedNodes[including] = node; + return new HashArrayMapNode(ownerID, count + 1, expandedNodes); +} + +function mergeIntoMapWith(map, merger, collections) { + var iters = []; + for (var ii = 0; ii < collections.length; ii++) { + var value = collections[ii]; + var iter = KeyedCollection(value); + if (!isCollection(value)) { + iter = iter.map(function (v) { return fromJS(v); }); + } + iters.push(iter); + } + return mergeIntoCollectionWith(map, merger, iters); +} + +function deepMerger(oldVal, newVal) { + return oldVal && oldVal.mergeDeep && isCollection(newVal) + ? oldVal.mergeDeep(newVal) + : is(oldVal, newVal) ? oldVal : newVal; +} + +function deepMergerWith(merger) { + return function (oldVal, newVal, key) { + if (oldVal && oldVal.mergeDeepWith && isCollection(newVal)) { + return oldVal.mergeDeepWith(merger, newVal); + } + var nextValue = merger(oldVal, newVal, key); + return is(oldVal, nextValue) ? oldVal : nextValue; + }; +} + +function mergeIntoCollectionWith(collection, merger, iters) { + iters = iters.filter(function (x) { return x.size !== 0; }); + if (iters.length === 0) { + return collection; + } + if (collection.size === 0 && !collection.__ownerID && iters.length === 1) { + return collection.constructor(iters[0]); + } + return collection.withMutations(function (collection) { + var mergeIntoMap = merger + ? function (value, key) { + collection.update( + key, + NOT_SET, + function (oldVal) { return oldVal === NOT_SET ? value : merger(oldVal, value, key); } + ); + } + : function (value, key) { + collection.set(key, value); + }; + for (var ii = 0; ii < iters.length; ii++) { + iters[ii].forEach(mergeIntoMap); + } + }); +} + +function updateInDeepMap(existing, keyPath, i, notSetValue, updater) { + var isNotSet = existing === NOT_SET; + if (i === keyPath.length) { + var existingValue = isNotSet ? notSetValue : existing; + var newValue = updater(existingValue); + return newValue === existingValue ? existing : newValue; + } + if (!(isNotSet || (existing && existing.set))) { + throw new TypeError( + 'Invalid keyPath: Value at [' + + keyPath.slice(0, i).map(quoteString) + + '] does not have a .set() method and cannot be updated: ' + + existing + ); + } + var key = keyPath[i]; + var nextExisting = isNotSet ? NOT_SET : existing.get(key, NOT_SET); + var nextUpdated = updateInDeepMap( + nextExisting, + keyPath, + i + 1, + notSetValue, + updater + ); + return nextUpdated === nextExisting + ? existing + : nextUpdated === NOT_SET + ? existing.remove(key) + : (isNotSet ? emptyMap() : existing).set(key, nextUpdated); +} + +function popCount(x) { + x -= x >> 1 & 0x55555555; + x = (x & 0x33333333) + (x >> 2 & 0x33333333); + x = x + (x >> 4) & 0x0f0f0f0f; + x += x >> 8; + x += x >> 16; + return x & 0x7f; +} + +function setIn(array, idx, val, canEdit) { + var newArray = canEdit ? array : arrCopy(array); + newArray[idx] = val; + return newArray; +} + +function spliceIn(array, idx, val, canEdit) { + var newLen = array.length + 1; + if (canEdit && idx + 1 === newLen) { + array[idx] = val; + return array; + } + var newArray = new Array(newLen); + var after = 0; + for (var ii = 0; ii < newLen; ii++) { + if (ii === idx) { + newArray[ii] = val; + after = -1; + } else { + newArray[ii] = array[ii + after]; + } + } + return newArray; +} + +function spliceOut(array, idx, canEdit) { + var newLen = array.length - 1; + if (canEdit && idx === newLen) { + array.pop(); + return array; + } + var newArray = new Array(newLen); + var after = 0; + for (var ii = 0; ii < newLen; ii++) { + if (ii === idx) { + after = 1; + } + newArray[ii] = array[ii + after]; + } + return newArray; +} + +var MAX_ARRAY_MAP_SIZE = SIZE / 4; +var MAX_BITMAP_INDEXED_SIZE = SIZE / 2; +var MIN_HASH_ARRAY_MAP_SIZE = SIZE / 4; + +var List = (function (IndexedCollection$$1) { + function List(value) { + var empty = emptyList(); + if (value === null || value === undefined) { + return empty; + } + if (isList(value)) { + return value; + } + var iter = IndexedCollection$$1(value); + var size = iter.size; + if (size === 0) { + return empty; + } + assertNotInfinite(size); + if (size > 0 && size < SIZE) { + return makeList(0, size, SHIFT, null, new VNode(iter.toArray())); + } + return empty.withMutations(function (list) { + list.setSize(size); + iter.forEach(function (v, i) { return list.set(i, v); }); + }); + } + + if ( IndexedCollection$$1 ) List.__proto__ = IndexedCollection$$1; + List.prototype = Object.create( IndexedCollection$$1 && IndexedCollection$$1.prototype ); + List.prototype.constructor = List; + + List.of = function of (/*...values*/) { + return this(arguments); + }; + + List.prototype.toString = function toString () { + return this.__toString('List [', ']'); + }; + + // @pragma Access + + List.prototype.get = function get (index, notSetValue) { + index = wrapIndex(this, index); + if (index >= 0 && index < this.size) { + index += this._origin; + var node = listNodeFor(this, index); + return node && node.array[index & MASK]; + } + return notSetValue; + }; + + // @pragma Modification + + List.prototype.set = function set (index, value) { + return updateList(this, index, value); + }; + + List.prototype.remove = function remove (index) { + return !this.has(index) + ? this + : index === 0 + ? this.shift() + : index === this.size - 1 ? this.pop() : this.splice(index, 1); + }; + + List.prototype.insert = function insert (index, value) { + return this.splice(index, 0, value); + }; + + List.prototype.clear = function clear () { + if (this.size === 0) { + return this; + } + if (this.__ownerID) { + this.size = (this._origin = (this._capacity = 0)); + this._level = SHIFT; + this._root = (this._tail = null); + this.__hash = undefined; + this.__altered = true; + return this; + } + return emptyList(); + }; + + List.prototype.push = function push (/*...values*/) { + var values = arguments; + var oldSize = this.size; + return this.withMutations(function (list) { + setListBounds(list, 0, oldSize + values.length); + for (var ii = 0; ii < values.length; ii++) { + list.set(oldSize + ii, values[ii]); + } + }); + }; + + List.prototype.pop = function pop () { + return setListBounds(this, 0, -1); + }; + + List.prototype.unshift = function unshift (/*...values*/) { + var values = arguments; + return this.withMutations(function (list) { + setListBounds(list, -values.length); + for (var ii = 0; ii < values.length; ii++) { + list.set(ii, values[ii]); + } + }); + }; + + List.prototype.shift = function shift () { + return setListBounds(this, 1); + }; + + // @pragma Composition + + List.prototype.merge = function merge (/*...iters*/) { + return mergeIntoListWith(this, undefined, arguments); + }; + + List.prototype.mergeWith = function mergeWith (merger) { + var iters = [], len = arguments.length - 1; + while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; + + return mergeIntoListWith(this, merger, iters); + }; + + List.prototype.mergeDeep = function mergeDeep (/*...iters*/) { + return mergeIntoListWith(this, deepMerger, arguments); + }; + + List.prototype.mergeDeepWith = function mergeDeepWith (merger) { + var iters = [], len = arguments.length - 1; + while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; + + return mergeIntoListWith(this, deepMergerWith(merger), iters); + }; + + List.prototype.setSize = function setSize (size) { + return setListBounds(this, 0, size); + }; + + // @pragma Iteration + + List.prototype.slice = function slice (begin, end) { + var size = this.size; + if (wholeSlice(begin, end, size)) { + return this; + } + return setListBounds( + this, + resolveBegin(begin, size), + resolveEnd(end, size) + ); + }; + + List.prototype.__iterator = function __iterator (type, reverse) { + var index = reverse ? this.size : 0; + var values = iterateList(this, reverse); + return new Iterator(function () { + var value = values(); + return value === DONE + ? iteratorDone() + : iteratorValue(type, reverse ? --index : index++, value); + }); + }; + + List.prototype.__iterate = function __iterate (fn, reverse) { + var this$1 = this; + + var index = reverse ? this.size : 0; + var values = iterateList(this, reverse); + var value; + while ((value = values()) !== DONE) { + if (fn(value, reverse ? --index : index++, this$1) === false) { + break; + } + } + return index; + }; + + List.prototype.__ensureOwner = function __ensureOwner (ownerID) { + if (ownerID === this.__ownerID) { + return this; + } + if (!ownerID) { + if (this.size === 0) { + return emptyList(); + } + this.__ownerID = ownerID; + return this; + } + return makeList( + this._origin, + this._capacity, + this._level, + this._root, + this._tail, + ownerID, + this.__hash + ); + }; + + return List; +}(IndexedCollection)); + +function isList(maybeList) { + return !!(maybeList && maybeList[IS_LIST_SENTINEL]); +} + +List.isList = isList; + +var IS_LIST_SENTINEL = '@@__IMMUTABLE_LIST__@@'; + +var ListPrototype = List.prototype; +ListPrototype[IS_LIST_SENTINEL] = true; +ListPrototype[DELETE] = ListPrototype.remove; +ListPrototype.setIn = MapPrototype.setIn; +ListPrototype.deleteIn = (ListPrototype.removeIn = MapPrototype.removeIn); +ListPrototype.update = MapPrototype.update; +ListPrototype.updateIn = MapPrototype.updateIn; +ListPrototype.mergeIn = MapPrototype.mergeIn; +ListPrototype.mergeDeepIn = MapPrototype.mergeDeepIn; +ListPrototype.withMutations = MapPrototype.withMutations; +ListPrototype.asMutable = MapPrototype.asMutable; +ListPrototype.asImmutable = MapPrototype.asImmutable; +ListPrototype.wasAltered = MapPrototype.wasAltered; +ListPrototype['@@transducer/init'] = ListPrototype.asMutable; +ListPrototype['@@transducer/step'] = function(result, arr) { + return result.push(arr); +}; +ListPrototype['@@transducer/result'] = MapPrototype['@@transducer/result']; + +var VNode = function VNode(array, ownerID) { + this.array = array; + this.ownerID = ownerID; +}; + +// TODO: seems like these methods are very similar + +VNode.prototype.removeBefore = function removeBefore (ownerID, level, index) { + if (index === level ? 1 << level : 0 || this.array.length === 0) { + return this; + } + var originIndex = index >>> level & MASK; + if (originIndex >= this.array.length) { + return new VNode([], ownerID); + } + var removingFirst = originIndex === 0; + var newChild; + if (level > 0) { + var oldChild = this.array[originIndex]; + newChild = oldChild && + oldChild.removeBefore(ownerID, level - SHIFT, index); + if (newChild === oldChild && removingFirst) { + return this; + } + } + if (removingFirst && !newChild) { + return this; + } + var editable = editableVNode(this, ownerID); + if (!removingFirst) { + for (var ii = 0; ii < originIndex; ii++) { + editable.array[ii] = undefined; + } + } + if (newChild) { + editable.array[originIndex] = newChild; + } + return editable; +}; + +VNode.prototype.removeAfter = function removeAfter (ownerID, level, index) { + if (index === (level ? 1 << level : 0) || this.array.length === 0) { + return this; + } + var sizeIndex = index - 1 >>> level & MASK; + if (sizeIndex >= this.array.length) { + return this; + } + + var newChild; + if (level > 0) { + var oldChild = this.array[sizeIndex]; + newChild = oldChild && + oldChild.removeAfter(ownerID, level - SHIFT, index); + if (newChild === oldChild && sizeIndex === this.array.length - 1) { + return this; + } + } + + var editable = editableVNode(this, ownerID); + editable.array.splice(sizeIndex + 1); + if (newChild) { + editable.array[sizeIndex] = newChild; + } + return editable; +}; + +var DONE = {}; + +function iterateList(list, reverse) { + var left = list._origin; + var right = list._capacity; + var tailPos = getTailOffset(right); + var tail = list._tail; + + return iterateNodeOrLeaf(list._root, list._level, 0); + + function iterateNodeOrLeaf(node, level, offset) { + return level === 0 + ? iterateLeaf(node, offset) + : iterateNode(node, level, offset); + } + + function iterateLeaf(node, offset) { + var array = offset === tailPos ? tail && tail.array : node && node.array; + var from = offset > left ? 0 : left - offset; + var to = right - offset; + if (to > SIZE) { + to = SIZE; + } + return function () { + if (from === to) { + return DONE; + } + var idx = reverse ? --to : from++; + return array && array[idx]; + }; + } + + function iterateNode(node, level, offset) { + var values; + var array = node && node.array; + var from = offset > left ? 0 : left - offset >> level; + var to = (right - offset >> level) + 1; + if (to > SIZE) { + to = SIZE; + } + return function () { + while (true) { + if (values) { + var value = values(); + if (value !== DONE) { + return value; + } + values = null; + } + if (from === to) { + return DONE; + } + var idx = reverse ? --to : from++; + values = iterateNodeOrLeaf( + array && array[idx], + level - SHIFT, + offset + (idx << level) + ); + } + }; + } +} + +function makeList(origin, capacity, level, root, tail, ownerID, hash) { + var list = Object.create(ListPrototype); + list.size = capacity - origin; + list._origin = origin; + list._capacity = capacity; + list._level = level; + list._root = root; + list._tail = tail; + list.__ownerID = ownerID; + list.__hash = hash; + list.__altered = false; + return list; +} + +var EMPTY_LIST; +function emptyList() { + return EMPTY_LIST || (EMPTY_LIST = makeList(0, 0, SHIFT)); +} + +function updateList(list, index, value) { + index = wrapIndex(list, index); + + if (index !== index) { + return list; + } + + if (index >= list.size || index < 0) { + return list.withMutations(function (list) { + index < 0 + ? setListBounds(list, index).set(0, value) + : setListBounds(list, 0, index + 1).set(index, value); + }); + } + + index += list._origin; + + var newTail = list._tail; + var newRoot = list._root; + var didAlter = MakeRef(DID_ALTER); + if (index >= getTailOffset(list._capacity)) { + newTail = updateVNode(newTail, list.__ownerID, 0, index, value, didAlter); + } else { + newRoot = updateVNode( + newRoot, + list.__ownerID, + list._level, + index, + value, + didAlter + ); + } + + if (!didAlter.value) { + return list; + } + + if (list.__ownerID) { + list._root = newRoot; + list._tail = newTail; + list.__hash = undefined; + list.__altered = true; + return list; + } + return makeList(list._origin, list._capacity, list._level, newRoot, newTail); +} + +function updateVNode(node, ownerID, level, index, value, didAlter) { + var idx = index >>> level & MASK; + var nodeHas = node && idx < node.array.length; + if (!nodeHas && value === undefined) { + return node; + } + + var newNode; + + if (level > 0) { + var lowerNode = node && node.array[idx]; + var newLowerNode = updateVNode( + lowerNode, + ownerID, + level - SHIFT, + index, + value, + didAlter + ); + if (newLowerNode === lowerNode) { + return node; + } + newNode = editableVNode(node, ownerID); + newNode.array[idx] = newLowerNode; + return newNode; + } + + if (nodeHas && node.array[idx] === value) { + return node; + } + + SetRef(didAlter); + + newNode = editableVNode(node, ownerID); + if (value === undefined && idx === newNode.array.length - 1) { + newNode.array.pop(); + } else { + newNode.array[idx] = value; + } + return newNode; +} + +function editableVNode(node, ownerID) { + if (ownerID && node && ownerID === node.ownerID) { + return node; + } + return new VNode(node ? node.array.slice() : [], ownerID); +} + +function listNodeFor(list, rawIndex) { + if (rawIndex >= getTailOffset(list._capacity)) { + return list._tail; + } + if (rawIndex < 1 << list._level + SHIFT) { + var node = list._root; + var level = list._level; + while (node && level > 0) { + node = node.array[rawIndex >>> level & MASK]; + level -= SHIFT; + } + return node; + } +} + +function setListBounds(list, begin, end) { + // Sanitize begin & end using this shorthand for ToInt32(argument) + // http://www.ecma-international.org/ecma-262/6.0/#sec-toint32 + if (begin !== undefined) { + begin |= 0; + } + if (end !== undefined) { + end |= 0; + } + var owner = list.__ownerID || new OwnerID(); + var oldOrigin = list._origin; + var oldCapacity = list._capacity; + var newOrigin = oldOrigin + begin; + var newCapacity = end === undefined + ? oldCapacity + : end < 0 ? oldCapacity + end : oldOrigin + end; + if (newOrigin === oldOrigin && newCapacity === oldCapacity) { + return list; + } + + // If it's going to end after it starts, it's empty. + if (newOrigin >= newCapacity) { + return list.clear(); + } + + var newLevel = list._level; + var newRoot = list._root; + + // New origin might need creating a higher root. + var offsetShift = 0; + while (newOrigin + offsetShift < 0) { + newRoot = new VNode( + newRoot && newRoot.array.length ? [undefined, newRoot] : [], + owner + ); + newLevel += SHIFT; + offsetShift += 1 << newLevel; + } + if (offsetShift) { + newOrigin += offsetShift; + oldOrigin += offsetShift; + newCapacity += offsetShift; + oldCapacity += offsetShift; + } + + var oldTailOffset = getTailOffset(oldCapacity); + var newTailOffset = getTailOffset(newCapacity); + + // New size might need creating a higher root. + while (newTailOffset >= 1 << newLevel + SHIFT) { + newRoot = new VNode( + newRoot && newRoot.array.length ? [newRoot] : [], + owner + ); + newLevel += SHIFT; + } + + // Locate or create the new tail. + var oldTail = list._tail; + var newTail = newTailOffset < oldTailOffset + ? listNodeFor(list, newCapacity - 1) + : newTailOffset > oldTailOffset ? new VNode([], owner) : oldTail; + + // Merge Tail into tree. + if ( + oldTail && + newTailOffset > oldTailOffset && + newOrigin < oldCapacity && + oldTail.array.length + ) { + newRoot = editableVNode(newRoot, owner); + var node = newRoot; + for (var level = newLevel; level > SHIFT; level -= SHIFT) { + var idx = oldTailOffset >>> level & MASK; + node = (node.array[idx] = editableVNode(node.array[idx], owner)); + } + node.array[oldTailOffset >>> SHIFT & MASK] = oldTail; + } + + // If the size has been reduced, there's a chance the tail needs to be trimmed. + if (newCapacity < oldCapacity) { + newTail = newTail && newTail.removeAfter(owner, 0, newCapacity); + } + + // If the new origin is within the tail, then we do not need a root. + if (newOrigin >= newTailOffset) { + newOrigin -= newTailOffset; + newCapacity -= newTailOffset; + newLevel = SHIFT; + newRoot = null; + newTail = newTail && newTail.removeBefore(owner, 0, newOrigin); + + // Otherwise, if the root has been trimmed, garbage collect. + } else if (newOrigin > oldOrigin || newTailOffset < oldTailOffset) { + offsetShift = 0; + + // Identify the new top root node of the subtree of the old root. + while (newRoot) { + var beginIndex = newOrigin >>> newLevel & MASK; + if (beginIndex !== newTailOffset >>> newLevel & MASK) { + break; + } + if (beginIndex) { + offsetShift += (1 << newLevel) * beginIndex; + } + newLevel -= SHIFT; + newRoot = newRoot.array[beginIndex]; + } + + // Trim the new sides of the new root. + if (newRoot && newOrigin > oldOrigin) { + newRoot = newRoot.removeBefore(owner, newLevel, newOrigin - offsetShift); + } + if (newRoot && newTailOffset < oldTailOffset) { + newRoot = newRoot.removeAfter( + owner, + newLevel, + newTailOffset - offsetShift + ); + } + if (offsetShift) { + newOrigin -= offsetShift; + newCapacity -= offsetShift; + } + } + + if (list.__ownerID) { + list.size = newCapacity - newOrigin; + list._origin = newOrigin; + list._capacity = newCapacity; + list._level = newLevel; + list._root = newRoot; + list._tail = newTail; + list.__hash = undefined; + list.__altered = true; + return list; + } + return makeList(newOrigin, newCapacity, newLevel, newRoot, newTail); +} + +function mergeIntoListWith(list, merger, collections) { + var iters = []; + var maxSize = 0; + for (var ii = 0; ii < collections.length; ii++) { + var value = collections[ii]; + var iter = IndexedCollection(value); + if (iter.size > maxSize) { + maxSize = iter.size; + } + if (!isCollection(value)) { + iter = iter.map(function (v) { return fromJS(v); }); + } + iters.push(iter); + } + if (maxSize > list.size) { + list = list.setSize(maxSize); + } + return mergeIntoCollectionWith(list, merger, iters); +} + +function getTailOffset(size) { + return size < SIZE ? 0 : size - 1 >>> SHIFT << SHIFT; +} + +var OrderedMap = (function (Map$$1) { + function OrderedMap(value) { + return value === null || value === undefined + ? emptyOrderedMap() + : isOrderedMap(value) + ? value + : emptyOrderedMap().withMutations(function (map) { + var iter = KeyedCollection(value); + assertNotInfinite(iter.size); + iter.forEach(function (v, k) { return map.set(k, v); }); + }); + } + + if ( Map$$1 ) OrderedMap.__proto__ = Map$$1; + OrderedMap.prototype = Object.create( Map$$1 && Map$$1.prototype ); + OrderedMap.prototype.constructor = OrderedMap; + + OrderedMap.of = function of (/*...values*/) { + return this(arguments); + }; + + OrderedMap.prototype.toString = function toString () { + return this.__toString('OrderedMap {', '}'); + }; + + // @pragma Access + + OrderedMap.prototype.get = function get (k, notSetValue) { + var index = this._map.get(k); + return index !== undefined ? this._list.get(index)[1] : notSetValue; + }; + + // @pragma Modification + + OrderedMap.prototype.clear = function clear () { + if (this.size === 0) { + return this; + } + if (this.__ownerID) { + this.size = 0; + this._map.clear(); + this._list.clear(); + return this; + } + return emptyOrderedMap(); + }; + + OrderedMap.prototype.set = function set (k, v) { + return updateOrderedMap(this, k, v); + }; + + OrderedMap.prototype.remove = function remove (k) { + return updateOrderedMap(this, k, NOT_SET); + }; + + OrderedMap.prototype.wasAltered = function wasAltered () { + return this._map.wasAltered() || this._list.wasAltered(); + }; + + OrderedMap.prototype.__iterate = function __iterate (fn, reverse) { + var this$1 = this; + + return this._list.__iterate( + function (entry) { return entry && fn(entry[1], entry[0], this$1); }, + reverse + ); + }; + + OrderedMap.prototype.__iterator = function __iterator (type, reverse) { + return this._list.fromEntrySeq().__iterator(type, reverse); + }; + + OrderedMap.prototype.__ensureOwner = function __ensureOwner (ownerID) { + if (ownerID === this.__ownerID) { + return this; + } + var newMap = this._map.__ensureOwner(ownerID); + var newList = this._list.__ensureOwner(ownerID); + if (!ownerID) { + if (this.size === 0) { + return emptyOrderedMap(); + } + this.__ownerID = ownerID; + this._map = newMap; + this._list = newList; + return this; + } + return makeOrderedMap(newMap, newList, ownerID, this.__hash); + }; + + return OrderedMap; +}(Map)); + +function isOrderedMap(maybeOrderedMap) { + return isMap(maybeOrderedMap) && isOrdered(maybeOrderedMap); +} + +OrderedMap.isOrderedMap = isOrderedMap; + +OrderedMap.prototype[IS_ORDERED_SENTINEL] = true; +OrderedMap.prototype[DELETE] = OrderedMap.prototype.remove; + +function makeOrderedMap(map, list, ownerID, hash) { + var omap = Object.create(OrderedMap.prototype); + omap.size = map ? map.size : 0; + omap._map = map; + omap._list = list; + omap.__ownerID = ownerID; + omap.__hash = hash; + return omap; +} + +var EMPTY_ORDERED_MAP; +function emptyOrderedMap() { + return EMPTY_ORDERED_MAP || + (EMPTY_ORDERED_MAP = makeOrderedMap(emptyMap(), emptyList())); +} + +function updateOrderedMap(omap, k, v) { + var map = omap._map; + var list = omap._list; + var i = map.get(k); + var has = i !== undefined; + var newMap; + var newList; + if (v === NOT_SET) { + // removed + if (!has) { + return omap; + } + if (list.size >= SIZE && list.size >= map.size * 2) { + newList = list.filter(function (entry, idx) { return entry !== undefined && i !== idx; }); + newMap = newList.toKeyedSeq().map(function (entry) { return entry[0]; }).flip().toMap(); + if (omap.__ownerID) { + newMap.__ownerID = (newList.__ownerID = omap.__ownerID); + } + } else { + newMap = map.remove(k); + newList = i === list.size - 1 ? list.pop() : list.set(i, undefined); + } + } else if (has) { + if (v === list.get(i)[1]) { + return omap; + } + newMap = map; + newList = list.set(i, [k, v]); + } else { + newMap = map.set(k, list.size); + newList = list.set(list.size, [k, v]); + } + if (omap.__ownerID) { + omap.size = newMap.size; + omap._map = newMap; + omap._list = newList; + omap.__hash = undefined; + return omap; + } + return makeOrderedMap(newMap, newList); +} + +var Stack = (function (IndexedCollection$$1) { + function Stack(value) { + return value === null || value === undefined + ? emptyStack() + : isStack(value) ? value : emptyStack().pushAll(value); + } + + if ( IndexedCollection$$1 ) Stack.__proto__ = IndexedCollection$$1; + Stack.prototype = Object.create( IndexedCollection$$1 && IndexedCollection$$1.prototype ); + Stack.prototype.constructor = Stack; + + Stack.of = function of (/*...values*/) { + return this(arguments); + }; + + Stack.prototype.toString = function toString () { + return this.__toString('Stack [', ']'); + }; + + // @pragma Access + + Stack.prototype.get = function get (index, notSetValue) { + var head = this._head; + index = wrapIndex(this, index); + while (head && index--) { + head = head.next; + } + return head ? head.value : notSetValue; + }; + + Stack.prototype.peek = function peek () { + return this._head && this._head.value; + }; + + // @pragma Modification + + Stack.prototype.push = function push (/*...values*/) { + var arguments$1 = arguments; + + if (arguments.length === 0) { + return this; + } + var newSize = this.size + arguments.length; + var head = this._head; + for (var ii = arguments.length - 1; ii >= 0; ii--) { + head = { + value: arguments$1[ii], + next: head + }; + } + if (this.__ownerID) { + this.size = newSize; + this._head = head; + this.__hash = undefined; + this.__altered = true; + return this; + } + return makeStack(newSize, head); + }; + + Stack.prototype.pushAll = function pushAll (iter) { + iter = IndexedCollection$$1(iter); + if (iter.size === 0) { + return this; + } + if (this.size === 0 && isStack(iter)) { + return iter; + } + assertNotInfinite(iter.size); + var newSize = this.size; + var head = this._head; + iter.__iterate( + function (value) { + newSize++; + head = { + value: value, + next: head + }; + }, + /* reverse */ true + ); + if (this.__ownerID) { + this.size = newSize; + this._head = head; + this.__hash = undefined; + this.__altered = true; + return this; + } + return makeStack(newSize, head); + }; + + Stack.prototype.pop = function pop () { + return this.slice(1); + }; + + Stack.prototype.clear = function clear () { + if (this.size === 0) { + return this; + } + if (this.__ownerID) { + this.size = 0; + this._head = undefined; + this.__hash = undefined; + this.__altered = true; + return this; + } + return emptyStack(); + }; + + Stack.prototype.slice = function slice (begin, end) { + if (wholeSlice(begin, end, this.size)) { + return this; + } + var resolvedBegin = resolveBegin(begin, this.size); + var resolvedEnd = resolveEnd(end, this.size); + if (resolvedEnd !== this.size) { + // super.slice(begin, end); + return IndexedCollection$$1.prototype.slice.call(this, begin, end); + } + var newSize = this.size - resolvedBegin; + var head = this._head; + while (resolvedBegin--) { + head = head.next; + } + if (this.__ownerID) { + this.size = newSize; + this._head = head; + this.__hash = undefined; + this.__altered = true; + return this; + } + return makeStack(newSize, head); + }; + + // @pragma Mutability + + Stack.prototype.__ensureOwner = function __ensureOwner (ownerID) { + if (ownerID === this.__ownerID) { + return this; + } + if (!ownerID) { + if (this.size === 0) { + return emptyStack(); + } + this.__ownerID = ownerID; + this.__altered = false; + return this; + } + return makeStack(this.size, this._head, ownerID, this.__hash); + }; + + // @pragma Iteration + + Stack.prototype.__iterate = function __iterate (fn, reverse) { + var this$1 = this; + + if (reverse) { + return new ArraySeq(this.toArray()).__iterate( + function (v, k) { return fn(v, k, this$1); }, + reverse + ); + } + var iterations = 0; + var node = this._head; + while (node) { + if (fn(node.value, iterations++, this$1) === false) { + break; + } + node = node.next; + } + return iterations; + }; + + Stack.prototype.__iterator = function __iterator (type, reverse) { + if (reverse) { + return new ArraySeq(this.toArray()).__iterator(type, reverse); + } + var iterations = 0; + var node = this._head; + return new Iterator(function () { + if (node) { + var value = node.value; + node = node.next; + return iteratorValue(type, iterations++, value); + } + return iteratorDone(); + }); + }; + + return Stack; +}(IndexedCollection)); + +function isStack(maybeStack) { + return !!(maybeStack && maybeStack[IS_STACK_SENTINEL]); +} + +Stack.isStack = isStack; + +var IS_STACK_SENTINEL = '@@__IMMUTABLE_STACK__@@'; + +var StackPrototype = Stack.prototype; +StackPrototype[IS_STACK_SENTINEL] = true; +StackPrototype.withMutations = MapPrototype.withMutations; +StackPrototype.asMutable = MapPrototype.asMutable; +StackPrototype.asImmutable = MapPrototype.asImmutable; +StackPrototype.wasAltered = MapPrototype.wasAltered; +StackPrototype.shift = StackPrototype.pop; +StackPrototype.unshift = StackPrototype.push; +StackPrototype.unshiftAll = StackPrototype.pushAll; +StackPrototype['@@transducer/init'] = StackPrototype.asMutable; +StackPrototype['@@transducer/step'] = function(result, arr) { + return result.unshift(arr); +}; +StackPrototype['@@transducer/result'] = MapPrototype['@@transducer/result']; + +function makeStack(size, head, ownerID, hash) { + var map = Object.create(StackPrototype); + map.size = size; + map._head = head; + map.__ownerID = ownerID; + map.__hash = hash; + map.__altered = false; + return map; +} + +var EMPTY_STACK; +function emptyStack() { + return EMPTY_STACK || (EMPTY_STACK = makeStack(0)); +} + +function deepEqual(a, b) { + if (a === b) { + return true; + } + + if ( + !isCollection(b) || + (a.size !== undefined && b.size !== undefined && a.size !== b.size) || + (a.__hash !== undefined && + b.__hash !== undefined && + a.__hash !== b.__hash) || + isKeyed(a) !== isKeyed(b) || + isIndexed(a) !== isIndexed(b) || + isOrdered(a) !== isOrdered(b) + ) { + return false; + } + + if (a.size === 0 && b.size === 0) { + return true; + } + + var notAssociative = !isAssociative(a); + + if (isOrdered(a)) { + var entries = a.entries(); + return b.every(function (v, k) { + var entry = entries.next().value; + return entry && is(entry[1], v) && (notAssociative || is(entry[0], k)); + }) && entries.next().done; + } + + var flipped = false; + + if (a.size === undefined) { + if (b.size === undefined) { + if (typeof a.cacheResult === 'function') { + a.cacheResult(); + } + } else { + flipped = true; + var _ = a; + a = b; + b = _; + } + } + + var allEqual = true; + var bSize = b.__iterate(function (v, k) { + if ( + notAssociative + ? !a.has(v) + : flipped ? !is(v, a.get(k, NOT_SET)) : !is(a.get(k, NOT_SET), v) + ) { + allEqual = false; + return false; + } + }); + + return allEqual && a.size === bSize; +} + +/** + * Contributes additional methods to a constructor + */ +function mixin(ctor, methods) { + var keyCopier = function (key) { + ctor.prototype[key] = methods[key]; + }; + Object.keys(methods).forEach(keyCopier); + Object.getOwnPropertySymbols && + Object.getOwnPropertySymbols(methods).forEach(keyCopier); + return ctor; +} + +var Set = (function (SetCollection$$1) { + function Set(value) { + return value === null || value === undefined + ? emptySet() + : isSet(value) && !isOrdered(value) + ? value + : emptySet().withMutations(function (set) { + var iter = SetCollection$$1(value); + assertNotInfinite(iter.size); + iter.forEach(function (v) { return set.add(v); }); + }); + } + + if ( SetCollection$$1 ) Set.__proto__ = SetCollection$$1; + Set.prototype = Object.create( SetCollection$$1 && SetCollection$$1.prototype ); + Set.prototype.constructor = Set; + + Set.of = function of (/*...values*/) { + return this(arguments); + }; + + Set.fromKeys = function fromKeys (value) { + return this(KeyedCollection(value).keySeq()); + }; + + Set.intersect = function intersect (sets) { + sets = Collection(sets).toArray(); + return sets.length + ? SetPrototype.intersect.apply(Set(sets.pop()), sets) + : emptySet(); + }; + + Set.union = function union (sets) { + sets = Collection(sets).toArray(); + return sets.length + ? SetPrototype.union.apply(Set(sets.pop()), sets) + : emptySet(); + }; + + Set.prototype.toString = function toString () { + return this.__toString('Set {', '}'); + }; + + // @pragma Access + + Set.prototype.has = function has (value) { + return this._map.has(value); + }; + + // @pragma Modification + + Set.prototype.add = function add (value) { + return updateSet(this, this._map.set(value, true)); + }; + + Set.prototype.remove = function remove (value) { + return updateSet(this, this._map.remove(value)); + }; + + Set.prototype.clear = function clear () { + return updateSet(this, this._map.clear()); + }; + + // @pragma Composition + + Set.prototype.union = function union () { + var iters = [], len = arguments.length; + while ( len-- ) iters[ len ] = arguments[ len ]; + + iters = iters.filter(function (x) { return x.size !== 0; }); + if (iters.length === 0) { + return this; + } + if (this.size === 0 && !this.__ownerID && iters.length === 1) { + return this.constructor(iters[0]); + } + return this.withMutations(function (set) { + for (var ii = 0; ii < iters.length; ii++) { + SetCollection$$1(iters[ii]).forEach(function (value) { return set.add(value); }); + } + }); + }; + + Set.prototype.intersect = function intersect () { + var iters = [], len = arguments.length; + while ( len-- ) iters[ len ] = arguments[ len ]; + + if (iters.length === 0) { + return this; + } + iters = iters.map(function (iter) { return SetCollection$$1(iter); }); + var toRemove = []; + this.forEach(function (value) { + if (!iters.every(function (iter) { return iter.includes(value); })) { + toRemove.push(value); + } + }); + return this.withMutations(function (set) { + toRemove.forEach(function (value) { + set.remove(value); + }); + }); + }; + + Set.prototype.subtract = function subtract () { + var iters = [], len = arguments.length; + while ( len-- ) iters[ len ] = arguments[ len ]; + + if (iters.length === 0) { + return this; + } + var toRemove = []; + this.forEach(function (value) { + if (iters.some(function (iter) { return iter.includes(value); })) { + toRemove.push(value); + } + }); + return this.withMutations(function (set) { + toRemove.forEach(function (value) { + set.remove(value); + }); + }); + }; + + Set.prototype.merge = function merge () { + return this.union.apply(this, arguments); + }; + + Set.prototype.mergeWith = function mergeWith (merger) { + var iters = [], len = arguments.length - 1; + while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; + + return this.union.apply(this, iters); + }; + + Set.prototype.sort = function sort (comparator) { + // Late binding + return OrderedSet(sortFactory(this, comparator)); + }; + + Set.prototype.sortBy = function sortBy (mapper, comparator) { + // Late binding + return OrderedSet(sortFactory(this, comparator, mapper)); + }; + + Set.prototype.wasAltered = function wasAltered () { + return this._map.wasAltered(); + }; + + Set.prototype.__iterate = function __iterate (fn, reverse) { + var this$1 = this; + + return this._map.__iterate(function (_, k) { return fn(k, k, this$1); }, reverse); + }; + + Set.prototype.__iterator = function __iterator (type, reverse) { + return this._map.map(function (_, k) { return k; }).__iterator(type, reverse); + }; + + Set.prototype.__ensureOwner = function __ensureOwner (ownerID) { + if (ownerID === this.__ownerID) { + return this; + } + var newMap = this._map.__ensureOwner(ownerID); + if (!ownerID) { + if (this.size === 0) { + return emptySet(); + } + this.__ownerID = ownerID; + this._map = newMap; + return this; + } + return this.__make(newMap, ownerID); + }; + + return Set; +}(SetCollection)); + +function isSet(maybeSet) { + return !!(maybeSet && maybeSet[IS_SET_SENTINEL]); +} + +Set.isSet = isSet; + +var IS_SET_SENTINEL = '@@__IMMUTABLE_SET__@@'; + +var SetPrototype = Set.prototype; +SetPrototype[IS_SET_SENTINEL] = true; +SetPrototype[DELETE] = SetPrototype.remove; +SetPrototype.mergeDeep = SetPrototype.merge; +SetPrototype.mergeDeepWith = SetPrototype.mergeWith; +SetPrototype.withMutations = MapPrototype.withMutations; +SetPrototype.asMutable = MapPrototype.asMutable; +SetPrototype.asImmutable = MapPrototype.asImmutable; +SetPrototype['@@transducer/init'] = SetPrototype.asMutable; +SetPrototype['@@transducer/step'] = function(result, arr) { + return result.add(arr); +}; +SetPrototype['@@transducer/result'] = MapPrototype['@@transducer/result']; + +SetPrototype.__empty = emptySet; +SetPrototype.__make = makeSet; + +function updateSet(set, newMap) { + if (set.__ownerID) { + set.size = newMap.size; + set._map = newMap; + return set; + } + return newMap === set._map + ? set + : newMap.size === 0 ? set.__empty() : set.__make(newMap); +} + +function makeSet(map, ownerID) { + var set = Object.create(SetPrototype); + set.size = map ? map.size : 0; + set._map = map; + set.__ownerID = ownerID; + return set; +} + +var EMPTY_SET; +function emptySet() { + return EMPTY_SET || (EMPTY_SET = makeSet(emptyMap())); +} + +/** + * Returns a lazy seq of nums from start (inclusive) to end + * (exclusive), by step, where start defaults to 0, step to 1, and end to + * infinity. When start is equal to end, returns empty list. + */ +var Range = (function (IndexedSeq$$1) { + function Range(start, end, step) { + if (!(this instanceof Range)) { + return new Range(start, end, step); + } + invariant(step !== 0, 'Cannot step a Range by 0'); + start = start || 0; + if (end === undefined) { + end = Infinity; + } + step = step === undefined ? 1 : Math.abs(step); + if (end < start) { + step = -step; + } + this._start = start; + this._end = end; + this._step = step; + this.size = Math.max(0, Math.ceil((end - start) / step - 1) + 1); + if (this.size === 0) { + if (EMPTY_RANGE) { + return EMPTY_RANGE; + } + EMPTY_RANGE = this; + } + } + + if ( IndexedSeq$$1 ) Range.__proto__ = IndexedSeq$$1; + Range.prototype = Object.create( IndexedSeq$$1 && IndexedSeq$$1.prototype ); + Range.prototype.constructor = Range; + + Range.prototype.toString = function toString () { + if (this.size === 0) { + return 'Range []'; + } + return 'Range [ ' + + this._start + + '...' + + this._end + + (this._step !== 1 ? ' by ' + this._step : '') + + ' ]'; + }; + + Range.prototype.get = function get (index, notSetValue) { + return this.has(index) + ? this._start + wrapIndex(this, index) * this._step + : notSetValue; + }; + + Range.prototype.includes = function includes (searchValue) { + var possibleIndex = (searchValue - this._start) / this._step; + return possibleIndex >= 0 && + possibleIndex < this.size && + possibleIndex === Math.floor(possibleIndex); + }; + + Range.prototype.slice = function slice (begin, end) { + if (wholeSlice(begin, end, this.size)) { + return this; + } + begin = resolveBegin(begin, this.size); + end = resolveEnd(end, this.size); + if (end <= begin) { + return new Range(0, 0); + } + return new Range( + this.get(begin, this._end), + this.get(end, this._end), + this._step + ); + }; + + Range.prototype.indexOf = function indexOf (searchValue) { + var offsetValue = searchValue - this._start; + if (offsetValue % this._step === 0) { + var index = offsetValue / this._step; + if (index >= 0 && index < this.size) { + return index; + } + } + return -1; + }; + + Range.prototype.lastIndexOf = function lastIndexOf (searchValue) { + return this.indexOf(searchValue); + }; + + Range.prototype.__iterate = function __iterate (fn, reverse) { + var this$1 = this; + + var size = this.size; + var step = this._step; + var value = reverse ? this._start + (size - 1) * step : this._start; + var i = 0; + while (i !== size) { + if (fn(value, reverse ? size - ++i : i++, this$1) === false) { + break; + } + value += reverse ? -step : step; + } + return i; + }; + + Range.prototype.__iterator = function __iterator (type, reverse) { + var size = this.size; + var step = this._step; + var value = reverse ? this._start + (size - 1) * step : this._start; + var i = 0; + return new Iterator(function () { + if (i === size) { + return iteratorDone(); + } + var v = value; + value += reverse ? -step : step; + return iteratorValue(type, reverse ? size - ++i : i++, v); + }); + }; + + Range.prototype.equals = function equals (other) { + return other instanceof Range + ? this._start === other._start && + this._end === other._end && + this._step === other._step + : deepEqual(this, other); + }; + + return Range; +}(IndexedSeq)); + +var EMPTY_RANGE; + +// Note: all of these methods are deprecated. +Collection.isIterable = isCollection; +Collection.isKeyed = isKeyed; +Collection.isIndexed = isIndexed; +Collection.isAssociative = isAssociative; +Collection.isOrdered = isOrdered; + +Collection.Iterator = Iterator; + +mixin(Collection, { + // ### Conversion to other types + + toArray: function toArray() { + assertNotInfinite(this.size); + var array = new Array(this.size || 0); + this.valueSeq().__iterate(function (v, i) { + array[i] = v; + }); + return array; + }, + + toIndexedSeq: function toIndexedSeq() { + return new ToIndexedSequence(this); + }, + + toJS: function toJS$1() { + return this.toSeq().map(toJS).toJSON(); + }, + + toKeyedSeq: function toKeyedSeq() { + return new ToKeyedSequence(this, true); + }, + + toMap: function toMap() { + // Use Late Binding here to solve the circular dependency. + return Map(this.toKeyedSeq()); + }, + + toObject: function toObject() { + assertNotInfinite(this.size); + var object = {}; + this.__iterate(function (v, k) { + object[k] = v; + }); + return object; + }, + + toOrderedMap: function toOrderedMap() { + // Use Late Binding here to solve the circular dependency. + return OrderedMap(this.toKeyedSeq()); + }, + + toOrderedSet: function toOrderedSet() { + // Use Late Binding here to solve the circular dependency. + return OrderedSet(isKeyed(this) ? this.valueSeq() : this); + }, + + toSet: function toSet() { + // Use Late Binding here to solve the circular dependency. + return Set(isKeyed(this) ? this.valueSeq() : this); + }, + + toSetSeq: function toSetSeq() { + return new ToSetSequence(this); + }, + + toSeq: function toSeq() { + return isIndexed(this) + ? this.toIndexedSeq() + : isKeyed(this) ? this.toKeyedSeq() : this.toSetSeq(); + }, + + toStack: function toStack() { + // Use Late Binding here to solve the circular dependency. + return Stack(isKeyed(this) ? this.valueSeq() : this); + }, + + toList: function toList() { + // Use Late Binding here to solve the circular dependency. + return List(isKeyed(this) ? this.valueSeq() : this); + }, + + // ### Common JavaScript methods and properties + + toString: function toString() { + return '[Collection]'; + }, + + __toString: function __toString(head, tail) { + if (this.size === 0) { + return head + tail; + } + return head + + ' ' + + this.toSeq().map(this.__toStringMapper).join(', ') + + ' ' + + tail; + }, + + // ### ES6 Collection methods (ES6 Array and Map) + + concat: function concat() { + var values = [], len = arguments.length; + while ( len-- ) values[ len ] = arguments[ len ]; + + return reify(this, concatFactory(this, values)); + }, + + includes: function includes(searchValue) { + return this.some(function (value) { return is(value, searchValue); }); + }, + + entries: function entries() { + return this.__iterator(ITERATE_ENTRIES); + }, + + every: function every(predicate, context) { + assertNotInfinite(this.size); + var returnValue = true; + this.__iterate(function (v, k, c) { + if (!predicate.call(context, v, k, c)) { + returnValue = false; + return false; + } + }); + return returnValue; + }, + + filter: function filter(predicate, context) { + return reify(this, filterFactory(this, predicate, context, true)); + }, + + find: function find(predicate, context, notSetValue) { + var entry = this.findEntry(predicate, context); + return entry ? entry[1] : notSetValue; + }, + + forEach: function forEach(sideEffect, context) { + assertNotInfinite(this.size); + return this.__iterate(context ? sideEffect.bind(context) : sideEffect); + }, + + join: function join(separator) { + assertNotInfinite(this.size); + separator = separator !== undefined ? '' + separator : ','; + var joined = ''; + var isFirst = true; + this.__iterate(function (v) { + isFirst ? (isFirst = false) : (joined += separator); + joined += v !== null && v !== undefined ? v.toString() : ''; + }); + return joined; + }, + + keys: function keys() { + return this.__iterator(ITERATE_KEYS); + }, + + map: function map(mapper, context) { + return reify(this, mapFactory(this, mapper, context)); + }, + + reduce: function reduce$1(reducer, initialReduction, context) { + return reduce( + this, + reducer, + initialReduction, + context, + arguments.length < 2, + false + ); + }, + + reduceRight: function reduceRight(reducer, initialReduction, context) { + return reduce( + this, + reducer, + initialReduction, + context, + arguments.length < 2, + true + ); + }, + + reverse: function reverse() { + return reify(this, reverseFactory(this, true)); + }, + + slice: function slice(begin, end) { + return reify(this, sliceFactory(this, begin, end, true)); + }, + + some: function some(predicate, context) { + return !this.every(not(predicate), context); + }, + + sort: function sort(comparator) { + return reify(this, sortFactory(this, comparator)); + }, + + values: function values() { + return this.__iterator(ITERATE_VALUES); + }, + + // ### More sequential methods + + butLast: function butLast() { + return this.slice(0, -1); + }, + + isEmpty: function isEmpty() { + return this.size !== undefined ? this.size === 0 : !this.some(function () { return true; }); + }, + + count: function count(predicate, context) { + return ensureSize( + predicate ? this.toSeq().filter(predicate, context) : this + ); + }, + + countBy: function countBy(grouper, context) { + return countByFactory(this, grouper, context); + }, + + equals: function equals(other) { + return deepEqual(this, other); + }, + + entrySeq: function entrySeq() { + var collection = this; + if (collection._cache) { + // We cache as an entries array, so we can just return the cache! + return new ArraySeq(collection._cache); + } + var entriesSequence = collection.toSeq().map(entryMapper).toIndexedSeq(); + entriesSequence.fromEntrySeq = function () { return collection.toSeq(); }; + + // Entries are plain Array, which do not define toJS, so it must + // manually converts keys and values before conversion. + entriesSequence.toJS = function() { + return this.map(function (entry) { return [toJS(entry[0]), toJS(entry[1])]; }).toJSON(); + }; + + return entriesSequence; + }, + + filterNot: function filterNot(predicate, context) { + return this.filter(not(predicate), context); + }, + + findEntry: function findEntry(predicate, context, notSetValue) { + var found = notSetValue; + this.__iterate(function (v, k, c) { + if (predicate.call(context, v, k, c)) { + found = [k, v]; + return false; + } + }); + return found; + }, + + findKey: function findKey(predicate, context) { + var entry = this.findEntry(predicate, context); + return entry && entry[0]; + }, + + findLast: function findLast(predicate, context, notSetValue) { + return this.toKeyedSeq().reverse().find(predicate, context, notSetValue); + }, + + findLastEntry: function findLastEntry(predicate, context, notSetValue) { + return this.toKeyedSeq() + .reverse() + .findEntry(predicate, context, notSetValue); + }, + + findLastKey: function findLastKey(predicate, context) { + return this.toKeyedSeq().reverse().findKey(predicate, context); + }, + + first: function first() { + return this.find(returnTrue); + }, + + flatMap: function flatMap(mapper, context) { + return reify(this, flatMapFactory(this, mapper, context)); + }, + + flatten: function flatten(depth) { + return reify(this, flattenFactory(this, depth, true)); + }, + + fromEntrySeq: function fromEntrySeq() { + return new FromEntriesSequence(this); + }, + + get: function get(searchKey, notSetValue) { + return this.find(function (_, key) { return is(key, searchKey); }, undefined, notSetValue); + }, + + getIn: function getIn(searchKeyPath, notSetValue) { + var nested = this; + var keyPath = coerceKeyPath(searchKeyPath); + var i = 0; + while (i !== keyPath.length) { + if (!nested || !nested.get) { + warn( + 'Invalid keyPath: Value at [' + + keyPath.slice(0, i).map(quoteString) + + '] does not have a .get() method: ' + + nested + + '\nThis warning will throw in a future version' + ); + return notSetValue; + } + nested = nested.get(keyPath[i++], NOT_SET); + if (nested === NOT_SET) { + return notSetValue; + } + } + return nested; + }, + + groupBy: function groupBy(grouper, context) { + return groupByFactory(this, grouper, context); + }, + + has: function has(searchKey) { + return this.get(searchKey, NOT_SET) !== NOT_SET; + }, + + hasIn: function hasIn(searchKeyPath) { + return this.getIn(searchKeyPath, NOT_SET) !== NOT_SET; + }, + + isSubset: function isSubset(iter) { + iter = typeof iter.includes === 'function' ? iter : Collection(iter); + return this.every(function (value) { return iter.includes(value); }); + }, + + isSuperset: function isSuperset(iter) { + iter = typeof iter.isSubset === 'function' ? iter : Collection(iter); + return iter.isSubset(this); + }, + + keyOf: function keyOf(searchValue) { + return this.findKey(function (value) { return is(value, searchValue); }); + }, + + keySeq: function keySeq() { + return this.toSeq().map(keyMapper).toIndexedSeq(); + }, + + last: function last() { + return this.toSeq().reverse().first(); + }, + + lastKeyOf: function lastKeyOf(searchValue) { + return this.toKeyedSeq().reverse().keyOf(searchValue); + }, + + max: function max(comparator) { + return maxFactory(this, comparator); + }, + + maxBy: function maxBy(mapper, comparator) { + return maxFactory(this, comparator, mapper); + }, + + min: function min(comparator) { + return maxFactory( + this, + comparator ? neg(comparator) : defaultNegComparator + ); + }, + + minBy: function minBy(mapper, comparator) { + return maxFactory( + this, + comparator ? neg(comparator) : defaultNegComparator, + mapper + ); + }, + + rest: function rest() { + return this.slice(1); + }, + + skip: function skip(amount) { + return amount === 0 ? this : this.slice(Math.max(0, amount)); + }, + + skipLast: function skipLast(amount) { + return amount === 0 ? this : this.slice(0, -Math.max(0, amount)); + }, + + skipWhile: function skipWhile(predicate, context) { + return reify(this, skipWhileFactory(this, predicate, context, true)); + }, + + skipUntil: function skipUntil(predicate, context) { + return this.skipWhile(not(predicate), context); + }, + + sortBy: function sortBy(mapper, comparator) { + return reify(this, sortFactory(this, comparator, mapper)); + }, + + take: function take(amount) { + return this.slice(0, Math.max(0, amount)); + }, + + takeLast: function takeLast(amount) { + return this.slice(-Math.max(0, amount)); + }, + + takeWhile: function takeWhile(predicate, context) { + return reify(this, takeWhileFactory(this, predicate, context)); + }, + + takeUntil: function takeUntil(predicate, context) { + return this.takeWhile(not(predicate), context); + }, + + update: function update(fn) { + return fn(this); + }, + + valueSeq: function valueSeq() { + return this.toIndexedSeq(); + }, + + // ### Hashable Object + + hashCode: function hashCode() { + return this.__hash || (this.__hash = hashCollection(this)); + } + + // ### Internal + + // abstract __iterate(fn, reverse) + + // abstract __iterator(type, reverse) +}); + +var CollectionPrototype = Collection.prototype; +CollectionPrototype[IS_ITERABLE_SENTINEL] = true; +CollectionPrototype[ITERATOR_SYMBOL] = CollectionPrototype.values; +CollectionPrototype.toJSON = CollectionPrototype.toArray; +CollectionPrototype.__toStringMapper = quoteString; +CollectionPrototype.inspect = (CollectionPrototype.toSource = function() { + return this.toString(); +}); +CollectionPrototype.chain = CollectionPrototype.flatMap; +CollectionPrototype.contains = CollectionPrototype.includes; + +mixin(KeyedCollection, { + // ### More sequential methods + + flip: function flip() { + return reify(this, flipFactory(this)); + }, + + mapEntries: function mapEntries(mapper, context) { + var this$1 = this; + + var iterations = 0; + return reify( + this, + this.toSeq() + .map(function (v, k) { return mapper.call(context, [k, v], iterations++, this$1); }) + .fromEntrySeq() + ); + }, + + mapKeys: function mapKeys(mapper, context) { + var this$1 = this; + + return reify( + this, + this.toSeq().flip().map(function (k, v) { return mapper.call(context, k, v, this$1); }).flip() + ); + } +}); + +var KeyedCollectionPrototype = KeyedCollection.prototype; +KeyedCollectionPrototype[IS_KEYED_SENTINEL] = true; +KeyedCollectionPrototype[ITERATOR_SYMBOL] = CollectionPrototype.entries; +KeyedCollectionPrototype.toJSON = CollectionPrototype.toObject; +KeyedCollectionPrototype.__toStringMapper = function (v, k) { return quoteString(k) + ': ' + quoteString(v); }; + +mixin(IndexedCollection, { + // ### Conversion to other types + + toKeyedSeq: function toKeyedSeq() { + return new ToKeyedSequence(this, false); + }, + + // ### ES6 Collection methods (ES6 Array and Map) + + filter: function filter(predicate, context) { + return reify(this, filterFactory(this, predicate, context, false)); + }, + + findIndex: function findIndex(predicate, context) { + var entry = this.findEntry(predicate, context); + return entry ? entry[0] : -1; + }, + + indexOf: function indexOf(searchValue) { + var key = this.keyOf(searchValue); + return key === undefined ? -1 : key; + }, + + lastIndexOf: function lastIndexOf(searchValue) { + var key = this.lastKeyOf(searchValue); + return key === undefined ? -1 : key; + }, + + reverse: function reverse() { + return reify(this, reverseFactory(this, false)); + }, + + slice: function slice(begin, end) { + return reify(this, sliceFactory(this, begin, end, false)); + }, + + splice: function splice(index, removeNum /*, ...values*/) { + var numArgs = arguments.length; + removeNum = Math.max(removeNum || 0, 0); + if (numArgs === 0 || (numArgs === 2 && !removeNum)) { + return this; + } + // If index is negative, it should resolve relative to the size of the + // collection. However size may be expensive to compute if not cached, so + // only call count() if the number is in fact negative. + index = resolveBegin(index, index < 0 ? this.count() : this.size); + var spliced = this.slice(0, index); + return reify( + this, + numArgs === 1 + ? spliced + : spliced.concat(arrCopy(arguments, 2), this.slice(index + removeNum)) + ); + }, + + // ### More collection methods + + findLastIndex: function findLastIndex(predicate, context) { + var entry = this.findLastEntry(predicate, context); + return entry ? entry[0] : -1; + }, + + first: function first() { + return this.get(0); + }, + + flatten: function flatten(depth) { + return reify(this, flattenFactory(this, depth, false)); + }, + + get: function get(index, notSetValue) { + index = wrapIndex(this, index); + return index < 0 || + (this.size === Infinity || (this.size !== undefined && index > this.size)) + ? notSetValue + : this.find(function (_, key) { return key === index; }, undefined, notSetValue); + }, + + has: function has(index) { + index = wrapIndex(this, index); + return index >= 0 && + (this.size !== undefined + ? this.size === Infinity || index < this.size + : this.indexOf(index) !== -1); + }, + + interpose: function interpose(separator) { + return reify(this, interposeFactory(this, separator)); + }, + + interleave: function interleave(/*...collections*/) { + var collections = [this].concat(arrCopy(arguments)); + var zipped = zipWithFactory(this.toSeq(), IndexedSeq.of, collections); + var interleaved = zipped.flatten(true); + if (zipped.size) { + interleaved.size = zipped.size * collections.length; + } + return reify(this, interleaved); + }, + + keySeq: function keySeq() { + return Range(0, this.size); + }, + + last: function last() { + return this.get(-1); + }, + + skipWhile: function skipWhile(predicate, context) { + return reify(this, skipWhileFactory(this, predicate, context, false)); + }, + + zip: function zip(/*, ...collections */) { + var collections = [this].concat(arrCopy(arguments)); + return reify(this, zipWithFactory(this, defaultZipper, collections)); + }, + + zipWith: function zipWith(zipper /*, ...collections */) { + var collections = arrCopy(arguments); + collections[0] = this; + return reify(this, zipWithFactory(this, zipper, collections)); + } +}); + +var IndexedCollectionPrototype = IndexedCollection.prototype; +IndexedCollectionPrototype[IS_INDEXED_SENTINEL] = true; +IndexedCollectionPrototype[IS_ORDERED_SENTINEL] = true; + +mixin(SetCollection, { + // ### ES6 Collection methods (ES6 Array and Map) + + get: function get(value, notSetValue) { + return this.has(value) ? value : notSetValue; + }, + + includes: function includes(value) { + return this.has(value); + }, + + // ### More sequential methods + + keySeq: function keySeq() { + return this.valueSeq(); + } +}); + +SetCollection.prototype.has = CollectionPrototype.includes; +SetCollection.prototype.contains = SetCollection.prototype.includes; + +// Mixin subclasses + +mixin(KeyedSeq, KeyedCollection.prototype); +mixin(IndexedSeq, IndexedCollection.prototype); +mixin(SetSeq, SetCollection.prototype); + +// #pragma Helper functions + +function reduce(collection, reducer, reduction, context, useFirst, reverse) { + assertNotInfinite(collection.size); + collection.__iterate( + function (v, k, c) { + if (useFirst) { + useFirst = false; + reduction = v; + } else { + reduction = reducer.call(context, reduction, v, k, c); + } + }, + reverse + ); + return reduction; +} + +function keyMapper(v, k) { + return k; +} + +function entryMapper(v, k) { + return [k, v]; +} + +function toJS(value) { + return value && typeof value.toJS === 'function' ? value.toJS() : value; +} + +function not(predicate) { + return function() { + return !predicate.apply(this, arguments); + }; +} + +function neg(predicate) { + return function() { + return -predicate.apply(this, arguments); + }; +} + +function defaultZipper() { + return arrCopy(arguments); +} + +function defaultNegComparator(a, b) { + return a < b ? 1 : a > b ? -1 : 0; +} + +function hashCollection(collection) { + if (collection.size === Infinity) { + return 0; + } + var ordered = isOrdered(collection); + var keyed = isKeyed(collection); + var h = ordered ? 1 : 0; + var size = collection.__iterate( + keyed + ? ordered + ? function (v, k) { + h = 31 * h + hashMerge(hash(v), hash(k)) | 0; + } + : function (v, k) { + h = h + hashMerge(hash(v), hash(k)) | 0; + } + : ordered + ? function (v) { + h = 31 * h + hash(v) | 0; + } + : function (v) { + h = h + hash(v) | 0; + } + ); + return murmurHashOfSize(size, h); +} + +function murmurHashOfSize(size, h) { + h = imul(h, 0xcc9e2d51); + h = imul(h << 15 | h >>> -15, 0x1b873593); + h = imul(h << 13 | h >>> -13, 5); + h = (h + 0xe6546b64 | 0) ^ size; + h = imul(h ^ h >>> 16, 0x85ebca6b); + h = imul(h ^ h >>> 13, 0xc2b2ae35); + h = smi(h ^ h >>> 16); + return h; +} + +function hashMerge(a, b) { + return a ^ b + 0x9e3779b9 + (a << 6) + (a >> 2) | 0; // int +} + +function warn(message) { + /* eslint-disable no-console */ + if (typeof console === 'object' && console.warn) { + console.warn(message); + } else { + throw new Error(message); + } + /* eslint-enable no-console */ +} + +var OrderedSet = (function (Set$$1) { + function OrderedSet(value) { + return value === null || value === undefined + ? emptyOrderedSet() + : isOrderedSet(value) + ? value + : emptyOrderedSet().withMutations(function (set) { + var iter = SetCollection(value); + assertNotInfinite(iter.size); + iter.forEach(function (v) { return set.add(v); }); + }); + } + + if ( Set$$1 ) OrderedSet.__proto__ = Set$$1; + OrderedSet.prototype = Object.create( Set$$1 && Set$$1.prototype ); + OrderedSet.prototype.constructor = OrderedSet; + + OrderedSet.of = function of (/*...values*/) { + return this(arguments); + }; + + OrderedSet.fromKeys = function fromKeys (value) { + return this(KeyedCollection(value).keySeq()); + }; + + OrderedSet.prototype.toString = function toString () { + return this.__toString('OrderedSet {', '}'); + }; + + return OrderedSet; +}(Set)); + +function isOrderedSet(maybeOrderedSet) { + return isSet(maybeOrderedSet) && isOrdered(maybeOrderedSet); +} + +OrderedSet.isOrderedSet = isOrderedSet; + +var OrderedSetPrototype = OrderedSet.prototype; +OrderedSetPrototype[IS_ORDERED_SENTINEL] = true; +OrderedSetPrototype.zip = IndexedCollectionPrototype.zip; +OrderedSetPrototype.zipWith = IndexedCollectionPrototype.zipWith; + +OrderedSetPrototype.__empty = emptyOrderedSet; +OrderedSetPrototype.__make = makeOrderedSet; + +function makeOrderedSet(map, ownerID) { + var set = Object.create(OrderedSetPrototype); + set.size = map ? map.size : 0; + set._map = map; + set.__ownerID = ownerID; + return set; +} + +var EMPTY_ORDERED_SET; +function emptyOrderedSet() { + return EMPTY_ORDERED_SET || + (EMPTY_ORDERED_SET = makeOrderedSet(emptyOrderedMap())); +} + +var Record = function Record(defaultValues, name) { + var hasInitialized; + + var RecordType = function Record(values) { + var this$1 = this; + + if (values instanceof RecordType) { + return values; + } + if (!(this instanceof RecordType)) { + return new RecordType(values); + } + if (!hasInitialized) { + hasInitialized = true; + var keys = Object.keys(defaultValues); + var indices = (RecordTypePrototype._indices = {}); + RecordTypePrototype._name = name; + RecordTypePrototype._keys = keys; + RecordTypePrototype._defaultValues = defaultValues; + for (var i = 0; i < keys.length; i++) { + var propName = keys[i]; + indices[propName] = i; + if (RecordTypePrototype[propName]) { + /* eslint-disable no-console */ + typeof console === 'object' && + console.warn && + console.warn( + 'Cannot define ' + + recordName(this$1) + + ' with property "' + + propName + + '" since that property name is part of the Record API.' + ); + /* eslint-enable no-console */ + } else { + setProp(RecordTypePrototype, propName); + } + } + } + this.__ownerID = undefined; + this._values = List().withMutations(function (l) { + l.setSize(this$1._keys.length); + KeyedCollection(values).forEach(function (v, k) { + l.set(this$1._indices[k], v === this$1._defaultValues[k] ? undefined : v); + }); + }); + }; + + var RecordTypePrototype = (RecordType.prototype = Object.create( + RecordPrototype + )); + RecordTypePrototype.constructor = RecordType; + + return RecordType; +}; + +Record.prototype.toString = function toString () { + var this$1 = this; + + var str = recordName(this) + ' { '; + var keys = this._keys; + var k; + for (var i = 0, l = keys.length; i !== l; i++) { + k = keys[i]; + str += (i ? ', ' : '') + k + ': ' + quoteString(this$1.get(k)); + } + return str + ' }'; +}; + +Record.prototype.equals = function equals (other) { + return this === other || + (other && + this._keys === other._keys && + recordSeq(this).equals(recordSeq(other))); +}; + +Record.prototype.hashCode = function hashCode () { + return recordSeq(this).hashCode(); +}; + +// @pragma Access + +Record.prototype.has = function has (k) { + return this._indices.hasOwnProperty(k); +}; + +Record.prototype.get = function get (k, notSetValue) { + if (!this.has(k)) { + return notSetValue; + } + var index = this._indices[k]; + var value = this._values.get(index); + return value === undefined ? this._defaultValues[k] : value; +}; + +// @pragma Modification + +Record.prototype.set = function set (k, v) { + if (this.has(k)) { + var newValues = this._values.set( + this._indices[k], + v === this._defaultValues[k] ? undefined : v + ); + if (newValues !== this._values && !this.__ownerID) { + return makeRecord(this, newValues); + } + } + return this; +}; + +Record.prototype.remove = function remove (k) { + return this.set(k); +}; + +Record.prototype.clear = function clear () { + var newValues = this._values.clear().setSize(this._keys.length); + return this.__ownerID ? this : makeRecord(this, newValues); +}; + +Record.prototype.wasAltered = function wasAltered () { + return this._values.wasAltered(); +}; + +Record.prototype.toSeq = function toSeq () { + return recordSeq(this); +}; + +Record.prototype.toJS = function toJS () { + return recordSeq(this).toJS(); +}; + +Record.prototype.__iterator = function __iterator (type, reverse) { + return recordSeq(this).__iterator(type, reverse); +}; + +Record.prototype.__iterate = function __iterate (fn, reverse) { + return recordSeq(this).__iterate(fn, reverse); +}; + +Record.prototype.__ensureOwner = function __ensureOwner (ownerID) { + if (ownerID === this.__ownerID) { + return this; + } + var newValues = this._values.__ensureOwner(ownerID); + if (!ownerID) { + this.__ownerID = ownerID; + this._values = newValues; + return this; + } + return makeRecord(this, newValues, ownerID); +}; + +Record.isRecord = isRecord; +Record.getDescriptiveName = recordName; +var RecordPrototype = Record.prototype; +RecordPrototype[IS_RECORD_SENTINEL] = true; +RecordPrototype[DELETE] = RecordPrototype.remove; +RecordPrototype.deleteIn = (RecordPrototype.removeIn = MapPrototype.removeIn); +RecordPrototype.getIn = CollectionPrototype.getIn; +RecordPrototype.hasIn = CollectionPrototype.hasIn; +RecordPrototype.merge = MapPrototype.merge; +RecordPrototype.mergeWith = MapPrototype.mergeWith; +RecordPrototype.mergeIn = MapPrototype.mergeIn; +RecordPrototype.mergeDeep = MapPrototype.mergeDeep; +RecordPrototype.mergeDeepWith = MapPrototype.mergeDeepWith; +RecordPrototype.mergeDeepIn = MapPrototype.mergeDeepIn; +RecordPrototype.setIn = MapPrototype.setIn; +RecordPrototype.update = MapPrototype.update; +RecordPrototype.updateIn = MapPrototype.updateIn; +RecordPrototype.withMutations = MapPrototype.withMutations; +RecordPrototype.asMutable = MapPrototype.asMutable; +RecordPrototype.asImmutable = MapPrototype.asImmutable; +RecordPrototype[ITERATOR_SYMBOL] = CollectionPrototype.entries; +RecordPrototype.toJSON = (RecordPrototype.toObject = CollectionPrototype.toObject); +RecordPrototype.inspect = (RecordPrototype.toSource = CollectionPrototype.toSource); + +function makeRecord(likeRecord, values, ownerID) { + var record = Object.create(Object.getPrototypeOf(likeRecord)); + record._values = values; + record.__ownerID = ownerID; + return record; +} + +function recordName(record) { + return record._name || record.constructor.name || 'Record'; +} + +function recordSeq(record) { + return keyedSeqFromValue(record._keys.map(function (k) { return [k, record.get(k)]; })); +} + +function setProp(prototype, name) { + try { + Object.defineProperty(prototype, name, { + get: function() { + return this.get(name); + }, + set: function(value) { + invariant(this.__ownerID, 'Cannot set on an immutable record.'); + this.set(name, value); + } + }); + } catch (error) { + // Object.defineProperty failed. Probably IE8. + } +} + +/** + * Returns a lazy Seq of `value` repeated `times` times. When `times` is + * undefined, returns an infinite sequence of `value`. + */ +var Repeat = (function (IndexedSeq$$1) { + function Repeat(value, times) { + if (!(this instanceof Repeat)) { + return new Repeat(value, times); + } + this._value = value; + this.size = times === undefined ? Infinity : Math.max(0, times); + if (this.size === 0) { + if (EMPTY_REPEAT) { + return EMPTY_REPEAT; + } + EMPTY_REPEAT = this; + } + } + + if ( IndexedSeq$$1 ) Repeat.__proto__ = IndexedSeq$$1; + Repeat.prototype = Object.create( IndexedSeq$$1 && IndexedSeq$$1.prototype ); + Repeat.prototype.constructor = Repeat; + + Repeat.prototype.toString = function toString () { + if (this.size === 0) { + return 'Repeat []'; + } + return 'Repeat [ ' + this._value + ' ' + this.size + ' times ]'; + }; + + Repeat.prototype.get = function get (index, notSetValue) { + return this.has(index) ? this._value : notSetValue; + }; + + Repeat.prototype.includes = function includes (searchValue) { + return is(this._value, searchValue); + }; + + Repeat.prototype.slice = function slice (begin, end) { + var size = this.size; + return wholeSlice(begin, end, size) + ? this + : new Repeat( + this._value, + resolveEnd(end, size) - resolveBegin(begin, size) + ); + }; + + Repeat.prototype.reverse = function reverse () { + return this; + }; + + Repeat.prototype.indexOf = function indexOf (searchValue) { + if (is(this._value, searchValue)) { + return 0; + } + return -1; + }; + + Repeat.prototype.lastIndexOf = function lastIndexOf (searchValue) { + if (is(this._value, searchValue)) { + return this.size; + } + return -1; + }; + + Repeat.prototype.__iterate = function __iterate (fn, reverse) { + var this$1 = this; + + var size = this.size; + var i = 0; + while (i !== size) { + if (fn(this$1._value, reverse ? size - ++i : i++, this$1) === false) { + break; + } + } + return i; + }; + + Repeat.prototype.__iterator = function __iterator (type, reverse) { + var this$1 = this; + + var size = this.size; + var i = 0; + return new Iterator( + function () { return i === size + ? iteratorDone() + : iteratorValue(type, reverse ? size - ++i : i++, this$1._value); } + ); + }; + + Repeat.prototype.equals = function equals (other) { + return other instanceof Repeat + ? is(this._value, other._value) + : deepEqual(other); + }; + + return Repeat; +}(IndexedSeq)); + +var EMPTY_REPEAT; + +var Immutable = { + Collection: Collection, + // Note: Iterable is deprecated + Iterable: Collection, + + Seq: Seq, + Map: Map, + OrderedMap: OrderedMap, + List: List, + Stack: Stack, + Set: Set, + OrderedSet: OrderedSet, + + Record: Record, + Range: Range, + Repeat: Repeat, + + is: is, + fromJS: fromJS, + hash: hash, + + isImmutable: isImmutable, + isCollection: isCollection, + isKeyed: isKeyed, + isIndexed: isIndexed, + isAssociative: isAssociative, + isOrdered: isOrdered, + isValueObject: isValueObject +}; + +// Note: Iterable is deprecated +var Iterable = Collection; + +exports['default'] = Immutable; +exports.Collection = Collection; +exports.Iterable = Iterable; +exports.Seq = Seq; +exports.Map = Map; +exports.OrderedMap = OrderedMap; +exports.List = List; +exports.Stack = Stack; +exports.Set = Set; +exports.OrderedSet = OrderedSet; +exports.Record = Record; +exports.Range = Range; +exports.Repeat = Repeat; +exports.is = is; +exports.fromJS = fromJS; +exports.hash = hash; +exports.isImmutable = isImmutable; +exports.isCollection = isCollection; +exports.isKeyed = isKeyed; +exports.isIndexed = isIndexed; +exports.isAssociative = isAssociative; +exports.isOrdered = isOrdered; +exports.isValueObject = isValueObject; + +Object.defineProperty(exports, '__esModule', { value: true }); + +}))); diff --git a/dist/immutable.js.flow b/dist/immutable.js.flow new file mode 100644 index 0000000000..c15797e79b --- /dev/null +++ b/dist/immutable.js.flow @@ -0,0 +1,1272 @@ +/** + * This file provides type definitions for use with the Flow type checker. + * + * An important caveat when using these definitions is that the types for + * `Collection.Keyed`, `Collection.Indexed`, `Seq.Keyed`, and so on are stubs. + * When referring to those types, you can get the proper definitions by + * importing the types `KeyedCollection`, `IndexedCollection`, `KeyedSeq`, etc. + * For example, + * + * import { Seq } from 'immutable' + * import type { IndexedCollection, IndexedSeq } from 'immutable' + * + * const someSeq: IndexedSeq = Seq.Indexed.of(1, 2, 3) + * + * function takesASeq>(iter: TS): TS { + * return iter.butLast() + * } + * + * takesASeq(someSeq) + * + * @flow + */ + +declare class _Collection /*implements ValueObject*/ { + equals(other: mixed): boolean; + hashCode(): number; + get(key: K, ..._: []): V | void; + get(key: K, notSetValue: NSV): V | NSV; + has(key: K): boolean; + includes(value: V): boolean; + contains(value: V): boolean; + first(): V | void; + last(): V | void; + + getIn(searchKeyPath: Iterable, notSetValue?: mixed): any; + hasIn(searchKeyPath: Iterable): boolean; + + update(updater: (value: this) => U): U; + + toJS(): Array | { [key: string]: mixed }; + toJSON(): Array | { [key: string]: V }; + toArray(): Array; + toObject(): { [key: string]: V }; + toMap(): Map; + toOrderedMap(): OrderedMap; + toSet(): Set; + toOrderedSet(): OrderedSet; + toList(): List; + toStack(): Stack; + toSeq(): Seq; + toKeyedSeq(): KeyedSeq; + toIndexedSeq(): IndexedSeq; + toSetSeq(): SetSeq; + + keys(): Iterator; + values(): Iterator; + entries(): Iterator<[K, V]>; + + keySeq(): IndexedSeq; + valueSeq(): IndexedSeq; + entrySeq(): IndexedSeq<[K, V]>; + + reverse(): this; + sort(comparator?: (valueA: V, valueB: V) => number): this; + + sortBy( + comparatorValueMapper: (value: V, key: K, iter: this) => C, + comparator?: (valueA: C, valueB: C) => number + ): this; + + groupBy( + grouper: (value: V, key: K, iter: this) => G, + context?: mixed + ): KeyedSeq; + + forEach( + sideEffect: (value: V, key: K, iter: this) => any, + context?: mixed + ): number; + + slice(begin?: number, end?: number): this; + rest(): this; + butLast(): this; + skip(amount: number): this; + skipLast(amount: number): this; + skipWhile(predicate: (value: V, key: K, iter: this) => mixed, context?: mixed): this; + skipUntil(predicate: (value: V, key: K, iter: this) => mixed, context?: mixed): this; + take(amount: number): this; + takeLast(amount: number): this; + takeWhile(predicate: (value: V, key: K, iter: this) => mixed, context?: mixed): this; + takeUntil(predicate: (value: V, key: K, iter: this) => mixed, context?: mixed): this; + + filter( + predicate: (value: V, key: K, iter: this) => mixed, + context?: mixed + ): this; + + filterNot( + predicate: (value: V, key: K, iter: this) => mixed, + context?: mixed + ): this; + + reduce( + reducer: (reduction: R, value: V, key: K, iter: this) => R, + initialReduction: R, + context?: mixed, + ): R; + reduce( + reducer: (reduction: V | R, value: V, key: K, iter: this) => R + ): R; + + reduceRight( + reducer: (reduction: R, value: V, key: K, iter: this) => R, + initialReduction: R, + context?: mixed, + ): R; + reduceRight( + reducer: (reduction: V | R, value: V, key: K, iter: this) => R + ): R; + + every(predicate: (value: V, key: K, iter: this) => mixed, context?: mixed): boolean; + some(predicate: (value: V, key: K, iter: this) => mixed, context?: mixed): boolean; + join(separator?: string): string; + isEmpty(): boolean; + count(predicate?: (value: V, key: K, iter: this) => mixed, context?: mixed): number; + countBy(grouper: (value: V, key: K, iter: this) => G, context?: mixed): Map; + + find( + predicate: (value: V, key: K, iter: this) => mixed, + context?: mixed, + notSetValue?: NSV + ): V | NSV; + findLast( + predicate: (value: V, key: K, iter: this) => mixed, + context?: mixed, + notSetValue?: NSV + ): V | NSV; + + findEntry(predicate: (value: V, key: K, iter: this) => mixed): [K, V] | void; + findLastEntry(predicate: (value: V, key: K, iter: this) => mixed): [K, V] | void; + + findKey(predicate: (value: V, key: K, iter: this) => mixed, context?: mixed): K | void; + findLastKey(predicate: (value: V, key: K, iter: this) => mixed, context?: mixed): K | void; + + keyOf(searchValue: V): K | void; + lastKeyOf(searchValue: V): K | void; + + max(comparator?: (valueA: V, valueB: V) => number): V; + maxBy( + comparatorValueMapper: (value: V, key: K, iter: this) => C, + comparator?: (valueA: C, valueB: C) => number + ): V; + min(comparator?: (valueA: V, valueB: V) => number): V; + minBy( + comparatorValueMapper: (value: V, key: K, iter: this) => C, + comparator?: (valueA: C, valueB: C) => number + ): V; + + isSubset(iter: Iterable): boolean; + isSuperset(iter: Iterable): boolean; +} + +declare function isImmutable(maybeImmutable: mixed): boolean %checks(maybeImmutable instanceof Collection); +declare function isCollection(maybeCollection: mixed): boolean %checks(maybeCollection instanceof Collection); +declare function isKeyed(maybeKeyed: mixed): boolean %checks(maybeKeyed instanceof KeyedCollection); +declare function isIndexed(maybeIndexed: mixed): boolean %checks(maybeIndexed instanceof IndexedCollection); +declare function isAssociative(maybeAssociative: mixed): boolean %checks( + maybeAssociative instanceof KeyedCollection || + maybeAssociative instanceof IndexedCollection +); +declare function isOrdered(maybeOrdered: mixed): boolean %checks( + maybeOrdered instanceof IndexedCollection || + maybeOrdered instanceof OrderedMap || + maybeOrdered instanceof OrderedSet +); +declare function isValueObject(maybeValue: mixed): boolean; + +declare interface ValueObject { + equals(other: mixed): boolean; + hashCode(): number; +} + +declare class Collection extends _Collection { + static Keyed: typeof KeyedCollection; + static Indexed: typeof IndexedCollection; + static Set: typeof SetCollection; + + static isCollection: typeof isCollection; + static isKeyed: typeof isKeyed; + static isIndexed: typeof isIndexed; + static isAssociative: typeof isAssociative; + static isOrdered: typeof isOrdered; +} + +declare class KeyedCollection extends Collection { + static (iter?: Iterable<[K, V]>): KeyedCollection; + static (obj?: { [key: K]: V }): KeyedCollection; + + toJS(): { [key: string]: mixed }; + toJSON(): { [key: string]: V }; + @@iterator(): Iterator<[K, V]>; + toSeq(): KeyedSeq; + flip(): KeyedCollection; + + concat(...iters: Array>): KeyedCollection; + concat(...iters: Array<{[key: string]: C}>): KeyedCollection; + + map( + mapper: (value: V, key: K, iter: this) => M, + context?: mixed + ): KeyedCollection; + + mapKeys( + mapper: (key: K, value: V, iter: this) => M, + context?: mixed + ): KeyedCollection; + + mapEntries( + mapper: (entry: [K, V], index: number, iter: this) => [KM, VM], + context?: mixed + ): KeyedCollection; + + flatMap( + mapper: (value: V, key: K, iter: this) => Iterable<[KM, VM]>, + context?: mixed + ): KeyedCollection; + + flatten(depth?: number): KeyedCollection; + flatten(shallow?: boolean): KeyedCollection; +} + +Collection.Keyed = KeyedCollection + +declare class IndexedCollection<+T> extends Collection { + static (iter?: Iterable): IndexedCollection; + + toJS(): Array; + toJSON(): Array; + @@iterator(): Iterator; + toSeq(): IndexedSeq; + fromEntrySeq(): KeyedSeq; + interpose(separator: T): this; + interleave(...collections: Iterable[]): this; + splice( + index: number, + removeNum: number, + ...values: T[] + ): this; + + zip( + a: Iterable, + ..._: [] + ): IndexedCollection<[T, A]>; + zip( + a: Iterable, + b: Iterable, + ..._: [] + ): IndexedCollection<[T, A, B]>; + zip( + a: Iterable, + b: Iterable, + c: Iterable, + ..._: [] + ): IndexedCollection<[T, A, B, C]>; + zip( + a: Iterable, + b: Iterable, + c: Iterable, + d: Iterable, + ..._: [] + ): IndexedCollection<[T, A, B, C, D]>; + zip( + a: Iterable, + b: Iterable, + c: Iterable, + d: Iterable, + e: Iterable, + ..._: [] + ): IndexedCollection<[T, A, B, C, D, E]>; + + zipWith( + zipper: (value: T, a: A) => R, + a: Iterable, + ..._: [] + ): IndexedCollection; + zipWith( + zipper: (value: T, a: A, b: B) => R, + a: Iterable, + b: Iterable, + ..._: [] + ): IndexedCollection; + zipWith( + zipper: (value: T, a: A, b: B, c: C) => R, + a: Iterable, + b: Iterable, + c: Iterable, + ..._: [] + ): IndexedCollection; + zipWith( + zipper: (value: T, a: A, b: B, c: C, d: D) => R, + a: Iterable, + b: Iterable, + c: Iterable, + d: Iterable, + ..._: [] + ): IndexedCollection; + zipWith( + zipper: (value: T, a: A, b: B, c: C, d: D, e: E) => R, + a: Iterable, + b: Iterable, + c: Iterable, + d: Iterable, + e: Iterable, + ..._: [] + ): IndexedCollection; + + indexOf(searchValue: T): number; + lastIndexOf(searchValue: T): number; + findIndex( + predicate: (value: T, index: number, iter: this) => mixed, + context?: mixed + ): number; + findLastIndex( + predicate: (value: T, index: number, iter: this) => mixed, + context?: mixed + ): number; + + concat(...iters: Array | C>): IndexedCollection; + + map( + mapper: (value: T, index: number, iter: this) => M, + context?: mixed + ): IndexedCollection; + + flatMap( + mapper: (value: T, index: number, iter: this) => Iterable, + context?: mixed + ): IndexedCollection; + + flatten(depth?: number): IndexedCollection; + flatten(shallow?: boolean): IndexedCollection; +} + +declare class SetCollection<+T> extends Collection { + static (iter?: Iterable): SetCollection; + + toJS(): Array; + toJSON(): Array; + @@iterator(): Iterator; + toSeq(): SetSeq; + + concat(...iters: Array | C>): SetCollection; + + // `map` and `flatMap` cannot be defined further up the hierarchy, because the + // implementation for `KeyedCollection` allows the value type to change without + // constraining the key type. That does not work for `SetCollection` - the value + // and key types *must* match. + map( + mapper: (value: T, value: T, iter: this) => M, + context?: mixed + ): SetCollection; + + flatMap( + mapper: (value: T, value: T, iter: this) => Iterable, + context?: mixed + ): SetCollection; + + flatten(depth?: number): SetCollection; + flatten(shallow?: boolean): SetCollection; +} + +declare function isSeq(maybeSeq: mixed): boolean %checks(maybeSeq instanceof Seq); +declare class Seq extends _Collection { + static Keyed: typeof KeyedSeq; + static Indexed: typeof IndexedSeq; + static Set: typeof SetSeq; + + static (iter: KeyedSeq): KeyedSeq; + static (iter: SetSeq): SetSeq; + static (iter?: Iterable): IndexedSeq; + static (iter: { [key: K]: V }): KeyedSeq; + + static isSeq: typeof isSeq; + + size: number | void; + cacheResult(): this; + toSeq(): this; +} + +declare class KeyedSeq extends Seq mixins KeyedCollection { + static (iter?: Iterable<[K, V]>): KeyedSeq; + static (iter?: { [key: K]: V }): KeyedSeq; + + // Override specialized return types + flip(): KeyedSeq; + + concat(...iters: Array>): KeyedSeq; + concat(...iters: Array<{[key: string]: C}>): KeyedSeq; + + map( + mapper: (value: V, key: K, iter: this) => M, + context?: mixed + ): KeyedSeq; + + mapKeys( + mapper: (key: K, value: V, iter: this) => M, + context?: mixed + ): KeyedSeq; + + mapEntries( + mapper: (entry: [K, V], index: number, iter: this) => [KM, VM], + context?: mixed + ): KeyedSeq; + + flatMap( + mapper: (value: V, key: K, iter: this) => Iterable<[KM, VM]>, + context?: mixed + ): KeyedSeq; + + flatten(depth?: number): KeyedSeq; + flatten(shallow?: boolean): KeyedSeq; +} + +declare class IndexedSeq<+T> extends Seq mixins IndexedCollection { + static (iter?: Iterable): IndexedSeq; + + static of(...values: T[]): IndexedSeq; + + // Override specialized return types + + concat(...iters: Array | C>): IndexedSeq; + + map( + mapper: (value: T, index: number, iter: this) => M, + context?: mixed + ): IndexedSeq; + + flatMap( + mapper: (value: T, index: number, iter: this) => Iterable, + context?: mixed + ): IndexedSeq; + + flatten(depth?: number): IndexedSeq; + flatten(shallow?: boolean): IndexedSeq; + + zip( + a: Iterable, + ..._: [] + ): IndexedSeq<[T, A]>; + zip( + a: Iterable, + b: Iterable, + ..._: [] + ): IndexedSeq<[T, A, B]>; + zip( + a: Iterable, + b: Iterable, + c: Iterable, + ..._: [] + ): IndexedSeq<[T, A, B, C]>; + zip( + a: Iterable, + b: Iterable, + c: Iterable, + d: Iterable, + ..._: [] + ): IndexedSeq<[T, A, B, C, D]>; + zip( + a: Iterable, + b: Iterable, + c: Iterable, + d: Iterable, + e: Iterable, + ..._: [] + ): IndexedSeq<[T, A, B, C, D, E]>; + + zipWith( + zipper: (value: T, a: A) => R, + a: Iterable, + ..._: [] + ): IndexedSeq; + zipWith( + zipper: (value: T, a: A, b: B) => R, + a: Iterable, + b: Iterable, + ..._: [] + ): IndexedSeq; + zipWith( + zipper: (value: T, a: A, b: B, c: C) => R, + a: Iterable, + b: Iterable, + c: Iterable, + ..._: [] + ): IndexedSeq; + zipWith( + zipper: (value: T, a: A, b: B, c: C, d: D) => R, + a: Iterable, + b: Iterable, + c: Iterable, + d: Iterable, + ..._: [] + ): IndexedSeq; + zipWith( + zipper: (value: T, a: A, b: B, c: C, d: D, e: E) => R, + a: Iterable, + b: Iterable, + c: Iterable, + d: Iterable, + e: Iterable, + ..._: [] + ): IndexedSeq; +} + +declare class SetSeq<+T> extends Seq mixins SetCollection { + static (iter?: Iterable): IndexedSeq; + + static of(...values: T[]): SetSeq; + + // Override specialized return types + + concat(...iters: Array | C>): SetSeq; + + map( + mapper: (value: T, value: T, iter: this) => M, + context?: mixed + ): SetSeq; + + flatMap( + mapper: (value: T, value: T, iter: this) => Iterable, + context?: mixed + ): SetSeq; + + flatten(depth?: number): SetSeq; + flatten(shallow?: boolean): SetSeq; +} + +declare function isList(maybeList: mixed): boolean %checks(maybeList instanceof List); +declare class List<+T> extends IndexedCollection { + static (collection?: Iterable): List; + + static of(...values: T[]): List; + + static isList: typeof isList; + + size: number; + + set(index: number, value: U): List; + delete(index: number): this; + remove(index: number): this; + insert(index: number, value: U): List; + clear(): this; + push(...values: U[]): List; + pop(): this; + unshift(...values: U[]): List; + shift(): this; + + update(updater: (value: this) => U): U; + update(index: number, updater: (value: T) => U): List; + update(index: number, notSetValue: U, updater: (value: T) => U): List; + + merge(...collections: Iterable[]): List; + + mergeWith( + merger: (oldVal: T, newVal: U, key: number) => V, + ...collections: Iterable[] + ): List; + + mergeDeep(...collections: Iterable[]): List; + + mergeDeepWith( + merger: (oldVal: T, newVal: U, key: number) => V, + ...collections: Iterable[] + ): List; + + setSize(size: number): this; + setIn(keyPath: Iterable, value: mixed): this; + deleteIn(keyPath: Iterable, value: mixed): this; + removeIn(keyPath: Iterable, value: mixed): this; + + updateIn( + keyPath: Iterable, + notSetValue: mixed, + updater: (value: any) => mixed + ): this; + updateIn( + keyPath: Iterable, + updater: (value: any) => mixed + ): this; + + mergeIn(keyPath: Iterable, ...collections: Iterable[]): this; + mergeDeepIn(keyPath: Iterable, ...collections: Iterable[]): this; + + withMutations(mutator: (mutable: this) => mixed): this; + asMutable(): this; + asImmutable(): this; + + // Override specialized return types + + concat(...iters: Array | C>): List; + + map( + mapper: (value: T, index: number, iter: this) => M, + context?: mixed + ): List; + + flatMap( + mapper: (value: T, index: number, iter: this) => Iterable, + context?: mixed + ): List; + + flatten(depth?: number): List; + flatten(shallow?: boolean): List; + + zip( + a: Iterable, + ..._: [] + ): List<[T, A]>; + zip( + a: Iterable, + b: Iterable, + ..._: [] + ): List<[T, A, B]>; + zip( + a: Iterable, + b: Iterable, + c: Iterable, + ..._: [] + ): List<[T, A, B, C]>; + zip( + a: Iterable, + b: Iterable, + c: Iterable, + d: Iterable, + ..._: [] + ): List<[T, A, B, C, D]>; + zip( + a: Iterable, + b: Iterable, + c: Iterable, + d: Iterable, + e: Iterable, + ..._: [] + ): List<[T, A, B, C, D, E]>; + + zipWith( + zipper: (value: T, a: A) => R, + a: Iterable, + ..._: [] + ): List; + zipWith( + zipper: (value: T, a: A, b: B) => R, + a: Iterable, + b: Iterable, + ..._: [] + ): List; + zipWith( + zipper: (value: T, a: A, b: B, c: C) => R, + a: Iterable, + b: Iterable, + c: Iterable, + ..._: [] + ): List; + zipWith( + zipper: (value: T, a: A, b: B, c: C, d: D) => R, + a: Iterable, + b: Iterable, + c: Iterable, + d: Iterable, + ..._: [] + ): List; + zipWith( + zipper: (value: T, a: A, b: B, c: C, d: D, e: E) => R, + a: Iterable, + b: Iterable, + c: Iterable, + d: Iterable, + e: Iterable, + ..._: [] + ): List; +} + +declare function isMap(maybeMap: mixed): boolean %checks(maybeMap instanceof Map); +declare class Map extends KeyedCollection { + static (obj?: {[key: K]: V}): Map; + static (collection: Iterable<[K, V]>): Map; + + static isMap: typeof isMap; + + size: number; + + set(key: K_, value: V_): Map; + delete(key: K): this; + remove(key: K): this; + clear(): this; + + deleteAll(keys: Iterable): Map; + removeAll(keys: Iterable): Map; + + update(updater: (value: this) => U): U; + update(key: K, updater: (value: V) => V_): Map; + update(key: K, notSetValue: V_, updater: (value: V) => V_): Map; + + merge( + ...collections: (Iterable<[K_, V_]> | { [key: K_]: V_ })[] + ): Map; + + mergeWith( + merger: (oldVal: V, newVal: W, key: K) => X, + ...collections: (Iterable<[K_, W]> | { [key: K_]: W })[] + ): Map; + + mergeDeep( + ...collections: (Iterable<[K_, V_]> | { [key: K_]: V_ })[] + ): Map; + + mergeDeepWith( + merger: (oldVal: V, newVal: W, key: K) => X, + ...collections: (Iterable<[K_, W]> | { [key: K_]: W })[] + ): Map; + + setIn(keyPath: Iterable, value: mixed): this; + deleteIn(keyPath: Iterable, value: mixed): this; + removeIn(keyPath: Iterable, value: mixed): this; + + updateIn( + keyPath: Iterable, + notSetValue: mixed, + updater: (value: any) => mixed + ): this; + updateIn( + keyPath: Iterable, + updater: (value: any) => mixed + ): this; + + mergeIn( + keyPath: Iterable, + ...collections: (Iterable | { [key: string]: mixed })[] + ): this; + mergeDeepIn( + keyPath: Iterable, + ...collections: (Iterable | { [key: string]: mixed })[] + ): this; + + withMutations(mutator: (mutable: this) => mixed): this; + asMutable(): this; + asImmutable(): this; + + // Override specialized return types + + flip(): Map; + + concat(...iters: Array>): Map; + concat(...iters: Array<{[key: string]: C}>): Map; + + map( + mapper: (value: V, key: K, iter: this) => M, + context?: mixed + ): Map; + + mapKeys( + mapper: (key: K, value: V, iter: this) => M, + context?: mixed + ): Map; + + mapEntries( + mapper: (entry: [K, V], index: number, iter: this) => [KM, VM], + context?: mixed + ): Map; + + flatMap( + mapper: (value: V, key: K, iter: this) => Iterable<[KM, VM]>, + context?: mixed + ): Map; + + flatten(depth?: number): Map; + flatten(shallow?: boolean): Map; +} + +declare function isOrderedMap(maybeOrderedMap: mixed): boolean %checks(maybeOrderedMap instanceof OrderedMap); +declare class OrderedMap extends Map { + static (obj?: {[key: K]: V}): OrderedMap; + static (collection: Iterable<[K, V]>): OrderedMap; + + static isOrderedMap: typeof isOrderedMap; + + size: number; + + set(key: K_, value: V_): OrderedMap; + delete(key: K): this; + remove(key: K): this; + clear(): this; + + update(updater: (value: this) => U): U; + update(key: K, updater: (value: V) => V_): OrderedMap; + update(key: K, notSetValue: V_, updater: (value: V) => V_): OrderedMap; + + merge( + ...collections: (Iterable<[K_, V_]> | { [key: K_]: V_ })[] + ): OrderedMap; + + mergeWith( + merger: (oldVal: V, newVal: W, key: K) => X, + ...collections: (Iterable<[K_, W]> | { [key: K_]: W })[] + ): OrderedMap; + + mergeDeep( + ...collections: (Iterable<[K_, V_]> | { [key: K_]: V_ })[] + ): OrderedMap; + + mergeDeepWith( + merger: (oldVal: V, newVal: W, key: K) => X, + ...collections: (Iterable<[K_, W]> | { [key: K_]: W })[] + ): OrderedMap; + + setIn(keyPath: Iterable, value: mixed): this; + deleteIn(keyPath: Iterable, value: mixed): this; + removeIn(keyPath: Iterable, value: mixed): this; + + updateIn( + keyPath: Iterable, + notSetValue: mixed, + updater: (value: any) => mixed + ): this; + updateIn( + keyPath: Iterable, + updater: (value: any) => mixed + ): this; + + mergeIn( + keyPath: Iterable, + ...collections: (Iterable | { [key: string]: mixed })[] + ): this; + mergeDeepIn( + keyPath: Iterable, + ...collections: (Iterable | { [key: string]: mixed })[] + ): this; + + withMutations(mutator: (mutable: this) => mixed): this; + asMutable(): this; + asImmutable(): this; + + // Override specialized return types + + flip(): OrderedMap; + + concat(...iters: Array>): OrderedMap; + concat(...iters: Array<{[key: string]: C}>): OrderedMap; + + map( + mapper: (value: V, key: K, iter: this) => M, + context?: mixed + ): OrderedMap; + + mapKeys( + mapper: (key: K, value: V, iter: this) => M, + context?: mixed + ): OrderedMap; + + mapEntries( + mapper: (entry: [K, V], index: number, iter: this) => [KM, VM], + context?: mixed + ): OrderedMap; + + flatMap( + mapper: (value: V, key: K, iter: this) => Iterable<[KM, VM]>, + context?: mixed + ): OrderedMap; + + flatten(depth?: number): OrderedMap; + flatten(shallow?: boolean): OrderedMap; +} + +declare function isSet(maybeSet: mixed): boolean %checks(maybeSet instanceof Set); +declare class Set<+T> extends SetCollection { + static (collection?: Iterable): Set; + + static of(...values: T[]): Set; + static fromKeys(iter: Iterable<[T, mixed]>): Set; + static fromKeys(object: { [key: K]: V }): Set; + + static intersect(sets: Iterable>): Set; + static union(sets: Iterable>): Set; + + static isSet: typeof isSet; + + size: number; + + add(value: U): Set; + delete(value: T): this; + remove(value: T): this; + clear(): this; + union(...collections: Iterable[]): Set; + merge(...collections: Iterable[]): Set; + intersect(...collections: Iterable[]): Set; + subtract(...collections: Iterable[]): this; + + withMutations(mutator: (mutable: this) => mixed): this; + asMutable(): this; + asImmutable(): this; + + // Override specialized return types + + concat(...iters: Array | C>): Set; + + map( + mapper: (value: T, value: T, iter: this) => M, + context?: mixed + ): Set; + + flatMap( + mapper: (value: T, value: T, iter: this) => Iterable, + context?: mixed + ): Set; + + flatten(depth?: number): Set; + flatten(shallow?: boolean): Set; +} + +// Overrides except for `isOrderedSet` are for specialized return types +declare function isOrderedSet(maybeOrderedSet: mixed): boolean %checks(maybeOrderedSet instanceof OrderedSet); +declare class OrderedSet<+T> extends Set { + static (collection: Iterable): OrderedSet; + static (_: void): OrderedSet; + + static of(...values: T[]): OrderedSet; + static fromKeys(iter: Iterable<[T, mixed]>): OrderedSet; + static fromKeys(object: { [key: K]: V }): OrderedSet; + + static isOrderedSet: typeof isOrderedSet; + + size: number; + + add(value: U): OrderedSet; + union(...collections: Iterable[]): OrderedSet; + merge(...collections: Iterable[]): OrderedSet; + intersect(...collections: Iterable[]): OrderedSet; + + concat(...iters: Array | C>): OrderedSet; + + map( + mapper: (value: T, value: T, iter: this) => M, + context?: mixed + ): OrderedSet; + + flatMap( + mapper: (value: T, value: T, iter: this) => Iterable, + context?: mixed + ): OrderedSet; + + flatten(depth?: number): OrderedSet; + flatten(shallow?: boolean): OrderedSet; + + zip( + a: Iterable, + ..._: [] + ): OrderedSet<[T, A]>; + zip( + a: Iterable, + b: Iterable, + ..._: [] + ): OrderedSet<[T, A, B]>; + zip( + a: Iterable, + b: Iterable, + c: Iterable, + ..._: [] + ): OrderedSet<[T, A, B, C]>; + zip( + a: Iterable, + b: Iterable, + c: Iterable, + d: Iterable, + ..._: [] + ): OrderedSet<[T, A, B, C, D]>; + zip( + a: Iterable, + b: Iterable, + c: Iterable, + d: Iterable, + e: Iterable, + ..._: [] + ): OrderedSet<[T, A, B, C, D, E]>; + + zipWith( + zipper: (value: T, a: A) => R, + a: Iterable, + ..._: [] + ): OrderedSet; + zipWith( + zipper: (value: T, a: A, b: B) => R, + a: Iterable, + b: Iterable, + ..._: [] + ): OrderedSet; + zipWith( + zipper: (value: T, a: A, b: B, c: C) => R, + a: Iterable, + b: Iterable, + c: Iterable, + ..._: [] + ): OrderedSet; + zipWith( + zipper: (value: T, a: A, b: B, c: C, d: D) => R, + a: Iterable, + b: Iterable, + c: Iterable, + d: Iterable, + ..._: [] + ): OrderedSet; + zipWith( + zipper: (value: T, a: A, b: B, c: C, d: D, e: E) => R, + a: Iterable, + b: Iterable, + c: Iterable, + d: Iterable, + e: Iterable, + ..._: [] + ): OrderedSet; +} + +declare function isStack(maybeStack: mixed): boolean %checks(maybeStack instanceof Stack); +declare class Stack<+T> extends IndexedCollection { + static (collection?: Iterable): Stack; + + static isStack(maybeStack: mixed): boolean; + static of(...values: T[]): Stack; + + static isStack: typeof isStack; + + size: number; + + peek(): T; + clear(): this; + unshift(...values: U[]): Stack; + unshiftAll(iter: Iterable): Stack; + shift(): this; + push(...values: U[]): Stack; + pushAll(iter: Iterable): Stack; + pop(): this; + + withMutations(mutator: (mutable: this) => mixed): this; + asMutable(): this; + asImmutable(): this; + + // Override specialized return types + + concat(...iters: Array | C>): Stack; + + map( + mapper: (value: T, index: number, iter: this) => M, + context?: mixed + ): Stack; + + flatMap( + mapper: (value: T, index: number, iter: this) => Iterable, + context?: mixed + ): Stack; + + flatten(depth?: number): Stack; + flatten(shallow?: boolean): Stack; + + zip( + a: Iterable, + ..._: [] + ): Stack<[T, A]>; + zip( + a: Iterable, + b: Iterable, + ..._: [] + ): Stack<[T, A, B]>; + zip( + a: Iterable, + b: Iterable, + c: Iterable, + ..._: [] + ): Stack<[T, A, B, C]>; + zip( + a: Iterable, + b: Iterable, + c: Iterable, + d: Iterable, + ..._: [] + ): Stack<[T, A, B, C, D]>; + zip( + a: Iterable, + b: Iterable, + c: Iterable, + d: Iterable, + e: Iterable, + ..._: [] + ): Stack<[T, A, B, C, D, E]>; + + zipWith( + zipper: (value: T, a: A) => R, + a: Iterable, + ..._: [] + ): Stack; + zipWith( + zipper: (value: T, a: A, b: B) => R, + a: Iterable, + b: Iterable, + ..._: [] + ): Stack; + zipWith( + zipper: (value: T, a: A, b: B, c: C) => R, + a: Iterable, + b: Iterable, + c: Iterable, + ..._: [] + ): Stack; + zipWith( + zipper: (value: T, a: A, b: B, c: C, d: D) => R, + a: Iterable, + b: Iterable, + c: Iterable, + d: Iterable, + ..._: [] + ): Stack; + zipWith( + zipper: (value: T, a: A, b: B, c: C, d: D, e: E) => R, + a: Iterable, + b: Iterable, + c: Iterable, + d: Iterable, + e: Iterable, + ..._: [] + ): Stack; +} + +declare function Range(start?: number, end?: number, step?: number): IndexedSeq; +declare function Repeat(value: T, times?: number): IndexedSeq; + +declare function isRecord(maybeRecord: any): boolean %checks(maybeRecord instanceof RecordInstance); +declare class Record { + static (spec: Values, name?: string): RecordClass; + constructor(spec: Values, name?: string): RecordClass; + + static isRecord: typeof isRecord; + + static getDescriptiveName(record: RecordInstance<*>): string; +} + +declare interface RecordClass { + (values: $Shape | Iterable<[string, any]>): RecordInstance & T; + new (values: $Shape | Iterable<[string, any]>): RecordInstance & T; +} + +declare class RecordInstance { + size: number; + + has(key: string): boolean; + get>(key: K): $ElementType; + + equals(other: any): boolean; + hashCode(): number; + + set>(key: K, value: $ElementType): this & T; + update>(key: K, updater: (value: $ElementType) => $ElementType): this & T; + merge(...collections: Array<$Shape | Iterable<[string, any]>>): this & T; + mergeDeep(...collections: Array<$Shape | Iterable<[string, any]>>): this & T; + + mergeWith( + merger: (oldVal: any, newVal: any, key: $Keys) => any, + ...collections: Array<$Shape | Iterable<[string, any]>> + ): this & T; + mergeDeepWith( + merger: (oldVal: any, newVal: any, key: any) => any, + ...collections: Array<$Shape | Iterable<[string, any]>> + ): this & T; + + delete>(key: K): this & T; + remove>(key: K): this & T; + clear(): this & T; + + setIn(keyPath: Iterable, value: any): this & T; + updateIn(keyPath: Iterable, updater: (value: any) => any): this & T; + mergeIn(keyPath: Iterable, ...collections: Array): this & T; + mergeDeepIn(keyPath: Iterable, ...collections: Array): this & T; + deleteIn(keyPath: Iterable): this & T; + removeIn(keyPath: Iterable): this & T; + + toSeq(): KeyedSeq<$Keys, any>; + + toJS(): { [key: $Keys]: mixed }; + toJSON(): T; + toObject(): T; + + withMutations(mutator: (mutable: this) => mixed): this & T; + asMutable(): this & T; + asImmutable(): this & T; + + @@iterator(): Iterator<[$Keys, any]>; +} + +declare function fromJS( + jsValue: mixed, + reviver?: ( + key: string | number, + sequence: KeyedCollection | IndexedCollection, + path?: Array + ) => mixed +): mixed; + +declare function is(first: mixed, second: mixed): boolean; +declare function hash(value: mixed): number; + +export { + Collection, + Seq, + + List, + Map, + OrderedMap, + OrderedSet, + Range, + Repeat, + Record, + Set, + Stack, + + fromJS, + is, + hash, + + isImmutable, + isCollection, + isKeyed, + isIndexed, + isAssociative, + isOrdered, + isRecord, + isValueObject, +} + +export default { + Collection, + Seq, + + List, + Map, + OrderedMap, + OrderedSet, + Range, + Repeat, + Record, + Set, + Stack, + + fromJS, + is, + hash, + + isImmutable, + isCollection, + isKeyed, + isIndexed, + isAssociative, + isOrdered, + isRecord, + isValueObject, +} + +export type { + KeyedCollection, + IndexedCollection, + SetCollection, + KeyedSeq, + IndexedSeq, + RecordInstance, + SetSeq, + ValueObject, +} diff --git a/dist/immutable.min.js b/dist/immutable.min.js new file mode 100644 index 0000000000..e2c83c54f3 --- /dev/null +++ b/dist/immutable.min.js @@ -0,0 +1,39 @@ +/** + * Copyright (c) 2014-2015, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.Immutable=t.Immutable||{})}(this,function(t){"use strict";function e(t){return t.value=!1,t}function r(t){t&&(t.value=!0)}function n(){}function i(t,e){e=e||0;for(var r=Math.max(0,t.length-e),n=Array(r),i=0;i>>0;if(""+r!==e||4294967295===r)return NaN;e=r}return e<0?o(t)+e:e}function s(){return!0}function a(t,e,r){return(0===t&&!p(t)||void 0!==r&&t<=-r)&&(void 0===e||void 0!==r&&e>=r)}function c(t,e){return f(t,e,0)}function h(t,e){return f(t,e,e)}function f(t,e,r){return void 0===t?r:p(t)?e===1/0?e:0|Math.max(0,e+t):void 0===e||e===t?t:0|Math.min(e,t)}function p(t){return t<0||0===t&&1/t==-(1/0)}function _(t){return(l(t)||m(t))&&!t.__ownerID}function l(t){return!(!t||!t[Re])}function v(t){return!(!t||!t[Ue])}function y(t){return!(!t||!t[Ke])}function d(t){return v(t)||y(t)}function g(t){return!(!t||!t[Le])}function m(t){return!(!t||!t[Te])}function w(t){return!(!t||"function"!=typeof t.equals||"function"!=typeof t.hashCode)}function z(t,e,r,n){var i=0===t?e:1===t?r:[e,r];return n?n.value=i:n={value:i,done:!1},n}function S(){return{value:void 0,done:!0}}function I(t){return!!M(t)}function b(t){return t&&"function"==typeof t.next}function O(t){var e=M(t);return e&&e.call(t)}function M(t){var e=t&&(He&&t[He]||t[Ye]);if("function"==typeof e)return e}function D(t){return t&&"number"==typeof t.length}function q(t){return!(!t||!t[tr])}function E(){return nr||(nr=new er([]))}function x(t){var e=Array.isArray(t)?new er(t):b(t)?new ur(t):I(t)?new or(t):void 0;if(e)return e.fromEntrySeq();if("object"==typeof t)return new rr(t);throw new TypeError("Expected Array or collection object of [k, v] entries, or keyed object: "+t)}function j(t){var e=A(t);if(e)return e;throw new TypeError("Expected Array or collection object of values: "+t)} +function k(t){var e=A(t);if(e)return e;if("object"==typeof t)return new rr(t);throw new TypeError("Expected Array or collection object of values, or keyed object: "+t)}function A(t){return D(t)?new er(t):b(t)?new ur(t):I(t)?new or(t):void 0}function R(t,e){if(t===e||t!==t&&e!==e)return!0;if(!t||!e)return!1;if("function"==typeof t.valueOf&&"function"==typeof e.valueOf){if(t=t.valueOf(),e=e.valueOf(),t===e||t!==t&&e!==e)return!0;if(!t||!e)return!1}return!!(w(t)&&w(e)&&t.equals(e))}function U(t,e){return K([],e||L,t,"",e&&e.length>2?[]:void 0,{"":t})}function K(t,e,r,n,i,o){var u=Array.isArray(r)?Ze:T(r)?Ge:null;if(u){if(~t.indexOf(r))throw new TypeError("Cannot convert circular structure to Immutable");t.push(r),i&&""!==n&&i.push(n);var s=e.call(o,n,u(r).map(function(n,o){return K(t,e,n,o,i,r)}),i&&i.slice());return t.pop(),i&&i.pop(),s}return r}function L(t,e){return v(e)?e.toMap():e.toList()}function T(t){return t&&(t.constructor===Object||void 0===t.constructor)}function C(t){return t>>>1&1073741824|3221225471&t}function W(t){if(t===!1||null===t||void 0===t)return 0;if("function"==typeof t.valueOf&&((t=t.valueOf())===!1||null===t||void 0===t))return 0;if(t===!0)return 1;var e=typeof t;if("number"===e){if(t!==t||t===1/0)return 0;var r=0|t;for(r!==t&&(r^=4294967295*t);t>4294967295;)t/=4294967295,r^=t;return C(r)}if("string"===e)return t.length>_r?B(t):J(t);if("function"==typeof t.hashCode)return C(t.hashCode());if("object"===e)return P(t);if("function"==typeof t.toString)return J(""+t);throw Error("Value type "+e+" cannot be hashed.")}function B(t){var e=yr[t];return void 0===e&&(e=J(t),vr===lr&&(vr=0,yr={}),vr++,yr[t]=e),e}function J(t){for(var e=0,r=0;r0)switch(t.nodeType){case 1:return t.uniqueID;case 9:return t.documentElement&&t.documentElement.uniqueID}}function V(t){var e=ft(t);return e._iter=t,e.size=t.size,e.flip=function(){return t},e.reverse=function(){var e=t.reverse.apply(this);return e.flip=function(){return t.reverse()},e},e.has=function(e){return t.includes(e)},e.includes=function(e){return t.has(e)},e.cacheResult=pt,e.__iterateUncached=function(e,r){var n=this;return t.__iterate(function(t,r){return e(r,t,n)!==!1},r)},e.__iteratorUncached=function(e,r){if(e===Ve){var n=t.__iterator(e,r);return new Xe(function(){var t=n.next();if(!t.done){var e=t.value[0];t.value[0]=t.value[1],t.value[1]=e}return t})}return t.__iterator(e===Ne?Pe:Ne,r)},e}function H(t,e,r){var n=ft(t);return n.size=t.size,n.has=function(e){return t.has(e)},n.get=function(n,i){var o=t.get(n,je);return o===je?i:e.call(r,o,n,t)},n.__iterateUncached=function(n,i){var o=this;return t.__iterate(function(t,i,u){return n(e.call(r,t,i,u),i,o)!==!1},i)},n.__iteratorUncached=function(n,i){var o=t.__iterator(Ve,i);return new Xe(function(){var i=o.next();if(i.done)return i;var u=i.value,s=u[0];return z(n,s,e.call(r,u[1],s,t),i)})},n}function Y(t,e){var r=this,n=ft(t);return n._iter=t,n.size=t.size,n.reverse=function(){return t},t.flip&&(n.flip=function(){var e=V(t);return e.reverse=function(){return t.flip()},e}),n.get=function(r,n){return t.get(e?r:-1-r,n)},n.has=function(r){return t.has(e?r:-1-r)},n.includes=function(e){ +return t.includes(e)},n.cacheResult=pt,n.__iterate=function(r,n){var i=this,u=0;return n&&o(t),t.__iterate(function(t,o){return r(t,e?o:n?i.size-++u:u++,i)},!n)},n.__iterator=function(n,i){var u=0;i&&o(t);var s=t.__iterator(Ve,!i);return new Xe(function(){var t=s.next();if(t.done)return t;var o=t.value;return z(n,e?o[0]:i?r.size-++u:u++,o[1],t)})},n}function Q(t,e,r,n){var i=ft(t);return n&&(i.has=function(n){var i=t.get(n,je);return i!==je&&!!e.call(r,i,n,t)},i.get=function(n,i){var o=t.get(n,je);return o!==je&&e.call(r,o,n,t)?o:i}),i.__iterateUncached=function(i,o){var u=this,s=0;return t.__iterate(function(t,o,a){if(e.call(r,t,o,a))return s++,i(t,n?o:s-1,u)},o),s},i.__iteratorUncached=function(i,o){var u=t.__iterator(Ve,o),s=0;return new Xe(function(){for(;;){var o=u.next();if(o.done)return o;var a=o.value,c=a[0],h=a[1];if(e.call(r,h,c,t))return z(i,n?c:s++,h,o)}})},i}function X(t,e,r){var n=zr().asMutable();return t.__iterate(function(i,o){n.update(e.call(r,i,o,t),0,function(t){return t+1})}),n.asImmutable()}function F(t,e,r){var n=v(t),i=(g(t)?Wr():zr()).asMutable();t.__iterate(function(o,u){i.update(e.call(r,o,u,t),function(t){return t=t||[],t.push(n?[u,o]:o),t})});var o=ht(t);return i.map(function(e){return at(t,o(e))})}function G(t,e,r,n){var i=t.size;if(a(e,r,i))return t;var o=c(e,i),s=h(r,i);if(o!==o||s!==s)return G(t.toSeq().cacheResult(),e,r,n);var f,p=s-o;p===p&&(f=p<0?0:p);var _=ft(t);return _.size=0===f?f:t.size&&f||void 0,!n&&q(t)&&f>=0&&(_.get=function(e,r){return e=u(this,e),e>=0&&ef)return S();var t=i.next() +;return n||e===Ne?t:e===Pe?z(e,s-1,void 0,t):z(e,s-1,t.value[1],t)})},_}function Z(t,e,r){var n=ft(t);return n.__iterateUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterate(n,i);var u=0;return t.__iterate(function(t,i,s){return e.call(r,t,i,s)&&++u&&n(t,i,o)}),u},n.__iteratorUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterator(n,i);var u=t.__iterator(Ve,i),s=!0;return new Xe(function(){if(!s)return S();var t=u.next();if(t.done)return t;var i=t.value,a=i[0],c=i[1];return e.call(r,c,a,o)?n===Ve?t:z(n,a,c,t):(s=!1,S())})},n}function $(t,e,r,n){var i=ft(t);return i.__iterateUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterate(i,o);var s=!0,a=0;return t.__iterate(function(t,o,c){if(!s||!(s=e.call(r,t,o,c)))return a++,i(t,n?o:a-1,u)}),a},i.__iteratorUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterator(i,o);var s=t.__iterator(Ve,o),a=!0,c=0;return new Xe(function(){var t,o,h;do{if(t=s.next(),t.done)return n||i===Ne?t:i===Pe?z(i,c++,void 0,t):z(i,c++,t.value[1],t);var f=t.value;o=f[0],h=f[1],a&&(a=e.call(r,h,o,u))}while(a);return i===Ve?t:z(i,o,h,t)})},i}function tt(t,e){var r=v(t),n=[t].concat(e).map(function(t){return l(t)?r&&(t=We(t)):t=r?x(t):j(Array.isArray(t)?t:[t]),t}).filter(function(t){return 0!==t.size});if(0===n.length)return t;if(1===n.length){var i=n[0];if(i===t||r&&v(i)||y(t)&&y(i))return i}var o=new er(n);return r?o=o.toKeyedSeq():y(t)||(o=o.toSetSeq()),o=o.flatten(!0),o.size=n.reduce(function(t,e){if(void 0!==t){var r=e.size;if(void 0!==r)return t+r}},0),o}function et(t,e,r){var n=ft(t);return n.__iterateUncached=function(i,o){function u(t,c){t.__iterate(function(t,o){return(!e||c0}function st(t,e,r){var n=ft(t);return n.size=new er(r).map(function(t){return t.size}).min(),n.__iterate=function(t,e){for(var r,n=this,i=this.__iterator(Ne,e),o=0;!(r=i.next()).done&&t(r.value,o++,n)!==!1;);return o},n.__iteratorUncached=function(t,n){var i=r.map(function(t){return t=Ce(t),O(n?t.reverse():t)}),o=0,u=!1;return new Xe(function(){var r;return u||(r=i.map(function(t){return t.next()}),u=r.some(function(t){return t.done})),u?S():z(t,o++,e.apply(null,r.map(function(t){return t.value})))})},n}function at(t,e){return t===e?t:q(t)?e:t.constructor(e)}function ct(t){if(t!==Object(t))throw new TypeError("Expected [K, V] tuple: "+t)}function ht(t){return v(t)?We:y(t)?Be:Je}function ft(t){return Object.create((v(t)?Ge:y(t)?Ze:$e).prototype)}function pt(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size, +this):Fe.prototype.cacheResult.call(this)}function _t(t,e){return void 0===t&&void 0===e?0:void 0===t?1:void 0===e?-1:t>e?1:t>>r)&xe,s=(0===r?n:n>>>r)&xe;return new Or(e,1<>>=1)u[s]=1&r?e[o++]:void 0;return u[n]=i,new Mr(t,o+1,u)}function xt(t,e,r){for(var n=[],i=0;i>1&1431655765,t=(858993459&t)+(t>>2&858993459),t=t+(t>>4)&252645135,t+=t>>8,127&(t+=t>>16)}function Kt(t,e,r,n){var o=n?t:i(t);return o[e]=r,o}function Lt(t,e,r,n){var i=t.length+1;if(n&&e+1===i)return t[e]=r,t;for(var o=Array(i),u=0,s=0;so?0:o-r,c=u-r;return c>Ee&&(c=Ee),function(){if(i===c)return Cr;var t=e?--c:i++;return n&&n[t]}}function i(t,n,i){var s,a=t&&t.array,c=i>o?0:o-i>>n,h=1+(u-i>>n);return h>Ee&&(h=Ee),function(){for(;;){if(s){var t=s();if(t!==Cr)return t;s=null}if(c===h)return Cr;var o=e?--h:c++;s=r(a&&a[o],n-qe,i+(o<=t.size||r<0)return t.withMutations(function(t){r<0?Yt(t,r).set(0,n):Yt(t,0,r+1).set(r,n)});r+=t._origin;var i=t._tail,o=t._root,s=e(Ae);return r>=Xt(t._capacity)?i=Nt(i,t.__ownerID,0,r,n,s):o=Nt(o,t.__ownerID,t._level,r,n,s),s.value?t.__ownerID?(t._root=o,t._tail=i,t.__hash=void 0,t.__altered=!0,t):Bt(t._origin,t._capacity,t._level,o,i):t}function Nt(t,e,n,i,o,u){var s=i>>>n&xe,a=t&&s0){var h=t&&t.array[s],f=Nt(h,e,n-qe,i,o,u);return f===h?t:(c=Vt(t,e),c.array[s]=f,c)}return a&&t.array[s]===o?t:(r(u),c=Vt(t,e),void 0===o&&s===c.array.length-1?c.array.pop():c.array[s]=o,c)}function Vt(t,e){return e&&t&&e===t.ownerID?t:new Lr(t?t.array.slice():[],e)}function Ht(t,e){if(e>=Xt(t._capacity))return t._tail;if(e<1<0;)r=r.array[e>>>n&xe],n-=qe;return r}}function Yt(t,e,r){void 0!==e&&(e|=0),void 0!==r&&(r|=0);var i=t.__ownerID||new n,o=t._origin,u=t._capacity,s=o+e,a=void 0===r?u:r<0?u+r:o+r;if(s===o&&a===u)return t;if(s>=a)return t.clear();for(var c=t._level,h=t._root,f=0;s+f<0;)h=new Lr(h&&h.array.length?[void 0,h]:[],i),c+=qe,f+=1<=1<p?new Lr([],i):l;if(l&&_>p&&sqe;d-=qe){var g=p>>>d&xe;y=y.array[g]=Vt(y.array[g],i)}y.array[p>>>qe&xe]=l}if(a=_)s-=_,a-=_,c=qe,h=null,v=v&&v.removeBefore(i,0,s);else if(s>o||_>>c&xe;if(m!==_>>>c&xe)break;m&&(f+=(1<o&&(h=h.removeBefore(i,c,s-f)),h&&_i&&(i=s.size),l(u)||(s=s.map(function(t){return U(t)})),n.push(s)}return i>t.size&&(t=t.setSize(i)), +At(t,e,n)}function Xt(t){return t>>qe<=Ee&&u.size>=2*o.size?(i=u.filter(function(t,e){return void 0!==t&&s!==e}),n=i.toKeyedSeq().map(function(t){return t[0]}).flip().toMap(),t.__ownerID&&(n.__ownerID=i.__ownerID=t.__ownerID)):(n=o.remove(e),i=s===u.size-1?u.pop():u.set(s,void 0))}else if(a){if(r===u.get(s)[1])return t;n=o,i=u.set(s,[e,r])}else n=o.set(e,u.size),i=u.set(u.size,[e,r]);return t.__ownerID?(t.size=n.size,t._map=n,t._list=i,t.__hash=void 0,t):Gt(n,i)}function te(t){return!(!t||!t[Pr])}function ee(t,e,r,n){var i=Object.create(Nr);return i.size=t,i._head=e,i.__ownerID=r,i.__hash=n,i.__altered=!1,i}function re(){return Vr||(Vr=ee(0))}function ne(t,e){if(t===e)return!0;if(!l(e)||void 0!==t.size&&void 0!==e.size&&t.size!==e.size||void 0!==t.__hash&&void 0!==e.__hash&&t.__hash!==e.__hash||v(t)!==v(e)||y(t)!==y(e)||g(t)!==g(e))return!1;if(0===t.size&&0===e.size)return!0;var r=!d(t);if(g(t)){var n=t.entries();return e.every(function(t,e){var i=n.next().value;return i&&R(i[1],t)&&(r||R(i[0],e))})&&n.next().done}var i=!1;if(void 0===t.size)if(void 0===e.size)"function"==typeof t.cacheResult&&t.cacheResult();else{i=!0;var o=t;t=e,e=o}var u=!0,s=e.__iterate(function(e,n){if(r?!t.has(e):i?!R(e,t.get(n,je)):!R(t.get(n,je),e))return u=!1,!1});return u&&t.size===s}function ie(t,e){var r=function(r){t.prototype[r]=e[r]};return Object.keys(e).forEach(r),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(e).forEach(r),t}function oe(t){return!(!t||!t[Yr])}function ue(t,e){return t.__ownerID?(t.size=e.size,t._map=e,t):e===t._map?t:0===e.size?t.__empty():t.__make(e)}function se(t,e){var r=Object.create(Qr);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function ae(){return Xr||(Xr=se(St()))} +function ce(t,e,r,n,i,o){return yt(t.size),t.__iterate(function(t,o,u){i?(i=!1,r=t):r=e.call(n,r,t,o,u)},o),r}function he(t,e){return e}function fe(t,e){return[e,t]}function pe(t){return t&&"function"==typeof t.toJS?t.toJS():t}function _e(t){return function(){return!t.apply(this,arguments)}}function le(t){return function(){return-t.apply(this,arguments)}}function ve(){return i(arguments)}function ye(t,e){return te?-1:0}function de(t){if(t.size===1/0)return 0;var e=g(t),r=v(t),n=e?1:0;return ge(t.__iterate(r?e?function(t,e){n=31*n+me(W(t),W(e))|0}:function(t,e){n=n+me(W(t),W(e))|0}:e?function(t){n=31*n+W(t)|0}:function(t){n=n+W(t)|0}),n)}function ge(t,e){return e=sr(e,3432918353),e=sr(e<<15|e>>>-15,461845907),e=sr(e<<13|e>>>-13,5),e=(e+3864292196|0)^t,e=sr(e^e>>>16,2246822507),e=sr(e^e>>>13,3266489909),e=C(e^e>>>16)}function me(t,e){return t^e+2654435769+(t<<6)+(t>>2)|0}function we(t){if("object"!=typeof console||!console.warn)throw Error(t);console.warn(t)}function ze(t){return oe(t)&&g(t)}function Se(t,e){var r=Object.create(rn);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function Ie(){return nn||(nn=Se(Zt()))}function be(t,e,r){var n=Object.create(Object.getPrototypeOf(t));return n._values=e,n.__ownerID=r,n}function Oe(t){return t._name||t.constructor.name||"Record"}function Me(t){return x(t._keys.map(function(e){return[e,t.get(e)]}))}function De(t,e){try{Object.defineProperty(t,e,{get:function(){return this.get(e)},set:function(t){vt(this.__ownerID,"Cannot set on an immutable record."),this.set(e,t)}})}catch(t){}}var qe=5,Ee=1<=n.length){var e=r.next();if(e.done)return e;n[i]=e.value}return z(t,i,n[i++])})},e}(Ze),sr="function"==typeof Math.imul&&Math.imul(4294967295,2)===-2?Math.imul:function(t,e){t|=0,e|=0;var r=65535&t,n=65535&e;return r*n+((t>>>16)*n+r*(e>>>16)<<16>>>0)|0},ar=Object.isExtensible,cr=function(){try{return Object.defineProperty({},"@",{}),!0}catch(t){return!1}}(),hr="function"==typeof WeakMap;hr&&(ir=new WeakMap);var fr=0,pr="__immutablehash__";"function"==typeof Symbol&&(pr=Symbol(pr));var _r=16,lr=255,vr=0,yr={},dr=function(t){function e(t,e){this._iter=t,this._useKeys=e,this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t,e){return this._iter.get(t,e)},e.prototype.has=function(t){return this._iter.has(t)},e.prototype.valueSeq=function(){return this._iter.valueSeq()},e.prototype.reverse=function(){var t=this,e=Y(this,!0);return this._useKeys||(e.valueSeq=function(){return t._iter.toSeq().reverse()}),e},e.prototype.map=function(t,e){var r=this,n=H(this,t,e);return this._useKeys||(n.valueSeq=function(){return r._iter.toSeq().map(t,e)}),n},e.prototype.__iterate=function(t,e){var r=this +;return this._iter.__iterate(function(e,n){return t(e,n,r)},e)},e.prototype.__iterator=function(t,e){return this._iter.__iterator(t,e)},e}(Ge);dr.prototype[Le]=!0;var gr=function(t){function e(t){this._iter=t,this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.includes=function(t){return this._iter.includes(t)},e.prototype.__iterate=function(t,e){var r=this,n=0;return e&&o(this),this._iter.__iterate(function(i){return t(i,e?r.size-++n:n++,r)},e)},e.prototype.__iterator=function(t,e){var r=this,n=this._iter.__iterator(Ne,e),i=0;return e&&o(this),new Xe(function(){var o=n.next();return o.done?o:z(t,e?r.size-++i:i++,o.value,o)})},e}(Ze),mr=function(t){function e(t){this._iter=t,this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.has=function(t){return this._iter.includes(t)},e.prototype.__iterate=function(t,e){var r=this;return this._iter.__iterate(function(e){return t(e,e,r)},e)},e.prototype.__iterator=function(t,e){var r=this._iter.__iterator(Ne,e);return new Xe(function(){var e=r.next();return e.done?e:z(t,e.value,e.value,e)})},e}($e),wr=function(t){function e(t){this._iter=t,this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.entrySeq=function(){return this._iter.toSeq()},e.prototype.__iterate=function(t,e){var r=this;return this._iter.__iterate(function(e){if(e){ct(e);var n=l(e);return t(n?e.get(1):e[1],n?e.get(0):e[0],r)}},e)},e.prototype.__iterator=function(t,e){var r=this._iter.__iterator(Ne,e);return new Xe(function(){for(;;){var e=r.next();if(e.done)return e;var n=e.value;if(n){ct(n);var i=l(n);return z(t,i?n.get(0):n[0],i?n.get(1):n[1],e)}}})},e}(Ge);gr.prototype.cacheResult=dr.prototype.cacheResult=mr.prototype.cacheResult=wr.prototype.cacheResult=pt;var zr=function(t){function e(e){return null===e||void 0===e?St():gt(e)&&!g(e)?e:St().withMutations(function(r){var n=t(e);yt(n.size), +n.forEach(function(t,e){return r.set(e,t)})})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return St().withMutations(function(e){for(var r=0;r=t.length)throw Error("Missing value for key: "+t[r]);e.set(t[r],t[r+1])}})},e.prototype.toString=function(){return this.__toString("Map {","}")},e.prototype.get=function(t,e){return this._root?this._root.get(0,void 0,t,e):e},e.prototype.set=function(t,e){return It(this,t,e)},e.prototype.setIn=function(t,e){return this.updateIn(t,je,function(){return e})},e.prototype.remove=function(t){return It(this,t,je)},e.prototype.deleteIn=function(t){if(t=[].concat(lt(t)),t.length){var e=t.pop();return this.updateIn(t,function(t){return t&&t.remove(e)})}},e.prototype.deleteAll=function(t){var e=Ce(t);return 0===e.size?this:this.withMutations(function(t){e.forEach(function(e){return t.remove(e)})})},e.prototype.update=function(t,e,r){return 1===arguments.length?t(this):this.updateIn([t],e,r)},e.prototype.updateIn=function(t,e,r){r||(r=e,e=void 0);var n=Rt(this,lt(t),0,e,r);return n===je?e:n},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):St()},e.prototype.merge=function(){return xt(this,void 0,arguments)},e.prototype.mergeWith=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return xt(this,t,e)},e.prototype.mergeIn=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return this.updateIn(t,St(),function(t){return"function"==typeof t.merge?t.merge.apply(t,e):e[e.length-1]})},e.prototype.mergeDeep=function(){return xt(this,jt,arguments)},e.prototype.mergeDeepWith=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return xt(this,kt(t),e)},e.prototype.mergeDeepIn=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return this.updateIn(t,St(),function(t){ +return"function"==typeof t.mergeDeep?t.mergeDeep.apply(t,e):e[e.length-1]})},e.prototype.sort=function(t){return Wr(it(this,t))},e.prototype.sortBy=function(t,e){return Wr(it(this,e,t))},e.prototype.withMutations=function(t){var e=this.asMutable();return t(e),e.wasAltered()?e.__ensureOwner(this.__ownerID):this},e.prototype.asMutable=function(){return this.__ownerID?this:this.__ensureOwner(new n)},e.prototype.asImmutable=function(){return this.__ensureOwner()},e.prototype.wasAltered=function(){return this.__altered},e.prototype.__iterator=function(t,e){return new xr(this,t,e)},e.prototype.__iterate=function(t,e){var r=this,n=0;return this._root&&this._root.iterate(function(e){return n++,t(e[1],e[0],r)},e),n},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?zt(this.size,this._root,t,this.__hash):0===this.size?St():(this.__ownerID=t,this.__altered=!1,this)},e}(We);zr.isMap=gt;var Sr="@@__IMMUTABLE_MAP__@@",Ir=zr.prototype;Ir[Sr]=!0,Ir.delete=Ir.remove,Ir.removeIn=Ir.deleteIn,Ir.removeAll=Ir.deleteAll,Ir["@@transducer/init"]=Ir.asMutable,Ir["@@transducer/step"]=function(t,e){return t.set(e[0],e[1])},Ir["@@transducer/result"]=function(t){return t.asImmutable()};var br=function(t,e){this.ownerID=t,this.entries=e};br.prototype.get=function(t,e,r,n){for(var i=this.entries,o=0,u=i.length;o=jr)return Dt(t,h,o,u);var l=t&&t===this.ownerID,v=l?h:i(h);return _?c?f===p-1?v.pop():v[f]=v.pop():v[f]=[o,u]:v.push([o,u]),l?(this.entries=v,this):new br(t,v)}};var Or=function(t,e,r){this.ownerID=t,this.bitmap=e,this.nodes=r};Or.prototype.get=function(t,e,r,n){void 0===e&&(e=W(r));var i=1<<((0===t?e:e>>>t)&xe),o=this.bitmap;return 0==(o&i)?n:this.nodes[Ut(o&i-1)].get(t+qe,e,r,n)},Or.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=W(n)) +;var s=(0===e?r:r>>>e)&xe,a=1<=kr)return Et(t,p,c,s,l);if(h&&!l&&2===p.length&&Ot(p[1^f]))return p[1^f];if(h&&l&&1===p.length&&Ot(l))return l;var v=t&&t===this.ownerID,y=h?l?c:c^a:c|a,d=h?l?Kt(p,f,l,v):Tt(p,f,v):Lt(p,f,l,v);return v?(this.bitmap=y,this.nodes=d,this):new Or(t,y,d)};var Mr=function(t,e,r){this.ownerID=t,this.count=e,this.nodes=r};Mr.prototype.get=function(t,e,r,n){void 0===e&&(e=W(r));var i=(0===t?e:e>>>t)&xe,o=this.nodes[i];return o?o.get(t+qe,e,r,n):n},Mr.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=W(n));var s=(0===e?r:r>>>e)&xe,a=i===je,c=this.nodes,h=c[s];if(a&&!h)return this;var f=bt(h,t,e+qe,r,n,i,o,u);if(f===h)return this;var p=this.count;if(h){if(!f&&--p0&&i=0&&t0;)e[r]=arguments[r+1];return Qt(this,t,e)},e.prototype.mergeDeep=function(){return Qt(this,jt,arguments)},e.prototype.mergeDeepWith=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Qt(this,kt(t),e)},e.prototype.setSize=function(t){return Yt(this,0,t)},e.prototype.slice=function(t,e){var r=this.size;return a(t,e,r)?this:Yt(this,c(t,r),h(e,r))},e.prototype.__iterator=function(t,e){var r=e?this.size:0,n=Wt(this,e);return new Xe(function(){var i=n();return i===Cr?S():z(t,e?--r:r++,i)})},e.prototype.__iterate=function(t,e){for(var r,n=this,i=e?this.size:0,o=Wt(this,e);(r=o())!==Cr&&t(r,e?--i:i++,n)!==!1;);return i},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Bt(this._origin,this._capacity,this._level,this._root,this._tail,t,this.__hash):0===this.size?Jt():(this.__ownerID=t,this)},e}(Be);Rr.isList=Ct;var Ur="@@__IMMUTABLE_LIST__@@",Kr=Rr.prototype;Kr[Ur]=!0,Kr.delete=Kr.remove,Kr.setIn=Ir.setIn,Kr.deleteIn=Kr.removeIn=Ir.removeIn,Kr.update=Ir.update,Kr.updateIn=Ir.updateIn,Kr.mergeIn=Ir.mergeIn,Kr.mergeDeepIn=Ir.mergeDeepIn,Kr.withMutations=Ir.withMutations,Kr.asMutable=Ir.asMutable,Kr.asImmutable=Ir.asImmutable,Kr.wasAltered=Ir.wasAltered,Kr["@@transducer/init"]=Kr.asMutable,Kr["@@transducer/step"]=function(t,e){return t.push(e)},Kr["@@transducer/result"]=Ir["@@transducer/result"];var Lr=function(t,e){this.array=t,this.ownerID=e};Lr.prototype.removeBefore=function(t,e,r){if(r===e?1<>>e&xe +;if(n>=this.array.length)return new Lr([],t);var i,o=0===n;if(e>0){var u=this.array[n];if((i=u&&u.removeBefore(t,e-qe,r))===u&&o)return this}if(o&&!i)return this;var s=Vt(this,t);if(!o)for(var a=0;a>>e&xe;if(n>=this.array.length)return this;var i;if(e>0){var o=this.array[n];if((i=o&&o.removeAfter(t,e-qe,r))===o&&n===this.array.length-1)return this}var u=Vt(this,t);return u.array.splice(n+1),i&&(u.array[n]=i),u};var Tr,Cr={},Wr=function(t){function e(t){return null===t||void 0===t?Zt():Ft(t)?t:Zt().withMutations(function(e){var r=We(t);yt(r.size),r.forEach(function(t,r){return e.set(r,t)})})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("OrderedMap {","}")},e.prototype.get=function(t,e){var r=this._map.get(t);return void 0!==r?this._list.get(r)[1]:e},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._map.clear(),this._list.clear(),this):Zt()},e.prototype.set=function(t,e){return $t(this,t,e)},e.prototype.remove=function(t){return $t(this,t,je)},e.prototype.wasAltered=function(){return this._map.wasAltered()||this._list.wasAltered()},e.prototype.__iterate=function(t,e){var r=this;return this._list.__iterate(function(e){return e&&t(e[1],e[0],r)},e)},e.prototype.__iterator=function(t,e){return this._list.fromEntrySeq().__iterator(t,e)},e.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var e=this._map.__ensureOwner(t),r=this._list.__ensureOwner(t);return t?Gt(e,r,t,this.__hash):0===this.size?Zt():(this.__ownerID=t,this._map=e,this._list=r,this)},e}(zr);Wr.isOrderedMap=Ft,Wr.prototype[Le]=!0,Wr.prototype.delete=Wr.prototype.remove;var Br,Jr=function(t){function e(t){return null===t||void 0===t?re():te(t)?t:re().pushAll(t)}return t&&(e.__proto__=t), +e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("Stack [","]")},e.prototype.get=function(t,e){var r=this._head;for(t=u(this,t);r&&t--;)r=r.next;return r?r.value:e},e.prototype.peek=function(){return this._head&&this._head.value},e.prototype.push=function(){var t=arguments;if(0===arguments.length)return this;for(var e=this.size+arguments.length,r=this._head,n=arguments.length-1;n>=0;n--)r={value:t[n],next:r};return this.__ownerID?(this.size=e,this._head=r,this.__hash=void 0,this.__altered=!0,this):ee(e,r)},e.prototype.pushAll=function(e){if(e=t(e),0===e.size)return this;if(0===this.size&&te(e))return e;yt(e.size);var r=this.size,n=this._head;return e.__iterate(function(t){r++,n={value:t,next:n}},!0),this.__ownerID?(this.size=r,this._head=n,this.__hash=void 0,this.__altered=!0,this):ee(r,n)},e.prototype.pop=function(){return this.slice(1)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):re()},e.prototype.slice=function(e,r){if(a(e,r,this.size))return this;var n=c(e,this.size);if(h(r,this.size)!==this.size)return t.prototype.slice.call(this,e,r);for(var i=this.size-n,o=this._head;n--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):ee(i,o)},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?ee(this.size,this._head,t,this.__hash):0===this.size?re():(this.__ownerID=t,this.__altered=!1,this)},e.prototype.__iterate=function(t,e){var r=this;if(e)return new er(this.toArray()).__iterate(function(e,n){return t(e,n,r)},e);for(var n=0,i=this._head;i&&t(i.value,n++,r)!==!1;)i=i.next;return n},e.prototype.__iterator=function(t,e){if(e)return new er(this.toArray()).__iterator(t,e);var r=0,n=this._head;return new Xe(function(){if(n){var e=n.value;return n=n.next,z(t,r++,e)}return S()})},e}(Be);Jr.isStack=te +;var Pr="@@__IMMUTABLE_STACK__@@",Nr=Jr.prototype;Nr[Pr]=!0,Nr.withMutations=Ir.withMutations,Nr.asMutable=Ir.asMutable,Nr.asImmutable=Ir.asImmutable,Nr.wasAltered=Ir.wasAltered,Nr.shift=Nr.pop,Nr.unshift=Nr.push,Nr.unshiftAll=Nr.pushAll,Nr["@@transducer/init"]=Nr.asMutable,Nr["@@transducer/step"]=function(t,e){return t.unshift(e)},Nr["@@transducer/result"]=Ir["@@transducer/result"];var Vr,Hr=function(t){function e(e){return null===e||void 0===e?ae():oe(e)&&!g(e)?e:ae().withMutations(function(r){var n=t(e);yt(n.size),n.forEach(function(t){return r.add(t)})})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(We(t).keySeq())},e.intersect=function(t){return t=Ce(t).toArray(),t.length?Qr.intersect.apply(e(t.pop()),t):ae()},e.union=function(t){return t=Ce(t).toArray(),t.length?Qr.union.apply(e(t.pop()),t):ae()},e.prototype.toString=function(){return this.__toString("Set {","}")},e.prototype.has=function(t){return this._map.has(t)},e.prototype.add=function(t){return ue(this,this._map.set(t,!0))},e.prototype.remove=function(t){return ue(this,this._map.remove(t))},e.prototype.clear=function(){return ue(this,this._map.clear())},e.prototype.union=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return e=e.filter(function(t){return 0!==t.size}),0===e.length?this:0!==this.size||this.__ownerID||1!==e.length?this.withMutations(function(r){for(var n=0;n0;)e[r]=arguments[r+1];return this.union.apply(this,e)},e.prototype.sort=function(t){return en(it(this,t))},e.prototype.sortBy=function(t,e){return en(it(this,e,t))},e.prototype.wasAltered=function(){return this._map.wasAltered()},e.prototype.__iterate=function(t,e){var r=this;return this._map.__iterate(function(e,n){return t(n,n,r)},e)},e.prototype.__iterator=function(t,e){return this._map.map(function(t,e){return e}).__iterator(t,e)},e.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var e=this._map.__ensureOwner(t);return t?this.__make(e,t):0===this.size?ae():(this.__ownerID=t,this._map=e,this)},e}(Je);Hr.isSet=oe;var Yr="@@__IMMUTABLE_SET__@@",Qr=Hr.prototype;Qr[Yr]=!0,Qr.delete=Qr.remove,Qr.mergeDeep=Qr.merge,Qr.mergeDeepWith=Qr.mergeWith,Qr.withMutations=Ir.withMutations,Qr.asMutable=Ir.asMutable,Qr.asImmutable=Ir.asImmutable,Qr["@@transducer/init"]=Qr.asMutable,Qr["@@transducer/step"]=function(t,e){return t.add(e)},Qr["@@transducer/result"]=Ir["@@transducer/result"],Qr.__empty=ae,Qr.__make=se;var Xr,Fr,Gr=function(t){function e(t,r,n){if(!(this instanceof e))return new e(t,r,n);if(vt(0!==n,"Cannot step a Range by 0"),t=t||0,void 0===r&&(r=1/0),n=void 0===n?1:Math.abs(n),r=0&&e=0&&rthis.size?e:this.find(function(e,r){return r===t},void 0,e)},has:function(t){return(t=u(this,t))>=0&&(void 0!==this.size?this.size===1/0||t /dev/null 2>1)" + }, + "jest": { + "moduleFileExtensions": [ + "js", + "ts" + ], + "transform": { + "^.+\\.ts$": "/resources/jestPreprocessor.js" + }, + "testRegex": "/__tests__/.*\\.(ts|js)$", + "unmockedModulePathPatterns": [ + "./node_modules/react" + ] + }, + "devDependencies": { + "benchmark": "2.1.3", + "browser-sync": "2.18.8", + "browserify": "^5.11.2", + "colors": "1.1.2", + "del": "2.2.2", + "dtslint": "0.1.2", + "eslint": "3.17.1", + "eslint-config-airbnb": "14.1.0", + "eslint-config-prettier": "1.5.0", + "eslint-plugin-import": "2.2.0", + "eslint-plugin-jsx-a11y": "4.0.0", + "eslint-plugin-prettier": "2.0.1", + "eslint-plugin-react": "6.10.0", + "flow-bin": "0.56.0", + "gulp": "3.9.1", + "gulp-concat": "2.6.1", + "gulp-filter": "5.0.0", + "gulp-header": "1.8.8", + "gulp-less": "3.3.0", + "gulp-size": "2.1.0", + "gulp-sourcemaps": "2.4.1", + "gulp-uglify": "2.1.0", + "gulp-util": "3.0.8", + "jasmine-check": "0.1.5", + "jest": "19.0.2", + "marked": "0.3.6", + "microtime": "2.1.6", + "mkdirp": "0.5.1", + "npm-run-all": "4.0.2", + "prettier": "0.22.0", + "react": "^0.12.0", + "react-router": "^0.11.2", + "react-tools": "^0.12.0", + "rimraf": "2.6.1", + "rollup": "0.41.5", + "rollup-plugin-buble": "0.15.0", + "rollup-plugin-commonjs": "7.1.0", + "rollup-plugin-strip-banner": "0.1.0", + "run-sequence": "1.2.2", + "through2": "2.0.3", + "transducers-js": "^0.4.174", + "tslint": "4.5.1", + "typescript": "2.2.1", + "uglify-js": "2.8.11", + "uglify-save-license": "0.4.1", + "vinyl-buffer": "1.0.0", + "vinyl-source-stream": "1.1.0" + }, + "files": [ + "dist", + "contrib", + "README.md", + "LICENSE", + "PATENTS" + ], + "keywords": [ + "immutable", + "persistent", + "lazy", + "data", + "datastructure", + "functional", + "collection", + "stateless", + "sequence", + "iteration" + ], + "license": "BSD-3-Clause" +} From e842720bc1910c534ac4f6f27ffb459d3f0e55e9 Mon Sep 17 00:00:00 2001 From: Travis CI Date: Fri, 29 Sep 2017 20:08:29 +0000 Subject: [PATCH 002/242] Deploy master to NPM branch --- contrib/cursor/README.md | 43 +++ contrib/cursor/__tests__/Cursor.ts.skip | 388 ++++++++++++++++++++++++ contrib/cursor/index.d.ts | 290 ++++++++++++++++++ contrib/cursor/index.js | 362 ++++++++++++++++++++++ package.json | 86 +----- 5 files changed, 1084 insertions(+), 85 deletions(-) create mode 100644 contrib/cursor/README.md create mode 100644 contrib/cursor/__tests__/Cursor.ts.skip create mode 100644 contrib/cursor/index.d.ts create mode 100644 contrib/cursor/index.js diff --git a/contrib/cursor/README.md b/contrib/cursor/README.md new file mode 100644 index 0000000000..3f255dc961 --- /dev/null +++ b/contrib/cursor/README.md @@ -0,0 +1,43 @@ +# DEPRECATED + +The Cursor API is deprecated and will be removed in a future major release. + +It is strongly suggested that you use the excellent `immutable-cursor` module +which has an extremely similar API but is much higher quality. + +https://github.com/redbadger/immutable-cursor + + +Cursors +------- + +Cursors allow you to hold a reference to a path in a nested immutable data +structure, allowing you to pass smaller sections of a larger nested +collection to portions of your application while maintaining a central point +aware of changes to the entire data structure: an `onChange` function which is +called whenever a cursor or sub-cursor calls `update`. + +This is particularly useful when used in conjuction with component-based UI +libraries like [React](https://facebook.github.io/react/) or to simulate +"state" throughout an application while maintaining a single flow of logic. + + +```javascript +var Immutable = require('immutable'); +var Cursor = require('immutable/contrib/cursor'); + +var data = Immutable.fromJS({ a: { b: { c: 1 } } }); +var cursor = Cursor.from(data, ['a', 'b'], newData => { + data = newData; +}); + +// ... elsewhere ... + +cursor.get('c'); // 1 +cursor = cursor.update('c', x => x + 1); +cursor.get('c'); // 2 + +// ... back to data ... + +data.getIn(['a', 'b', 'c']); // 2 +``` diff --git a/contrib/cursor/__tests__/Cursor.ts.skip b/contrib/cursor/__tests__/Cursor.ts.skip new file mode 100644 index 0000000000..0a1892386c --- /dev/null +++ b/contrib/cursor/__tests__/Cursor.ts.skip @@ -0,0 +1,388 @@ +/// + +import * as Immutable from '../../../'; +import * as Cursor from '../'; + +describe('Cursor', () => { + + beforeEach(function () { + jasmine.addMatchers({ + toValueEqual: function(actual, expected) { + var passed = Immutable.is(actual, expected); + return { + pass: passed, + message: 'Expected ' + actual + (passed ? '' : ' not') + ' to equal ' + expected + }; + } + }); + }); + + var json = { a: { b: { c: 1 } } }; + + it('gets from its path', () => { + var data = Immutable.fromJS(json); + var cursor = Cursor.from(data); + + expect(cursor.deref()).toBe(data); + + var deepCursor = cursor.cursor(['a', 'b']); + expect(deepCursor.deref().toJS()).toEqual(json.a.b); + expect(deepCursor.deref()).toBe(data.getIn(['a', 'b'])); + expect(deepCursor.get('c')).toBe(1); + + var leafCursor = deepCursor.cursor('c'); + expect(leafCursor.deref()).toBe(1); + + var missCursor = leafCursor.cursor('d'); + expect(missCursor.deref()).toBe(undefined); + }); + + it('gets return new cursors', () => { + var data = Immutable.fromJS(json); + var cursor = Cursor.from(data); + var deepCursor = cursor.getIn(['a', 'b']); + expect(deepCursor.deref()).toBe(data.getIn(['a', 'b'])); + }); + + it('gets return new cursors using List', () => { + var data = Immutable.fromJS(json); + var cursor = Cursor.from(data); + var deepCursor = cursor.getIn(Immutable.fromJS(['a', 'b'])); + expect(deepCursor.deref()).toBe(data.getIn(Immutable.fromJS(['a', 'b']))); + }); + + it('cursor return new cursors of correct type', () => { + var data = Immutable.fromJS({ a: [1, 2, 3] }); + var cursor = Cursor.from(data); + var deepCursor = cursor.cursor('a'); + expect(deepCursor.findIndex).toBeDefined(); + }); + + it('can be treated as a value', () => { + var data = Immutable.fromJS(json); + var cursor = Cursor.from(data, ['a', 'b']); + expect(cursor.toJS()).toEqual(json.a.b); + expect(cursor).toValueEqual(data.getIn(['a', 'b'])); + expect(cursor.size).toBe(1); + expect(cursor.get('c')).toBe(1); + }); + + it('can be value compared to a primitive', () => { + var data = Immutable.Map({ a: 'A' }); + var aCursor = Cursor.from(data, 'a'); + expect(aCursor.size).toBe(undefined); + expect(aCursor.deref()).toBe('A'); + expect(Immutable.is(aCursor, 'A')).toBe(true); + }); + + it('updates at its path', () => { + var onChange = jest.genMockFunction(); + + var data = Immutable.fromJS(json); + var aCursor = Cursor.from(data, 'a', onChange); + + var deepCursor = aCursor.cursor(['b', 'c']); + expect(deepCursor.deref()).toBe(1); + + // cursor edits return new cursors: + var newDeepCursor = deepCursor.update(x => x + 1); + expect(newDeepCursor.deref()).toBe(2); + var call1 = onChange.mock.calls[0]; + expect(call1[0]).toValueEqual(Immutable.fromJS({a:{b:{c:2}}})); + expect(call1[1]).toBe(data); + expect(call1[2]).toEqual(['a', 'b', 'c']); + + var newestDeepCursor = newDeepCursor.update(x => x + 1); + expect(newestDeepCursor.deref()).toBe(3); + var call2 = onChange.mock.calls[1]; + expect(call2[0]).toValueEqual(Immutable.fromJS({a:{b:{c:3}}})); + expect(call2[1]).toValueEqual(Immutable.fromJS({a:{b:{c:2}}})); + expect(call2[2]).toEqual(['a', 'b', 'c']); + + // meanwhile, data is still immutable: + expect(data.toJS()).toEqual(json); + + // as is the original cursor. + expect(deepCursor.deref()).toBe(1); + var otherNewDeepCursor = deepCursor.update(x => x + 10); + expect(otherNewDeepCursor.deref()).toBe(11); + var call3 = onChange.mock.calls[2]; + expect(call3[0]).toValueEqual(Immutable.fromJS({a:{b:{c:11}}})); + expect(call3[1]).toBe(data); + expect(call3[2]).toEqual(['a', 'b', 'c']); + + // and update has been called exactly thrice. + expect(onChange.mock.calls.length).toBe(3); + }); + + it('updates with the return value of onChange', () => { + var onChange = jest.genMockFunction(); + + var data = Immutable.fromJS(json); + var deepCursor = Cursor.from(data, ['a', 'b', 'c'], onChange); + + onChange.mockReturnValueOnce(undefined); + // onChange returning undefined has no effect + var newCursor = deepCursor.update(x => x + 1); + expect(newCursor.deref()).toBe(2); + var call1 = onChange.mock.calls[0]; + expect(call1[0]).toValueEqual(Immutable.fromJS({a:{b:{c:2}}})); + expect(call1[1]).toBe(data); + expect(call1[2]).toEqual(['a', 'b', 'c']); + + onChange.mockReturnValueOnce(Immutable.fromJS({a:{b:{c:11}}})); + // onChange returning something else has an effect + newCursor = newCursor.update(x => 999); + expect(newCursor.deref()).toBe(11); + var call2 = onChange.mock.calls[1]; + expect(call2[0]).toValueEqual(Immutable.fromJS({a:{b:{c:999}}})); + expect(call2[1]).toValueEqual(Immutable.fromJS({a:{b:{c:2}}})); + expect(call2[2]).toEqual(['a', 'b', 'c']); + + // and update has been called exactly twice + expect(onChange.mock.calls.length).toBe(2); + }); + + it('has map API for update shorthand', () => { + var onChange = jest.genMockFunction(); + + var data = Immutable.fromJS(json); + var aCursor = Cursor.from(data, 'a', onChange); + var bCursor = aCursor.cursor('b'); + var cCursor = bCursor.cursor('c'); + + expect(bCursor.set('c', 10).deref()).toValueEqual( + Immutable.fromJS({ c: 10 }) + ); + + var call1 = onChange.mock.calls[0]; + expect(call1[0]).toValueEqual(Immutable.fromJS({a:{b:{c:10}}})); + expect(call1[1]).toBe(data); + expect(call1[2]).toEqual(['a', 'b', 'c']); + }); + + it('creates maps as necessary', () => { + var data = Immutable.Map(); + var cursor = Cursor.from(data, ['a', 'b', 'c']); + expect(cursor.deref()).toBe(undefined); + cursor = cursor.set('d', 3); + expect(cursor.deref()).toValueEqual(Immutable.Map({d: 3})); + }); + + it('can set undefined', () => { + var data = Immutable.Map(); + var cursor = Cursor.from(data, ['a', 'b', 'c']); + expect(cursor.deref()).toBe(undefined); + cursor = cursor.set('d', undefined); + expect(cursor.toJS()).toEqual({d: undefined}); + }); + + it('has the sequence API', () => { + var data = Immutable.Map({a: 1, b: 2, c: 3}); + var cursor = Cursor.from(data); + expect(cursor.map((x: number) => x * x)).toValueEqual(Immutable.Map({a: 1, b: 4, c: 9})); + }); + + it('can push values on a List', () => { + var onChange = jest.genMockFunction(); + var data = Immutable.fromJS({a: {b: [0, 1, 2]}}); + var cursor = Cursor.from(data, ['a', 'b'], onChange); + + expect(cursor.push(3,4)).toValueEqual(Immutable.List([0, 1, 2, 3, 4])); + + var call = onChange.mock.calls[0]; + expect(call[0]).toValueEqual(Immutable.fromJS({a: {b: [0, 1, 2, 3, 4]}})); + expect(call[1]).toBe(data); + expect(call[2]).toEqual(['a', 'b']); + }); + + it('can pop values of a List', () => { + var onChange = jest.genMockFunction(); + var data = Immutable.fromJS({a: {b: [0, 1, 2]}}); + var cursor = Cursor.from(data, ['a', 'b'], onChange); + + expect(cursor.pop()).toValueEqual(Immutable.List([0, 1])); + + var call = onChange.mock.calls[0]; + expect(call[0]).toValueEqual(Immutable.fromJS({a: {b: [0, 1]}})); + expect(call[1]).toBe(data); + expect(call[2]).toEqual(['a', 'b']); + }); + + it('can unshift values on a List', () => { + var onChange = jest.genMockFunction(); + var data = Immutable.fromJS({a: {b: [0, 1, 2]}}); + var cursor = Cursor.from(data, ['a', 'b'], onChange); + + expect(cursor.unshift(-2, -1)).toValueEqual(Immutable.List([-2, -1, 0, 1, 2])); + + var call = onChange.mock.calls[0]; + expect(call[0]).toValueEqual(Immutable.fromJS({a: {b: [-2, -1, 0, 1, 2]}})); + expect(call[1]).toBe(data); + expect(call[2]).toEqual(['a', 'b']); + }); + + it('can shift values of a List', () => { + var onChange = jest.genMockFunction(); + var data = Immutable.fromJS({a: {b: [0, 1, 2]}}); + var cursor = Cursor.from(data, ['a', 'b'], onChange); + + expect(cursor.shift()).toValueEqual(Immutable.List([1, 2])); + + var call = onChange.mock.calls[0]; + expect(call[0]).toValueEqual(Immutable.fromJS({a: {b: [1, 2]}})); + expect(call[1]).toBe(data); + expect(call[2]).toEqual(['a', 'b']); + }); + + + it('returns wrapped values for sequence API', () => { + var data = Immutable.fromJS({a: {v: 1}, b: {v: 2}, c: {v: 3}}); + var onChange = jest.genMockFunction(); + var cursor = Cursor.from(data, onChange); + + var found = cursor.find(map => map.get('v') === 2); + expect(typeof found.deref).toBe('function'); // is a cursor! + found = found.set('v', 20); + + var call = onChange.mock.calls[0]; + expect(call[0]).toValueEqual(Immutable.fromJS({a: {v: 1}, b: {v: 20}, c: {v: 3}})); + expect(call[1]).toBe(data); + expect(call[2]).toEqual(['b', 'v']); + }); + + it('returns wrapped values for iteration API', () => { + var jsData = [{val: 0}, {val: 1}, {val: 2}]; + var data = Immutable.fromJS(jsData); + var cursor = Cursor.from(data); + cursor.forEach(function (c, i) { + expect(typeof c.deref).toBe('function'); // is a cursor! + expect(c.get('val')).toBe(i); + }); + }); + + it('can map over values to get subcursors', () => { + var data = Immutable.fromJS({a: {v: 1}, b: {v: 2}, c: {v: 3}}); + var cursor = Cursor.from(data); + + var mapped = cursor.map(val => { + expect(typeof val.deref).toBe('function'); // mapped values are cursors. + return val; + }).toMap(); + // Mapped is not a cursor, but it is a sequence of cursors. + expect(typeof (mapped).deref).not.toBe('function'); + expect(typeof (mapped.get('a')).deref).toBe('function'); + + // Same for indexed cursors + var data2 = Immutable.fromJS({x: [{v: 1}, {v: 2}, {v: 3}]}); + var cursor2 = Cursor.from(data2); + + var mapped2 = cursor2.get('x').map(val => { + expect(typeof val.deref).toBe('function'); // mapped values are cursors. + return val; + }).toList(); + // Mapped is not a cursor, but it is a sequence of cursors. + expect(typeof mapped2.deref).not.toBe('function'); + expect(typeof mapped2.get(0).deref).toBe('function'); + }); + + it('can have mutations apply with a single callback', () => { + var onChange = jest.genMockFunction(); + var data = Immutable.fromJS({'a': 1}); + + var c1 = Cursor.from(data, onChange); + var c2 = c1.withMutations(m => m.set('b', 2).set('c', 3).set('d', 4)); + + expect(c1.deref().toObject()).toEqual({'a': 1}); + expect(c2.deref().toObject()).toEqual({'a': 1, 'b': 2, 'c': 3, 'd': 4}); + expect(onChange.mock.calls.length).toBe(1); + }); + + it('can use withMutations on an unfulfilled cursor', () => { + var onChange = jest.genMockFunction(); + var data = Immutable.fromJS({}); + + var c1 = Cursor.from(data, ['a', 'b', 'c'], onChange); + var c2 = c1.withMutations(m => m.set('x', 1).set('y', 2).set('z', 3)); + + expect(c1.deref()).toEqual(undefined); + expect(c2.deref()).toValueEqual(Immutable.fromJS( + { x: 1, y: 2, z: 3 } + )); + expect(onChange.mock.calls.length).toBe(1); + }); + + it('maintains indexed sequences', () => { + var data = Immutable.fromJS([]); + var c = Cursor.from(data); + expect(c.toJS()).toEqual([]); + }); + + it('properly acts as an iterable', () => { + var data = Immutable.fromJS({key: {val: 1}}); + var c = Cursor.from(data).values(); + var c1 = c.next().value.get('val'); + expect(c1).toBe(1); + }); + + it('can update deeply', () => { + var onChange = jest.genMockFunction(); + var data = Immutable.fromJS({a:{b:{c:1}}}); + var c = Cursor.from(data, ['a'], onChange); + var c1 = c.updateIn(['b', 'c'], x => x * 10); + expect(c1.getIn(['b', 'c'])).toBe(10); + + var call = onChange.mock.calls[0]; + expect(call[0]).toValueEqual(Immutable.fromJS({a:{b:{c:10}}})); + expect(call[1]).toBe(data); + expect(call[2]).toEqual(['a', 'b', 'c']); + }); + + it('can set deeply', () => { + var onChange = jest.genMockFunction(); + var data = Immutable.fromJS({a:{b:{c:1}}}); + var c = Cursor.from(data, ['a'], onChange); + var c1 = c.setIn(['b', 'c'], 10); + expect(c1.getIn(['b', 'c'])).toBe(10); + + var call = onChange.mock.calls[0]; + expect(call[0]).toValueEqual(Immutable.fromJS({a:{b:{c:10}}})); + expect(call[1]).toBe(data); + expect(call[2]).toEqual(['a', 'b', 'c']); + }); + + it('can get Record value as a property', () => { + var User = Immutable.Record({ name: 'John' }); + var users = Immutable.List.of(new User()); + var data = Immutable.Map({'users': users}); + var cursor = Cursor.from(data, ['users']); + expect(cursor.first().name).toBe('John'); + }); + + it('can set value of a cursor directly', () => { + var onChange = jest.genMockFunction(); + var data = Immutable.fromJS({a:1}); + var c = Cursor.from(data, ['a'], onChange); + var c1 = c.set(2); + expect(c1.deref()).toBe(2); + + var call = onChange.mock.calls[0]; + expect(call[0]).toValueEqual(Immutable.fromJS({a:2})); + expect(call[1]).toBe(data); + expect(call[2]).toEqual(['a']); + }); + + it('can set value of a cursor to undefined directly', () => { + var onChange = jest.genMockFunction(); + var data = Immutable.fromJS({a:1}); + var c = Cursor.from(data, ['a'], onChange); + var c1 = c.set(undefined); + expect(c1.deref()).toBe(undefined); + + var call = onChange.mock.calls[0]; + expect(call[0]).toValueEqual(Immutable.fromJS({a:undefined})); + expect(call[1]).toBe(data); + expect(call[2]).toEqual(['a']); + }); + +}); diff --git a/contrib/cursor/index.d.ts b/contrib/cursor/index.d.ts new file mode 100644 index 0000000000..96c14afae4 --- /dev/null +++ b/contrib/cursor/index.d.ts @@ -0,0 +1,290 @@ +/** + * Copyright (c) 2014-2015, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + + +/** + * Cursors + * ------- + * + * Cursors allow you to hold a reference to a path in a nested immutable data + * structure, allowing you to pass smaller sections of a larger nested + * collection to portions of your application while maintaining a central point + * aware of changes to the entire data structure. + * + * This is particularly useful when used in conjuction with component-based UI + * libraries like [React](http://facebook.github.io/react/) or to simulate + * "state" throughout an application while maintaining a single flow of logic. + * + * Cursors provide a simple API for getting the value at that path + * (the equivalent of `this.getIn(keyPath)`), updating the value at that path + * (the equivalent of `this.updateIn(keyPath)`), and getting a sub-cursor + * starting from that path. + * + * When updated, a new root collection is created and provided to the `onChange` + * function provided to the first call to `Cursor(map, onChange)`. + * + * When this cursor's (or any of its sub-cursors') `update` method is called, + * the resulting new data structure will be provided to the `onChange` + * function. Use this callback to keep track of the most current value or + * update the rest of your application. + */ + +import * as Immutable from '../../'; + +export function from( + collection: Immutable.Collection, + onChange?: (newValue: any, oldValue?: any, keyPath?: Array) => any +): Cursor; +export function from( + collection: Immutable.Collection, + keyPath: Array, + onChange?: (newValue: any, oldValue?: any, keyPath?: Array) => any +): Cursor; +export function from( + collection: Immutable.Collection, + key: any, + onChange?: (newValue: any, oldValue?: any, keyPath?: Array) => any +): Cursor; + + +export interface Cursor extends Immutable.Iterable, Immutable.Seq { + + /** + * Returns a sub-cursor following the key-path starting from this cursor. + */ + cursor(subKeyPath: Array): Cursor; + cursor(subKey: any): Cursor; + + /** + * Returns the value at the cursor, if the cursor path does not yet exist, + * returns `notSetValue`. + */ + deref(notSetValue?: any): any; + + /** + * Returns the value at the `key` in the cursor, or `notSetValue` if it + * does not exist. + * + * If the key would return a collection, a new Cursor is returned. + */ + get(key: any, notSetValue?: any): any; + + /** + * Returns the value at the `keyPath` in the cursor, or `notSetValue` if it + * does not exist. + * + * If the keyPath would return a collection, a new Cursor is returned. + */ + getIn(keyPath: Array, notSetValue?: any): any; + getIn(keyPath: Immutable.Iterable, notSetValue?: any): any; + + /** + * Sets `value` at `key` in the cursor, returning a new cursor to the same + * point in the new data. + * + * If only one parameter is provided, it is set directly as the cursor's value. + */ + set(key: any, value: any): Cursor; + set(value: any): Cursor; + + /** + * Deletes `key` from the cursor, returning a new cursor to the same + * point in the new data. + * + * Note: `delete` cannot be safely used in IE8 + * @alias remove + */ + delete(key: any): Cursor; + remove(key: any): Cursor; + + /** + * Clears the value at this cursor, returning a new cursor to the same + * point in the new data. + */ + clear(): Cursor; + + /** + * Updates the value in the data this cursor points to, triggering the + * callback for the root cursor and returning a new cursor pointing to the + * new data. + */ + update(updater: (value: any) => any): Cursor; + update(key: any, updater: (value: any) => any): Cursor; + update(key: any, notSetValue: any, updater: (value: any) => any): Cursor; + + /** + * @see `Map#merge` + */ + merge(...iterables: Immutable.Iterable[]): Cursor; + merge(...iterables: {[key: string]: any}[]): Cursor; + + /** + * @see `Map#mergeWith` + */ + mergeWith( + merger: (previous?: any, next?: any) => any, + ...iterables: Immutable.Iterable[] + ): Cursor; + mergeWith( + merger: (previous?: any, next?: any) => any, + ...iterables: {[key: string]: any}[] + ): Cursor; + + /** + * @see `Map#mergeDeep` + */ + mergeDeep(...iterables: Immutable.Iterable[]): Cursor; + mergeDeep(...iterables: {[key: string]: any}[]): Cursor; + + /** + * @see `Map#mergeDeepWith` + */ + mergeDeepWith( + merger: (previous?: any, next?: any) => any, + ...iterables: Immutable.Iterable[] + ): Cursor; + mergeDeepWith( + merger: (previous?: any, next?: any) => any, + ...iterables: {[key: string]: any}[] + ): Cursor; + + // Deep persistent changes + + /** + * Returns a new Cursor having set `value` at this `keyPath`. If any keys in + * `keyPath` do not exist, a new immutable Map will be created at that key. + */ + setIn(keyPath: Array, value: any): Cursor; + setIn(keyPath: Immutable.Iterable, value: any): Cursor; + + /** + * Returns a new Cursor with provided `values` appended + */ + push(...values: Array): Cursor; + + /** + * Returns a new Cursor with a size ones less than this Cursor, + * excluding the last index in this Cursor. + */ + pop(): Cursor; + + /** + * Returns a new Cursor with the provided `values` prepended, + * shifting other values ahead to higher indices. + */ + unshift(...values: Array): Cursor; + + /** + * Returns a new Cursor with a size ones less than this Cursor, excluding + * the first index in this Cursor, shifting all other values to a lower index. + */ + shift(): Cursor; + + /** + * Returns a new Cursor having removed the value at this `keyPath`. + * + * @alias removeIn + */ + deleteIn(keyPath: Array): Cursor; + deleteIn(keyPath: Immutable.Iterable): Cursor; + removeIn(keyPath: Array): Cursor; + removeIn(keyPath: Immutable.Iterable): Cursor; + + /** + * Returns a new Cursor having applied the `updater` to the value found at + * the keyPath. + * + * If any keys in `keyPath` do not exist, new Immutable `Map`s will + * be created at those keys. If the `keyPath` does not already contain a + * value, the `updater` function will be called with `notSetValue`, if + * provided, otherwise `undefined`. + * + * If the `updater` function returns the same value it was called with, then + * no change will occur. This is still true if `notSetValue` is provided. + */ + updateIn( + keyPath: Array, + updater: (value: any) => any + ): Cursor; + updateIn( + keyPath: Array, + notSetValue: any, + updater: (value: any) => any + ): Cursor; + updateIn( + keyPath: Immutable.Iterable, + updater: (value: any) => any + ): Cursor; + updateIn( + keyPath: Immutable.Iterable, + notSetValue: any, + updater: (value: any) => any + ): Cursor; + + /** + * A combination of `updateIn` and `merge`, returning a new Cursor, but + * performing the merge at a point arrived at by following the keyPath. + * In other words, these two lines are equivalent: + * + * x.updateIn(['a', 'b', 'c'], abc => abc.merge(y)); + * x.mergeIn(['a', 'b', 'c'], y); + * + */ + mergeIn( + keyPath: Immutable.Iterable, + ...iterables: Immutable.Iterable[] + ): Cursor; + mergeIn( + keyPath: Array, + ...iterables: Immutable.Iterable[] + ): Cursor; + mergeIn( + keyPath: Array, + ...iterables: {[key: string]: any}[] + ): Cursor; + + /** + * A combination of `updateIn` and `mergeDeep`, returning a new Cursor, but + * performing the deep merge at a point arrived at by following the keyPath. + * In other words, these two lines are equivalent: + * + * x.updateIn(['a', 'b', 'c'], abc => abc.mergeDeep(y)); + * x.mergeDeepIn(['a', 'b', 'c'], y); + * + */ + mergeDeepIn( + keyPath: Immutable.Iterable, + ...iterables: Immutable.Iterable[] + ): Cursor; + mergeDeepIn( + keyPath: Array, + ...iterables: Immutable.Iterable[] + ): Cursor; + mergeDeepIn( + keyPath: Array, + ...iterables: {[key: string]: any}[] + ): Cursor; + + // Transient changes + + /** + * Every time you call one of the above functions, a new immutable value is + * created and the callback is triggered. If you need to apply a series of + * mutations to a Cursor without triggering the callback repeatedly, + * `withMutations()` creates a temporary mutable copy of the value which + * can apply mutations in a highly performant manner. Afterwards the + * callback is triggered with the final value. + */ + withMutations(mutator: (mutable: any) => any): Cursor; + + /** + * @ignore + */ + map(fn: (v: any, k: any, c: this) => any): this; +} diff --git a/contrib/cursor/index.js b/contrib/cursor/index.js new file mode 100644 index 0000000000..09b7929a6e --- /dev/null +++ b/contrib/cursor/index.js @@ -0,0 +1,362 @@ +/** + * Copyright (c) 2014-2015, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + +/** + * DEPRECATED + * + * The Cursor API is deprecated and will be removed in a future major release. + * + * It is strongly suggested that you use the excellent `immutable-cursor` module + * which has an extremely similar API but is much higher quality. + * + * https://github.com/redbadger/immutable-cursor + */ +typeof console === 'object' && console.warn && console.warn( + 'The Cursor API is deprecated and will be removed in a future major release.\n' + + '\n' + + 'It is strongly suggested that you use the excellent `immutable-cursor` module\n' + + 'which has an extremely similar API but is much higher quality.\n' + + '\n' + + 'https://github.com/redbadger/immutable-cursor\n' + +); + +/** + * Cursor is expected to be required in a node or other CommonJS context: + * + * var Cursor = require('immutable/contrib/cursor'); + * + * If you wish to use it in the browser, please check out Browserify or WebPack! + */ + +var Immutable = require('../../'); +var Iterable = Immutable.Iterable; +var Iterator = Iterable.Iterator; +var Seq = Immutable.Seq; +var Map = Immutable.Map; +var Record = Immutable.Record; + + +function cursorFrom(rootData, keyPath, onChange) { + if (arguments.length === 1) { + keyPath = []; + } else if (typeof keyPath === 'function') { + onChange = keyPath; + keyPath = []; + } else { + keyPath = valToKeyPath(keyPath); + } + return makeCursor(rootData, keyPath, onChange); +} + + +var KeyedCursorPrototype = Object.create(Seq.Keyed.prototype); +var IndexedCursorPrototype = Object.create(Seq.Indexed.prototype); + +function KeyedCursor(rootData, keyPath, onChange, size) { + this.size = size; + this._rootData = rootData; + this._keyPath = keyPath; + this._onChange = onChange; +} +KeyedCursorPrototype.constructor = KeyedCursor; + +function IndexedCursor(rootData, keyPath, onChange, size) { + this.size = size; + this._rootData = rootData; + this._keyPath = keyPath; + this._onChange = onChange; +} +IndexedCursorPrototype.constructor = IndexedCursor; + +KeyedCursorPrototype.toString = function() { + return this.__toString('Cursor {', '}'); +} +IndexedCursorPrototype.toString = function() { + return this.__toString('Cursor [', ']'); +} + +KeyedCursorPrototype.deref = +KeyedCursorPrototype.valueOf = +IndexedCursorPrototype.deref = +IndexedCursorPrototype.valueOf = function(notSetValue) { + return this._rootData.getIn(this._keyPath, notSetValue); +} + +KeyedCursorPrototype.get = +IndexedCursorPrototype.get = function(key, notSetValue) { + return this.getIn([key], notSetValue); +} + +KeyedCursorPrototype.getIn = +IndexedCursorPrototype.getIn = function(keyPath, notSetValue) { + keyPath = listToKeyPath(keyPath); + if (keyPath.length === 0) { + return this; + } + var value = this._rootData.getIn(newKeyPath(this._keyPath, keyPath), NOT_SET); + return value === NOT_SET ? notSetValue : wrappedValue(this, keyPath, value); +} + +IndexedCursorPrototype.set = +KeyedCursorPrototype.set = function(key, value) { + if(arguments.length === 1) { + return updateCursor(this, function() { return key; }, []); + } else { + return updateCursor(this, function (m) { return m.set(key, value); }, [key]); + } +} + +IndexedCursorPrototype.push = function(/* values */) { + var args = arguments; + return updateCursor(this, function (m) { + return m.push.apply(m, args); + }); +} + +IndexedCursorPrototype.pop = function() { + return updateCursor(this, function (m) { + return m.pop(); + }); +} + +IndexedCursorPrototype.unshift = function(/* values */) { + var args = arguments; + return updateCursor(this, function (m) { + return m.unshift.apply(m, args); + }); +} + +IndexedCursorPrototype.shift = function() { + return updateCursor(this, function (m) { + return m.shift(); + }); +} + +IndexedCursorPrototype.setIn = +KeyedCursorPrototype.setIn = Map.prototype.setIn; + +KeyedCursorPrototype.remove = +KeyedCursorPrototype['delete'] = +IndexedCursorPrototype.remove = +IndexedCursorPrototype['delete'] = function(key) { + return updateCursor(this, function (m) { return m.remove(key); }, [key]); +} + +IndexedCursorPrototype.removeIn = +IndexedCursorPrototype.deleteIn = +KeyedCursorPrototype.removeIn = +KeyedCursorPrototype.deleteIn = Map.prototype.deleteIn; + +KeyedCursorPrototype.clear = +IndexedCursorPrototype.clear = function() { + return updateCursor(this, function (m) { return m.clear(); }); +} + +IndexedCursorPrototype.update = +KeyedCursorPrototype.update = function(keyOrFn, notSetValue, updater) { + return arguments.length === 1 ? + updateCursor(this, keyOrFn) : + this.updateIn([keyOrFn], notSetValue, updater); +} + +IndexedCursorPrototype.updateIn = +KeyedCursorPrototype.updateIn = function(keyPath, notSetValue, updater) { + return updateCursor(this, function (m) { + return m.updateIn(keyPath, notSetValue, updater); + }, keyPath); +} + +IndexedCursorPrototype.merge = +KeyedCursorPrototype.merge = function(/*...iters*/) { + var args = arguments; + return updateCursor(this, function (m) { + return m.merge.apply(m, args); + }); +} + +IndexedCursorPrototype.mergeWith = +KeyedCursorPrototype.mergeWith = function(merger/*, ...iters*/) { + var args = arguments; + return updateCursor(this, function (m) { + return m.mergeWith.apply(m, args); + }); +} + +IndexedCursorPrototype.mergeIn = +KeyedCursorPrototype.mergeIn = Map.prototype.mergeIn; + +IndexedCursorPrototype.mergeDeep = +KeyedCursorPrototype.mergeDeep = function(/*...iters*/) { + var args = arguments; + return updateCursor(this, function (m) { + return m.mergeDeep.apply(m, args); + }); +} + +IndexedCursorPrototype.mergeDeepWith = +KeyedCursorPrototype.mergeDeepWith = function(merger/*, ...iters*/) { + var args = arguments; + return updateCursor(this, function (m) { + return m.mergeDeepWith.apply(m, args); + }); +} + +IndexedCursorPrototype.mergeDeepIn = +KeyedCursorPrototype.mergeDeepIn = Map.prototype.mergeDeepIn; + +KeyedCursorPrototype.withMutations = +IndexedCursorPrototype.withMutations = function(fn) { + return updateCursor(this, function (m) { + return (m || Map()).withMutations(fn); + }); +} + +KeyedCursorPrototype.cursor = +IndexedCursorPrototype.cursor = function(subKeyPath) { + subKeyPath = valToKeyPath(subKeyPath); + return subKeyPath.length === 0 ? this : subCursor(this, subKeyPath); +} + +/** + * All iterables need to implement __iterate + */ +KeyedCursorPrototype.__iterate = +IndexedCursorPrototype.__iterate = function(fn, reverse) { + var cursor = this; + var deref = cursor.deref(); + return deref && deref.__iterate ? deref.__iterate( + function (v, k) { return fn(wrappedValue(cursor, [k], v), k, cursor); }, + reverse + ) : 0; +} + +/** + * All iterables need to implement __iterator + */ +KeyedCursorPrototype.__iterator = +IndexedCursorPrototype.__iterator = function(type, reverse) { + var deref = this.deref(); + var cursor = this; + var iterator = deref && deref.__iterator && + deref.__iterator(Iterator.ENTRIES, reverse); + return new Iterator(function () { + if (!iterator) { + return { value: undefined, done: true }; + } + var step = iterator.next(); + if (step.done) { + return step; + } + var entry = step.value; + var k = entry[0]; + var v = wrappedValue(cursor, [k], entry[1]); + return { + value: type === Iterator.KEYS ? k : type === Iterator.VALUES ? v : [k, v], + done: false + }; + }); +} + +KeyedCursor.prototype = KeyedCursorPrototype; +IndexedCursor.prototype = IndexedCursorPrototype; + + +var NOT_SET = {}; // Sentinel value + +function makeCursor(rootData, keyPath, onChange, value) { + if (arguments.length < 4) { + value = rootData.getIn(keyPath); + } + var size = value && value.size; + var CursorClass = Iterable.isIndexed(value) ? IndexedCursor : KeyedCursor; + var cursor = new CursorClass(rootData, keyPath, onChange, size); + + if (value instanceof Record) { + defineRecordProperties(cursor, value); + } + + return cursor; +} + +function defineRecordProperties(cursor, value) { + try { + value._keys.forEach(setProp.bind(undefined, cursor)); + } catch (error) { + // Object.defineProperty failed. Probably IE8. + } +} + +function setProp(prototype, name) { + Object.defineProperty(prototype, name, { + get: function() { + return this.get(name); + }, + set: function(value) { + if (!this.__ownerID) { + throw new Error('Cannot set on an immutable record.'); + } + } + }); +} + +function wrappedValue(cursor, keyPath, value) { + return Iterable.isIterable(value) ? subCursor(cursor, keyPath, value) : value; +} + +function subCursor(cursor, keyPath, value) { + if (arguments.length < 3) { + return makeCursor( // call without value + cursor._rootData, + newKeyPath(cursor._keyPath, keyPath), + cursor._onChange + ); + } + return makeCursor( + cursor._rootData, + newKeyPath(cursor._keyPath, keyPath), + cursor._onChange, + value + ); +} + +function updateCursor(cursor, changeFn, changeKeyPath) { + var deepChange = arguments.length > 2; + var newRootData = cursor._rootData.updateIn( + cursor._keyPath, + deepChange ? Map() : undefined, + changeFn + ); + var keyPath = cursor._keyPath || []; + var result = cursor._onChange && cursor._onChange.call( + undefined, + newRootData, + cursor._rootData, + deepChange ? newKeyPath(keyPath, changeKeyPath) : keyPath + ); + if (result !== undefined) { + newRootData = result; + } + return makeCursor(newRootData, cursor._keyPath, cursor._onChange); +} + +function newKeyPath(head, tail) { + return head.concat(listToKeyPath(tail)); +} + +function listToKeyPath(list) { + return Array.isArray(list) ? list : Immutable.Iterable(list).toArray(); +} + +function valToKeyPath(val) { + return Array.isArray(val) ? val : + Iterable.isIterable(val) ? val.toArray() : + [val]; +} + +exports.from = cursorFrom; diff --git a/package.json b/package.json index 84ee797c4e..6414687fb9 100644 --- a/package.json +++ b/package.json @@ -20,90 +20,6 @@ "typescript": { "definition": "dist/immutable.d.ts" }, - "scripts": { - "build": "run-s build:*", - "build:dist": "run-s clean:dist bundle:dist bundle:es copy:dist stats:dist", - "build:pages": "gulp --gulpfile gulpfile.js default", - "stats:dist": "node ./resources/dist-stats.js", - "clean:dist": "rimraf dist", - "bundle:dist": "rollup -c ./resources/rollup-config.js", - "bundle:es": "rollup -c ./resources/rollup-config-es.js", - "copy:dist": "node ./resources/copy-dist-typedefs.js", - "lint": "run-s lint:*", - "lint:ts": "tslint \"__tests__/**/*.ts\"", - "lint:js": "eslint \"{__tests__,src,pages/src,pages/lib}/**/*.js\"", - "format": "prettier --single-quote --write \"{__tests__,src,pages/src,pages/lib}/**/*.js\"", - "testonly": "./resources/jest", - "test": "run-s format build lint testonly test:types:*", - "test:travis": "npm run test && ./resources/check-changes", - "test:types:ts": "dtslint type-definitions/ts-tests", - "test:types:flow": "flow check type-definitions/tests", - "perf": "node ./resources/bench.js", - "start": "gulp --gulpfile gulpfile.js dev", - "deploy": "(cd ./pages/out && git init && git config user.name \"Travis CI\" && git config user.email \"github@fb.com\" && git add . && git commit -m \"Deploy to GitHub Pages\" && git push --force --quiet \"https://${GH_TOKEN}@github.com/facebook/immutable-js.git\" master:gh-pages > /dev/null 2>1)" - }, - "jest": { - "moduleFileExtensions": [ - "js", - "ts" - ], - "transform": { - "^.+\\.ts$": "/resources/jestPreprocessor.js" - }, - "testRegex": "/__tests__/.*\\.(ts|js)$", - "unmockedModulePathPatterns": [ - "./node_modules/react" - ] - }, - "devDependencies": { - "benchmark": "2.1.3", - "browser-sync": "2.18.8", - "browserify": "^5.11.2", - "colors": "1.1.2", - "del": "2.2.2", - "dtslint": "0.1.2", - "eslint": "3.17.1", - "eslint-config-airbnb": "14.1.0", - "eslint-config-prettier": "1.5.0", - "eslint-plugin-import": "2.2.0", - "eslint-plugin-jsx-a11y": "4.0.0", - "eslint-plugin-prettier": "2.0.1", - "eslint-plugin-react": "6.10.0", - "flow-bin": "0.56.0", - "gulp": "3.9.1", - "gulp-concat": "2.6.1", - "gulp-filter": "5.0.0", - "gulp-header": "1.8.8", - "gulp-less": "3.3.0", - "gulp-size": "2.1.0", - "gulp-sourcemaps": "2.4.1", - "gulp-uglify": "2.1.0", - "gulp-util": "3.0.8", - "jasmine-check": "0.1.5", - "jest": "19.0.2", - "marked": "0.3.6", - "microtime": "2.1.6", - "mkdirp": "0.5.1", - "npm-run-all": "4.0.2", - "prettier": "0.22.0", - "react": "^0.12.0", - "react-router": "^0.11.2", - "react-tools": "^0.12.0", - "rimraf": "2.6.1", - "rollup": "0.41.5", - "rollup-plugin-buble": "0.15.0", - "rollup-plugin-commonjs": "7.1.0", - "rollup-plugin-strip-banner": "0.1.0", - "run-sequence": "1.2.2", - "through2": "2.0.3", - "transducers-js": "^0.4.174", - "tslint": "4.5.1", - "typescript": "2.2.1", - "uglify-js": "2.8.11", - "uglify-save-license": "0.4.1", - "vinyl-buffer": "1.0.0", - "vinyl-source-stream": "1.1.0" - }, "files": [ "dist", "contrib", @@ -124,4 +40,4 @@ "iteration" ], "license": "BSD-3-Clause" -} +} \ No newline at end of file From 87279f958b1d6d4f1b7040917b85af880c8a77ae Mon Sep 17 00:00:00 2001 From: Travis CI Date: Fri, 29 Sep 2017 22:56:56 +0000 Subject: [PATCH 003/242] Deploy master to NPM branch --- dist/immutable-nonambient.d.ts | 73 ++++++++++++++++ dist/immutable.d.ts | 73 ++++++++++++++++ dist/immutable.es.js | 12 ++- dist/immutable.js | 12 ++- dist/immutable.js.flow | 155 +++++++++++++++++++++++++++++++++ dist/immutable.min.js | 52 +++++------ 6 files changed, 345 insertions(+), 32 deletions(-) diff --git a/dist/immutable-nonambient.d.ts b/dist/immutable-nonambient.d.ts index 21e57fb499..04c2ba163a 100644 --- a/dist/immutable-nonambient.d.ts +++ b/dist/immutable-nonambient.d.ts @@ -891,6 +891,20 @@ */ zip(...collections: Array>): List; + /** + * Returns a List "zipped" with the provided collections. + * + * Unlike `zip`, `zipAll` continues zipping until the longest collection is + * exhausted. Missing values from shorter collections are filled with `undefined`. + * + * ```js + * const a = List([ 1, 2 ]); + * const b = List([ 3, 4, 5 ]); + * const c = a.zipAll(b); // List [ [ 1, 3 ], [ 2, 4 ], [ undefined, 5 ] ] + * ``` + */ + zipAll(...collections: Array>): List; + /** * Returns a List "zipped" with the provided collections by using a * custom `zipper` function. @@ -2039,6 +2053,23 @@ */ zip(...collections: Array>): OrderedSet; + /** + * Returns a OrderedSet of the same type "zipped" with the provided + * collections. + * + * @see IndexedIterator.zipAll + * + * Unlike `zip`, `zipAll` continues zipping until the longest collection is + * exhausted. Missing values from shorter collections are filled with `undefined`. + * + * ```js + * const a = OrderedSet([ 1, 2 ]); + * const b = OrderedSet([ 3, 4, 5 ]); + * const c = a.zipAll(b); // OrderedSet [ [ 1, 3 ], [ 2, 4 ], [ undefined, 5 ] ] + * ``` + */ + zipAll(...collections: Array>): OrderedSet; + /** * Returns an OrderedSet of the same type "zipped" with the provided * collections by using a custom `zipper` function. @@ -2280,6 +2311,20 @@ */ zip(...collections: Array>): Stack; + /** + * Returns a Stack "zipped" with the provided collections. + * + * Unlike `zip`, `zipAll` continues zipping until the longest collection is + * exhausted. Missing values from shorter collections are filled with `undefined`. + * + * ```js + * const a = Stack([ 1, 2 ]); + * const b = Stack([ 3, 4, 5 ]); + * const c = a.zipAll(b); // Stack [ [ 1, 3 ], [ 2, 4 ], [ undefined, 5 ] ] + * ``` + */ + zipAll(...collections: Array>): Stack; + /** * Returns a Stack "zipped" with the provided collections by using a * custom `zipper` function. @@ -2836,6 +2881,20 @@ */ zip(...collections: Array>): Seq.Indexed; + /** + * Returns a Seq "zipped" with the provided collections. + * + * Unlike `zip`, `zipAll` continues zipping until the longest collection is + * exhausted. Missing values from shorter collections are filled with `undefined`. + * + * ```js + * const a = Seq([ 1, 2 ]); + * const b = Seq([ 3, 4, 5 ]); + * const c = a.zipAll(b); // Seq [ [ 1, 3 ], [ 2, 4 ], [ undefined, 5 ] ] + * ``` + */ + zipAll(...collections: Array>): Seq.Indexed; + /** * Returns a Seq "zipped" with the provided collections by using a * custom `zipper` function. @@ -3411,6 +3470,20 @@ */ zip(...collections: Array>): Collection.Indexed; + /** + * Returns a Collection "zipped" with the provided collections. + * + * Unlike `zip`, `zipAll` continues zipping until the longest collection is + * exhausted. Missing values from shorter collections are filled with `undefined`. + * + * ```js + * const a = List([ 1, 2 ]); + * const b = List([ 3, 4, 5 ]); + * const c = a.zipAll(b); // List [ [ 1, 3 ], [ 2, 4 ], [ undefined, 5 ] ] + * ``` + */ + zipAll(...collections: Array>): Collection.Indexed; + /** * Returns a Collection of the same type "zipped" with the provided * collections by using a custom `zipper` function. diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index 35c9ecd64b..bc3c975cc3 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -891,6 +891,20 @@ declare module Immutable { */ zip(...collections: Array>): List; + /** + * Returns a List "zipped" with the provided collections. + * + * Unlike `zip`, `zipAll` continues zipping until the longest collection is + * exhausted. Missing values from shorter collections are filled with `undefined`. + * + * ```js + * const a = List([ 1, 2 ]); + * const b = List([ 3, 4, 5 ]); + * const c = a.zipAll(b); // List [ [ 1, 3 ], [ 2, 4 ], [ undefined, 5 ] ] + * ``` + */ + zipAll(...collections: Array>): List; + /** * Returns a List "zipped" with the provided collections by using a * custom `zipper` function. @@ -2039,6 +2053,23 @@ declare module Immutable { */ zip(...collections: Array>): OrderedSet; + /** + * Returns a OrderedSet of the same type "zipped" with the provided + * collections. + * + * @see IndexedIterator.zipAll + * + * Unlike `zip`, `zipAll` continues zipping until the longest collection is + * exhausted. Missing values from shorter collections are filled with `undefined`. + * + * ```js + * const a = OrderedSet([ 1, 2 ]); + * const b = OrderedSet([ 3, 4, 5 ]); + * const c = a.zipAll(b); // OrderedSet [ [ 1, 3 ], [ 2, 4 ], [ undefined, 5 ] ] + * ``` + */ + zipAll(...collections: Array>): OrderedSet; + /** * Returns an OrderedSet of the same type "zipped" with the provided * collections by using a custom `zipper` function. @@ -2280,6 +2311,20 @@ declare module Immutable { */ zip(...collections: Array>): Stack; + /** + * Returns a Stack "zipped" with the provided collections. + * + * Unlike `zip`, `zipAll` continues zipping until the longest collection is + * exhausted. Missing values from shorter collections are filled with `undefined`. + * + * ```js + * const a = Stack([ 1, 2 ]); + * const b = Stack([ 3, 4, 5 ]); + * const c = a.zipAll(b); // Stack [ [ 1, 3 ], [ 2, 4 ], [ undefined, 5 ] ] + * ``` + */ + zipAll(...collections: Array>): Stack; + /** * Returns a Stack "zipped" with the provided collections by using a * custom `zipper` function. @@ -2836,6 +2881,20 @@ declare module Immutable { */ zip(...collections: Array>): Seq.Indexed; + /** + * Returns a Seq "zipped" with the provided collections. + * + * Unlike `zip`, `zipAll` continues zipping until the longest collection is + * exhausted. Missing values from shorter collections are filled with `undefined`. + * + * ```js + * const a = Seq([ 1, 2 ]); + * const b = Seq([ 3, 4, 5 ]); + * const c = a.zipAll(b); // Seq [ [ 1, 3 ], [ 2, 4 ], [ undefined, 5 ] ] + * ``` + */ + zipAll(...collections: Array>): Seq.Indexed; + /** * Returns a Seq "zipped" with the provided collections by using a * custom `zipper` function. @@ -3411,6 +3470,20 @@ declare module Immutable { */ zip(...collections: Array>): Collection.Indexed; + /** + * Returns a Collection "zipped" with the provided collections. + * + * Unlike `zip`, `zipAll` continues zipping until the longest collection is + * exhausted. Missing values from shorter collections are filled with `undefined`. + * + * ```js + * const a = List([ 1, 2 ]); + * const b = List([ 3, 4, 5 ]); + * const c = a.zipAll(b); // List [ [ 1, 3 ], [ 2, 4 ], [ undefined, 5 ] ] + * ``` + */ + zipAll(...collections: Array>): Collection.Indexed; + /** * Returns a Collection of the same type "zipped" with the provided * collections by using a custom `zipper` function. diff --git a/dist/immutable.es.js b/dist/immutable.es.js index 1a40d2a78e..1355f0236c 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -1807,9 +1807,10 @@ function maxCompare(comparator, a, b) { comp > 0; } -function zipWithFactory(keyIter, zipper, iters) { +function zipWithFactory(keyIter, zipper, iters, zipAll) { var zipSequence = makeSequence(keyIter); - zipSequence.size = new ArraySeq(iters).map(function (i) { return i.size; }).min(); + var sizes = new ArraySeq(iters).map(function (i) { return i.size; }); + zipSequence.size = zipAll ? sizes.max() : sizes.min(); // Note: this a generic base implementation of __iterate in terms of // __iterator which may be more generically useful in the future. zipSequence.__iterate = function(fn, reverse) { @@ -1848,7 +1849,7 @@ function zipWithFactory(keyIter, zipper, iters) { var steps; if (!isDone) { steps = iterators.map(function (i) { return i.next(); }); - isDone = steps.some(function (s) { return s.done; }); + isDone = zipAll ? steps.every(function (s) { return s.done; }) : steps.some(function (s) { return s.done; }); } if (isDone) { return iteratorDone(); @@ -4990,6 +4991,11 @@ mixin(IndexedCollection, { return reify(this, zipWithFactory(this, defaultZipper, collections)); }, + zipAll: function zipAll(/*, ...collections */) { + var collections = [this].concat(arrCopy(arguments)); + return reify(this, zipWithFactory(this, defaultZipper, collections, true)); + }, + zipWith: function zipWith(zipper /*, ...collections */) { var collections = arrCopy(arguments); collections[0] = this; diff --git a/dist/immutable.js b/dist/immutable.js index 11ab6097ff..9835f14887 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -1813,9 +1813,10 @@ function maxCompare(comparator, a, b) { comp > 0; } -function zipWithFactory(keyIter, zipper, iters) { +function zipWithFactory(keyIter, zipper, iters, zipAll) { var zipSequence = makeSequence(keyIter); - zipSequence.size = new ArraySeq(iters).map(function (i) { return i.size; }).min(); + var sizes = new ArraySeq(iters).map(function (i) { return i.size; }); + zipSequence.size = zipAll ? sizes.max() : sizes.min(); // Note: this a generic base implementation of __iterate in terms of // __iterator which may be more generically useful in the future. zipSequence.__iterate = function(fn, reverse) { @@ -1854,7 +1855,7 @@ function zipWithFactory(keyIter, zipper, iters) { var steps; if (!isDone) { steps = iterators.map(function (i) { return i.next(); }); - isDone = steps.some(function (s) { return s.done; }); + isDone = zipAll ? steps.every(function (s) { return s.done; }) : steps.some(function (s) { return s.done; }); } if (isDone) { return iteratorDone(); @@ -4996,6 +4997,11 @@ mixin(IndexedCollection, { return reify(this, zipWithFactory(this, defaultZipper, collections)); }, + zipAll: function zipAll(/*, ...collections */) { + var collections = [this].concat(arrCopy(arguments)); + return reify(this, zipWithFactory(this, defaultZipper, collections, true)); + }, + zipWith: function zipWith(zipper /*, ...collections */) { var collections = arrCopy(arguments); collections[0] = this; diff --git a/dist/immutable.js.flow b/dist/immutable.js.flow index c15797e79b..8e01975962 100644 --- a/dist/immutable.js.flow +++ b/dist/immutable.js.flow @@ -278,6 +278,37 @@ declare class IndexedCollection<+T> extends Collection { ..._: [] ): IndexedCollection<[T, A, B, C, D, E]>; + zipAll( + a: Iterable, + ..._: [] + ): IndexedCollection<[T, A]>; + zipAll( + a: Iterable, + b: Iterable, + ..._: [] + ): IndexedCollection<[T, A, B]>; + zipAll( + a: Iterable, + b: Iterable, + c: Iterable, + ..._: [] + ): IndexedCollection<[T, A, B, C]>; + zipAll( + a: Iterable, + b: Iterable, + c: Iterable, + d: Iterable, + ..._: [] + ): IndexedCollection<[T, A, B, C, D]>; + zipAll( + a: Iterable, + b: Iterable, + c: Iterable, + d: Iterable, + e: Iterable, + ..._: [] + ): IndexedCollection<[T, A, B, C, D, E]>; + zipWith( zipper: (value: T, a: A) => R, a: Iterable, @@ -474,6 +505,37 @@ declare class IndexedSeq<+T> extends Seq mixins IndexedCollection ..._: [] ): IndexedSeq<[T, A, B, C, D, E]>; + zipAll( + a: Iterable, + ..._: [] + ): IndexedSeq<[T, A]>; + zipAll( + a: Iterable, + b: Iterable, + ..._: [] + ): IndexedSeq<[T, A, B]>; + zipAll( + a: Iterable, + b: Iterable, + c: Iterable, + ..._: [] + ): IndexedSeq<[T, A, B, C]>; + zipAll( + a: Iterable, + b: Iterable, + c: Iterable, + d: Iterable, + ..._: [] + ): IndexedSeq<[T, A, B, C, D]>; + zipAll( + a: Iterable, + b: Iterable, + c: Iterable, + d: Iterable, + e: Iterable, + ..._: [] + ): IndexedSeq<[T, A, B, C, D, E]>; + zipWith( zipper: (value: T, a: A) => R, a: Iterable, @@ -642,6 +704,37 @@ declare class List<+T> extends IndexedCollection { ..._: [] ): List<[T, A, B, C, D, E]>; + zipAll( + a: Iterable, + ..._: [] + ): List<[T, A]>; + zipAll( + a: Iterable, + b: Iterable, + ..._: [] + ): List<[T, A, B]>; + zipAll( + a: Iterable, + b: Iterable, + c: Iterable, + ..._: [] + ): List<[T, A, B, C]>; + zipAll( + a: Iterable, + b: Iterable, + c: Iterable, + d: Iterable, + ..._: [] + ): List<[T, A, B, C, D]>; + zipAll( + a: Iterable, + b: Iterable, + c: Iterable, + d: Iterable, + e: Iterable, + ..._: [] + ): List<[T, A, B, C, D, E]>; + zipWith( zipper: (value: T, a: A) => R, a: Iterable, @@ -981,6 +1074,37 @@ declare class OrderedSet<+T> extends Set { ..._: [] ): OrderedSet<[T, A, B, C, D, E]>; + zipAll( + a: Iterable, + ..._: [] + ): OrderedSet<[T, A]>; + zipAll( + a: Iterable, + b: Iterable, + ..._: [] + ): OrderedSet<[T, A, B]>; + zipAll( + a: Iterable, + b: Iterable, + c: Iterable, + ..._: [] + ): OrderedSet<[T, A, B, C]>; + zipAll( + a: Iterable, + b: Iterable, + c: Iterable, + d: Iterable, + ..._: [] + ): OrderedSet<[T, A, B, C, D]>; + zipAll( + a: Iterable, + b: Iterable, + c: Iterable, + d: Iterable, + e: Iterable, + ..._: [] + ): OrderedSet<[T, A, B, C, D, E]>; + zipWith( zipper: (value: T, a: A) => R, a: Iterable, @@ -1090,6 +1214,37 @@ declare class Stack<+T> extends IndexedCollection { ..._: [] ): Stack<[T, A, B, C, D, E]>; + zipAll( + a: Iterable, + ..._: [] + ): Stack<[T, A]>; + zipAll( + a: Iterable, + b: Iterable, + ..._: [] + ): Stack<[T, A, B]>; + zipAll( + a: Iterable, + b: Iterable, + c: Iterable, + ..._: [] + ): Stack<[T, A, B, C]>; + zipAll( + a: Iterable, + b: Iterable, + c: Iterable, + d: Iterable, + ..._: [] + ): Stack<[T, A, B, C, D]>; + zipAll( + a: Iterable, + b: Iterable, + c: Iterable, + d: Iterable, + e: Iterable, + ..._: [] + ): Stack<[T, A, B, C, D, E]>; + zipWith( zipper: (value: T, a: A) => R, a: Iterable, diff --git a/dist/immutable.min.js b/dist/immutable.min.js index e2c83c54f3..9a52a00dcc 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -11,29 +11,29 @@ function k(t){var e=A(t);if(e)return e;if("object"==typeof t)return new rr(t);th if(void 0!==ar&&ar(t)===!1)throw Error("Non-extensible objects are not allowed as keys.");if(cr)Object.defineProperty(t,pr,{enumerable:!1,configurable:!1,writable:!1,value:e});else if(void 0!==t.propertyIsEnumerable&&t.propertyIsEnumerable===t.constructor.prototype.propertyIsEnumerable)t.propertyIsEnumerable=function(){return this.constructor.prototype.propertyIsEnumerable.apply(this,arguments)},t.propertyIsEnumerable[pr]=e;else{if(void 0===t.nodeType)throw Error("Unable to set a non-enumerable property on object.");t[pr]=e}}return e}function N(t){if(t&&t.nodeType>0)switch(t.nodeType){case 1:return t.uniqueID;case 9:return t.documentElement&&t.documentElement.uniqueID}}function V(t){var e=ft(t);return e._iter=t,e.size=t.size,e.flip=function(){return t},e.reverse=function(){var e=t.reverse.apply(this);return e.flip=function(){return t.reverse()},e},e.has=function(e){return t.includes(e)},e.includes=function(e){return t.has(e)},e.cacheResult=pt,e.__iterateUncached=function(e,r){var n=this;return t.__iterate(function(t,r){return e(r,t,n)!==!1},r)},e.__iteratorUncached=function(e,r){if(e===Ve){var n=t.__iterator(e,r);return new Xe(function(){var t=n.next();if(!t.done){var e=t.value[0];t.value[0]=t.value[1],t.value[1]=e}return t})}return t.__iterator(e===Ne?Pe:Ne,r)},e}function H(t,e,r){var n=ft(t);return n.size=t.size,n.has=function(e){return t.has(e)},n.get=function(n,i){var o=t.get(n,je);return o===je?i:e.call(r,o,n,t)},n.__iterateUncached=function(n,i){var o=this;return t.__iterate(function(t,i,u){return n(e.call(r,t,i,u),i,o)!==!1},i)},n.__iteratorUncached=function(n,i){var o=t.__iterator(Ve,i);return new Xe(function(){var i=o.next();if(i.done)return i;var u=i.value,s=u[0];return z(n,s,e.call(r,u[1],s,t),i)})},n}function Y(t,e){var r=this,n=ft(t);return n._iter=t,n.size=t.size,n.reverse=function(){return t},t.flip&&(n.flip=function(){var e=V(t);return e.reverse=function(){return t.flip()},e}),n.get=function(r,n){return t.get(e?r:-1-r,n)},n.has=function(r){return t.has(e?r:-1-r)},n.includes=function(e){ return t.includes(e)},n.cacheResult=pt,n.__iterate=function(r,n){var i=this,u=0;return n&&o(t),t.__iterate(function(t,o){return r(t,e?o:n?i.size-++u:u++,i)},!n)},n.__iterator=function(n,i){var u=0;i&&o(t);var s=t.__iterator(Ve,!i);return new Xe(function(){var t=s.next();if(t.done)return t;var o=t.value;return z(n,e?o[0]:i?r.size-++u:u++,o[1],t)})},n}function Q(t,e,r,n){var i=ft(t);return n&&(i.has=function(n){var i=t.get(n,je);return i!==je&&!!e.call(r,i,n,t)},i.get=function(n,i){var o=t.get(n,je);return o!==je&&e.call(r,o,n,t)?o:i}),i.__iterateUncached=function(i,o){var u=this,s=0;return t.__iterate(function(t,o,a){if(e.call(r,t,o,a))return s++,i(t,n?o:s-1,u)},o),s},i.__iteratorUncached=function(i,o){var u=t.__iterator(Ve,o),s=0;return new Xe(function(){for(;;){var o=u.next();if(o.done)return o;var a=o.value,c=a[0],h=a[1];if(e.call(r,h,c,t))return z(i,n?c:s++,h,o)}})},i}function X(t,e,r){var n=zr().asMutable();return t.__iterate(function(i,o){n.update(e.call(r,i,o,t),0,function(t){return t+1})}),n.asImmutable()}function F(t,e,r){var n=v(t),i=(g(t)?Wr():zr()).asMutable();t.__iterate(function(o,u){i.update(e.call(r,o,u,t),function(t){return t=t||[],t.push(n?[u,o]:o),t})});var o=ht(t);return i.map(function(e){return at(t,o(e))})}function G(t,e,r,n){var i=t.size;if(a(e,r,i))return t;var o=c(e,i),s=h(r,i);if(o!==o||s!==s)return G(t.toSeq().cacheResult(),e,r,n);var f,p=s-o;p===p&&(f=p<0?0:p);var _=ft(t);return _.size=0===f?f:t.size&&f||void 0,!n&&q(t)&&f>=0&&(_.get=function(e,r){return e=u(this,e),e>=0&&ef)return S();var t=i.next() ;return n||e===Ne?t:e===Pe?z(e,s-1,void 0,t):z(e,s-1,t.value[1],t)})},_}function Z(t,e,r){var n=ft(t);return n.__iterateUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterate(n,i);var u=0;return t.__iterate(function(t,i,s){return e.call(r,t,i,s)&&++u&&n(t,i,o)}),u},n.__iteratorUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterator(n,i);var u=t.__iterator(Ve,i),s=!0;return new Xe(function(){if(!s)return S();var t=u.next();if(t.done)return t;var i=t.value,a=i[0],c=i[1];return e.call(r,c,a,o)?n===Ve?t:z(n,a,c,t):(s=!1,S())})},n}function $(t,e,r,n){var i=ft(t);return i.__iterateUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterate(i,o);var s=!0,a=0;return t.__iterate(function(t,o,c){if(!s||!(s=e.call(r,t,o,c)))return a++,i(t,n?o:a-1,u)}),a},i.__iteratorUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterator(i,o);var s=t.__iterator(Ve,o),a=!0,c=0;return new Xe(function(){var t,o,h;do{if(t=s.next(),t.done)return n||i===Ne?t:i===Pe?z(i,c++,void 0,t):z(i,c++,t.value[1],t);var f=t.value;o=f[0],h=f[1],a&&(a=e.call(r,h,o,u))}while(a);return i===Ve?t:z(i,o,h,t)})},i}function tt(t,e){var r=v(t),n=[t].concat(e).map(function(t){return l(t)?r&&(t=We(t)):t=r?x(t):j(Array.isArray(t)?t:[t]),t}).filter(function(t){return 0!==t.size});if(0===n.length)return t;if(1===n.length){var i=n[0];if(i===t||r&&v(i)||y(t)&&y(i))return i}var o=new er(n);return r?o=o.toKeyedSeq():y(t)||(o=o.toSetSeq()),o=o.flatten(!0),o.size=n.reduce(function(t,e){if(void 0!==t){var r=e.size;if(void 0!==r)return t+r}},0),o}function et(t,e,r){var n=ft(t);return n.__iterateUncached=function(i,o){function u(t,c){t.__iterate(function(t,o){return(!e||c0}function st(t,e,r){var n=ft(t);return n.size=new er(r).map(function(t){return t.size}).min(),n.__iterate=function(t,e){for(var r,n=this,i=this.__iterator(Ne,e),o=0;!(r=i.next()).done&&t(r.value,o++,n)!==!1;);return o},n.__iteratorUncached=function(t,n){var i=r.map(function(t){return t=Ce(t),O(n?t.reverse():t)}),o=0,u=!1;return new Xe(function(){var r;return u||(r=i.map(function(t){return t.next()}),u=r.some(function(t){return t.done})),u?S():z(t,o++,e.apply(null,r.map(function(t){return t.value})))})},n}function at(t,e){return t===e?t:q(t)?e:t.constructor(e)}function ct(t){if(t!==Object(t))throw new TypeError("Expected [K, V] tuple: "+t)}function ht(t){return v(t)?We:y(t)?Be:Je}function ft(t){return Object.create((v(t)?Ge:y(t)?Ze:$e).prototype)}function pt(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size, -this):Fe.prototype.cacheResult.call(this)}function _t(t,e){return void 0===t&&void 0===e?0:void 0===t?1:void 0===e?-1:t>e?1:t>>r)&xe,s=(0===r?n:n>>>r)&xe;return new Or(e,1<>>=1)u[s]=1&r?e[o++]:void 0;return u[n]=i,new Mr(t,o+1,u)}function xt(t,e,r){for(var n=[],i=0;i>1&1431655765,t=(858993459&t)+(t>>2&858993459),t=t+(t>>4)&252645135,t+=t>>8,127&(t+=t>>16)}function Kt(t,e,r,n){var o=n?t:i(t);return o[e]=r,o}function Lt(t,e,r,n){var i=t.length+1;if(n&&e+1===i)return t[e]=r,t;for(var o=Array(i),u=0,s=0;so?0:o-r,c=u-r;return c>Ee&&(c=Ee),function(){if(i===c)return Cr;var t=e?--c:i++;return n&&n[t]}}function i(t,n,i){var s,a=t&&t.array,c=i>o?0:o-i>>n,h=1+(u-i>>n);return h>Ee&&(h=Ee),function(){for(;;){if(s){var t=s();if(t!==Cr)return t;s=null}if(c===h)return Cr;var o=e?--h:c++;s=r(a&&a[o],n-qe,i+(o<=t.size||r<0)return t.withMutations(function(t){r<0?Yt(t,r).set(0,n):Yt(t,0,r+1).set(r,n)});r+=t._origin;var i=t._tail,o=t._root,s=e(Ae);return r>=Xt(t._capacity)?i=Nt(i,t.__ownerID,0,r,n,s):o=Nt(o,t.__ownerID,t._level,r,n,s),s.value?t.__ownerID?(t._root=o,t._tail=i,t.__hash=void 0,t.__altered=!0,t):Bt(t._origin,t._capacity,t._level,o,i):t}function Nt(t,e,n,i,o,u){var s=i>>>n&xe,a=t&&s0){var h=t&&t.array[s],f=Nt(h,e,n-qe,i,o,u);return f===h?t:(c=Vt(t,e),c.array[s]=f,c)}return a&&t.array[s]===o?t:(r(u),c=Vt(t,e),void 0===o&&s===c.array.length-1?c.array.pop():c.array[s]=o,c)}function Vt(t,e){return e&&t&&e===t.ownerID?t:new Lr(t?t.array.slice():[],e)}function Ht(t,e){if(e>=Xt(t._capacity))return t._tail;if(e<1<0;)r=r.array[e>>>n&xe],n-=qe;return r}}function Yt(t,e,r){void 0!==e&&(e|=0),void 0!==r&&(r|=0);var i=t.__ownerID||new n,o=t._origin,u=t._capacity,s=o+e,a=void 0===r?u:r<0?u+r:o+r;if(s===o&&a===u)return t;if(s>=a)return t.clear();for(var c=t._level,h=t._root,f=0;s+f<0;)h=new Lr(h&&h.array.length?[void 0,h]:[],i),c+=qe,f+=1<=1<p?new Lr([],i):l;if(l&&_>p&&sqe;d-=qe){var g=p>>>d&xe;y=y.array[g]=Vt(y.array[g],i)}y.array[p>>>qe&xe]=l}if(a=_)s-=_,a-=_,c=qe,h=null,v=v&&v.removeBefore(i,0,s);else if(s>o||_>>c&xe;if(m!==_>>>c&xe)break;m&&(f+=(1<o&&(h=h.removeBefore(i,c,s-f)),h&&_i&&(i=s.size),l(u)||(s=s.map(function(t){return U(t)})),n.push(s)}return i>t.size&&(t=t.setSize(i)), -At(t,e,n)}function Xt(t){return t>>qe<=Ee&&u.size>=2*o.size?(i=u.filter(function(t,e){return void 0!==t&&s!==e}),n=i.toKeyedSeq().map(function(t){return t[0]}).flip().toMap(),t.__ownerID&&(n.__ownerID=i.__ownerID=t.__ownerID)):(n=o.remove(e),i=s===u.size-1?u.pop():u.set(s,void 0))}else if(a){if(r===u.get(s)[1])return t;n=o,i=u.set(s,[e,r])}else n=o.set(e,u.size),i=u.set(u.size,[e,r]);return t.__ownerID?(t.size=n.size,t._map=n,t._list=i,t.__hash=void 0,t):Gt(n,i)}function te(t){return!(!t||!t[Pr])}function ee(t,e,r,n){var i=Object.create(Nr);return i.size=t,i._head=e,i.__ownerID=r,i.__hash=n,i.__altered=!1,i}function re(){return Vr||(Vr=ee(0))}function ne(t,e){if(t===e)return!0;if(!l(e)||void 0!==t.size&&void 0!==e.size&&t.size!==e.size||void 0!==t.__hash&&void 0!==e.__hash&&t.__hash!==e.__hash||v(t)!==v(e)||y(t)!==y(e)||g(t)!==g(e))return!1;if(0===t.size&&0===e.size)return!0;var r=!d(t);if(g(t)){var n=t.entries();return e.every(function(t,e){var i=n.next().value;return i&&R(i[1],t)&&(r||R(i[0],e))})&&n.next().done}var i=!1;if(void 0===t.size)if(void 0===e.size)"function"==typeof t.cacheResult&&t.cacheResult();else{i=!0;var o=t;t=e,e=o}var u=!0,s=e.__iterate(function(e,n){if(r?!t.has(e):i?!R(e,t.get(n,je)):!R(t.get(n,je),e))return u=!1,!1});return u&&t.size===s}function ie(t,e){var r=function(r){t.prototype[r]=e[r]};return Object.keys(e).forEach(r),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(e).forEach(r),t}function oe(t){return!(!t||!t[Yr])}function ue(t,e){return t.__ownerID?(t.size=e.size,t._map=e,t):e===t._map?t:0===e.size?t.__empty():t.__make(e)}function se(t,e){var r=Object.create(Qr);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function ae(){return Xr||(Xr=se(St()))} -function ce(t,e,r,n,i,o){return yt(t.size),t.__iterate(function(t,o,u){i?(i=!1,r=t):r=e.call(n,r,t,o,u)},o),r}function he(t,e){return e}function fe(t,e){return[e,t]}function pe(t){return t&&"function"==typeof t.toJS?t.toJS():t}function _e(t){return function(){return!t.apply(this,arguments)}}function le(t){return function(){return-t.apply(this,arguments)}}function ve(){return i(arguments)}function ye(t,e){return te?-1:0}function de(t){if(t.size===1/0)return 0;var e=g(t),r=v(t),n=e?1:0;return ge(t.__iterate(r?e?function(t,e){n=31*n+me(W(t),W(e))|0}:function(t,e){n=n+me(W(t),W(e))|0}:e?function(t){n=31*n+W(t)|0}:function(t){n=n+W(t)|0}),n)}function ge(t,e){return e=sr(e,3432918353),e=sr(e<<15|e>>>-15,461845907),e=sr(e<<13|e>>>-13,5),e=(e+3864292196|0)^t,e=sr(e^e>>>16,2246822507),e=sr(e^e>>>13,3266489909),e=C(e^e>>>16)}function me(t,e){return t^e+2654435769+(t<<6)+(t>>2)|0}function we(t){if("object"!=typeof console||!console.warn)throw Error(t);console.warn(t)}function ze(t){return oe(t)&&g(t)}function Se(t,e){var r=Object.create(rn);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function Ie(){return nn||(nn=Se(Zt()))}function be(t,e,r){var n=Object.create(Object.getPrototypeOf(t));return n._values=e,n.__ownerID=r,n}function Oe(t){return t._name||t.constructor.name||"Record"}function Me(t){return x(t._keys.map(function(e){return[e,t.get(e)]}))}function De(t,e){try{Object.defineProperty(t,e,{get:function(){return this.get(e)},set:function(t){vt(this.__ownerID,"Cannot set on an immutable record."),this.set(e,t)}})}catch(t){}}var qe=5,Ee=1<=n.length){var e=r.next();if(e.done)return e;n[i]=e.value}return z(t,i,n[i++])})},e}(Ze),sr="function"==typeof Math.imul&&Math.imul(4294967295,2)===-2?Math.imul:function(t,e){t|=0,e|=0;var r=65535&t,n=65535&e;return r*n+((t>>>16)*n+r*(e>>>16)<<16>>>0)|0},ar=Object.isExtensible,cr=function(){try{return Object.defineProperty({},"@",{}),!0}catch(t){return!1}}(),hr="function"==typeof WeakMap;hr&&(ir=new WeakMap);var fr=0,pr="__immutablehash__";"function"==typeof Symbol&&(pr=Symbol(pr));var _r=16,lr=255,vr=0,yr={},dr=function(t){function e(t,e){this._iter=t,this._useKeys=e,this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t,e){return this._iter.get(t,e)},e.prototype.has=function(t){return this._iter.has(t)},e.prototype.valueSeq=function(){return this._iter.valueSeq()},e.prototype.reverse=function(){var t=this,e=Y(this,!0);return this._useKeys||(e.valueSeq=function(){return t._iter.toSeq().reverse()}),e},e.prototype.map=function(t,e){var r=this,n=H(this,t,e);return this._useKeys||(n.valueSeq=function(){return r._iter.toSeq().map(t,e)}),n},e.prototype.__iterate=function(t,e){var r=this -;return this._iter.__iterate(function(e,n){return t(e,n,r)},e)},e.prototype.__iterator=function(t,e){return this._iter.__iterator(t,e)},e}(Ge);dr.prototype[Le]=!0;var gr=function(t){function e(t){this._iter=t,this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.includes=function(t){return this._iter.includes(t)},e.prototype.__iterate=function(t,e){var r=this,n=0;return e&&o(this),this._iter.__iterate(function(i){return t(i,e?r.size-++n:n++,r)},e)},e.prototype.__iterator=function(t,e){var r=this,n=this._iter.__iterator(Ne,e),i=0;return e&&o(this),new Xe(function(){var o=n.next();return o.done?o:z(t,e?r.size-++i:i++,o.value,o)})},e}(Ze),mr=function(t){function e(t){this._iter=t,this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.has=function(t){return this._iter.includes(t)},e.prototype.__iterate=function(t,e){var r=this;return this._iter.__iterate(function(e){return t(e,e,r)},e)},e.prototype.__iterator=function(t,e){var r=this._iter.__iterator(Ne,e);return new Xe(function(){var e=r.next();return e.done?e:z(t,e.value,e.value,e)})},e}($e),wr=function(t){function e(t){this._iter=t,this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.entrySeq=function(){return this._iter.toSeq()},e.prototype.__iterate=function(t,e){var r=this;return this._iter.__iterate(function(e){if(e){ct(e);var n=l(e);return t(n?e.get(1):e[1],n?e.get(0):e[0],r)}},e)},e.prototype.__iterator=function(t,e){var r=this._iter.__iterator(Ne,e);return new Xe(function(){for(;;){var e=r.next();if(e.done)return e;var n=e.value;if(n){ct(n);var i=l(n);return z(t,i?n.get(0):n[0],i?n.get(1):n[1],e)}}})},e}(Ge);gr.prototype.cacheResult=dr.prototype.cacheResult=mr.prototype.cacheResult=wr.prototype.cacheResult=pt;var zr=function(t){function e(e){return null===e||void 0===e?St():gt(e)&&!g(e)?e:St().withMutations(function(r){var n=t(e);yt(n.size), -n.forEach(function(t,e){return r.set(e,t)})})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return St().withMutations(function(e){for(var r=0;r=t.length)throw Error("Missing value for key: "+t[r]);e.set(t[r],t[r+1])}})},e.prototype.toString=function(){return this.__toString("Map {","}")},e.prototype.get=function(t,e){return this._root?this._root.get(0,void 0,t,e):e},e.prototype.set=function(t,e){return It(this,t,e)},e.prototype.setIn=function(t,e){return this.updateIn(t,je,function(){return e})},e.prototype.remove=function(t){return It(this,t,je)},e.prototype.deleteIn=function(t){if(t=[].concat(lt(t)),t.length){var e=t.pop();return this.updateIn(t,function(t){return t&&t.remove(e)})}},e.prototype.deleteAll=function(t){var e=Ce(t);return 0===e.size?this:this.withMutations(function(t){e.forEach(function(e){return t.remove(e)})})},e.prototype.update=function(t,e,r){return 1===arguments.length?t(this):this.updateIn([t],e,r)},e.prototype.updateIn=function(t,e,r){r||(r=e,e=void 0);var n=Rt(this,lt(t),0,e,r);return n===je?e:n},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):St()},e.prototype.merge=function(){return xt(this,void 0,arguments)},e.prototype.mergeWith=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return xt(this,t,e)},e.prototype.mergeIn=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return this.updateIn(t,St(),function(t){return"function"==typeof t.merge?t.merge.apply(t,e):e[e.length-1]})},e.prototype.mergeDeep=function(){return xt(this,jt,arguments)},e.prototype.mergeDeepWith=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return xt(this,kt(t),e)},e.prototype.mergeDeepIn=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return this.updateIn(t,St(),function(t){ -return"function"==typeof t.mergeDeep?t.mergeDeep.apply(t,e):e[e.length-1]})},e.prototype.sort=function(t){return Wr(it(this,t))},e.prototype.sortBy=function(t,e){return Wr(it(this,e,t))},e.prototype.withMutations=function(t){var e=this.asMutable();return t(e),e.wasAltered()?e.__ensureOwner(this.__ownerID):this},e.prototype.asMutable=function(){return this.__ownerID?this:this.__ensureOwner(new n)},e.prototype.asImmutable=function(){return this.__ensureOwner()},e.prototype.wasAltered=function(){return this.__altered},e.prototype.__iterator=function(t,e){return new xr(this,t,e)},e.prototype.__iterate=function(t,e){var r=this,n=0;return this._root&&this._root.iterate(function(e){return n++,t(e[1],e[0],r)},e),n},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?zt(this.size,this._root,t,this.__hash):0===this.size?St():(this.__ownerID=t,this.__altered=!1,this)},e}(We);zr.isMap=gt;var Sr="@@__IMMUTABLE_MAP__@@",Ir=zr.prototype;Ir[Sr]=!0,Ir.delete=Ir.remove,Ir.removeIn=Ir.deleteIn,Ir.removeAll=Ir.deleteAll,Ir["@@transducer/init"]=Ir.asMutable,Ir["@@transducer/step"]=function(t,e){return t.set(e[0],e[1])},Ir["@@transducer/result"]=function(t){return t.asImmutable()};var br=function(t,e){this.ownerID=t,this.entries=e};br.prototype.get=function(t,e,r,n){for(var i=this.entries,o=0,u=i.length;o=jr)return Dt(t,h,o,u);var l=t&&t===this.ownerID,v=l?h:i(h);return _?c?f===p-1?v.pop():v[f]=v.pop():v[f]=[o,u]:v.push([o,u]),l?(this.entries=v,this):new br(t,v)}};var Or=function(t,e,r){this.ownerID=t,this.bitmap=e,this.nodes=r};Or.prototype.get=function(t,e,r,n){void 0===e&&(e=W(r));var i=1<<((0===t?e:e>>>t)&xe),o=this.bitmap;return 0==(o&i)?n:this.nodes[Ut(o&i-1)].get(t+qe,e,r,n)},Or.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=W(n)) -;var s=(0===e?r:r>>>e)&xe,a=1<=kr)return Et(t,p,c,s,l);if(h&&!l&&2===p.length&&Ot(p[1^f]))return p[1^f];if(h&&l&&1===p.length&&Ot(l))return l;var v=t&&t===this.ownerID,y=h?l?c:c^a:c|a,d=h?l?Kt(p,f,l,v):Tt(p,f,v):Lt(p,f,l,v);return v?(this.bitmap=y,this.nodes=d,this):new Or(t,y,d)};var Mr=function(t,e,r){this.ownerID=t,this.count=e,this.nodes=r};Mr.prototype.get=function(t,e,r,n){void 0===e&&(e=W(r));var i=(0===t?e:e>>>t)&xe,o=this.nodes[i];return o?o.get(t+qe,e,r,n):n},Mr.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=W(n));var s=(0===e?r:r>>>e)&xe,a=i===je,c=this.nodes,h=c[s];if(a&&!h)return this;var f=bt(h,t,e+qe,r,n,i,o,u);if(f===h)return this;var p=this.count;if(h){if(!f&&--p0&&i=0&&t0;)e[r]=arguments[r+1];return Qt(this,t,e)},e.prototype.mergeDeep=function(){return Qt(this,jt,arguments)},e.prototype.mergeDeepWith=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Qt(this,kt(t),e)},e.prototype.setSize=function(t){return Yt(this,0,t)},e.prototype.slice=function(t,e){var r=this.size;return a(t,e,r)?this:Yt(this,c(t,r),h(e,r))},e.prototype.__iterator=function(t,e){var r=e?this.size:0,n=Wt(this,e);return new Xe(function(){var i=n();return i===Cr?S():z(t,e?--r:r++,i)})},e.prototype.__iterate=function(t,e){for(var r,n=this,i=e?this.size:0,o=Wt(this,e);(r=o())!==Cr&&t(r,e?--i:i++,n)!==!1;);return i},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Bt(this._origin,this._capacity,this._level,this._root,this._tail,t,this.__hash):0===this.size?Jt():(this.__ownerID=t,this)},e}(Be);Rr.isList=Ct;var Ur="@@__IMMUTABLE_LIST__@@",Kr=Rr.prototype;Kr[Ur]=!0,Kr.delete=Kr.remove,Kr.setIn=Ir.setIn,Kr.deleteIn=Kr.removeIn=Ir.removeIn,Kr.update=Ir.update,Kr.updateIn=Ir.updateIn,Kr.mergeIn=Ir.mergeIn,Kr.mergeDeepIn=Ir.mergeDeepIn,Kr.withMutations=Ir.withMutations,Kr.asMutable=Ir.asMutable,Kr.asImmutable=Ir.asImmutable,Kr.wasAltered=Ir.wasAltered,Kr["@@transducer/init"]=Kr.asMutable,Kr["@@transducer/step"]=function(t,e){return t.push(e)},Kr["@@transducer/result"]=Ir["@@transducer/result"];var Lr=function(t,e){this.array=t,this.ownerID=e};Lr.prototype.removeBefore=function(t,e,r){if(r===e?1<>>e&xe -;if(n>=this.array.length)return new Lr([],t);var i,o=0===n;if(e>0){var u=this.array[n];if((i=u&&u.removeBefore(t,e-qe,r))===u&&o)return this}if(o&&!i)return this;var s=Vt(this,t);if(!o)for(var a=0;a>>e&xe;if(n>=this.array.length)return this;var i;if(e>0){var o=this.array[n];if((i=o&&o.removeAfter(t,e-qe,r))===o&&n===this.array.length-1)return this}var u=Vt(this,t);return u.array.splice(n+1),i&&(u.array[n]=i),u};var Tr,Cr={},Wr=function(t){function e(t){return null===t||void 0===t?Zt():Ft(t)?t:Zt().withMutations(function(e){var r=We(t);yt(r.size),r.forEach(function(t,r){return e.set(r,t)})})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("OrderedMap {","}")},e.prototype.get=function(t,e){var r=this._map.get(t);return void 0!==r?this._list.get(r)[1]:e},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._map.clear(),this._list.clear(),this):Zt()},e.prototype.set=function(t,e){return $t(this,t,e)},e.prototype.remove=function(t){return $t(this,t,je)},e.prototype.wasAltered=function(){return this._map.wasAltered()||this._list.wasAltered()},e.prototype.__iterate=function(t,e){var r=this;return this._list.__iterate(function(e){return e&&t(e[1],e[0],r)},e)},e.prototype.__iterator=function(t,e){return this._list.fromEntrySeq().__iterator(t,e)},e.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var e=this._map.__ensureOwner(t),r=this._list.__ensureOwner(t);return t?Gt(e,r,t,this.__hash):0===this.size?Zt():(this.__ownerID=t,this._map=e,this._list=r,this)},e}(zr);Wr.isOrderedMap=Ft,Wr.prototype[Le]=!0,Wr.prototype.delete=Wr.prototype.remove;var Br,Jr=function(t){function e(t){return null===t||void 0===t?re():te(t)?t:re().pushAll(t)}return t&&(e.__proto__=t), -e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("Stack [","]")},e.prototype.get=function(t,e){var r=this._head;for(t=u(this,t);r&&t--;)r=r.next;return r?r.value:e},e.prototype.peek=function(){return this._head&&this._head.value},e.prototype.push=function(){var t=arguments;if(0===arguments.length)return this;for(var e=this.size+arguments.length,r=this._head,n=arguments.length-1;n>=0;n--)r={value:t[n],next:r};return this.__ownerID?(this.size=e,this._head=r,this.__hash=void 0,this.__altered=!0,this):ee(e,r)},e.prototype.pushAll=function(e){if(e=t(e),0===e.size)return this;if(0===this.size&&te(e))return e;yt(e.size);var r=this.size,n=this._head;return e.__iterate(function(t){r++,n={value:t,next:n}},!0),this.__ownerID?(this.size=r,this._head=n,this.__hash=void 0,this.__altered=!0,this):ee(r,n)},e.prototype.pop=function(){return this.slice(1)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):re()},e.prototype.slice=function(e,r){if(a(e,r,this.size))return this;var n=c(e,this.size);if(h(r,this.size)!==this.size)return t.prototype.slice.call(this,e,r);for(var i=this.size-n,o=this._head;n--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):ee(i,o)},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?ee(this.size,this._head,t,this.__hash):0===this.size?re():(this.__ownerID=t,this.__altered=!1,this)},e.prototype.__iterate=function(t,e){var r=this;if(e)return new er(this.toArray()).__iterate(function(e,n){return t(e,n,r)},e);for(var n=0,i=this._head;i&&t(i.value,n++,r)!==!1;)i=i.next;return n},e.prototype.__iterator=function(t,e){if(e)return new er(this.toArray()).__iterator(t,e);var r=0,n=this._head;return new Xe(function(){if(n){var e=n.value;return n=n.next,z(t,r++,e)}return S()})},e}(Be);Jr.isStack=te -;var Pr="@@__IMMUTABLE_STACK__@@",Nr=Jr.prototype;Nr[Pr]=!0,Nr.withMutations=Ir.withMutations,Nr.asMutable=Ir.asMutable,Nr.asImmutable=Ir.asImmutable,Nr.wasAltered=Ir.wasAltered,Nr.shift=Nr.pop,Nr.unshift=Nr.push,Nr.unshiftAll=Nr.pushAll,Nr["@@transducer/init"]=Nr.asMutable,Nr["@@transducer/step"]=function(t,e){return t.unshift(e)},Nr["@@transducer/result"]=Ir["@@transducer/result"];var Vr,Hr=function(t){function e(e){return null===e||void 0===e?ae():oe(e)&&!g(e)?e:ae().withMutations(function(r){var n=t(e);yt(n.size),n.forEach(function(t){return r.add(t)})})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(We(t).keySeq())},e.intersect=function(t){return t=Ce(t).toArray(),t.length?Qr.intersect.apply(e(t.pop()),t):ae()},e.union=function(t){return t=Ce(t).toArray(),t.length?Qr.union.apply(e(t.pop()),t):ae()},e.prototype.toString=function(){return this.__toString("Set {","}")},e.prototype.has=function(t){return this._map.has(t)},e.prototype.add=function(t){return ue(this,this._map.set(t,!0))},e.prototype.remove=function(t){return ue(this,this._map.remove(t))},e.prototype.clear=function(){return ue(this,this._map.clear())},e.prototype.union=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return e=e.filter(function(t){return 0!==t.size}),0===e.length?this:0!==this.size||this.__ownerID||1!==e.length?this.withMutations(function(r){for(var n=0;n0;)e[r]=arguments[r+1];return this.union.apply(this,e)},e.prototype.sort=function(t){return en(it(this,t))},e.prototype.sortBy=function(t,e){return en(it(this,e,t))},e.prototype.wasAltered=function(){return this._map.wasAltered()},e.prototype.__iterate=function(t,e){var r=this;return this._map.__iterate(function(e,n){return t(n,n,r)},e)},e.prototype.__iterator=function(t,e){return this._map.map(function(t,e){return e}).__iterator(t,e)},e.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var e=this._map.__ensureOwner(t);return t?this.__make(e,t):0===this.size?ae():(this.__ownerID=t,this._map=e,this)},e}(Je);Hr.isSet=oe;var Yr="@@__IMMUTABLE_SET__@@",Qr=Hr.prototype;Qr[Yr]=!0,Qr.delete=Qr.remove,Qr.mergeDeep=Qr.merge,Qr.mergeDeepWith=Qr.mergeWith,Qr.withMutations=Ir.withMutations,Qr.asMutable=Ir.asMutable,Qr.asImmutable=Ir.asImmutable,Qr["@@transducer/init"]=Qr.asMutable,Qr["@@transducer/step"]=function(t,e){return t.add(e)},Qr["@@transducer/result"]=Ir["@@transducer/result"],Qr.__empty=ae,Qr.__make=se;var Xr,Fr,Gr=function(t){function e(t,r,n){if(!(this instanceof e))return new e(t,r,n);if(vt(0!==n,"Cannot step a Range by 0"),t=t||0,void 0===r&&(r=1/0),n=void 0===n?1:Math.abs(n),r=0&&e=0&&rthis.size?e:this.find(function(e,r){return r===t},void 0,e)},has:function(t){return(t=u(this,t))>=0&&(void 0!==this.size?this.size===1/0||t0}function st(t,e,r,n){var i=ft(t),o=new er(r).map(function(t){return t.size});return i.size=n?o.max():o.min(),i.__iterate=function(t,e){for(var r,n=this,i=this.__iterator(Ne,e),o=0;!(r=i.next()).done&&t(r.value,o++,n)!==!1;);return o},i.__iteratorUncached=function(t,i){var o=r.map(function(t){return t=Ce(t),O(i?t.reverse():t)}),u=0,s=!1;return new Xe(function(){var r;return s||(r=o.map(function(t){return t.next()}),s=n?r.every(function(t){return t.done}):r.some(function(t){return t.done})),s?S():z(t,u++,e.apply(null,r.map(function(t){return t.value})))})},i}function at(t,e){return t===e?t:q(t)?e:t.constructor(e)}function ct(t){if(t!==Object(t))throw new TypeError("Expected [K, V] tuple: "+t)}function ht(t){return v(t)?We:y(t)?Be:Je}function ft(t){return Object.create((v(t)?Ge:y(t)?Ze:$e).prototype)}function pt(){return this._iter.cacheResult?(this._iter.cacheResult(), +this.size=this._iter.size,this):Fe.prototype.cacheResult.call(this)}function _t(t,e){return void 0===t&&void 0===e?0:void 0===t?1:void 0===e?-1:t>e?1:t>>r)&xe,s=(0===r?n:n>>>r)&xe;return new Or(e,1<>>=1)u[s]=1&r?e[o++]:void 0;return u[n]=i,new Mr(t,o+1,u)}function xt(t,e,r){for(var n=[],i=0;i>1&1431655765,t=(858993459&t)+(t>>2&858993459),t=t+(t>>4)&252645135,t+=t>>8,127&(t+=t>>16)}function Kt(t,e,r,n){var o=n?t:i(t);return o[e]=r,o}function Lt(t,e,r,n){var i=t.length+1;if(n&&e+1===i)return t[e]=r,t;for(var o=Array(i),u=0,s=0;so?0:o-r,c=u-r;return c>Ee&&(c=Ee),function(){if(i===c)return Cr;var t=e?--c:i++;return n&&n[t]}}function i(t,n,i){var s,a=t&&t.array,c=i>o?0:o-i>>n,h=1+(u-i>>n);return h>Ee&&(h=Ee),function(){for(;;){if(s){var t=s();if(t!==Cr)return t;s=null}if(c===h)return Cr;var o=e?--h:c++;s=r(a&&a[o],n-qe,i+(o<=t.size||r<0)return t.withMutations(function(t){r<0?Yt(t,r).set(0,n):Yt(t,0,r+1).set(r,n)});r+=t._origin;var i=t._tail,o=t._root,s=e(Ae);return r>=Xt(t._capacity)?i=Nt(i,t.__ownerID,0,r,n,s):o=Nt(o,t.__ownerID,t._level,r,n,s),s.value?t.__ownerID?(t._root=o,t._tail=i,t.__hash=void 0,t.__altered=!0,t):Bt(t._origin,t._capacity,t._level,o,i):t}function Nt(t,e,n,i,o,u){var s=i>>>n&xe,a=t&&s0){var h=t&&t.array[s],f=Nt(h,e,n-qe,i,o,u);return f===h?t:(c=Vt(t,e),c.array[s]=f,c)}return a&&t.array[s]===o?t:(r(u),c=Vt(t,e),void 0===o&&s===c.array.length-1?c.array.pop():c.array[s]=o,c)}function Vt(t,e){return e&&t&&e===t.ownerID?t:new Lr(t?t.array.slice():[],e)}function Ht(t,e){if(e>=Xt(t._capacity))return t._tail;if(e<1<0;)r=r.array[e>>>n&xe],n-=qe;return r}}function Yt(t,e,r){void 0!==e&&(e|=0),void 0!==r&&(r|=0);var i=t.__ownerID||new n,o=t._origin,u=t._capacity,s=o+e,a=void 0===r?u:r<0?u+r:o+r;if(s===o&&a===u)return t;if(s>=a)return t.clear();for(var c=t._level,h=t._root,f=0;s+f<0;)h=new Lr(h&&h.array.length?[void 0,h]:[],i),c+=qe,f+=1<=1<p?new Lr([],i):l;if(l&&_>p&&sqe;d-=qe){var g=p>>>d&xe;y=y.array[g]=Vt(y.array[g],i)}y.array[p>>>qe&xe]=l}if(a=_)s-=_,a-=_,c=qe,h=null,v=v&&v.removeBefore(i,0,s);else if(s>o||_>>c&xe;if(m!==_>>>c&xe)break;m&&(f+=(1<o&&(h=h.removeBefore(i,c,s-f)),h&&_i&&(i=s.size),l(u)||(s=s.map(function(t){return U(t)})),n.push(s)} +return i>t.size&&(t=t.setSize(i)),At(t,e,n)}function Xt(t){return t>>qe<=Ee&&u.size>=2*o.size?(i=u.filter(function(t,e){return void 0!==t&&s!==e}),n=i.toKeyedSeq().map(function(t){return t[0]}).flip().toMap(),t.__ownerID&&(n.__ownerID=i.__ownerID=t.__ownerID)):(n=o.remove(e),i=s===u.size-1?u.pop():u.set(s,void 0))}else if(a){if(r===u.get(s)[1])return t;n=o,i=u.set(s,[e,r])}else n=o.set(e,u.size),i=u.set(u.size,[e,r]);return t.__ownerID?(t.size=n.size,t._map=n,t._list=i,t.__hash=void 0,t):Gt(n,i)}function te(t){return!(!t||!t[Pr])}function ee(t,e,r,n){var i=Object.create(Nr);return i.size=t,i._head=e,i.__ownerID=r,i.__hash=n,i.__altered=!1,i}function re(){return Vr||(Vr=ee(0))}function ne(t,e){if(t===e)return!0;if(!l(e)||void 0!==t.size&&void 0!==e.size&&t.size!==e.size||void 0!==t.__hash&&void 0!==e.__hash&&t.__hash!==e.__hash||v(t)!==v(e)||y(t)!==y(e)||g(t)!==g(e))return!1;if(0===t.size&&0===e.size)return!0;var r=!d(t);if(g(t)){var n=t.entries();return e.every(function(t,e){var i=n.next().value;return i&&R(i[1],t)&&(r||R(i[0],e))})&&n.next().done}var i=!1;if(void 0===t.size)if(void 0===e.size)"function"==typeof t.cacheResult&&t.cacheResult();else{i=!0;var o=t;t=e,e=o}var u=!0,s=e.__iterate(function(e,n){if(r?!t.has(e):i?!R(e,t.get(n,je)):!R(t.get(n,je),e))return u=!1,!1});return u&&t.size===s}function ie(t,e){var r=function(r){t.prototype[r]=e[r]};return Object.keys(e).forEach(r),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(e).forEach(r),t}function oe(t){return!(!t||!t[Yr])}function ue(t,e){return t.__ownerID?(t.size=e.size,t._map=e,t):e===t._map?t:0===e.size?t.__empty():t.__make(e)}function se(t,e){var r=Object.create(Qr);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r} +function ae(){return Xr||(Xr=se(St()))}function ce(t,e,r,n,i,o){return yt(t.size),t.__iterate(function(t,o,u){i?(i=!1,r=t):r=e.call(n,r,t,o,u)},o),r}function he(t,e){return e}function fe(t,e){return[e,t]}function pe(t){return t&&"function"==typeof t.toJS?t.toJS():t}function _e(t){return function(){return!t.apply(this,arguments)}}function le(t){return function(){return-t.apply(this,arguments)}}function ve(){return i(arguments)}function ye(t,e){return te?-1:0}function de(t){if(t.size===1/0)return 0;var e=g(t),r=v(t),n=e?1:0;return ge(t.__iterate(r?e?function(t,e){n=31*n+me(W(t),W(e))|0}:function(t,e){n=n+me(W(t),W(e))|0}:e?function(t){n=31*n+W(t)|0}:function(t){n=n+W(t)|0}),n)}function ge(t,e){return e=sr(e,3432918353),e=sr(e<<15|e>>>-15,461845907),e=sr(e<<13|e>>>-13,5),e=(e+3864292196|0)^t,e=sr(e^e>>>16,2246822507),e=sr(e^e>>>13,3266489909),e=C(e^e>>>16)}function me(t,e){return t^e+2654435769+(t<<6)+(t>>2)|0}function we(t){if("object"!=typeof console||!console.warn)throw Error(t);console.warn(t)}function ze(t){return oe(t)&&g(t)}function Se(t,e){var r=Object.create(rn);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function Ie(){return nn||(nn=Se(Zt()))}function be(t,e,r){var n=Object.create(Object.getPrototypeOf(t));return n._values=e,n.__ownerID=r,n}function Oe(t){return t._name||t.constructor.name||"Record"}function Me(t){return x(t._keys.map(function(e){return[e,t.get(e)]}))}function De(t,e){try{Object.defineProperty(t,e,{get:function(){return this.get(e)},set:function(t){vt(this.__ownerID,"Cannot set on an immutable record."),this.set(e,t)}})}catch(t){}}var qe=5,Ee=1<=n.length){var e=r.next();if(e.done)return e;n[i]=e.value}return z(t,i,n[i++])})},e}(Ze),sr="function"==typeof Math.imul&&Math.imul(4294967295,2)===-2?Math.imul:function(t,e){t|=0,e|=0;var r=65535&t,n=65535&e;return r*n+((t>>>16)*n+r*(e>>>16)<<16>>>0)|0},ar=Object.isExtensible,cr=function(){try{return Object.defineProperty({},"@",{}),!0}catch(t){return!1}}(),hr="function"==typeof WeakMap;hr&&(ir=new WeakMap);var fr=0,pr="__immutablehash__";"function"==typeof Symbol&&(pr=Symbol(pr));var _r=16,lr=255,vr=0,yr={},dr=function(t){function e(t,e){this._iter=t,this._useKeys=e,this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t,e){return this._iter.get(t,e)},e.prototype.has=function(t){return this._iter.has(t)},e.prototype.valueSeq=function(){return this._iter.valueSeq()},e.prototype.reverse=function(){var t=this,e=Y(this,!0);return this._useKeys||(e.valueSeq=function(){return t._iter.toSeq().reverse()}),e},e.prototype.map=function(t,e){var r=this,n=H(this,t,e);return this._useKeys||(n.valueSeq=function(){ +return r._iter.toSeq().map(t,e)}),n},e.prototype.__iterate=function(t,e){var r=this;return this._iter.__iterate(function(e,n){return t(e,n,r)},e)},e.prototype.__iterator=function(t,e){return this._iter.__iterator(t,e)},e}(Ge);dr.prototype[Le]=!0;var gr=function(t){function e(t){this._iter=t,this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.includes=function(t){return this._iter.includes(t)},e.prototype.__iterate=function(t,e){var r=this,n=0;return e&&o(this),this._iter.__iterate(function(i){return t(i,e?r.size-++n:n++,r)},e)},e.prototype.__iterator=function(t,e){var r=this,n=this._iter.__iterator(Ne,e),i=0;return e&&o(this),new Xe(function(){var o=n.next();return o.done?o:z(t,e?r.size-++i:i++,o.value,o)})},e}(Ze),mr=function(t){function e(t){this._iter=t,this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.has=function(t){return this._iter.includes(t)},e.prototype.__iterate=function(t,e){var r=this;return this._iter.__iterate(function(e){return t(e,e,r)},e)},e.prototype.__iterator=function(t,e){var r=this._iter.__iterator(Ne,e);return new Xe(function(){var e=r.next();return e.done?e:z(t,e.value,e.value,e)})},e}($e),wr=function(t){function e(t){this._iter=t,this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.entrySeq=function(){return this._iter.toSeq()},e.prototype.__iterate=function(t,e){var r=this;return this._iter.__iterate(function(e){if(e){ct(e);var n=l(e);return t(n?e.get(1):e[1],n?e.get(0):e[0],r)}},e)},e.prototype.__iterator=function(t,e){var r=this._iter.__iterator(Ne,e);return new Xe(function(){for(;;){var e=r.next();if(e.done)return e;var n=e.value;if(n){ct(n);var i=l(n);return z(t,i?n.get(0):n[0],i?n.get(1):n[1],e)}}})},e}(Ge);gr.prototype.cacheResult=dr.prototype.cacheResult=mr.prototype.cacheResult=wr.prototype.cacheResult=pt;var zr=function(t){function e(e){ +return null===e||void 0===e?St():gt(e)&&!g(e)?e:St().withMutations(function(r){var n=t(e);yt(n.size),n.forEach(function(t,e){return r.set(e,t)})})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return St().withMutations(function(e){for(var r=0;r=t.length)throw Error("Missing value for key: "+t[r]);e.set(t[r],t[r+1])}})},e.prototype.toString=function(){return this.__toString("Map {","}")},e.prototype.get=function(t,e){return this._root?this._root.get(0,void 0,t,e):e},e.prototype.set=function(t,e){return It(this,t,e)},e.prototype.setIn=function(t,e){return this.updateIn(t,je,function(){return e})},e.prototype.remove=function(t){return It(this,t,je)},e.prototype.deleteIn=function(t){if(t=[].concat(lt(t)),t.length){var e=t.pop();return this.updateIn(t,function(t){return t&&t.remove(e)})}},e.prototype.deleteAll=function(t){var e=Ce(t);return 0===e.size?this:this.withMutations(function(t){e.forEach(function(e){return t.remove(e)})})},e.prototype.update=function(t,e,r){return 1===arguments.length?t(this):this.updateIn([t],e,r)},e.prototype.updateIn=function(t,e,r){r||(r=e,e=void 0);var n=Rt(this,lt(t),0,e,r);return n===je?e:n},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):St()},e.prototype.merge=function(){return xt(this,void 0,arguments)},e.prototype.mergeWith=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return xt(this,t,e)},e.prototype.mergeIn=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return this.updateIn(t,St(),function(t){return"function"==typeof t.merge?t.merge.apply(t,e):e[e.length-1]})},e.prototype.mergeDeep=function(){return xt(this,jt,arguments)},e.prototype.mergeDeepWith=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return xt(this,kt(t),e)},e.prototype.mergeDeepIn=function(t){ +for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return this.updateIn(t,St(),function(t){return"function"==typeof t.mergeDeep?t.mergeDeep.apply(t,e):e[e.length-1]})},e.prototype.sort=function(t){return Wr(it(this,t))},e.prototype.sortBy=function(t,e){return Wr(it(this,e,t))},e.prototype.withMutations=function(t){var e=this.asMutable();return t(e),e.wasAltered()?e.__ensureOwner(this.__ownerID):this},e.prototype.asMutable=function(){return this.__ownerID?this:this.__ensureOwner(new n)},e.prototype.asImmutable=function(){return this.__ensureOwner()},e.prototype.wasAltered=function(){return this.__altered},e.prototype.__iterator=function(t,e){return new xr(this,t,e)},e.prototype.__iterate=function(t,e){var r=this,n=0;return this._root&&this._root.iterate(function(e){return n++,t(e[1],e[0],r)},e),n},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?zt(this.size,this._root,t,this.__hash):0===this.size?St():(this.__ownerID=t,this.__altered=!1,this)},e}(We);zr.isMap=gt;var Sr="@@__IMMUTABLE_MAP__@@",Ir=zr.prototype;Ir[Sr]=!0,Ir.delete=Ir.remove,Ir.removeIn=Ir.deleteIn,Ir.removeAll=Ir.deleteAll,Ir["@@transducer/init"]=Ir.asMutable,Ir["@@transducer/step"]=function(t,e){return t.set(e[0],e[1])},Ir["@@transducer/result"]=function(t){return t.asImmutable()};var br=function(t,e){this.ownerID=t,this.entries=e};br.prototype.get=function(t,e,r,n){for(var i=this.entries,o=0,u=i.length;o=jr)return Dt(t,h,o,u);var l=t&&t===this.ownerID,v=l?h:i(h);return _?c?f===p-1?v.pop():v[f]=v.pop():v[f]=[o,u]:v.push([o,u]),l?(this.entries=v,this):new br(t,v)}};var Or=function(t,e,r){this.ownerID=t,this.bitmap=e,this.nodes=r};Or.prototype.get=function(t,e,r,n){void 0===e&&(e=W(r));var i=1<<((0===t?e:e>>>t)&xe),o=this.bitmap +;return 0==(o&i)?n:this.nodes[Ut(o&i-1)].get(t+qe,e,r,n)},Or.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=W(n));var s=(0===e?r:r>>>e)&xe,a=1<=kr)return Et(t,p,c,s,l);if(h&&!l&&2===p.length&&Ot(p[1^f]))return p[1^f];if(h&&l&&1===p.length&&Ot(l))return l;var v=t&&t===this.ownerID,y=h?l?c:c^a:c|a,d=h?l?Kt(p,f,l,v):Tt(p,f,v):Lt(p,f,l,v);return v?(this.bitmap=y,this.nodes=d,this):new Or(t,y,d)};var Mr=function(t,e,r){this.ownerID=t,this.count=e,this.nodes=r};Mr.prototype.get=function(t,e,r,n){void 0===e&&(e=W(r));var i=(0===t?e:e>>>t)&xe,o=this.nodes[i];return o?o.get(t+qe,e,r,n):n},Mr.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=W(n));var s=(0===e?r:r>>>e)&xe,a=i===je,c=this.nodes,h=c[s];if(a&&!h)return this;var f=bt(h,t,e+qe,r,n,i,o,u);if(f===h)return this;var p=this.count;if(h){if(!f&&--p0&&i=0&&t0;)e[r]=arguments[r+1];return Qt(this,t,e)},e.prototype.mergeDeep=function(){return Qt(this,jt,arguments)},e.prototype.mergeDeepWith=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Qt(this,kt(t),e)},e.prototype.setSize=function(t){return Yt(this,0,t)},e.prototype.slice=function(t,e){var r=this.size;return a(t,e,r)?this:Yt(this,c(t,r),h(e,r))},e.prototype.__iterator=function(t,e){var r=e?this.size:0,n=Wt(this,e);return new Xe(function(){var i=n();return i===Cr?S():z(t,e?--r:r++,i)})},e.prototype.__iterate=function(t,e){for(var r,n=this,i=e?this.size:0,o=Wt(this,e);(r=o())!==Cr&&t(r,e?--i:i++,n)!==!1;);return i},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Bt(this._origin,this._capacity,this._level,this._root,this._tail,t,this.__hash):0===this.size?Jt():(this.__ownerID=t,this)},e}(Be);Rr.isList=Ct;var Ur="@@__IMMUTABLE_LIST__@@",Kr=Rr.prototype;Kr[Ur]=!0,Kr.delete=Kr.remove,Kr.setIn=Ir.setIn,Kr.deleteIn=Kr.removeIn=Ir.removeIn,Kr.update=Ir.update,Kr.updateIn=Ir.updateIn,Kr.mergeIn=Ir.mergeIn,Kr.mergeDeepIn=Ir.mergeDeepIn,Kr.withMutations=Ir.withMutations,Kr.asMutable=Ir.asMutable,Kr.asImmutable=Ir.asImmutable,Kr.wasAltered=Ir.wasAltered,Kr["@@transducer/init"]=Kr.asMutable,Kr["@@transducer/step"]=function(t,e){return t.push(e)}, +Kr["@@transducer/result"]=Ir["@@transducer/result"];var Lr=function(t,e){this.array=t,this.ownerID=e};Lr.prototype.removeBefore=function(t,e,r){if(r===e?1<>>e&xe;if(n>=this.array.length)return new Lr([],t);var i,o=0===n;if(e>0){var u=this.array[n];if((i=u&&u.removeBefore(t,e-qe,r))===u&&o)return this}if(o&&!i)return this;var s=Vt(this,t);if(!o)for(var a=0;a>>e&xe;if(n>=this.array.length)return this;var i;if(e>0){var o=this.array[n];if((i=o&&o.removeAfter(t,e-qe,r))===o&&n===this.array.length-1)return this}var u=Vt(this,t);return u.array.splice(n+1),i&&(u.array[n]=i),u};var Tr,Cr={},Wr=function(t){function e(t){return null===t||void 0===t?Zt():Ft(t)?t:Zt().withMutations(function(e){var r=We(t);yt(r.size),r.forEach(function(t,r){return e.set(r,t)})})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("OrderedMap {","}")},e.prototype.get=function(t,e){var r=this._map.get(t);return void 0!==r?this._list.get(r)[1]:e},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._map.clear(),this._list.clear(),this):Zt()},e.prototype.set=function(t,e){return $t(this,t,e)},e.prototype.remove=function(t){return $t(this,t,je)},e.prototype.wasAltered=function(){return this._map.wasAltered()||this._list.wasAltered()},e.prototype.__iterate=function(t,e){var r=this;return this._list.__iterate(function(e){return e&&t(e[1],e[0],r)},e)},e.prototype.__iterator=function(t,e){return this._list.fromEntrySeq().__iterator(t,e)},e.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var e=this._map.__ensureOwner(t),r=this._list.__ensureOwner(t);return t?Gt(e,r,t,this.__hash):0===this.size?Zt():(this.__ownerID=t,this._map=e,this._list=r,this)},e}(zr) +;Wr.isOrderedMap=Ft,Wr.prototype[Le]=!0,Wr.prototype.delete=Wr.prototype.remove;var Br,Jr=function(t){function e(t){return null===t||void 0===t?re():te(t)?t:re().pushAll(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("Stack [","]")},e.prototype.get=function(t,e){var r=this._head;for(t=u(this,t);r&&t--;)r=r.next;return r?r.value:e},e.prototype.peek=function(){return this._head&&this._head.value},e.prototype.push=function(){var t=arguments;if(0===arguments.length)return this;for(var e=this.size+arguments.length,r=this._head,n=arguments.length-1;n>=0;n--)r={value:t[n],next:r};return this.__ownerID?(this.size=e,this._head=r,this.__hash=void 0,this.__altered=!0,this):ee(e,r)},e.prototype.pushAll=function(e){if(e=t(e),0===e.size)return this;if(0===this.size&&te(e))return e;yt(e.size);var r=this.size,n=this._head;return e.__iterate(function(t){r++,n={value:t,next:n}},!0),this.__ownerID?(this.size=r,this._head=n,this.__hash=void 0,this.__altered=!0,this):ee(r,n)},e.prototype.pop=function(){return this.slice(1)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):re()},e.prototype.slice=function(e,r){if(a(e,r,this.size))return this;var n=c(e,this.size);if(h(r,this.size)!==this.size)return t.prototype.slice.call(this,e,r);for(var i=this.size-n,o=this._head;n--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):ee(i,o)},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?ee(this.size,this._head,t,this.__hash):0===this.size?re():(this.__ownerID=t,this.__altered=!1,this)},e.prototype.__iterate=function(t,e){var r=this;if(e)return new er(this.toArray()).__iterate(function(e,n){return t(e,n,r)},e);for(var n=0,i=this._head;i&&t(i.value,n++,r)!==!1;)i=i.next;return n},e.prototype.__iterator=function(t,e){ +if(e)return new er(this.toArray()).__iterator(t,e);var r=0,n=this._head;return new Xe(function(){if(n){var e=n.value;return n=n.next,z(t,r++,e)}return S()})},e}(Be);Jr.isStack=te;var Pr="@@__IMMUTABLE_STACK__@@",Nr=Jr.prototype;Nr[Pr]=!0,Nr.withMutations=Ir.withMutations,Nr.asMutable=Ir.asMutable,Nr.asImmutable=Ir.asImmutable,Nr.wasAltered=Ir.wasAltered,Nr.shift=Nr.pop,Nr.unshift=Nr.push,Nr.unshiftAll=Nr.pushAll,Nr["@@transducer/init"]=Nr.asMutable,Nr["@@transducer/step"]=function(t,e){return t.unshift(e)},Nr["@@transducer/result"]=Ir["@@transducer/result"];var Vr,Hr=function(t){function e(e){return null===e||void 0===e?ae():oe(e)&&!g(e)?e:ae().withMutations(function(r){var n=t(e);yt(n.size),n.forEach(function(t){return r.add(t)})})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(We(t).keySeq())},e.intersect=function(t){return t=Ce(t).toArray(),t.length?Qr.intersect.apply(e(t.pop()),t):ae()},e.union=function(t){return t=Ce(t).toArray(),t.length?Qr.union.apply(e(t.pop()),t):ae()},e.prototype.toString=function(){return this.__toString("Set {","}")},e.prototype.has=function(t){return this._map.has(t)},e.prototype.add=function(t){return ue(this,this._map.set(t,!0))},e.prototype.remove=function(t){return ue(this,this._map.remove(t))},e.prototype.clear=function(){return ue(this,this._map.clear())},e.prototype.union=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return e=e.filter(function(t){return 0!==t.size}),0===e.length?this:0!==this.size||this.__ownerID||1!==e.length?this.withMutations(function(r){for(var n=0;n0;)e[r]=arguments[r+1];return this.union.apply(this,e)},e.prototype.sort=function(t){return en(it(this,t))},e.prototype.sortBy=function(t,e){return en(it(this,e,t))},e.prototype.wasAltered=function(){return this._map.wasAltered()},e.prototype.__iterate=function(t,e){var r=this;return this._map.__iterate(function(e,n){return t(n,n,r)},e)},e.prototype.__iterator=function(t,e){return this._map.map(function(t,e){return e}).__iterator(t,e)},e.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var e=this._map.__ensureOwner(t);return t?this.__make(e,t):0===this.size?ae():(this.__ownerID=t,this._map=e,this)},e}(Je);Hr.isSet=oe;var Yr="@@__IMMUTABLE_SET__@@",Qr=Hr.prototype;Qr[Yr]=!0,Qr.delete=Qr.remove,Qr.mergeDeep=Qr.merge,Qr.mergeDeepWith=Qr.mergeWith,Qr.withMutations=Ir.withMutations,Qr.asMutable=Ir.asMutable,Qr.asImmutable=Ir.asImmutable,Qr["@@transducer/init"]=Qr.asMutable,Qr["@@transducer/step"]=function(t,e){return t.add(e)},Qr["@@transducer/result"]=Ir["@@transducer/result"],Qr.__empty=ae,Qr.__make=se;var Xr,Fr,Gr=function(t){function e(t,r,n){if(!(this instanceof e))return new e(t,r,n);if(vt(0!==n,"Cannot step a Range by 0"),t=t||0,void 0===r&&(r=1/0),n=void 0===n?1:Math.abs(n),r=0&&e=0&&rthis.size?e:this.find(function(e,r){return r===t},void 0,e)},has:function(t){return(t=u(this,t))>=0&&(void 0!==this.size?this.size===1/0||t Date: Sat, 30 Sep 2017 00:58:59 +0000 Subject: [PATCH 004/242] Deploy master to NPM branch --- dist/immutable.js.flow | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/dist/immutable.js.flow b/dist/immutable.js.flow index 8e01975962..77080cf1dd 100644 --- a/dist/immutable.js.flow +++ b/dist/immutable.js.flow @@ -1287,20 +1287,22 @@ declare function Repeat(value: T, times?: number): IndexedSeq; declare function isRecord(maybeRecord: any): boolean %checks(maybeRecord instanceof RecordInstance); declare class Record { - static (spec: Values, name?: string): RecordClass; - constructor(spec: Values, name?: string): RecordClass; + static (spec: Values, name?: string): Class>; + constructor(spec: Values, name?: string): Class>; static isRecord: typeof isRecord; - static getDescriptiveName(record: RecordInstance<*>): string; + static getDescriptiveName(record: RecordInstance): string; } -declare interface RecordClass { - (values: $Shape | Iterable<[string, any]>): RecordInstance & T; - new (values: $Shape | Iterable<[string, any]>): RecordInstance & T; -} +type RecordOf = RecordInstance & Values; declare class RecordInstance { + static (values?: $Shape | Iterable<[string, any]>): RecordOf; + // Note: a constructor can only create an instance of RecordInstance, + // it's encouraged to not use `new` when creating Records. + constructor (values?: $Shape | Iterable<[string, any]>): void; + size: number; has(key: string): boolean; @@ -1421,7 +1423,8 @@ export type { SetCollection, KeyedSeq, IndexedSeq, - RecordInstance, SetSeq, + RecordOf, + RecordInstance, ValueObject, } From f97bc688f5faf22f8b7bc743014e580b58965de7 Mon Sep 17 00:00:00 2001 From: Travis CI Date: Sat, 30 Sep 2017 00:59:08 +0000 Subject: [PATCH 005/242] Deploy master to NPM branch --- dist/immutable.es.js | 585 +++++++++++++++++++++++-------------------- dist/immutable.js | 585 +++++++++++++++++++++++-------------------- 2 files changed, 626 insertions(+), 544 deletions(-) diff --git a/dist/immutable.es.js b/dist/immutable.es.js index 1355f0236c..5b7b1d216e 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -78,9 +78,11 @@ function returnTrue() { } function wholeSlice(begin, end, size) { - return ((begin === 0 && !isNeg(begin)) || - (size !== undefined && begin <= -size)) && - (end === undefined || (size !== undefined && end >= size)); + return ( + ((begin === 0 && !isNeg(begin)) || + (size !== undefined && begin <= -size)) && + (end === undefined || (size !== undefined && end >= size)) + ); } function resolveBegin(begin, size) { @@ -97,10 +99,10 @@ function resolveIndex(index, size, defaultIndex) { return index === undefined ? defaultIndex : isNeg(index) - ? size === Infinity ? size : Math.max(0, size + index) | 0 - : size === undefined || size === index - ? index - : Math.min(size, index) | 0; + ? size === Infinity ? size : Math.max(0, size + index) | 0 + : size === undefined || size === index + ? index + : Math.min(size, index) | 0; } function isNeg(value) { @@ -109,8 +111,10 @@ function isNeg(value) { } function isImmutable(maybeImmutable) { - return (isCollection(maybeImmutable) || isRecord(maybeImmutable)) && - !maybeImmutable.__ownerID; + return ( + (isCollection(maybeImmutable) || isRecord(maybeImmutable)) && + !maybeImmutable.__ownerID + ); } function isCollection(maybeCollection) { @@ -138,9 +142,11 @@ function isRecord(maybeRecord) { } function isValueObject(maybeValue) { - return !!(maybeValue && + return !!( + maybeValue && typeof maybeValue.equals === 'function' && - typeof maybeValue.hashCode === 'function'); + typeof maybeValue.hashCode === 'function' + ); } var IS_ITERABLE_SENTINEL = '@@__IMMUTABLE_ITERABLE__@@'; @@ -214,9 +220,9 @@ Iterator.KEYS = ITERATE_KEYS; Iterator.VALUES = ITERATE_VALUES; Iterator.ENTRIES = ITERATE_ENTRIES; -Iterator.prototype.inspect = (Iterator.prototype.toSource = function() { +Iterator.prototype.inspect = Iterator.prototype.toSource = function() { return this.toString(); -}); +}; Iterator.prototype[ITERATOR_SYMBOL] = function() { return this; }; @@ -250,7 +256,8 @@ function getIterator(iterable) { } function getIteratorFn(iterable) { - var iteratorFn = iterable && + var iteratorFn = + iterable && ((REAL_ITERATOR_SYMBOL && iterable[REAL_ITERATOR_SYMBOL]) || iterable[FAUX_ITERATOR_SYMBOL]); if (typeof iteratorFn === 'function') { @@ -267,8 +274,8 @@ var Seq = (function (Collection$$1) { return value === null || value === undefined ? emptySequence() : isCollection(value) || isRecord(value) - ? value.toSeq() - : seqFromValue(value); + ? value.toSeq() + : seqFromValue(value); } if ( Collection$$1 ) Seq.__proto__ = Collection$$1; @@ -337,8 +344,8 @@ var KeyedSeq = (function (Seq) { return value === null || value === undefined ? emptySequence().toKeyedSeq() : isCollection(value) - ? isKeyed(value) ? value.toSeq() : value.fromEntrySeq() - : isRecord(value) ? value.toSeq() : keyedSeqFromValue(value); + ? isKeyed(value) ? value.toSeq() : value.fromEntrySeq() + : isRecord(value) ? value.toSeq() : keyedSeqFromValue(value); } if ( Seq ) KeyedSeq.__proto__ = Seq; @@ -357,10 +364,10 @@ var IndexedSeq = (function (Seq) { return value === null || value === undefined ? emptySequence() : isCollection(value) - ? isKeyed(value) ? value.entrySeq() : value.toIndexedSeq() - : isRecord(value) - ? value.toSeq().entrySeq() - : indexedSeqFromValue(value); + ? isKeyed(value) ? value.entrySeq() : value.toIndexedSeq() + : isRecord(value) + ? value.toSeq().entrySeq() + : indexedSeqFromValue(value); } if ( Seq ) IndexedSeq.__proto__ = Seq; @@ -386,7 +393,8 @@ var SetSeq = (function (Seq) { function SetSeq(value) { return (isCollection(value) && !isAssociative(value) ? value - : IndexedSeq(value)).toSetSeq(); + : IndexedSeq(value) + ).toSetSeq(); } if ( Seq ) SetSeq.__proto__ = Seq; @@ -639,8 +647,8 @@ function keyedSeqFromValue(value) { var seq = Array.isArray(value) ? new ArraySeq(value) : isIterator(value) - ? new IteratorSeq(value) - : hasIterator(value) ? new CollectionSeq(value) : undefined; + ? new IteratorSeq(value) + : hasIterator(value) ? new CollectionSeq(value) : undefined; if (seq) { return seq.fromEntrySeq(); } @@ -680,8 +688,8 @@ function maybeIndexedSeqFromValue(value) { return isArrayLike(value) ? new ArraySeq(value) : isIterator(value) - ? new IteratorSeq(value) - : hasIterator(value) ? new CollectionSeq(value) : undefined; + ? new IteratorSeq(value) + : hasIterator(value) ? new CollectionSeq(value) : undefined; } /** @@ -746,7 +754,8 @@ function is(valueA, valueB) { return false; } if ( - typeof valueA.valueOf === 'function' && typeof valueB.valueOf === 'function' + typeof valueA.valueOf === 'function' && + typeof valueB.valueOf === 'function' ) { valueA = valueA.valueOf(); valueB = valueB.valueOf(); @@ -757,9 +766,11 @@ function is(valueA, valueB) { return false; } } - return !!(isValueObject(valueA) && + return !!( + isValueObject(valueA) && isValueObject(valueB) && - valueA.equals(valueB)); + valueA.equals(valueB) + ); } function fromJS(value, converter) { @@ -786,7 +797,8 @@ function fromJSWith(stack, converter, value, key, keyPath, parentValue) { var converted = converter.call( parentValue, key, - toSeq(value).map(function (v, k) { return fromJSWith(stack, converter, v, k, keyPath, value); }), + toSeq(value).map(function (v, k) { return fromJSWith(stack, converter, v, k, keyPath, value); } + ), keyPath && keyPath.slice() ); stack.pop(); @@ -801,28 +813,29 @@ function defaultConverter(k, v) { } function isPlainObj(value) { - return value && - (value.constructor === Object || value.constructor === undefined); -} - -var imul = typeof Math.imul === 'function' && - Math.imul(0xffffffff, 2) === -2 - ? Math.imul - : function imul(a, b) { - a |= 0; // int - b |= 0; // int - var c = a & 0xffff; - var d = b & 0xffff; - // Shift by 0 fixes the sign on the high part. - return c * d + ((a >>> 16) * d + c * (b >>> 16) << 16 >>> 0) | 0; // int - }; + return ( + value && (value.constructor === Object || value.constructor === undefined) + ); +} + +var imul = + typeof Math.imul === 'function' && Math.imul(0xffffffff, 2) === -2 + ? Math.imul + : function imul(a, b) { + a |= 0; // int + b |= 0; // int + var c = a & 0xffff; + var d = b & 0xffff; + // Shift by 0 fixes the sign on the high part. + return (c * d + ((((a >>> 16) * d + c * (b >>> 16)) << 16) >>> 0)) | 0; // int + }; // v8 has an optimization for storing 31-bit signed numbers. // Values which have either 00 or 11 as the high order bits qualify. // This function drops the highest order bit in a signed number, maintaining // the sign bit. function smi(i32) { - return i32 >>> 1 & 0x40000000 | i32 & 0xbfffffff; + return ((i32 >>> 1) & 0x40000000) | (i32 & 0xbfffffff); } function hash(o) { @@ -895,7 +908,7 @@ function hashString(string) { // (exclusive) by dropping high bits. var hashed = 0; for (var ii = 0; ii < string.length; ii++) { - hashed = 31 * hash + string.charCodeAt(ii) | 0; + hashed = (31 * hash + string.charCodeAt(ii)) | 0; } return smi(hashed); } @@ -1169,22 +1182,19 @@ var FromEntriesSequence = (function (KeyedSeq$$1) { FromEntriesSequence.prototype.__iterate = function __iterate (fn, reverse) { var this$1 = this; - return this._iter.__iterate( - function (entry) { - // Check if entry exists first so array access doesn't throw for holes - // in the parent iteration. - if (entry) { - validateEntry(entry); - var indexedCollection = isCollection(entry); - return fn( - indexedCollection ? entry.get(1) : entry[1], - indexedCollection ? entry.get(0) : entry[0], - this$1 - ); - } - }, - reverse - ); + return this._iter.__iterate(function (entry) { + // Check if entry exists first so array access doesn't throw for holes + // in the parent iteration. + if (entry) { + validateEntry(entry); + var indexedCollection = isCollection(entry); + return fn( + indexedCollection ? entry.get(1) : entry[1], + indexedCollection ? entry.get(0) : entry[0], + this$1 + ); + } + }, reverse); }; FromEntriesSequence.prototype.__iterator = function __iterator (type, reverse) { @@ -1215,7 +1225,7 @@ var FromEntriesSequence = (function (KeyedSeq$$1) { return FromEntriesSequence; }(KeyedSeq)); -ToIndexedSequence.prototype.cacheResult = (ToKeyedSequence.prototype.cacheResult = (ToSetSequence.prototype.cacheResult = (FromEntriesSequence.prototype.cacheResult = cacheResultThrough))); +ToIndexedSequence.prototype.cacheResult = ToKeyedSequence.prototype.cacheResult = ToSetSequence.prototype.cacheResult = FromEntriesSequence.prototype.cacheResult = cacheResultThrough; function flipFactory(collection) { var flipSequence = makeSequence(collection); @@ -1361,15 +1371,12 @@ function filterFactory(collection, predicate, context, useKeys) { var this$1 = this; var iterations = 0; - collection.__iterate( - function (v, k, c) { - if (predicate.call(context, v, k, c)) { - iterations++; - return fn(v, useKeys ? k : iterations - 1, this$1); - } - }, - reverse - ); + collection.__iterate(function (v, k, c) { + if (predicate.call(context, v, k, c)) { + iterations++; + return fn(v, useKeys ? k : iterations - 1, this$1); + } + }, reverse); return iterations; }; filterSequence.__iteratorUncached = function(type, reverse) { @@ -1445,9 +1452,8 @@ function sliceFactory(collection, begin, end, useKeys) { // If collection.size is undefined, the size of the realized sliceSeq is // unknown at this point unless the number of items to slice is 0 - sliceSeq.size = sliceSize === 0 - ? sliceSize - : (collection.size && sliceSize) || undefined; + sliceSeq.size = + sliceSize === 0 ? sliceSize : (collection.size && sliceSize) || undefined; if (!useKeys && isSeq(collection) && sliceSize >= 0) { sliceSeq.get = function(index, notSetValue) { @@ -1473,8 +1479,10 @@ function sliceFactory(collection, begin, end, useKeys) { collection.__iterate(function (v, k) { if (!(isSkipping && (isSkipping = skipped++ < resolvedBegin))) { iterations++; - return fn(v, useKeys ? k : iterations - 1, this$1) !== false && - iterations !== sliceSize; + return ( + fn(v, useKeys ? k : iterations - 1, this$1) !== false && + iterations !== sliceSize + ); } }); return iterations; @@ -1646,17 +1654,14 @@ function concatFactory(collection, values) { concatSeq = concatSeq.toSetSeq(); } concatSeq = concatSeq.flatten(true); - concatSeq.size = iters.reduce( - function (sum, seq) { - if (sum !== undefined) { - var size = seq.size; - if (size !== undefined) { - return sum + size; - } + concatSeq.size = iters.reduce(function (sum, seq) { + if (sum !== undefined) { + var size = seq.size; + if (size !== undefined) { + return sum + size; } - }, - 0 - ); + } + }, 0); return concatSeq; } @@ -1669,20 +1674,17 @@ function flattenFactory(collection, depth, useKeys) { var iterations = 0; var stopped = false; function flatDeep(iter, currentDepth) { - iter.__iterate( - function (v, k) { - if ((!depth || currentDepth < depth) && isCollection(v)) { - flatDeep(v, currentDepth + 1); - } else { - iterations++; - if (fn(v, useKeys ? k : iterations - 1, flatSequence) === false) { - stopped = true; - } + iter.__iterate(function (v, k) { + if ((!depth || currentDepth < depth) && isCollection(v)) { + flatDeep(v, currentDepth + 1); + } else { + iterations++; + if (fn(v, useKeys ? k : iterations - 1, flatSequence) === false) { + stopped = true; } - return !stopped; - }, - reverse - ); + } + return !stopped; + }, reverse); } flatDeep(collection, 0); return iterations; @@ -1791,20 +1793,20 @@ function maxFactory(collection, comparator, mapper) { var entry = collection .toSeq() .map(function (v, k) { return [v, mapper(v, k, collection)]; }) - .reduce(function (a, b) { return maxCompare(comparator, a[1], b[1]) ? b : a; }); + .reduce(function (a, b) { return (maxCompare(comparator, a[1], b[1]) ? b : a); }); return entry && entry[0]; } - return collection.reduce(function (a, b) { return maxCompare(comparator, a, b) ? b : a; }); + return collection.reduce(function (a, b) { return (maxCompare(comparator, a, b) ? b : a); }); } function maxCompare(comparator, a, b) { var comp = comparator(b, a); // b is considered the new max if the comparator declares them equal, but // they are not equal and b is in fact a nullish value. - return (comp === 0 && - b !== a && - (b === undefined || b === null || b !== b)) || - comp > 0; + return ( + (comp === 0 && b !== a && (b === undefined || b === null || b !== b)) || + comp > 0 + ); } function zipWithFactory(keyIter, zipper, iters, zipAll) { @@ -1886,7 +1888,8 @@ function makeSequence(collection) { return Object.create( (isKeyed(collection) ? KeyedSeq - : isIndexed(collection) ? IndexedSeq : SetSeq).prototype + : isIndexed(collection) ? IndexedSeq : SetSeq + ).prototype ); } @@ -1950,12 +1953,12 @@ var Map = (function (KeyedCollection$$1) { return value === null || value === undefined ? emptyMap() : isMap(value) && !isOrdered(value) - ? value - : emptyMap().withMutations(function (map) { - var iter = KeyedCollection$$1(value); - assertNotInfinite(iter.size); - iter.forEach(function (v, k) { return map.set(k, v); }); - }); + ? value + : emptyMap().withMutations(function (map) { + var iter = KeyedCollection$$1(value); + assertNotInfinite(iter.size); + iter.forEach(function (v, k) { return map.set(k, v); }); + }); } if ( KeyedCollection$$1 ) Map.__proto__ = KeyedCollection$$1; @@ -2146,13 +2149,10 @@ var Map = (function (KeyedCollection$$1) { var iterations = 0; this._root && - this._root.iterate( - function (entry) { - iterations++; - return fn(entry[1], entry[0], this$1); - }, - reverse - ); + this._root.iterate(function (entry) { + iterations++; + return fn(entry[1], entry[0], this$1); + }, reverse); return iterations; }; @@ -2277,7 +2277,7 @@ BitmapIndexedNode.prototype.get = function get (shift, keyHash, key, notSetValue var bitmap = this.bitmap; return (bitmap & bit) === 0 ? notSetValue - : this.nodes[popCount(bitmap & bit - 1)].get( + : this.nodes[popCount(bitmap & (bit - 1))].get( shift + SHIFT, keyHash, key, @@ -2298,7 +2298,7 @@ BitmapIndexedNode.prototype.update = function update (ownerID, shift, keyHash, k return this; } - var idx = popCount(bitmap & bit - 1); + var idx = popCount(bitmap & (bit - 1)); var nodes = this.nodes; var node = exists ? nodes[idx] : undefined; var newNode = updateNode( @@ -2321,7 +2321,10 @@ BitmapIndexedNode.prototype.update = function update (ownerID, shift, keyHash, k } if ( - exists && !newNode && nodes.length === 2 && isLeafNode(nodes[idx ^ 1]) + exists && + !newNode && + nodes.length === 2 && + isLeafNode(nodes[idx ^ 1]) ) { return nodes[idx ^ 1]; } @@ -2331,11 +2334,11 @@ BitmapIndexedNode.prototype.update = function update (ownerID, shift, keyHash, k } var isEditable = ownerID && ownerID === this.ownerID; - var newBitmap = exists ? newNode ? bitmap : bitmap ^ bit : bitmap | bit; + var newBitmap = exists ? (newNode ? bitmap : bitmap ^ bit) : bitmap | bit; var newNodes = exists ? newNode - ? setIn(nodes, idx, newNode, isEditable) - : spliceOut(nodes, idx, isEditable) + ? setIn(nodes, idx, newNode, isEditable) + : spliceOut(nodes, idx, isEditable) : spliceIn(nodes, idx, newNode, isEditable); if (isEditable) { @@ -2527,7 +2530,7 @@ ValueNode.prototype.update = function update (ownerID, shift, keyHash, key, valu // #pragma Iterators -ArrayMapNode.prototype.iterate = (HashCollisionNode.prototype.iterate = function( +ArrayMapNode.prototype.iterate = HashCollisionNode.prototype.iterate = function( fn, reverse ) { @@ -2537,9 +2540,9 @@ ArrayMapNode.prototype.iterate = (HashCollisionNode.prototype.iterate = function return false; } } -}); +}; -BitmapIndexedNode.prototype.iterate = (HashArrayMapNode.prototype.iterate = function( +BitmapIndexedNode.prototype.iterate = HashArrayMapNode.prototype.iterate = function( fn, reverse ) { @@ -2550,7 +2553,7 @@ BitmapIndexedNode.prototype.iterate = (HashArrayMapNode.prototype.iterate = func return false; } } -}); +}; // eslint-disable-next-line no-unused-vars ValueNode.prototype.iterate = function(fn, reverse) { @@ -2597,12 +2600,12 @@ var MapIterator = (function (Iterator$$1) { if (subNode.entry) { return mapIteratorValue(type, subNode.entry); } - stack = (this$1._stack = mapIteratorFrame(subNode, stack)); + stack = this$1._stack = mapIteratorFrame(subNode, stack); } continue; } } - stack = (this$1._stack = this$1._stack.__prev); + stack = this$1._stack = this$1._stack.__prev; } return iteratorDone(); }; @@ -2662,7 +2665,7 @@ function updateMap(map, k, v) { if (!didAlter.value) { return map; } - newSize = map.size + (didChangeSize.value ? v === NOT_SET ? -1 : 1 : 0); + newSize = map.size + (didChangeSize.value ? (v === NOT_SET ? -1 : 1) : 0); } if (map.__ownerID) { map.size = newSize; @@ -2704,8 +2707,9 @@ function updateNode( } function isLeafNode(node) { - return node.constructor === ValueNode || - node.constructor === HashCollisionNode; + return ( + node.constructor === ValueNode || node.constructor === HashCollisionNode + ); } function mergeIntoNode(node, ownerID, shift, keyHash, entry) { @@ -2717,13 +2721,13 @@ function mergeIntoNode(node, ownerID, shift, keyHash, entry) { var idx2 = (shift === 0 ? keyHash : keyHash >>> shift) & MASK; var newNode; - var nodes = idx1 === idx2 - ? [mergeIntoNode(node, ownerID, shift + SHIFT, keyHash, entry)] - : ((newNode = new ValueNode(ownerID, keyHash, entry)), idx1 < idx2 - ? [node, newNode] - : [newNode, node]); + var nodes = + idx1 === idx2 + ? [mergeIntoNode(node, ownerID, shift + SHIFT, keyHash, entry)] + : ((newNode = new ValueNode(ownerID, keyHash, entry)), + idx1 < idx2 ? [node, newNode] : [newNode, node]); - return new BitmapIndexedNode(ownerID, 1 << idx1 | 1 << idx2, nodes); + return new BitmapIndexedNode(ownerID, (1 << idx1) | (1 << idx2), nodes); } function createNodes(ownerID, entries, key, value) { @@ -2742,7 +2746,7 @@ function packNodes(ownerID, nodes, count, excluding) { var bitmap = 0; var packedII = 0; var packedNodes = new Array(count); - for (var ii = 0, bit = 1, len = nodes.length; ii < len; ii++, (bit <<= 1)) { + for (var ii = 0, bit = 1, len = nodes.length; ii < len; ii++, bit <<= 1) { var node = nodes[ii]; if (node !== undefined && ii !== excluding) { bitmap |= bit; @@ -2755,7 +2759,7 @@ function packNodes(ownerID, nodes, count, excluding) { function expandNodes(ownerID, nodes, bitmap, including, node) { var count = 0; var expandedNodes = new Array(SIZE); - for (var ii = 0; bitmap !== 0; ii++, (bitmap >>>= 1)) { + for (var ii = 0; bitmap !== 0; ii++, bitmap >>>= 1) { expandedNodes[ii] = bitmap & 1 ? nodes[count++] : undefined; } expandedNodes[including] = node; @@ -2805,7 +2809,7 @@ function mergeIntoCollectionWith(collection, merger, iters) { collection.update( key, NOT_SET, - function (oldVal) { return oldVal === NOT_SET ? value : merger(oldVal, value, key); } + function (oldVal) { return (oldVal === NOT_SET ? value : merger(oldVal, value, key)); } ); } : function (value, key) { @@ -2844,14 +2848,14 @@ function updateInDeepMap(existing, keyPath, i, notSetValue, updater) { return nextUpdated === nextExisting ? existing : nextUpdated === NOT_SET - ? existing.remove(key) - : (isNotSet ? emptyMap() : existing).set(key, nextUpdated); + ? existing.remove(key) + : (isNotSet ? emptyMap() : existing).set(key, nextUpdated); } function popCount(x) { - x -= x >> 1 & 0x55555555; - x = (x & 0x33333333) + (x >> 2 & 0x33333333); - x = x + (x >> 4) & 0x0f0f0f0f; + x -= (x >> 1) & 0x55555555; + x = (x & 0x33333333) + ((x >> 2) & 0x33333333); + x = (x + (x >> 4)) & 0x0f0f0f0f; x += x >> 8; x += x >> 16; return x & 0x7f; @@ -2961,8 +2965,8 @@ var List = (function (IndexedCollection$$1) { return !this.has(index) ? this : index === 0 - ? this.shift() - : index === this.size - 1 ? this.pop() : this.splice(index, 1); + ? this.shift() + : index === this.size - 1 ? this.pop() : this.splice(index, 1); }; List.prototype.insert = function insert (index, value) { @@ -2974,9 +2978,9 @@ var List = (function (IndexedCollection$$1) { return this; } if (this.__ownerID) { - this.size = (this._origin = (this._capacity = 0)); + this.size = this._origin = this._capacity = 0; this._level = SHIFT; - this._root = (this._tail = null); + this._root = this._tail = null; this.__hash = undefined; this.__altered = true; return this; @@ -3117,7 +3121,7 @@ var ListPrototype = List.prototype; ListPrototype[IS_LIST_SENTINEL] = true; ListPrototype[DELETE] = ListPrototype.remove; ListPrototype.setIn = MapPrototype.setIn; -ListPrototype.deleteIn = (ListPrototype.removeIn = MapPrototype.removeIn); +ListPrototype.deleteIn = ListPrototype.removeIn = MapPrototype.removeIn; ListPrototype.update = MapPrototype.update; ListPrototype.updateIn = MapPrototype.updateIn; ListPrototype.mergeIn = MapPrototype.mergeIn; @@ -3143,7 +3147,7 @@ VNode.prototype.removeBefore = function removeBefore (ownerID, level, index) { if (index === level ? 1 << level : 0 || this.array.length === 0) { return this; } - var originIndex = index >>> level & MASK; + var originIndex = (index >>> level) & MASK; if (originIndex >= this.array.length) { return new VNode([], ownerID); } @@ -3151,8 +3155,8 @@ VNode.prototype.removeBefore = function removeBefore (ownerID, level, index) { var newChild; if (level > 0) { var oldChild = this.array[originIndex]; - newChild = oldChild && - oldChild.removeBefore(ownerID, level - SHIFT, index); + newChild = + oldChild && oldChild.removeBefore(ownerID, level - SHIFT, index); if (newChild === oldChild && removingFirst) { return this; } @@ -3176,7 +3180,7 @@ VNode.prototype.removeAfter = function removeAfter (ownerID, level, index) { if (index === (level ? 1 << level : 0) || this.array.length === 0) { return this; } - var sizeIndex = index - 1 >>> level & MASK; + var sizeIndex = ((index - 1) >>> level) & MASK; if (sizeIndex >= this.array.length) { return this; } @@ -3184,8 +3188,8 @@ VNode.prototype.removeAfter = function removeAfter (ownerID, level, index) { var newChild; if (level > 0) { var oldChild = this.array[sizeIndex]; - newChild = oldChild && - oldChild.removeAfter(ownerID, level - SHIFT, index); + newChild = + oldChild && oldChild.removeAfter(ownerID, level - SHIFT, index); if (newChild === oldChild && sizeIndex === this.array.length - 1) { return this; } @@ -3234,8 +3238,8 @@ function iterateList(list, reverse) { function iterateNode(node, level, offset) { var values; var array = node && node.array; - var from = offset > left ? 0 : left - offset >> level; - var to = (right - offset >> level) + 1; + var from = offset > left ? 0 : (left - offset) >> level; + var to = ((right - offset) >> level) + 1; if (to > SIZE) { to = SIZE; } @@ -3329,7 +3333,7 @@ function updateList(list, index, value) { } function updateVNode(node, ownerID, level, index, value, didAlter) { - var idx = index >>> level & MASK; + var idx = (index >>> level) & MASK; var nodeHas = node && idx < node.array.length; if (!nodeHas && value === undefined) { return node; @@ -3381,11 +3385,11 @@ function listNodeFor(list, rawIndex) { if (rawIndex >= getTailOffset(list._capacity)) { return list._tail; } - if (rawIndex < 1 << list._level + SHIFT) { + if (rawIndex < 1 << (list._level + SHIFT)) { var node = list._root; var level = list._level; while (node && level > 0) { - node = node.array[rawIndex >>> level & MASK]; + node = node.array[(rawIndex >>> level) & MASK]; level -= SHIFT; } return node; @@ -3405,9 +3409,10 @@ function setListBounds(list, begin, end) { var oldOrigin = list._origin; var oldCapacity = list._capacity; var newOrigin = oldOrigin + begin; - var newCapacity = end === undefined - ? oldCapacity - : end < 0 ? oldCapacity + end : oldOrigin + end; + var newCapacity = + end === undefined + ? oldCapacity + : end < 0 ? oldCapacity + end : oldOrigin + end; if (newOrigin === oldOrigin && newCapacity === oldCapacity) { return list; } @@ -3441,7 +3446,7 @@ function setListBounds(list, begin, end) { var newTailOffset = getTailOffset(newCapacity); // New size might need creating a higher root. - while (newTailOffset >= 1 << newLevel + SHIFT) { + while (newTailOffset >= 1 << (newLevel + SHIFT)) { newRoot = new VNode( newRoot && newRoot.array.length ? [newRoot] : [], owner @@ -3451,9 +3456,10 @@ function setListBounds(list, begin, end) { // Locate or create the new tail. var oldTail = list._tail; - var newTail = newTailOffset < oldTailOffset - ? listNodeFor(list, newCapacity - 1) - : newTailOffset > oldTailOffset ? new VNode([], owner) : oldTail; + var newTail = + newTailOffset < oldTailOffset + ? listNodeFor(list, newCapacity - 1) + : newTailOffset > oldTailOffset ? new VNode([], owner) : oldTail; // Merge Tail into tree. if ( @@ -3465,10 +3471,10 @@ function setListBounds(list, begin, end) { newRoot = editableVNode(newRoot, owner); var node = newRoot; for (var level = newLevel; level > SHIFT; level -= SHIFT) { - var idx = oldTailOffset >>> level & MASK; - node = (node.array[idx] = editableVNode(node.array[idx], owner)); + var idx = (oldTailOffset >>> level) & MASK; + node = node.array[idx] = editableVNode(node.array[idx], owner); } - node.array[oldTailOffset >>> SHIFT & MASK] = oldTail; + node.array[(oldTailOffset >>> SHIFT) & MASK] = oldTail; } // If the size has been reduced, there's a chance the tail needs to be trimmed. @@ -3490,8 +3496,8 @@ function setListBounds(list, begin, end) { // Identify the new top root node of the subtree of the old root. while (newRoot) { - var beginIndex = newOrigin >>> newLevel & MASK; - if (beginIndex !== newTailOffset >>> newLevel & MASK) { + var beginIndex = (newOrigin >>> newLevel) & MASK; + if ((beginIndex !== newTailOffset >>> newLevel) & MASK) { break; } if (beginIndex) { @@ -3553,7 +3559,7 @@ function mergeIntoListWith(list, merger, collections) { } function getTailOffset(size) { - return size < SIZE ? 0 : size - 1 >>> SHIFT << SHIFT; + return size < SIZE ? 0 : ((size - 1) >>> SHIFT) << SHIFT; } var OrderedMap = (function (Map$$1) { @@ -3561,12 +3567,12 @@ var OrderedMap = (function (Map$$1) { return value === null || value === undefined ? emptyOrderedMap() : isOrderedMap(value) - ? value - : emptyOrderedMap().withMutations(function (map) { - var iter = KeyedCollection(value); - assertNotInfinite(iter.size); - iter.forEach(function (v, k) { return map.set(k, v); }); - }); + ? value + : emptyOrderedMap().withMutations(function (map) { + var iter = KeyedCollection(value); + assertNotInfinite(iter.size); + iter.forEach(function (v, k) { return map.set(k, v); }); + }); } if ( Map$$1 ) OrderedMap.__proto__ = Map$$1; @@ -3670,8 +3676,10 @@ function makeOrderedMap(map, list, ownerID, hash) { var EMPTY_ORDERED_MAP; function emptyOrderedMap() { - return EMPTY_ORDERED_MAP || - (EMPTY_ORDERED_MAP = makeOrderedMap(emptyMap(), emptyList())); + return ( + EMPTY_ORDERED_MAP || + (EMPTY_ORDERED_MAP = makeOrderedMap(emptyMap(), emptyList())) + ); } function updateOrderedMap(omap, k, v) { @@ -3688,9 +3696,13 @@ function updateOrderedMap(omap, k, v) { } if (list.size >= SIZE && list.size >= map.size * 2) { newList = list.filter(function (entry, idx) { return entry !== undefined && i !== idx; }); - newMap = newList.toKeyedSeq().map(function (entry) { return entry[0]; }).flip().toMap(); + newMap = newList + .toKeyedSeq() + .map(function (entry) { return entry[0]; }) + .flip() + .toMap(); if (omap.__ownerID) { - newMap.__ownerID = (newList.__ownerID = omap.__ownerID); + newMap.__ownerID = newList.__ownerID = omap.__ownerID; } } else { newMap = map.remove(k); @@ -3787,16 +3799,13 @@ var Stack = (function (IndexedCollection$$1) { assertNotInfinite(iter.size); var newSize = this.size; var head = this._head; - iter.__iterate( - function (value) { - newSize++; - head = { - value: value, - next: head - }; - }, - /* reverse */ true - ); + iter.__iterate(function (value) { + newSize++; + head = { + value: value, + next: head + }; + }, /* reverse */ true); if (this.__ownerID) { this.size = newSize; this._head = head; @@ -3972,10 +3981,12 @@ function deepEqual(a, b) { if (isOrdered(a)) { var entries = a.entries(); - return b.every(function (v, k) { - var entry = entries.next().value; - return entry && is(entry[1], v) && (notAssociative || is(entry[0], k)); - }) && entries.next().done; + return ( + b.every(function (v, k) { + var entry = entries.next().value; + return entry && is(entry[1], v) && (notAssociative || is(entry[0], k)); + }) && entries.next().done + ); } var flipped = false; @@ -4026,12 +4037,12 @@ var Set = (function (SetCollection$$1) { return value === null || value === undefined ? emptySet() : isSet(value) && !isOrdered(value) - ? value - : emptySet().withMutations(function (set) { - var iter = SetCollection$$1(value); - assertNotInfinite(iter.size); - iter.forEach(function (v) { return set.add(v); }); - }); + ? value + : emptySet().withMutations(function (set) { + var iter = SetCollection$$1(value); + assertNotInfinite(iter.size); + iter.forEach(function (v) { return set.add(v); }); + }); } if ( SetCollection$$1 ) Set.__proto__ = SetCollection$$1; @@ -4287,12 +4298,14 @@ var Range = (function (IndexedSeq$$1) { if (this.size === 0) { return 'Range []'; } - return 'Range [ ' + + return ( + 'Range [ ' + this._start + '...' + this._end + (this._step !== 1 ? ' by ' + this._step : '') + - ' ]'; + ' ]' + ); }; Range.prototype.get = function get (index, notSetValue) { @@ -4303,9 +4316,11 @@ var Range = (function (IndexedSeq$$1) { Range.prototype.includes = function includes (searchValue) { var possibleIndex = (searchValue - this._start) / this._step; - return possibleIndex >= 0 && + return ( + possibleIndex >= 0 && possibleIndex < this.size && - possibleIndex === Math.floor(possibleIndex); + possibleIndex === Math.floor(possibleIndex) + ); }; Range.prototype.slice = function slice (begin, end) { @@ -4409,7 +4424,9 @@ mixin(Collection, { }, toJS: function toJS$1() { - return this.toSeq().map(toJS).toJSON(); + return this.toSeq() + .map(toJS) + .toJSON(); }, toKeyedSeq: function toKeyedSeq() { @@ -4475,11 +4492,15 @@ mixin(Collection, { if (this.size === 0) { return head + tail; } - return head + + return ( + head + ' ' + - this.toSeq().map(this.__toStringMapper).join(', ') + + this.toSeq() + .map(this.__toStringMapper) + .join(', ') + ' ' + - tail; + tail + ); }, // ### ES6 Collection methods (ES6 Array and Map) @@ -4617,7 +4638,10 @@ mixin(Collection, { // We cache as an entries array, so we can just return the cache! return new ArraySeq(collection._cache); } - var entriesSequence = collection.toSeq().map(entryMapper).toIndexedSeq(); + var entriesSequence = collection + .toSeq() + .map(entryMapper) + .toIndexedSeq(); entriesSequence.fromEntrySeq = function () { return collection.toSeq(); }; // Entries are plain Array, which do not define toJS, so it must @@ -4650,7 +4674,9 @@ mixin(Collection, { }, findLast: function findLast(predicate, context, notSetValue) { - return this.toKeyedSeq().reverse().find(predicate, context, notSetValue); + return this.toKeyedSeq() + .reverse() + .find(predicate, context, notSetValue); }, findLastEntry: function findLastEntry(predicate, context, notSetValue) { @@ -4660,7 +4686,9 @@ mixin(Collection, { }, findLastKey: function findLastKey(predicate, context) { - return this.toKeyedSeq().reverse().findKey(predicate, context); + return this.toKeyedSeq() + .reverse() + .findKey(predicate, context); }, first: function first() { @@ -4733,15 +4761,21 @@ mixin(Collection, { }, keySeq: function keySeq() { - return this.toSeq().map(keyMapper).toIndexedSeq(); + return this.toSeq() + .map(keyMapper) + .toIndexedSeq(); }, last: function last() { - return this.toSeq().reverse().first(); + return this.toSeq() + .reverse() + .first(); }, lastKeyOf: function lastKeyOf(searchValue) { - return this.toKeyedSeq().reverse().keyOf(searchValue); + return this.toKeyedSeq() + .reverse() + .keyOf(searchValue); }, max: function max(comparator) { @@ -4833,9 +4867,9 @@ CollectionPrototype[IS_ITERABLE_SENTINEL] = true; CollectionPrototype[ITERATOR_SYMBOL] = CollectionPrototype.values; CollectionPrototype.toJSON = CollectionPrototype.toArray; CollectionPrototype.__toStringMapper = quoteString; -CollectionPrototype.inspect = (CollectionPrototype.toSource = function() { +CollectionPrototype.inspect = CollectionPrototype.toSource = function() { return this.toString(); -}); +}; CollectionPrototype.chain = CollectionPrototype.flatMap; CollectionPrototype.contains = CollectionPrototype.includes; @@ -4863,7 +4897,10 @@ mixin(KeyedCollection, { return reify( this, - this.toSeq().flip().map(function (k, v) { return mapper.call(context, k, v, this$1); }).flip() + this.toSeq() + .flip() + .map(function (k, v) { return mapper.call(context, k, v, this$1); }) + .flip() ); } }); @@ -4954,10 +4991,12 @@ mixin(IndexedCollection, { has: function has(index) { index = wrapIndex(this, index); - return index >= 0 && + return ( + index >= 0 && (this.size !== undefined ? this.size === Infinity || index < this.size - : this.indexOf(index) !== -1); + : this.indexOf(index) !== -1) + ); }, interpose: function interpose(separator) { @@ -5038,17 +5077,14 @@ mixin(SetSeq, SetCollection.prototype); function reduce(collection, reducer, reduction, context, useFirst, reverse) { assertNotInfinite(collection.size); - collection.__iterate( - function (v, k, c) { - if (useFirst) { - useFirst = false; - reduction = v; - } else { - reduction = reducer.call(context, reduction, v, k, c); - } - }, - reverse - ); + collection.__iterate(function (v, k, c) { + if (useFirst) { + useFirst = false; + reduction = v; + } else { + reduction = reducer.call(context, reduction, v, k, c); + } + }, reverse); return reduction; } @@ -5094,36 +5130,36 @@ function hashCollection(collection) { var size = collection.__iterate( keyed ? ordered - ? function (v, k) { - h = 31 * h + hashMerge(hash(v), hash(k)) | 0; - } - : function (v, k) { - h = h + hashMerge(hash(v), hash(k)) | 0; - } + ? function (v, k) { + h = (31 * h + hashMerge(hash(v), hash(k))) | 0; + } + : function (v, k) { + h = (h + hashMerge(hash(v), hash(k))) | 0; + } : ordered - ? function (v) { - h = 31 * h + hash(v) | 0; - } - : function (v) { - h = h + hash(v) | 0; - } + ? function (v) { + h = (31 * h + hash(v)) | 0; + } + : function (v) { + h = (h + hash(v)) | 0; + } ); return murmurHashOfSize(size, h); } function murmurHashOfSize(size, h) { h = imul(h, 0xcc9e2d51); - h = imul(h << 15 | h >>> -15, 0x1b873593); - h = imul(h << 13 | h >>> -13, 5); - h = (h + 0xe6546b64 | 0) ^ size; - h = imul(h ^ h >>> 16, 0x85ebca6b); - h = imul(h ^ h >>> 13, 0xc2b2ae35); - h = smi(h ^ h >>> 16); + h = imul((h << 15) | (h >>> -15), 0x1b873593); + h = imul((h << 13) | (h >>> -13), 5); + h = ((h + 0xe6546b64) | 0) ^ size; + h = imul(h ^ (h >>> 16), 0x85ebca6b); + h = imul(h ^ (h >>> 13), 0xc2b2ae35); + h = smi(h ^ (h >>> 16)); return h; } function hashMerge(a, b) { - return a ^ b + 0x9e3779b9 + (a << 6) + (a >> 2) | 0; // int + return (a ^ (b + 0x9e3779b9 + (a << 6) + (a >> 2))) | 0; // int } function warn(message) { @@ -5141,12 +5177,12 @@ var OrderedSet = (function (Set$$1) { return value === null || value === undefined ? emptyOrderedSet() : isOrderedSet(value) - ? value - : emptyOrderedSet().withMutations(function (set) { - var iter = SetCollection(value); - assertNotInfinite(iter.size); - iter.forEach(function (v) { return set.add(v); }); - }); + ? value + : emptyOrderedSet().withMutations(function (set) { + var iter = SetCollection(value); + assertNotInfinite(iter.size); + iter.forEach(function (v) { return set.add(v); }); + }); } if ( Set$$1 ) OrderedSet.__proto__ = Set$$1; @@ -5192,8 +5228,9 @@ function makeOrderedSet(map, ownerID) { var EMPTY_ORDERED_SET; function emptyOrderedSet() { - return EMPTY_ORDERED_SET || - (EMPTY_ORDERED_SET = makeOrderedSet(emptyOrderedMap())); + return ( + EMPTY_ORDERED_SET || (EMPTY_ORDERED_SET = makeOrderedSet(emptyOrderedMap())) + ); } var Record = function Record(defaultValues, name) { @@ -5266,10 +5303,12 @@ Record.prototype.toString = function toString () { }; Record.prototype.equals = function equals (other) { - return this === other || + return ( + this === other || (other && this._keys === other._keys && - recordSeq(this).equals(recordSeq(other))); + recordSeq(this).equals(recordSeq(other))) + ); }; Record.prototype.hashCode = function hashCode () { @@ -5353,7 +5392,7 @@ Record.getDescriptiveName = recordName; var RecordPrototype = Record.prototype; RecordPrototype[IS_RECORD_SENTINEL] = true; RecordPrototype[DELETE] = RecordPrototype.remove; -RecordPrototype.deleteIn = (RecordPrototype.removeIn = MapPrototype.removeIn); +RecordPrototype.deleteIn = RecordPrototype.removeIn = MapPrototype.removeIn; RecordPrototype.getIn = CollectionPrototype.getIn; RecordPrototype.hasIn = CollectionPrototype.hasIn; RecordPrototype.merge = MapPrototype.merge; @@ -5369,8 +5408,10 @@ RecordPrototype.withMutations = MapPrototype.withMutations; RecordPrototype.asMutable = MapPrototype.asMutable; RecordPrototype.asImmutable = MapPrototype.asImmutable; RecordPrototype[ITERATOR_SYMBOL] = CollectionPrototype.entries; -RecordPrototype.toJSON = (RecordPrototype.toObject = CollectionPrototype.toObject); -RecordPrototype.inspect = (RecordPrototype.toSource = CollectionPrototype.toSource); +RecordPrototype.toJSON = RecordPrototype.toObject = + CollectionPrototype.toObject; +RecordPrototype.inspect = RecordPrototype.toSource = + CollectionPrototype.toSource; function makeRecord(likeRecord, values, ownerID) { var record = Object.create(Object.getPrototypeOf(likeRecord)); diff --git a/dist/immutable.js b/dist/immutable.js index 9835f14887..39555e4239 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -84,9 +84,11 @@ function returnTrue() { } function wholeSlice(begin, end, size) { - return ((begin === 0 && !isNeg(begin)) || - (size !== undefined && begin <= -size)) && - (end === undefined || (size !== undefined && end >= size)); + return ( + ((begin === 0 && !isNeg(begin)) || + (size !== undefined && begin <= -size)) && + (end === undefined || (size !== undefined && end >= size)) + ); } function resolveBegin(begin, size) { @@ -103,10 +105,10 @@ function resolveIndex(index, size, defaultIndex) { return index === undefined ? defaultIndex : isNeg(index) - ? size === Infinity ? size : Math.max(0, size + index) | 0 - : size === undefined || size === index - ? index - : Math.min(size, index) | 0; + ? size === Infinity ? size : Math.max(0, size + index) | 0 + : size === undefined || size === index + ? index + : Math.min(size, index) | 0; } function isNeg(value) { @@ -115,8 +117,10 @@ function isNeg(value) { } function isImmutable(maybeImmutable) { - return (isCollection(maybeImmutable) || isRecord(maybeImmutable)) && - !maybeImmutable.__ownerID; + return ( + (isCollection(maybeImmutable) || isRecord(maybeImmutable)) && + !maybeImmutable.__ownerID + ); } function isCollection(maybeCollection) { @@ -144,9 +148,11 @@ function isRecord(maybeRecord) { } function isValueObject(maybeValue) { - return !!(maybeValue && + return !!( + maybeValue && typeof maybeValue.equals === 'function' && - typeof maybeValue.hashCode === 'function'); + typeof maybeValue.hashCode === 'function' + ); } var IS_ITERABLE_SENTINEL = '@@__IMMUTABLE_ITERABLE__@@'; @@ -220,9 +226,9 @@ Iterator.KEYS = ITERATE_KEYS; Iterator.VALUES = ITERATE_VALUES; Iterator.ENTRIES = ITERATE_ENTRIES; -Iterator.prototype.inspect = (Iterator.prototype.toSource = function() { +Iterator.prototype.inspect = Iterator.prototype.toSource = function() { return this.toString(); -}); +}; Iterator.prototype[ITERATOR_SYMBOL] = function() { return this; }; @@ -256,7 +262,8 @@ function getIterator(iterable) { } function getIteratorFn(iterable) { - var iteratorFn = iterable && + var iteratorFn = + iterable && ((REAL_ITERATOR_SYMBOL && iterable[REAL_ITERATOR_SYMBOL]) || iterable[FAUX_ITERATOR_SYMBOL]); if (typeof iteratorFn === 'function') { @@ -273,8 +280,8 @@ var Seq = (function (Collection$$1) { return value === null || value === undefined ? emptySequence() : isCollection(value) || isRecord(value) - ? value.toSeq() - : seqFromValue(value); + ? value.toSeq() + : seqFromValue(value); } if ( Collection$$1 ) Seq.__proto__ = Collection$$1; @@ -343,8 +350,8 @@ var KeyedSeq = (function (Seq) { return value === null || value === undefined ? emptySequence().toKeyedSeq() : isCollection(value) - ? isKeyed(value) ? value.toSeq() : value.fromEntrySeq() - : isRecord(value) ? value.toSeq() : keyedSeqFromValue(value); + ? isKeyed(value) ? value.toSeq() : value.fromEntrySeq() + : isRecord(value) ? value.toSeq() : keyedSeqFromValue(value); } if ( Seq ) KeyedSeq.__proto__ = Seq; @@ -363,10 +370,10 @@ var IndexedSeq = (function (Seq) { return value === null || value === undefined ? emptySequence() : isCollection(value) - ? isKeyed(value) ? value.entrySeq() : value.toIndexedSeq() - : isRecord(value) - ? value.toSeq().entrySeq() - : indexedSeqFromValue(value); + ? isKeyed(value) ? value.entrySeq() : value.toIndexedSeq() + : isRecord(value) + ? value.toSeq().entrySeq() + : indexedSeqFromValue(value); } if ( Seq ) IndexedSeq.__proto__ = Seq; @@ -392,7 +399,8 @@ var SetSeq = (function (Seq) { function SetSeq(value) { return (isCollection(value) && !isAssociative(value) ? value - : IndexedSeq(value)).toSetSeq(); + : IndexedSeq(value) + ).toSetSeq(); } if ( Seq ) SetSeq.__proto__ = Seq; @@ -645,8 +653,8 @@ function keyedSeqFromValue(value) { var seq = Array.isArray(value) ? new ArraySeq(value) : isIterator(value) - ? new IteratorSeq(value) - : hasIterator(value) ? new CollectionSeq(value) : undefined; + ? new IteratorSeq(value) + : hasIterator(value) ? new CollectionSeq(value) : undefined; if (seq) { return seq.fromEntrySeq(); } @@ -686,8 +694,8 @@ function maybeIndexedSeqFromValue(value) { return isArrayLike(value) ? new ArraySeq(value) : isIterator(value) - ? new IteratorSeq(value) - : hasIterator(value) ? new CollectionSeq(value) : undefined; + ? new IteratorSeq(value) + : hasIterator(value) ? new CollectionSeq(value) : undefined; } /** @@ -752,7 +760,8 @@ function is(valueA, valueB) { return false; } if ( - typeof valueA.valueOf === 'function' && typeof valueB.valueOf === 'function' + typeof valueA.valueOf === 'function' && + typeof valueB.valueOf === 'function' ) { valueA = valueA.valueOf(); valueB = valueB.valueOf(); @@ -763,9 +772,11 @@ function is(valueA, valueB) { return false; } } - return !!(isValueObject(valueA) && + return !!( + isValueObject(valueA) && isValueObject(valueB) && - valueA.equals(valueB)); + valueA.equals(valueB) + ); } function fromJS(value, converter) { @@ -792,7 +803,8 @@ function fromJSWith(stack, converter, value, key, keyPath, parentValue) { var converted = converter.call( parentValue, key, - toSeq(value).map(function (v, k) { return fromJSWith(stack, converter, v, k, keyPath, value); }), + toSeq(value).map(function (v, k) { return fromJSWith(stack, converter, v, k, keyPath, value); } + ), keyPath && keyPath.slice() ); stack.pop(); @@ -807,28 +819,29 @@ function defaultConverter(k, v) { } function isPlainObj(value) { - return value && - (value.constructor === Object || value.constructor === undefined); -} - -var imul = typeof Math.imul === 'function' && - Math.imul(0xffffffff, 2) === -2 - ? Math.imul - : function imul(a, b) { - a |= 0; // int - b |= 0; // int - var c = a & 0xffff; - var d = b & 0xffff; - // Shift by 0 fixes the sign on the high part. - return c * d + ((a >>> 16) * d + c * (b >>> 16) << 16 >>> 0) | 0; // int - }; + return ( + value && (value.constructor === Object || value.constructor === undefined) + ); +} + +var imul = + typeof Math.imul === 'function' && Math.imul(0xffffffff, 2) === -2 + ? Math.imul + : function imul(a, b) { + a |= 0; // int + b |= 0; // int + var c = a & 0xffff; + var d = b & 0xffff; + // Shift by 0 fixes the sign on the high part. + return (c * d + ((((a >>> 16) * d + c * (b >>> 16)) << 16) >>> 0)) | 0; // int + }; // v8 has an optimization for storing 31-bit signed numbers. // Values which have either 00 or 11 as the high order bits qualify. // This function drops the highest order bit in a signed number, maintaining // the sign bit. function smi(i32) { - return i32 >>> 1 & 0x40000000 | i32 & 0xbfffffff; + return ((i32 >>> 1) & 0x40000000) | (i32 & 0xbfffffff); } function hash(o) { @@ -901,7 +914,7 @@ function hashString(string) { // (exclusive) by dropping high bits. var hashed = 0; for (var ii = 0; ii < string.length; ii++) { - hashed = 31 * hash + string.charCodeAt(ii) | 0; + hashed = (31 * hash + string.charCodeAt(ii)) | 0; } return smi(hashed); } @@ -1175,22 +1188,19 @@ var FromEntriesSequence = (function (KeyedSeq$$1) { FromEntriesSequence.prototype.__iterate = function __iterate (fn, reverse) { var this$1 = this; - return this._iter.__iterate( - function (entry) { - // Check if entry exists first so array access doesn't throw for holes - // in the parent iteration. - if (entry) { - validateEntry(entry); - var indexedCollection = isCollection(entry); - return fn( - indexedCollection ? entry.get(1) : entry[1], - indexedCollection ? entry.get(0) : entry[0], - this$1 - ); - } - }, - reverse - ); + return this._iter.__iterate(function (entry) { + // Check if entry exists first so array access doesn't throw for holes + // in the parent iteration. + if (entry) { + validateEntry(entry); + var indexedCollection = isCollection(entry); + return fn( + indexedCollection ? entry.get(1) : entry[1], + indexedCollection ? entry.get(0) : entry[0], + this$1 + ); + } + }, reverse); }; FromEntriesSequence.prototype.__iterator = function __iterator (type, reverse) { @@ -1221,7 +1231,7 @@ var FromEntriesSequence = (function (KeyedSeq$$1) { return FromEntriesSequence; }(KeyedSeq)); -ToIndexedSequence.prototype.cacheResult = (ToKeyedSequence.prototype.cacheResult = (ToSetSequence.prototype.cacheResult = (FromEntriesSequence.prototype.cacheResult = cacheResultThrough))); +ToIndexedSequence.prototype.cacheResult = ToKeyedSequence.prototype.cacheResult = ToSetSequence.prototype.cacheResult = FromEntriesSequence.prototype.cacheResult = cacheResultThrough; function flipFactory(collection) { var flipSequence = makeSequence(collection); @@ -1367,15 +1377,12 @@ function filterFactory(collection, predicate, context, useKeys) { var this$1 = this; var iterations = 0; - collection.__iterate( - function (v, k, c) { - if (predicate.call(context, v, k, c)) { - iterations++; - return fn(v, useKeys ? k : iterations - 1, this$1); - } - }, - reverse - ); + collection.__iterate(function (v, k, c) { + if (predicate.call(context, v, k, c)) { + iterations++; + return fn(v, useKeys ? k : iterations - 1, this$1); + } + }, reverse); return iterations; }; filterSequence.__iteratorUncached = function(type, reverse) { @@ -1451,9 +1458,8 @@ function sliceFactory(collection, begin, end, useKeys) { // If collection.size is undefined, the size of the realized sliceSeq is // unknown at this point unless the number of items to slice is 0 - sliceSeq.size = sliceSize === 0 - ? sliceSize - : (collection.size && sliceSize) || undefined; + sliceSeq.size = + sliceSize === 0 ? sliceSize : (collection.size && sliceSize) || undefined; if (!useKeys && isSeq(collection) && sliceSize >= 0) { sliceSeq.get = function(index, notSetValue) { @@ -1479,8 +1485,10 @@ function sliceFactory(collection, begin, end, useKeys) { collection.__iterate(function (v, k) { if (!(isSkipping && (isSkipping = skipped++ < resolvedBegin))) { iterations++; - return fn(v, useKeys ? k : iterations - 1, this$1) !== false && - iterations !== sliceSize; + return ( + fn(v, useKeys ? k : iterations - 1, this$1) !== false && + iterations !== sliceSize + ); } }); return iterations; @@ -1652,17 +1660,14 @@ function concatFactory(collection, values) { concatSeq = concatSeq.toSetSeq(); } concatSeq = concatSeq.flatten(true); - concatSeq.size = iters.reduce( - function (sum, seq) { - if (sum !== undefined) { - var size = seq.size; - if (size !== undefined) { - return sum + size; - } + concatSeq.size = iters.reduce(function (sum, seq) { + if (sum !== undefined) { + var size = seq.size; + if (size !== undefined) { + return sum + size; } - }, - 0 - ); + } + }, 0); return concatSeq; } @@ -1675,20 +1680,17 @@ function flattenFactory(collection, depth, useKeys) { var iterations = 0; var stopped = false; function flatDeep(iter, currentDepth) { - iter.__iterate( - function (v, k) { - if ((!depth || currentDepth < depth) && isCollection(v)) { - flatDeep(v, currentDepth + 1); - } else { - iterations++; - if (fn(v, useKeys ? k : iterations - 1, flatSequence) === false) { - stopped = true; - } + iter.__iterate(function (v, k) { + if ((!depth || currentDepth < depth) && isCollection(v)) { + flatDeep(v, currentDepth + 1); + } else { + iterations++; + if (fn(v, useKeys ? k : iterations - 1, flatSequence) === false) { + stopped = true; } - return !stopped; - }, - reverse - ); + } + return !stopped; + }, reverse); } flatDeep(collection, 0); return iterations; @@ -1797,20 +1799,20 @@ function maxFactory(collection, comparator, mapper) { var entry = collection .toSeq() .map(function (v, k) { return [v, mapper(v, k, collection)]; }) - .reduce(function (a, b) { return maxCompare(comparator, a[1], b[1]) ? b : a; }); + .reduce(function (a, b) { return (maxCompare(comparator, a[1], b[1]) ? b : a); }); return entry && entry[0]; } - return collection.reduce(function (a, b) { return maxCompare(comparator, a, b) ? b : a; }); + return collection.reduce(function (a, b) { return (maxCompare(comparator, a, b) ? b : a); }); } function maxCompare(comparator, a, b) { var comp = comparator(b, a); // b is considered the new max if the comparator declares them equal, but // they are not equal and b is in fact a nullish value. - return (comp === 0 && - b !== a && - (b === undefined || b === null || b !== b)) || - comp > 0; + return ( + (comp === 0 && b !== a && (b === undefined || b === null || b !== b)) || + comp > 0 + ); } function zipWithFactory(keyIter, zipper, iters, zipAll) { @@ -1892,7 +1894,8 @@ function makeSequence(collection) { return Object.create( (isKeyed(collection) ? KeyedSeq - : isIndexed(collection) ? IndexedSeq : SetSeq).prototype + : isIndexed(collection) ? IndexedSeq : SetSeq + ).prototype ); } @@ -1956,12 +1959,12 @@ var Map = (function (KeyedCollection$$1) { return value === null || value === undefined ? emptyMap() : isMap(value) && !isOrdered(value) - ? value - : emptyMap().withMutations(function (map) { - var iter = KeyedCollection$$1(value); - assertNotInfinite(iter.size); - iter.forEach(function (v, k) { return map.set(k, v); }); - }); + ? value + : emptyMap().withMutations(function (map) { + var iter = KeyedCollection$$1(value); + assertNotInfinite(iter.size); + iter.forEach(function (v, k) { return map.set(k, v); }); + }); } if ( KeyedCollection$$1 ) Map.__proto__ = KeyedCollection$$1; @@ -2152,13 +2155,10 @@ var Map = (function (KeyedCollection$$1) { var iterations = 0; this._root && - this._root.iterate( - function (entry) { - iterations++; - return fn(entry[1], entry[0], this$1); - }, - reverse - ); + this._root.iterate(function (entry) { + iterations++; + return fn(entry[1], entry[0], this$1); + }, reverse); return iterations; }; @@ -2283,7 +2283,7 @@ BitmapIndexedNode.prototype.get = function get (shift, keyHash, key, notSetValue var bitmap = this.bitmap; return (bitmap & bit) === 0 ? notSetValue - : this.nodes[popCount(bitmap & bit - 1)].get( + : this.nodes[popCount(bitmap & (bit - 1))].get( shift + SHIFT, keyHash, key, @@ -2304,7 +2304,7 @@ BitmapIndexedNode.prototype.update = function update (ownerID, shift, keyHash, k return this; } - var idx = popCount(bitmap & bit - 1); + var idx = popCount(bitmap & (bit - 1)); var nodes = this.nodes; var node = exists ? nodes[idx] : undefined; var newNode = updateNode( @@ -2327,7 +2327,10 @@ BitmapIndexedNode.prototype.update = function update (ownerID, shift, keyHash, k } if ( - exists && !newNode && nodes.length === 2 && isLeafNode(nodes[idx ^ 1]) + exists && + !newNode && + nodes.length === 2 && + isLeafNode(nodes[idx ^ 1]) ) { return nodes[idx ^ 1]; } @@ -2337,11 +2340,11 @@ BitmapIndexedNode.prototype.update = function update (ownerID, shift, keyHash, k } var isEditable = ownerID && ownerID === this.ownerID; - var newBitmap = exists ? newNode ? bitmap : bitmap ^ bit : bitmap | bit; + var newBitmap = exists ? (newNode ? bitmap : bitmap ^ bit) : bitmap | bit; var newNodes = exists ? newNode - ? setIn(nodes, idx, newNode, isEditable) - : spliceOut(nodes, idx, isEditable) + ? setIn(nodes, idx, newNode, isEditable) + : spliceOut(nodes, idx, isEditable) : spliceIn(nodes, idx, newNode, isEditable); if (isEditable) { @@ -2533,7 +2536,7 @@ ValueNode.prototype.update = function update (ownerID, shift, keyHash, key, valu // #pragma Iterators -ArrayMapNode.prototype.iterate = (HashCollisionNode.prototype.iterate = function( +ArrayMapNode.prototype.iterate = HashCollisionNode.prototype.iterate = function( fn, reverse ) { @@ -2543,9 +2546,9 @@ ArrayMapNode.prototype.iterate = (HashCollisionNode.prototype.iterate = function return false; } } -}); +}; -BitmapIndexedNode.prototype.iterate = (HashArrayMapNode.prototype.iterate = function( +BitmapIndexedNode.prototype.iterate = HashArrayMapNode.prototype.iterate = function( fn, reverse ) { @@ -2556,7 +2559,7 @@ BitmapIndexedNode.prototype.iterate = (HashArrayMapNode.prototype.iterate = func return false; } } -}); +}; // eslint-disable-next-line no-unused-vars ValueNode.prototype.iterate = function(fn, reverse) { @@ -2603,12 +2606,12 @@ var MapIterator = (function (Iterator$$1) { if (subNode.entry) { return mapIteratorValue(type, subNode.entry); } - stack = (this$1._stack = mapIteratorFrame(subNode, stack)); + stack = this$1._stack = mapIteratorFrame(subNode, stack); } continue; } } - stack = (this$1._stack = this$1._stack.__prev); + stack = this$1._stack = this$1._stack.__prev; } return iteratorDone(); }; @@ -2668,7 +2671,7 @@ function updateMap(map, k, v) { if (!didAlter.value) { return map; } - newSize = map.size + (didChangeSize.value ? v === NOT_SET ? -1 : 1 : 0); + newSize = map.size + (didChangeSize.value ? (v === NOT_SET ? -1 : 1) : 0); } if (map.__ownerID) { map.size = newSize; @@ -2710,8 +2713,9 @@ function updateNode( } function isLeafNode(node) { - return node.constructor === ValueNode || - node.constructor === HashCollisionNode; + return ( + node.constructor === ValueNode || node.constructor === HashCollisionNode + ); } function mergeIntoNode(node, ownerID, shift, keyHash, entry) { @@ -2723,13 +2727,13 @@ function mergeIntoNode(node, ownerID, shift, keyHash, entry) { var idx2 = (shift === 0 ? keyHash : keyHash >>> shift) & MASK; var newNode; - var nodes = idx1 === idx2 - ? [mergeIntoNode(node, ownerID, shift + SHIFT, keyHash, entry)] - : ((newNode = new ValueNode(ownerID, keyHash, entry)), idx1 < idx2 - ? [node, newNode] - : [newNode, node]); + var nodes = + idx1 === idx2 + ? [mergeIntoNode(node, ownerID, shift + SHIFT, keyHash, entry)] + : ((newNode = new ValueNode(ownerID, keyHash, entry)), + idx1 < idx2 ? [node, newNode] : [newNode, node]); - return new BitmapIndexedNode(ownerID, 1 << idx1 | 1 << idx2, nodes); + return new BitmapIndexedNode(ownerID, (1 << idx1) | (1 << idx2), nodes); } function createNodes(ownerID, entries, key, value) { @@ -2748,7 +2752,7 @@ function packNodes(ownerID, nodes, count, excluding) { var bitmap = 0; var packedII = 0; var packedNodes = new Array(count); - for (var ii = 0, bit = 1, len = nodes.length; ii < len; ii++, (bit <<= 1)) { + for (var ii = 0, bit = 1, len = nodes.length; ii < len; ii++, bit <<= 1) { var node = nodes[ii]; if (node !== undefined && ii !== excluding) { bitmap |= bit; @@ -2761,7 +2765,7 @@ function packNodes(ownerID, nodes, count, excluding) { function expandNodes(ownerID, nodes, bitmap, including, node) { var count = 0; var expandedNodes = new Array(SIZE); - for (var ii = 0; bitmap !== 0; ii++, (bitmap >>>= 1)) { + for (var ii = 0; bitmap !== 0; ii++, bitmap >>>= 1) { expandedNodes[ii] = bitmap & 1 ? nodes[count++] : undefined; } expandedNodes[including] = node; @@ -2811,7 +2815,7 @@ function mergeIntoCollectionWith(collection, merger, iters) { collection.update( key, NOT_SET, - function (oldVal) { return oldVal === NOT_SET ? value : merger(oldVal, value, key); } + function (oldVal) { return (oldVal === NOT_SET ? value : merger(oldVal, value, key)); } ); } : function (value, key) { @@ -2850,14 +2854,14 @@ function updateInDeepMap(existing, keyPath, i, notSetValue, updater) { return nextUpdated === nextExisting ? existing : nextUpdated === NOT_SET - ? existing.remove(key) - : (isNotSet ? emptyMap() : existing).set(key, nextUpdated); + ? existing.remove(key) + : (isNotSet ? emptyMap() : existing).set(key, nextUpdated); } function popCount(x) { - x -= x >> 1 & 0x55555555; - x = (x & 0x33333333) + (x >> 2 & 0x33333333); - x = x + (x >> 4) & 0x0f0f0f0f; + x -= (x >> 1) & 0x55555555; + x = (x & 0x33333333) + ((x >> 2) & 0x33333333); + x = (x + (x >> 4)) & 0x0f0f0f0f; x += x >> 8; x += x >> 16; return x & 0x7f; @@ -2967,8 +2971,8 @@ var List = (function (IndexedCollection$$1) { return !this.has(index) ? this : index === 0 - ? this.shift() - : index === this.size - 1 ? this.pop() : this.splice(index, 1); + ? this.shift() + : index === this.size - 1 ? this.pop() : this.splice(index, 1); }; List.prototype.insert = function insert (index, value) { @@ -2980,9 +2984,9 @@ var List = (function (IndexedCollection$$1) { return this; } if (this.__ownerID) { - this.size = (this._origin = (this._capacity = 0)); + this.size = this._origin = this._capacity = 0; this._level = SHIFT; - this._root = (this._tail = null); + this._root = this._tail = null; this.__hash = undefined; this.__altered = true; return this; @@ -3123,7 +3127,7 @@ var ListPrototype = List.prototype; ListPrototype[IS_LIST_SENTINEL] = true; ListPrototype[DELETE] = ListPrototype.remove; ListPrototype.setIn = MapPrototype.setIn; -ListPrototype.deleteIn = (ListPrototype.removeIn = MapPrototype.removeIn); +ListPrototype.deleteIn = ListPrototype.removeIn = MapPrototype.removeIn; ListPrototype.update = MapPrototype.update; ListPrototype.updateIn = MapPrototype.updateIn; ListPrototype.mergeIn = MapPrototype.mergeIn; @@ -3149,7 +3153,7 @@ VNode.prototype.removeBefore = function removeBefore (ownerID, level, index) { if (index === level ? 1 << level : 0 || this.array.length === 0) { return this; } - var originIndex = index >>> level & MASK; + var originIndex = (index >>> level) & MASK; if (originIndex >= this.array.length) { return new VNode([], ownerID); } @@ -3157,8 +3161,8 @@ VNode.prototype.removeBefore = function removeBefore (ownerID, level, index) { var newChild; if (level > 0) { var oldChild = this.array[originIndex]; - newChild = oldChild && - oldChild.removeBefore(ownerID, level - SHIFT, index); + newChild = + oldChild && oldChild.removeBefore(ownerID, level - SHIFT, index); if (newChild === oldChild && removingFirst) { return this; } @@ -3182,7 +3186,7 @@ VNode.prototype.removeAfter = function removeAfter (ownerID, level, index) { if (index === (level ? 1 << level : 0) || this.array.length === 0) { return this; } - var sizeIndex = index - 1 >>> level & MASK; + var sizeIndex = ((index - 1) >>> level) & MASK; if (sizeIndex >= this.array.length) { return this; } @@ -3190,8 +3194,8 @@ VNode.prototype.removeAfter = function removeAfter (ownerID, level, index) { var newChild; if (level > 0) { var oldChild = this.array[sizeIndex]; - newChild = oldChild && - oldChild.removeAfter(ownerID, level - SHIFT, index); + newChild = + oldChild && oldChild.removeAfter(ownerID, level - SHIFT, index); if (newChild === oldChild && sizeIndex === this.array.length - 1) { return this; } @@ -3240,8 +3244,8 @@ function iterateList(list, reverse) { function iterateNode(node, level, offset) { var values; var array = node && node.array; - var from = offset > left ? 0 : left - offset >> level; - var to = (right - offset >> level) + 1; + var from = offset > left ? 0 : (left - offset) >> level; + var to = ((right - offset) >> level) + 1; if (to > SIZE) { to = SIZE; } @@ -3335,7 +3339,7 @@ function updateList(list, index, value) { } function updateVNode(node, ownerID, level, index, value, didAlter) { - var idx = index >>> level & MASK; + var idx = (index >>> level) & MASK; var nodeHas = node && idx < node.array.length; if (!nodeHas && value === undefined) { return node; @@ -3387,11 +3391,11 @@ function listNodeFor(list, rawIndex) { if (rawIndex >= getTailOffset(list._capacity)) { return list._tail; } - if (rawIndex < 1 << list._level + SHIFT) { + if (rawIndex < 1 << (list._level + SHIFT)) { var node = list._root; var level = list._level; while (node && level > 0) { - node = node.array[rawIndex >>> level & MASK]; + node = node.array[(rawIndex >>> level) & MASK]; level -= SHIFT; } return node; @@ -3411,9 +3415,10 @@ function setListBounds(list, begin, end) { var oldOrigin = list._origin; var oldCapacity = list._capacity; var newOrigin = oldOrigin + begin; - var newCapacity = end === undefined - ? oldCapacity - : end < 0 ? oldCapacity + end : oldOrigin + end; + var newCapacity = + end === undefined + ? oldCapacity + : end < 0 ? oldCapacity + end : oldOrigin + end; if (newOrigin === oldOrigin && newCapacity === oldCapacity) { return list; } @@ -3447,7 +3452,7 @@ function setListBounds(list, begin, end) { var newTailOffset = getTailOffset(newCapacity); // New size might need creating a higher root. - while (newTailOffset >= 1 << newLevel + SHIFT) { + while (newTailOffset >= 1 << (newLevel + SHIFT)) { newRoot = new VNode( newRoot && newRoot.array.length ? [newRoot] : [], owner @@ -3457,9 +3462,10 @@ function setListBounds(list, begin, end) { // Locate or create the new tail. var oldTail = list._tail; - var newTail = newTailOffset < oldTailOffset - ? listNodeFor(list, newCapacity - 1) - : newTailOffset > oldTailOffset ? new VNode([], owner) : oldTail; + var newTail = + newTailOffset < oldTailOffset + ? listNodeFor(list, newCapacity - 1) + : newTailOffset > oldTailOffset ? new VNode([], owner) : oldTail; // Merge Tail into tree. if ( @@ -3471,10 +3477,10 @@ function setListBounds(list, begin, end) { newRoot = editableVNode(newRoot, owner); var node = newRoot; for (var level = newLevel; level > SHIFT; level -= SHIFT) { - var idx = oldTailOffset >>> level & MASK; - node = (node.array[idx] = editableVNode(node.array[idx], owner)); + var idx = (oldTailOffset >>> level) & MASK; + node = node.array[idx] = editableVNode(node.array[idx], owner); } - node.array[oldTailOffset >>> SHIFT & MASK] = oldTail; + node.array[(oldTailOffset >>> SHIFT) & MASK] = oldTail; } // If the size has been reduced, there's a chance the tail needs to be trimmed. @@ -3496,8 +3502,8 @@ function setListBounds(list, begin, end) { // Identify the new top root node of the subtree of the old root. while (newRoot) { - var beginIndex = newOrigin >>> newLevel & MASK; - if (beginIndex !== newTailOffset >>> newLevel & MASK) { + var beginIndex = (newOrigin >>> newLevel) & MASK; + if ((beginIndex !== newTailOffset >>> newLevel) & MASK) { break; } if (beginIndex) { @@ -3559,7 +3565,7 @@ function mergeIntoListWith(list, merger, collections) { } function getTailOffset(size) { - return size < SIZE ? 0 : size - 1 >>> SHIFT << SHIFT; + return size < SIZE ? 0 : ((size - 1) >>> SHIFT) << SHIFT; } var OrderedMap = (function (Map$$1) { @@ -3567,12 +3573,12 @@ var OrderedMap = (function (Map$$1) { return value === null || value === undefined ? emptyOrderedMap() : isOrderedMap(value) - ? value - : emptyOrderedMap().withMutations(function (map) { - var iter = KeyedCollection(value); - assertNotInfinite(iter.size); - iter.forEach(function (v, k) { return map.set(k, v); }); - }); + ? value + : emptyOrderedMap().withMutations(function (map) { + var iter = KeyedCollection(value); + assertNotInfinite(iter.size); + iter.forEach(function (v, k) { return map.set(k, v); }); + }); } if ( Map$$1 ) OrderedMap.__proto__ = Map$$1; @@ -3676,8 +3682,10 @@ function makeOrderedMap(map, list, ownerID, hash) { var EMPTY_ORDERED_MAP; function emptyOrderedMap() { - return EMPTY_ORDERED_MAP || - (EMPTY_ORDERED_MAP = makeOrderedMap(emptyMap(), emptyList())); + return ( + EMPTY_ORDERED_MAP || + (EMPTY_ORDERED_MAP = makeOrderedMap(emptyMap(), emptyList())) + ); } function updateOrderedMap(omap, k, v) { @@ -3694,9 +3702,13 @@ function updateOrderedMap(omap, k, v) { } if (list.size >= SIZE && list.size >= map.size * 2) { newList = list.filter(function (entry, idx) { return entry !== undefined && i !== idx; }); - newMap = newList.toKeyedSeq().map(function (entry) { return entry[0]; }).flip().toMap(); + newMap = newList + .toKeyedSeq() + .map(function (entry) { return entry[0]; }) + .flip() + .toMap(); if (omap.__ownerID) { - newMap.__ownerID = (newList.__ownerID = omap.__ownerID); + newMap.__ownerID = newList.__ownerID = omap.__ownerID; } } else { newMap = map.remove(k); @@ -3793,16 +3805,13 @@ var Stack = (function (IndexedCollection$$1) { assertNotInfinite(iter.size); var newSize = this.size; var head = this._head; - iter.__iterate( - function (value) { - newSize++; - head = { - value: value, - next: head - }; - }, - /* reverse */ true - ); + iter.__iterate(function (value) { + newSize++; + head = { + value: value, + next: head + }; + }, /* reverse */ true); if (this.__ownerID) { this.size = newSize; this._head = head; @@ -3978,10 +3987,12 @@ function deepEqual(a, b) { if (isOrdered(a)) { var entries = a.entries(); - return b.every(function (v, k) { - var entry = entries.next().value; - return entry && is(entry[1], v) && (notAssociative || is(entry[0], k)); - }) && entries.next().done; + return ( + b.every(function (v, k) { + var entry = entries.next().value; + return entry && is(entry[1], v) && (notAssociative || is(entry[0], k)); + }) && entries.next().done + ); } var flipped = false; @@ -4032,12 +4043,12 @@ var Set = (function (SetCollection$$1) { return value === null || value === undefined ? emptySet() : isSet(value) && !isOrdered(value) - ? value - : emptySet().withMutations(function (set) { - var iter = SetCollection$$1(value); - assertNotInfinite(iter.size); - iter.forEach(function (v) { return set.add(v); }); - }); + ? value + : emptySet().withMutations(function (set) { + var iter = SetCollection$$1(value); + assertNotInfinite(iter.size); + iter.forEach(function (v) { return set.add(v); }); + }); } if ( SetCollection$$1 ) Set.__proto__ = SetCollection$$1; @@ -4293,12 +4304,14 @@ var Range = (function (IndexedSeq$$1) { if (this.size === 0) { return 'Range []'; } - return 'Range [ ' + + return ( + 'Range [ ' + this._start + '...' + this._end + (this._step !== 1 ? ' by ' + this._step : '') + - ' ]'; + ' ]' + ); }; Range.prototype.get = function get (index, notSetValue) { @@ -4309,9 +4322,11 @@ var Range = (function (IndexedSeq$$1) { Range.prototype.includes = function includes (searchValue) { var possibleIndex = (searchValue - this._start) / this._step; - return possibleIndex >= 0 && + return ( + possibleIndex >= 0 && possibleIndex < this.size && - possibleIndex === Math.floor(possibleIndex); + possibleIndex === Math.floor(possibleIndex) + ); }; Range.prototype.slice = function slice (begin, end) { @@ -4415,7 +4430,9 @@ mixin(Collection, { }, toJS: function toJS$1() { - return this.toSeq().map(toJS).toJSON(); + return this.toSeq() + .map(toJS) + .toJSON(); }, toKeyedSeq: function toKeyedSeq() { @@ -4481,11 +4498,15 @@ mixin(Collection, { if (this.size === 0) { return head + tail; } - return head + + return ( + head + ' ' + - this.toSeq().map(this.__toStringMapper).join(', ') + + this.toSeq() + .map(this.__toStringMapper) + .join(', ') + ' ' + - tail; + tail + ); }, // ### ES6 Collection methods (ES6 Array and Map) @@ -4623,7 +4644,10 @@ mixin(Collection, { // We cache as an entries array, so we can just return the cache! return new ArraySeq(collection._cache); } - var entriesSequence = collection.toSeq().map(entryMapper).toIndexedSeq(); + var entriesSequence = collection + .toSeq() + .map(entryMapper) + .toIndexedSeq(); entriesSequence.fromEntrySeq = function () { return collection.toSeq(); }; // Entries are plain Array, which do not define toJS, so it must @@ -4656,7 +4680,9 @@ mixin(Collection, { }, findLast: function findLast(predicate, context, notSetValue) { - return this.toKeyedSeq().reverse().find(predicate, context, notSetValue); + return this.toKeyedSeq() + .reverse() + .find(predicate, context, notSetValue); }, findLastEntry: function findLastEntry(predicate, context, notSetValue) { @@ -4666,7 +4692,9 @@ mixin(Collection, { }, findLastKey: function findLastKey(predicate, context) { - return this.toKeyedSeq().reverse().findKey(predicate, context); + return this.toKeyedSeq() + .reverse() + .findKey(predicate, context); }, first: function first() { @@ -4739,15 +4767,21 @@ mixin(Collection, { }, keySeq: function keySeq() { - return this.toSeq().map(keyMapper).toIndexedSeq(); + return this.toSeq() + .map(keyMapper) + .toIndexedSeq(); }, last: function last() { - return this.toSeq().reverse().first(); + return this.toSeq() + .reverse() + .first(); }, lastKeyOf: function lastKeyOf(searchValue) { - return this.toKeyedSeq().reverse().keyOf(searchValue); + return this.toKeyedSeq() + .reverse() + .keyOf(searchValue); }, max: function max(comparator) { @@ -4839,9 +4873,9 @@ CollectionPrototype[IS_ITERABLE_SENTINEL] = true; CollectionPrototype[ITERATOR_SYMBOL] = CollectionPrototype.values; CollectionPrototype.toJSON = CollectionPrototype.toArray; CollectionPrototype.__toStringMapper = quoteString; -CollectionPrototype.inspect = (CollectionPrototype.toSource = function() { +CollectionPrototype.inspect = CollectionPrototype.toSource = function() { return this.toString(); -}); +}; CollectionPrototype.chain = CollectionPrototype.flatMap; CollectionPrototype.contains = CollectionPrototype.includes; @@ -4869,7 +4903,10 @@ mixin(KeyedCollection, { return reify( this, - this.toSeq().flip().map(function (k, v) { return mapper.call(context, k, v, this$1); }).flip() + this.toSeq() + .flip() + .map(function (k, v) { return mapper.call(context, k, v, this$1); }) + .flip() ); } }); @@ -4960,10 +4997,12 @@ mixin(IndexedCollection, { has: function has(index) { index = wrapIndex(this, index); - return index >= 0 && + return ( + index >= 0 && (this.size !== undefined ? this.size === Infinity || index < this.size - : this.indexOf(index) !== -1); + : this.indexOf(index) !== -1) + ); }, interpose: function interpose(separator) { @@ -5044,17 +5083,14 @@ mixin(SetSeq, SetCollection.prototype); function reduce(collection, reducer, reduction, context, useFirst, reverse) { assertNotInfinite(collection.size); - collection.__iterate( - function (v, k, c) { - if (useFirst) { - useFirst = false; - reduction = v; - } else { - reduction = reducer.call(context, reduction, v, k, c); - } - }, - reverse - ); + collection.__iterate(function (v, k, c) { + if (useFirst) { + useFirst = false; + reduction = v; + } else { + reduction = reducer.call(context, reduction, v, k, c); + } + }, reverse); return reduction; } @@ -5100,36 +5136,36 @@ function hashCollection(collection) { var size = collection.__iterate( keyed ? ordered - ? function (v, k) { - h = 31 * h + hashMerge(hash(v), hash(k)) | 0; - } - : function (v, k) { - h = h + hashMerge(hash(v), hash(k)) | 0; - } + ? function (v, k) { + h = (31 * h + hashMerge(hash(v), hash(k))) | 0; + } + : function (v, k) { + h = (h + hashMerge(hash(v), hash(k))) | 0; + } : ordered - ? function (v) { - h = 31 * h + hash(v) | 0; - } - : function (v) { - h = h + hash(v) | 0; - } + ? function (v) { + h = (31 * h + hash(v)) | 0; + } + : function (v) { + h = (h + hash(v)) | 0; + } ); return murmurHashOfSize(size, h); } function murmurHashOfSize(size, h) { h = imul(h, 0xcc9e2d51); - h = imul(h << 15 | h >>> -15, 0x1b873593); - h = imul(h << 13 | h >>> -13, 5); - h = (h + 0xe6546b64 | 0) ^ size; - h = imul(h ^ h >>> 16, 0x85ebca6b); - h = imul(h ^ h >>> 13, 0xc2b2ae35); - h = smi(h ^ h >>> 16); + h = imul((h << 15) | (h >>> -15), 0x1b873593); + h = imul((h << 13) | (h >>> -13), 5); + h = ((h + 0xe6546b64) | 0) ^ size; + h = imul(h ^ (h >>> 16), 0x85ebca6b); + h = imul(h ^ (h >>> 13), 0xc2b2ae35); + h = smi(h ^ (h >>> 16)); return h; } function hashMerge(a, b) { - return a ^ b + 0x9e3779b9 + (a << 6) + (a >> 2) | 0; // int + return (a ^ (b + 0x9e3779b9 + (a << 6) + (a >> 2))) | 0; // int } function warn(message) { @@ -5147,12 +5183,12 @@ var OrderedSet = (function (Set$$1) { return value === null || value === undefined ? emptyOrderedSet() : isOrderedSet(value) - ? value - : emptyOrderedSet().withMutations(function (set) { - var iter = SetCollection(value); - assertNotInfinite(iter.size); - iter.forEach(function (v) { return set.add(v); }); - }); + ? value + : emptyOrderedSet().withMutations(function (set) { + var iter = SetCollection(value); + assertNotInfinite(iter.size); + iter.forEach(function (v) { return set.add(v); }); + }); } if ( Set$$1 ) OrderedSet.__proto__ = Set$$1; @@ -5198,8 +5234,9 @@ function makeOrderedSet(map, ownerID) { var EMPTY_ORDERED_SET; function emptyOrderedSet() { - return EMPTY_ORDERED_SET || - (EMPTY_ORDERED_SET = makeOrderedSet(emptyOrderedMap())); + return ( + EMPTY_ORDERED_SET || (EMPTY_ORDERED_SET = makeOrderedSet(emptyOrderedMap())) + ); } var Record = function Record(defaultValues, name) { @@ -5272,10 +5309,12 @@ Record.prototype.toString = function toString () { }; Record.prototype.equals = function equals (other) { - return this === other || + return ( + this === other || (other && this._keys === other._keys && - recordSeq(this).equals(recordSeq(other))); + recordSeq(this).equals(recordSeq(other))) + ); }; Record.prototype.hashCode = function hashCode () { @@ -5359,7 +5398,7 @@ Record.getDescriptiveName = recordName; var RecordPrototype = Record.prototype; RecordPrototype[IS_RECORD_SENTINEL] = true; RecordPrototype[DELETE] = RecordPrototype.remove; -RecordPrototype.deleteIn = (RecordPrototype.removeIn = MapPrototype.removeIn); +RecordPrototype.deleteIn = RecordPrototype.removeIn = MapPrototype.removeIn; RecordPrototype.getIn = CollectionPrototype.getIn; RecordPrototype.hasIn = CollectionPrototype.hasIn; RecordPrototype.merge = MapPrototype.merge; @@ -5375,8 +5414,10 @@ RecordPrototype.withMutations = MapPrototype.withMutations; RecordPrototype.asMutable = MapPrototype.asMutable; RecordPrototype.asImmutable = MapPrototype.asImmutable; RecordPrototype[ITERATOR_SYMBOL] = CollectionPrototype.entries; -RecordPrototype.toJSON = (RecordPrototype.toObject = CollectionPrototype.toObject); -RecordPrototype.inspect = (RecordPrototype.toSource = CollectionPrototype.toSource); +RecordPrototype.toJSON = RecordPrototype.toObject = + CollectionPrototype.toObject; +RecordPrototype.inspect = RecordPrototype.toSource = + CollectionPrototype.toSource; function makeRecord(likeRecord, values, ownerID) { var record = Object.create(Object.getPrototypeOf(likeRecord)); From 7dffbebd12d7f42b8073a8eaa16d0d4320a42b0d Mon Sep 17 00:00:00 2001 From: Travis CI Date: Sat, 30 Sep 2017 01:31:36 +0000 Subject: [PATCH 006/242] Deploy master to NPM branch --- dist/immutable.es.js | 52 +++++++++++++++++++++--------------- dist/immutable.js | 52 +++++++++++++++++++++--------------- dist/immutable.min.js | 62 +++++++++++++++++++++---------------------- 3 files changed, 91 insertions(+), 75 deletions(-) diff --git a/dist/immutable.es.js b/dist/immutable.es.js index 5b7b1d216e..f9fa1138bb 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -4711,27 +4711,8 @@ mixin(Collection, { return this.find(function (_, key) { return is(key, searchKey); }, undefined, notSetValue); }, - getIn: function getIn(searchKeyPath, notSetValue) { - var nested = this; - var keyPath = coerceKeyPath(searchKeyPath); - var i = 0; - while (i !== keyPath.length) { - if (!nested || !nested.get) { - warn( - 'Invalid keyPath: Value at [' + - keyPath.slice(0, i).map(quoteString) + - '] does not have a .get() method: ' + - nested + - '\nThis warning will throw in a future version' - ); - return notSetValue; - } - nested = nested.get(keyPath[i++], NOT_SET); - if (nested === NOT_SET) { - return notSetValue; - } - } - return nested; + getIn: function getIn$1(searchKeyPath, notSetValue) { + return getIn(this, notSetValue, searchKeyPath, true /* report bad path */); }, groupBy: function groupBy(grouper, context) { @@ -4743,7 +4724,10 @@ mixin(Collection, { }, hasIn: function hasIn(searchKeyPath) { - return this.getIn(searchKeyPath, NOT_SET) !== NOT_SET; + return ( + getIn(this, NOT_SET, searchKeyPath, false /* report bad path */) !== + NOT_SET + ); }, isSubset: function isSubset(iter) { @@ -5172,6 +5156,30 @@ function warn(message) { /* eslint-enable no-console */ } +function getIn(value, notSetValue, searchKeyPath, reportBadKeyPath) { + var keyPath = coerceKeyPath(searchKeyPath); + var i = 0; + while (i !== keyPath.length) { + if (!value || !value.get) { + if (reportBadKeyPath) { + warn( + 'Invalid keyPath: Value at [' + + keyPath.slice(0, i).map(quoteString) + + '] does not have a .get() method: ' + + value + + '\nThis warning will throw in a future version' + ); + } + return notSetValue; + } + value = value.get(keyPath[i++], NOT_SET); + if (value === NOT_SET) { + return notSetValue; + } + } + return value; +} + var OrderedSet = (function (Set$$1) { function OrderedSet(value) { return value === null || value === undefined diff --git a/dist/immutable.js b/dist/immutable.js index 39555e4239..5f707bebff 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -4717,27 +4717,8 @@ mixin(Collection, { return this.find(function (_, key) { return is(key, searchKey); }, undefined, notSetValue); }, - getIn: function getIn(searchKeyPath, notSetValue) { - var nested = this; - var keyPath = coerceKeyPath(searchKeyPath); - var i = 0; - while (i !== keyPath.length) { - if (!nested || !nested.get) { - warn( - 'Invalid keyPath: Value at [' + - keyPath.slice(0, i).map(quoteString) + - '] does not have a .get() method: ' + - nested + - '\nThis warning will throw in a future version' - ); - return notSetValue; - } - nested = nested.get(keyPath[i++], NOT_SET); - if (nested === NOT_SET) { - return notSetValue; - } - } - return nested; + getIn: function getIn$1(searchKeyPath, notSetValue) { + return getIn(this, notSetValue, searchKeyPath, true /* report bad path */); }, groupBy: function groupBy(grouper, context) { @@ -4749,7 +4730,10 @@ mixin(Collection, { }, hasIn: function hasIn(searchKeyPath) { - return this.getIn(searchKeyPath, NOT_SET) !== NOT_SET; + return ( + getIn(this, NOT_SET, searchKeyPath, false /* report bad path */) !== + NOT_SET + ); }, isSubset: function isSubset(iter) { @@ -5178,6 +5162,30 @@ function warn(message) { /* eslint-enable no-console */ } +function getIn(value, notSetValue, searchKeyPath, reportBadKeyPath) { + var keyPath = coerceKeyPath(searchKeyPath); + var i = 0; + while (i !== keyPath.length) { + if (!value || !value.get) { + if (reportBadKeyPath) { + warn( + 'Invalid keyPath: Value at [' + + keyPath.slice(0, i).map(quoteString) + + '] does not have a .get() method: ' + + value + + '\nThis warning will throw in a future version' + ); + } + return notSetValue; + } + value = value.get(keyPath[i++], NOT_SET); + if (value === NOT_SET) { + return notSetValue; + } + } + return value; +} + var OrderedSet = (function (Set$$1) { function OrderedSet(value) { return value === null || value === undefined diff --git a/dist/immutable.min.js b/dist/immutable.min.js index 9a52a00dcc..05b069327c 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -6,34 +6,34 @@ * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. */ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.Immutable=t.Immutable||{})}(this,function(t){"use strict";function e(t){return t.value=!1,t}function r(t){t&&(t.value=!0)}function n(){}function i(t,e){e=e||0;for(var r=Math.max(0,t.length-e),n=Array(r),i=0;i>>0;if(""+r!==e||4294967295===r)return NaN;e=r}return e<0?o(t)+e:e}function s(){return!0}function a(t,e,r){return(0===t&&!p(t)||void 0!==r&&t<=-r)&&(void 0===e||void 0!==r&&e>=r)}function c(t,e){return f(t,e,0)}function h(t,e){return f(t,e,e)}function f(t,e,r){return void 0===t?r:p(t)?e===1/0?e:0|Math.max(0,e+t):void 0===e||e===t?t:0|Math.min(e,t)}function p(t){return t<0||0===t&&1/t==-(1/0)}function _(t){return(l(t)||m(t))&&!t.__ownerID}function l(t){return!(!t||!t[Re])}function v(t){return!(!t||!t[Ue])}function y(t){return!(!t||!t[Ke])}function d(t){return v(t)||y(t)}function g(t){return!(!t||!t[Le])}function m(t){return!(!t||!t[Te])}function w(t){return!(!t||"function"!=typeof t.equals||"function"!=typeof t.hashCode)}function z(t,e,r,n){var i=0===t?e:1===t?r:[e,r];return n?n.value=i:n={value:i,done:!1},n}function S(){return{value:void 0,done:!0}}function I(t){return!!M(t)}function b(t){return t&&"function"==typeof t.next}function O(t){var e=M(t);return e&&e.call(t)}function M(t){var e=t&&(He&&t[He]||t[Ye]);if("function"==typeof e)return e}function D(t){return t&&"number"==typeof t.length}function q(t){return!(!t||!t[tr])}function E(){return nr||(nr=new er([]))}function x(t){var e=Array.isArray(t)?new er(t):b(t)?new ur(t):I(t)?new or(t):void 0;if(e)return e.fromEntrySeq();if("object"==typeof t)return new rr(t);throw new TypeError("Expected Array or collection object of [k, v] entries, or keyed object: "+t)}function j(t){var e=A(t);if(e)return e;throw new TypeError("Expected Array or collection object of values: "+t)} -function k(t){var e=A(t);if(e)return e;if("object"==typeof t)return new rr(t);throw new TypeError("Expected Array or collection object of values, or keyed object: "+t)}function A(t){return D(t)?new er(t):b(t)?new ur(t):I(t)?new or(t):void 0}function R(t,e){if(t===e||t!==t&&e!==e)return!0;if(!t||!e)return!1;if("function"==typeof t.valueOf&&"function"==typeof e.valueOf){if(t=t.valueOf(),e=e.valueOf(),t===e||t!==t&&e!==e)return!0;if(!t||!e)return!1}return!!(w(t)&&w(e)&&t.equals(e))}function U(t,e){return K([],e||L,t,"",e&&e.length>2?[]:void 0,{"":t})}function K(t,e,r,n,i,o){var u=Array.isArray(r)?Ze:T(r)?Ge:null;if(u){if(~t.indexOf(r))throw new TypeError("Cannot convert circular structure to Immutable");t.push(r),i&&""!==n&&i.push(n);var s=e.call(o,n,u(r).map(function(n,o){return K(t,e,n,o,i,r)}),i&&i.slice());return t.pop(),i&&i.pop(),s}return r}function L(t,e){return v(e)?e.toMap():e.toList()}function T(t){return t&&(t.constructor===Object||void 0===t.constructor)}function C(t){return t>>>1&1073741824|3221225471&t}function W(t){if(t===!1||null===t||void 0===t)return 0;if("function"==typeof t.valueOf&&((t=t.valueOf())===!1||null===t||void 0===t))return 0;if(t===!0)return 1;var e=typeof t;if("number"===e){if(t!==t||t===1/0)return 0;var r=0|t;for(r!==t&&(r^=4294967295*t);t>4294967295;)t/=4294967295,r^=t;return C(r)}if("string"===e)return t.length>_r?B(t):J(t);if("function"==typeof t.hashCode)return C(t.hashCode());if("object"===e)return P(t);if("function"==typeof t.toString)return J(""+t);throw Error("Value type "+e+" cannot be hashed.")}function B(t){var e=yr[t];return void 0===e&&(e=J(t),vr===lr&&(vr=0,yr={}),vr++,yr[t]=e),e}function J(t){for(var e=0,r=0;r0)switch(t.nodeType){case 1:return t.uniqueID;case 9:return t.documentElement&&t.documentElement.uniqueID}}function V(t){var e=ft(t);return e._iter=t,e.size=t.size,e.flip=function(){return t},e.reverse=function(){var e=t.reverse.apply(this);return e.flip=function(){return t.reverse()},e},e.has=function(e){return t.includes(e)},e.includes=function(e){return t.has(e)},e.cacheResult=pt,e.__iterateUncached=function(e,r){var n=this;return t.__iterate(function(t,r){return e(r,t,n)!==!1},r)},e.__iteratorUncached=function(e,r){if(e===Ve){var n=t.__iterator(e,r);return new Xe(function(){var t=n.next();if(!t.done){var e=t.value[0];t.value[0]=t.value[1],t.value[1]=e}return t})}return t.__iterator(e===Ne?Pe:Ne,r)},e}function H(t,e,r){var n=ft(t);return n.size=t.size,n.has=function(e){return t.has(e)},n.get=function(n,i){var o=t.get(n,je);return o===je?i:e.call(r,o,n,t)},n.__iterateUncached=function(n,i){var o=this;return t.__iterate(function(t,i,u){return n(e.call(r,t,i,u),i,o)!==!1},i)},n.__iteratorUncached=function(n,i){var o=t.__iterator(Ve,i);return new Xe(function(){var i=o.next();if(i.done)return i;var u=i.value,s=u[0];return z(n,s,e.call(r,u[1],s,t),i)})},n}function Y(t,e){var r=this,n=ft(t);return n._iter=t,n.size=t.size,n.reverse=function(){return t},t.flip&&(n.flip=function(){var e=V(t);return e.reverse=function(){return t.flip()},e}),n.get=function(r,n){return t.get(e?r:-1-r,n)},n.has=function(r){return t.has(e?r:-1-r)},n.includes=function(e){ -return t.includes(e)},n.cacheResult=pt,n.__iterate=function(r,n){var i=this,u=0;return n&&o(t),t.__iterate(function(t,o){return r(t,e?o:n?i.size-++u:u++,i)},!n)},n.__iterator=function(n,i){var u=0;i&&o(t);var s=t.__iterator(Ve,!i);return new Xe(function(){var t=s.next();if(t.done)return t;var o=t.value;return z(n,e?o[0]:i?r.size-++u:u++,o[1],t)})},n}function Q(t,e,r,n){var i=ft(t);return n&&(i.has=function(n){var i=t.get(n,je);return i!==je&&!!e.call(r,i,n,t)},i.get=function(n,i){var o=t.get(n,je);return o!==je&&e.call(r,o,n,t)?o:i}),i.__iterateUncached=function(i,o){var u=this,s=0;return t.__iterate(function(t,o,a){if(e.call(r,t,o,a))return s++,i(t,n?o:s-1,u)},o),s},i.__iteratorUncached=function(i,o){var u=t.__iterator(Ve,o),s=0;return new Xe(function(){for(;;){var o=u.next();if(o.done)return o;var a=o.value,c=a[0],h=a[1];if(e.call(r,h,c,t))return z(i,n?c:s++,h,o)}})},i}function X(t,e,r){var n=zr().asMutable();return t.__iterate(function(i,o){n.update(e.call(r,i,o,t),0,function(t){return t+1})}),n.asImmutable()}function F(t,e,r){var n=v(t),i=(g(t)?Wr():zr()).asMutable();t.__iterate(function(o,u){i.update(e.call(r,o,u,t),function(t){return t=t||[],t.push(n?[u,o]:o),t})});var o=ht(t);return i.map(function(e){return at(t,o(e))})}function G(t,e,r,n){var i=t.size;if(a(e,r,i))return t;var o=c(e,i),s=h(r,i);if(o!==o||s!==s)return G(t.toSeq().cacheResult(),e,r,n);var f,p=s-o;p===p&&(f=p<0?0:p);var _=ft(t);return _.size=0===f?f:t.size&&f||void 0,!n&&q(t)&&f>=0&&(_.get=function(e,r){return e=u(this,e),e>=0&&ef)return S();var t=i.next() -;return n||e===Ne?t:e===Pe?z(e,s-1,void 0,t):z(e,s-1,t.value[1],t)})},_}function Z(t,e,r){var n=ft(t);return n.__iterateUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterate(n,i);var u=0;return t.__iterate(function(t,i,s){return e.call(r,t,i,s)&&++u&&n(t,i,o)}),u},n.__iteratorUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterator(n,i);var u=t.__iterator(Ve,i),s=!0;return new Xe(function(){if(!s)return S();var t=u.next();if(t.done)return t;var i=t.value,a=i[0],c=i[1];return e.call(r,c,a,o)?n===Ve?t:z(n,a,c,t):(s=!1,S())})},n}function $(t,e,r,n){var i=ft(t);return i.__iterateUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterate(i,o);var s=!0,a=0;return t.__iterate(function(t,o,c){if(!s||!(s=e.call(r,t,o,c)))return a++,i(t,n?o:a-1,u)}),a},i.__iteratorUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterator(i,o);var s=t.__iterator(Ve,o),a=!0,c=0;return new Xe(function(){var t,o,h;do{if(t=s.next(),t.done)return n||i===Ne?t:i===Pe?z(i,c++,void 0,t):z(i,c++,t.value[1],t);var f=t.value;o=f[0],h=f[1],a&&(a=e.call(r,h,o,u))}while(a);return i===Ve?t:z(i,o,h,t)})},i}function tt(t,e){var r=v(t),n=[t].concat(e).map(function(t){return l(t)?r&&(t=We(t)):t=r?x(t):j(Array.isArray(t)?t:[t]),t}).filter(function(t){return 0!==t.size});if(0===n.length)return t;if(1===n.length){var i=n[0];if(i===t||r&&v(i)||y(t)&&y(i))return i}var o=new er(n);return r?o=o.toKeyedSeq():y(t)||(o=o.toSetSeq()),o=o.flatten(!0),o.size=n.reduce(function(t,e){if(void 0!==t){var r=e.size;if(void 0!==r)return t+r}},0),o}function et(t,e,r){var n=ft(t);return n.__iterateUncached=function(i,o){function u(t,c){t.__iterate(function(t,o){return(!e||c0}function st(t,e,r,n){var i=ft(t),o=new er(r).map(function(t){return t.size});return i.size=n?o.max():o.min(),i.__iterate=function(t,e){for(var r,n=this,i=this.__iterator(Ne,e),o=0;!(r=i.next()).done&&t(r.value,o++,n)!==!1;);return o},i.__iteratorUncached=function(t,i){var o=r.map(function(t){return t=Ce(t),O(i?t.reverse():t)}),u=0,s=!1;return new Xe(function(){var r;return s||(r=o.map(function(t){return t.next()}),s=n?r.every(function(t){return t.done}):r.some(function(t){return t.done})),s?S():z(t,u++,e.apply(null,r.map(function(t){return t.value})))})},i}function at(t,e){return t===e?t:q(t)?e:t.constructor(e)}function ct(t){if(t!==Object(t))throw new TypeError("Expected [K, V] tuple: "+t)}function ht(t){return v(t)?We:y(t)?Be:Je}function ft(t){return Object.create((v(t)?Ge:y(t)?Ze:$e).prototype)}function pt(){return this._iter.cacheResult?(this._iter.cacheResult(), -this.size=this._iter.size,this):Fe.prototype.cacheResult.call(this)}function _t(t,e){return void 0===t&&void 0===e?0:void 0===t?1:void 0===e?-1:t>e?1:t>>r)&xe,s=(0===r?n:n>>>r)&xe;return new Or(e,1<>>=1)u[s]=1&r?e[o++]:void 0;return u[n]=i,new Mr(t,o+1,u)}function xt(t,e,r){for(var n=[],i=0;i>1&1431655765,t=(858993459&t)+(t>>2&858993459),t=t+(t>>4)&252645135,t+=t>>8,127&(t+=t>>16)}function Kt(t,e,r,n){var o=n?t:i(t);return o[e]=r,o}function Lt(t,e,r,n){var i=t.length+1;if(n&&e+1===i)return t[e]=r,t;for(var o=Array(i),u=0,s=0;so?0:o-r,c=u-r;return c>Ee&&(c=Ee),function(){if(i===c)return Cr;var t=e?--c:i++;return n&&n[t]}}function i(t,n,i){var s,a=t&&t.array,c=i>o?0:o-i>>n,h=1+(u-i>>n);return h>Ee&&(h=Ee),function(){for(;;){if(s){var t=s();if(t!==Cr)return t;s=null}if(c===h)return Cr;var o=e?--h:c++;s=r(a&&a[o],n-qe,i+(o<=t.size||r<0)return t.withMutations(function(t){r<0?Yt(t,r).set(0,n):Yt(t,0,r+1).set(r,n)});r+=t._origin;var i=t._tail,o=t._root,s=e(Ae);return r>=Xt(t._capacity)?i=Nt(i,t.__ownerID,0,r,n,s):o=Nt(o,t.__ownerID,t._level,r,n,s),s.value?t.__ownerID?(t._root=o,t._tail=i,t.__hash=void 0,t.__altered=!0,t):Bt(t._origin,t._capacity,t._level,o,i):t}function Nt(t,e,n,i,o,u){var s=i>>>n&xe,a=t&&s0){var h=t&&t.array[s],f=Nt(h,e,n-qe,i,o,u);return f===h?t:(c=Vt(t,e),c.array[s]=f,c)}return a&&t.array[s]===o?t:(r(u),c=Vt(t,e),void 0===o&&s===c.array.length-1?c.array.pop():c.array[s]=o,c)}function Vt(t,e){return e&&t&&e===t.ownerID?t:new Lr(t?t.array.slice():[],e)}function Ht(t,e){if(e>=Xt(t._capacity))return t._tail;if(e<1<0;)r=r.array[e>>>n&xe],n-=qe;return r}}function Yt(t,e,r){void 0!==e&&(e|=0),void 0!==r&&(r|=0);var i=t.__ownerID||new n,o=t._origin,u=t._capacity,s=o+e,a=void 0===r?u:r<0?u+r:o+r;if(s===o&&a===u)return t;if(s>=a)return t.clear();for(var c=t._level,h=t._root,f=0;s+f<0;)h=new Lr(h&&h.array.length?[void 0,h]:[],i),c+=qe,f+=1<=1<p?new Lr([],i):l;if(l&&_>p&&sqe;d-=qe){var g=p>>>d&xe;y=y.array[g]=Vt(y.array[g],i)}y.array[p>>>qe&xe]=l}if(a=_)s-=_,a-=_,c=qe,h=null,v=v&&v.removeBefore(i,0,s);else if(s>o||_>>c&xe;if(m!==_>>>c&xe)break;m&&(f+=(1<o&&(h=h.removeBefore(i,c,s-f)),h&&_i&&(i=s.size),l(u)||(s=s.map(function(t){return U(t)})),n.push(s)} -return i>t.size&&(t=t.setSize(i)),At(t,e,n)}function Xt(t){return t>>qe<=Ee&&u.size>=2*o.size?(i=u.filter(function(t,e){return void 0!==t&&s!==e}),n=i.toKeyedSeq().map(function(t){return t[0]}).flip().toMap(),t.__ownerID&&(n.__ownerID=i.__ownerID=t.__ownerID)):(n=o.remove(e),i=s===u.size-1?u.pop():u.set(s,void 0))}else if(a){if(r===u.get(s)[1])return t;n=o,i=u.set(s,[e,r])}else n=o.set(e,u.size),i=u.set(u.size,[e,r]);return t.__ownerID?(t.size=n.size,t._map=n,t._list=i,t.__hash=void 0,t):Gt(n,i)}function te(t){return!(!t||!t[Pr])}function ee(t,e,r,n){var i=Object.create(Nr);return i.size=t,i._head=e,i.__ownerID=r,i.__hash=n,i.__altered=!1,i}function re(){return Vr||(Vr=ee(0))}function ne(t,e){if(t===e)return!0;if(!l(e)||void 0!==t.size&&void 0!==e.size&&t.size!==e.size||void 0!==t.__hash&&void 0!==e.__hash&&t.__hash!==e.__hash||v(t)!==v(e)||y(t)!==y(e)||g(t)!==g(e))return!1;if(0===t.size&&0===e.size)return!0;var r=!d(t);if(g(t)){var n=t.entries();return e.every(function(t,e){var i=n.next().value;return i&&R(i[1],t)&&(r||R(i[0],e))})&&n.next().done}var i=!1;if(void 0===t.size)if(void 0===e.size)"function"==typeof t.cacheResult&&t.cacheResult();else{i=!0;var o=t;t=e,e=o}var u=!0,s=e.__iterate(function(e,n){if(r?!t.has(e):i?!R(e,t.get(n,je)):!R(t.get(n,je),e))return u=!1,!1});return u&&t.size===s}function ie(t,e){var r=function(r){t.prototype[r]=e[r]};return Object.keys(e).forEach(r),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(e).forEach(r),t}function oe(t){return!(!t||!t[Yr])}function ue(t,e){return t.__ownerID?(t.size=e.size,t._map=e,t):e===t._map?t:0===e.size?t.__empty():t.__make(e)}function se(t,e){var r=Object.create(Qr);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r} -function ae(){return Xr||(Xr=se(St()))}function ce(t,e,r,n,i,o){return yt(t.size),t.__iterate(function(t,o,u){i?(i=!1,r=t):r=e.call(n,r,t,o,u)},o),r}function he(t,e){return e}function fe(t,e){return[e,t]}function pe(t){return t&&"function"==typeof t.toJS?t.toJS():t}function _e(t){return function(){return!t.apply(this,arguments)}}function le(t){return function(){return-t.apply(this,arguments)}}function ve(){return i(arguments)}function ye(t,e){return te?-1:0}function de(t){if(t.size===1/0)return 0;var e=g(t),r=v(t),n=e?1:0;return ge(t.__iterate(r?e?function(t,e){n=31*n+me(W(t),W(e))|0}:function(t,e){n=n+me(W(t),W(e))|0}:e?function(t){n=31*n+W(t)|0}:function(t){n=n+W(t)|0}),n)}function ge(t,e){return e=sr(e,3432918353),e=sr(e<<15|e>>>-15,461845907),e=sr(e<<13|e>>>-13,5),e=(e+3864292196|0)^t,e=sr(e^e>>>16,2246822507),e=sr(e^e>>>13,3266489909),e=C(e^e>>>16)}function me(t,e){return t^e+2654435769+(t<<6)+(t>>2)|0}function we(t){if("object"!=typeof console||!console.warn)throw Error(t);console.warn(t)}function ze(t){return oe(t)&&g(t)}function Se(t,e){var r=Object.create(rn);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function Ie(){return nn||(nn=Se(Zt()))}function be(t,e,r){var n=Object.create(Object.getPrototypeOf(t));return n._values=e,n.__ownerID=r,n}function Oe(t){return t._name||t.constructor.name||"Record"}function Me(t){return x(t._keys.map(function(e){return[e,t.get(e)]}))}function De(t,e){try{Object.defineProperty(t,e,{get:function(){return this.get(e)},set:function(t){vt(this.__ownerID,"Cannot set on an immutable record."),this.set(e,t)}})}catch(t){}}var qe=5,Ee=1<=n.length){var e=r.next();if(e.done)return e;n[i]=e.value}return z(t,i,n[i++])})},e}(Ze),sr="function"==typeof Math.imul&&Math.imul(4294967295,2)===-2?Math.imul:function(t,e){t|=0,e|=0;var r=65535&t,n=65535&e;return r*n+((t>>>16)*n+r*(e>>>16)<<16>>>0)|0},ar=Object.isExtensible,cr=function(){try{return Object.defineProperty({},"@",{}),!0}catch(t){return!1}}(),hr="function"==typeof WeakMap;hr&&(ir=new WeakMap);var fr=0,pr="__immutablehash__";"function"==typeof Symbol&&(pr=Symbol(pr));var _r=16,lr=255,vr=0,yr={},dr=function(t){function e(t,e){this._iter=t,this._useKeys=e,this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t,e){return this._iter.get(t,e)},e.prototype.has=function(t){return this._iter.has(t)},e.prototype.valueSeq=function(){return this._iter.valueSeq()},e.prototype.reverse=function(){var t=this,e=Y(this,!0);return this._useKeys||(e.valueSeq=function(){return t._iter.toSeq().reverse()}),e},e.prototype.map=function(t,e){var r=this,n=H(this,t,e);return this._useKeys||(n.valueSeq=function(){ -return r._iter.toSeq().map(t,e)}),n},e.prototype.__iterate=function(t,e){var r=this;return this._iter.__iterate(function(e,n){return t(e,n,r)},e)},e.prototype.__iterator=function(t,e){return this._iter.__iterator(t,e)},e}(Ge);dr.prototype[Le]=!0;var gr=function(t){function e(t){this._iter=t,this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.includes=function(t){return this._iter.includes(t)},e.prototype.__iterate=function(t,e){var r=this,n=0;return e&&o(this),this._iter.__iterate(function(i){return t(i,e?r.size-++n:n++,r)},e)},e.prototype.__iterator=function(t,e){var r=this,n=this._iter.__iterator(Ne,e),i=0;return e&&o(this),new Xe(function(){var o=n.next();return o.done?o:z(t,e?r.size-++i:i++,o.value,o)})},e}(Ze),mr=function(t){function e(t){this._iter=t,this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.has=function(t){return this._iter.includes(t)},e.prototype.__iterate=function(t,e){var r=this;return this._iter.__iterate(function(e){return t(e,e,r)},e)},e.prototype.__iterator=function(t,e){var r=this._iter.__iterator(Ne,e);return new Xe(function(){var e=r.next();return e.done?e:z(t,e.value,e.value,e)})},e}($e),wr=function(t){function e(t){this._iter=t,this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.entrySeq=function(){return this._iter.toSeq()},e.prototype.__iterate=function(t,e){var r=this;return this._iter.__iterate(function(e){if(e){ct(e);var n=l(e);return t(n?e.get(1):e[1],n?e.get(0):e[0],r)}},e)},e.prototype.__iterator=function(t,e){var r=this._iter.__iterator(Ne,e);return new Xe(function(){for(;;){var e=r.next();if(e.done)return e;var n=e.value;if(n){ct(n);var i=l(n);return z(t,i?n.get(0):n[0],i?n.get(1):n[1],e)}}})},e}(Ge);gr.prototype.cacheResult=dr.prototype.cacheResult=mr.prototype.cacheResult=wr.prototype.cacheResult=pt;var zr=function(t){function e(e){ -return null===e||void 0===e?St():gt(e)&&!g(e)?e:St().withMutations(function(r){var n=t(e);yt(n.size),n.forEach(function(t,e){return r.set(e,t)})})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return St().withMutations(function(e){for(var r=0;r=t.length)throw Error("Missing value for key: "+t[r]);e.set(t[r],t[r+1])}})},e.prototype.toString=function(){return this.__toString("Map {","}")},e.prototype.get=function(t,e){return this._root?this._root.get(0,void 0,t,e):e},e.prototype.set=function(t,e){return It(this,t,e)},e.prototype.setIn=function(t,e){return this.updateIn(t,je,function(){return e})},e.prototype.remove=function(t){return It(this,t,je)},e.prototype.deleteIn=function(t){if(t=[].concat(lt(t)),t.length){var e=t.pop();return this.updateIn(t,function(t){return t&&t.remove(e)})}},e.prototype.deleteAll=function(t){var e=Ce(t);return 0===e.size?this:this.withMutations(function(t){e.forEach(function(e){return t.remove(e)})})},e.prototype.update=function(t,e,r){return 1===arguments.length?t(this):this.updateIn([t],e,r)},e.prototype.updateIn=function(t,e,r){r||(r=e,e=void 0);var n=Rt(this,lt(t),0,e,r);return n===je?e:n},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):St()},e.prototype.merge=function(){return xt(this,void 0,arguments)},e.prototype.mergeWith=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return xt(this,t,e)},e.prototype.mergeIn=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return this.updateIn(t,St(),function(t){return"function"==typeof t.merge?t.merge.apply(t,e):e[e.length-1]})},e.prototype.mergeDeep=function(){return xt(this,jt,arguments)},e.prototype.mergeDeepWith=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return xt(this,kt(t),e)},e.prototype.mergeDeepIn=function(t){ -for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return this.updateIn(t,St(),function(t){return"function"==typeof t.mergeDeep?t.mergeDeep.apply(t,e):e[e.length-1]})},e.prototype.sort=function(t){return Wr(it(this,t))},e.prototype.sortBy=function(t,e){return Wr(it(this,e,t))},e.prototype.withMutations=function(t){var e=this.asMutable();return t(e),e.wasAltered()?e.__ensureOwner(this.__ownerID):this},e.prototype.asMutable=function(){return this.__ownerID?this:this.__ensureOwner(new n)},e.prototype.asImmutable=function(){return this.__ensureOwner()},e.prototype.wasAltered=function(){return this.__altered},e.prototype.__iterator=function(t,e){return new xr(this,t,e)},e.prototype.__iterate=function(t,e){var r=this,n=0;return this._root&&this._root.iterate(function(e){return n++,t(e[1],e[0],r)},e),n},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?zt(this.size,this._root,t,this.__hash):0===this.size?St():(this.__ownerID=t,this.__altered=!1,this)},e}(We);zr.isMap=gt;var Sr="@@__IMMUTABLE_MAP__@@",Ir=zr.prototype;Ir[Sr]=!0,Ir.delete=Ir.remove,Ir.removeIn=Ir.deleteIn,Ir.removeAll=Ir.deleteAll,Ir["@@transducer/init"]=Ir.asMutable,Ir["@@transducer/step"]=function(t,e){return t.set(e[0],e[1])},Ir["@@transducer/result"]=function(t){return t.asImmutable()};var br=function(t,e){this.ownerID=t,this.entries=e};br.prototype.get=function(t,e,r,n){for(var i=this.entries,o=0,u=i.length;o=jr)return Dt(t,h,o,u);var l=t&&t===this.ownerID,v=l?h:i(h);return _?c?f===p-1?v.pop():v[f]=v.pop():v[f]=[o,u]:v.push([o,u]),l?(this.entries=v,this):new br(t,v)}};var Or=function(t,e,r){this.ownerID=t,this.bitmap=e,this.nodes=r};Or.prototype.get=function(t,e,r,n){void 0===e&&(e=W(r));var i=1<<((0===t?e:e>>>t)&xe),o=this.bitmap -;return 0==(o&i)?n:this.nodes[Ut(o&i-1)].get(t+qe,e,r,n)},Or.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=W(n));var s=(0===e?r:r>>>e)&xe,a=1<=kr)return Et(t,p,c,s,l);if(h&&!l&&2===p.length&&Ot(p[1^f]))return p[1^f];if(h&&l&&1===p.length&&Ot(l))return l;var v=t&&t===this.ownerID,y=h?l?c:c^a:c|a,d=h?l?Kt(p,f,l,v):Tt(p,f,v):Lt(p,f,l,v);return v?(this.bitmap=y,this.nodes=d,this):new Or(t,y,d)};var Mr=function(t,e,r){this.ownerID=t,this.count=e,this.nodes=r};Mr.prototype.get=function(t,e,r,n){void 0===e&&(e=W(r));var i=(0===t?e:e>>>t)&xe,o=this.nodes[i];return o?o.get(t+qe,e,r,n):n},Mr.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=W(n));var s=(0===e?r:r>>>e)&xe,a=i===je,c=this.nodes,h=c[s];if(a&&!h)return this;var f=bt(h,t,e+qe,r,n,i,o,u);if(f===h)return this;var p=this.count;if(h){if(!f&&--p0&&i=0&&t0;)e[r]=arguments[r+1];return Qt(this,t,e)},e.prototype.mergeDeep=function(){return Qt(this,jt,arguments)},e.prototype.mergeDeepWith=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Qt(this,kt(t),e)},e.prototype.setSize=function(t){return Yt(this,0,t)},e.prototype.slice=function(t,e){var r=this.size;return a(t,e,r)?this:Yt(this,c(t,r),h(e,r))},e.prototype.__iterator=function(t,e){var r=e?this.size:0,n=Wt(this,e);return new Xe(function(){var i=n();return i===Cr?S():z(t,e?--r:r++,i)})},e.prototype.__iterate=function(t,e){for(var r,n=this,i=e?this.size:0,o=Wt(this,e);(r=o())!==Cr&&t(r,e?--i:i++,n)!==!1;);return i},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Bt(this._origin,this._capacity,this._level,this._root,this._tail,t,this.__hash):0===this.size?Jt():(this.__ownerID=t,this)},e}(Be);Rr.isList=Ct;var Ur="@@__IMMUTABLE_LIST__@@",Kr=Rr.prototype;Kr[Ur]=!0,Kr.delete=Kr.remove,Kr.setIn=Ir.setIn,Kr.deleteIn=Kr.removeIn=Ir.removeIn,Kr.update=Ir.update,Kr.updateIn=Ir.updateIn,Kr.mergeIn=Ir.mergeIn,Kr.mergeDeepIn=Ir.mergeDeepIn,Kr.withMutations=Ir.withMutations,Kr.asMutable=Ir.asMutable,Kr.asImmutable=Ir.asImmutable,Kr.wasAltered=Ir.wasAltered,Kr["@@transducer/init"]=Kr.asMutable,Kr["@@transducer/step"]=function(t,e){return t.push(e)}, -Kr["@@transducer/result"]=Ir["@@transducer/result"];var Lr=function(t,e){this.array=t,this.ownerID=e};Lr.prototype.removeBefore=function(t,e,r){if(r===e?1<>>e&xe;if(n>=this.array.length)return new Lr([],t);var i,o=0===n;if(e>0){var u=this.array[n];if((i=u&&u.removeBefore(t,e-qe,r))===u&&o)return this}if(o&&!i)return this;var s=Vt(this,t);if(!o)for(var a=0;a>>e&xe;if(n>=this.array.length)return this;var i;if(e>0){var o=this.array[n];if((i=o&&o.removeAfter(t,e-qe,r))===o&&n===this.array.length-1)return this}var u=Vt(this,t);return u.array.splice(n+1),i&&(u.array[n]=i),u};var Tr,Cr={},Wr=function(t){function e(t){return null===t||void 0===t?Zt():Ft(t)?t:Zt().withMutations(function(e){var r=We(t);yt(r.size),r.forEach(function(t,r){return e.set(r,t)})})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("OrderedMap {","}")},e.prototype.get=function(t,e){var r=this._map.get(t);return void 0!==r?this._list.get(r)[1]:e},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._map.clear(),this._list.clear(),this):Zt()},e.prototype.set=function(t,e){return $t(this,t,e)},e.prototype.remove=function(t){return $t(this,t,je)},e.prototype.wasAltered=function(){return this._map.wasAltered()||this._list.wasAltered()},e.prototype.__iterate=function(t,e){var r=this;return this._list.__iterate(function(e){return e&&t(e[1],e[0],r)},e)},e.prototype.__iterator=function(t,e){return this._list.fromEntrySeq().__iterator(t,e)},e.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var e=this._map.__ensureOwner(t),r=this._list.__ensureOwner(t);return t?Gt(e,r,t,this.__hash):0===this.size?Zt():(this.__ownerID=t,this._map=e,this._list=r,this)},e}(zr) -;Wr.isOrderedMap=Ft,Wr.prototype[Le]=!0,Wr.prototype.delete=Wr.prototype.remove;var Br,Jr=function(t){function e(t){return null===t||void 0===t?re():te(t)?t:re().pushAll(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("Stack [","]")},e.prototype.get=function(t,e){var r=this._head;for(t=u(this,t);r&&t--;)r=r.next;return r?r.value:e},e.prototype.peek=function(){return this._head&&this._head.value},e.prototype.push=function(){var t=arguments;if(0===arguments.length)return this;for(var e=this.size+arguments.length,r=this._head,n=arguments.length-1;n>=0;n--)r={value:t[n],next:r};return this.__ownerID?(this.size=e,this._head=r,this.__hash=void 0,this.__altered=!0,this):ee(e,r)},e.prototype.pushAll=function(e){if(e=t(e),0===e.size)return this;if(0===this.size&&te(e))return e;yt(e.size);var r=this.size,n=this._head;return e.__iterate(function(t){r++,n={value:t,next:n}},!0),this.__ownerID?(this.size=r,this._head=n,this.__hash=void 0,this.__altered=!0,this):ee(r,n)},e.prototype.pop=function(){return this.slice(1)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):re()},e.prototype.slice=function(e,r){if(a(e,r,this.size))return this;var n=c(e,this.size);if(h(r,this.size)!==this.size)return t.prototype.slice.call(this,e,r);for(var i=this.size-n,o=this._head;n--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):ee(i,o)},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?ee(this.size,this._head,t,this.__hash):0===this.size?re():(this.__ownerID=t,this.__altered=!1,this)},e.prototype.__iterate=function(t,e){var r=this;if(e)return new er(this.toArray()).__iterate(function(e,n){return t(e,n,r)},e);for(var n=0,i=this._head;i&&t(i.value,n++,r)!==!1;)i=i.next;return n},e.prototype.__iterator=function(t,e){ -if(e)return new er(this.toArray()).__iterator(t,e);var r=0,n=this._head;return new Xe(function(){if(n){var e=n.value;return n=n.next,z(t,r++,e)}return S()})},e}(Be);Jr.isStack=te;var Pr="@@__IMMUTABLE_STACK__@@",Nr=Jr.prototype;Nr[Pr]=!0,Nr.withMutations=Ir.withMutations,Nr.asMutable=Ir.asMutable,Nr.asImmutable=Ir.asImmutable,Nr.wasAltered=Ir.wasAltered,Nr.shift=Nr.pop,Nr.unshift=Nr.push,Nr.unshiftAll=Nr.pushAll,Nr["@@transducer/init"]=Nr.asMutable,Nr["@@transducer/step"]=function(t,e){return t.unshift(e)},Nr["@@transducer/result"]=Ir["@@transducer/result"];var Vr,Hr=function(t){function e(e){return null===e||void 0===e?ae():oe(e)&&!g(e)?e:ae().withMutations(function(r){var n=t(e);yt(n.size),n.forEach(function(t){return r.add(t)})})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(We(t).keySeq())},e.intersect=function(t){return t=Ce(t).toArray(),t.length?Qr.intersect.apply(e(t.pop()),t):ae()},e.union=function(t){return t=Ce(t).toArray(),t.length?Qr.union.apply(e(t.pop()),t):ae()},e.prototype.toString=function(){return this.__toString("Set {","}")},e.prototype.has=function(t){return this._map.has(t)},e.prototype.add=function(t){return ue(this,this._map.set(t,!0))},e.prototype.remove=function(t){return ue(this,this._map.remove(t))},e.prototype.clear=function(){return ue(this,this._map.clear())},e.prototype.union=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return e=e.filter(function(t){return 0!==t.size}),0===e.length?this:0!==this.size||this.__ownerID||1!==e.length?this.withMutations(function(r){for(var n=0;n0;)e[r]=arguments[r+1];return this.union.apply(this,e)},e.prototype.sort=function(t){return en(it(this,t))},e.prototype.sortBy=function(t,e){return en(it(this,e,t))},e.prototype.wasAltered=function(){return this._map.wasAltered()},e.prototype.__iterate=function(t,e){var r=this;return this._map.__iterate(function(e,n){return t(n,n,r)},e)},e.prototype.__iterator=function(t,e){return this._map.map(function(t,e){return e}).__iterator(t,e)},e.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var e=this._map.__ensureOwner(t);return t?this.__make(e,t):0===this.size?ae():(this.__ownerID=t,this._map=e,this)},e}(Je);Hr.isSet=oe;var Yr="@@__IMMUTABLE_SET__@@",Qr=Hr.prototype;Qr[Yr]=!0,Qr.delete=Qr.remove,Qr.mergeDeep=Qr.merge,Qr.mergeDeepWith=Qr.mergeWith,Qr.withMutations=Ir.withMutations,Qr.asMutable=Ir.asMutable,Qr.asImmutable=Ir.asImmutable,Qr["@@transducer/init"]=Qr.asMutable,Qr["@@transducer/step"]=function(t,e){return t.add(e)},Qr["@@transducer/result"]=Ir["@@transducer/result"],Qr.__empty=ae,Qr.__make=se;var Xr,Fr,Gr=function(t){function e(t,r,n){if(!(this instanceof e))return new e(t,r,n);if(vt(0!==n,"Cannot step a Range by 0"),t=t||0,void 0===r&&(r=1/0),n=void 0===n?1:Math.abs(n),r=0&&e=0&&rthis.size?e:this.find(function(e,r){return r===t},void 0,e)},has:function(t){return(t=u(this,t))>=0&&(void 0!==this.size?this.size===1/0||t>>0;if(""+r!==e||4294967295===r)return NaN;e=r}return e<0?o(t)+e:e}function s(){return!0}function a(t,e,r){return(0===t&&!p(t)||void 0!==r&&t<=-r)&&(void 0===e||void 0!==r&&e>=r)}function c(t,e){return f(t,e,0)}function h(t,e){return f(t,e,e)}function f(t,e,r){return void 0===t?r:p(t)?e===1/0?e:0|Math.max(0,e+t):void 0===e||e===t?t:0|Math.min(e,t)}function p(t){return t<0||0===t&&1/t==-(1/0)}function _(t){return(l(t)||m(t))&&!t.__ownerID}function l(t){return!(!t||!t[Ue])}function v(t){return!(!t||!t[Ke])}function y(t){return!(!t||!t[Le])}function d(t){return v(t)||y(t)}function g(t){return!(!t||!t[Te])}function m(t){return!(!t||!t[Ce])}function w(t){return!(!t||"function"!=typeof t.equals||"function"!=typeof t.hashCode)}function z(t,e,r,n){var i=0===t?e:1===t?r:[e,r];return n?n.value=i:n={value:i,done:!1},n}function S(){return{value:void 0,done:!0}}function I(t){return!!M(t)}function b(t){return t&&"function"==typeof t.next}function O(t){var e=M(t);return e&&e.call(t)}function M(t){var e=t&&(Ye&&t[Ye]||t[Qe]);if("function"==typeof e)return e}function D(t){return t&&"number"==typeof t.length}function q(t){return!(!t||!t[er])}function E(){return ir||(ir=new rr([]))}function x(t){var e=Array.isArray(t)?new rr(t):b(t)?new sr(t):I(t)?new ur(t):void 0;if(e)return e.fromEntrySeq();if("object"==typeof t)return new nr(t);throw new TypeError("Expected Array or collection object of [k, v] entries, or keyed object: "+t)}function j(t){var e=A(t);if(e)return e;throw new TypeError("Expected Array or collection object of values: "+t)} +function k(t){var e=A(t);if(e)return e;if("object"==typeof t)return new nr(t);throw new TypeError("Expected Array or collection object of values, or keyed object: "+t)}function A(t){return D(t)?new rr(t):b(t)?new sr(t):I(t)?new ur(t):void 0}function R(t,e){if(t===e||t!==t&&e!==e)return!0;if(!t||!e)return!1;if("function"==typeof t.valueOf&&"function"==typeof e.valueOf){if(t=t.valueOf(),e=e.valueOf(),t===e||t!==t&&e!==e)return!0;if(!t||!e)return!1}return!!(w(t)&&w(e)&&t.equals(e))}function U(t,e){return K([],e||L,t,"",e&&e.length>2?[]:void 0,{"":t})}function K(t,e,r,n,i,o){var u=Array.isArray(r)?$e:T(r)?Ze:null;if(u){if(~t.indexOf(r))throw new TypeError("Cannot convert circular structure to Immutable");t.push(r),i&&""!==n&&i.push(n);var s=e.call(o,n,u(r).map(function(n,o){return K(t,e,n,o,i,r)}),i&&i.slice());return t.pop(),i&&i.pop(),s}return r}function L(t,e){return v(e)?e.toMap():e.toList()}function T(t){return t&&(t.constructor===Object||void 0===t.constructor)}function C(t){return t>>>1&1073741824|3221225471&t}function W(t){if(t===!1||null===t||void 0===t)return 0;if("function"==typeof t.valueOf&&((t=t.valueOf())===!1||null===t||void 0===t))return 0;if(t===!0)return 1;var e=typeof t;if("number"===e){if(t!==t||t===1/0)return 0;var r=0|t;for(r!==t&&(r^=4294967295*t);t>4294967295;)t/=4294967295,r^=t;return C(r)}if("string"===e)return t.length>lr?B(t):J(t);if("function"==typeof t.hashCode)return C(t.hashCode());if("object"===e)return P(t);if("function"==typeof t.toString)return J(""+t);throw Error("Value type "+e+" cannot be hashed.")}function B(t){var e=dr[t];return void 0===e&&(e=J(t),yr===vr&&(yr=0,dr={}),yr++,dr[t]=e),e}function J(t){for(var e=0,r=0;r0)switch(t.nodeType){case 1:return t.uniqueID;case 9:return t.documentElement&&t.documentElement.uniqueID}}function V(t){var e=ft(t);return e._iter=t,e.size=t.size,e.flip=function(){return t},e.reverse=function(){var e=t.reverse.apply(this);return e.flip=function(){return t.reverse()},e},e.has=function(e){return t.includes(e)},e.includes=function(e){return t.has(e)},e.cacheResult=pt,e.__iterateUncached=function(e,r){var n=this;return t.__iterate(function(t,r){return e(r,t,n)!==!1},r)},e.__iteratorUncached=function(e,r){if(e===He){var n=t.__iterator(e,r);return new Fe(function(){var t=n.next();if(!t.done){var e=t.value[0];t.value[0]=t.value[1],t.value[1]=e}return t})}return t.__iterator(e===Ve?Ne:Ve,r)},e}function H(t,e,r){var n=ft(t);return n.size=t.size,n.has=function(e){return t.has(e)},n.get=function(n,i){var o=t.get(n,ke);return o===ke?i:e.call(r,o,n,t)},n.__iterateUncached=function(n,i){var o=this;return t.__iterate(function(t,i,u){return n(e.call(r,t,i,u),i,o)!==!1},i)},n.__iteratorUncached=function(n,i){var o=t.__iterator(He,i);return new Fe(function(){var i=o.next();if(i.done)return i;var u=i.value,s=u[0];return z(n,s,e.call(r,u[1],s,t),i)})},n}function Y(t,e){var r=this,n=ft(t);return n._iter=t,n.size=t.size,n.reverse=function(){return t},t.flip&&(n.flip=function(){var e=V(t);return e.reverse=function(){return t.flip()},e}),n.get=function(r,n){return t.get(e?r:-1-r,n)},n.has=function(r){return t.has(e?r:-1-r)},n.includes=function(e){ +return t.includes(e)},n.cacheResult=pt,n.__iterate=function(r,n){var i=this,u=0;return n&&o(t),t.__iterate(function(t,o){return r(t,e?o:n?i.size-++u:u++,i)},!n)},n.__iterator=function(n,i){var u=0;i&&o(t);var s=t.__iterator(He,!i);return new Fe(function(){var t=s.next();if(t.done)return t;var o=t.value;return z(n,e?o[0]:i?r.size-++u:u++,o[1],t)})},n}function Q(t,e,r,n){var i=ft(t);return n&&(i.has=function(n){var i=t.get(n,ke);return i!==ke&&!!e.call(r,i,n,t)},i.get=function(n,i){var o=t.get(n,ke);return o!==ke&&e.call(r,o,n,t)?o:i}),i.__iterateUncached=function(i,o){var u=this,s=0;return t.__iterate(function(t,o,a){if(e.call(r,t,o,a))return s++,i(t,n?o:s-1,u)},o),s},i.__iteratorUncached=function(i,o){var u=t.__iterator(He,o),s=0;return new Fe(function(){for(;;){var o=u.next();if(o.done)return o;var a=o.value,c=a[0],h=a[1];if(e.call(r,h,c,t))return z(i,n?c:s++,h,o)}})},i}function X(t,e,r){var n=Sr().asMutable();return t.__iterate(function(i,o){n.update(e.call(r,i,o,t),0,function(t){return t+1})}),n.asImmutable()}function F(t,e,r){var n=v(t),i=(g(t)?Br():Sr()).asMutable();t.__iterate(function(o,u){i.update(e.call(r,o,u,t),function(t){return t=t||[],t.push(n?[u,o]:o),t})});var o=ht(t);return i.map(function(e){return at(t,o(e))})}function G(t,e,r,n){var i=t.size;if(a(e,r,i))return t;var o=c(e,i),s=h(r,i);if(o!==o||s!==s)return G(t.toSeq().cacheResult(),e,r,n);var f,p=s-o;p===p&&(f=p<0?0:p);var _=ft(t);return _.size=0===f?f:t.size&&f||void 0,!n&&q(t)&&f>=0&&(_.get=function(e,r){return e=u(this,e),e>=0&&ef)return S();var t=i.next() +;return n||e===Ve?t:e===Ne?z(e,s-1,void 0,t):z(e,s-1,t.value[1],t)})},_}function Z(t,e,r){var n=ft(t);return n.__iterateUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterate(n,i);var u=0;return t.__iterate(function(t,i,s){return e.call(r,t,i,s)&&++u&&n(t,i,o)}),u},n.__iteratorUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterator(n,i);var u=t.__iterator(He,i),s=!0;return new Fe(function(){if(!s)return S();var t=u.next();if(t.done)return t;var i=t.value,a=i[0],c=i[1];return e.call(r,c,a,o)?n===He?t:z(n,a,c,t):(s=!1,S())})},n}function $(t,e,r,n){var i=ft(t);return i.__iterateUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterate(i,o);var s=!0,a=0;return t.__iterate(function(t,o,c){if(!s||!(s=e.call(r,t,o,c)))return a++,i(t,n?o:a-1,u)}),a},i.__iteratorUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterator(i,o);var s=t.__iterator(He,o),a=!0,c=0;return new Fe(function(){var t,o,h;do{if(t=s.next(),t.done)return n||i===Ve?t:i===Ne?z(i,c++,void 0,t):z(i,c++,t.value[1],t);var f=t.value;o=f[0],h=f[1],a&&(a=e.call(r,h,o,u))}while(a);return i===He?t:z(i,o,h,t)})},i}function tt(t,e){var r=v(t),n=[t].concat(e).map(function(t){return l(t)?r&&(t=Be(t)):t=r?x(t):j(Array.isArray(t)?t:[t]),t}).filter(function(t){return 0!==t.size});if(0===n.length)return t;if(1===n.length){var i=n[0];if(i===t||r&&v(i)||y(t)&&y(i))return i}var o=new rr(n);return r?o=o.toKeyedSeq():y(t)||(o=o.toSetSeq()),o=o.flatten(!0),o.size=n.reduce(function(t,e){if(void 0!==t){var r=e.size;if(void 0!==r)return t+r}},0),o}function et(t,e,r){var n=ft(t);return n.__iterateUncached=function(i,o){function u(t,c){t.__iterate(function(t,o){return(!e||c0}function st(t,e,r,n){var i=ft(t),o=new rr(r).map(function(t){return t.size});return i.size=n?o.max():o.min(),i.__iterate=function(t,e){for(var r,n=this,i=this.__iterator(Ve,e),o=0;!(r=i.next()).done&&t(r.value,o++,n)!==!1;);return o},i.__iteratorUncached=function(t,i){var o=r.map(function(t){return t=We(t),O(i?t.reverse():t)}),u=0,s=!1;return new Fe(function(){var r;return s||(r=o.map(function(t){return t.next()}),s=n?r.every(function(t){return t.done}):r.some(function(t){return t.done})),s?S():z(t,u++,e.apply(null,r.map(function(t){return t.value})))})},i}function at(t,e){return t===e?t:q(t)?e:t.constructor(e)}function ct(t){if(t!==Object(t))throw new TypeError("Expected [K, V] tuple: "+t)}function ht(t){return v(t)?Be:y(t)?Je:Pe}function ft(t){return Object.create((v(t)?Ze:y(t)?$e:tr).prototype)}function pt(){return this._iter.cacheResult?(this._iter.cacheResult(), +this.size=this._iter.size,this):Ge.prototype.cacheResult.call(this)}function _t(t,e){return void 0===t&&void 0===e?0:void 0===t?1:void 0===e?-1:t>e?1:t>>r)&je,s=(0===r?n:n>>>r)&je;return new Mr(e,1<>>=1)u[s]=1&r?e[o++]:void 0;return u[n]=i,new Dr(t,o+1,u)}function xt(t,e,r){for(var n=[],i=0;i>1&1431655765,t=(858993459&t)+(t>>2&858993459),t=t+(t>>4)&252645135,t+=t>>8,127&(t+=t>>16)}function Kt(t,e,r,n){var o=n?t:i(t);return o[e]=r,o}function Lt(t,e,r,n){var i=t.length+1;if(n&&e+1===i)return t[e]=r,t;for(var o=Array(i),u=0,s=0;so?0:o-r,c=u-r;return c>xe&&(c=xe),function(){if(i===c)return Wr;var t=e?--c:i++;return n&&n[t]}}function i(t,n,i){var s,a=t&&t.array,c=i>o?0:o-i>>n,h=1+(u-i>>n);return h>xe&&(h=xe),function(){for(;;){if(s){var t=s();if(t!==Wr)return t;s=null}if(c===h)return Wr;var o=e?--h:c++;s=r(a&&a[o],n-Ee,i+(o<=t.size||r<0)return t.withMutations(function(t){r<0?Yt(t,r).set(0,n):Yt(t,0,r+1).set(r,n)});r+=t._origin;var i=t._tail,o=t._root,s=e(Re);return r>=Xt(t._capacity)?i=Nt(i,t.__ownerID,0,r,n,s):o=Nt(o,t.__ownerID,t._level,r,n,s),s.value?t.__ownerID?(t._root=o,t._tail=i,t.__hash=void 0,t.__altered=!0,t):Bt(t._origin,t._capacity,t._level,o,i):t}function Nt(t,e,n,i,o,u){var s=i>>>n&je,a=t&&s0){var h=t&&t.array[s],f=Nt(h,e,n-Ee,i,o,u);return f===h?t:(c=Vt(t,e),c.array[s]=f,c)}return a&&t.array[s]===o?t:(r(u),c=Vt(t,e),void 0===o&&s===c.array.length-1?c.array.pop():c.array[s]=o,c)}function Vt(t,e){return e&&t&&e===t.ownerID?t:new Tr(t?t.array.slice():[],e)}function Ht(t,e){if(e>=Xt(t._capacity))return t._tail;if(e<1<0;)r=r.array[e>>>n&je],n-=Ee;return r}}function Yt(t,e,r){void 0!==e&&(e|=0),void 0!==r&&(r|=0);var i=t.__ownerID||new n,o=t._origin,u=t._capacity,s=o+e,a=void 0===r?u:r<0?u+r:o+r;if(s===o&&a===u)return t;if(s>=a)return t.clear();for(var c=t._level,h=t._root,f=0;s+f<0;)h=new Tr(h&&h.array.length?[void 0,h]:[],i),c+=Ee,f+=1<=1<p?new Tr([],i):l;if(l&&_>p&&sEe;d-=Ee){var g=p>>>d&je;y=y.array[g]=Vt(y.array[g],i)}y.array[p>>>Ee&je]=l}if(a=_)s-=_,a-=_,c=Ee,h=null,v=v&&v.removeBefore(i,0,s);else if(s>o||_>>c&je;if(m!==_>>>c&je)break;m&&(f+=(1<o&&(h=h.removeBefore(i,c,s-f)),h&&_i&&(i=s.size),l(u)||(s=s.map(function(t){return U(t)})),n.push(s)} +return i>t.size&&(t=t.setSize(i)),At(t,e,n)}function Xt(t){return t>>Ee<=xe&&u.size>=2*o.size?(i=u.filter(function(t,e){return void 0!==t&&s!==e}),n=i.toKeyedSeq().map(function(t){return t[0]}).flip().toMap(),t.__ownerID&&(n.__ownerID=i.__ownerID=t.__ownerID)):(n=o.remove(e),i=s===u.size-1?u.pop():u.set(s,void 0))}else if(a){if(r===u.get(s)[1])return t;n=o,i=u.set(s,[e,r])}else n=o.set(e,u.size),i=u.set(u.size,[e,r]);return t.__ownerID?(t.size=n.size,t._map=n,t._list=i,t.__hash=void 0,t):Gt(n,i)}function te(t){return!(!t||!t[Nr])}function ee(t,e,r,n){var i=Object.create(Vr);return i.size=t,i._head=e,i.__ownerID=r,i.__hash=n,i.__altered=!1,i}function re(){return Hr||(Hr=ee(0))}function ne(t,e){if(t===e)return!0;if(!l(e)||void 0!==t.size&&void 0!==e.size&&t.size!==e.size||void 0!==t.__hash&&void 0!==e.__hash&&t.__hash!==e.__hash||v(t)!==v(e)||y(t)!==y(e)||g(t)!==g(e))return!1;if(0===t.size&&0===e.size)return!0;var r=!d(t);if(g(t)){var n=t.entries();return e.every(function(t,e){var i=n.next().value;return i&&R(i[1],t)&&(r||R(i[0],e))})&&n.next().done}var i=!1;if(void 0===t.size)if(void 0===e.size)"function"==typeof t.cacheResult&&t.cacheResult();else{i=!0;var o=t;t=e,e=o}var u=!0,s=e.__iterate(function(e,n){if(r?!t.has(e):i?!R(e,t.get(n,ke)):!R(t.get(n,ke),e))return u=!1,!1});return u&&t.size===s}function ie(t,e){var r=function(r){t.prototype[r]=e[r]};return Object.keys(e).forEach(r),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(e).forEach(r),t}function oe(t){return!(!t||!t[Qr])}function ue(t,e){return t.__ownerID?(t.size=e.size,t._map=e,t):e===t._map?t:0===e.size?t.__empty():t.__make(e)}function se(t,e){var r=Object.create(Xr);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r} +function ae(){return Fr||(Fr=se(St()))}function ce(t,e,r,n,i,o){return yt(t.size),t.__iterate(function(t,o,u){i?(i=!1,r=t):r=e.call(n,r,t,o,u)},o),r}function he(t,e){return e}function fe(t,e){return[e,t]}function pe(t){return t&&"function"==typeof t.toJS?t.toJS():t}function _e(t){return function(){return!t.apply(this,arguments)}}function le(t){return function(){return-t.apply(this,arguments)}}function ve(){return i(arguments)}function ye(t,e){return te?-1:0}function de(t){if(t.size===1/0)return 0;var e=g(t),r=v(t),n=e?1:0;return ge(t.__iterate(r?e?function(t,e){n=31*n+me(W(t),W(e))|0}:function(t,e){n=n+me(W(t),W(e))|0}:e?function(t){n=31*n+W(t)|0}:function(t){n=n+W(t)|0}),n)}function ge(t,e){return e=ar(e,3432918353),e=ar(e<<15|e>>>-15,461845907),e=ar(e<<13|e>>>-13,5),e=(e+3864292196|0)^t,e=ar(e^e>>>16,2246822507),e=ar(e^e>>>13,3266489909),e=C(e^e>>>16)}function me(t,e){return t^e+2654435769+(t<<6)+(t>>2)|0}function we(t){if("object"!=typeof console||!console.warn)throw Error(t);console.warn(t)}function ze(t,e,r,n){for(var i=lt(r),o=0;o!==i.length;){if(!t||!t.get)return n&&we("Invalid keyPath: Value at ["+i.slice(0,o).map(dt)+"] does not have a .get() method: "+t+"\nThis warning will throw in a future version"),e;if((t=t.get(i[o++],ke))===ke)return e}return t}function Se(t){return oe(t)&&g(t)}function Ie(t,e){var r=Object.create(nn);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function be(){return on||(on=Ie(Zt()))}function Oe(t,e,r){var n=Object.create(Object.getPrototypeOf(t));return n._values=e,n.__ownerID=r,n}function Me(t){return t._name||t.constructor.name||"Record"}function De(t){return x(t._keys.map(function(e){return[e,t.get(e)]}))}function qe(t,e){try{Object.defineProperty(t,e,{get:function(){return this.get(e)},set:function(t){vt(this.__ownerID,"Cannot set on an immutable record."),this.set(e,t)}})}catch(t){}}var Ee=5,xe=1<=n.length){var e=r.next();if(e.done)return e;n[i]=e.value}return z(t,i,n[i++])})},e}($e),ar="function"==typeof Math.imul&&Math.imul(4294967295,2)===-2?Math.imul:function(t,e){t|=0,e|=0;var r=65535&t,n=65535&e;return r*n+((t>>>16)*n+r*(e>>>16)<<16>>>0)|0},cr=Object.isExtensible,hr=function(){try{return Object.defineProperty({},"@",{}),!0}catch(t){return!1}}(),fr="function"==typeof WeakMap;fr&&(or=new WeakMap);var pr=0,_r="__immutablehash__";"function"==typeof Symbol&&(_r=Symbol(_r));var lr=16,vr=255,yr=0,dr={},gr=function(t){function e(t,e){this._iter=t,this._useKeys=e,this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t,e){return this._iter.get(t,e)}, +e.prototype.has=function(t){return this._iter.has(t)},e.prototype.valueSeq=function(){return this._iter.valueSeq()},e.prototype.reverse=function(){var t=this,e=Y(this,!0);return this._useKeys||(e.valueSeq=function(){return t._iter.toSeq().reverse()}),e},e.prototype.map=function(t,e){var r=this,n=H(this,t,e);return this._useKeys||(n.valueSeq=function(){return r._iter.toSeq().map(t,e)}),n},e.prototype.__iterate=function(t,e){var r=this;return this._iter.__iterate(function(e,n){return t(e,n,r)},e)},e.prototype.__iterator=function(t,e){return this._iter.__iterator(t,e)},e}(Ze);gr.prototype[Te]=!0;var mr=function(t){function e(t){this._iter=t,this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.includes=function(t){return this._iter.includes(t)},e.prototype.__iterate=function(t,e){var r=this,n=0;return e&&o(this),this._iter.__iterate(function(i){return t(i,e?r.size-++n:n++,r)},e)},e.prototype.__iterator=function(t,e){var r=this,n=this._iter.__iterator(Ve,e),i=0;return e&&o(this),new Fe(function(){var o=n.next();return o.done?o:z(t,e?r.size-++i:i++,o.value,o)})},e}($e),wr=function(t){function e(t){this._iter=t,this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.has=function(t){return this._iter.includes(t)},e.prototype.__iterate=function(t,e){var r=this;return this._iter.__iterate(function(e){return t(e,e,r)},e)},e.prototype.__iterator=function(t,e){var r=this._iter.__iterator(Ve,e);return new Fe(function(){var e=r.next();return e.done?e:z(t,e.value,e.value,e)})},e}(tr),zr=function(t){function e(t){this._iter=t,this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.entrySeq=function(){return this._iter.toSeq()},e.prototype.__iterate=function(t,e){var r=this;return this._iter.__iterate(function(e){if(e){ct(e);var n=l(e);return t(n?e.get(1):e[1],n?e.get(0):e[0],r)}},e)},e.prototype.__iterator=function(t,e){ +var r=this._iter.__iterator(Ve,e);return new Fe(function(){for(;;){var e=r.next();if(e.done)return e;var n=e.value;if(n){ct(n);var i=l(n);return z(t,i?n.get(0):n[0],i?n.get(1):n[1],e)}}})},e}(Ze);mr.prototype.cacheResult=gr.prototype.cacheResult=wr.prototype.cacheResult=zr.prototype.cacheResult=pt;var Sr=function(t){function e(e){return null===e||void 0===e?St():gt(e)&&!g(e)?e:St().withMutations(function(r){var n=t(e);yt(n.size),n.forEach(function(t,e){return r.set(e,t)})})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return St().withMutations(function(e){for(var r=0;r=t.length)throw Error("Missing value for key: "+t[r]);e.set(t[r],t[r+1])}})},e.prototype.toString=function(){return this.__toString("Map {","}")},e.prototype.get=function(t,e){return this._root?this._root.get(0,void 0,t,e):e},e.prototype.set=function(t,e){return It(this,t,e)},e.prototype.setIn=function(t,e){return this.updateIn(t,ke,function(){return e})},e.prototype.remove=function(t){return It(this,t,ke)},e.prototype.deleteIn=function(t){if(t=[].concat(lt(t)),t.length){var e=t.pop();return this.updateIn(t,function(t){return t&&t.remove(e)})}},e.prototype.deleteAll=function(t){var e=We(t);return 0===e.size?this:this.withMutations(function(t){e.forEach(function(e){return t.remove(e)})})},e.prototype.update=function(t,e,r){return 1===arguments.length?t(this):this.updateIn([t],e,r)},e.prototype.updateIn=function(t,e,r){r||(r=e,e=void 0);var n=Rt(this,lt(t),0,e,r);return n===ke?e:n},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):St()},e.prototype.merge=function(){return xt(this,void 0,arguments)},e.prototype.mergeWith=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return xt(this,t,e)},e.prototype.mergeIn=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1] +;return this.updateIn(t,St(),function(t){return"function"==typeof t.merge?t.merge.apply(t,e):e[e.length-1]})},e.prototype.mergeDeep=function(){return xt(this,jt,arguments)},e.prototype.mergeDeepWith=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return xt(this,kt(t),e)},e.prototype.mergeDeepIn=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return this.updateIn(t,St(),function(t){return"function"==typeof t.mergeDeep?t.mergeDeep.apply(t,e):e[e.length-1]})},e.prototype.sort=function(t){return Br(it(this,t))},e.prototype.sortBy=function(t,e){return Br(it(this,e,t))},e.prototype.withMutations=function(t){var e=this.asMutable();return t(e),e.wasAltered()?e.__ensureOwner(this.__ownerID):this},e.prototype.asMutable=function(){return this.__ownerID?this:this.__ensureOwner(new n)},e.prototype.asImmutable=function(){return this.__ensureOwner()},e.prototype.wasAltered=function(){return this.__altered},e.prototype.__iterator=function(t,e){return new jr(this,t,e)},e.prototype.__iterate=function(t,e){var r=this,n=0;return this._root&&this._root.iterate(function(e){return n++,t(e[1],e[0],r)},e),n},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?zt(this.size,this._root,t,this.__hash):0===this.size?St():(this.__ownerID=t,this.__altered=!1,this)},e}(Be);Sr.isMap=gt;var Ir="@@__IMMUTABLE_MAP__@@",br=Sr.prototype;br[Ir]=!0,br.delete=br.remove,br.removeIn=br.deleteIn,br.removeAll=br.deleteAll,br["@@transducer/init"]=br.asMutable,br["@@transducer/step"]=function(t,e){return t.set(e[0],e[1])},br["@@transducer/result"]=function(t){return t.asImmutable()};var Or=function(t,e){this.ownerID=t,this.entries=e};Or.prototype.get=function(t,e,r,n){for(var i=this.entries,o=0,u=i.length;o=kr)return Dt(t,h,o,u) +;var l=t&&t===this.ownerID,v=l?h:i(h);return _?c?f===p-1?v.pop():v[f]=v.pop():v[f]=[o,u]:v.push([o,u]),l?(this.entries=v,this):new Or(t,v)}};var Mr=function(t,e,r){this.ownerID=t,this.bitmap=e,this.nodes=r};Mr.prototype.get=function(t,e,r,n){void 0===e&&(e=W(r));var i=1<<((0===t?e:e>>>t)&je),o=this.bitmap;return 0==(o&i)?n:this.nodes[Ut(o&i-1)].get(t+Ee,e,r,n)},Mr.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=W(n));var s=(0===e?r:r>>>e)&je,a=1<=Ar)return Et(t,p,c,s,l);if(h&&!l&&2===p.length&&Ot(p[1^f]))return p[1^f];if(h&&l&&1===p.length&&Ot(l))return l;var v=t&&t===this.ownerID,y=h?l?c:c^a:c|a,d=h?l?Kt(p,f,l,v):Tt(p,f,v):Lt(p,f,l,v);return v?(this.bitmap=y,this.nodes=d,this):new Mr(t,y,d)};var Dr=function(t,e,r){this.ownerID=t,this.count=e,this.nodes=r};Dr.prototype.get=function(t,e,r,n){void 0===e&&(e=W(r));var i=(0===t?e:e>>>t)&je,o=this.nodes[i];return o?o.get(t+Ee,e,r,n):n},Dr.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=W(n));var s=(0===e?r:r>>>e)&je,a=i===ke,c=this.nodes,h=c[s];if(a&&!h)return this;var f=bt(h,t,e+Ee,r,n,i,o,u);if(f===h)return this;var p=this.count;if(h){if(!f&&--p0&&i=0&&t0;)e[r]=arguments[r+1];return Qt(this,t,e)},e.prototype.mergeDeep=function(){return Qt(this,jt,arguments)},e.prototype.mergeDeepWith=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Qt(this,kt(t),e)},e.prototype.setSize=function(t){return Yt(this,0,t)},e.prototype.slice=function(t,e){var r=this.size;return a(t,e,r)?this:Yt(this,c(t,r),h(e,r))},e.prototype.__iterator=function(t,e){var r=e?this.size:0,n=Wt(this,e);return new Fe(function(){var i=n();return i===Wr?S():z(t,e?--r:r++,i)})},e.prototype.__iterate=function(t,e){for(var r,n=this,i=e?this.size:0,o=Wt(this,e);(r=o())!==Wr&&t(r,e?--i:i++,n)!==!1;);return i},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Bt(this._origin,this._capacity,this._level,this._root,this._tail,t,this.__hash):0===this.size?Jt():(this.__ownerID=t,this)},e}(Je);Ur.isList=Ct;var Kr="@@__IMMUTABLE_LIST__@@",Lr=Ur.prototype;Lr[Kr]=!0,Lr.delete=Lr.remove,Lr.setIn=br.setIn,Lr.deleteIn=Lr.removeIn=br.removeIn,Lr.update=br.update,Lr.updateIn=br.updateIn,Lr.mergeIn=br.mergeIn,Lr.mergeDeepIn=br.mergeDeepIn, +Lr.withMutations=br.withMutations,Lr.asMutable=br.asMutable,Lr.asImmutable=br.asImmutable,Lr.wasAltered=br.wasAltered,Lr["@@transducer/init"]=Lr.asMutable,Lr["@@transducer/step"]=function(t,e){return t.push(e)},Lr["@@transducer/result"]=br["@@transducer/result"];var Tr=function(t,e){this.array=t,this.ownerID=e};Tr.prototype.removeBefore=function(t,e,r){if(r===e?1<>>e&je;if(n>=this.array.length)return new Tr([],t);var i,o=0===n;if(e>0){var u=this.array[n];if((i=u&&u.removeBefore(t,e-Ee,r))===u&&o)return this}if(o&&!i)return this;var s=Vt(this,t);if(!o)for(var a=0;a>>e&je;if(n>=this.array.length)return this;var i;if(e>0){var o=this.array[n];if((i=o&&o.removeAfter(t,e-Ee,r))===o&&n===this.array.length-1)return this}var u=Vt(this,t);return u.array.splice(n+1),i&&(u.array[n]=i),u};var Cr,Wr={},Br=function(t){function e(t){return null===t||void 0===t?Zt():Ft(t)?t:Zt().withMutations(function(e){var r=Be(t);yt(r.size),r.forEach(function(t,r){return e.set(r,t)})})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("OrderedMap {","}")},e.prototype.get=function(t,e){var r=this._map.get(t);return void 0!==r?this._list.get(r)[1]:e},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._map.clear(),this._list.clear(),this):Zt()},e.prototype.set=function(t,e){return $t(this,t,e)},e.prototype.remove=function(t){return $t(this,t,ke)},e.prototype.wasAltered=function(){return this._map.wasAltered()||this._list.wasAltered()},e.prototype.__iterate=function(t,e){var r=this;return this._list.__iterate(function(e){return e&&t(e[1],e[0],r)},e)},e.prototype.__iterator=function(t,e){return this._list.fromEntrySeq().__iterator(t,e)},e.prototype.__ensureOwner=function(t){ +if(t===this.__ownerID)return this;var e=this._map.__ensureOwner(t),r=this._list.__ensureOwner(t);return t?Gt(e,r,t,this.__hash):0===this.size?Zt():(this.__ownerID=t,this._map=e,this._list=r,this)},e}(Sr);Br.isOrderedMap=Ft,Br.prototype[Te]=!0,Br.prototype.delete=Br.prototype.remove;var Jr,Pr=function(t){function e(t){return null===t||void 0===t?re():te(t)?t:re().pushAll(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("Stack [","]")},e.prototype.get=function(t,e){var r=this._head;for(t=u(this,t);r&&t--;)r=r.next;return r?r.value:e},e.prototype.peek=function(){return this._head&&this._head.value},e.prototype.push=function(){var t=arguments;if(0===arguments.length)return this;for(var e=this.size+arguments.length,r=this._head,n=arguments.length-1;n>=0;n--)r={value:t[n],next:r};return this.__ownerID?(this.size=e,this._head=r,this.__hash=void 0,this.__altered=!0,this):ee(e,r)},e.prototype.pushAll=function(e){if(e=t(e),0===e.size)return this;if(0===this.size&&te(e))return e;yt(e.size);var r=this.size,n=this._head;return e.__iterate(function(t){r++,n={value:t,next:n}},!0),this.__ownerID?(this.size=r,this._head=n,this.__hash=void 0,this.__altered=!0,this):ee(r,n)},e.prototype.pop=function(){return this.slice(1)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):re()},e.prototype.slice=function(e,r){if(a(e,r,this.size))return this;var n=c(e,this.size);if(h(r,this.size)!==this.size)return t.prototype.slice.call(this,e,r);for(var i=this.size-n,o=this._head;n--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):ee(i,o)},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?ee(this.size,this._head,t,this.__hash):0===this.size?re():(this.__ownerID=t,this.__altered=!1,this)},e.prototype.__iterate=function(t,e){var r=this +;if(e)return new rr(this.toArray()).__iterate(function(e,n){return t(e,n,r)},e);for(var n=0,i=this._head;i&&t(i.value,n++,r)!==!1;)i=i.next;return n},e.prototype.__iterator=function(t,e){if(e)return new rr(this.toArray()).__iterator(t,e);var r=0,n=this._head;return new Fe(function(){if(n){var e=n.value;return n=n.next,z(t,r++,e)}return S()})},e}(Je);Pr.isStack=te;var Nr="@@__IMMUTABLE_STACK__@@",Vr=Pr.prototype;Vr[Nr]=!0,Vr.withMutations=br.withMutations,Vr.asMutable=br.asMutable,Vr.asImmutable=br.asImmutable,Vr.wasAltered=br.wasAltered,Vr.shift=Vr.pop,Vr.unshift=Vr.push,Vr.unshiftAll=Vr.pushAll,Vr["@@transducer/init"]=Vr.asMutable,Vr["@@transducer/step"]=function(t,e){return t.unshift(e)},Vr["@@transducer/result"]=br["@@transducer/result"];var Hr,Yr=function(t){function e(e){return null===e||void 0===e?ae():oe(e)&&!g(e)?e:ae().withMutations(function(r){var n=t(e);yt(n.size),n.forEach(function(t){return r.add(t)})})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(Be(t).keySeq())},e.intersect=function(t){return t=We(t).toArray(),t.length?Xr.intersect.apply(e(t.pop()),t):ae()},e.union=function(t){return t=We(t).toArray(),t.length?Xr.union.apply(e(t.pop()),t):ae()},e.prototype.toString=function(){return this.__toString("Set {","}")},e.prototype.has=function(t){return this._map.has(t)},e.prototype.add=function(t){return ue(this,this._map.set(t,!0))},e.prototype.remove=function(t){return ue(this,this._map.remove(t))},e.prototype.clear=function(){return ue(this,this._map.clear())},e.prototype.union=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return e=e.filter(function(t){return 0!==t.size}),0===e.length?this:0!==this.size||this.__ownerID||1!==e.length?this.withMutations(function(r){for(var n=0;n0;)e[r]=arguments[r+1];return this.union.apply(this,e)},e.prototype.sort=function(t){return rn(it(this,t))},e.prototype.sortBy=function(t,e){return rn(it(this,e,t))},e.prototype.wasAltered=function(){return this._map.wasAltered()},e.prototype.__iterate=function(t,e){var r=this;return this._map.__iterate(function(e,n){return t(n,n,r)},e)},e.prototype.__iterator=function(t,e){return this._map.map(function(t,e){return e}).__iterator(t,e)},e.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var e=this._map.__ensureOwner(t);return t?this.__make(e,t):0===this.size?ae():(this.__ownerID=t,this._map=e,this)},e}(Pe);Yr.isSet=oe;var Qr="@@__IMMUTABLE_SET__@@",Xr=Yr.prototype;Xr[Qr]=!0,Xr.delete=Xr.remove,Xr.mergeDeep=Xr.merge,Xr.mergeDeepWith=Xr.mergeWith,Xr.withMutations=br.withMutations,Xr.asMutable=br.asMutable,Xr.asImmutable=br.asImmutable,Xr["@@transducer/init"]=Xr.asMutable,Xr["@@transducer/step"]=function(t,e){return t.add(e)},Xr["@@transducer/result"]=br["@@transducer/result"],Xr.__empty=ae,Xr.__make=se;var Fr,Gr,Zr=function(t){function e(t,r,n){if(!(this instanceof e))return new e(t,r,n);if(vt(0!==n,"Cannot step a Range by 0"),t=t||0,void 0===r&&(r=1/0),n=void 0===n?1:Math.abs(n),r=0&&e=0&&rthis.size?e:this.find(function(e,r){return r===t},void 0,e)},has:function(t){return(t=u(this,t))>=0&&(void 0!==this.size?this.size===1/0||t Date: Sat, 30 Sep 2017 02:05:37 +0000 Subject: [PATCH 007/242] Deploy master to NPM branch --- dist/immutable-nonambient.d.ts | 60 +++++++++++++++++++++++++++++++++- dist/immutable.d.ts | 60 +++++++++++++++++++++++++++++++++- 2 files changed, 118 insertions(+), 2 deletions(-) diff --git a/dist/immutable-nonambient.d.ts b/dist/immutable-nonambient.d.ts index 04c2ba163a..6df1b935ca 100644 --- a/dist/immutable-nonambient.d.ts +++ b/dist/immutable-nonambient.d.ts @@ -2252,7 +2252,7 @@ * Similar to `stack.map(...).flatten(true)`. */ flatMap( - mapper: (value: T, key: number, iter: this) => M, + mapper: (value: T, key: number, iter: this) => Iterable, context?: any ): Stack; @@ -3093,6 +3093,25 @@ context?: any ): Seq; + /** + * Returns a new Seq with values passed through a + * `mapper` function. + * + * ```js + * const { Seq } = require('immutable') + * Seq([ 1, 2 ]).map(x => 10 * x) + * // Seq [ 10, 20 ] + * ``` + * + * Note: `map()` always returns a new instance, even if it produced the same + * value at every step. + * Note: used only for sets. + */ + map( + mapper: (value: V, key: K, iter: this) => M, + context?: any + ): Seq; + /** * Flat-maps the Seq, returning a Seq of the same type. * @@ -3103,6 +3122,17 @@ context?: any ): Seq; + /** + * Flat-maps the Seq, returning a Seq of the same type. + * + * Similar to `seq.map(...).flatten(true)`. + * Note: Used only for sets. + */ + flatMap( + mapper: (value: V, key: K, iter: this) => Iterable, + context?: any + ): Seq; + /** * Returns a new Seq with only the values for which the `predicate` * function returns true. @@ -4038,6 +4068,23 @@ context?: any ): Collection; + /** + * Returns a new Collection of the same type with values passed through a + * `mapper` function. + * + * ```js + * const { Collection } = require('immutable') + * Collection({ a: 1, b: 2 }).map(x => 10 * x) + * // Seq { "a": 10, "b": 20 } + * ``` + * + * Note: `map()` always returns a new instance, even if it produced the same + * value at every step. + * Note: used only for sets, which return Collection but are otherwise + * identical to normal `map()`. + */ + map(...args: never[]): any; + /** * Returns a new Collection of the same type with only the entries for which * the `predicate` function returns true. @@ -4337,6 +4384,17 @@ context?: any ): Collection; + /** + * Flat-maps the Collection, returning a Collection of the same type. + * + * Similar to `collection.map(...).flatten(true)`. + * Used for Dictionaries only. + */ + flatMap( + mapper: (value: V, key: K, iter: this) => Iterable<[KM, VM]>, + context?: any + ): Collection; + // Reducing a value /** diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index bc3c975cc3..8fdcafd6ca 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -2252,7 +2252,7 @@ declare module Immutable { * Similar to `stack.map(...).flatten(true)`. */ flatMap( - mapper: (value: T, key: number, iter: this) => M, + mapper: (value: T, key: number, iter: this) => Iterable, context?: any ): Stack; @@ -3093,6 +3093,25 @@ declare module Immutable { context?: any ): Seq; + /** + * Returns a new Seq with values passed through a + * `mapper` function. + * + * ```js + * const { Seq } = require('immutable') + * Seq([ 1, 2 ]).map(x => 10 * x) + * // Seq [ 10, 20 ] + * ``` + * + * Note: `map()` always returns a new instance, even if it produced the same + * value at every step. + * Note: used only for sets. + */ + map( + mapper: (value: V, key: K, iter: this) => M, + context?: any + ): Seq; + /** * Flat-maps the Seq, returning a Seq of the same type. * @@ -3103,6 +3122,17 @@ declare module Immutable { context?: any ): Seq; + /** + * Flat-maps the Seq, returning a Seq of the same type. + * + * Similar to `seq.map(...).flatten(true)`. + * Note: Used only for sets. + */ + flatMap( + mapper: (value: V, key: K, iter: this) => Iterable, + context?: any + ): Seq; + /** * Returns a new Seq with only the values for which the `predicate` * function returns true. @@ -4038,6 +4068,23 @@ declare module Immutable { context?: any ): Collection; + /** + * Returns a new Collection of the same type with values passed through a + * `mapper` function. + * + * ```js + * const { Collection } = require('immutable') + * Collection({ a: 1, b: 2 }).map(x => 10 * x) + * // Seq { "a": 10, "b": 20 } + * ``` + * + * Note: `map()` always returns a new instance, even if it produced the same + * value at every step. + * Note: used only for sets, which return Collection but are otherwise + * identical to normal `map()`. + */ + map(...args: never[]): any; + /** * Returns a new Collection of the same type with only the entries for which * the `predicate` function returns true. @@ -4337,6 +4384,17 @@ declare module Immutable { context?: any ): Collection; + /** + * Flat-maps the Collection, returning a Collection of the same type. + * + * Similar to `collection.map(...).flatten(true)`. + * Used for Dictionaries only. + */ + flatMap( + mapper: (value: V, key: K, iter: this) => Iterable<[KM, VM]>, + context?: any + ): Collection; + // Reducing a value /** From f6a79b372a021bfa6d800479fe3565e215e9aedc Mon Sep 17 00:00:00 2001 From: Travis CI Date: Sat, 30 Sep 2017 03:01:55 +0000 Subject: [PATCH 008/242] Deploy master to NPM branch --- LICENSE | 43 ++++++++++--------------- README.md | 2 +- bower.json | 4 +-- contrib/cursor/__tests__/Cursor.ts.skip | 7 ++++ contrib/cursor/index.d.ts | 9 ++---- contrib/cursor/index.js | 8 ++--- dist/immutable-nonambient.d.ts | 8 ++--- dist/immutable.d.ts | 8 ++--- dist/immutable.es.js | 8 ++--- dist/immutable.js | 8 ++--- dist/immutable.js.flow | 7 ++++ dist/immutable.min.js | 8 ++--- package.json | 7 ++-- 13 files changed, 58 insertions(+), 69 deletions(-) diff --git a/LICENSE b/LICENSE index c6a207cd5e..cde61b6c53 100644 --- a/LICENSE +++ b/LICENSE @@ -1,30 +1,21 @@ -BSD License +MIT License -For Immutable JS software +Copyright (c) 2014-present, Facebook, Inc. -Copyright (c) 2014-2015, Facebook, Inc. All rights reserved. +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: -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - - * Neither the name Facebook nor the names of its contributors may be used to - endorse or promote products derived from this software without specific - prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index 182f7be172..f984bc1af9 100644 --- a/README.md +++ b/README.md @@ -534,4 +534,4 @@ name. If you're looking for his unsupported package, see [this repository](https License ------- -Immutable.js is [BSD-licensed](https://github.com/facebook/immutable-js/blob/master/LICENSE). We also provide an additional [patent grant](https://github.com/facebook/immutable-js/blob/master/PATENTS). +Immutable.js is [MIT-licensed](https://github.com/facebook/immutable-js/blob/master/LICENSE). diff --git a/bower.json b/bower.json index c1a3fd8284..0322021172 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,7 @@ { "name": "immutable", "description": "Immutable Data Collections", + "license": "MIT", "homepage": "https://github.com/facebook/immutable-js", "author": { "name": "Lee Byron", @@ -34,6 +35,5 @@ "stateless", "sequence", "iteration" - ], - "license": "BSD" + ] } diff --git a/contrib/cursor/__tests__/Cursor.ts.skip b/contrib/cursor/__tests__/Cursor.ts.skip index 0a1892386c..89346e799e 100644 --- a/contrib/cursor/__tests__/Cursor.ts.skip +++ b/contrib/cursor/__tests__/Cursor.ts.skip @@ -1,3 +1,10 @@ +/** + * Copyright (c) 2014-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + /// import * as Immutable from '../../../'; diff --git a/contrib/cursor/index.d.ts b/contrib/cursor/index.d.ts index 96c14afae4..495fde9aa7 100644 --- a/contrib/cursor/index.d.ts +++ b/contrib/cursor/index.d.ts @@ -1,13 +1,10 @@ /** - * Copyright (c) 2014-2015, Facebook, Inc. - * All rights reserved. + * Copyright (c) 2014-present, Facebook, Inc. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ - /** * Cursors * ------- diff --git a/contrib/cursor/index.js b/contrib/cursor/index.js index 09b7929a6e..afa4dc39b8 100644 --- a/contrib/cursor/index.js +++ b/contrib/cursor/index.js @@ -1,10 +1,8 @@ /** - * Copyright (c) 2014-2015, Facebook, Inc. - * All rights reserved. + * Copyright (c) 2014-present, Facebook, Inc. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ /** diff --git a/dist/immutable-nonambient.d.ts b/dist/immutable-nonambient.d.ts index 6df1b935ca..626776cef7 100644 --- a/dist/immutable-nonambient.d.ts +++ b/dist/immutable-nonambient.d.ts @@ -1,10 +1,8 @@ /** - * Copyright (c) 2014-2015, Facebook, Inc. - * All rights reserved. + * Copyright (c) 2014-present, Facebook, Inc. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ /** diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index 8fdcafd6ca..4895986680 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -1,10 +1,8 @@ /** - * Copyright (c) 2014-2015, Facebook, Inc. - * All rights reserved. + * Copyright (c) 2014-present, Facebook, Inc. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ /** diff --git a/dist/immutable.es.js b/dist/immutable.es.js index f9fa1138bb..d98f0b11f8 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -1,10 +1,8 @@ /** - * Copyright (c) 2014-2015, Facebook, Inc. - * All rights reserved. + * Copyright (c) 2014-present, Facebook, Inc. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ // Used for setting prototype methods that IE8 chokes on. diff --git a/dist/immutable.js b/dist/immutable.js index 5f707bebff..de13cd2fc8 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -1,10 +1,8 @@ /** - * Copyright (c) 2014-2015, Facebook, Inc. - * All rights reserved. + * Copyright (c) 2014-present, Facebook, Inc. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ (function (global, factory) { diff --git a/dist/immutable.js.flow b/dist/immutable.js.flow index 77080cf1dd..c555c5463e 100644 --- a/dist/immutable.js.flow +++ b/dist/immutable.js.flow @@ -1,3 +1,10 @@ +/** + * Copyright (c) 2014-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + /** * This file provides type definitions for use with the Flow type checker. * diff --git a/dist/immutable.min.js b/dist/immutable.min.js index 05b069327c..80aaecc610 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -1,10 +1,8 @@ /** - * Copyright (c) 2014-2015, Facebook, Inc. - * All rights reserved. + * Copyright (c) 2014-present, Facebook, Inc. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.Immutable=t.Immutable||{})}(this,function(t){"use strict";function e(t){return t.value=!1,t}function r(t){t&&(t.value=!0)}function n(){}function i(t,e){e=e||0;for(var r=Math.max(0,t.length-e),n=Array(r),i=0;i>>0;if(""+r!==e||4294967295===r)return NaN;e=r}return e<0?o(t)+e:e}function s(){return!0}function a(t,e,r){return(0===t&&!p(t)||void 0!==r&&t<=-r)&&(void 0===e||void 0!==r&&e>=r)}function c(t,e){return f(t,e,0)}function h(t,e){return f(t,e,e)}function f(t,e,r){return void 0===t?r:p(t)?e===1/0?e:0|Math.max(0,e+t):void 0===e||e===t?t:0|Math.min(e,t)}function p(t){return t<0||0===t&&1/t==-(1/0)}function _(t){return(l(t)||m(t))&&!t.__ownerID}function l(t){return!(!t||!t[Ue])}function v(t){return!(!t||!t[Ke])}function y(t){return!(!t||!t[Le])}function d(t){return v(t)||y(t)}function g(t){return!(!t||!t[Te])}function m(t){return!(!t||!t[Ce])}function w(t){return!(!t||"function"!=typeof t.equals||"function"!=typeof t.hashCode)}function z(t,e,r,n){var i=0===t?e:1===t?r:[e,r];return n?n.value=i:n={value:i,done:!1},n}function S(){return{value:void 0,done:!0}}function I(t){return!!M(t)}function b(t){return t&&"function"==typeof t.next}function O(t){var e=M(t);return e&&e.call(t)}function M(t){var e=t&&(Ye&&t[Ye]||t[Qe]);if("function"==typeof e)return e}function D(t){return t&&"number"==typeof t.length}function q(t){return!(!t||!t[er])}function E(){return ir||(ir=new rr([]))}function x(t){var e=Array.isArray(t)?new rr(t):b(t)?new sr(t):I(t)?new ur(t):void 0;if(e)return e.fromEntrySeq();if("object"==typeof t)return new nr(t);throw new TypeError("Expected Array or collection object of [k, v] entries, or keyed object: "+t)}function j(t){var e=A(t);if(e)return e;throw new TypeError("Expected Array or collection object of values: "+t)} function k(t){var e=A(t);if(e)return e;if("object"==typeof t)return new nr(t);throw new TypeError("Expected Array or collection object of values, or keyed object: "+t)}function A(t){return D(t)?new rr(t):b(t)?new sr(t):I(t)?new ur(t):void 0}function R(t,e){if(t===e||t!==t&&e!==e)return!0;if(!t||!e)return!1;if("function"==typeof t.valueOf&&"function"==typeof e.valueOf){if(t=t.valueOf(),e=e.valueOf(),t===e||t!==t&&e!==e)return!0;if(!t||!e)return!1}return!!(w(t)&&w(e)&&t.equals(e))}function U(t,e){return K([],e||L,t,"",e&&e.length>2?[]:void 0,{"":t})}function K(t,e,r,n,i,o){var u=Array.isArray(r)?$e:T(r)?Ze:null;if(u){if(~t.indexOf(r))throw new TypeError("Cannot convert circular structure to Immutable");t.push(r),i&&""!==n&&i.push(n);var s=e.call(o,n,u(r).map(function(n,o){return K(t,e,n,o,i,r)}),i&&i.slice());return t.pop(),i&&i.pop(),s}return r}function L(t,e){return v(e)?e.toMap():e.toList()}function T(t){return t&&(t.constructor===Object||void 0===t.constructor)}function C(t){return t>>>1&1073741824|3221225471&t}function W(t){if(t===!1||null===t||void 0===t)return 0;if("function"==typeof t.valueOf&&((t=t.valueOf())===!1||null===t||void 0===t))return 0;if(t===!0)return 1;var e=typeof t;if("number"===e){if(t!==t||t===1/0)return 0;var r=0|t;for(r!==t&&(r^=4294967295*t);t>4294967295;)t/=4294967295,r^=t;return C(r)}if("string"===e)return t.length>lr?B(t):J(t);if("function"==typeof t.hashCode)return C(t.hashCode());if("object"===e)return P(t);if("function"==typeof t.toString)return J(""+t);throw Error("Value type "+e+" cannot be hashed.")}function B(t){var e=dr[t];return void 0===e&&(e=J(t),yr===vr&&(yr=0,dr={}),yr++,dr[t]=e),e}function J(t){for(var e=0,r=0;r Date: Sat, 30 Sep 2017 03:02:43 +0000 Subject: [PATCH 009/242] Deploy master to NPM branch --- LICENSE | 43 +++++++++++++++---------- README.md | 2 +- bower.json | 4 +-- contrib/cursor/__tests__/Cursor.ts.skip | 7 ---- contrib/cursor/index.d.ts | 9 ++++-- contrib/cursor/index.js | 8 +++-- dist/immutable-nonambient.d.ts | 8 +++-- dist/immutable.d.ts | 8 +++-- dist/immutable.es.js | 8 +++-- dist/immutable.js | 8 +++-- dist/immutable.js.flow | 7 ---- dist/immutable.min.js | 8 +++-- package.json | 7 ++-- 13 files changed, 69 insertions(+), 58 deletions(-) diff --git a/LICENSE b/LICENSE index cde61b6c53..c6a207cd5e 100644 --- a/LICENSE +++ b/LICENSE @@ -1,21 +1,30 @@ -MIT License +BSD License -Copyright (c) 2014-present, Facebook, Inc. +For Immutable JS software -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: +Copyright (c) 2014-2015, Facebook, Inc. All rights reserved. -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + * Neither the name Facebook nor the names of its contributors may be used to + endorse or promote products derived from this software without specific + prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/README.md b/README.md index f984bc1af9..182f7be172 100644 --- a/README.md +++ b/README.md @@ -534,4 +534,4 @@ name. If you're looking for his unsupported package, see [this repository](https License ------- -Immutable.js is [MIT-licensed](https://github.com/facebook/immutable-js/blob/master/LICENSE). +Immutable.js is [BSD-licensed](https://github.com/facebook/immutable-js/blob/master/LICENSE). We also provide an additional [patent grant](https://github.com/facebook/immutable-js/blob/master/PATENTS). diff --git a/bower.json b/bower.json index 0322021172..c1a3fd8284 100644 --- a/bower.json +++ b/bower.json @@ -1,7 +1,6 @@ { "name": "immutable", "description": "Immutable Data Collections", - "license": "MIT", "homepage": "https://github.com/facebook/immutable-js", "author": { "name": "Lee Byron", @@ -35,5 +34,6 @@ "stateless", "sequence", "iteration" - ] + ], + "license": "BSD" } diff --git a/contrib/cursor/__tests__/Cursor.ts.skip b/contrib/cursor/__tests__/Cursor.ts.skip index 89346e799e..0a1892386c 100644 --- a/contrib/cursor/__tests__/Cursor.ts.skip +++ b/contrib/cursor/__tests__/Cursor.ts.skip @@ -1,10 +1,3 @@ -/** - * Copyright (c) 2014-present, Facebook, Inc. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - /// import * as Immutable from '../../../'; diff --git a/contrib/cursor/index.d.ts b/contrib/cursor/index.d.ts index 495fde9aa7..96c14afae4 100644 --- a/contrib/cursor/index.d.ts +++ b/contrib/cursor/index.d.ts @@ -1,10 +1,13 @@ /** - * Copyright (c) 2014-present, Facebook, Inc. + * Copyright (c) 2014-2015, Facebook, Inc. + * All rights reserved. * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. */ + /** * Cursors * ------- diff --git a/contrib/cursor/index.js b/contrib/cursor/index.js index afa4dc39b8..09b7929a6e 100644 --- a/contrib/cursor/index.js +++ b/contrib/cursor/index.js @@ -1,8 +1,10 @@ /** - * Copyright (c) 2014-present, Facebook, Inc. + * Copyright (c) 2014-2015, Facebook, Inc. + * All rights reserved. * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. */ /** diff --git a/dist/immutable-nonambient.d.ts b/dist/immutable-nonambient.d.ts index 626776cef7..6df1b935ca 100644 --- a/dist/immutable-nonambient.d.ts +++ b/dist/immutable-nonambient.d.ts @@ -1,8 +1,10 @@ /** - * Copyright (c) 2014-present, Facebook, Inc. + * Copyright (c) 2014-2015, Facebook, Inc. + * All rights reserved. * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. */ /** diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index 4895986680..8fdcafd6ca 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -1,8 +1,10 @@ /** - * Copyright (c) 2014-present, Facebook, Inc. + * Copyright (c) 2014-2015, Facebook, Inc. + * All rights reserved. * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. */ /** diff --git a/dist/immutable.es.js b/dist/immutable.es.js index d98f0b11f8..f9fa1138bb 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -1,8 +1,10 @@ /** - * Copyright (c) 2014-present, Facebook, Inc. + * Copyright (c) 2014-2015, Facebook, Inc. + * All rights reserved. * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. */ // Used for setting prototype methods that IE8 chokes on. diff --git a/dist/immutable.js b/dist/immutable.js index de13cd2fc8..5f707bebff 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -1,8 +1,10 @@ /** - * Copyright (c) 2014-present, Facebook, Inc. + * Copyright (c) 2014-2015, Facebook, Inc. + * All rights reserved. * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. */ (function (global, factory) { diff --git a/dist/immutable.js.flow b/dist/immutable.js.flow index c555c5463e..77080cf1dd 100644 --- a/dist/immutable.js.flow +++ b/dist/immutable.js.flow @@ -1,10 +1,3 @@ -/** - * Copyright (c) 2014-present, Facebook, Inc. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - /** * This file provides type definitions for use with the Flow type checker. * diff --git a/dist/immutable.min.js b/dist/immutable.min.js index 80aaecc610..05b069327c 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -1,8 +1,10 @@ /** - * Copyright (c) 2014-present, Facebook, Inc. + * Copyright (c) 2014-2015, Facebook, Inc. + * All rights reserved. * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. */ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.Immutable=t.Immutable||{})}(this,function(t){"use strict";function e(t){return t.value=!1,t}function r(t){t&&(t.value=!0)}function n(){}function i(t,e){e=e||0;for(var r=Math.max(0,t.length-e),n=Array(r),i=0;i>>0;if(""+r!==e||4294967295===r)return NaN;e=r}return e<0?o(t)+e:e}function s(){return!0}function a(t,e,r){return(0===t&&!p(t)||void 0!==r&&t<=-r)&&(void 0===e||void 0!==r&&e>=r)}function c(t,e){return f(t,e,0)}function h(t,e){return f(t,e,e)}function f(t,e,r){return void 0===t?r:p(t)?e===1/0?e:0|Math.max(0,e+t):void 0===e||e===t?t:0|Math.min(e,t)}function p(t){return t<0||0===t&&1/t==-(1/0)}function _(t){return(l(t)||m(t))&&!t.__ownerID}function l(t){return!(!t||!t[Ue])}function v(t){return!(!t||!t[Ke])}function y(t){return!(!t||!t[Le])}function d(t){return v(t)||y(t)}function g(t){return!(!t||!t[Te])}function m(t){return!(!t||!t[Ce])}function w(t){return!(!t||"function"!=typeof t.equals||"function"!=typeof t.hashCode)}function z(t,e,r,n){var i=0===t?e:1===t?r:[e,r];return n?n.value=i:n={value:i,done:!1},n}function S(){return{value:void 0,done:!0}}function I(t){return!!M(t)}function b(t){return t&&"function"==typeof t.next}function O(t){var e=M(t);return e&&e.call(t)}function M(t){var e=t&&(Ye&&t[Ye]||t[Qe]);if("function"==typeof e)return e}function D(t){return t&&"number"==typeof t.length}function q(t){return!(!t||!t[er])}function E(){return ir||(ir=new rr([]))}function x(t){var e=Array.isArray(t)?new rr(t):b(t)?new sr(t):I(t)?new ur(t):void 0;if(e)return e.fromEntrySeq();if("object"==typeof t)return new nr(t);throw new TypeError("Expected Array or collection object of [k, v] entries, or keyed object: "+t)}function j(t){var e=A(t);if(e)return e;throw new TypeError("Expected Array or collection object of values: "+t)} function k(t){var e=A(t);if(e)return e;if("object"==typeof t)return new nr(t);throw new TypeError("Expected Array or collection object of values, or keyed object: "+t)}function A(t){return D(t)?new rr(t):b(t)?new sr(t):I(t)?new ur(t):void 0}function R(t,e){if(t===e||t!==t&&e!==e)return!0;if(!t||!e)return!1;if("function"==typeof t.valueOf&&"function"==typeof e.valueOf){if(t=t.valueOf(),e=e.valueOf(),t===e||t!==t&&e!==e)return!0;if(!t||!e)return!1}return!!(w(t)&&w(e)&&t.equals(e))}function U(t,e){return K([],e||L,t,"",e&&e.length>2?[]:void 0,{"":t})}function K(t,e,r,n,i,o){var u=Array.isArray(r)?$e:T(r)?Ze:null;if(u){if(~t.indexOf(r))throw new TypeError("Cannot convert circular structure to Immutable");t.push(r),i&&""!==n&&i.push(n);var s=e.call(o,n,u(r).map(function(n,o){return K(t,e,n,o,i,r)}),i&&i.slice());return t.pop(),i&&i.pop(),s}return r}function L(t,e){return v(e)?e.toMap():e.toList()}function T(t){return t&&(t.constructor===Object||void 0===t.constructor)}function C(t){return t>>>1&1073741824|3221225471&t}function W(t){if(t===!1||null===t||void 0===t)return 0;if("function"==typeof t.valueOf&&((t=t.valueOf())===!1||null===t||void 0===t))return 0;if(t===!0)return 1;var e=typeof t;if("number"===e){if(t!==t||t===1/0)return 0;var r=0|t;for(r!==t&&(r^=4294967295*t);t>4294967295;)t/=4294967295,r^=t;return C(r)}if("string"===e)return t.length>lr?B(t):J(t);if("function"==typeof t.hashCode)return C(t.hashCode());if("object"===e)return P(t);if("function"==typeof t.toString)return J(""+t);throw Error("Value type "+e+" cannot be hashed.")}function B(t){var e=dr[t];return void 0===e&&(e=J(t),yr===vr&&(yr=0,dr={}),yr++,dr[t]=e),e}function J(t){for(var e=0,r=0;r Date: Sat, 30 Sep 2017 03:14:48 +0000 Subject: [PATCH 010/242] Deploy master to NPM branch --- LICENSE | 43 ++++++++++--------------- README.md | 2 +- bower.json | 4 +-- contrib/cursor/__tests__/Cursor.ts.skip | 7 ++++ contrib/cursor/index.d.ts | 9 ++---- contrib/cursor/index.js | 8 ++--- dist/immutable-nonambient.d.ts | 8 ++--- dist/immutable.d.ts | 8 ++--- dist/immutable.es.js | 8 ++--- dist/immutable.js | 8 ++--- dist/immutable.js.flow | 7 ++++ dist/immutable.min.js | 8 ++--- package.json | 7 ++-- 13 files changed, 58 insertions(+), 69 deletions(-) diff --git a/LICENSE b/LICENSE index c6a207cd5e..cde61b6c53 100644 --- a/LICENSE +++ b/LICENSE @@ -1,30 +1,21 @@ -BSD License +MIT License -For Immutable JS software +Copyright (c) 2014-present, Facebook, Inc. -Copyright (c) 2014-2015, Facebook, Inc. All rights reserved. +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: -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - - * Neither the name Facebook nor the names of its contributors may be used to - endorse or promote products derived from this software without specific - prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index 182f7be172..f984bc1af9 100644 --- a/README.md +++ b/README.md @@ -534,4 +534,4 @@ name. If you're looking for his unsupported package, see [this repository](https License ------- -Immutable.js is [BSD-licensed](https://github.com/facebook/immutable-js/blob/master/LICENSE). We also provide an additional [patent grant](https://github.com/facebook/immutable-js/blob/master/PATENTS). +Immutable.js is [MIT-licensed](https://github.com/facebook/immutable-js/blob/master/LICENSE). diff --git a/bower.json b/bower.json index c1a3fd8284..0322021172 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,7 @@ { "name": "immutable", "description": "Immutable Data Collections", + "license": "MIT", "homepage": "https://github.com/facebook/immutable-js", "author": { "name": "Lee Byron", @@ -34,6 +35,5 @@ "stateless", "sequence", "iteration" - ], - "license": "BSD" + ] } diff --git a/contrib/cursor/__tests__/Cursor.ts.skip b/contrib/cursor/__tests__/Cursor.ts.skip index 0a1892386c..89346e799e 100644 --- a/contrib/cursor/__tests__/Cursor.ts.skip +++ b/contrib/cursor/__tests__/Cursor.ts.skip @@ -1,3 +1,10 @@ +/** + * Copyright (c) 2014-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + /// import * as Immutable from '../../../'; diff --git a/contrib/cursor/index.d.ts b/contrib/cursor/index.d.ts index 96c14afae4..495fde9aa7 100644 --- a/contrib/cursor/index.d.ts +++ b/contrib/cursor/index.d.ts @@ -1,13 +1,10 @@ /** - * Copyright (c) 2014-2015, Facebook, Inc. - * All rights reserved. + * Copyright (c) 2014-present, Facebook, Inc. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ - /** * Cursors * ------- diff --git a/contrib/cursor/index.js b/contrib/cursor/index.js index 09b7929a6e..afa4dc39b8 100644 --- a/contrib/cursor/index.js +++ b/contrib/cursor/index.js @@ -1,10 +1,8 @@ /** - * Copyright (c) 2014-2015, Facebook, Inc. - * All rights reserved. + * Copyright (c) 2014-present, Facebook, Inc. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ /** diff --git a/dist/immutable-nonambient.d.ts b/dist/immutable-nonambient.d.ts index 6df1b935ca..626776cef7 100644 --- a/dist/immutable-nonambient.d.ts +++ b/dist/immutable-nonambient.d.ts @@ -1,10 +1,8 @@ /** - * Copyright (c) 2014-2015, Facebook, Inc. - * All rights reserved. + * Copyright (c) 2014-present, Facebook, Inc. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ /** diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index 8fdcafd6ca..4895986680 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -1,10 +1,8 @@ /** - * Copyright (c) 2014-2015, Facebook, Inc. - * All rights reserved. + * Copyright (c) 2014-present, Facebook, Inc. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ /** diff --git a/dist/immutable.es.js b/dist/immutable.es.js index f9fa1138bb..d98f0b11f8 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -1,10 +1,8 @@ /** - * Copyright (c) 2014-2015, Facebook, Inc. - * All rights reserved. + * Copyright (c) 2014-present, Facebook, Inc. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ // Used for setting prototype methods that IE8 chokes on. diff --git a/dist/immutable.js b/dist/immutable.js index 5f707bebff..de13cd2fc8 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -1,10 +1,8 @@ /** - * Copyright (c) 2014-2015, Facebook, Inc. - * All rights reserved. + * Copyright (c) 2014-present, Facebook, Inc. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ (function (global, factory) { diff --git a/dist/immutable.js.flow b/dist/immutable.js.flow index 77080cf1dd..c555c5463e 100644 --- a/dist/immutable.js.flow +++ b/dist/immutable.js.flow @@ -1,3 +1,10 @@ +/** + * Copyright (c) 2014-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + /** * This file provides type definitions for use with the Flow type checker. * diff --git a/dist/immutable.min.js b/dist/immutable.min.js index 05b069327c..80aaecc610 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -1,10 +1,8 @@ /** - * Copyright (c) 2014-2015, Facebook, Inc. - * All rights reserved. + * Copyright (c) 2014-present, Facebook, Inc. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.Immutable=t.Immutable||{})}(this,function(t){"use strict";function e(t){return t.value=!1,t}function r(t){t&&(t.value=!0)}function n(){}function i(t,e){e=e||0;for(var r=Math.max(0,t.length-e),n=Array(r),i=0;i>>0;if(""+r!==e||4294967295===r)return NaN;e=r}return e<0?o(t)+e:e}function s(){return!0}function a(t,e,r){return(0===t&&!p(t)||void 0!==r&&t<=-r)&&(void 0===e||void 0!==r&&e>=r)}function c(t,e){return f(t,e,0)}function h(t,e){return f(t,e,e)}function f(t,e,r){return void 0===t?r:p(t)?e===1/0?e:0|Math.max(0,e+t):void 0===e||e===t?t:0|Math.min(e,t)}function p(t){return t<0||0===t&&1/t==-(1/0)}function _(t){return(l(t)||m(t))&&!t.__ownerID}function l(t){return!(!t||!t[Ue])}function v(t){return!(!t||!t[Ke])}function y(t){return!(!t||!t[Le])}function d(t){return v(t)||y(t)}function g(t){return!(!t||!t[Te])}function m(t){return!(!t||!t[Ce])}function w(t){return!(!t||"function"!=typeof t.equals||"function"!=typeof t.hashCode)}function z(t,e,r,n){var i=0===t?e:1===t?r:[e,r];return n?n.value=i:n={value:i,done:!1},n}function S(){return{value:void 0,done:!0}}function I(t){return!!M(t)}function b(t){return t&&"function"==typeof t.next}function O(t){var e=M(t);return e&&e.call(t)}function M(t){var e=t&&(Ye&&t[Ye]||t[Qe]);if("function"==typeof e)return e}function D(t){return t&&"number"==typeof t.length}function q(t){return!(!t||!t[er])}function E(){return ir||(ir=new rr([]))}function x(t){var e=Array.isArray(t)?new rr(t):b(t)?new sr(t):I(t)?new ur(t):void 0;if(e)return e.fromEntrySeq();if("object"==typeof t)return new nr(t);throw new TypeError("Expected Array or collection object of [k, v] entries, or keyed object: "+t)}function j(t){var e=A(t);if(e)return e;throw new TypeError("Expected Array or collection object of values: "+t)} function k(t){var e=A(t);if(e)return e;if("object"==typeof t)return new nr(t);throw new TypeError("Expected Array or collection object of values, or keyed object: "+t)}function A(t){return D(t)?new rr(t):b(t)?new sr(t):I(t)?new ur(t):void 0}function R(t,e){if(t===e||t!==t&&e!==e)return!0;if(!t||!e)return!1;if("function"==typeof t.valueOf&&"function"==typeof e.valueOf){if(t=t.valueOf(),e=e.valueOf(),t===e||t!==t&&e!==e)return!0;if(!t||!e)return!1}return!!(w(t)&&w(e)&&t.equals(e))}function U(t,e){return K([],e||L,t,"",e&&e.length>2?[]:void 0,{"":t})}function K(t,e,r,n,i,o){var u=Array.isArray(r)?$e:T(r)?Ze:null;if(u){if(~t.indexOf(r))throw new TypeError("Cannot convert circular structure to Immutable");t.push(r),i&&""!==n&&i.push(n);var s=e.call(o,n,u(r).map(function(n,o){return K(t,e,n,o,i,r)}),i&&i.slice());return t.pop(),i&&i.pop(),s}return r}function L(t,e){return v(e)?e.toMap():e.toList()}function T(t){return t&&(t.constructor===Object||void 0===t.constructor)}function C(t){return t>>>1&1073741824|3221225471&t}function W(t){if(t===!1||null===t||void 0===t)return 0;if("function"==typeof t.valueOf&&((t=t.valueOf())===!1||null===t||void 0===t))return 0;if(t===!0)return 1;var e=typeof t;if("number"===e){if(t!==t||t===1/0)return 0;var r=0|t;for(r!==t&&(r^=4294967295*t);t>4294967295;)t/=4294967295,r^=t;return C(r)}if("string"===e)return t.length>lr?B(t):J(t);if("function"==typeof t.hashCode)return C(t.hashCode());if("object"===e)return P(t);if("function"==typeof t.toString)return J(""+t);throw Error("Value type "+e+" cannot be hashed.")}function B(t){var e=dr[t];return void 0===e&&(e=J(t),yr===vr&&(yr=0,dr={}),yr++,dr[t]=e),e}function J(t){for(var e=0,r=0;r Date: Sat, 30 Sep 2017 03:46:29 +0000 Subject: [PATCH 011/242] Deploy master to NPM branch --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 31a239ec41..c2c5cccd45 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "immutable", - "version": "4.0.0-rc.2", + "version": "4.0.0-rc.3", "description": "Immutable Data Collections", "license": "MIT", "homepage": "https://facebook.github.com/immutable-js", From dc0a947ab8943a5cbdb38cacbb2663e9c32b1e81 Mon Sep 17 00:00:00 2001 From: Travis CI Date: Mon, 2 Oct 2017 20:23:30 +0000 Subject: [PATCH 012/242] Deploy master to NPM branch --- README.md | 2 +- dist/immutable.es.js | 6 +++--- dist/immutable.js | 6 +++--- dist/immutable.min.js | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index f984bc1af9..ae4f9b236b 100644 --- a/README.md +++ b/README.md @@ -512,7 +512,7 @@ Contribution Use [Github issues](https://github.com/facebook/immutable-js/issues) for requests. -We actively welcome pull requests, learn how to [contribute](./CONTRIBUTING.md). +We actively welcome pull requests, learn how to [contribute](./.github/CONTRIBUTING.md). Changelog diff --git a/dist/immutable.es.js b/dist/immutable.es.js index d98f0b11f8..6ad87621b5 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -906,7 +906,7 @@ function hashString(string) { // (exclusive) by dropping high bits. var hashed = 0; for (var ii = 0; ii < string.length; ii++) { - hashed = (31 * hash + string.charCodeAt(ii)) | 0; + hashed = (31 * hashed + string.charCodeAt(ii)) | 0; } return smi(hashed); } @@ -921,7 +921,7 @@ function hashJSObj(obj) { } hashed = obj[UID_HASH_KEY]; - if (hash !== undefined) { + if (hashed !== undefined) { return hashed; } @@ -1505,7 +1505,7 @@ function sliceFactory(collection, begin, end, useKeys) { return iteratorDone(); } var step = iterator.next(); - if (useKeys || type === ITERATE_VALUES) { + if (useKeys || type === ITERATE_VALUES || step.done) { return step; } if (type === ITERATE_KEYS) { diff --git a/dist/immutable.js b/dist/immutable.js index de13cd2fc8..9647b37dce 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -912,7 +912,7 @@ function hashString(string) { // (exclusive) by dropping high bits. var hashed = 0; for (var ii = 0; ii < string.length; ii++) { - hashed = (31 * hash + string.charCodeAt(ii)) | 0; + hashed = (31 * hashed + string.charCodeAt(ii)) | 0; } return smi(hashed); } @@ -927,7 +927,7 @@ function hashJSObj(obj) { } hashed = obj[UID_HASH_KEY]; - if (hash !== undefined) { + if (hashed !== undefined) { return hashed; } @@ -1511,7 +1511,7 @@ function sliceFactory(collection, begin, end, useKeys) { return iteratorDone(); } var step = iterator.next(); - if (useKeys || type === ITERATE_VALUES) { + if (useKeys || type === ITERATE_VALUES || step.done) { return step; } if (type === ITERATE_KEYS) { diff --git a/dist/immutable.min.js b/dist/immutable.min.js index 80aaecc610..e7319e908c 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -5,10 +5,10 @@ * LICENSE file in the root directory of this source tree. */ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.Immutable=t.Immutable||{})}(this,function(t){"use strict";function e(t){return t.value=!1,t}function r(t){t&&(t.value=!0)}function n(){}function i(t,e){e=e||0;for(var r=Math.max(0,t.length-e),n=Array(r),i=0;i>>0;if(""+r!==e||4294967295===r)return NaN;e=r}return e<0?o(t)+e:e}function s(){return!0}function a(t,e,r){return(0===t&&!p(t)||void 0!==r&&t<=-r)&&(void 0===e||void 0!==r&&e>=r)}function c(t,e){return f(t,e,0)}function h(t,e){return f(t,e,e)}function f(t,e,r){return void 0===t?r:p(t)?e===1/0?e:0|Math.max(0,e+t):void 0===e||e===t?t:0|Math.min(e,t)}function p(t){return t<0||0===t&&1/t==-(1/0)}function _(t){return(l(t)||m(t))&&!t.__ownerID}function l(t){return!(!t||!t[Ue])}function v(t){return!(!t||!t[Ke])}function y(t){return!(!t||!t[Le])}function d(t){return v(t)||y(t)}function g(t){return!(!t||!t[Te])}function m(t){return!(!t||!t[Ce])}function w(t){return!(!t||"function"!=typeof t.equals||"function"!=typeof t.hashCode)}function z(t,e,r,n){var i=0===t?e:1===t?r:[e,r];return n?n.value=i:n={value:i,done:!1},n}function S(){return{value:void 0,done:!0}}function I(t){return!!M(t)}function b(t){return t&&"function"==typeof t.next}function O(t){var e=M(t);return e&&e.call(t)}function M(t){var e=t&&(Ye&&t[Ye]||t[Qe]);if("function"==typeof e)return e}function D(t){return t&&"number"==typeof t.length}function q(t){return!(!t||!t[er])}function E(){return ir||(ir=new rr([]))}function x(t){var e=Array.isArray(t)?new rr(t):b(t)?new sr(t):I(t)?new ur(t):void 0;if(e)return e.fromEntrySeq();if("object"==typeof t)return new nr(t);throw new TypeError("Expected Array or collection object of [k, v] entries, or keyed object: "+t)}function j(t){var e=A(t);if(e)return e;throw new TypeError("Expected Array or collection object of values: "+t)} -function k(t){var e=A(t);if(e)return e;if("object"==typeof t)return new nr(t);throw new TypeError("Expected Array or collection object of values, or keyed object: "+t)}function A(t){return D(t)?new rr(t):b(t)?new sr(t):I(t)?new ur(t):void 0}function R(t,e){if(t===e||t!==t&&e!==e)return!0;if(!t||!e)return!1;if("function"==typeof t.valueOf&&"function"==typeof e.valueOf){if(t=t.valueOf(),e=e.valueOf(),t===e||t!==t&&e!==e)return!0;if(!t||!e)return!1}return!!(w(t)&&w(e)&&t.equals(e))}function U(t,e){return K([],e||L,t,"",e&&e.length>2?[]:void 0,{"":t})}function K(t,e,r,n,i,o){var u=Array.isArray(r)?$e:T(r)?Ze:null;if(u){if(~t.indexOf(r))throw new TypeError("Cannot convert circular structure to Immutable");t.push(r),i&&""!==n&&i.push(n);var s=e.call(o,n,u(r).map(function(n,o){return K(t,e,n,o,i,r)}),i&&i.slice());return t.pop(),i&&i.pop(),s}return r}function L(t,e){return v(e)?e.toMap():e.toList()}function T(t){return t&&(t.constructor===Object||void 0===t.constructor)}function C(t){return t>>>1&1073741824|3221225471&t}function W(t){if(t===!1||null===t||void 0===t)return 0;if("function"==typeof t.valueOf&&((t=t.valueOf())===!1||null===t||void 0===t))return 0;if(t===!0)return 1;var e=typeof t;if("number"===e){if(t!==t||t===1/0)return 0;var r=0|t;for(r!==t&&(r^=4294967295*t);t>4294967295;)t/=4294967295,r^=t;return C(r)}if("string"===e)return t.length>lr?B(t):J(t);if("function"==typeof t.hashCode)return C(t.hashCode());if("object"===e)return P(t);if("function"==typeof t.toString)return J(""+t);throw Error("Value type "+e+" cannot be hashed.")}function B(t){var e=dr[t];return void 0===e&&(e=J(t),yr===vr&&(yr=0,dr={}),yr++,dr[t]=e),e}function J(t){for(var e=0,r=0;r2?[]:void 0,{"":t})}function K(t,e,r,n,i,o){var u=Array.isArray(r)?$e:T(r)?Ze:null;if(u){if(~t.indexOf(r))throw new TypeError("Cannot convert circular structure to Immutable");t.push(r),i&&""!==n&&i.push(n);var s=e.call(o,n,u(r).map(function(n,o){return K(t,e,n,o,i,r)}),i&&i.slice());return t.pop(),i&&i.pop(),s}return r}function L(t,e){return v(e)?e.toMap():e.toList()}function T(t){return t&&(t.constructor===Object||void 0===t.constructor)}function C(t){return t>>>1&1073741824|3221225471&t}function W(t){if(t===!1||null===t||void 0===t)return 0;if("function"==typeof t.valueOf&&((t=t.valueOf())===!1||null===t||void 0===t))return 0;if(t===!0)return 1;var e=typeof t;if("number"===e){if(t!==t||t===1/0)return 0;var r=0|t;for(r!==t&&(r^=4294967295*t);t>4294967295;)t/=4294967295,r^=t;return C(r)}if("string"===e)return t.length>lr?B(t):J(t);if("function"==typeof t.hashCode)return C(t.hashCode());if("object"===e)return P(t);if("function"==typeof t.toString)return J(""+t);throw Error("Value type "+e+" cannot be hashed.")}function B(t){var e=dr[t];return void 0===e&&(e=J(t),yr===vr&&(yr=0,dr={}),yr++,dr[t]=e),e}function J(t){for(var e=0,r=0;r0)switch(t.nodeType){case 1:return t.uniqueID;case 9:return t.documentElement&&t.documentElement.uniqueID}}function V(t){var e=ft(t);return e._iter=t,e.size=t.size,e.flip=function(){return t},e.reverse=function(){var e=t.reverse.apply(this);return e.flip=function(){return t.reverse()},e},e.has=function(e){return t.includes(e)},e.includes=function(e){return t.has(e)},e.cacheResult=pt,e.__iterateUncached=function(e,r){var n=this;return t.__iterate(function(t,r){return e(r,t,n)!==!1},r)},e.__iteratorUncached=function(e,r){if(e===He){var n=t.__iterator(e,r);return new Fe(function(){var t=n.next();if(!t.done){var e=t.value[0];t.value[0]=t.value[1],t.value[1]=e}return t})}return t.__iterator(e===Ve?Ne:Ve,r)},e}function H(t,e,r){var n=ft(t);return n.size=t.size,n.has=function(e){return t.has(e)},n.get=function(n,i){var o=t.get(n,ke);return o===ke?i:e.call(r,o,n,t)},n.__iterateUncached=function(n,i){var o=this;return t.__iterate(function(t,i,u){return n(e.call(r,t,i,u),i,o)!==!1},i)},n.__iteratorUncached=function(n,i){var o=t.__iterator(He,i);return new Fe(function(){var i=o.next();if(i.done)return i;var u=i.value,s=u[0];return z(n,s,e.call(r,u[1],s,t),i)})},n}function Y(t,e){var r=this,n=ft(t);return n._iter=t,n.size=t.size,n.reverse=function(){return t},t.flip&&(n.flip=function(){var e=V(t);return e.reverse=function(){return t.flip()},e}),n.get=function(r,n){return t.get(e?r:-1-r,n)},n.has=function(r){return t.has(e?r:-1-r)},n.includes=function(e){ return t.includes(e)},n.cacheResult=pt,n.__iterate=function(r,n){var i=this,u=0;return n&&o(t),t.__iterate(function(t,o){return r(t,e?o:n?i.size-++u:u++,i)},!n)},n.__iterator=function(n,i){var u=0;i&&o(t);var s=t.__iterator(He,!i);return new Fe(function(){var t=s.next();if(t.done)return t;var o=t.value;return z(n,e?o[0]:i?r.size-++u:u++,o[1],t)})},n}function Q(t,e,r,n){var i=ft(t);return n&&(i.has=function(n){var i=t.get(n,ke);return i!==ke&&!!e.call(r,i,n,t)},i.get=function(n,i){var o=t.get(n,ke);return o!==ke&&e.call(r,o,n,t)?o:i}),i.__iterateUncached=function(i,o){var u=this,s=0;return t.__iterate(function(t,o,a){if(e.call(r,t,o,a))return s++,i(t,n?o:s-1,u)},o),s},i.__iteratorUncached=function(i,o){var u=t.__iterator(He,o),s=0;return new Fe(function(){for(;;){var o=u.next();if(o.done)return o;var a=o.value,c=a[0],h=a[1];if(e.call(r,h,c,t))return z(i,n?c:s++,h,o)}})},i}function X(t,e,r){var n=Sr().asMutable();return t.__iterate(function(i,o){n.update(e.call(r,i,o,t),0,function(t){return t+1})}),n.asImmutable()}function F(t,e,r){var n=v(t),i=(g(t)?Br():Sr()).asMutable();t.__iterate(function(o,u){i.update(e.call(r,o,u,t),function(t){return t=t||[],t.push(n?[u,o]:o),t})});var o=ht(t);return i.map(function(e){return at(t,o(e))})}function G(t,e,r,n){var i=t.size;if(a(e,r,i))return t;var o=c(e,i),s=h(r,i);if(o!==o||s!==s)return G(t.toSeq().cacheResult(),e,r,n);var f,p=s-o;p===p&&(f=p<0?0:p);var _=ft(t);return _.size=0===f?f:t.size&&f||void 0,!n&&q(t)&&f>=0&&(_.get=function(e,r){return e=u(this,e),e>=0&&ef)return S();var t=i.next() -;return n||e===Ve?t:e===Ne?z(e,s-1,void 0,t):z(e,s-1,t.value[1],t)})},_}function Z(t,e,r){var n=ft(t);return n.__iterateUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterate(n,i);var u=0;return t.__iterate(function(t,i,s){return e.call(r,t,i,s)&&++u&&n(t,i,o)}),u},n.__iteratorUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterator(n,i);var u=t.__iterator(He,i),s=!0;return new Fe(function(){if(!s)return S();var t=u.next();if(t.done)return t;var i=t.value,a=i[0],c=i[1];return e.call(r,c,a,o)?n===He?t:z(n,a,c,t):(s=!1,S())})},n}function $(t,e,r,n){var i=ft(t);return i.__iterateUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterate(i,o);var s=!0,a=0;return t.__iterate(function(t,o,c){if(!s||!(s=e.call(r,t,o,c)))return a++,i(t,n?o:a-1,u)}),a},i.__iteratorUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterator(i,o);var s=t.__iterator(He,o),a=!0,c=0;return new Fe(function(){var t,o,h;do{if(t=s.next(),t.done)return n||i===Ve?t:i===Ne?z(i,c++,void 0,t):z(i,c++,t.value[1],t);var f=t.value;o=f[0],h=f[1],a&&(a=e.call(r,h,o,u))}while(a);return i===He?t:z(i,o,h,t)})},i}function tt(t,e){var r=v(t),n=[t].concat(e).map(function(t){return l(t)?r&&(t=Be(t)):t=r?x(t):j(Array.isArray(t)?t:[t]),t}).filter(function(t){return 0!==t.size});if(0===n.length)return t;if(1===n.length){var i=n[0];if(i===t||r&&v(i)||y(t)&&y(i))return i}var o=new rr(n);return r?o=o.toKeyedSeq():y(t)||(o=o.toSetSeq()),o=o.flatten(!0),o.size=n.reduce(function(t,e){if(void 0!==t){var r=e.size;if(void 0!==r)return t+r}},0),o}function et(t,e,r){var n=ft(t);return n.__iterateUncached=function(i,o){function u(t,c){t.__iterate(function(t,o){return(!e||c0}function st(t,e,r,n){var i=ft(t),o=new rr(r).map(function(t){return t.size});return i.size=n?o.max():o.min(),i.__iterate=function(t,e){for(var r,n=this,i=this.__iterator(Ve,e),o=0;!(r=i.next()).done&&t(r.value,o++,n)!==!1;);return o},i.__iteratorUncached=function(t,i){var o=r.map(function(t){return t=We(t),O(i?t.reverse():t)}),u=0,s=!1;return new Fe(function(){var r;return s||(r=o.map(function(t){return t.next()}),s=n?r.every(function(t){return t.done}):r.some(function(t){return t.done})),s?S():z(t,u++,e.apply(null,r.map(function(t){return t.value})))})},i}function at(t,e){return t===e?t:q(t)?e:t.constructor(e)}function ct(t){if(t!==Object(t))throw new TypeError("Expected [K, V] tuple: "+t)}function ht(t){return v(t)?Be:y(t)?Je:Pe}function ft(t){return Object.create((v(t)?Ze:y(t)?$e:tr).prototype)}function pt(){return this._iter.cacheResult?(this._iter.cacheResult(), this.size=this._iter.size,this):Ge.prototype.cacheResult.call(this)}function _t(t,e){return void 0===t&&void 0===e?0:void 0===t?1:void 0===e?-1:t>e?1:t>>r)&je,s=(0===r?n:n>>>r)&je;return new Mr(e,1<>>=1)u[s]=1&r?e[o++]:void 0;return u[n]=i,new Dr(t,o+1,u)}function xt(t,e,r){for(var n=[],i=0;i>1&1431655765,t=(858993459&t)+(t>>2&858993459),t=t+(t>>4)&252645135,t+=t>>8,127&(t+=t>>16)}function Kt(t,e,r,n){var o=n?t:i(t);return o[e]=r,o}function Lt(t,e,r,n){var i=t.length+1;if(n&&e+1===i)return t[e]=r,t;for(var o=Array(i),u=0,s=0;so?0:o-r,c=u-r;return c>xe&&(c=xe),function(){if(i===c)return Wr;var t=e?--c:i++;return n&&n[t]}}function i(t,n,i){var s,a=t&&t.array,c=i>o?0:o-i>>n,h=1+(u-i>>n);return h>xe&&(h=xe),function(){for(;;){if(s){var t=s();if(t!==Wr)return t;s=null}if(c===h)return Wr;var o=e?--h:c++;s=r(a&&a[o],n-Ee,i+(o< Date: Mon, 2 Oct 2017 20:23:47 +0000 Subject: [PATCH 013/242] Deploy master to NPM branch --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ae4f9b236b..f984bc1af9 100644 --- a/README.md +++ b/README.md @@ -512,7 +512,7 @@ Contribution Use [Github issues](https://github.com/facebook/immutable-js/issues) for requests. -We actively welcome pull requests, learn how to [contribute](./.github/CONTRIBUTING.md). +We actively welcome pull requests, learn how to [contribute](./CONTRIBUTING.md). Changelog From 794f1ea6611e4745a44e29db909138f758c0df6a Mon Sep 17 00:00:00 2001 From: Travis CI Date: Mon, 2 Oct 2017 20:24:58 +0000 Subject: [PATCH 014/242] Deploy master to NPM branch --- dist/immutable.es.js | 2 +- dist/immutable.js | 2 +- dist/immutable.min.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/dist/immutable.es.js b/dist/immutable.es.js index 6ad87621b5..8d7124fa34 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -1505,7 +1505,7 @@ function sliceFactory(collection, begin, end, useKeys) { return iteratorDone(); } var step = iterator.next(); - if (useKeys || type === ITERATE_VALUES || step.done) { + if (useKeys || type === ITERATE_VALUES) { return step; } if (type === ITERATE_KEYS) { diff --git a/dist/immutable.js b/dist/immutable.js index 9647b37dce..1fcebdbc98 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -1511,7 +1511,7 @@ function sliceFactory(collection, begin, end, useKeys) { return iteratorDone(); } var step = iterator.next(); - if (useKeys || type === ITERATE_VALUES || step.done) { + if (useKeys || type === ITERATE_VALUES) { return step; } if (type === ITERATE_KEYS) { diff --git a/dist/immutable.min.js b/dist/immutable.min.js index e7319e908c..06ffc942ff 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -8,7 +8,7 @@ function k(t){var e=A(t);if(e)return e;if("object"==typeof t)return new nr(t);throw new TypeError("Expected Array or collection object of values, or keyed object: "+t)}function A(t){return D(t)?new rr(t):b(t)?new sr(t):I(t)?new ur(t):void 0}function R(t,e){if(t===e||t!==t&&e!==e)return!0;if(!t||!e)return!1;if("function"==typeof t.valueOf&&"function"==typeof e.valueOf){if(t=t.valueOf(),e=e.valueOf(),t===e||t!==t&&e!==e)return!0;if(!t||!e)return!1}return!!(w(t)&&w(e)&&t.equals(e))}function U(t,e){return K([],e||L,t,"",e&&e.length>2?[]:void 0,{"":t})}function K(t,e,r,n,i,o){var u=Array.isArray(r)?$e:T(r)?Ze:null;if(u){if(~t.indexOf(r))throw new TypeError("Cannot convert circular structure to Immutable");t.push(r),i&&""!==n&&i.push(n);var s=e.call(o,n,u(r).map(function(n,o){return K(t,e,n,o,i,r)}),i&&i.slice());return t.pop(),i&&i.pop(),s}return r}function L(t,e){return v(e)?e.toMap():e.toList()}function T(t){return t&&(t.constructor===Object||void 0===t.constructor)}function C(t){return t>>>1&1073741824|3221225471&t}function W(t){if(t===!1||null===t||void 0===t)return 0;if("function"==typeof t.valueOf&&((t=t.valueOf())===!1||null===t||void 0===t))return 0;if(t===!0)return 1;var e=typeof t;if("number"===e){if(t!==t||t===1/0)return 0;var r=0|t;for(r!==t&&(r^=4294967295*t);t>4294967295;)t/=4294967295,r^=t;return C(r)}if("string"===e)return t.length>lr?B(t):J(t);if("function"==typeof t.hashCode)return C(t.hashCode());if("object"===e)return P(t);if("function"==typeof t.toString)return J(""+t);throw Error("Value type "+e+" cannot be hashed.")}function B(t){var e=dr[t];return void 0===e&&(e=J(t),yr===vr&&(yr=0,dr={}),yr++,dr[t]=e),e}function J(t){for(var e=0,r=0;r0)switch(t.nodeType){case 1:return t.uniqueID;case 9:return t.documentElement&&t.documentElement.uniqueID}}function V(t){var e=ft(t);return e._iter=t,e.size=t.size,e.flip=function(){return t},e.reverse=function(){var e=t.reverse.apply(this);return e.flip=function(){return t.reverse()},e},e.has=function(e){return t.includes(e)},e.includes=function(e){return t.has(e)},e.cacheResult=pt,e.__iterateUncached=function(e,r){var n=this;return t.__iterate(function(t,r){return e(r,t,n)!==!1},r)},e.__iteratorUncached=function(e,r){if(e===He){var n=t.__iterator(e,r);return new Fe(function(){var t=n.next();if(!t.done){var e=t.value[0];t.value[0]=t.value[1],t.value[1]=e}return t})}return t.__iterator(e===Ve?Ne:Ve,r)},e}function H(t,e,r){var n=ft(t);return n.size=t.size,n.has=function(e){return t.has(e)},n.get=function(n,i){var o=t.get(n,ke);return o===ke?i:e.call(r,o,n,t)},n.__iterateUncached=function(n,i){var o=this;return t.__iterate(function(t,i,u){return n(e.call(r,t,i,u),i,o)!==!1},i)},n.__iteratorUncached=function(n,i){var o=t.__iterator(He,i);return new Fe(function(){var i=o.next();if(i.done)return i;var u=i.value,s=u[0];return z(n,s,e.call(r,u[1],s,t),i)})},n}function Y(t,e){var r=this,n=ft(t);return n._iter=t,n.size=t.size,n.reverse=function(){return t},t.flip&&(n.flip=function(){var e=V(t);return e.reverse=function(){return t.flip()},e}),n.get=function(r,n){return t.get(e?r:-1-r,n)},n.has=function(r){return t.has(e?r:-1-r)},n.includes=function(e){ return t.includes(e)},n.cacheResult=pt,n.__iterate=function(r,n){var i=this,u=0;return n&&o(t),t.__iterate(function(t,o){return r(t,e?o:n?i.size-++u:u++,i)},!n)},n.__iterator=function(n,i){var u=0;i&&o(t);var s=t.__iterator(He,!i);return new Fe(function(){var t=s.next();if(t.done)return t;var o=t.value;return z(n,e?o[0]:i?r.size-++u:u++,o[1],t)})},n}function Q(t,e,r,n){var i=ft(t);return n&&(i.has=function(n){var i=t.get(n,ke);return i!==ke&&!!e.call(r,i,n,t)},i.get=function(n,i){var o=t.get(n,ke);return o!==ke&&e.call(r,o,n,t)?o:i}),i.__iterateUncached=function(i,o){var u=this,s=0;return t.__iterate(function(t,o,a){if(e.call(r,t,o,a))return s++,i(t,n?o:s-1,u)},o),s},i.__iteratorUncached=function(i,o){var u=t.__iterator(He,o),s=0;return new Fe(function(){for(;;){var o=u.next();if(o.done)return o;var a=o.value,c=a[0],h=a[1];if(e.call(r,h,c,t))return z(i,n?c:s++,h,o)}})},i}function X(t,e,r){var n=Sr().asMutable();return t.__iterate(function(i,o){n.update(e.call(r,i,o,t),0,function(t){return t+1})}),n.asImmutable()}function F(t,e,r){var n=v(t),i=(g(t)?Br():Sr()).asMutable();t.__iterate(function(o,u){i.update(e.call(r,o,u,t),function(t){return t=t||[],t.push(n?[u,o]:o),t})});var o=ht(t);return i.map(function(e){return at(t,o(e))})}function G(t,e,r,n){var i=t.size;if(a(e,r,i))return t;var o=c(e,i),s=h(r,i);if(o!==o||s!==s)return G(t.toSeq().cacheResult(),e,r,n);var f,p=s-o;p===p&&(f=p<0?0:p);var _=ft(t);return _.size=0===f?f:t.size&&f||void 0,!n&&q(t)&&f>=0&&(_.get=function(e,r){return e=u(this,e),e>=0&&ef)return S();var t=i.next() -;return n||e===Ve||t.done?t:e===Ne?z(e,s-1,void 0,t):z(e,s-1,t.value[1],t)})},_}function Z(t,e,r){var n=ft(t);return n.__iterateUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterate(n,i);var u=0;return t.__iterate(function(t,i,s){return e.call(r,t,i,s)&&++u&&n(t,i,o)}),u},n.__iteratorUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterator(n,i);var u=t.__iterator(He,i),s=!0;return new Fe(function(){if(!s)return S();var t=u.next();if(t.done)return t;var i=t.value,a=i[0],c=i[1];return e.call(r,c,a,o)?n===He?t:z(n,a,c,t):(s=!1,S())})},n}function $(t,e,r,n){var i=ft(t);return i.__iterateUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterate(i,o);var s=!0,a=0;return t.__iterate(function(t,o,c){if(!s||!(s=e.call(r,t,o,c)))return a++,i(t,n?o:a-1,u)}),a},i.__iteratorUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterator(i,o);var s=t.__iterator(He,o),a=!0,c=0;return new Fe(function(){var t,o,h;do{if(t=s.next(),t.done)return n||i===Ve?t:i===Ne?z(i,c++,void 0,t):z(i,c++,t.value[1],t);var f=t.value;o=f[0],h=f[1],a&&(a=e.call(r,h,o,u))}while(a);return i===He?t:z(i,o,h,t)})},i}function tt(t,e){var r=v(t),n=[t].concat(e).map(function(t){return l(t)?r&&(t=Be(t)):t=r?x(t):j(Array.isArray(t)?t:[t]),t}).filter(function(t){return 0!==t.size});if(0===n.length)return t;if(1===n.length){var i=n[0];if(i===t||r&&v(i)||y(t)&&y(i))return i}var o=new rr(n);return r?o=o.toKeyedSeq():y(t)||(o=o.toSetSeq()),o=o.flatten(!0),o.size=n.reduce(function(t,e){if(void 0!==t){var r=e.size;if(void 0!==r)return t+r}},0),o}function et(t,e,r){var n=ft(t);return n.__iterateUncached=function(i,o){function u(t,c){t.__iterate(function(t,o){return(!e||c0}function st(t,e,r,n){var i=ft(t),o=new rr(r).map(function(t){return t.size});return i.size=n?o.max():o.min(),i.__iterate=function(t,e){for(var r,n=this,i=this.__iterator(Ve,e),o=0;!(r=i.next()).done&&t(r.value,o++,n)!==!1;);return o},i.__iteratorUncached=function(t,i){var o=r.map(function(t){return t=We(t),O(i?t.reverse():t)}),u=0,s=!1;return new Fe(function(){var r;return s||(r=o.map(function(t){return t.next()}),s=n?r.every(function(t){return t.done}):r.some(function(t){return t.done})),s?S():z(t,u++,e.apply(null,r.map(function(t){return t.value})))})},i}function at(t,e){return t===e?t:q(t)?e:t.constructor(e)}function ct(t){if(t!==Object(t))throw new TypeError("Expected [K, V] tuple: "+t)}function ht(t){return v(t)?Be:y(t)?Je:Pe}function ft(t){return Object.create((v(t)?Ze:y(t)?$e:tr).prototype)}function pt(){return this._iter.cacheResult?(this._iter.cacheResult(), this.size=this._iter.size,this):Ge.prototype.cacheResult.call(this)}function _t(t,e){return void 0===t&&void 0===e?0:void 0===t?1:void 0===e?-1:t>e?1:t>>r)&je,s=(0===r?n:n>>>r)&je;return new Mr(e,1<>>=1)u[s]=1&r?e[o++]:void 0;return u[n]=i,new Dr(t,o+1,u)}function xt(t,e,r){for(var n=[],i=0;i>1&1431655765,t=(858993459&t)+(t>>2&858993459),t=t+(t>>4)&252645135,t+=t>>8,127&(t+=t>>16)}function Kt(t,e,r,n){var o=n?t:i(t);return o[e]=r,o}function Lt(t,e,r,n){var i=t.length+1;if(n&&e+1===i)return t[e]=r,t;for(var o=Array(i),u=0,s=0;so?0:o-r,c=u-r;return c>xe&&(c=xe),function(){if(i===c)return Wr;var t=e?--c:i++;return n&&n[t]}}function i(t,n,i){var s,a=t&&t.array,c=i>o?0:o-i>>n,h=1+(u-i>>n);return h>xe&&(h=xe),function(){for(;;){if(s){var t=s();if(t!==Wr)return t;s=null}if(c===h)return Wr;var o=e?--h:c++;s=r(a&&a[o],n-Ee,i+(o< Date: Mon, 2 Oct 2017 20:25:55 +0000 Subject: [PATCH 015/242] Deploy master to NPM branch --- README.md | 2 +- dist/immutable.es.js | 2 +- dist/immutable.js | 2 +- dist/immutable.min.js | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index f984bc1af9..ae4f9b236b 100644 --- a/README.md +++ b/README.md @@ -512,7 +512,7 @@ Contribution Use [Github issues](https://github.com/facebook/immutable-js/issues) for requests. -We actively welcome pull requests, learn how to [contribute](./CONTRIBUTING.md). +We actively welcome pull requests, learn how to [contribute](./.github/CONTRIBUTING.md). Changelog diff --git a/dist/immutable.es.js b/dist/immutable.es.js index 8d7124fa34..6ad87621b5 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -1505,7 +1505,7 @@ function sliceFactory(collection, begin, end, useKeys) { return iteratorDone(); } var step = iterator.next(); - if (useKeys || type === ITERATE_VALUES) { + if (useKeys || type === ITERATE_VALUES || step.done) { return step; } if (type === ITERATE_KEYS) { diff --git a/dist/immutable.js b/dist/immutable.js index 1fcebdbc98..9647b37dce 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -1511,7 +1511,7 @@ function sliceFactory(collection, begin, end, useKeys) { return iteratorDone(); } var step = iterator.next(); - if (useKeys || type === ITERATE_VALUES) { + if (useKeys || type === ITERATE_VALUES || step.done) { return step; } if (type === ITERATE_KEYS) { diff --git a/dist/immutable.min.js b/dist/immutable.min.js index 06ffc942ff..e7319e908c 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -8,7 +8,7 @@ function k(t){var e=A(t);if(e)return e;if("object"==typeof t)return new nr(t);throw new TypeError("Expected Array or collection object of values, or keyed object: "+t)}function A(t){return D(t)?new rr(t):b(t)?new sr(t):I(t)?new ur(t):void 0}function R(t,e){if(t===e||t!==t&&e!==e)return!0;if(!t||!e)return!1;if("function"==typeof t.valueOf&&"function"==typeof e.valueOf){if(t=t.valueOf(),e=e.valueOf(),t===e||t!==t&&e!==e)return!0;if(!t||!e)return!1}return!!(w(t)&&w(e)&&t.equals(e))}function U(t,e){return K([],e||L,t,"",e&&e.length>2?[]:void 0,{"":t})}function K(t,e,r,n,i,o){var u=Array.isArray(r)?$e:T(r)?Ze:null;if(u){if(~t.indexOf(r))throw new TypeError("Cannot convert circular structure to Immutable");t.push(r),i&&""!==n&&i.push(n);var s=e.call(o,n,u(r).map(function(n,o){return K(t,e,n,o,i,r)}),i&&i.slice());return t.pop(),i&&i.pop(),s}return r}function L(t,e){return v(e)?e.toMap():e.toList()}function T(t){return t&&(t.constructor===Object||void 0===t.constructor)}function C(t){return t>>>1&1073741824|3221225471&t}function W(t){if(t===!1||null===t||void 0===t)return 0;if("function"==typeof t.valueOf&&((t=t.valueOf())===!1||null===t||void 0===t))return 0;if(t===!0)return 1;var e=typeof t;if("number"===e){if(t!==t||t===1/0)return 0;var r=0|t;for(r!==t&&(r^=4294967295*t);t>4294967295;)t/=4294967295,r^=t;return C(r)}if("string"===e)return t.length>lr?B(t):J(t);if("function"==typeof t.hashCode)return C(t.hashCode());if("object"===e)return P(t);if("function"==typeof t.toString)return J(""+t);throw Error("Value type "+e+" cannot be hashed.")}function B(t){var e=dr[t];return void 0===e&&(e=J(t),yr===vr&&(yr=0,dr={}),yr++,dr[t]=e),e}function J(t){for(var e=0,r=0;r0)switch(t.nodeType){case 1:return t.uniqueID;case 9:return t.documentElement&&t.documentElement.uniqueID}}function V(t){var e=ft(t);return e._iter=t,e.size=t.size,e.flip=function(){return t},e.reverse=function(){var e=t.reverse.apply(this);return e.flip=function(){return t.reverse()},e},e.has=function(e){return t.includes(e)},e.includes=function(e){return t.has(e)},e.cacheResult=pt,e.__iterateUncached=function(e,r){var n=this;return t.__iterate(function(t,r){return e(r,t,n)!==!1},r)},e.__iteratorUncached=function(e,r){if(e===He){var n=t.__iterator(e,r);return new Fe(function(){var t=n.next();if(!t.done){var e=t.value[0];t.value[0]=t.value[1],t.value[1]=e}return t})}return t.__iterator(e===Ve?Ne:Ve,r)},e}function H(t,e,r){var n=ft(t);return n.size=t.size,n.has=function(e){return t.has(e)},n.get=function(n,i){var o=t.get(n,ke);return o===ke?i:e.call(r,o,n,t)},n.__iterateUncached=function(n,i){var o=this;return t.__iterate(function(t,i,u){return n(e.call(r,t,i,u),i,o)!==!1},i)},n.__iteratorUncached=function(n,i){var o=t.__iterator(He,i);return new Fe(function(){var i=o.next();if(i.done)return i;var u=i.value,s=u[0];return z(n,s,e.call(r,u[1],s,t),i)})},n}function Y(t,e){var r=this,n=ft(t);return n._iter=t,n.size=t.size,n.reverse=function(){return t},t.flip&&(n.flip=function(){var e=V(t);return e.reverse=function(){return t.flip()},e}),n.get=function(r,n){return t.get(e?r:-1-r,n)},n.has=function(r){return t.has(e?r:-1-r)},n.includes=function(e){ return t.includes(e)},n.cacheResult=pt,n.__iterate=function(r,n){var i=this,u=0;return n&&o(t),t.__iterate(function(t,o){return r(t,e?o:n?i.size-++u:u++,i)},!n)},n.__iterator=function(n,i){var u=0;i&&o(t);var s=t.__iterator(He,!i);return new Fe(function(){var t=s.next();if(t.done)return t;var o=t.value;return z(n,e?o[0]:i?r.size-++u:u++,o[1],t)})},n}function Q(t,e,r,n){var i=ft(t);return n&&(i.has=function(n){var i=t.get(n,ke);return i!==ke&&!!e.call(r,i,n,t)},i.get=function(n,i){var o=t.get(n,ke);return o!==ke&&e.call(r,o,n,t)?o:i}),i.__iterateUncached=function(i,o){var u=this,s=0;return t.__iterate(function(t,o,a){if(e.call(r,t,o,a))return s++,i(t,n?o:s-1,u)},o),s},i.__iteratorUncached=function(i,o){var u=t.__iterator(He,o),s=0;return new Fe(function(){for(;;){var o=u.next();if(o.done)return o;var a=o.value,c=a[0],h=a[1];if(e.call(r,h,c,t))return z(i,n?c:s++,h,o)}})},i}function X(t,e,r){var n=Sr().asMutable();return t.__iterate(function(i,o){n.update(e.call(r,i,o,t),0,function(t){return t+1})}),n.asImmutable()}function F(t,e,r){var n=v(t),i=(g(t)?Br():Sr()).asMutable();t.__iterate(function(o,u){i.update(e.call(r,o,u,t),function(t){return t=t||[],t.push(n?[u,o]:o),t})});var o=ht(t);return i.map(function(e){return at(t,o(e))})}function G(t,e,r,n){var i=t.size;if(a(e,r,i))return t;var o=c(e,i),s=h(r,i);if(o!==o||s!==s)return G(t.toSeq().cacheResult(),e,r,n);var f,p=s-o;p===p&&(f=p<0?0:p);var _=ft(t);return _.size=0===f?f:t.size&&f||void 0,!n&&q(t)&&f>=0&&(_.get=function(e,r){return e=u(this,e),e>=0&&ef)return S();var t=i.next() -;return n||e===Ve?t:e===Ne?z(e,s-1,void 0,t):z(e,s-1,t.value[1],t)})},_}function Z(t,e,r){var n=ft(t);return n.__iterateUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterate(n,i);var u=0;return t.__iterate(function(t,i,s){return e.call(r,t,i,s)&&++u&&n(t,i,o)}),u},n.__iteratorUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterator(n,i);var u=t.__iterator(He,i),s=!0;return new Fe(function(){if(!s)return S();var t=u.next();if(t.done)return t;var i=t.value,a=i[0],c=i[1];return e.call(r,c,a,o)?n===He?t:z(n,a,c,t):(s=!1,S())})},n}function $(t,e,r,n){var i=ft(t);return i.__iterateUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterate(i,o);var s=!0,a=0;return t.__iterate(function(t,o,c){if(!s||!(s=e.call(r,t,o,c)))return a++,i(t,n?o:a-1,u)}),a},i.__iteratorUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterator(i,o);var s=t.__iterator(He,o),a=!0,c=0;return new Fe(function(){var t,o,h;do{if(t=s.next(),t.done)return n||i===Ve?t:i===Ne?z(i,c++,void 0,t):z(i,c++,t.value[1],t);var f=t.value;o=f[0],h=f[1],a&&(a=e.call(r,h,o,u))}while(a);return i===He?t:z(i,o,h,t)})},i}function tt(t,e){var r=v(t),n=[t].concat(e).map(function(t){return l(t)?r&&(t=Be(t)):t=r?x(t):j(Array.isArray(t)?t:[t]),t}).filter(function(t){return 0!==t.size});if(0===n.length)return t;if(1===n.length){var i=n[0];if(i===t||r&&v(i)||y(t)&&y(i))return i}var o=new rr(n);return r?o=o.toKeyedSeq():y(t)||(o=o.toSetSeq()),o=o.flatten(!0),o.size=n.reduce(function(t,e){if(void 0!==t){var r=e.size;if(void 0!==r)return t+r}},0),o}function et(t,e,r){var n=ft(t);return n.__iterateUncached=function(i,o){function u(t,c){t.__iterate(function(t,o){return(!e||c0}function st(t,e,r,n){var i=ft(t),o=new rr(r).map(function(t){return t.size});return i.size=n?o.max():o.min(),i.__iterate=function(t,e){for(var r,n=this,i=this.__iterator(Ve,e),o=0;!(r=i.next()).done&&t(r.value,o++,n)!==!1;);return o},i.__iteratorUncached=function(t,i){var o=r.map(function(t){return t=We(t),O(i?t.reverse():t)}),u=0,s=!1;return new Fe(function(){var r;return s||(r=o.map(function(t){return t.next()}),s=n?r.every(function(t){return t.done}):r.some(function(t){return t.done})),s?S():z(t,u++,e.apply(null,r.map(function(t){return t.value})))})},i}function at(t,e){return t===e?t:q(t)?e:t.constructor(e)}function ct(t){if(t!==Object(t))throw new TypeError("Expected [K, V] tuple: "+t)}function ht(t){return v(t)?Be:y(t)?Je:Pe}function ft(t){return Object.create((v(t)?Ze:y(t)?$e:tr).prototype)}function pt(){return this._iter.cacheResult?(this._iter.cacheResult(), this.size=this._iter.size,this):Ge.prototype.cacheResult.call(this)}function _t(t,e){return void 0===t&&void 0===e?0:void 0===t?1:void 0===e?-1:t>e?1:t>>r)&je,s=(0===r?n:n>>>r)&je;return new Mr(e,1<>>=1)u[s]=1&r?e[o++]:void 0;return u[n]=i,new Dr(t,o+1,u)}function xt(t,e,r){for(var n=[],i=0;i>1&1431655765,t=(858993459&t)+(t>>2&858993459),t=t+(t>>4)&252645135,t+=t>>8,127&(t+=t>>16)}function Kt(t,e,r,n){var o=n?t:i(t);return o[e]=r,o}function Lt(t,e,r,n){var i=t.length+1;if(n&&e+1===i)return t[e]=r,t;for(var o=Array(i),u=0,s=0;so?0:o-r,c=u-r;return c>xe&&(c=xe),function(){if(i===c)return Wr;var t=e?--c:i++;return n&&n[t]}}function i(t,n,i){var s,a=t&&t.array,c=i>o?0:o-i>>n,h=1+(u-i>>n);return h>xe&&(h=xe),function(){for(;;){if(s){var t=s();if(t!==Wr)return t;s=null}if(c===h)return Wr;var o=e?--h:c++;s=r(a&&a[o],n-Ee,i+(o< Date: Mon, 2 Oct 2017 22:59:46 +0000 Subject: [PATCH 016/242] Deploy master to NPM branch --- dist/immutable.js.flow | 50 +++++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/dist/immutable.js.flow b/dist/immutable.js.flow index c555c5463e..6d853f534a 100644 --- a/dist/immutable.js.flow +++ b/dist/immutable.js.flow @@ -28,6 +28,10 @@ * @flow */ +// Helper type that represents plain objects allowed as arguments to +// some constructors and functions. +type PlainObjInput = {[key: K]: V, __proto__: null}; + declare class _Collection /*implements ValueObject*/ { equals(other: mixed): boolean; hashCode(): number; @@ -201,7 +205,7 @@ declare class Collection extends _Collection { declare class KeyedCollection extends Collection { static (iter?: Iterable<[K, V]>): KeyedCollection; - static (obj?: { [key: K]: V }): KeyedCollection; + static (obj?: PlainObjInput): KeyedCollection; toJS(): { [key: string]: mixed }; toJSON(): { [key: string]: V }; @@ -210,7 +214,7 @@ declare class KeyedCollection extends Collection { flip(): KeyedCollection; concat(...iters: Array>): KeyedCollection; - concat(...iters: Array<{[key: string]: C}>): KeyedCollection; + concat(...iters: Array>): KeyedCollection; map( mapper: (value: V, key: K, iter: this) => M, @@ -416,7 +420,7 @@ declare class Seq extends _Collection { static (iter: KeyedSeq): KeyedSeq; static (iter: SetSeq): SetSeq; static (iter?: Iterable): IndexedSeq; - static (iter: { [key: K]: V }): KeyedSeq; + static (iter: PlainObjInput): KeyedSeq; static isSeq: typeof isSeq; @@ -427,13 +431,13 @@ declare class Seq extends _Collection { declare class KeyedSeq extends Seq mixins KeyedCollection { static (iter?: Iterable<[K, V]>): KeyedSeq; - static (iter?: { [key: K]: V }): KeyedSeq; + static (iter?: PlainObjInput): KeyedSeq; // Override specialized return types flip(): KeyedSeq; concat(...iters: Array>): KeyedSeq; - concat(...iters: Array<{[key: string]: C}>): KeyedSeq; + concat(...iters: Array>): KeyedSeq; map( mapper: (value: V, key: K, iter: this) => M, @@ -781,8 +785,8 @@ declare class List<+T> extends IndexedCollection { declare function isMap(maybeMap: mixed): boolean %checks(maybeMap instanceof Map); declare class Map extends KeyedCollection { - static (obj?: {[key: K]: V}): Map; static (collection: Iterable<[K, V]>): Map; + static (obj?: PlainObjInput): Map; static isMap: typeof isMap; @@ -801,21 +805,21 @@ declare class Map extends KeyedCollection { update(key: K, notSetValue: V_, updater: (value: V) => V_): Map; merge( - ...collections: (Iterable<[K_, V_]> | { [key: K_]: V_ })[] + ...collections: (Iterable<[K_, V_]> | PlainObjInput)[] ): Map; mergeWith( merger: (oldVal: V, newVal: W, key: K) => X, - ...collections: (Iterable<[K_, W]> | { [key: K_]: W })[] + ...collections: (Iterable<[K_, W]> | PlainObjInput)[] ): Map; mergeDeep( - ...collections: (Iterable<[K_, V_]> | { [key: K_]: V_ })[] + ...collections: (Iterable<[K_, V_]> | PlainObjInput)[] ): Map; mergeDeepWith( merger: (oldVal: V, newVal: W, key: K) => X, - ...collections: (Iterable<[K_, W]> | { [key: K_]: W })[] + ...collections: (Iterable<[K_, W]> | PlainObjInput)[] ): Map; setIn(keyPath: Iterable, value: mixed): this; @@ -834,11 +838,11 @@ declare class Map extends KeyedCollection { mergeIn( keyPath: Iterable, - ...collections: (Iterable | { [key: string]: mixed })[] + ...collections: (Iterable | PlainObjInput)[] ): this; mergeDeepIn( keyPath: Iterable, - ...collections: (Iterable | { [key: string]: mixed })[] + ...collections: (Iterable | PlainObjInput)[] ): this; withMutations(mutator: (mutable: this) => mixed): this; @@ -850,7 +854,7 @@ declare class Map extends KeyedCollection { flip(): Map; concat(...iters: Array>): Map; - concat(...iters: Array<{[key: string]: C}>): Map; + concat(...iters: Array>): Map; map( mapper: (value: V, key: K, iter: this) => M, @@ -878,8 +882,8 @@ declare class Map extends KeyedCollection { declare function isOrderedMap(maybeOrderedMap: mixed): boolean %checks(maybeOrderedMap instanceof OrderedMap); declare class OrderedMap extends Map { - static (obj?: {[key: K]: V}): OrderedMap; static (collection: Iterable<[K, V]>): OrderedMap; + static (obj?: PlainObjInput): OrderedMap; static isOrderedMap: typeof isOrderedMap; @@ -895,21 +899,21 @@ declare class OrderedMap extends Map { update(key: K, notSetValue: V_, updater: (value: V) => V_): OrderedMap; merge( - ...collections: (Iterable<[K_, V_]> | { [key: K_]: V_ })[] + ...collections: (Iterable<[K_, V_]> | PlainObjInput)[] ): OrderedMap; mergeWith( merger: (oldVal: V, newVal: W, key: K) => X, - ...collections: (Iterable<[K_, W]> | { [key: K_]: W })[] + ...collections: (Iterable<[K_, W]> | PlainObjInput)[] ): OrderedMap; mergeDeep( - ...collections: (Iterable<[K_, V_]> | { [key: K_]: V_ })[] + ...collections: (Iterable<[K_, V_]> | PlainObjInput)[] ): OrderedMap; mergeDeepWith( merger: (oldVal: V, newVal: W, key: K) => X, - ...collections: (Iterable<[K_, W]> | { [key: K_]: W })[] + ...collections: (Iterable<[K_, W]> | PlainObjInput)[] ): OrderedMap; setIn(keyPath: Iterable, value: mixed): this; @@ -928,11 +932,11 @@ declare class OrderedMap extends Map { mergeIn( keyPath: Iterable, - ...collections: (Iterable | { [key: string]: mixed })[] + ...collections: (Iterable | PlainObjInput)[] ): this; mergeDeepIn( keyPath: Iterable, - ...collections: (Iterable | { [key: string]: mixed })[] + ...collections: (Iterable | PlainObjInput)[] ): this; withMutations(mutator: (mutable: this) => mixed): this; @@ -944,7 +948,7 @@ declare class OrderedMap extends Map { flip(): OrderedMap; concat(...iters: Array>): OrderedMap; - concat(...iters: Array<{[key: string]: C}>): OrderedMap; + concat(...iters: Array>): OrderedMap; map( mapper: (value: V, key: K, iter: this) => M, @@ -976,7 +980,7 @@ declare class Set<+T> extends SetCollection { static of(...values: T[]): Set; static fromKeys(iter: Iterable<[T, mixed]>): Set; - static fromKeys(object: { [key: K]: V }): Set; + static fromKeys(object: PlainObjInput): Set; static intersect(sets: Iterable>): Set; static union(sets: Iterable>): Set; @@ -1024,7 +1028,7 @@ declare class OrderedSet<+T> extends Set { static of(...values: T[]): OrderedSet; static fromKeys(iter: Iterable<[T, mixed]>): OrderedSet; - static fromKeys(object: { [key: K]: V }): OrderedSet; + static fromKeys(object: PlainObjInput): OrderedSet; static isOrderedSet: typeof isOrderedSet; From a770ae2c1c5dffc7ff1ffd29684bd7537c1c3169 Mon Sep 17 00:00:00 2001 From: Travis CI Date: Mon, 2 Oct 2017 23:03:45 +0000 Subject: [PATCH 017/242] Deploy master to NPM branch --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c2c5cccd45..f014012f69 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "immutable", - "version": "4.0.0-rc.3", + "version": "4.0.0-rc.4", "description": "Immutable Data Collections", "license": "MIT", "homepage": "https://facebook.github.com/immutable-js", From 41def9699eb33ad32edc870f97f056339bc38598 Mon Sep 17 00:00:00 2001 From: Travis CI Date: Tue, 3 Oct 2017 21:52:02 +0000 Subject: [PATCH 018/242] Deploy master to NPM branch --- bower.json | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/bower.json b/bower.json index 0322021172..f014012f69 100644 --- a/bower.json +++ b/bower.json @@ -1,28 +1,31 @@ { "name": "immutable", + "version": "4.0.0-rc.4", "description": "Immutable Data Collections", "license": "MIT", - "homepage": "https://github.com/facebook/immutable-js", + "homepage": "https://facebook.github.com/immutable-js", "author": { "name": "Lee Byron", - "homepage": "https://github.com/leebyron" + "url": "https://github.com/leebyron" }, "repository": { "type": "git", "url": "git://github.com/facebook/immutable-js.git" }, + "bugs": { + "url": "https://github.com/facebook/immutable-js/issues" + }, "main": "dist/immutable.js", + "module": "dist/immutable.es.js", + "typings": "dist/immutable-nonambient.d.ts", "typescript": { "definition": "dist/immutable.d.ts" }, - "ignore": [ - "**/.*", - "__tests__", - "resources", - "src", - "type-definitions", - "package.json", - "Gruntfile.js" + "files": [ + "dist", + "contrib", + "README.md", + "LICENSE" ], "keywords": [ "immutable", @@ -36,4 +39,4 @@ "sequence", "iteration" ] -} +} \ No newline at end of file From 2ce6cc971be614edd4e1cfc4709b4c66fb73ced9 Mon Sep 17 00:00:00 2001 From: Travis CI Date: Wed, 4 Oct 2017 01:08:20 +0000 Subject: [PATCH 019/242] Deploy master to NPM branch --- dist/immutable.js.flow | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/dist/immutable.js.flow b/dist/immutable.js.flow index 6d853f534a..95a532abb3 100644 --- a/dist/immutable.js.flow +++ b/dist/immutable.js.flow @@ -1296,18 +1296,22 @@ declare class Stack<+T> extends IndexedCollection { declare function Range(start?: number, end?: number, step?: number): IndexedSeq; declare function Repeat(value: T, times?: number): IndexedSeq; +// The type of a Record factory function. +type RecordFactory = Class>; + +// The type of runtime Record instances. +type RecordOf = RecordInstance & Values; + declare function isRecord(maybeRecord: any): boolean %checks(maybeRecord instanceof RecordInstance); declare class Record { - static (spec: Values, name?: string): Class>; - constructor(spec: Values, name?: string): Class>; + static (spec: Values, name?: string): RecordFactory; + constructor(spec: Values, name?: string): RecordFactory; static isRecord: typeof isRecord; static getDescriptiveName(record: RecordInstance): string; } -type RecordOf = RecordInstance & Values; - declare class RecordInstance { static (values?: $Shape | Iterable<[string, any]>): RecordOf; // Note: a constructor can only create an instance of RecordInstance, @@ -1435,7 +1439,7 @@ export type { KeyedSeq, IndexedSeq, SetSeq, + RecordFactory, RecordOf, - RecordInstance, ValueObject, } From 2a91dd9b96041a4b940d53b7c4ea5ed38e03b053 Mon Sep 17 00:00:00 2001 From: Travis CI Date: Wed, 4 Oct 2017 02:22:07 +0000 Subject: [PATCH 020/242] Deploy master to NPM branch --- dist/immutable-nonambient.d.ts | 8 ++++++++ dist/immutable.d.ts | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/dist/immutable-nonambient.d.ts b/dist/immutable-nonambient.d.ts index 626776cef7..f974f681f8 100644 --- a/dist/immutable-nonambient.d.ts +++ b/dist/immutable-nonambient.d.ts @@ -211,6 +211,14 @@ * `.equals()` method returns true, that both values `.hashCode()` method * return the same value. `hash()` may be used to produce those values. * + * For non-Immutable Objects that do not provide a `.hashCode()` functions + * (including plain Objects, plain Arrays, Date objects, etc), a unique hash + * value will be created for each *instance*. That is, the create hash + * represents referential equality, and not value equality for Objects. This + * ensures that if that Object is mutated over time that its hash code will + * remain consistent, allowing Objects to be used as keys and values in + * Immutable.js collections. + * * Note that `hash()` attempts to balance between speed and avoiding * collisions, however it makes no attempt to produce secure hashes. * diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index 4895986680..ea1b4decd3 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -211,6 +211,14 @@ declare module Immutable { * `.equals()` method returns true, that both values `.hashCode()` method * return the same value. `hash()` may be used to produce those values. * + * For non-Immutable Objects that do not provide a `.hashCode()` functions + * (including plain Objects, plain Arrays, Date objects, etc), a unique hash + * value will be created for each *instance*. That is, the create hash + * represents referential equality, and not value equality for Objects. This + * ensures that if that Object is mutated over time that its hash code will + * remain consistent, allowing Objects to be used as keys and values in + * Immutable.js collections. + * * Note that `hash()` attempts to balance between speed and avoiding * collisions, however it makes no attempt to produce secure hashes. * From ad3476f7bfabd5c8ff38415b8c191414e218c620 Mon Sep 17 00:00:00 2001 From: Travis CI Date: Wed, 4 Oct 2017 02:31:28 +0000 Subject: [PATCH 021/242] Deploy master to NPM branch --- dist/immutable-nonambient.d.ts | 33 +++++++++++++++++++++++++++++++++ dist/immutable.d.ts | 33 +++++++++++++++++++++++++++++++++ dist/immutable.es.js | 1 + dist/immutable.js | 1 + dist/immutable.js.flow | 6 ++++++ dist/immutable.min.js | 16 ++++++++-------- 6 files changed, 82 insertions(+), 8 deletions(-) diff --git a/dist/immutable-nonambient.d.ts b/dist/immutable-nonambient.d.ts index f974f681f8..35d110eb8c 100644 --- a/dist/immutable-nonambient.d.ts +++ b/dist/immutable-nonambient.d.ts @@ -362,6 +362,11 @@ * to be equal][Hash Collision]. If two values have different `hashCode`s, * they must not be equal. * + * Note: `hashCode()` is not guaranteed to always be called before + * `equals()`. Most but not all Immutable.js collections use hash codes to + * organize their internal data structures, while all Immutable.js + * collections use equality during lookups. + * * [Hash Collision]: http://en.wikipedia.org/wiki/Collision_(computer_science) */ hashCode(): number; @@ -797,6 +802,11 @@ */ asMutable(): this; + /** + * @see `Map#wasAltered` + */ + wasAltered(): boolean; + /** * @see `Map#asImmutable` */ @@ -1522,6 +1532,14 @@ */ asMutable(): this; + /** + * Returns true if this is a mutable copy (see `asMutable()`) and mutative + * alterations have been applied. + * + * @see `Map#asMutable` + */ + wasAltered(): boolean; + /** * The yin to `asMutable`'s yang. Because it applies to mutable collections, * this operation is *mutable* and returns itself. Once performed, the mutable @@ -1860,6 +1878,11 @@ */ asMutable(): this; + /** + * @see `Map#wasAltered` + */ + wasAltered(): boolean; + /** * @see `Map#asImmutable` */ @@ -2225,6 +2248,11 @@ */ asMutable(): this; + /** + * @see `Map#wasAltered` + */ + wasAltered(): boolean; + /** * @see `Map#asImmutable` */ @@ -2572,6 +2600,11 @@ */ asMutable(): this; + /** + * @see `Map#wasAltered` + */ + wasAltered(): boolean; + /** * @see `Map#asImmutable` */ diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index ea1b4decd3..c6db30ebdc 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -362,6 +362,11 @@ declare module Immutable { * to be equal][Hash Collision]. If two values have different `hashCode`s, * they must not be equal. * + * Note: `hashCode()` is not guaranteed to always be called before + * `equals()`. Most but not all Immutable.js collections use hash codes to + * organize their internal data structures, while all Immutable.js + * collections use equality during lookups. + * * [Hash Collision]: http://en.wikipedia.org/wiki/Collision_(computer_science) */ hashCode(): number; @@ -797,6 +802,11 @@ declare module Immutable { */ asMutable(): this; + /** + * @see `Map#wasAltered` + */ + wasAltered(): boolean; + /** * @see `Map#asImmutable` */ @@ -1522,6 +1532,14 @@ declare module Immutable { */ asMutable(): this; + /** + * Returns true if this is a mutable copy (see `asMutable()`) and mutative + * alterations have been applied. + * + * @see `Map#asMutable` + */ + wasAltered(): boolean; + /** * The yin to `asMutable`'s yang. Because it applies to mutable collections, * this operation is *mutable* and returns itself. Once performed, the mutable @@ -1860,6 +1878,11 @@ declare module Immutable { */ asMutable(): this; + /** + * @see `Map#wasAltered` + */ + wasAltered(): boolean; + /** * @see `Map#asImmutable` */ @@ -2225,6 +2248,11 @@ declare module Immutable { */ asMutable(): this; + /** + * @see `Map#wasAltered` + */ + wasAltered(): boolean; + /** * @see `Map#asImmutable` */ @@ -2572,6 +2600,11 @@ declare module Immutable { */ asMutable(): this; + /** + * @see `Map#wasAltered` + */ + wasAltered(): boolean; + /** * @see `Map#asImmutable` */ diff --git a/dist/immutable.es.js b/dist/immutable.es.js index 6ad87621b5..24901107ef 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -3091,6 +3091,7 @@ var List = (function (IndexedCollection$$1) { return emptyList(); } this.__ownerID = ownerID; + this.__altered = false; return this; } return makeList( diff --git a/dist/immutable.js b/dist/immutable.js index 9647b37dce..820bb79f0a 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -3097,6 +3097,7 @@ var List = (function (IndexedCollection$$1) { return emptyList(); } this.__ownerID = ownerID; + this.__altered = false; return this; } return makeList( diff --git a/dist/immutable.js.flow b/dist/immutable.js.flow index 95a532abb3..f306d3be41 100644 --- a/dist/immutable.js.flow +++ b/dist/immutable.js.flow @@ -665,6 +665,7 @@ declare class List<+T> extends IndexedCollection { withMutations(mutator: (mutable: this) => mixed): this; asMutable(): this; + wasAltered(): boolean; asImmutable(): this; // Override specialized return types @@ -847,6 +848,7 @@ declare class Map extends KeyedCollection { withMutations(mutator: (mutable: this) => mixed): this; asMutable(): this; + wasAltered(): boolean; asImmutable(): this; // Override specialized return types @@ -941,6 +943,7 @@ declare class OrderedMap extends Map { withMutations(mutator: (mutable: this) => mixed): this; asMutable(): this; + wasAltered(): boolean; asImmutable(): this; // Override specialized return types @@ -1000,6 +1003,7 @@ declare class Set<+T> extends SetCollection { withMutations(mutator: (mutable: this) => mixed): this; asMutable(): this; + wasAltered(): boolean; asImmutable(): this; // Override specialized return types @@ -1175,6 +1179,7 @@ declare class Stack<+T> extends IndexedCollection { withMutations(mutator: (mutable: this) => mixed): this; asMutable(): this; + wasAltered(): boolean; asImmutable(): this; // Override specialized return types @@ -1359,6 +1364,7 @@ declare class RecordInstance { withMutations(mutator: (mutable: this) => mixed): this & T; asMutable(): this & T; + wasAltered(): boolean; asImmutable(): this & T; @@iterator(): Iterator<[$Keys, any]>; diff --git a/dist/immutable.min.js b/dist/immutable.min.js index e7319e908c..65cc03ba68 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -23,14 +23,14 @@ var r=this._iter.__iterator(Ve,e);return new Fe(function(){for(;;){var e=r.next( ;return this.updateIn(t,St(),function(t){return"function"==typeof t.merge?t.merge.apply(t,e):e[e.length-1]})},e.prototype.mergeDeep=function(){return xt(this,jt,arguments)},e.prototype.mergeDeepWith=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return xt(this,kt(t),e)},e.prototype.mergeDeepIn=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return this.updateIn(t,St(),function(t){return"function"==typeof t.mergeDeep?t.mergeDeep.apply(t,e):e[e.length-1]})},e.prototype.sort=function(t){return Br(it(this,t))},e.prototype.sortBy=function(t,e){return Br(it(this,e,t))},e.prototype.withMutations=function(t){var e=this.asMutable();return t(e),e.wasAltered()?e.__ensureOwner(this.__ownerID):this},e.prototype.asMutable=function(){return this.__ownerID?this:this.__ensureOwner(new n)},e.prototype.asImmutable=function(){return this.__ensureOwner()},e.prototype.wasAltered=function(){return this.__altered},e.prototype.__iterator=function(t,e){return new jr(this,t,e)},e.prototype.__iterate=function(t,e){var r=this,n=0;return this._root&&this._root.iterate(function(e){return n++,t(e[1],e[0],r)},e),n},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?zt(this.size,this._root,t,this.__hash):0===this.size?St():(this.__ownerID=t,this.__altered=!1,this)},e}(Be);Sr.isMap=gt;var Ir="@@__IMMUTABLE_MAP__@@",br=Sr.prototype;br[Ir]=!0,br.delete=br.remove,br.removeIn=br.deleteIn,br.removeAll=br.deleteAll,br["@@transducer/init"]=br.asMutable,br["@@transducer/step"]=function(t,e){return t.set(e[0],e[1])},br["@@transducer/result"]=function(t){return t.asImmutable()};var Or=function(t,e){this.ownerID=t,this.entries=e};Or.prototype.get=function(t,e,r,n){for(var i=this.entries,o=0,u=i.length;o=kr)return Dt(t,h,o,u) ;var l=t&&t===this.ownerID,v=l?h:i(h);return _?c?f===p-1?v.pop():v[f]=v.pop():v[f]=[o,u]:v.push([o,u]),l?(this.entries=v,this):new Or(t,v)}};var Mr=function(t,e,r){this.ownerID=t,this.bitmap=e,this.nodes=r};Mr.prototype.get=function(t,e,r,n){void 0===e&&(e=W(r));var i=1<<((0===t?e:e>>>t)&je),o=this.bitmap;return 0==(o&i)?n:this.nodes[Ut(o&i-1)].get(t+Ee,e,r,n)},Mr.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=W(n));var s=(0===e?r:r>>>e)&je,a=1<=Ar)return Et(t,p,c,s,l);if(h&&!l&&2===p.length&&Ot(p[1^f]))return p[1^f];if(h&&l&&1===p.length&&Ot(l))return l;var v=t&&t===this.ownerID,y=h?l?c:c^a:c|a,d=h?l?Kt(p,f,l,v):Tt(p,f,v):Lt(p,f,l,v);return v?(this.bitmap=y,this.nodes=d,this):new Mr(t,y,d)};var Dr=function(t,e,r){this.ownerID=t,this.count=e,this.nodes=r};Dr.prototype.get=function(t,e,r,n){void 0===e&&(e=W(r));var i=(0===t?e:e>>>t)&je,o=this.nodes[i];return o?o.get(t+Ee,e,r,n):n},Dr.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=W(n));var s=(0===e?r:r>>>e)&je,a=i===ke,c=this.nodes,h=c[s];if(a&&!h)return this;var f=bt(h,t,e+Ee,r,n,i,o,u);if(f===h)return this;var p=this.count;if(h){if(!f&&--p0&&i=0&&t0;)e[r]=arguments[r+1];return Qt(this,t,e)},e.prototype.mergeDeep=function(){return Qt(this,jt,arguments)},e.prototype.mergeDeepWith=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Qt(this,kt(t),e)},e.prototype.setSize=function(t){return Yt(this,0,t)},e.prototype.slice=function(t,e){var r=this.size;return a(t,e,r)?this:Yt(this,c(t,r),h(e,r))},e.prototype.__iterator=function(t,e){var r=e?this.size:0,n=Wt(this,e);return new Fe(function(){var i=n();return i===Wr?S():z(t,e?--r:r++,i)})},e.prototype.__iterate=function(t,e){for(var r,n=this,i=e?this.size:0,o=Wt(this,e);(r=o())!==Wr&&t(r,e?--i:i++,n)!==!1;);return i},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Bt(this._origin,this._capacity,this._level,this._root,this._tail,t,this.__hash):0===this.size?Jt():(this.__ownerID=t,this)},e}(Je);Ur.isList=Ct;var Kr="@@__IMMUTABLE_LIST__@@",Lr=Ur.prototype;Lr[Kr]=!0,Lr.delete=Lr.remove,Lr.setIn=br.setIn,Lr.deleteIn=Lr.removeIn=br.removeIn,Lr.update=br.update,Lr.updateIn=br.updateIn,Lr.mergeIn=br.mergeIn,Lr.mergeDeepIn=br.mergeDeepIn, -Lr.withMutations=br.withMutations,Lr.asMutable=br.asMutable,Lr.asImmutable=br.asImmutable,Lr.wasAltered=br.wasAltered,Lr["@@transducer/init"]=Lr.asMutable,Lr["@@transducer/step"]=function(t,e){return t.push(e)},Lr["@@transducer/result"]=br["@@transducer/result"];var Tr=function(t,e){this.array=t,this.ownerID=e};Tr.prototype.removeBefore=function(t,e,r){if(r===e?1<>>e&je;if(n>=this.array.length)return new Tr([],t);var i,o=0===n;if(e>0){var u=this.array[n];if((i=u&&u.removeBefore(t,e-Ee,r))===u&&o)return this}if(o&&!i)return this;var s=Vt(this,t);if(!o)for(var a=0;a>>e&je;if(n>=this.array.length)return this;var i;if(e>0){var o=this.array[n];if((i=o&&o.removeAfter(t,e-Ee,r))===o&&n===this.array.length-1)return this}var u=Vt(this,t);return u.array.splice(n+1),i&&(u.array[n]=i),u};var Cr,Wr={},Br=function(t){function e(t){return null===t||void 0===t?Zt():Ft(t)?t:Zt().withMutations(function(e){var r=Be(t);yt(r.size),r.forEach(function(t,r){return e.set(r,t)})})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("OrderedMap {","}")},e.prototype.get=function(t,e){var r=this._map.get(t);return void 0!==r?this._list.get(r)[1]:e},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._map.clear(),this._list.clear(),this):Zt()},e.prototype.set=function(t,e){return $t(this,t,e)},e.prototype.remove=function(t){return $t(this,t,ke)},e.prototype.wasAltered=function(){return this._map.wasAltered()||this._list.wasAltered()},e.prototype.__iterate=function(t,e){var r=this;return this._list.__iterate(function(e){return e&&t(e[1],e[0],r)},e)},e.prototype.__iterator=function(t,e){return this._list.fromEntrySeq().__iterator(t,e)},e.prototype.__ensureOwner=function(t){ -if(t===this.__ownerID)return this;var e=this._map.__ensureOwner(t),r=this._list.__ensureOwner(t);return t?Gt(e,r,t,this.__hash):0===this.size?Zt():(this.__ownerID=t,this._map=e,this._list=r,this)},e}(Sr);Br.isOrderedMap=Ft,Br.prototype[Te]=!0,Br.prototype.delete=Br.prototype.remove;var Jr,Pr=function(t){function e(t){return null===t||void 0===t?re():te(t)?t:re().pushAll(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("Stack [","]")},e.prototype.get=function(t,e){var r=this._head;for(t=u(this,t);r&&t--;)r=r.next;return r?r.value:e},e.prototype.peek=function(){return this._head&&this._head.value},e.prototype.push=function(){var t=arguments;if(0===arguments.length)return this;for(var e=this.size+arguments.length,r=this._head,n=arguments.length-1;n>=0;n--)r={value:t[n],next:r};return this.__ownerID?(this.size=e,this._head=r,this.__hash=void 0,this.__altered=!0,this):ee(e,r)},e.prototype.pushAll=function(e){if(e=t(e),0===e.size)return this;if(0===this.size&&te(e))return e;yt(e.size);var r=this.size,n=this._head;return e.__iterate(function(t){r++,n={value:t,next:n}},!0),this.__ownerID?(this.size=r,this._head=n,this.__hash=void 0,this.__altered=!0,this):ee(r,n)},e.prototype.pop=function(){return this.slice(1)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):re()},e.prototype.slice=function(e,r){if(a(e,r,this.size))return this;var n=c(e,this.size);if(h(r,this.size)!==this.size)return t.prototype.slice.call(this,e,r);for(var i=this.size-n,o=this._head;n--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):ee(i,o)},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?ee(this.size,this._head,t,this.__hash):0===this.size?re():(this.__ownerID=t,this.__altered=!1,this)},e.prototype.__iterate=function(t,e){var r=this -;if(e)return new rr(this.toArray()).__iterate(function(e,n){return t(e,n,r)},e);for(var n=0,i=this._head;i&&t(i.value,n++,r)!==!1;)i=i.next;return n},e.prototype.__iterator=function(t,e){if(e)return new rr(this.toArray()).__iterator(t,e);var r=0,n=this._head;return new Fe(function(){if(n){var e=n.value;return n=n.next,z(t,r++,e)}return S()})},e}(Je);Pr.isStack=te;var Nr="@@__IMMUTABLE_STACK__@@",Vr=Pr.prototype;Vr[Nr]=!0,Vr.withMutations=br.withMutations,Vr.asMutable=br.asMutable,Vr.asImmutable=br.asImmutable,Vr.wasAltered=br.wasAltered,Vr.shift=Vr.pop,Vr.unshift=Vr.push,Vr.unshiftAll=Vr.pushAll,Vr["@@transducer/init"]=Vr.asMutable,Vr["@@transducer/step"]=function(t,e){return t.unshift(e)},Vr["@@transducer/result"]=br["@@transducer/result"];var Hr,Yr=function(t){function e(e){return null===e||void 0===e?ae():oe(e)&&!g(e)?e:ae().withMutations(function(r){var n=t(e);yt(n.size),n.forEach(function(t){return r.add(t)})})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(Be(t).keySeq())},e.intersect=function(t){return t=We(t).toArray(),t.length?Xr.intersect.apply(e(t.pop()),t):ae()},e.union=function(t){return t=We(t).toArray(),t.length?Xr.union.apply(e(t.pop()),t):ae()},e.prototype.toString=function(){return this.__toString("Set {","}")},e.prototype.has=function(t){return this._map.has(t)},e.prototype.add=function(t){return ue(this,this._map.set(t,!0))},e.prototype.remove=function(t){return ue(this,this._map.remove(t))},e.prototype.clear=function(){return ue(this,this._map.clear())},e.prototype.union=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return e=e.filter(function(t){return 0!==t.size}),0===e.length?this:0!==this.size||this.__ownerID||1!==e.length?this.withMutations(function(r){for(var n=0;n0;)e[r]=arguments[r+1];return this.union.apply(this,e)},e.prototype.sort=function(t){return rn(it(this,t))},e.prototype.sortBy=function(t,e){return rn(it(this,e,t))},e.prototype.wasAltered=function(){return this._map.wasAltered()},e.prototype.__iterate=function(t,e){var r=this;return this._map.__iterate(function(e,n){return t(n,n,r)},e)},e.prototype.__iterator=function(t,e){return this._map.map(function(t,e){return e}).__iterator(t,e)},e.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var e=this._map.__ensureOwner(t);return t?this.__make(e,t):0===this.size?ae():(this.__ownerID=t,this._map=e,this)},e}(Pe);Yr.isSet=oe;var Qr="@@__IMMUTABLE_SET__@@",Xr=Yr.prototype;Xr[Qr]=!0,Xr.delete=Xr.remove,Xr.mergeDeep=Xr.merge,Xr.mergeDeepWith=Xr.mergeWith,Xr.withMutations=br.withMutations,Xr.asMutable=br.asMutable,Xr.asImmutable=br.asImmutable,Xr["@@transducer/init"]=Xr.asMutable,Xr["@@transducer/step"]=function(t,e){return t.add(e)},Xr["@@transducer/result"]=br["@@transducer/result"],Xr.__empty=ae,Xr.__make=se;var Fr,Gr,Zr=function(t){function e(t,r,n){if(!(this instanceof e))return new e(t,r,n);if(vt(0!==n,"Cannot step a Range by 0"),t=t||0,void 0===r&&(r=1/0),n=void 0===n?1:Math.abs(n),r=0&&e=0&&r0;)e[r]=arguments[r+1];return Qt(this,t,e)},e.prototype.mergeDeep=function(){return Qt(this,jt,arguments)},e.prototype.mergeDeepWith=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Qt(this,kt(t),e)},e.prototype.setSize=function(t){return Yt(this,0,t)},e.prototype.slice=function(t,e){var r=this.size;return a(t,e,r)?this:Yt(this,c(t,r),h(e,r))},e.prototype.__iterator=function(t,e){var r=e?this.size:0,n=Wt(this,e);return new Fe(function(){var i=n();return i===Wr?S():z(t,e?--r:r++,i)})},e.prototype.__iterate=function(t,e){for(var r,n=this,i=e?this.size:0,o=Wt(this,e);(r=o())!==Wr&&t(r,e?--i:i++,n)!==!1;);return i},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Bt(this._origin,this._capacity,this._level,this._root,this._tail,t,this.__hash):0===this.size?Jt():(this.__ownerID=t,this.__altered=!1,this)},e}(Je);Ur.isList=Ct;var Kr="@@__IMMUTABLE_LIST__@@",Lr=Ur.prototype;Lr[Kr]=!0,Lr.delete=Lr.remove,Lr.setIn=br.setIn,Lr.deleteIn=Lr.removeIn=br.removeIn,Lr.update=br.update,Lr.updateIn=br.updateIn,Lr.mergeIn=br.mergeIn, +Lr.mergeDeepIn=br.mergeDeepIn,Lr.withMutations=br.withMutations,Lr.asMutable=br.asMutable,Lr.asImmutable=br.asImmutable,Lr.wasAltered=br.wasAltered,Lr["@@transducer/init"]=Lr.asMutable,Lr["@@transducer/step"]=function(t,e){return t.push(e)},Lr["@@transducer/result"]=br["@@transducer/result"];var Tr=function(t,e){this.array=t,this.ownerID=e};Tr.prototype.removeBefore=function(t,e,r){if(r===e?1<>>e&je;if(n>=this.array.length)return new Tr([],t);var i,o=0===n;if(e>0){var u=this.array[n];if((i=u&&u.removeBefore(t,e-Ee,r))===u&&o)return this}if(o&&!i)return this;var s=Vt(this,t);if(!o)for(var a=0;a>>e&je;if(n>=this.array.length)return this;var i;if(e>0){var o=this.array[n];if((i=o&&o.removeAfter(t,e-Ee,r))===o&&n===this.array.length-1)return this}var u=Vt(this,t);return u.array.splice(n+1),i&&(u.array[n]=i),u};var Cr,Wr={},Br=function(t){function e(t){return null===t||void 0===t?Zt():Ft(t)?t:Zt().withMutations(function(e){var r=Be(t);yt(r.size),r.forEach(function(t,r){return e.set(r,t)})})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("OrderedMap {","}")},e.prototype.get=function(t,e){var r=this._map.get(t);return void 0!==r?this._list.get(r)[1]:e},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._map.clear(),this._list.clear(),this):Zt()},e.prototype.set=function(t,e){return $t(this,t,e)},e.prototype.remove=function(t){return $t(this,t,ke)},e.prototype.wasAltered=function(){return this._map.wasAltered()||this._list.wasAltered()},e.prototype.__iterate=function(t,e){var r=this;return this._list.__iterate(function(e){return e&&t(e[1],e[0],r)},e)},e.prototype.__iterator=function(t,e){return this._list.fromEntrySeq().__iterator(t,e)}, +e.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var e=this._map.__ensureOwner(t),r=this._list.__ensureOwner(t);return t?Gt(e,r,t,this.__hash):0===this.size?Zt():(this.__ownerID=t,this._map=e,this._list=r,this)},e}(Sr);Br.isOrderedMap=Ft,Br.prototype[Te]=!0,Br.prototype.delete=Br.prototype.remove;var Jr,Pr=function(t){function e(t){return null===t||void 0===t?re():te(t)?t:re().pushAll(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("Stack [","]")},e.prototype.get=function(t,e){var r=this._head;for(t=u(this,t);r&&t--;)r=r.next;return r?r.value:e},e.prototype.peek=function(){return this._head&&this._head.value},e.prototype.push=function(){var t=arguments;if(0===arguments.length)return this;for(var e=this.size+arguments.length,r=this._head,n=arguments.length-1;n>=0;n--)r={value:t[n],next:r};return this.__ownerID?(this.size=e,this._head=r,this.__hash=void 0,this.__altered=!0,this):ee(e,r)},e.prototype.pushAll=function(e){if(e=t(e),0===e.size)return this;if(0===this.size&&te(e))return e;yt(e.size);var r=this.size,n=this._head;return e.__iterate(function(t){r++,n={value:t,next:n}},!0),this.__ownerID?(this.size=r,this._head=n,this.__hash=void 0,this.__altered=!0,this):ee(r,n)},e.prototype.pop=function(){return this.slice(1)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):re()},e.prototype.slice=function(e,r){if(a(e,r,this.size))return this;var n=c(e,this.size);if(h(r,this.size)!==this.size)return t.prototype.slice.call(this,e,r);for(var i=this.size-n,o=this._head;n--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):ee(i,o)},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?ee(this.size,this._head,t,this.__hash):0===this.size?re():(this.__ownerID=t,this.__altered=!1,this)}, +e.prototype.__iterate=function(t,e){var r=this;if(e)return new rr(this.toArray()).__iterate(function(e,n){return t(e,n,r)},e);for(var n=0,i=this._head;i&&t(i.value,n++,r)!==!1;)i=i.next;return n},e.prototype.__iterator=function(t,e){if(e)return new rr(this.toArray()).__iterator(t,e);var r=0,n=this._head;return new Fe(function(){if(n){var e=n.value;return n=n.next,z(t,r++,e)}return S()})},e}(Je);Pr.isStack=te;var Nr="@@__IMMUTABLE_STACK__@@",Vr=Pr.prototype;Vr[Nr]=!0,Vr.withMutations=br.withMutations,Vr.asMutable=br.asMutable,Vr.asImmutable=br.asImmutable,Vr.wasAltered=br.wasAltered,Vr.shift=Vr.pop,Vr.unshift=Vr.push,Vr.unshiftAll=Vr.pushAll,Vr["@@transducer/init"]=Vr.asMutable,Vr["@@transducer/step"]=function(t,e){return t.unshift(e)},Vr["@@transducer/result"]=br["@@transducer/result"];var Hr,Yr=function(t){function e(e){return null===e||void 0===e?ae():oe(e)&&!g(e)?e:ae().withMutations(function(r){var n=t(e);yt(n.size),n.forEach(function(t){return r.add(t)})})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(Be(t).keySeq())},e.intersect=function(t){return t=We(t).toArray(),t.length?Xr.intersect.apply(e(t.pop()),t):ae()},e.union=function(t){return t=We(t).toArray(),t.length?Xr.union.apply(e(t.pop()),t):ae()},e.prototype.toString=function(){return this.__toString("Set {","}")},e.prototype.has=function(t){return this._map.has(t)},e.prototype.add=function(t){return ue(this,this._map.set(t,!0))},e.prototype.remove=function(t){return ue(this,this._map.remove(t))},e.prototype.clear=function(){return ue(this,this._map.clear())},e.prototype.union=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return e=e.filter(function(t){return 0!==t.size}),0===e.length?this:0!==this.size||this.__ownerID||1!==e.length?this.withMutations(function(r){for(var n=0;n0;)e[r]=arguments[r+1];return this.union.apply(this,e)},e.prototype.sort=function(t){return rn(it(this,t))},e.prototype.sortBy=function(t,e){return rn(it(this,e,t))},e.prototype.wasAltered=function(){return this._map.wasAltered()},e.prototype.__iterate=function(t,e){var r=this;return this._map.__iterate(function(e,n){return t(n,n,r)},e)},e.prototype.__iterator=function(t,e){return this._map.map(function(t,e){return e}).__iterator(t,e)},e.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var e=this._map.__ensureOwner(t);return t?this.__make(e,t):0===this.size?ae():(this.__ownerID=t,this._map=e,this)},e}(Pe);Yr.isSet=oe;var Qr="@@__IMMUTABLE_SET__@@",Xr=Yr.prototype;Xr[Qr]=!0,Xr.delete=Xr.remove,Xr.mergeDeep=Xr.merge,Xr.mergeDeepWith=Xr.mergeWith,Xr.withMutations=br.withMutations,Xr.asMutable=br.asMutable,Xr.asImmutable=br.asImmutable,Xr["@@transducer/init"]=Xr.asMutable,Xr["@@transducer/step"]=function(t,e){return t.add(e)},Xr["@@transducer/result"]=br["@@transducer/result"],Xr.__empty=ae,Xr.__make=se;var Fr,Gr,Zr=function(t){function e(t,r,n){if(!(this instanceof e))return new e(t,r,n);if(vt(0!==n,"Cannot step a Range by 0"),t=t||0,void 0===r&&(r=1/0),n=void 0===n?1:Math.abs(n),r=0&&e=0&&rthis.size?e:this.find(function(e,r){return r===t},void 0,e)},has:function(t){return(t=u(this,t))>=0&&(void 0!==this.size?this.size===1/0||t Date: Wed, 4 Oct 2017 02:36:16 +0000 Subject: [PATCH 022/242] Deploy master to NPM branch --- dist/immutable-nonambient.d.ts | 28 ---------------------------- dist/immutable.d.ts | 28 ---------------------------- dist/immutable.es.js | 1 - dist/immutable.js | 1 - dist/immutable.js.flow | 6 ------ dist/immutable.min.js | 16 ++++++++-------- 6 files changed, 8 insertions(+), 72 deletions(-) diff --git a/dist/immutable-nonambient.d.ts b/dist/immutable-nonambient.d.ts index 35d110eb8c..9f20a49480 100644 --- a/dist/immutable-nonambient.d.ts +++ b/dist/immutable-nonambient.d.ts @@ -802,11 +802,6 @@ */ asMutable(): this; - /** - * @see `Map#wasAltered` - */ - wasAltered(): boolean; - /** * @see `Map#asImmutable` */ @@ -1532,14 +1527,6 @@ */ asMutable(): this; - /** - * Returns true if this is a mutable copy (see `asMutable()`) and mutative - * alterations have been applied. - * - * @see `Map#asMutable` - */ - wasAltered(): boolean; - /** * The yin to `asMutable`'s yang. Because it applies to mutable collections, * this operation is *mutable* and returns itself. Once performed, the mutable @@ -1878,11 +1865,6 @@ */ asMutable(): this; - /** - * @see `Map#wasAltered` - */ - wasAltered(): boolean; - /** * @see `Map#asImmutable` */ @@ -2248,11 +2230,6 @@ */ asMutable(): this; - /** - * @see `Map#wasAltered` - */ - wasAltered(): boolean; - /** * @see `Map#asImmutable` */ @@ -2600,11 +2577,6 @@ */ asMutable(): this; - /** - * @see `Map#wasAltered` - */ - wasAltered(): boolean; - /** * @see `Map#asImmutable` */ diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index c6db30ebdc..27b8a59a73 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -802,11 +802,6 @@ declare module Immutable { */ asMutable(): this; - /** - * @see `Map#wasAltered` - */ - wasAltered(): boolean; - /** * @see `Map#asImmutable` */ @@ -1532,14 +1527,6 @@ declare module Immutable { */ asMutable(): this; - /** - * Returns true if this is a mutable copy (see `asMutable()`) and mutative - * alterations have been applied. - * - * @see `Map#asMutable` - */ - wasAltered(): boolean; - /** * The yin to `asMutable`'s yang. Because it applies to mutable collections, * this operation is *mutable* and returns itself. Once performed, the mutable @@ -1878,11 +1865,6 @@ declare module Immutable { */ asMutable(): this; - /** - * @see `Map#wasAltered` - */ - wasAltered(): boolean; - /** * @see `Map#asImmutable` */ @@ -2248,11 +2230,6 @@ declare module Immutable { */ asMutable(): this; - /** - * @see `Map#wasAltered` - */ - wasAltered(): boolean; - /** * @see `Map#asImmutable` */ @@ -2600,11 +2577,6 @@ declare module Immutable { */ asMutable(): this; - /** - * @see `Map#wasAltered` - */ - wasAltered(): boolean; - /** * @see `Map#asImmutable` */ diff --git a/dist/immutable.es.js b/dist/immutable.es.js index 24901107ef..6ad87621b5 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -3091,7 +3091,6 @@ var List = (function (IndexedCollection$$1) { return emptyList(); } this.__ownerID = ownerID; - this.__altered = false; return this; } return makeList( diff --git a/dist/immutable.js b/dist/immutable.js index 820bb79f0a..9647b37dce 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -3097,7 +3097,6 @@ var List = (function (IndexedCollection$$1) { return emptyList(); } this.__ownerID = ownerID; - this.__altered = false; return this; } return makeList( diff --git a/dist/immutable.js.flow b/dist/immutable.js.flow index f306d3be41..95a532abb3 100644 --- a/dist/immutable.js.flow +++ b/dist/immutable.js.flow @@ -665,7 +665,6 @@ declare class List<+T> extends IndexedCollection { withMutations(mutator: (mutable: this) => mixed): this; asMutable(): this; - wasAltered(): boolean; asImmutable(): this; // Override specialized return types @@ -848,7 +847,6 @@ declare class Map extends KeyedCollection { withMutations(mutator: (mutable: this) => mixed): this; asMutable(): this; - wasAltered(): boolean; asImmutable(): this; // Override specialized return types @@ -943,7 +941,6 @@ declare class OrderedMap extends Map { withMutations(mutator: (mutable: this) => mixed): this; asMutable(): this; - wasAltered(): boolean; asImmutable(): this; // Override specialized return types @@ -1003,7 +1000,6 @@ declare class Set<+T> extends SetCollection { withMutations(mutator: (mutable: this) => mixed): this; asMutable(): this; - wasAltered(): boolean; asImmutable(): this; // Override specialized return types @@ -1179,7 +1175,6 @@ declare class Stack<+T> extends IndexedCollection { withMutations(mutator: (mutable: this) => mixed): this; asMutable(): this; - wasAltered(): boolean; asImmutable(): this; // Override specialized return types @@ -1364,7 +1359,6 @@ declare class RecordInstance { withMutations(mutator: (mutable: this) => mixed): this & T; asMutable(): this & T; - wasAltered(): boolean; asImmutable(): this & T; @@iterator(): Iterator<[$Keys, any]>; diff --git a/dist/immutable.min.js b/dist/immutable.min.js index 65cc03ba68..e7319e908c 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -23,14 +23,14 @@ var r=this._iter.__iterator(Ve,e);return new Fe(function(){for(;;){var e=r.next( ;return this.updateIn(t,St(),function(t){return"function"==typeof t.merge?t.merge.apply(t,e):e[e.length-1]})},e.prototype.mergeDeep=function(){return xt(this,jt,arguments)},e.prototype.mergeDeepWith=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return xt(this,kt(t),e)},e.prototype.mergeDeepIn=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return this.updateIn(t,St(),function(t){return"function"==typeof t.mergeDeep?t.mergeDeep.apply(t,e):e[e.length-1]})},e.prototype.sort=function(t){return Br(it(this,t))},e.prototype.sortBy=function(t,e){return Br(it(this,e,t))},e.prototype.withMutations=function(t){var e=this.asMutable();return t(e),e.wasAltered()?e.__ensureOwner(this.__ownerID):this},e.prototype.asMutable=function(){return this.__ownerID?this:this.__ensureOwner(new n)},e.prototype.asImmutable=function(){return this.__ensureOwner()},e.prototype.wasAltered=function(){return this.__altered},e.prototype.__iterator=function(t,e){return new jr(this,t,e)},e.prototype.__iterate=function(t,e){var r=this,n=0;return this._root&&this._root.iterate(function(e){return n++,t(e[1],e[0],r)},e),n},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?zt(this.size,this._root,t,this.__hash):0===this.size?St():(this.__ownerID=t,this.__altered=!1,this)},e}(Be);Sr.isMap=gt;var Ir="@@__IMMUTABLE_MAP__@@",br=Sr.prototype;br[Ir]=!0,br.delete=br.remove,br.removeIn=br.deleteIn,br.removeAll=br.deleteAll,br["@@transducer/init"]=br.asMutable,br["@@transducer/step"]=function(t,e){return t.set(e[0],e[1])},br["@@transducer/result"]=function(t){return t.asImmutable()};var Or=function(t,e){this.ownerID=t,this.entries=e};Or.prototype.get=function(t,e,r,n){for(var i=this.entries,o=0,u=i.length;o=kr)return Dt(t,h,o,u) ;var l=t&&t===this.ownerID,v=l?h:i(h);return _?c?f===p-1?v.pop():v[f]=v.pop():v[f]=[o,u]:v.push([o,u]),l?(this.entries=v,this):new Or(t,v)}};var Mr=function(t,e,r){this.ownerID=t,this.bitmap=e,this.nodes=r};Mr.prototype.get=function(t,e,r,n){void 0===e&&(e=W(r));var i=1<<((0===t?e:e>>>t)&je),o=this.bitmap;return 0==(o&i)?n:this.nodes[Ut(o&i-1)].get(t+Ee,e,r,n)},Mr.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=W(n));var s=(0===e?r:r>>>e)&je,a=1<=Ar)return Et(t,p,c,s,l);if(h&&!l&&2===p.length&&Ot(p[1^f]))return p[1^f];if(h&&l&&1===p.length&&Ot(l))return l;var v=t&&t===this.ownerID,y=h?l?c:c^a:c|a,d=h?l?Kt(p,f,l,v):Tt(p,f,v):Lt(p,f,l,v);return v?(this.bitmap=y,this.nodes=d,this):new Mr(t,y,d)};var Dr=function(t,e,r){this.ownerID=t,this.count=e,this.nodes=r};Dr.prototype.get=function(t,e,r,n){void 0===e&&(e=W(r));var i=(0===t?e:e>>>t)&je,o=this.nodes[i];return o?o.get(t+Ee,e,r,n):n},Dr.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=W(n));var s=(0===e?r:r>>>e)&je,a=i===ke,c=this.nodes,h=c[s];if(a&&!h)return this;var f=bt(h,t,e+Ee,r,n,i,o,u);if(f===h)return this;var p=this.count;if(h){if(!f&&--p0&&i=0&&t0;)e[r]=arguments[r+1];return Qt(this,t,e)},e.prototype.mergeDeep=function(){return Qt(this,jt,arguments)},e.prototype.mergeDeepWith=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Qt(this,kt(t),e)},e.prototype.setSize=function(t){return Yt(this,0,t)},e.prototype.slice=function(t,e){var r=this.size;return a(t,e,r)?this:Yt(this,c(t,r),h(e,r))},e.prototype.__iterator=function(t,e){var r=e?this.size:0,n=Wt(this,e);return new Fe(function(){var i=n();return i===Wr?S():z(t,e?--r:r++,i)})},e.prototype.__iterate=function(t,e){for(var r,n=this,i=e?this.size:0,o=Wt(this,e);(r=o())!==Wr&&t(r,e?--i:i++,n)!==!1;);return i},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Bt(this._origin,this._capacity,this._level,this._root,this._tail,t,this.__hash):0===this.size?Jt():(this.__ownerID=t,this.__altered=!1,this)},e}(Je);Ur.isList=Ct;var Kr="@@__IMMUTABLE_LIST__@@",Lr=Ur.prototype;Lr[Kr]=!0,Lr.delete=Lr.remove,Lr.setIn=br.setIn,Lr.deleteIn=Lr.removeIn=br.removeIn,Lr.update=br.update,Lr.updateIn=br.updateIn,Lr.mergeIn=br.mergeIn, -Lr.mergeDeepIn=br.mergeDeepIn,Lr.withMutations=br.withMutations,Lr.asMutable=br.asMutable,Lr.asImmutable=br.asImmutable,Lr.wasAltered=br.wasAltered,Lr["@@transducer/init"]=Lr.asMutable,Lr["@@transducer/step"]=function(t,e){return t.push(e)},Lr["@@transducer/result"]=br["@@transducer/result"];var Tr=function(t,e){this.array=t,this.ownerID=e};Tr.prototype.removeBefore=function(t,e,r){if(r===e?1<>>e&je;if(n>=this.array.length)return new Tr([],t);var i,o=0===n;if(e>0){var u=this.array[n];if((i=u&&u.removeBefore(t,e-Ee,r))===u&&o)return this}if(o&&!i)return this;var s=Vt(this,t);if(!o)for(var a=0;a>>e&je;if(n>=this.array.length)return this;var i;if(e>0){var o=this.array[n];if((i=o&&o.removeAfter(t,e-Ee,r))===o&&n===this.array.length-1)return this}var u=Vt(this,t);return u.array.splice(n+1),i&&(u.array[n]=i),u};var Cr,Wr={},Br=function(t){function e(t){return null===t||void 0===t?Zt():Ft(t)?t:Zt().withMutations(function(e){var r=Be(t);yt(r.size),r.forEach(function(t,r){return e.set(r,t)})})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("OrderedMap {","}")},e.prototype.get=function(t,e){var r=this._map.get(t);return void 0!==r?this._list.get(r)[1]:e},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._map.clear(),this._list.clear(),this):Zt()},e.prototype.set=function(t,e){return $t(this,t,e)},e.prototype.remove=function(t){return $t(this,t,ke)},e.prototype.wasAltered=function(){return this._map.wasAltered()||this._list.wasAltered()},e.prototype.__iterate=function(t,e){var r=this;return this._list.__iterate(function(e){return e&&t(e[1],e[0],r)},e)},e.prototype.__iterator=function(t,e){return this._list.fromEntrySeq().__iterator(t,e)}, -e.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var e=this._map.__ensureOwner(t),r=this._list.__ensureOwner(t);return t?Gt(e,r,t,this.__hash):0===this.size?Zt():(this.__ownerID=t,this._map=e,this._list=r,this)},e}(Sr);Br.isOrderedMap=Ft,Br.prototype[Te]=!0,Br.prototype.delete=Br.prototype.remove;var Jr,Pr=function(t){function e(t){return null===t||void 0===t?re():te(t)?t:re().pushAll(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("Stack [","]")},e.prototype.get=function(t,e){var r=this._head;for(t=u(this,t);r&&t--;)r=r.next;return r?r.value:e},e.prototype.peek=function(){return this._head&&this._head.value},e.prototype.push=function(){var t=arguments;if(0===arguments.length)return this;for(var e=this.size+arguments.length,r=this._head,n=arguments.length-1;n>=0;n--)r={value:t[n],next:r};return this.__ownerID?(this.size=e,this._head=r,this.__hash=void 0,this.__altered=!0,this):ee(e,r)},e.prototype.pushAll=function(e){if(e=t(e),0===e.size)return this;if(0===this.size&&te(e))return e;yt(e.size);var r=this.size,n=this._head;return e.__iterate(function(t){r++,n={value:t,next:n}},!0),this.__ownerID?(this.size=r,this._head=n,this.__hash=void 0,this.__altered=!0,this):ee(r,n)},e.prototype.pop=function(){return this.slice(1)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):re()},e.prototype.slice=function(e,r){if(a(e,r,this.size))return this;var n=c(e,this.size);if(h(r,this.size)!==this.size)return t.prototype.slice.call(this,e,r);for(var i=this.size-n,o=this._head;n--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):ee(i,o)},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?ee(this.size,this._head,t,this.__hash):0===this.size?re():(this.__ownerID=t,this.__altered=!1,this)}, -e.prototype.__iterate=function(t,e){var r=this;if(e)return new rr(this.toArray()).__iterate(function(e,n){return t(e,n,r)},e);for(var n=0,i=this._head;i&&t(i.value,n++,r)!==!1;)i=i.next;return n},e.prototype.__iterator=function(t,e){if(e)return new rr(this.toArray()).__iterator(t,e);var r=0,n=this._head;return new Fe(function(){if(n){var e=n.value;return n=n.next,z(t,r++,e)}return S()})},e}(Je);Pr.isStack=te;var Nr="@@__IMMUTABLE_STACK__@@",Vr=Pr.prototype;Vr[Nr]=!0,Vr.withMutations=br.withMutations,Vr.asMutable=br.asMutable,Vr.asImmutable=br.asImmutable,Vr.wasAltered=br.wasAltered,Vr.shift=Vr.pop,Vr.unshift=Vr.push,Vr.unshiftAll=Vr.pushAll,Vr["@@transducer/init"]=Vr.asMutable,Vr["@@transducer/step"]=function(t,e){return t.unshift(e)},Vr["@@transducer/result"]=br["@@transducer/result"];var Hr,Yr=function(t){function e(e){return null===e||void 0===e?ae():oe(e)&&!g(e)?e:ae().withMutations(function(r){var n=t(e);yt(n.size),n.forEach(function(t){return r.add(t)})})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(Be(t).keySeq())},e.intersect=function(t){return t=We(t).toArray(),t.length?Xr.intersect.apply(e(t.pop()),t):ae()},e.union=function(t){return t=We(t).toArray(),t.length?Xr.union.apply(e(t.pop()),t):ae()},e.prototype.toString=function(){return this.__toString("Set {","}")},e.prototype.has=function(t){return this._map.has(t)},e.prototype.add=function(t){return ue(this,this._map.set(t,!0))},e.prototype.remove=function(t){return ue(this,this._map.remove(t))},e.prototype.clear=function(){return ue(this,this._map.clear())},e.prototype.union=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return e=e.filter(function(t){return 0!==t.size}),0===e.length?this:0!==this.size||this.__ownerID||1!==e.length?this.withMutations(function(r){for(var n=0;n0;)e[r]=arguments[r+1];return this.union.apply(this,e)},e.prototype.sort=function(t){return rn(it(this,t))},e.prototype.sortBy=function(t,e){return rn(it(this,e,t))},e.prototype.wasAltered=function(){return this._map.wasAltered()},e.prototype.__iterate=function(t,e){var r=this;return this._map.__iterate(function(e,n){return t(n,n,r)},e)},e.prototype.__iterator=function(t,e){return this._map.map(function(t,e){return e}).__iterator(t,e)},e.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var e=this._map.__ensureOwner(t);return t?this.__make(e,t):0===this.size?ae():(this.__ownerID=t,this._map=e,this)},e}(Pe);Yr.isSet=oe;var Qr="@@__IMMUTABLE_SET__@@",Xr=Yr.prototype;Xr[Qr]=!0,Xr.delete=Xr.remove,Xr.mergeDeep=Xr.merge,Xr.mergeDeepWith=Xr.mergeWith,Xr.withMutations=br.withMutations,Xr.asMutable=br.asMutable,Xr.asImmutable=br.asImmutable,Xr["@@transducer/init"]=Xr.asMutable,Xr["@@transducer/step"]=function(t,e){return t.add(e)},Xr["@@transducer/result"]=br["@@transducer/result"],Xr.__empty=ae,Xr.__make=se;var Fr,Gr,Zr=function(t){function e(t,r,n){if(!(this instanceof e))return new e(t,r,n);if(vt(0!==n,"Cannot step a Range by 0"),t=t||0,void 0===r&&(r=1/0),n=void 0===n?1:Math.abs(n),r=0&&e=0&&r0;)e[r]=arguments[r+1];return Qt(this,t,e)},e.prototype.mergeDeep=function(){return Qt(this,jt,arguments)},e.prototype.mergeDeepWith=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Qt(this,kt(t),e)},e.prototype.setSize=function(t){return Yt(this,0,t)},e.prototype.slice=function(t,e){var r=this.size;return a(t,e,r)?this:Yt(this,c(t,r),h(e,r))},e.prototype.__iterator=function(t,e){var r=e?this.size:0,n=Wt(this,e);return new Fe(function(){var i=n();return i===Wr?S():z(t,e?--r:r++,i)})},e.prototype.__iterate=function(t,e){for(var r,n=this,i=e?this.size:0,o=Wt(this,e);(r=o())!==Wr&&t(r,e?--i:i++,n)!==!1;);return i},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Bt(this._origin,this._capacity,this._level,this._root,this._tail,t,this.__hash):0===this.size?Jt():(this.__ownerID=t,this)},e}(Je);Ur.isList=Ct;var Kr="@@__IMMUTABLE_LIST__@@",Lr=Ur.prototype;Lr[Kr]=!0,Lr.delete=Lr.remove,Lr.setIn=br.setIn,Lr.deleteIn=Lr.removeIn=br.removeIn,Lr.update=br.update,Lr.updateIn=br.updateIn,Lr.mergeIn=br.mergeIn,Lr.mergeDeepIn=br.mergeDeepIn, +Lr.withMutations=br.withMutations,Lr.asMutable=br.asMutable,Lr.asImmutable=br.asImmutable,Lr.wasAltered=br.wasAltered,Lr["@@transducer/init"]=Lr.asMutable,Lr["@@transducer/step"]=function(t,e){return t.push(e)},Lr["@@transducer/result"]=br["@@transducer/result"];var Tr=function(t,e){this.array=t,this.ownerID=e};Tr.prototype.removeBefore=function(t,e,r){if(r===e?1<>>e&je;if(n>=this.array.length)return new Tr([],t);var i,o=0===n;if(e>0){var u=this.array[n];if((i=u&&u.removeBefore(t,e-Ee,r))===u&&o)return this}if(o&&!i)return this;var s=Vt(this,t);if(!o)for(var a=0;a>>e&je;if(n>=this.array.length)return this;var i;if(e>0){var o=this.array[n];if((i=o&&o.removeAfter(t,e-Ee,r))===o&&n===this.array.length-1)return this}var u=Vt(this,t);return u.array.splice(n+1),i&&(u.array[n]=i),u};var Cr,Wr={},Br=function(t){function e(t){return null===t||void 0===t?Zt():Ft(t)?t:Zt().withMutations(function(e){var r=Be(t);yt(r.size),r.forEach(function(t,r){return e.set(r,t)})})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("OrderedMap {","}")},e.prototype.get=function(t,e){var r=this._map.get(t);return void 0!==r?this._list.get(r)[1]:e},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._map.clear(),this._list.clear(),this):Zt()},e.prototype.set=function(t,e){return $t(this,t,e)},e.prototype.remove=function(t){return $t(this,t,ke)},e.prototype.wasAltered=function(){return this._map.wasAltered()||this._list.wasAltered()},e.prototype.__iterate=function(t,e){var r=this;return this._list.__iterate(function(e){return e&&t(e[1],e[0],r)},e)},e.prototype.__iterator=function(t,e){return this._list.fromEntrySeq().__iterator(t,e)},e.prototype.__ensureOwner=function(t){ +if(t===this.__ownerID)return this;var e=this._map.__ensureOwner(t),r=this._list.__ensureOwner(t);return t?Gt(e,r,t,this.__hash):0===this.size?Zt():(this.__ownerID=t,this._map=e,this._list=r,this)},e}(Sr);Br.isOrderedMap=Ft,Br.prototype[Te]=!0,Br.prototype.delete=Br.prototype.remove;var Jr,Pr=function(t){function e(t){return null===t||void 0===t?re():te(t)?t:re().pushAll(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("Stack [","]")},e.prototype.get=function(t,e){var r=this._head;for(t=u(this,t);r&&t--;)r=r.next;return r?r.value:e},e.prototype.peek=function(){return this._head&&this._head.value},e.prototype.push=function(){var t=arguments;if(0===arguments.length)return this;for(var e=this.size+arguments.length,r=this._head,n=arguments.length-1;n>=0;n--)r={value:t[n],next:r};return this.__ownerID?(this.size=e,this._head=r,this.__hash=void 0,this.__altered=!0,this):ee(e,r)},e.prototype.pushAll=function(e){if(e=t(e),0===e.size)return this;if(0===this.size&&te(e))return e;yt(e.size);var r=this.size,n=this._head;return e.__iterate(function(t){r++,n={value:t,next:n}},!0),this.__ownerID?(this.size=r,this._head=n,this.__hash=void 0,this.__altered=!0,this):ee(r,n)},e.prototype.pop=function(){return this.slice(1)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):re()},e.prototype.slice=function(e,r){if(a(e,r,this.size))return this;var n=c(e,this.size);if(h(r,this.size)!==this.size)return t.prototype.slice.call(this,e,r);for(var i=this.size-n,o=this._head;n--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):ee(i,o)},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?ee(this.size,this._head,t,this.__hash):0===this.size?re():(this.__ownerID=t,this.__altered=!1,this)},e.prototype.__iterate=function(t,e){var r=this +;if(e)return new rr(this.toArray()).__iterate(function(e,n){return t(e,n,r)},e);for(var n=0,i=this._head;i&&t(i.value,n++,r)!==!1;)i=i.next;return n},e.prototype.__iterator=function(t,e){if(e)return new rr(this.toArray()).__iterator(t,e);var r=0,n=this._head;return new Fe(function(){if(n){var e=n.value;return n=n.next,z(t,r++,e)}return S()})},e}(Je);Pr.isStack=te;var Nr="@@__IMMUTABLE_STACK__@@",Vr=Pr.prototype;Vr[Nr]=!0,Vr.withMutations=br.withMutations,Vr.asMutable=br.asMutable,Vr.asImmutable=br.asImmutable,Vr.wasAltered=br.wasAltered,Vr.shift=Vr.pop,Vr.unshift=Vr.push,Vr.unshiftAll=Vr.pushAll,Vr["@@transducer/init"]=Vr.asMutable,Vr["@@transducer/step"]=function(t,e){return t.unshift(e)},Vr["@@transducer/result"]=br["@@transducer/result"];var Hr,Yr=function(t){function e(e){return null===e||void 0===e?ae():oe(e)&&!g(e)?e:ae().withMutations(function(r){var n=t(e);yt(n.size),n.forEach(function(t){return r.add(t)})})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(Be(t).keySeq())},e.intersect=function(t){return t=We(t).toArray(),t.length?Xr.intersect.apply(e(t.pop()),t):ae()},e.union=function(t){return t=We(t).toArray(),t.length?Xr.union.apply(e(t.pop()),t):ae()},e.prototype.toString=function(){return this.__toString("Set {","}")},e.prototype.has=function(t){return this._map.has(t)},e.prototype.add=function(t){return ue(this,this._map.set(t,!0))},e.prototype.remove=function(t){return ue(this,this._map.remove(t))},e.prototype.clear=function(){return ue(this,this._map.clear())},e.prototype.union=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return e=e.filter(function(t){return 0!==t.size}),0===e.length?this:0!==this.size||this.__ownerID||1!==e.length?this.withMutations(function(r){for(var n=0;n0;)e[r]=arguments[r+1];return this.union.apply(this,e)},e.prototype.sort=function(t){return rn(it(this,t))},e.prototype.sortBy=function(t,e){return rn(it(this,e,t))},e.prototype.wasAltered=function(){return this._map.wasAltered()},e.prototype.__iterate=function(t,e){var r=this;return this._map.__iterate(function(e,n){return t(n,n,r)},e)},e.prototype.__iterator=function(t,e){return this._map.map(function(t,e){return e}).__iterator(t,e)},e.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var e=this._map.__ensureOwner(t);return t?this.__make(e,t):0===this.size?ae():(this.__ownerID=t,this._map=e,this)},e}(Pe);Yr.isSet=oe;var Qr="@@__IMMUTABLE_SET__@@",Xr=Yr.prototype;Xr[Qr]=!0,Xr.delete=Xr.remove,Xr.mergeDeep=Xr.merge,Xr.mergeDeepWith=Xr.mergeWith,Xr.withMutations=br.withMutations,Xr.asMutable=br.asMutable,Xr.asImmutable=br.asImmutable,Xr["@@transducer/init"]=Xr.asMutable,Xr["@@transducer/step"]=function(t,e){return t.add(e)},Xr["@@transducer/result"]=br["@@transducer/result"],Xr.__empty=ae,Xr.__make=se;var Fr,Gr,Zr=function(t){function e(t,r,n){if(!(this instanceof e))return new e(t,r,n);if(vt(0!==n,"Cannot step a Range by 0"),t=t||0,void 0===r&&(r=1/0),n=void 0===n?1:Math.abs(n),r=0&&e=0&&rthis.size?e:this.find(function(e,r){return r===t},void 0,e)},has:function(t){return(t=u(this,t))>=0&&(void 0!==this.size?this.size===1/0||t Date: Wed, 4 Oct 2017 02:52:58 +0000 Subject: [PATCH 023/242] Deploy master to NPM branch --- dist/immutable-nonambient.d.ts | 28 ++++++++++++++++++++++++++++ dist/immutable.d.ts | 28 ++++++++++++++++++++++++++++ dist/immutable.es.js | 1 + dist/immutable.js | 1 + dist/immutable.js.flow | 6 ++++++ dist/immutable.min.js | 16 ++++++++-------- 6 files changed, 72 insertions(+), 8 deletions(-) diff --git a/dist/immutable-nonambient.d.ts b/dist/immutable-nonambient.d.ts index 9f20a49480..35d110eb8c 100644 --- a/dist/immutable-nonambient.d.ts +++ b/dist/immutable-nonambient.d.ts @@ -802,6 +802,11 @@ */ asMutable(): this; + /** + * @see `Map#wasAltered` + */ + wasAltered(): boolean; + /** * @see `Map#asImmutable` */ @@ -1527,6 +1532,14 @@ */ asMutable(): this; + /** + * Returns true if this is a mutable copy (see `asMutable()`) and mutative + * alterations have been applied. + * + * @see `Map#asMutable` + */ + wasAltered(): boolean; + /** * The yin to `asMutable`'s yang. Because it applies to mutable collections, * this operation is *mutable* and returns itself. Once performed, the mutable @@ -1865,6 +1878,11 @@ */ asMutable(): this; + /** + * @see `Map#wasAltered` + */ + wasAltered(): boolean; + /** * @see `Map#asImmutable` */ @@ -2230,6 +2248,11 @@ */ asMutable(): this; + /** + * @see `Map#wasAltered` + */ + wasAltered(): boolean; + /** * @see `Map#asImmutable` */ @@ -2577,6 +2600,11 @@ */ asMutable(): this; + /** + * @see `Map#wasAltered` + */ + wasAltered(): boolean; + /** * @see `Map#asImmutable` */ diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index 27b8a59a73..c6db30ebdc 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -802,6 +802,11 @@ declare module Immutable { */ asMutable(): this; + /** + * @see `Map#wasAltered` + */ + wasAltered(): boolean; + /** * @see `Map#asImmutable` */ @@ -1527,6 +1532,14 @@ declare module Immutable { */ asMutable(): this; + /** + * Returns true if this is a mutable copy (see `asMutable()`) and mutative + * alterations have been applied. + * + * @see `Map#asMutable` + */ + wasAltered(): boolean; + /** * The yin to `asMutable`'s yang. Because it applies to mutable collections, * this operation is *mutable* and returns itself. Once performed, the mutable @@ -1865,6 +1878,11 @@ declare module Immutable { */ asMutable(): this; + /** + * @see `Map#wasAltered` + */ + wasAltered(): boolean; + /** * @see `Map#asImmutable` */ @@ -2230,6 +2248,11 @@ declare module Immutable { */ asMutable(): this; + /** + * @see `Map#wasAltered` + */ + wasAltered(): boolean; + /** * @see `Map#asImmutable` */ @@ -2577,6 +2600,11 @@ declare module Immutable { */ asMutable(): this; + /** + * @see `Map#wasAltered` + */ + wasAltered(): boolean; + /** * @see `Map#asImmutable` */ diff --git a/dist/immutable.es.js b/dist/immutable.es.js index 6ad87621b5..24901107ef 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -3091,6 +3091,7 @@ var List = (function (IndexedCollection$$1) { return emptyList(); } this.__ownerID = ownerID; + this.__altered = false; return this; } return makeList( diff --git a/dist/immutable.js b/dist/immutable.js index 9647b37dce..820bb79f0a 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -3097,6 +3097,7 @@ var List = (function (IndexedCollection$$1) { return emptyList(); } this.__ownerID = ownerID; + this.__altered = false; return this; } return makeList( diff --git a/dist/immutable.js.flow b/dist/immutable.js.flow index 95a532abb3..f306d3be41 100644 --- a/dist/immutable.js.flow +++ b/dist/immutable.js.flow @@ -665,6 +665,7 @@ declare class List<+T> extends IndexedCollection { withMutations(mutator: (mutable: this) => mixed): this; asMutable(): this; + wasAltered(): boolean; asImmutable(): this; // Override specialized return types @@ -847,6 +848,7 @@ declare class Map extends KeyedCollection { withMutations(mutator: (mutable: this) => mixed): this; asMutable(): this; + wasAltered(): boolean; asImmutable(): this; // Override specialized return types @@ -941,6 +943,7 @@ declare class OrderedMap extends Map { withMutations(mutator: (mutable: this) => mixed): this; asMutable(): this; + wasAltered(): boolean; asImmutable(): this; // Override specialized return types @@ -1000,6 +1003,7 @@ declare class Set<+T> extends SetCollection { withMutations(mutator: (mutable: this) => mixed): this; asMutable(): this; + wasAltered(): boolean; asImmutable(): this; // Override specialized return types @@ -1175,6 +1179,7 @@ declare class Stack<+T> extends IndexedCollection { withMutations(mutator: (mutable: this) => mixed): this; asMutable(): this; + wasAltered(): boolean; asImmutable(): this; // Override specialized return types @@ -1359,6 +1364,7 @@ declare class RecordInstance { withMutations(mutator: (mutable: this) => mixed): this & T; asMutable(): this & T; + wasAltered(): boolean; asImmutable(): this & T; @@iterator(): Iterator<[$Keys, any]>; diff --git a/dist/immutable.min.js b/dist/immutable.min.js index e7319e908c..65cc03ba68 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -23,14 +23,14 @@ var r=this._iter.__iterator(Ve,e);return new Fe(function(){for(;;){var e=r.next( ;return this.updateIn(t,St(),function(t){return"function"==typeof t.merge?t.merge.apply(t,e):e[e.length-1]})},e.prototype.mergeDeep=function(){return xt(this,jt,arguments)},e.prototype.mergeDeepWith=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return xt(this,kt(t),e)},e.prototype.mergeDeepIn=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return this.updateIn(t,St(),function(t){return"function"==typeof t.mergeDeep?t.mergeDeep.apply(t,e):e[e.length-1]})},e.prototype.sort=function(t){return Br(it(this,t))},e.prototype.sortBy=function(t,e){return Br(it(this,e,t))},e.prototype.withMutations=function(t){var e=this.asMutable();return t(e),e.wasAltered()?e.__ensureOwner(this.__ownerID):this},e.prototype.asMutable=function(){return this.__ownerID?this:this.__ensureOwner(new n)},e.prototype.asImmutable=function(){return this.__ensureOwner()},e.prototype.wasAltered=function(){return this.__altered},e.prototype.__iterator=function(t,e){return new jr(this,t,e)},e.prototype.__iterate=function(t,e){var r=this,n=0;return this._root&&this._root.iterate(function(e){return n++,t(e[1],e[0],r)},e),n},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?zt(this.size,this._root,t,this.__hash):0===this.size?St():(this.__ownerID=t,this.__altered=!1,this)},e}(Be);Sr.isMap=gt;var Ir="@@__IMMUTABLE_MAP__@@",br=Sr.prototype;br[Ir]=!0,br.delete=br.remove,br.removeIn=br.deleteIn,br.removeAll=br.deleteAll,br["@@transducer/init"]=br.asMutable,br["@@transducer/step"]=function(t,e){return t.set(e[0],e[1])},br["@@transducer/result"]=function(t){return t.asImmutable()};var Or=function(t,e){this.ownerID=t,this.entries=e};Or.prototype.get=function(t,e,r,n){for(var i=this.entries,o=0,u=i.length;o=kr)return Dt(t,h,o,u) ;var l=t&&t===this.ownerID,v=l?h:i(h);return _?c?f===p-1?v.pop():v[f]=v.pop():v[f]=[o,u]:v.push([o,u]),l?(this.entries=v,this):new Or(t,v)}};var Mr=function(t,e,r){this.ownerID=t,this.bitmap=e,this.nodes=r};Mr.prototype.get=function(t,e,r,n){void 0===e&&(e=W(r));var i=1<<((0===t?e:e>>>t)&je),o=this.bitmap;return 0==(o&i)?n:this.nodes[Ut(o&i-1)].get(t+Ee,e,r,n)},Mr.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=W(n));var s=(0===e?r:r>>>e)&je,a=1<=Ar)return Et(t,p,c,s,l);if(h&&!l&&2===p.length&&Ot(p[1^f]))return p[1^f];if(h&&l&&1===p.length&&Ot(l))return l;var v=t&&t===this.ownerID,y=h?l?c:c^a:c|a,d=h?l?Kt(p,f,l,v):Tt(p,f,v):Lt(p,f,l,v);return v?(this.bitmap=y,this.nodes=d,this):new Mr(t,y,d)};var Dr=function(t,e,r){this.ownerID=t,this.count=e,this.nodes=r};Dr.prototype.get=function(t,e,r,n){void 0===e&&(e=W(r));var i=(0===t?e:e>>>t)&je,o=this.nodes[i];return o?o.get(t+Ee,e,r,n):n},Dr.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=W(n));var s=(0===e?r:r>>>e)&je,a=i===ke,c=this.nodes,h=c[s];if(a&&!h)return this;var f=bt(h,t,e+Ee,r,n,i,o,u);if(f===h)return this;var p=this.count;if(h){if(!f&&--p0&&i=0&&t0;)e[r]=arguments[r+1];return Qt(this,t,e)},e.prototype.mergeDeep=function(){return Qt(this,jt,arguments)},e.prototype.mergeDeepWith=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Qt(this,kt(t),e)},e.prototype.setSize=function(t){return Yt(this,0,t)},e.prototype.slice=function(t,e){var r=this.size;return a(t,e,r)?this:Yt(this,c(t,r),h(e,r))},e.prototype.__iterator=function(t,e){var r=e?this.size:0,n=Wt(this,e);return new Fe(function(){var i=n();return i===Wr?S():z(t,e?--r:r++,i)})},e.prototype.__iterate=function(t,e){for(var r,n=this,i=e?this.size:0,o=Wt(this,e);(r=o())!==Wr&&t(r,e?--i:i++,n)!==!1;);return i},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Bt(this._origin,this._capacity,this._level,this._root,this._tail,t,this.__hash):0===this.size?Jt():(this.__ownerID=t,this)},e}(Je);Ur.isList=Ct;var Kr="@@__IMMUTABLE_LIST__@@",Lr=Ur.prototype;Lr[Kr]=!0,Lr.delete=Lr.remove,Lr.setIn=br.setIn,Lr.deleteIn=Lr.removeIn=br.removeIn,Lr.update=br.update,Lr.updateIn=br.updateIn,Lr.mergeIn=br.mergeIn,Lr.mergeDeepIn=br.mergeDeepIn, -Lr.withMutations=br.withMutations,Lr.asMutable=br.asMutable,Lr.asImmutable=br.asImmutable,Lr.wasAltered=br.wasAltered,Lr["@@transducer/init"]=Lr.asMutable,Lr["@@transducer/step"]=function(t,e){return t.push(e)},Lr["@@transducer/result"]=br["@@transducer/result"];var Tr=function(t,e){this.array=t,this.ownerID=e};Tr.prototype.removeBefore=function(t,e,r){if(r===e?1<>>e&je;if(n>=this.array.length)return new Tr([],t);var i,o=0===n;if(e>0){var u=this.array[n];if((i=u&&u.removeBefore(t,e-Ee,r))===u&&o)return this}if(o&&!i)return this;var s=Vt(this,t);if(!o)for(var a=0;a>>e&je;if(n>=this.array.length)return this;var i;if(e>0){var o=this.array[n];if((i=o&&o.removeAfter(t,e-Ee,r))===o&&n===this.array.length-1)return this}var u=Vt(this,t);return u.array.splice(n+1),i&&(u.array[n]=i),u};var Cr,Wr={},Br=function(t){function e(t){return null===t||void 0===t?Zt():Ft(t)?t:Zt().withMutations(function(e){var r=Be(t);yt(r.size),r.forEach(function(t,r){return e.set(r,t)})})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("OrderedMap {","}")},e.prototype.get=function(t,e){var r=this._map.get(t);return void 0!==r?this._list.get(r)[1]:e},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._map.clear(),this._list.clear(),this):Zt()},e.prototype.set=function(t,e){return $t(this,t,e)},e.prototype.remove=function(t){return $t(this,t,ke)},e.prototype.wasAltered=function(){return this._map.wasAltered()||this._list.wasAltered()},e.prototype.__iterate=function(t,e){var r=this;return this._list.__iterate(function(e){return e&&t(e[1],e[0],r)},e)},e.prototype.__iterator=function(t,e){return this._list.fromEntrySeq().__iterator(t,e)},e.prototype.__ensureOwner=function(t){ -if(t===this.__ownerID)return this;var e=this._map.__ensureOwner(t),r=this._list.__ensureOwner(t);return t?Gt(e,r,t,this.__hash):0===this.size?Zt():(this.__ownerID=t,this._map=e,this._list=r,this)},e}(Sr);Br.isOrderedMap=Ft,Br.prototype[Te]=!0,Br.prototype.delete=Br.prototype.remove;var Jr,Pr=function(t){function e(t){return null===t||void 0===t?re():te(t)?t:re().pushAll(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("Stack [","]")},e.prototype.get=function(t,e){var r=this._head;for(t=u(this,t);r&&t--;)r=r.next;return r?r.value:e},e.prototype.peek=function(){return this._head&&this._head.value},e.prototype.push=function(){var t=arguments;if(0===arguments.length)return this;for(var e=this.size+arguments.length,r=this._head,n=arguments.length-1;n>=0;n--)r={value:t[n],next:r};return this.__ownerID?(this.size=e,this._head=r,this.__hash=void 0,this.__altered=!0,this):ee(e,r)},e.prototype.pushAll=function(e){if(e=t(e),0===e.size)return this;if(0===this.size&&te(e))return e;yt(e.size);var r=this.size,n=this._head;return e.__iterate(function(t){r++,n={value:t,next:n}},!0),this.__ownerID?(this.size=r,this._head=n,this.__hash=void 0,this.__altered=!0,this):ee(r,n)},e.prototype.pop=function(){return this.slice(1)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):re()},e.prototype.slice=function(e,r){if(a(e,r,this.size))return this;var n=c(e,this.size);if(h(r,this.size)!==this.size)return t.prototype.slice.call(this,e,r);for(var i=this.size-n,o=this._head;n--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):ee(i,o)},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?ee(this.size,this._head,t,this.__hash):0===this.size?re():(this.__ownerID=t,this.__altered=!1,this)},e.prototype.__iterate=function(t,e){var r=this -;if(e)return new rr(this.toArray()).__iterate(function(e,n){return t(e,n,r)},e);for(var n=0,i=this._head;i&&t(i.value,n++,r)!==!1;)i=i.next;return n},e.prototype.__iterator=function(t,e){if(e)return new rr(this.toArray()).__iterator(t,e);var r=0,n=this._head;return new Fe(function(){if(n){var e=n.value;return n=n.next,z(t,r++,e)}return S()})},e}(Je);Pr.isStack=te;var Nr="@@__IMMUTABLE_STACK__@@",Vr=Pr.prototype;Vr[Nr]=!0,Vr.withMutations=br.withMutations,Vr.asMutable=br.asMutable,Vr.asImmutable=br.asImmutable,Vr.wasAltered=br.wasAltered,Vr.shift=Vr.pop,Vr.unshift=Vr.push,Vr.unshiftAll=Vr.pushAll,Vr["@@transducer/init"]=Vr.asMutable,Vr["@@transducer/step"]=function(t,e){return t.unshift(e)},Vr["@@transducer/result"]=br["@@transducer/result"];var Hr,Yr=function(t){function e(e){return null===e||void 0===e?ae():oe(e)&&!g(e)?e:ae().withMutations(function(r){var n=t(e);yt(n.size),n.forEach(function(t){return r.add(t)})})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(Be(t).keySeq())},e.intersect=function(t){return t=We(t).toArray(),t.length?Xr.intersect.apply(e(t.pop()),t):ae()},e.union=function(t){return t=We(t).toArray(),t.length?Xr.union.apply(e(t.pop()),t):ae()},e.prototype.toString=function(){return this.__toString("Set {","}")},e.prototype.has=function(t){return this._map.has(t)},e.prototype.add=function(t){return ue(this,this._map.set(t,!0))},e.prototype.remove=function(t){return ue(this,this._map.remove(t))},e.prototype.clear=function(){return ue(this,this._map.clear())},e.prototype.union=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return e=e.filter(function(t){return 0!==t.size}),0===e.length?this:0!==this.size||this.__ownerID||1!==e.length?this.withMutations(function(r){for(var n=0;n0;)e[r]=arguments[r+1];return this.union.apply(this,e)},e.prototype.sort=function(t){return rn(it(this,t))},e.prototype.sortBy=function(t,e){return rn(it(this,e,t))},e.prototype.wasAltered=function(){return this._map.wasAltered()},e.prototype.__iterate=function(t,e){var r=this;return this._map.__iterate(function(e,n){return t(n,n,r)},e)},e.prototype.__iterator=function(t,e){return this._map.map(function(t,e){return e}).__iterator(t,e)},e.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var e=this._map.__ensureOwner(t);return t?this.__make(e,t):0===this.size?ae():(this.__ownerID=t,this._map=e,this)},e}(Pe);Yr.isSet=oe;var Qr="@@__IMMUTABLE_SET__@@",Xr=Yr.prototype;Xr[Qr]=!0,Xr.delete=Xr.remove,Xr.mergeDeep=Xr.merge,Xr.mergeDeepWith=Xr.mergeWith,Xr.withMutations=br.withMutations,Xr.asMutable=br.asMutable,Xr.asImmutable=br.asImmutable,Xr["@@transducer/init"]=Xr.asMutable,Xr["@@transducer/step"]=function(t,e){return t.add(e)},Xr["@@transducer/result"]=br["@@transducer/result"],Xr.__empty=ae,Xr.__make=se;var Fr,Gr,Zr=function(t){function e(t,r,n){if(!(this instanceof e))return new e(t,r,n);if(vt(0!==n,"Cannot step a Range by 0"),t=t||0,void 0===r&&(r=1/0),n=void 0===n?1:Math.abs(n),r=0&&e=0&&r0;)e[r]=arguments[r+1];return Qt(this,t,e)},e.prototype.mergeDeep=function(){return Qt(this,jt,arguments)},e.prototype.mergeDeepWith=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Qt(this,kt(t),e)},e.prototype.setSize=function(t){return Yt(this,0,t)},e.prototype.slice=function(t,e){var r=this.size;return a(t,e,r)?this:Yt(this,c(t,r),h(e,r))},e.prototype.__iterator=function(t,e){var r=e?this.size:0,n=Wt(this,e);return new Fe(function(){var i=n();return i===Wr?S():z(t,e?--r:r++,i)})},e.prototype.__iterate=function(t,e){for(var r,n=this,i=e?this.size:0,o=Wt(this,e);(r=o())!==Wr&&t(r,e?--i:i++,n)!==!1;);return i},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Bt(this._origin,this._capacity,this._level,this._root,this._tail,t,this.__hash):0===this.size?Jt():(this.__ownerID=t,this.__altered=!1,this)},e}(Je);Ur.isList=Ct;var Kr="@@__IMMUTABLE_LIST__@@",Lr=Ur.prototype;Lr[Kr]=!0,Lr.delete=Lr.remove,Lr.setIn=br.setIn,Lr.deleteIn=Lr.removeIn=br.removeIn,Lr.update=br.update,Lr.updateIn=br.updateIn,Lr.mergeIn=br.mergeIn, +Lr.mergeDeepIn=br.mergeDeepIn,Lr.withMutations=br.withMutations,Lr.asMutable=br.asMutable,Lr.asImmutable=br.asImmutable,Lr.wasAltered=br.wasAltered,Lr["@@transducer/init"]=Lr.asMutable,Lr["@@transducer/step"]=function(t,e){return t.push(e)},Lr["@@transducer/result"]=br["@@transducer/result"];var Tr=function(t,e){this.array=t,this.ownerID=e};Tr.prototype.removeBefore=function(t,e,r){if(r===e?1<>>e&je;if(n>=this.array.length)return new Tr([],t);var i,o=0===n;if(e>0){var u=this.array[n];if((i=u&&u.removeBefore(t,e-Ee,r))===u&&o)return this}if(o&&!i)return this;var s=Vt(this,t);if(!o)for(var a=0;a>>e&je;if(n>=this.array.length)return this;var i;if(e>0){var o=this.array[n];if((i=o&&o.removeAfter(t,e-Ee,r))===o&&n===this.array.length-1)return this}var u=Vt(this,t);return u.array.splice(n+1),i&&(u.array[n]=i),u};var Cr,Wr={},Br=function(t){function e(t){return null===t||void 0===t?Zt():Ft(t)?t:Zt().withMutations(function(e){var r=Be(t);yt(r.size),r.forEach(function(t,r){return e.set(r,t)})})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("OrderedMap {","}")},e.prototype.get=function(t,e){var r=this._map.get(t);return void 0!==r?this._list.get(r)[1]:e},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._map.clear(),this._list.clear(),this):Zt()},e.prototype.set=function(t,e){return $t(this,t,e)},e.prototype.remove=function(t){return $t(this,t,ke)},e.prototype.wasAltered=function(){return this._map.wasAltered()||this._list.wasAltered()},e.prototype.__iterate=function(t,e){var r=this;return this._list.__iterate(function(e){return e&&t(e[1],e[0],r)},e)},e.prototype.__iterator=function(t,e){return this._list.fromEntrySeq().__iterator(t,e)}, +e.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var e=this._map.__ensureOwner(t),r=this._list.__ensureOwner(t);return t?Gt(e,r,t,this.__hash):0===this.size?Zt():(this.__ownerID=t,this._map=e,this._list=r,this)},e}(Sr);Br.isOrderedMap=Ft,Br.prototype[Te]=!0,Br.prototype.delete=Br.prototype.remove;var Jr,Pr=function(t){function e(t){return null===t||void 0===t?re():te(t)?t:re().pushAll(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("Stack [","]")},e.prototype.get=function(t,e){var r=this._head;for(t=u(this,t);r&&t--;)r=r.next;return r?r.value:e},e.prototype.peek=function(){return this._head&&this._head.value},e.prototype.push=function(){var t=arguments;if(0===arguments.length)return this;for(var e=this.size+arguments.length,r=this._head,n=arguments.length-1;n>=0;n--)r={value:t[n],next:r};return this.__ownerID?(this.size=e,this._head=r,this.__hash=void 0,this.__altered=!0,this):ee(e,r)},e.prototype.pushAll=function(e){if(e=t(e),0===e.size)return this;if(0===this.size&&te(e))return e;yt(e.size);var r=this.size,n=this._head;return e.__iterate(function(t){r++,n={value:t,next:n}},!0),this.__ownerID?(this.size=r,this._head=n,this.__hash=void 0,this.__altered=!0,this):ee(r,n)},e.prototype.pop=function(){return this.slice(1)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):re()},e.prototype.slice=function(e,r){if(a(e,r,this.size))return this;var n=c(e,this.size);if(h(r,this.size)!==this.size)return t.prototype.slice.call(this,e,r);for(var i=this.size-n,o=this._head;n--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):ee(i,o)},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?ee(this.size,this._head,t,this.__hash):0===this.size?re():(this.__ownerID=t,this.__altered=!1,this)}, +e.prototype.__iterate=function(t,e){var r=this;if(e)return new rr(this.toArray()).__iterate(function(e,n){return t(e,n,r)},e);for(var n=0,i=this._head;i&&t(i.value,n++,r)!==!1;)i=i.next;return n},e.prototype.__iterator=function(t,e){if(e)return new rr(this.toArray()).__iterator(t,e);var r=0,n=this._head;return new Fe(function(){if(n){var e=n.value;return n=n.next,z(t,r++,e)}return S()})},e}(Je);Pr.isStack=te;var Nr="@@__IMMUTABLE_STACK__@@",Vr=Pr.prototype;Vr[Nr]=!0,Vr.withMutations=br.withMutations,Vr.asMutable=br.asMutable,Vr.asImmutable=br.asImmutable,Vr.wasAltered=br.wasAltered,Vr.shift=Vr.pop,Vr.unshift=Vr.push,Vr.unshiftAll=Vr.pushAll,Vr["@@transducer/init"]=Vr.asMutable,Vr["@@transducer/step"]=function(t,e){return t.unshift(e)},Vr["@@transducer/result"]=br["@@transducer/result"];var Hr,Yr=function(t){function e(e){return null===e||void 0===e?ae():oe(e)&&!g(e)?e:ae().withMutations(function(r){var n=t(e);yt(n.size),n.forEach(function(t){return r.add(t)})})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(Be(t).keySeq())},e.intersect=function(t){return t=We(t).toArray(),t.length?Xr.intersect.apply(e(t.pop()),t):ae()},e.union=function(t){return t=We(t).toArray(),t.length?Xr.union.apply(e(t.pop()),t):ae()},e.prototype.toString=function(){return this.__toString("Set {","}")},e.prototype.has=function(t){return this._map.has(t)},e.prototype.add=function(t){return ue(this,this._map.set(t,!0))},e.prototype.remove=function(t){return ue(this,this._map.remove(t))},e.prototype.clear=function(){return ue(this,this._map.clear())},e.prototype.union=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return e=e.filter(function(t){return 0!==t.size}),0===e.length?this:0!==this.size||this.__ownerID||1!==e.length?this.withMutations(function(r){for(var n=0;n0;)e[r]=arguments[r+1];return this.union.apply(this,e)},e.prototype.sort=function(t){return rn(it(this,t))},e.prototype.sortBy=function(t,e){return rn(it(this,e,t))},e.prototype.wasAltered=function(){return this._map.wasAltered()},e.prototype.__iterate=function(t,e){var r=this;return this._map.__iterate(function(e,n){return t(n,n,r)},e)},e.prototype.__iterator=function(t,e){return this._map.map(function(t,e){return e}).__iterator(t,e)},e.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var e=this._map.__ensureOwner(t);return t?this.__make(e,t):0===this.size?ae():(this.__ownerID=t,this._map=e,this)},e}(Pe);Yr.isSet=oe;var Qr="@@__IMMUTABLE_SET__@@",Xr=Yr.prototype;Xr[Qr]=!0,Xr.delete=Xr.remove,Xr.mergeDeep=Xr.merge,Xr.mergeDeepWith=Xr.mergeWith,Xr.withMutations=br.withMutations,Xr.asMutable=br.asMutable,Xr.asImmutable=br.asImmutable,Xr["@@transducer/init"]=Xr.asMutable,Xr["@@transducer/step"]=function(t,e){return t.add(e)},Xr["@@transducer/result"]=br["@@transducer/result"],Xr.__empty=ae,Xr.__make=se;var Fr,Gr,Zr=function(t){function e(t,r,n){if(!(this instanceof e))return new e(t,r,n);if(vt(0!==n,"Cannot step a Range by 0"),t=t||0,void 0===r&&(r=1/0),n=void 0===n?1:Math.abs(n),r=0&&e=0&&rthis.size?e:this.find(function(e,r){return r===t},void 0,e)},has:function(t){return(t=u(this,t))>=0&&(void 0!==this.size?this.size===1/0||t Date: Wed, 4 Oct 2017 02:56:35 +0000 Subject: [PATCH 024/242] Deploy master to NPM branch --- dist/immutable-nonambient.d.ts | 4 ++++ dist/immutable.d.ts | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/dist/immutable-nonambient.d.ts b/dist/immutable-nonambient.d.ts index 35d110eb8c..7783137ffb 100644 --- a/dist/immutable-nonambient.d.ts +++ b/dist/immutable-nonambient.d.ts @@ -4200,6 +4200,8 @@ * * Note: `sort()` Always returns a new instance, even if the original was * already sorted. + * + * Note: This is always an eager operation. */ sort(comparator?: (valueA: V, valueB: V) => number): this; @@ -4211,6 +4213,8 @@ * * Note: `sortBy()` Always returns a new instance, even if the original was * already sorted. + * + * Note: This is always an eager operation. */ sortBy( comparatorValueMapper: (value: V, key: K, iter: this) => C, diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index c6db30ebdc..ca053e007e 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -4200,6 +4200,8 @@ declare module Immutable { * * Note: `sort()` Always returns a new instance, even if the original was * already sorted. + * + * Note: This is always an eager operation. */ sort(comparator?: (valueA: V, valueB: V) => number): this; @@ -4211,6 +4213,8 @@ declare module Immutable { * * Note: `sortBy()` Always returns a new instance, even if the original was * already sorted. + * + * Note: This is always an eager operation. */ sortBy( comparatorValueMapper: (value: V, key: K, iter: this) => C, From 7d581689494190d3c9c43616177bf218b5d8538a Mon Sep 17 00:00:00 2001 From: Travis CI Date: Wed, 4 Oct 2017 18:44:39 +0000 Subject: [PATCH 025/242] Deploy master to NPM branch --- dist/immutable-nonambient.d.ts | 2 +- dist/immutable.d.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/immutable-nonambient.d.ts b/dist/immutable-nonambient.d.ts index 7783137ffb..1beb06c159 100644 --- a/dist/immutable-nonambient.d.ts +++ b/dist/immutable-nonambient.d.ts @@ -1368,7 +1368,7 @@ * ) * // Map { * // "subObject": Map { - * // "subKey": "ha ha!", + * // "subKey": "subvalue", * // "subSubObject": Map { "subSubKey": "ha ha ha!" } * // } * // } diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index ca053e007e..9f856f9ec4 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -1368,7 +1368,7 @@ declare module Immutable { * ) * // Map { * // "subObject": Map { - * // "subKey": "ha ha!", + * // "subKey": "subvalue", * // "subSubObject": Map { "subSubKey": "ha ha ha!" } * // } * // } From 1561d0cf903ad2458496cc5c91458f9d8c989362 Mon Sep 17 00:00:00 2001 From: Travis CI Date: Wed, 4 Oct 2017 19:09:10 +0000 Subject: [PATCH 026/242] Deploy master to NPM branch --- dist/immutable-nonambient.d.ts | 197 ++++++++++++++++++--------------- dist/immutable.d.ts | 197 ++++++++++++++++++--------------- 2 files changed, 218 insertions(+), 176 deletions(-) diff --git a/dist/immutable-nonambient.d.ts b/dist/immutable-nonambient.d.ts index 1beb06c159..2baa4a66b8 100644 --- a/dist/immutable-nonambient.d.ts +++ b/dist/immutable-nonambient.d.ts @@ -87,7 +87,7 @@ * ```js * // ES2015 * const mappedFoo = foo.map(x => x * x); - * // ES3 + * // ES5 * var mappedFoo = foo.map(function (x) { return x * x; }); * ``` * @@ -116,8 +116,9 @@ * If `reviver` is not provided, the default behavior will convert Objects * into Maps and Arrays into Lists like so: * + * * ```js - * const { fromJS, isKeyed } = require('immutable') + * const { fromJS, isKeyed } = require('immutable@4.0.0-rc.4') * function (key, value) { * return isKeyed(value) ? value.Map() : value.toList() * } @@ -129,8 +130,9 @@ * * Accordingly, this example converts native JS data to OrderedMap and List: * + * * ```js - * const { fromJS, isKeyed } = require('immutable') + * const { fromJS, isKeyed } = require('immutable@4.0.0-rc.4') * fromJS({ a: {b: [10, 20, 30]}, c: 40}, function (key, value, path) { * console.log(key, value, path) * return isKeyed(value) ? value.toOrderedMap() : value.toList() @@ -145,10 +147,9 @@ * JavaScript Object properties are always strings, even if written in a * quote-less shorthand, while Immutable Maps accept keys of any type. * - * + * * ```js + * const { Map } = require('immutable@4.0.0-rc.4') * let obj = { 1: "one" }; * Object.keys(obj); // [ "1" ] * assert.equal(obj["1"], obj[1]); // "one" === "one" @@ -184,7 +185,7 @@ * * * ```js - * const { Map, is } = require('immutable') + * const { Map, is } = require('immutable@4.0.0-rc.4') * const map1 = Map({ a: 1, b: 1, c: 1 }) * const map2 = Map({ a: 1, b: 1, c: 1 }) * assert.equal(map1 !== map2, true) @@ -229,8 +230,9 @@ /** * True if `maybeImmutable` is an Immutable Collection or Record. * + * * ```js - * const { isImmutable, Map, List, Stack } = require('immutable'); + * const { isImmutable, Map, List, Stack } = require('immutable@4.0.0-rc.4'); * isImmutable([]); // false * isImmutable({}); // false * isImmutable(Map()); // true @@ -244,8 +246,9 @@ /** * True if `maybeCollection` is a Collection, or any of its subclasses. * + * * ```js - * const { isCollection, Map, List, Stack } = require('immutable'); + * const { isCollection, Map, List, Stack } = require('immutable@4.0.0-rc.4'); * isCollection([]); // false * isCollection({}); // false * isCollection(Map()); // true @@ -258,8 +261,9 @@ /** * True if `maybeKeyed` is a Collection.Keyed, or any of its subclasses. * + * * ```js - * const { isKeyed, Map, List, Stack } = require('immutable'); + * const { isKeyed, Map, List, Stack } = require('immutable@4.0.0-rc.4'); * isKeyed([]); // false * isKeyed({}); // false * isKeyed(Map()); // true @@ -272,8 +276,9 @@ /** * True if `maybeIndexed` is a Collection.Indexed, or any of its subclasses. * + * * ```js - * const { isIndexed, Map, List, Stack, Set } = require('immutable'); + * const { isIndexed, Map, List, Stack, Set } = require('immutable@4.0.0-rc.4'); * isIndexed([]); // false * isIndexed({}); // false * isIndexed(Map()); // false @@ -287,8 +292,9 @@ /** * True if `maybeAssociative` is either a Keyed or Indexed Collection. * + * * ```js - * const { isAssociative, Map, List, Stack, Set } = require('immutable'); + * const { isAssociative, Map, List, Stack, Set } = require('immutable@4.0.0-rc.4'); * isAssociative([]); // false * isAssociative({}); // false * isAssociative(Map()); // true @@ -303,8 +309,9 @@ * True if `maybeOrdered` is a Collection where iteration order is well * defined. True for Collection.Indexed as well as OrderedMap and OrderedSet. * + * * ```js - * const { isOrdered, Map, OrderedMap, List, Set } = require('immutable'); + * const { isOrdered, Map, OrderedMap, List, Set } = require('immutable@4.0.0-rc.4'); * isOrdered([]); // false * isOrdered({}); // false * isOrdered(Map()); // false @@ -344,10 +351,9 @@ * and is used when adding this to a `Set` or as a key in a `Map`, enabling * lookup via a different instance. * - * + * * ```js + * const { List, Set } = require('immutable@4.0.0-rc.4'); * const a = List([ 1, 2, 3 ]); * const b = List([ 1, 2, 3 ]); * assert.notStrictEqual(a, b); // different instances @@ -391,10 +397,9 @@ /** * True if the provided value is a List * - * + * * ```js + * const { List } = require('immutable@4.0.0-rc.4'); * List.isList([]); // false * List.isList(List()); // true * ``` @@ -404,20 +409,18 @@ /** * Creates a new List containing `values`. * - * + * * ```js + * const { List } = require('immutable@4.0.0-rc.4'); * List.of(1, 2, 3, 4) * // List [ 1, 2, 3, 4 ] * ``` * * Note: Values are not altered or converted in any way. * - * + * * ```js + * const { List } = require('immutable@4.0.0-rc.4'); * List.of({x:1}, 2, [3], 4) * // List [ { x: 1 }, 2, [ 3 ], 4 ] * ``` @@ -431,7 +434,7 @@ * * * ```js - * const { List, Set } = require('immutable') + * const { List, Set } = require('immutable@4.0.0-rc.4') * * const emptyList = List() * // List [] @@ -870,6 +873,9 @@ * * Like `zipWith`, but using the default `zipper`: creating an `Array`. * + * * ```js * const a = List([ 1, 2, 3 ]); * const b = List([ 4, 5, 6 ]); @@ -882,7 +888,9 @@ * Returns a List "zipped" with the provided collection. * * Like `zipWith`, but using the default `zipper`: creating an `Array`. - * + * * ```js * const a = List([ 1, 2, 3 ]); * const b = List([ 4, 5, 6 ]); @@ -913,6 +921,9 @@ * Unlike `zip`, `zipAll` continues zipping until the longest collection is * exhausted. Missing values from shorter collections are filled with `undefined`. * + * * ```js * const a = List([ 1, 2 ]); * const b = List([ 3, 4, 5 ]); @@ -967,7 +978,7 @@ * * * ```js - * const { Map, List } = require('immutable'); + * const { Map, List } = require('immutable@4.0.0-rc.4'); * Map().set(List([ 1 ]), 'listofone').get(List([ 1 ])); * // 'listofone' * ``` @@ -983,8 +994,9 @@ /** * True if the provided value is a Map * + * * ```js - * const { Map } = require('immutable') + * const { Map } = require('immutable@4.0.0-rc.4') * Map.isMap({}) // false * Map.isMap(Map()) // true * ``` @@ -996,7 +1008,7 @@ * * * ```js - * const { Map } = require('immutable') + * const { Map } = require('immutable@4.0.0-rc.4') * Map.of( * 'key', 'value', * 'numerical value', 3, @@ -1018,7 +1030,7 @@ * * * ```js - * const { Map } = require('immutable') + * const { Map } = require('immutable@4.0.0-rc.4') * Map({ key: "value" }) * Map([ [ "key", "value" ] ]) * ``` @@ -1064,7 +1076,7 @@ * * * ```js - * const { Map } = require('immutable') + * const { Map } = require('immutable@4.0.0-rc.4') * const originalMap = Map() * const newerMap = originalMap.set('key', 'value') * const newestMap = newerMap.set('key', 'newer value') @@ -1089,7 +1101,7 @@ * * * ```js - * const { Map } = require('immutable') + * const { Map } = require('immutable@4.0.0-rc.4') * const originalMap = Map({ * key: 'value', * otherKey: 'other value' @@ -1109,8 +1121,9 @@ /** * Returns a new Map which excludes the provided `keys`. * + * * ```js - * const { Map } = require('immutable') + * const { Map } = require('immutable@4.0.0-rc.4') * const names = Map({ a: "Aaron", b: "Barry", c: "Connor" }) * names.deleteAll([ 'a', 'c' ]) * // Map { "b": "Barry" } @@ -1128,7 +1141,7 @@ * * * ```js - * const { Map } = require('immutable') + * const { Map } = require('immutable@4.0.0-rc.4') * Map({ key: 'value' }).clear() * // Map {} * ``` @@ -1145,7 +1158,7 @@ * * * ```js - * const { Map } = require('immutable') + * const { Map } = require('immutable@4.0.0-rc.4') * const aMap = Map({ key: 'value' }) * const newMap = aMap.update('key', value => value + value) * // Map { "key": "valuevalue" } @@ -1256,7 +1269,7 @@ * * * ```js - * const { Map } = require('immutable') + * const { Map } = require('immutable@4.0.0-rc.4') * const one = Map({ a: 10, b: 20, c: 30 }) * const two = Map({ b: 40, a: 50, d: 60 }) * one.merge(two) // Map { "a": 50, "b": 40, "c": 30, "d": 60 } @@ -1274,7 +1287,7 @@ * * * ```js - * const { Map } = require('immutable') + * const { Map } = require('immutable@4.0.0-rc.4') * const one = Map({ a: 10, b: 20, c: 30 }) * const two = Map({ b: 40, a: 50, d: 60 }) * one.mergeWith((oldVal, newVal) => oldVal / newVal, two) @@ -1296,7 +1309,7 @@ * * * ```js - * const { Map } = require('immutable') + * const { Map } = require('immutable@4.0.0-rc.4') * const one = Map({ a: Map({ x: 10, y: 10 }), b: Map({ x: 20, y: 50 }) }) * const two = Map({ a: Map({ x: 2 }), b: Map({ y: 5 }), c: Map({ z: 3 }) }) * one.mergeDeep(two) @@ -1317,7 +1330,7 @@ * * * ```js - * const { Map } = require('immutable') + * const { Map } = require('immutable@4.0.0-rc.4') * const one = Map({ a: Map({ x: 10, y: 10 }), b: Map({ x: 20, y: 50 }) }) * const two = Map({ a: Map({ x: 2 }), b: Map({ y: 5 }), c: Map({ z: 3 }) }) * one.mergeDeepWith((oldVal, newVal) => oldVal / newVal, two) @@ -1344,7 +1357,7 @@ * * * ```js - * const { Map } = require('immutable') + * const { Map } = require('immutable@4.0.0-rc.4') * const originalMap = Map({ * subObject: Map({ * subKey: 'subvalue', @@ -1402,7 +1415,7 @@ * * * ```js - * const { Map, List } = require('immutable') + * const { Map, List } = require('immutable@4.0.0-rc.4') * const map = Map({ inMap: Map({ inList: List([ 1, 2, 3 ]) }) }) * const newMap = map.updateIn(['inMap', 'inList'], list => list.push(4)) * // Map { "inMap": Map { "inList": List [ 1, 2, 3, 4 ] } } @@ -1414,7 +1427,7 @@ * provided, otherwise `undefined`. * * * ```js * const map = Map({ a: Map({ b: Map({ c: 10 }) }) }) @@ -1426,7 +1439,7 @@ * no change will occur. This is still true if `notSetValue` is provided. * * * ```js * const map = Map({ a: Map({ b: Map({ c: 10 }) }) }) @@ -1442,7 +1455,7 @@ * The previous example behaves differently when written with default values: * * * ```js * const map = Map({ a: Map({ b: Map({ c: 10 }) }) }) @@ -1501,7 +1514,7 @@ * * * ```js - * const { Map } = require('immutable') + * const { Map } = require('immutable@4.0.0-rc.4') * const map1 = Map() * const map2 = map1.withMutations(map => { * map.set('a', 1).set('b', 2).set('c', 3) @@ -1762,7 +1775,7 @@ * a collection of other sets. * * ```js - * const { Set } = require('immutable') + * const { Set } = require('immutable@4.0.0-rc.4') * const intersected = Set.intersect([ * Set([ 'a', 'b', 'c' ]) * Set([ 'c', 'a', 't' ]) @@ -1777,7 +1790,7 @@ * collection of other sets. * * ```js - * const { Set } = require('immutable') + * const { Set } = require('immutable@4.0.0-rc.4') * const unioned = Set.union([ * Set([ 'a', 'b', 'c' ]) * Set([ 'c', 'a', 't' ]) @@ -2392,7 +2405,7 @@ * infinity. When `start` is equal to `end`, returns empty range. * * ```js - * const { Range } = require('immutable') + * const { Range } = require('immutable@4.0.0-rc.4') * Range() // [ 0, 1, 2, 3, ... ] * Range(10) // [ 10, 11, 12, 13, ... ] * Range(10, 15) // [ 10, 11, 12, 13, 14 ] @@ -2409,7 +2422,7 @@ * not defined, returns an infinite `Seq` of `value`. * * ```js - * const { Repeat } = require('immutable') + * const { Repeat } = require('immutable@4.0.0-rc.4') * Repeat('foo') // [ 'foo', 'foo', 'foo', ... ] * Repeat('bar', 4) // [ 'bar', 'bar', 'bar', 'bar' ] * ``` @@ -2423,7 +2436,7 @@ * default values. * * ```js - * const { Record } = require('immutable') + * const { Record } = require('immutable@4.0.0-rc.4') * const ABRecord = Record({ a: 1, b: 2 }) * const myRecord = new ABRecord({ b: 3 }) * ``` @@ -2490,7 +2503,7 @@ * method. If one was not provided, the string "Record" is returned. * * ```js - * const { Record } = require('immutable') + * const { Record } = require('immutable@4.0.0-rc.4') * const Person = Record({ * name: null * }, 'Person') @@ -2638,7 +2651,7 @@ * Seq's values are never iterated: * * ```js - * const { Seq } = require('immutable') + * const { Seq } = require('immutable@4.0.0-rc.4') * const oddSquares = Seq([ 1, 2, 3, 4, 5, 6, 7, 8 ]) * .filter(x => x % 2 !== 0) * .map(x => x * x) @@ -2666,7 +2679,7 @@ * As well as expressing logic that would otherwise be memory or time limited: * * ```js - * const { Range } = require('immutable') + * const { Range } = require('immutable@4.0.0-rc.4') * Range(1, Infinity) * .skip(1000) * .map(n => -n) @@ -2740,7 +2753,7 @@ * `mapper` function. * * ```js - * const { Seq } = require('immutable') + * const { Seq } = require('immutable@4.0.0-rc.4') * Seq.Keyed({ a: 1, b: 2 }).map(x => 10 * x) * // Seq { "a": 10, "b": 20 } * ``` @@ -2842,7 +2855,7 @@ * `mapper` function. * * ```js - * const { Seq } = require('immutable') + * const { Seq } = require('immutable@4.0.0-rc.4') * Seq.Indexed([ 1, 2 ]).map(x => 10 * x) * // Seq [ 10, 20 ] * ``` @@ -3119,7 +3132,7 @@ * `mapper` function. * * ```js - * const { Seq } = require('immutable') + * const { Seq } = require('immutable@4.0.0-rc.4') * Seq([ 1, 2 ]).map(x => 10 * x) * // Seq [ 10, 20 ] * ``` @@ -3137,7 +3150,7 @@ * `mapper` function. * * ```js - * const { Seq } = require('immutable') + * const { Seq } = require('immutable@4.0.0-rc.4') * Seq([ 1, 2 ]).map(x => 10 * x) * // Seq [ 10, 20 ] * ``` @@ -3206,22 +3219,22 @@ export module Collection { /** - * @deprecated use `const { isKeyed } = require('immutable')` + * @deprecated use `const { isKeyed } = require('immutable@4.0.0-rc.4')` */ function isKeyed(maybeKeyed: any): maybeKeyed is Collection.Keyed; /** - * @deprecated use `const { isIndexed } = require('immutable')` + * @deprecated use `const { isIndexed } = require('immutable@4.0.0-rc.4')` */ function isIndexed(maybeIndexed: any): maybeIndexed is Collection.Indexed; /** - * @deprecated use `const { isAssociative } = require('immutable')` + * @deprecated use `const { isAssociative } = require('immutable@4.0.0-rc.4')` */ function isAssociative(maybeAssociative: any): maybeAssociative is Collection.Keyed | Collection.Indexed; /** - * @deprecated use `const { isOrdered } = require('immutable')` + * @deprecated use `const { isOrdered } = require('immutable@4.0.0-rc.4')` */ function isOrdered(maybeOrdered: any): boolean; @@ -3274,7 +3287,7 @@ * * * ```js - * const { Map } = require('immutable') + * const { Map } = require('immutable@4.0.0-rc.4') * Map({ a: 'z', b: 'y' }).flip() * // Map { "z": "a", "y": "b" } * ``` @@ -3292,7 +3305,7 @@ * `mapper` function. * * ```js - * const { Collection } = require('immutable') + * const { Collection } = require('immutable@4.0.0-rc.4') * Collection.Keyed({ a: 1, b: 2 }).map(x => 10 * x) * // Seq { "a": 10, "b": 20 } * ``` @@ -3311,7 +3324,7 @@ * * * ```js - * const { Map } = require('immutable') + * const { Map } = require('immutable@4.0.0-rc.4') * Map({ a: 1, b: 2 }).mapKeys(x => x.toUpperCase()) * // Map { "A": 1, "B": 2 } * ``` @@ -3330,7 +3343,7 @@ * * * ```js - * const { Map } = require('immutable') + * const { Map } = require('immutable@4.0.0-rc.4') * Map({ a: 1, b: 2 }) * .mapEntries(([ k, v ]) => [ k.toUpperCase(), v * 2 ]) * // Map { "A": 2, "B": 4 } @@ -3450,9 +3463,11 @@ * The resulting Collection includes the first item from each, then the * second from each, etc. * - * + * * ```js - * const { List } = require('immutable') + * const { List } = require('immutable@4.0.0-rc.4') * List([ 1, 2, 3 ]).interleave(List([ 'A', 'B', 'C' ])) * // List [ 1, "A", 2, "B", 3, "C"" ] * ``` @@ -3460,7 +3475,7 @@ * The shortest Collection stops interleave. * * * ```js * List([ 1, 2, 3 ]).interleave( @@ -3482,7 +3497,7 @@ * * * ```js - * const { List } = require('immutable') + * const { List } = require('immutable@4.0.0-rc.4') * List([ 'a', 'b', 'c', 'd' ]).splice(1, 2, 'q', 'r', 's') * // List [ "a", "q", "r", "s", "d" ] * ``` @@ -3501,7 +3516,7 @@ * * * * ```js * const a = List([ 1, 2, 3 ]); @@ -3558,7 +3573,7 @@ * collections by using a custom `zipper` function. * * * ```js * const a = List([ 1, 2, 3 ]); @@ -3626,7 +3641,7 @@ * `mapper` function. * * ```js - * const { Collection } = require('immutable') + * const { Collection } = require('immutable@4.0.0-rc.4') * Collection.Indexed([1,2]).map(x => 10 * x) * // Seq [ 1, 2 ] * ``` @@ -3678,7 +3693,7 @@ * the value as both the first and second arguments to the provided function. * * ```js - * const { Collection } = require('immutable') + * const { Collection } = require('immutable@4.0.0-rc.4') * const seq = Collection.Set([ 'A', 'B', 'C' ]) * // Seq { "A", "B", "C" } * seq.forEach((v, k) => @@ -3805,7 +3820,7 @@ * lookup via a different instance. * * * ```js * const a = List([ 1, 2, 3 ]); @@ -3884,8 +3899,9 @@ * * For example, to sum a Seq after mapping and filtering: * + * * ```js - * const { Seq } = require('immutable') + * const { Seq } = require('immutable@4.0.0-rc.4') * * function sum(collection) { * return collection.reduce((sum, x) => sum + x, 0) @@ -3978,7 +3994,7 @@ * * * ```js - * const { Map, List } = require('immutable') + * const { Map, List } = require('immutable@4.0.0-rc.4') * var myMap = Map({ a: 'Apple', b: 'Banana' }) * List(myMap) // List [ [ "a", "Apple" ], [ "b", "Banana" ] ] * myMap.toList() // List [ "Apple", "Banana" ] @@ -4013,8 +4029,9 @@ * The returned Seq will have identical iteration order as * this Collection. * + * * ```js - * const { Seq } = require('immutable') + * const { Seq } = require('immutable@4.0.0-rc.4') * const indexedSeq = Seq([ 'A', 'B', 'C' ]) * // Seq [ "A", "B", "C" ] * indexedSeq.filter(v => v === 'B') @@ -4093,8 +4110,9 @@ * Returns a new Collection of the same type with values passed through a * `mapper` function. * + * * ```js - * const { Collection } = require('immutable') + * const { Collection } = require('immutable@4.0.0-rc.4') * Collection({ a: 1, b: 2 }).map(x => 10 * x) * // Seq { "a": 10, "b": 20 } * ``` @@ -4111,8 +4129,9 @@ * Returns a new Collection of the same type with values passed through a * `mapper` function. * + * * ```js - * const { Collection } = require('immutable') + * const { Collection } = require('immutable@4.0.0-rc.4') * Collection({ a: 1, b: 2 }).map(x => 10 * x) * // Seq { "a": 10, "b": 20 } * ``` @@ -4130,7 +4149,7 @@ * * * ```js - * const { Map } = require('immutable') + * const { Map } = require('immutable@4.0.0-rc.4') * Map({ a: 1, b: 2, c: 3, d: 4}).filter(x => x % 2 === 0) * // Map { "b": 2, "d": 4 } * ``` @@ -4153,7 +4172,7 @@ * * * ```js - * const { Map } = require('immutable') + * const { Map } = require('immutable@4.0.0-rc.4') * Map({ a: 1, b: 2, c: 3, d: 4}).filterNot(x => x % 2 === 0) * // Map { "a": 1, "c": 3 } * ``` @@ -4188,8 +4207,9 @@ * When sorting collections which have no defined order, their ordered * equivalents will be returned. e.g. `map.sort()` returns OrderedMap. * + * * ```js - * const { Map } = require('immutable') + * const { Map } = require('immutable@4.0.0-rc.4') * Map({ "c": 3, "a": 1, "b": 2 }).sort((a, b) => { * if (a < b) { return -1; } * if (a > b) { return 1; } @@ -4227,8 +4247,9 @@ * * Note: This is always an eager operation. * + * * ```js - * const { List, Map } = require('immutable') + * const { List, Map } = require('immutable@4.0.0-rc.4') * const listOfMaps = List([ * Map({ v: 0 }), * Map({ v: 1 }), @@ -4315,7 +4336,7 @@ * * * ```js - * const { List } = require('immutable') + * const { List } = require('immutable@4.0.0-rc.4') * List([ 'dog', 'frog', 'cat', 'hat', 'god' ]) * .skipWhile(x => x.match(/g/)) * // List [ "cat", "hat", "god"" ] @@ -4332,7 +4353,7 @@ * * * ```js - * const { List } = require('immutable') + * const { List } = require('immutable@4.0.0-rc.4') * List([ 'dog', 'frog', 'cat', 'hat', 'god' ]) * .skipUntil(x => x.match(/hat/)) * // List [ "hat", "god"" ] @@ -4361,7 +4382,7 @@ * * * ```js - * const { List } = require('immutable') + * const { List } = require('immutable@4.0.0-rc.4') * List([ 'dog', 'frog', 'cat', 'hat', 'god' ]) * .takeWhile(x => x.match(/o/)) * // List [ "dog", "frog" ] @@ -4378,7 +4399,7 @@ * * * ```js - * const { List } = require('immutable') + * const { List } = require('immutable@4.0.0-rc.4') * List([ 'dog', 'frog', 'cat', 'hat', 'god' ]) * .takeUntil(x => x.match(/at/)) * // List [ "dog", "frog" ] diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index 9f856f9ec4..146bc62007 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -87,7 +87,7 @@ * ```js * // ES2015 * const mappedFoo = foo.map(x => x * x); - * // ES3 + * // ES5 * var mappedFoo = foo.map(function (x) { return x * x; }); * ``` * @@ -116,8 +116,9 @@ declare module Immutable { * If `reviver` is not provided, the default behavior will convert Objects * into Maps and Arrays into Lists like so: * + * * ```js - * const { fromJS, isKeyed } = require('immutable') + * const { fromJS, isKeyed } = require('immutable@4.0.0-rc.4') * function (key, value) { * return isKeyed(value) ? value.Map() : value.toList() * } @@ -129,8 +130,9 @@ declare module Immutable { * * Accordingly, this example converts native JS data to OrderedMap and List: * + * * ```js - * const { fromJS, isKeyed } = require('immutable') + * const { fromJS, isKeyed } = require('immutable@4.0.0-rc.4') * fromJS({ a: {b: [10, 20, 30]}, c: 40}, function (key, value, path) { * console.log(key, value, path) * return isKeyed(value) ? value.toOrderedMap() : value.toList() @@ -145,10 +147,9 @@ declare module Immutable { * JavaScript Object properties are always strings, even if written in a * quote-less shorthand, while Immutable Maps accept keys of any type. * - * + * * ```js + * const { Map } = require('immutable@4.0.0-rc.4') * let obj = { 1: "one" }; * Object.keys(obj); // [ "1" ] * assert.equal(obj["1"], obj[1]); // "one" === "one" @@ -184,7 +185,7 @@ declare module Immutable { * * * ```js - * const { Map, is } = require('immutable') + * const { Map, is } = require('immutable@4.0.0-rc.4') * const map1 = Map({ a: 1, b: 1, c: 1 }) * const map2 = Map({ a: 1, b: 1, c: 1 }) * assert.equal(map1 !== map2, true) @@ -229,8 +230,9 @@ declare module Immutable { /** * True if `maybeImmutable` is an Immutable Collection or Record. * + * * ```js - * const { isImmutable, Map, List, Stack } = require('immutable'); + * const { isImmutable, Map, List, Stack } = require('immutable@4.0.0-rc.4'); * isImmutable([]); // false * isImmutable({}); // false * isImmutable(Map()); // true @@ -244,8 +246,9 @@ declare module Immutable { /** * True if `maybeCollection` is a Collection, or any of its subclasses. * + * * ```js - * const { isCollection, Map, List, Stack } = require('immutable'); + * const { isCollection, Map, List, Stack } = require('immutable@4.0.0-rc.4'); * isCollection([]); // false * isCollection({}); // false * isCollection(Map()); // true @@ -258,8 +261,9 @@ declare module Immutable { /** * True if `maybeKeyed` is a Collection.Keyed, or any of its subclasses. * + * * ```js - * const { isKeyed, Map, List, Stack } = require('immutable'); + * const { isKeyed, Map, List, Stack } = require('immutable@4.0.0-rc.4'); * isKeyed([]); // false * isKeyed({}); // false * isKeyed(Map()); // true @@ -272,8 +276,9 @@ declare module Immutable { /** * True if `maybeIndexed` is a Collection.Indexed, or any of its subclasses. * + * * ```js - * const { isIndexed, Map, List, Stack, Set } = require('immutable'); + * const { isIndexed, Map, List, Stack, Set } = require('immutable@4.0.0-rc.4'); * isIndexed([]); // false * isIndexed({}); // false * isIndexed(Map()); // false @@ -287,8 +292,9 @@ declare module Immutable { /** * True if `maybeAssociative` is either a Keyed or Indexed Collection. * + * * ```js - * const { isAssociative, Map, List, Stack, Set } = require('immutable'); + * const { isAssociative, Map, List, Stack, Set } = require('immutable@4.0.0-rc.4'); * isAssociative([]); // false * isAssociative({}); // false * isAssociative(Map()); // true @@ -303,8 +309,9 @@ declare module Immutable { * True if `maybeOrdered` is a Collection where iteration order is well * defined. True for Collection.Indexed as well as OrderedMap and OrderedSet. * + * * ```js - * const { isOrdered, Map, OrderedMap, List, Set } = require('immutable'); + * const { isOrdered, Map, OrderedMap, List, Set } = require('immutable@4.0.0-rc.4'); * isOrdered([]); // false * isOrdered({}); // false * isOrdered(Map()); // false @@ -344,10 +351,9 @@ declare module Immutable { * and is used when adding this to a `Set` or as a key in a `Map`, enabling * lookup via a different instance. * - * + * * ```js + * const { List, Set } = require('immutable@4.0.0-rc.4'); * const a = List([ 1, 2, 3 ]); * const b = List([ 1, 2, 3 ]); * assert.notStrictEqual(a, b); // different instances @@ -391,10 +397,9 @@ declare module Immutable { /** * True if the provided value is a List * - * + * * ```js + * const { List } = require('immutable@4.0.0-rc.4'); * List.isList([]); // false * List.isList(List()); // true * ``` @@ -404,20 +409,18 @@ declare module Immutable { /** * Creates a new List containing `values`. * - * + * * ```js + * const { List } = require('immutable@4.0.0-rc.4'); * List.of(1, 2, 3, 4) * // List [ 1, 2, 3, 4 ] * ``` * * Note: Values are not altered or converted in any way. * - * + * * ```js + * const { List } = require('immutable@4.0.0-rc.4'); * List.of({x:1}, 2, [3], 4) * // List [ { x: 1 }, 2, [ 3 ], 4 ] * ``` @@ -431,7 +434,7 @@ declare module Immutable { * * * ```js - * const { List, Set } = require('immutable') + * const { List, Set } = require('immutable@4.0.0-rc.4') * * const emptyList = List() * // List [] @@ -870,6 +873,9 @@ declare module Immutable { * * Like `zipWith`, but using the default `zipper`: creating an `Array`. * + * * ```js * const a = List([ 1, 2, 3 ]); * const b = List([ 4, 5, 6 ]); @@ -882,7 +888,9 @@ declare module Immutable { * Returns a List "zipped" with the provided collection. * * Like `zipWith`, but using the default `zipper`: creating an `Array`. - * + * * ```js * const a = List([ 1, 2, 3 ]); * const b = List([ 4, 5, 6 ]); @@ -913,6 +921,9 @@ declare module Immutable { * Unlike `zip`, `zipAll` continues zipping until the longest collection is * exhausted. Missing values from shorter collections are filled with `undefined`. * + * * ```js * const a = List([ 1, 2 ]); * const b = List([ 3, 4, 5 ]); @@ -967,7 +978,7 @@ declare module Immutable { * * * ```js - * const { Map, List } = require('immutable'); + * const { Map, List } = require('immutable@4.0.0-rc.4'); * Map().set(List([ 1 ]), 'listofone').get(List([ 1 ])); * // 'listofone' * ``` @@ -983,8 +994,9 @@ declare module Immutable { /** * True if the provided value is a Map * + * * ```js - * const { Map } = require('immutable') + * const { Map } = require('immutable@4.0.0-rc.4') * Map.isMap({}) // false * Map.isMap(Map()) // true * ``` @@ -996,7 +1008,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable') + * const { Map } = require('immutable@4.0.0-rc.4') * Map.of( * 'key', 'value', * 'numerical value', 3, @@ -1018,7 +1030,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable') + * const { Map } = require('immutable@4.0.0-rc.4') * Map({ key: "value" }) * Map([ [ "key", "value" ] ]) * ``` @@ -1064,7 +1076,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable') + * const { Map } = require('immutable@4.0.0-rc.4') * const originalMap = Map() * const newerMap = originalMap.set('key', 'value') * const newestMap = newerMap.set('key', 'newer value') @@ -1089,7 +1101,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable') + * const { Map } = require('immutable@4.0.0-rc.4') * const originalMap = Map({ * key: 'value', * otherKey: 'other value' @@ -1109,8 +1121,9 @@ declare module Immutable { /** * Returns a new Map which excludes the provided `keys`. * + * * ```js - * const { Map } = require('immutable') + * const { Map } = require('immutable@4.0.0-rc.4') * const names = Map({ a: "Aaron", b: "Barry", c: "Connor" }) * names.deleteAll([ 'a', 'c' ]) * // Map { "b": "Barry" } @@ -1128,7 +1141,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable') + * const { Map } = require('immutable@4.0.0-rc.4') * Map({ key: 'value' }).clear() * // Map {} * ``` @@ -1145,7 +1158,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable') + * const { Map } = require('immutable@4.0.0-rc.4') * const aMap = Map({ key: 'value' }) * const newMap = aMap.update('key', value => value + value) * // Map { "key": "valuevalue" } @@ -1256,7 +1269,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable') + * const { Map } = require('immutable@4.0.0-rc.4') * const one = Map({ a: 10, b: 20, c: 30 }) * const two = Map({ b: 40, a: 50, d: 60 }) * one.merge(two) // Map { "a": 50, "b": 40, "c": 30, "d": 60 } @@ -1274,7 +1287,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable') + * const { Map } = require('immutable@4.0.0-rc.4') * const one = Map({ a: 10, b: 20, c: 30 }) * const two = Map({ b: 40, a: 50, d: 60 }) * one.mergeWith((oldVal, newVal) => oldVal / newVal, two) @@ -1296,7 +1309,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable') + * const { Map } = require('immutable@4.0.0-rc.4') * const one = Map({ a: Map({ x: 10, y: 10 }), b: Map({ x: 20, y: 50 }) }) * const two = Map({ a: Map({ x: 2 }), b: Map({ y: 5 }), c: Map({ z: 3 }) }) * one.mergeDeep(two) @@ -1317,7 +1330,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable') + * const { Map } = require('immutable@4.0.0-rc.4') * const one = Map({ a: Map({ x: 10, y: 10 }), b: Map({ x: 20, y: 50 }) }) * const two = Map({ a: Map({ x: 2 }), b: Map({ y: 5 }), c: Map({ z: 3 }) }) * one.mergeDeepWith((oldVal, newVal) => oldVal / newVal, two) @@ -1344,7 +1357,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable') + * const { Map } = require('immutable@4.0.0-rc.4') * const originalMap = Map({ * subObject: Map({ * subKey: 'subvalue', @@ -1402,7 +1415,7 @@ declare module Immutable { * * * ```js - * const { Map, List } = require('immutable') + * const { Map, List } = require('immutable@4.0.0-rc.4') * const map = Map({ inMap: Map({ inList: List([ 1, 2, 3 ]) }) }) * const newMap = map.updateIn(['inMap', 'inList'], list => list.push(4)) * // Map { "inMap": Map { "inList": List [ 1, 2, 3, 4 ] } } @@ -1414,7 +1427,7 @@ declare module Immutable { * provided, otherwise `undefined`. * * * ```js * const map = Map({ a: Map({ b: Map({ c: 10 }) }) }) @@ -1426,7 +1439,7 @@ declare module Immutable { * no change will occur. This is still true if `notSetValue` is provided. * * * ```js * const map = Map({ a: Map({ b: Map({ c: 10 }) }) }) @@ -1442,7 +1455,7 @@ declare module Immutable { * The previous example behaves differently when written with default values: * * * ```js * const map = Map({ a: Map({ b: Map({ c: 10 }) }) }) @@ -1501,7 +1514,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable') + * const { Map } = require('immutable@4.0.0-rc.4') * const map1 = Map() * const map2 = map1.withMutations(map => { * map.set('a', 1).set('b', 2).set('c', 3) @@ -1762,7 +1775,7 @@ declare module Immutable { * a collection of other sets. * * ```js - * const { Set } = require('immutable') + * const { Set } = require('immutable@4.0.0-rc.4') * const intersected = Set.intersect([ * Set([ 'a', 'b', 'c' ]) * Set([ 'c', 'a', 't' ]) @@ -1777,7 +1790,7 @@ declare module Immutable { * collection of other sets. * * ```js - * const { Set } = require('immutable') + * const { Set } = require('immutable@4.0.0-rc.4') * const unioned = Set.union([ * Set([ 'a', 'b', 'c' ]) * Set([ 'c', 'a', 't' ]) @@ -2392,7 +2405,7 @@ declare module Immutable { * infinity. When `start` is equal to `end`, returns empty range. * * ```js - * const { Range } = require('immutable') + * const { Range } = require('immutable@4.0.0-rc.4') * Range() // [ 0, 1, 2, 3, ... ] * Range(10) // [ 10, 11, 12, 13, ... ] * Range(10, 15) // [ 10, 11, 12, 13, 14 ] @@ -2409,7 +2422,7 @@ declare module Immutable { * not defined, returns an infinite `Seq` of `value`. * * ```js - * const { Repeat } = require('immutable') + * const { Repeat } = require('immutable@4.0.0-rc.4') * Repeat('foo') // [ 'foo', 'foo', 'foo', ... ] * Repeat('bar', 4) // [ 'bar', 'bar', 'bar', 'bar' ] * ``` @@ -2423,7 +2436,7 @@ declare module Immutable { * default values. * * ```js - * const { Record } = require('immutable') + * const { Record } = require('immutable@4.0.0-rc.4') * const ABRecord = Record({ a: 1, b: 2 }) * const myRecord = new ABRecord({ b: 3 }) * ``` @@ -2490,7 +2503,7 @@ declare module Immutable { * method. If one was not provided, the string "Record" is returned. * * ```js - * const { Record } = require('immutable') + * const { Record } = require('immutable@4.0.0-rc.4') * const Person = Record({ * name: null * }, 'Person') @@ -2638,7 +2651,7 @@ declare module Immutable { * Seq's values are never iterated: * * ```js - * const { Seq } = require('immutable') + * const { Seq } = require('immutable@4.0.0-rc.4') * const oddSquares = Seq([ 1, 2, 3, 4, 5, 6, 7, 8 ]) * .filter(x => x % 2 !== 0) * .map(x => x * x) @@ -2666,7 +2679,7 @@ declare module Immutable { * As well as expressing logic that would otherwise be memory or time limited: * * ```js - * const { Range } = require('immutable') + * const { Range } = require('immutable@4.0.0-rc.4') * Range(1, Infinity) * .skip(1000) * .map(n => -n) @@ -2740,7 +2753,7 @@ declare module Immutable { * `mapper` function. * * ```js - * const { Seq } = require('immutable') + * const { Seq } = require('immutable@4.0.0-rc.4') * Seq.Keyed({ a: 1, b: 2 }).map(x => 10 * x) * // Seq { "a": 10, "b": 20 } * ``` @@ -2842,7 +2855,7 @@ declare module Immutable { * `mapper` function. * * ```js - * const { Seq } = require('immutable') + * const { Seq } = require('immutable@4.0.0-rc.4') * Seq.Indexed([ 1, 2 ]).map(x => 10 * x) * // Seq [ 10, 20 ] * ``` @@ -3119,7 +3132,7 @@ declare module Immutable { * `mapper` function. * * ```js - * const { Seq } = require('immutable') + * const { Seq } = require('immutable@4.0.0-rc.4') * Seq([ 1, 2 ]).map(x => 10 * x) * // Seq [ 10, 20 ] * ``` @@ -3137,7 +3150,7 @@ declare module Immutable { * `mapper` function. * * ```js - * const { Seq } = require('immutable') + * const { Seq } = require('immutable@4.0.0-rc.4') * Seq([ 1, 2 ]).map(x => 10 * x) * // Seq [ 10, 20 ] * ``` @@ -3206,22 +3219,22 @@ declare module Immutable { export module Collection { /** - * @deprecated use `const { isKeyed } = require('immutable')` + * @deprecated use `const { isKeyed } = require('immutable@4.0.0-rc.4')` */ function isKeyed(maybeKeyed: any): maybeKeyed is Collection.Keyed; /** - * @deprecated use `const { isIndexed } = require('immutable')` + * @deprecated use `const { isIndexed } = require('immutable@4.0.0-rc.4')` */ function isIndexed(maybeIndexed: any): maybeIndexed is Collection.Indexed; /** - * @deprecated use `const { isAssociative } = require('immutable')` + * @deprecated use `const { isAssociative } = require('immutable@4.0.0-rc.4')` */ function isAssociative(maybeAssociative: any): maybeAssociative is Collection.Keyed | Collection.Indexed; /** - * @deprecated use `const { isOrdered } = require('immutable')` + * @deprecated use `const { isOrdered } = require('immutable@4.0.0-rc.4')` */ function isOrdered(maybeOrdered: any): boolean; @@ -3274,7 +3287,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable') + * const { Map } = require('immutable@4.0.0-rc.4') * Map({ a: 'z', b: 'y' }).flip() * // Map { "z": "a", "y": "b" } * ``` @@ -3292,7 +3305,7 @@ declare module Immutable { * `mapper` function. * * ```js - * const { Collection } = require('immutable') + * const { Collection } = require('immutable@4.0.0-rc.4') * Collection.Keyed({ a: 1, b: 2 }).map(x => 10 * x) * // Seq { "a": 10, "b": 20 } * ``` @@ -3311,7 +3324,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable') + * const { Map } = require('immutable@4.0.0-rc.4') * Map({ a: 1, b: 2 }).mapKeys(x => x.toUpperCase()) * // Map { "A": 1, "B": 2 } * ``` @@ -3330,7 +3343,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable') + * const { Map } = require('immutable@4.0.0-rc.4') * Map({ a: 1, b: 2 }) * .mapEntries(([ k, v ]) => [ k.toUpperCase(), v * 2 ]) * // Map { "A": 2, "B": 4 } @@ -3450,9 +3463,11 @@ declare module Immutable { * The resulting Collection includes the first item from each, then the * second from each, etc. * - * + * * ```js - * const { List } = require('immutable') + * const { List } = require('immutable@4.0.0-rc.4') * List([ 1, 2, 3 ]).interleave(List([ 'A', 'B', 'C' ])) * // List [ 1, "A", 2, "B", 3, "C"" ] * ``` @@ -3460,7 +3475,7 @@ declare module Immutable { * The shortest Collection stops interleave. * * * ```js * List([ 1, 2, 3 ]).interleave( @@ -3482,7 +3497,7 @@ declare module Immutable { * * * ```js - * const { List } = require('immutable') + * const { List } = require('immutable@4.0.0-rc.4') * List([ 'a', 'b', 'c', 'd' ]).splice(1, 2, 'q', 'r', 's') * // List [ "a", "q", "r", "s", "d" ] * ``` @@ -3501,7 +3516,7 @@ declare module Immutable { * * * * ```js * const a = List([ 1, 2, 3 ]); @@ -3558,7 +3573,7 @@ declare module Immutable { * collections by using a custom `zipper` function. * * * ```js * const a = List([ 1, 2, 3 ]); @@ -3626,7 +3641,7 @@ declare module Immutable { * `mapper` function. * * ```js - * const { Collection } = require('immutable') + * const { Collection } = require('immutable@4.0.0-rc.4') * Collection.Indexed([1,2]).map(x => 10 * x) * // Seq [ 1, 2 ] * ``` @@ -3678,7 +3693,7 @@ declare module Immutable { * the value as both the first and second arguments to the provided function. * * ```js - * const { Collection } = require('immutable') + * const { Collection } = require('immutable@4.0.0-rc.4') * const seq = Collection.Set([ 'A', 'B', 'C' ]) * // Seq { "A", "B", "C" } * seq.forEach((v, k) => @@ -3805,7 +3820,7 @@ declare module Immutable { * lookup via a different instance. * * * ```js * const a = List([ 1, 2, 3 ]); @@ -3884,8 +3899,9 @@ declare module Immutable { * * For example, to sum a Seq after mapping and filtering: * + * * ```js - * const { Seq } = require('immutable') + * const { Seq } = require('immutable@4.0.0-rc.4') * * function sum(collection) { * return collection.reduce((sum, x) => sum + x, 0) @@ -3978,7 +3994,7 @@ declare module Immutable { * * * ```js - * const { Map, List } = require('immutable') + * const { Map, List } = require('immutable@4.0.0-rc.4') * var myMap = Map({ a: 'Apple', b: 'Banana' }) * List(myMap) // List [ [ "a", "Apple" ], [ "b", "Banana" ] ] * myMap.toList() // List [ "Apple", "Banana" ] @@ -4013,8 +4029,9 @@ declare module Immutable { * The returned Seq will have identical iteration order as * this Collection. * + * * ```js - * const { Seq } = require('immutable') + * const { Seq } = require('immutable@4.0.0-rc.4') * const indexedSeq = Seq([ 'A', 'B', 'C' ]) * // Seq [ "A", "B", "C" ] * indexedSeq.filter(v => v === 'B') @@ -4093,8 +4110,9 @@ declare module Immutable { * Returns a new Collection of the same type with values passed through a * `mapper` function. * + * * ```js - * const { Collection } = require('immutable') + * const { Collection } = require('immutable@4.0.0-rc.4') * Collection({ a: 1, b: 2 }).map(x => 10 * x) * // Seq { "a": 10, "b": 20 } * ``` @@ -4111,8 +4129,9 @@ declare module Immutable { * Returns a new Collection of the same type with values passed through a * `mapper` function. * + * * ```js - * const { Collection } = require('immutable') + * const { Collection } = require('immutable@4.0.0-rc.4') * Collection({ a: 1, b: 2 }).map(x => 10 * x) * // Seq { "a": 10, "b": 20 } * ``` @@ -4130,7 +4149,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable') + * const { Map } = require('immutable@4.0.0-rc.4') * Map({ a: 1, b: 2, c: 3, d: 4}).filter(x => x % 2 === 0) * // Map { "b": 2, "d": 4 } * ``` @@ -4153,7 +4172,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable') + * const { Map } = require('immutable@4.0.0-rc.4') * Map({ a: 1, b: 2, c: 3, d: 4}).filterNot(x => x % 2 === 0) * // Map { "a": 1, "c": 3 } * ``` @@ -4188,8 +4207,9 @@ declare module Immutable { * When sorting collections which have no defined order, their ordered * equivalents will be returned. e.g. `map.sort()` returns OrderedMap. * + * * ```js - * const { Map } = require('immutable') + * const { Map } = require('immutable@4.0.0-rc.4') * Map({ "c": 3, "a": 1, "b": 2 }).sort((a, b) => { * if (a < b) { return -1; } * if (a > b) { return 1; } @@ -4227,8 +4247,9 @@ declare module Immutable { * * Note: This is always an eager operation. * + * * ```js - * const { List, Map } = require('immutable') + * const { List, Map } = require('immutable@4.0.0-rc.4') * const listOfMaps = List([ * Map({ v: 0 }), * Map({ v: 1 }), @@ -4315,7 +4336,7 @@ declare module Immutable { * * * ```js - * const { List } = require('immutable') + * const { List } = require('immutable@4.0.0-rc.4') * List([ 'dog', 'frog', 'cat', 'hat', 'god' ]) * .skipWhile(x => x.match(/g/)) * // List [ "cat", "hat", "god"" ] @@ -4332,7 +4353,7 @@ declare module Immutable { * * * ```js - * const { List } = require('immutable') + * const { List } = require('immutable@4.0.0-rc.4') * List([ 'dog', 'frog', 'cat', 'hat', 'god' ]) * .skipUntil(x => x.match(/hat/)) * // List [ "hat", "god"" ] @@ -4361,7 +4382,7 @@ declare module Immutable { * * * ```js - * const { List } = require('immutable') + * const { List } = require('immutable@4.0.0-rc.4') * List([ 'dog', 'frog', 'cat', 'hat', 'god' ]) * .takeWhile(x => x.match(/o/)) * // List [ "dog", "frog" ] @@ -4378,7 +4399,7 @@ declare module Immutable { * * * ```js - * const { List } = require('immutable') + * const { List } = require('immutable@4.0.0-rc.4') * List([ 'dog', 'frog', 'cat', 'hat', 'god' ]) * .takeUntil(x => x.match(/at/)) * // List [ "dog", "frog" ] From fee20b3bd41f36a0f07d79aeda0f902086c3942c Mon Sep 17 00:00:00 2001 From: Travis CI Date: Wed, 4 Oct 2017 21:09:16 +0000 Subject: [PATCH 027/242] Deploy master to NPM branch --- dist/immutable-nonambient.d.ts | 151 +++------------------------------ dist/immutable.d.ts | 151 +++------------------------------ 2 files changed, 22 insertions(+), 280 deletions(-) diff --git a/dist/immutable-nonambient.d.ts b/dist/immutable-nonambient.d.ts index 2baa4a66b8..acc80f751b 100644 --- a/dist/immutable-nonambient.d.ts +++ b/dist/immutable-nonambient.d.ts @@ -883,36 +883,7 @@ * ``` */ zip(other: Collection): List<[T,U]>; - - /** - * Returns a List "zipped" with the provided collection. - * - * Like `zipWith`, but using the default `zipper`: creating an `Array`. - * - * ```js - * const a = List([ 1, 2, 3 ]); - * const b = List([ 4, 5, 6 ]); - * const c = a.zip(b); // List [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] - * ``` - */ zip(other: Collection, other2: Collection): List<[T,U,V]>; - - /** - * Returns a List "zipped" with the provided collections. - * - * Like `zipWith`, but using the default `zipper`: creating an `Array`. - * - * - * ```js - * const a = List([ 1, 2, 3 ]); - * const b = List([ 4, 5, 6 ]); - * const c = a.zip(b); // List [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] - * ``` - */ zip(...collections: Array>): List; /** @@ -930,6 +901,8 @@ * const c = a.zipAll(b); // List [ [ 1, 3 ], [ 2, 4 ], [ undefined, 5 ] ] * ``` */ + zipAll(other: Collection): List<[T,U]>; + zipAll(other: Collection, other2: Collection): List<[T,U,V]>; zipAll(...collections: Array>): List; /** @@ -2048,8 +2021,6 @@ * Returns an OrderedSet of the same type "zipped" with the provided * collections. * - * @see IndexedIterator.zip - * * Like `zipWith`, but using the default `zipper`: creating an `Array`. * * ```js @@ -2060,47 +2031,13 @@ * ``` */ zip(other: Collection): OrderedSet<[T,U]>; - - /** - * Returns an OrderedSet of the same type "zipped" with the provided - * collections. - * - * @see IndexedIterator.zip - * - * Like `zipWith`, but using the default `zipper`: creating an `Array`. - * - * ```js - * const a = OrderedSet([ 1, 2, 3 ]) - * const b = OrderedSet([ 4, 5, 6 ]) - * const c = a.zip(b) - * // OrderedSet [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] - * ``` - */ zip(other1: Collection, other2: Collection): OrderedSet<[T,U,V]>; - - /** - * Returns an OrderedSet of the same type "zipped" with the provided - * collections. - * - * @see IndexedIterator.zip - * - * Like `zipWith`, but using the default `zipper`: creating an `Array`. - * - * ```js - * const a = OrderedSet([ 1, 2, 3 ]) - * const b = OrderedSet([ 4, 5, 6 ]) - * const c = a.zip(b) - * // OrderedSet [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] - * ``` - */ zip(...collections: Array>): OrderedSet; /** * Returns a OrderedSet of the same type "zipped" with the provided * collections. * - * @see IndexedIterator.zipAll - * * Unlike `zip`, `zipAll` continues zipping until the longest collection is * exhausted. Missing values from shorter collections are filled with `undefined`. * @@ -2110,13 +2047,15 @@ * const c = a.zipAll(b); // OrderedSet [ [ 1, 3 ], [ 2, 4 ], [ undefined, 5 ] ] * ``` */ + zipAll(other: Collection): OrderedSet<[T,U]>; + zipAll(other1: Collection, other2: Collection): OrderedSet<[T,U,V]>; zipAll(...collections: Array>): OrderedSet; /** * Returns an OrderedSet of the same type "zipped" with the provided * collections by using a custom `zipper` function. * - * @see IndexedIterator.zipWith + * @see Seq.Indexed.zipWith */ zipWith( zipper: (value: T, otherValue: U) => Z, @@ -2331,31 +2270,7 @@ * ``` */ zip(other: Collection): Stack<[T,U]>; - - /** - * Returns a Stack "zipped" with the provided collections. - * - * Like `zipWith`, but using the default `zipper`: creating an `Array`. - * - * ```js - * const a = Stack([ 1, 2, 3 ]); - * const b = Stack([ 4, 5, 6 ]); - * const c = a.zip(b); // Stack [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] - * ``` - */ zip(other: Collection, other2: Collection): Stack<[T,U,V]>; - - /** - * Returns a Stack "zipped" with the provided collections. - * - * Like `zipWith`, but using the default `zipper`: creating an `Array`. - * - * ```js - * const a = Stack([ 1, 2, 3 ]); - * const b = Stack([ 4, 5, 6 ]); - * const c = a.zip(b); // Stack [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] - * ``` - */ zip(...collections: Array>): Stack; /** @@ -2370,6 +2285,8 @@ * const c = a.zipAll(b); // Stack [ [ 1, 3 ], [ 2, 4 ], [ undefined, 5 ] ] * ``` */ + zipAll(other: Collection): Stack<[T,U]>; + zipAll(other: Collection, other2: Collection): Stack<[T,U,V]>; zipAll(...collections: Array>): Stack; /** @@ -2906,31 +2823,7 @@ * ``` */ zip(other: Collection): Seq.Indexed<[T,U]>; - - /** - * Returns a Seq "zipped" with the provided collections. - * - * Like `zipWith`, but using the default `zipper`: creating an `Array`. - * - * ```js - * const a = Seq([ 1, 2, 3 ]); - * const b = Seq([ 4, 5, 6 ]); - * const c = a.zip(b); // Seq [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] - * ``` - */ zip(other: Collection, other2: Collection): Seq.Indexed<[T,U,V]>; - - /** - * Returns a Seq "zipped" with the provided collections. - * - * Like `zipWith`, but using the default `zipper`: creating an `Array`. - * - * ```js - * const a = Seq([ 1, 2, 3 ]); - * const b = Seq([ 4, 5, 6 ]); - * const c = a.zip(b); // Seq [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] - * ``` - */ zip(...collections: Array>): Seq.Indexed; /** @@ -2945,6 +2838,8 @@ * const c = a.zipAll(b); // Seq [ [ 1, 3 ], [ 2, 4 ], [ undefined, 5 ] ] * ``` */ + zipAll(other: Collection): Seq.Indexed<[T,U]>; + zipAll(other: Collection, other2: Collection): Seq.Indexed<[T,U,V]>; zipAll(...collections: Array>): Seq.Indexed; /** @@ -3525,33 +3420,7 @@ * ``` */ zip(other: Collection): Collection.Indexed<[T,U]>; - - /** - * Returns a Collection of the same type "zipped" with the provided - * collections. - * - * Like `zipWith`, but using the default `zipper`: creating an `Array`. - * - * ```js - * const a = List([ 1, 2, 3 ]); - * const b = List([ 4, 5, 6 ]); - * const c = a.zip(b); // List [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] - * ``` - */ zip(other: Collection, other2: Collection): Collection.Indexed<[T,U,V]>; - - /** - * Returns a Collection of the same type "zipped" with the provided - * collections. - * - * Like `zipWith`, but using the default `zipper`: creating an `Array`. - * - * ```js - * const a = List([ 1, 2, 3 ]); - * const b = List([ 4, 5, 6 ]); - * const c = a.zip(b); // List [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] - * ``` - */ zip(...collections: Array>): Collection.Indexed; /** @@ -3566,6 +3435,8 @@ * const c = a.zipAll(b); // List [ [ 1, 3 ], [ 2, 4 ], [ undefined, 5 ] ] * ``` */ + zipAll(other: Collection): Collection.Indexed<[T,U]>; + zipAll(other: Collection, other2: Collection): Collection.Indexed<[T,U,V]>; zipAll(...collections: Array>): Collection.Indexed; /** diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index 146bc62007..d3c90139ef 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -883,36 +883,7 @@ declare module Immutable { * ``` */ zip(other: Collection): List<[T,U]>; - - /** - * Returns a List "zipped" with the provided collection. - * - * Like `zipWith`, but using the default `zipper`: creating an `Array`. - * - * ```js - * const a = List([ 1, 2, 3 ]); - * const b = List([ 4, 5, 6 ]); - * const c = a.zip(b); // List [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] - * ``` - */ zip(other: Collection, other2: Collection): List<[T,U,V]>; - - /** - * Returns a List "zipped" with the provided collections. - * - * Like `zipWith`, but using the default `zipper`: creating an `Array`. - * - * - * ```js - * const a = List([ 1, 2, 3 ]); - * const b = List([ 4, 5, 6 ]); - * const c = a.zip(b); // List [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] - * ``` - */ zip(...collections: Array>): List; /** @@ -930,6 +901,8 @@ declare module Immutable { * const c = a.zipAll(b); // List [ [ 1, 3 ], [ 2, 4 ], [ undefined, 5 ] ] * ``` */ + zipAll(other: Collection): List<[T,U]>; + zipAll(other: Collection, other2: Collection): List<[T,U,V]>; zipAll(...collections: Array>): List; /** @@ -2048,8 +2021,6 @@ declare module Immutable { * Returns an OrderedSet of the same type "zipped" with the provided * collections. * - * @see IndexedIterator.zip - * * Like `zipWith`, but using the default `zipper`: creating an `Array`. * * ```js @@ -2060,47 +2031,13 @@ declare module Immutable { * ``` */ zip(other: Collection): OrderedSet<[T,U]>; - - /** - * Returns an OrderedSet of the same type "zipped" with the provided - * collections. - * - * @see IndexedIterator.zip - * - * Like `zipWith`, but using the default `zipper`: creating an `Array`. - * - * ```js - * const a = OrderedSet([ 1, 2, 3 ]) - * const b = OrderedSet([ 4, 5, 6 ]) - * const c = a.zip(b) - * // OrderedSet [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] - * ``` - */ zip(other1: Collection, other2: Collection): OrderedSet<[T,U,V]>; - - /** - * Returns an OrderedSet of the same type "zipped" with the provided - * collections. - * - * @see IndexedIterator.zip - * - * Like `zipWith`, but using the default `zipper`: creating an `Array`. - * - * ```js - * const a = OrderedSet([ 1, 2, 3 ]) - * const b = OrderedSet([ 4, 5, 6 ]) - * const c = a.zip(b) - * // OrderedSet [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] - * ``` - */ zip(...collections: Array>): OrderedSet; /** * Returns a OrderedSet of the same type "zipped" with the provided * collections. * - * @see IndexedIterator.zipAll - * * Unlike `zip`, `zipAll` continues zipping until the longest collection is * exhausted. Missing values from shorter collections are filled with `undefined`. * @@ -2110,13 +2047,15 @@ declare module Immutable { * const c = a.zipAll(b); // OrderedSet [ [ 1, 3 ], [ 2, 4 ], [ undefined, 5 ] ] * ``` */ + zipAll(other: Collection): OrderedSet<[T,U]>; + zipAll(other1: Collection, other2: Collection): OrderedSet<[T,U,V]>; zipAll(...collections: Array>): OrderedSet; /** * Returns an OrderedSet of the same type "zipped" with the provided * collections by using a custom `zipper` function. * - * @see IndexedIterator.zipWith + * @see Seq.Indexed.zipWith */ zipWith( zipper: (value: T, otherValue: U) => Z, @@ -2331,31 +2270,7 @@ declare module Immutable { * ``` */ zip(other: Collection): Stack<[T,U]>; - - /** - * Returns a Stack "zipped" with the provided collections. - * - * Like `zipWith`, but using the default `zipper`: creating an `Array`. - * - * ```js - * const a = Stack([ 1, 2, 3 ]); - * const b = Stack([ 4, 5, 6 ]); - * const c = a.zip(b); // Stack [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] - * ``` - */ zip(other: Collection, other2: Collection): Stack<[T,U,V]>; - - /** - * Returns a Stack "zipped" with the provided collections. - * - * Like `zipWith`, but using the default `zipper`: creating an `Array`. - * - * ```js - * const a = Stack([ 1, 2, 3 ]); - * const b = Stack([ 4, 5, 6 ]); - * const c = a.zip(b); // Stack [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] - * ``` - */ zip(...collections: Array>): Stack; /** @@ -2370,6 +2285,8 @@ declare module Immutable { * const c = a.zipAll(b); // Stack [ [ 1, 3 ], [ 2, 4 ], [ undefined, 5 ] ] * ``` */ + zipAll(other: Collection): Stack<[T,U]>; + zipAll(other: Collection, other2: Collection): Stack<[T,U,V]>; zipAll(...collections: Array>): Stack; /** @@ -2906,31 +2823,7 @@ declare module Immutable { * ``` */ zip(other: Collection): Seq.Indexed<[T,U]>; - - /** - * Returns a Seq "zipped" with the provided collections. - * - * Like `zipWith`, but using the default `zipper`: creating an `Array`. - * - * ```js - * const a = Seq([ 1, 2, 3 ]); - * const b = Seq([ 4, 5, 6 ]); - * const c = a.zip(b); // Seq [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] - * ``` - */ zip(other: Collection, other2: Collection): Seq.Indexed<[T,U,V]>; - - /** - * Returns a Seq "zipped" with the provided collections. - * - * Like `zipWith`, but using the default `zipper`: creating an `Array`. - * - * ```js - * const a = Seq([ 1, 2, 3 ]); - * const b = Seq([ 4, 5, 6 ]); - * const c = a.zip(b); // Seq [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] - * ``` - */ zip(...collections: Array>): Seq.Indexed; /** @@ -2945,6 +2838,8 @@ declare module Immutable { * const c = a.zipAll(b); // Seq [ [ 1, 3 ], [ 2, 4 ], [ undefined, 5 ] ] * ``` */ + zipAll(other: Collection): Seq.Indexed<[T,U]>; + zipAll(other: Collection, other2: Collection): Seq.Indexed<[T,U,V]>; zipAll(...collections: Array>): Seq.Indexed; /** @@ -3525,33 +3420,7 @@ declare module Immutable { * ``` */ zip(other: Collection): Collection.Indexed<[T,U]>; - - /** - * Returns a Collection of the same type "zipped" with the provided - * collections. - * - * Like `zipWith`, but using the default `zipper`: creating an `Array`. - * - * ```js - * const a = List([ 1, 2, 3 ]); - * const b = List([ 4, 5, 6 ]); - * const c = a.zip(b); // List [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] - * ``` - */ zip(other: Collection, other2: Collection): Collection.Indexed<[T,U,V]>; - - /** - * Returns a Collection of the same type "zipped" with the provided - * collections. - * - * Like `zipWith`, but using the default `zipper`: creating an `Array`. - * - * ```js - * const a = List([ 1, 2, 3 ]); - * const b = List([ 4, 5, 6 ]); - * const c = a.zip(b); // List [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] - * ``` - */ zip(...collections: Array>): Collection.Indexed; /** @@ -3566,6 +3435,8 @@ declare module Immutable { * const c = a.zipAll(b); // List [ [ 1, 3 ], [ 2, 4 ], [ undefined, 5 ] ] * ``` */ + zipAll(other: Collection): Collection.Indexed<[T,U]>; + zipAll(other: Collection, other2: Collection): Collection.Indexed<[T,U,V]>; zipAll(...collections: Array>): Collection.Indexed; /** From a7e5cd9b62d2713802c5afd52426e89982d452bf Mon Sep 17 00:00:00 2001 From: Travis CI Date: Wed, 4 Oct 2017 22:42:28 +0000 Subject: [PATCH 028/242] Deploy master to NPM branch --- dist/immutable-nonambient.d.ts | 17 ++++++++++++++++- dist/immutable.d.ts | 17 ++++++++++++++++- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/dist/immutable-nonambient.d.ts b/dist/immutable-nonambient.d.ts index acc80f751b..d994313f5a 100644 --- a/dist/immutable-nonambient.d.ts +++ b/dist/immutable-nonambient.d.ts @@ -1597,6 +1597,11 @@ predicate: (value: V, key: K, iter: this) => any, context?: any ): this; + + /** + * @see Collection.Keyed.flip + */ + flip(): Map; } @@ -1710,6 +1715,11 @@ predicate: (value: V, key: K, iter: this) => any, context?: any ): this; + + /** + * @see Collection.Keyed.flip + */ + flip(): OrderedMap; } @@ -2724,6 +2734,11 @@ predicate: (value: V, key: K, iter: this) => any, context?: any ): this; + + /** + * @see Collection.Keyed.flip + */ + flip(): Seq.Keyed; } @@ -3187,7 +3202,7 @@ * // Map { "z": "a", "y": "b" } * ``` */ - flip(): this; + flip(): Collection.Keyed; /** * Returns a new Collection with other collections concatenated to this one. diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index d3c90139ef..6331bab75c 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -1597,6 +1597,11 @@ declare module Immutable { predicate: (value: V, key: K, iter: this) => any, context?: any ): this; + + /** + * @see Collection.Keyed.flip + */ + flip(): Map; } @@ -1710,6 +1715,11 @@ declare module Immutable { predicate: (value: V, key: K, iter: this) => any, context?: any ): this; + + /** + * @see Collection.Keyed.flip + */ + flip(): OrderedMap; } @@ -2724,6 +2734,11 @@ declare module Immutable { predicate: (value: V, key: K, iter: this) => any, context?: any ): this; + + /** + * @see Collection.Keyed.flip + */ + flip(): Seq.Keyed; } @@ -3187,7 +3202,7 @@ declare module Immutable { * // Map { "z": "a", "y": "b" } * ``` */ - flip(): this; + flip(): Collection.Keyed; /** * Returns a new Collection with other collections concatenated to this one. From 4df57db6099c589e368d4cb51d3c7c5bcf7b4b6d Mon Sep 17 00:00:00 2001 From: Travis CI Date: Wed, 4 Oct 2017 22:45:02 +0000 Subject: [PATCH 029/242] Deploy master to NPM branch --- dist/immutable.es.js | 8 ++++---- dist/immutable.js | 8 ++++---- dist/immutable.min.js | 10 +++++----- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/dist/immutable.es.js b/dist/immutable.es.js index 24901107ef..001877b482 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -4083,7 +4083,7 @@ var Set = (function (SetCollection$$1) { // @pragma Modification Set.prototype.add = function add (value) { - return updateSet(this, this._map.set(value, true)); + return updateSet(this, this._map.set(value, value)); }; Set.prototype.remove = function remove (value) { @@ -4183,11 +4183,11 @@ var Set = (function (SetCollection$$1) { Set.prototype.__iterate = function __iterate (fn, reverse) { var this$1 = this; - return this._map.__iterate(function (_, k) { return fn(k, k, this$1); }, reverse); + return this._map.__iterate(function (k) { return fn(k, k, this$1); }, reverse); }; Set.prototype.__iterator = function __iterator (type, reverse) { - return this._map.map(function (_, k) { return k; }).__iterator(type, reverse); + return this._map.__iterator(type, reverse); }; Set.prototype.__ensureOwner = function __ensureOwner (ownerID) { @@ -4197,7 +4197,7 @@ var Set = (function (SetCollection$$1) { var newMap = this._map.__ensureOwner(ownerID); if (!ownerID) { if (this.size === 0) { - return emptySet(); + return this.__empty(); } this.__ownerID = ownerID; this._map = newMap; diff --git a/dist/immutable.js b/dist/immutable.js index 820bb79f0a..fece69ba1d 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -4089,7 +4089,7 @@ var Set = (function (SetCollection$$1) { // @pragma Modification Set.prototype.add = function add (value) { - return updateSet(this, this._map.set(value, true)); + return updateSet(this, this._map.set(value, value)); }; Set.prototype.remove = function remove (value) { @@ -4189,11 +4189,11 @@ var Set = (function (SetCollection$$1) { Set.prototype.__iterate = function __iterate (fn, reverse) { var this$1 = this; - return this._map.__iterate(function (_, k) { return fn(k, k, this$1); }, reverse); + return this._map.__iterate(function (k) { return fn(k, k, this$1); }, reverse); }; Set.prototype.__iterator = function __iterator (type, reverse) { - return this._map.map(function (_, k) { return k; }).__iterator(type, reverse); + return this._map.__iterator(type, reverse); }; Set.prototype.__ensureOwner = function __ensureOwner (ownerID) { @@ -4203,7 +4203,7 @@ var Set = (function (SetCollection$$1) { var newMap = this._map.__ensureOwner(ownerID); if (!ownerID) { if (this.size === 0) { - return emptySet(); + return this.__empty(); } this.__ownerID = ownerID; this._map = newMap; diff --git a/dist/immutable.min.js b/dist/immutable.min.js index 65cc03ba68..9b0141010a 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -26,11 +26,11 @@ this):new qr(t,this.keyHash,v)};var Er=function(t,e,r){this.ownerID=t,this.keyHa return Pt(this,t,e)},e.prototype.remove=function(t){return this.has(t)?0===t?this.shift():t===this.size-1?this.pop():this.splice(t,1):this},e.prototype.insert=function(t,e){return this.splice(t,0,e)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=this._origin=this._capacity=0,this._level=Ee,this._root=this._tail=null,this.__hash=void 0,this.__altered=!0,this):Jt()},e.prototype.push=function(){var t=arguments,e=this.size;return this.withMutations(function(r){Yt(r,0,e+t.length);for(var n=0;n0;)e[r]=arguments[r+1];return Qt(this,t,e)},e.prototype.mergeDeep=function(){return Qt(this,jt,arguments)},e.prototype.mergeDeepWith=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Qt(this,kt(t),e)},e.prototype.setSize=function(t){return Yt(this,0,t)},e.prototype.slice=function(t,e){var r=this.size;return a(t,e,r)?this:Yt(this,c(t,r),h(e,r))},e.prototype.__iterator=function(t,e){var r=e?this.size:0,n=Wt(this,e);return new Fe(function(){var i=n();return i===Wr?S():z(t,e?--r:r++,i)})},e.prototype.__iterate=function(t,e){for(var r,n=this,i=e?this.size:0,o=Wt(this,e);(r=o())!==Wr&&t(r,e?--i:i++,n)!==!1;);return i},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Bt(this._origin,this._capacity,this._level,this._root,this._tail,t,this.__hash):0===this.size?Jt():(this.__ownerID=t,this.__altered=!1,this)},e}(Je);Ur.isList=Ct;var Kr="@@__IMMUTABLE_LIST__@@",Lr=Ur.prototype;Lr[Kr]=!0,Lr.delete=Lr.remove,Lr.setIn=br.setIn,Lr.deleteIn=Lr.removeIn=br.removeIn,Lr.update=br.update,Lr.updateIn=br.updateIn,Lr.mergeIn=br.mergeIn, Lr.mergeDeepIn=br.mergeDeepIn,Lr.withMutations=br.withMutations,Lr.asMutable=br.asMutable,Lr.asImmutable=br.asImmutable,Lr.wasAltered=br.wasAltered,Lr["@@transducer/init"]=Lr.asMutable,Lr["@@transducer/step"]=function(t,e){return t.push(e)},Lr["@@transducer/result"]=br["@@transducer/result"];var Tr=function(t,e){this.array=t,this.ownerID=e};Tr.prototype.removeBefore=function(t,e,r){if(r===e?1<>>e&je;if(n>=this.array.length)return new Tr([],t);var i,o=0===n;if(e>0){var u=this.array[n];if((i=u&&u.removeBefore(t,e-Ee,r))===u&&o)return this}if(o&&!i)return this;var s=Vt(this,t);if(!o)for(var a=0;a>>e&je;if(n>=this.array.length)return this;var i;if(e>0){var o=this.array[n];if((i=o&&o.removeAfter(t,e-Ee,r))===o&&n===this.array.length-1)return this}var u=Vt(this,t);return u.array.splice(n+1),i&&(u.array[n]=i),u};var Cr,Wr={},Br=function(t){function e(t){return null===t||void 0===t?Zt():Ft(t)?t:Zt().withMutations(function(e){var r=Be(t);yt(r.size),r.forEach(function(t,r){return e.set(r,t)})})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("OrderedMap {","}")},e.prototype.get=function(t,e){var r=this._map.get(t);return void 0!==r?this._list.get(r)[1]:e},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._map.clear(),this._list.clear(),this):Zt()},e.prototype.set=function(t,e){return $t(this,t,e)},e.prototype.remove=function(t){return $t(this,t,ke)},e.prototype.wasAltered=function(){return this._map.wasAltered()||this._list.wasAltered()},e.prototype.__iterate=function(t,e){var r=this;return this._list.__iterate(function(e){return e&&t(e[1],e[0],r)},e)},e.prototype.__iterator=function(t,e){return this._list.fromEntrySeq().__iterator(t,e)}, e.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var e=this._map.__ensureOwner(t),r=this._list.__ensureOwner(t);return t?Gt(e,r,t,this.__hash):0===this.size?Zt():(this.__ownerID=t,this._map=e,this._list=r,this)},e}(Sr);Br.isOrderedMap=Ft,Br.prototype[Te]=!0,Br.prototype.delete=Br.prototype.remove;var Jr,Pr=function(t){function e(t){return null===t||void 0===t?re():te(t)?t:re().pushAll(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("Stack [","]")},e.prototype.get=function(t,e){var r=this._head;for(t=u(this,t);r&&t--;)r=r.next;return r?r.value:e},e.prototype.peek=function(){return this._head&&this._head.value},e.prototype.push=function(){var t=arguments;if(0===arguments.length)return this;for(var e=this.size+arguments.length,r=this._head,n=arguments.length-1;n>=0;n--)r={value:t[n],next:r};return this.__ownerID?(this.size=e,this._head=r,this.__hash=void 0,this.__altered=!0,this):ee(e,r)},e.prototype.pushAll=function(e){if(e=t(e),0===e.size)return this;if(0===this.size&&te(e))return e;yt(e.size);var r=this.size,n=this._head;return e.__iterate(function(t){r++,n={value:t,next:n}},!0),this.__ownerID?(this.size=r,this._head=n,this.__hash=void 0,this.__altered=!0,this):ee(r,n)},e.prototype.pop=function(){return this.slice(1)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):re()},e.prototype.slice=function(e,r){if(a(e,r,this.size))return this;var n=c(e,this.size);if(h(r,this.size)!==this.size)return t.prototype.slice.call(this,e,r);for(var i=this.size-n,o=this._head;n--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):ee(i,o)},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?ee(this.size,this._head,t,this.__hash):0===this.size?re():(this.__ownerID=t,this.__altered=!1,this)}, -e.prototype.__iterate=function(t,e){var r=this;if(e)return new rr(this.toArray()).__iterate(function(e,n){return t(e,n,r)},e);for(var n=0,i=this._head;i&&t(i.value,n++,r)!==!1;)i=i.next;return n},e.prototype.__iterator=function(t,e){if(e)return new rr(this.toArray()).__iterator(t,e);var r=0,n=this._head;return new Fe(function(){if(n){var e=n.value;return n=n.next,z(t,r++,e)}return S()})},e}(Je);Pr.isStack=te;var Nr="@@__IMMUTABLE_STACK__@@",Vr=Pr.prototype;Vr[Nr]=!0,Vr.withMutations=br.withMutations,Vr.asMutable=br.asMutable,Vr.asImmutable=br.asImmutable,Vr.wasAltered=br.wasAltered,Vr.shift=Vr.pop,Vr.unshift=Vr.push,Vr.unshiftAll=Vr.pushAll,Vr["@@transducer/init"]=Vr.asMutable,Vr["@@transducer/step"]=function(t,e){return t.unshift(e)},Vr["@@transducer/result"]=br["@@transducer/result"];var Hr,Yr=function(t){function e(e){return null===e||void 0===e?ae():oe(e)&&!g(e)?e:ae().withMutations(function(r){var n=t(e);yt(n.size),n.forEach(function(t){return r.add(t)})})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(Be(t).keySeq())},e.intersect=function(t){return t=We(t).toArray(),t.length?Xr.intersect.apply(e(t.pop()),t):ae()},e.union=function(t){return t=We(t).toArray(),t.length?Xr.union.apply(e(t.pop()),t):ae()},e.prototype.toString=function(){return this.__toString("Set {","}")},e.prototype.has=function(t){return this._map.has(t)},e.prototype.add=function(t){return ue(this,this._map.set(t,!0))},e.prototype.remove=function(t){return ue(this,this._map.remove(t))},e.prototype.clear=function(){return ue(this,this._map.clear())},e.prototype.union=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return e=e.filter(function(t){return 0!==t.size}),0===e.length?this:0!==this.size||this.__ownerID||1!==e.length?this.withMutations(function(r){for(var n=0;n0;)e[r]=arguments[r+1];return this.union.apply(this,e)},e.prototype.sort=function(t){return rn(it(this,t))},e.prototype.sortBy=function(t,e){return rn(it(this,e,t))},e.prototype.wasAltered=function(){return this._map.wasAltered()},e.prototype.__iterate=function(t,e){var r=this;return this._map.__iterate(function(e,n){return t(n,n,r)},e)},e.prototype.__iterator=function(t,e){return this._map.map(function(t,e){return e}).__iterator(t,e)},e.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var e=this._map.__ensureOwner(t);return t?this.__make(e,t):0===this.size?ae():(this.__ownerID=t,this._map=e,this)},e}(Pe);Yr.isSet=oe;var Qr="@@__IMMUTABLE_SET__@@",Xr=Yr.prototype;Xr[Qr]=!0,Xr.delete=Xr.remove,Xr.mergeDeep=Xr.merge,Xr.mergeDeepWith=Xr.mergeWith,Xr.withMutations=br.withMutations,Xr.asMutable=br.asMutable,Xr.asImmutable=br.asImmutable,Xr["@@transducer/init"]=Xr.asMutable,Xr["@@transducer/step"]=function(t,e){return t.add(e)},Xr["@@transducer/result"]=br["@@transducer/result"],Xr.__empty=ae,Xr.__make=se;var Fr,Gr,Zr=function(t){function e(t,r,n){if(!(this instanceof e))return new e(t,r,n);if(vt(0!==n,"Cannot step a Range by 0"),t=t||0,void 0===r&&(r=1/0),n=void 0===n?1:Math.abs(n),r=0&&e=0&&r0;)e[r]=arguments[r+1];return this.union.apply(this,e)},e.prototype.sort=function(t){return rn(it(this,t))},e.prototype.sortBy=function(t,e){return rn(it(this,e,t))},e.prototype.wasAltered=function(){return this._map.wasAltered()},e.prototype.__iterate=function(t,e){var r=this;return this._map.__iterate(function(e){return t(e,e,r)},e)},e.prototype.__iterator=function(t,e){return this._map.__iterator(t,e)},e.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var e=this._map.__ensureOwner(t);return t?this.__make(e,t):0===this.size?this.__empty():(this.__ownerID=t,this._map=e,this)},e}(Pe);Yr.isSet=oe;var Qr="@@__IMMUTABLE_SET__@@",Xr=Yr.prototype;Xr[Qr]=!0,Xr.delete=Xr.remove,Xr.mergeDeep=Xr.merge,Xr.mergeDeepWith=Xr.mergeWith,Xr.withMutations=br.withMutations,Xr.asMutable=br.asMutable,Xr.asImmutable=br.asImmutable,Xr["@@transducer/init"]=Xr.asMutable,Xr["@@transducer/step"]=function(t,e){return t.add(e)},Xr["@@transducer/result"]=br["@@transducer/result"],Xr.__empty=ae,Xr.__make=se;var Fr,Gr,Zr=function(t){function e(t,r,n){if(!(this instanceof e))return new e(t,r,n);if(vt(0!==n,"Cannot step a Range by 0"),t=t||0,void 0===r&&(r=1/0),n=void 0===n?1:Math.abs(n),r=0&&e=0&&rthis.size?e:this.find(function(e,r){return r===t},void 0,e)},has:function(t){return(t=u(this,t))>=0&&(void 0!==this.size?this.size===1/0||t Date: Wed, 4 Oct 2017 22:45:34 +0000 Subject: [PATCH 030/242] Deploy master to NPM branch --- dist/immutable.es.js | 2 +- dist/immutable.js | 2 +- dist/immutable.min.js | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dist/immutable.es.js b/dist/immutable.es.js index 001877b482..0030d3a08d 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -4197,7 +4197,7 @@ var Set = (function (SetCollection$$1) { var newMap = this._map.__ensureOwner(ownerID); if (!ownerID) { if (this.size === 0) { - return this.__empty(); + return emptySet(); } this.__ownerID = ownerID; this._map = newMap; diff --git a/dist/immutable.js b/dist/immutable.js index fece69ba1d..59f4a8b969 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -4203,7 +4203,7 @@ var Set = (function (SetCollection$$1) { var newMap = this._map.__ensureOwner(ownerID); if (!ownerID) { if (this.size === 0) { - return this.__empty(); + return emptySet(); } this.__ownerID = ownerID; this._map = newMap; diff --git a/dist/immutable.min.js b/dist/immutable.min.js index 9b0141010a..e07fb6d6fd 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -27,8 +27,8 @@ return Pt(this,t,e)},e.prototype.remove=function(t){return this.has(t)?0===t?thi Lr.mergeDeepIn=br.mergeDeepIn,Lr.withMutations=br.withMutations,Lr.asMutable=br.asMutable,Lr.asImmutable=br.asImmutable,Lr.wasAltered=br.wasAltered,Lr["@@transducer/init"]=Lr.asMutable,Lr["@@transducer/step"]=function(t,e){return t.push(e)},Lr["@@transducer/result"]=br["@@transducer/result"];var Tr=function(t,e){this.array=t,this.ownerID=e};Tr.prototype.removeBefore=function(t,e,r){if(r===e?1<>>e&je;if(n>=this.array.length)return new Tr([],t);var i,o=0===n;if(e>0){var u=this.array[n];if((i=u&&u.removeBefore(t,e-Ee,r))===u&&o)return this}if(o&&!i)return this;var s=Vt(this,t);if(!o)for(var a=0;a>>e&je;if(n>=this.array.length)return this;var i;if(e>0){var o=this.array[n];if((i=o&&o.removeAfter(t,e-Ee,r))===o&&n===this.array.length-1)return this}var u=Vt(this,t);return u.array.splice(n+1),i&&(u.array[n]=i),u};var Cr,Wr={},Br=function(t){function e(t){return null===t||void 0===t?Zt():Ft(t)?t:Zt().withMutations(function(e){var r=Be(t);yt(r.size),r.forEach(function(t,r){return e.set(r,t)})})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("OrderedMap {","}")},e.prototype.get=function(t,e){var r=this._map.get(t);return void 0!==r?this._list.get(r)[1]:e},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._map.clear(),this._list.clear(),this):Zt()},e.prototype.set=function(t,e){return $t(this,t,e)},e.prototype.remove=function(t){return $t(this,t,ke)},e.prototype.wasAltered=function(){return this._map.wasAltered()||this._list.wasAltered()},e.prototype.__iterate=function(t,e){var r=this;return this._list.__iterate(function(e){return e&&t(e[1],e[0],r)},e)},e.prototype.__iterator=function(t,e){return this._list.fromEntrySeq().__iterator(t,e)}, e.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var e=this._map.__ensureOwner(t),r=this._list.__ensureOwner(t);return t?Gt(e,r,t,this.__hash):0===this.size?Zt():(this.__ownerID=t,this._map=e,this._list=r,this)},e}(Sr);Br.isOrderedMap=Ft,Br.prototype[Te]=!0,Br.prototype.delete=Br.prototype.remove;var Jr,Pr=function(t){function e(t){return null===t||void 0===t?re():te(t)?t:re().pushAll(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("Stack [","]")},e.prototype.get=function(t,e){var r=this._head;for(t=u(this,t);r&&t--;)r=r.next;return r?r.value:e},e.prototype.peek=function(){return this._head&&this._head.value},e.prototype.push=function(){var t=arguments;if(0===arguments.length)return this;for(var e=this.size+arguments.length,r=this._head,n=arguments.length-1;n>=0;n--)r={value:t[n],next:r};return this.__ownerID?(this.size=e,this._head=r,this.__hash=void 0,this.__altered=!0,this):ee(e,r)},e.prototype.pushAll=function(e){if(e=t(e),0===e.size)return this;if(0===this.size&&te(e))return e;yt(e.size);var r=this.size,n=this._head;return e.__iterate(function(t){r++,n={value:t,next:n}},!0),this.__ownerID?(this.size=r,this._head=n,this.__hash=void 0,this.__altered=!0,this):ee(r,n)},e.prototype.pop=function(){return this.slice(1)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):re()},e.prototype.slice=function(e,r){if(a(e,r,this.size))return this;var n=c(e,this.size);if(h(r,this.size)!==this.size)return t.prototype.slice.call(this,e,r);for(var i=this.size-n,o=this._head;n--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):ee(i,o)},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?ee(this.size,this._head,t,this.__hash):0===this.size?re():(this.__ownerID=t,this.__altered=!1,this)}, e.prototype.__iterate=function(t,e){var r=this;if(e)return new rr(this.toArray()).__iterate(function(e,n){return t(e,n,r)},e);for(var n=0,i=this._head;i&&t(i.value,n++,r)!==!1;)i=i.next;return n},e.prototype.__iterator=function(t,e){if(e)return new rr(this.toArray()).__iterator(t,e);var r=0,n=this._head;return new Fe(function(){if(n){var e=n.value;return n=n.next,z(t,r++,e)}return S()})},e}(Je);Pr.isStack=te;var Nr="@@__IMMUTABLE_STACK__@@",Vr=Pr.prototype;Vr[Nr]=!0,Vr.withMutations=br.withMutations,Vr.asMutable=br.asMutable,Vr.asImmutable=br.asImmutable,Vr.wasAltered=br.wasAltered,Vr.shift=Vr.pop,Vr.unshift=Vr.push,Vr.unshiftAll=Vr.pushAll,Vr["@@transducer/init"]=Vr.asMutable,Vr["@@transducer/step"]=function(t,e){return t.unshift(e)},Vr["@@transducer/result"]=br["@@transducer/result"];var Hr,Yr=function(t){function e(e){return null===e||void 0===e?ae():oe(e)&&!g(e)?e:ae().withMutations(function(r){var n=t(e);yt(n.size),n.forEach(function(t){return r.add(t)})})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(Be(t).keySeq())},e.intersect=function(t){return t=We(t).toArray(),t.length?Xr.intersect.apply(e(t.pop()),t):ae()},e.union=function(t){return t=We(t).toArray(),t.length?Xr.union.apply(e(t.pop()),t):ae()},e.prototype.toString=function(){return this.__toString("Set {","}")},e.prototype.has=function(t){return this._map.has(t)},e.prototype.add=function(t){return ue(this,this._map.set(t,t))},e.prototype.remove=function(t){return ue(this,this._map.remove(t))},e.prototype.clear=function(){return ue(this,this._map.clear())},e.prototype.union=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return e=e.filter(function(t){return 0!==t.size}),0===e.length?this:0!==this.size||this.__ownerID||1!==e.length?this.withMutations(function(r){for(var n=0;n0;)e[r]=arguments[r+1];return this.union.apply(this,e)},e.prototype.sort=function(t){return rn(it(this,t))},e.prototype.sortBy=function(t,e){return rn(it(this,e,t))},e.prototype.wasAltered=function(){return this._map.wasAltered()},e.prototype.__iterate=function(t,e){var r=this;return this._map.__iterate(function(e){return t(e,e,r)},e)},e.prototype.__iterator=function(t,e){return this._map.__iterator(t,e)},e.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var e=this._map.__ensureOwner(t);return t?this.__make(e,t):0===this.size?this.__empty():(this.__ownerID=t,this._map=e,this)},e}(Pe);Yr.isSet=oe;var Qr="@@__IMMUTABLE_SET__@@",Xr=Yr.prototype;Xr[Qr]=!0,Xr.delete=Xr.remove,Xr.mergeDeep=Xr.merge,Xr.mergeDeepWith=Xr.mergeWith,Xr.withMutations=br.withMutations,Xr.asMutable=br.asMutable,Xr.asImmutable=br.asImmutable,Xr["@@transducer/init"]=Xr.asMutable,Xr["@@transducer/step"]=function(t,e){return t.add(e)},Xr["@@transducer/result"]=br["@@transducer/result"],Xr.__empty=ae,Xr.__make=se;var Fr,Gr,Zr=function(t){function e(t,r,n){if(!(this instanceof e))return new e(t,r,n);if(vt(0!==n,"Cannot step a Range by 0"),t=t||0,void 0===r&&(r=1/0),n=void 0===n?1:Math.abs(n),r=0&&e=0&&r0;)e[r]=arguments[r+1];return this.union.apply(this,e)},e.prototype.sort=function(t){return rn(it(this,t))},e.prototype.sortBy=function(t,e){return rn(it(this,e,t))},e.prototype.wasAltered=function(){return this._map.wasAltered()},e.prototype.__iterate=function(t,e){var r=this;return this._map.__iterate(function(e){return t(e,e,r)},e)},e.prototype.__iterator=function(t,e){return this._map.__iterator(t,e)},e.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var e=this._map.__ensureOwner(t);return t?this.__make(e,t):0===this.size?ae():(this.__ownerID=t,this._map=e,this)},e}(Pe);Yr.isSet=oe;var Qr="@@__IMMUTABLE_SET__@@",Xr=Yr.prototype;Xr[Qr]=!0,Xr.delete=Xr.remove,Xr.mergeDeep=Xr.merge,Xr.mergeDeepWith=Xr.mergeWith,Xr.withMutations=br.withMutations,Xr.asMutable=br.asMutable,Xr.asImmutable=br.asImmutable,Xr["@@transducer/init"]=Xr.asMutable,Xr["@@transducer/step"]=function(t,e){return t.add(e)},Xr["@@transducer/result"]=br["@@transducer/result"],Xr.__empty=ae,Xr.__make=se;var Fr,Gr,Zr=function(t){function e(t,r,n){if(!(this instanceof e))return new e(t,r,n);if(vt(0!==n,"Cannot step a Range by 0"),t=t||0,void 0===r&&(r=1/0),n=void 0===n?1:Math.abs(n),r=0&&e=0&&rthis.size?e:this.find(function(e,r){return r===t},void 0,e)},has:function(t){return(t=u(this,t))>=0&&(void 0!==this.size?this.size===1/0||t Date: Wed, 4 Oct 2017 22:49:42 +0000 Subject: [PATCH 031/242] Deploy master to NPM branch --- dist/immutable-nonambient.d.ts | 20 ++++++++++---------- dist/immutable.d.ts | 20 ++++++++++---------- dist/immutable.es.js | 2 +- dist/immutable.js | 2 +- dist/immutable.min.js | 4 ++-- 5 files changed, 24 insertions(+), 24 deletions(-) diff --git a/dist/immutable-nonambient.d.ts b/dist/immutable-nonambient.d.ts index d994313f5a..6f45329260 100644 --- a/dist/immutable-nonambient.d.ts +++ b/dist/immutable-nonambient.d.ts @@ -680,7 +680,7 @@ * * @see `Map#merge` */ - merge(...collections: Array | Array>): this; + merge(...collections: Array>): this; /** * Note: `mergeWith` can be used in `withMutations`. @@ -689,7 +689,7 @@ */ mergeWith( merger: (oldVal: T, newVal: T, key: number) => T, - ...collections: Array | Array> + ...collections: Array> ): this; /** @@ -697,7 +697,7 @@ * * @see `Map#mergeDeep` */ - mergeDeep(...collections: Array | Array>): this; + mergeDeep(...collections: Array>): this; /** * Note: `mergeDeepWith` can be used in `withMutations`. @@ -705,7 +705,7 @@ */ mergeDeepWith( merger: (oldVal: T, newVal: T, key: number) => T, - ...collections: Array | Array> + ...collections: Array> ): this; /** @@ -1251,7 +1251,7 @@ * * Note: `merge` can be used in `withMutations`. */ - merge(...collections: Array | {[key: string]: V}>): this; + merge(...collections: Array | {[key: string]: V}>): this; /** * Like `merge()`, `mergeWith()` returns a new Map resulting from merging @@ -1273,7 +1273,7 @@ */ mergeWith( merger: (oldVal: V, newVal: V, key: K) => V, - ...collections: Array | {[key: string]: V}> + ...collections: Array | {[key: string]: V}> ): this; /** @@ -1295,7 +1295,7 @@ * * Note: `mergeDeep` can be used in `withMutations`. */ - mergeDeep(...collections: Array | {[key: string]: V}>): this; + mergeDeep(...collections: Array | {[key: string]: V}>): this; /** * Like `mergeDeep()`, but when two non-Collections conflict, it uses the @@ -1318,7 +1318,7 @@ */ mergeDeepWith( merger: (oldVal: V, newVal: V, key: K) => V, - ...collections: Array | {[key: string]: V}> + ...collections: Array | {[key: string]: V}> ): this; @@ -1835,8 +1835,8 @@ * Note: `union` can be used in `withMutations`. * @alias merge */ - union(...collections: Array | Array>): this; - merge(...collections: Array | Array>): this; + union(...collections: Array>): this; + merge(...collections: Array>): this; /** * Returns a Set which has removed any values not also contained diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index 6331bab75c..76f13f5db9 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -680,7 +680,7 @@ declare module Immutable { * * @see `Map#merge` */ - merge(...collections: Array | Array>): this; + merge(...collections: Array>): this; /** * Note: `mergeWith` can be used in `withMutations`. @@ -689,7 +689,7 @@ declare module Immutable { */ mergeWith( merger: (oldVal: T, newVal: T, key: number) => T, - ...collections: Array | Array> + ...collections: Array> ): this; /** @@ -697,7 +697,7 @@ declare module Immutable { * * @see `Map#mergeDeep` */ - mergeDeep(...collections: Array | Array>): this; + mergeDeep(...collections: Array>): this; /** * Note: `mergeDeepWith` can be used in `withMutations`. @@ -705,7 +705,7 @@ declare module Immutable { */ mergeDeepWith( merger: (oldVal: T, newVal: T, key: number) => T, - ...collections: Array | Array> + ...collections: Array> ): this; /** @@ -1251,7 +1251,7 @@ declare module Immutable { * * Note: `merge` can be used in `withMutations`. */ - merge(...collections: Array | {[key: string]: V}>): this; + merge(...collections: Array | {[key: string]: V}>): this; /** * Like `merge()`, `mergeWith()` returns a new Map resulting from merging @@ -1273,7 +1273,7 @@ declare module Immutable { */ mergeWith( merger: (oldVal: V, newVal: V, key: K) => V, - ...collections: Array | {[key: string]: V}> + ...collections: Array | {[key: string]: V}> ): this; /** @@ -1295,7 +1295,7 @@ declare module Immutable { * * Note: `mergeDeep` can be used in `withMutations`. */ - mergeDeep(...collections: Array | {[key: string]: V}>): this; + mergeDeep(...collections: Array | {[key: string]: V}>): this; /** * Like `mergeDeep()`, but when two non-Collections conflict, it uses the @@ -1318,7 +1318,7 @@ declare module Immutable { */ mergeDeepWith( merger: (oldVal: V, newVal: V, key: K) => V, - ...collections: Array | {[key: string]: V}> + ...collections: Array | {[key: string]: V}> ): this; @@ -1835,8 +1835,8 @@ declare module Immutable { * Note: `union` can be used in `withMutations`. * @alias merge */ - union(...collections: Array | Array>): this; - merge(...collections: Array | Array>): this; + union(...collections: Array>): this; + merge(...collections: Array>): this; /** * Returns a Set which has removed any values not also contained diff --git a/dist/immutable.es.js b/dist/immutable.es.js index 0030d3a08d..001877b482 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -4197,7 +4197,7 @@ var Set = (function (SetCollection$$1) { var newMap = this._map.__ensureOwner(ownerID); if (!ownerID) { if (this.size === 0) { - return emptySet(); + return this.__empty(); } this.__ownerID = ownerID; this._map = newMap; diff --git a/dist/immutable.js b/dist/immutable.js index 59f4a8b969..fece69ba1d 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -4203,7 +4203,7 @@ var Set = (function (SetCollection$$1) { var newMap = this._map.__ensureOwner(ownerID); if (!ownerID) { if (this.size === 0) { - return emptySet(); + return this.__empty(); } this.__ownerID = ownerID; this._map = newMap; diff --git a/dist/immutable.min.js b/dist/immutable.min.js index e07fb6d6fd..9b0141010a 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -27,8 +27,8 @@ return Pt(this,t,e)},e.prototype.remove=function(t){return this.has(t)?0===t?thi Lr.mergeDeepIn=br.mergeDeepIn,Lr.withMutations=br.withMutations,Lr.asMutable=br.asMutable,Lr.asImmutable=br.asImmutable,Lr.wasAltered=br.wasAltered,Lr["@@transducer/init"]=Lr.asMutable,Lr["@@transducer/step"]=function(t,e){return t.push(e)},Lr["@@transducer/result"]=br["@@transducer/result"];var Tr=function(t,e){this.array=t,this.ownerID=e};Tr.prototype.removeBefore=function(t,e,r){if(r===e?1<>>e&je;if(n>=this.array.length)return new Tr([],t);var i,o=0===n;if(e>0){var u=this.array[n];if((i=u&&u.removeBefore(t,e-Ee,r))===u&&o)return this}if(o&&!i)return this;var s=Vt(this,t);if(!o)for(var a=0;a>>e&je;if(n>=this.array.length)return this;var i;if(e>0){var o=this.array[n];if((i=o&&o.removeAfter(t,e-Ee,r))===o&&n===this.array.length-1)return this}var u=Vt(this,t);return u.array.splice(n+1),i&&(u.array[n]=i),u};var Cr,Wr={},Br=function(t){function e(t){return null===t||void 0===t?Zt():Ft(t)?t:Zt().withMutations(function(e){var r=Be(t);yt(r.size),r.forEach(function(t,r){return e.set(r,t)})})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("OrderedMap {","}")},e.prototype.get=function(t,e){var r=this._map.get(t);return void 0!==r?this._list.get(r)[1]:e},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._map.clear(),this._list.clear(),this):Zt()},e.prototype.set=function(t,e){return $t(this,t,e)},e.prototype.remove=function(t){return $t(this,t,ke)},e.prototype.wasAltered=function(){return this._map.wasAltered()||this._list.wasAltered()},e.prototype.__iterate=function(t,e){var r=this;return this._list.__iterate(function(e){return e&&t(e[1],e[0],r)},e)},e.prototype.__iterator=function(t,e){return this._list.fromEntrySeq().__iterator(t,e)}, e.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var e=this._map.__ensureOwner(t),r=this._list.__ensureOwner(t);return t?Gt(e,r,t,this.__hash):0===this.size?Zt():(this.__ownerID=t,this._map=e,this._list=r,this)},e}(Sr);Br.isOrderedMap=Ft,Br.prototype[Te]=!0,Br.prototype.delete=Br.prototype.remove;var Jr,Pr=function(t){function e(t){return null===t||void 0===t?re():te(t)?t:re().pushAll(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("Stack [","]")},e.prototype.get=function(t,e){var r=this._head;for(t=u(this,t);r&&t--;)r=r.next;return r?r.value:e},e.prototype.peek=function(){return this._head&&this._head.value},e.prototype.push=function(){var t=arguments;if(0===arguments.length)return this;for(var e=this.size+arguments.length,r=this._head,n=arguments.length-1;n>=0;n--)r={value:t[n],next:r};return this.__ownerID?(this.size=e,this._head=r,this.__hash=void 0,this.__altered=!0,this):ee(e,r)},e.prototype.pushAll=function(e){if(e=t(e),0===e.size)return this;if(0===this.size&&te(e))return e;yt(e.size);var r=this.size,n=this._head;return e.__iterate(function(t){r++,n={value:t,next:n}},!0),this.__ownerID?(this.size=r,this._head=n,this.__hash=void 0,this.__altered=!0,this):ee(r,n)},e.prototype.pop=function(){return this.slice(1)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):re()},e.prototype.slice=function(e,r){if(a(e,r,this.size))return this;var n=c(e,this.size);if(h(r,this.size)!==this.size)return t.prototype.slice.call(this,e,r);for(var i=this.size-n,o=this._head;n--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):ee(i,o)},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?ee(this.size,this._head,t,this.__hash):0===this.size?re():(this.__ownerID=t,this.__altered=!1,this)}, e.prototype.__iterate=function(t,e){var r=this;if(e)return new rr(this.toArray()).__iterate(function(e,n){return t(e,n,r)},e);for(var n=0,i=this._head;i&&t(i.value,n++,r)!==!1;)i=i.next;return n},e.prototype.__iterator=function(t,e){if(e)return new rr(this.toArray()).__iterator(t,e);var r=0,n=this._head;return new Fe(function(){if(n){var e=n.value;return n=n.next,z(t,r++,e)}return S()})},e}(Je);Pr.isStack=te;var Nr="@@__IMMUTABLE_STACK__@@",Vr=Pr.prototype;Vr[Nr]=!0,Vr.withMutations=br.withMutations,Vr.asMutable=br.asMutable,Vr.asImmutable=br.asImmutable,Vr.wasAltered=br.wasAltered,Vr.shift=Vr.pop,Vr.unshift=Vr.push,Vr.unshiftAll=Vr.pushAll,Vr["@@transducer/init"]=Vr.asMutable,Vr["@@transducer/step"]=function(t,e){return t.unshift(e)},Vr["@@transducer/result"]=br["@@transducer/result"];var Hr,Yr=function(t){function e(e){return null===e||void 0===e?ae():oe(e)&&!g(e)?e:ae().withMutations(function(r){var n=t(e);yt(n.size),n.forEach(function(t){return r.add(t)})})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(Be(t).keySeq())},e.intersect=function(t){return t=We(t).toArray(),t.length?Xr.intersect.apply(e(t.pop()),t):ae()},e.union=function(t){return t=We(t).toArray(),t.length?Xr.union.apply(e(t.pop()),t):ae()},e.prototype.toString=function(){return this.__toString("Set {","}")},e.prototype.has=function(t){return this._map.has(t)},e.prototype.add=function(t){return ue(this,this._map.set(t,t))},e.prototype.remove=function(t){return ue(this,this._map.remove(t))},e.prototype.clear=function(){return ue(this,this._map.clear())},e.prototype.union=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return e=e.filter(function(t){return 0!==t.size}),0===e.length?this:0!==this.size||this.__ownerID||1!==e.length?this.withMutations(function(r){for(var n=0;n0;)e[r]=arguments[r+1];return this.union.apply(this,e)},e.prototype.sort=function(t){return rn(it(this,t))},e.prototype.sortBy=function(t,e){return rn(it(this,e,t))},e.prototype.wasAltered=function(){return this._map.wasAltered()},e.prototype.__iterate=function(t,e){var r=this;return this._map.__iterate(function(e){return t(e,e,r)},e)},e.prototype.__iterator=function(t,e){return this._map.__iterator(t,e)},e.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var e=this._map.__ensureOwner(t);return t?this.__make(e,t):0===this.size?ae():(this.__ownerID=t,this._map=e,this)},e}(Pe);Yr.isSet=oe;var Qr="@@__IMMUTABLE_SET__@@",Xr=Yr.prototype;Xr[Qr]=!0,Xr.delete=Xr.remove,Xr.mergeDeep=Xr.merge,Xr.mergeDeepWith=Xr.mergeWith,Xr.withMutations=br.withMutations,Xr.asMutable=br.asMutable,Xr.asImmutable=br.asImmutable,Xr["@@transducer/init"]=Xr.asMutable,Xr["@@transducer/step"]=function(t,e){return t.add(e)},Xr["@@transducer/result"]=br["@@transducer/result"],Xr.__empty=ae,Xr.__make=se;var Fr,Gr,Zr=function(t){function e(t,r,n){if(!(this instanceof e))return new e(t,r,n);if(vt(0!==n,"Cannot step a Range by 0"),t=t||0,void 0===r&&(r=1/0),n=void 0===n?1:Math.abs(n),r=0&&e=0&&r0;)e[r]=arguments[r+1];return this.union.apply(this,e)},e.prototype.sort=function(t){return rn(it(this,t))},e.prototype.sortBy=function(t,e){return rn(it(this,e,t))},e.prototype.wasAltered=function(){return this._map.wasAltered()},e.prototype.__iterate=function(t,e){var r=this;return this._map.__iterate(function(e){return t(e,e,r)},e)},e.prototype.__iterator=function(t,e){return this._map.__iterator(t,e)},e.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var e=this._map.__ensureOwner(t);return t?this.__make(e,t):0===this.size?this.__empty():(this.__ownerID=t,this._map=e,this)},e}(Pe);Yr.isSet=oe;var Qr="@@__IMMUTABLE_SET__@@",Xr=Yr.prototype;Xr[Qr]=!0,Xr.delete=Xr.remove,Xr.mergeDeep=Xr.merge,Xr.mergeDeepWith=Xr.mergeWith,Xr.withMutations=br.withMutations,Xr.asMutable=br.asMutable,Xr.asImmutable=br.asImmutable,Xr["@@transducer/init"]=Xr.asMutable,Xr["@@transducer/step"]=function(t,e){return t.add(e)},Xr["@@transducer/result"]=br["@@transducer/result"],Xr.__empty=ae,Xr.__make=se;var Fr,Gr,Zr=function(t){function e(t,r,n){if(!(this instanceof e))return new e(t,r,n);if(vt(0!==n,"Cannot step a Range by 0"),t=t||0,void 0===r&&(r=1/0),n=void 0===n?1:Math.abs(n),r=0&&e=0&&rthis.size?e:this.find(function(e,r){return r===t},void 0,e)},has:function(t){return(t=u(this,t))>=0&&(void 0!==this.size?this.size===1/0||t Date: Wed, 4 Oct 2017 23:15:07 +0000 Subject: [PATCH 032/242] Deploy master to NPM branch --- dist/immutable.es.js | 1 + dist/immutable.js | 1 + dist/immutable.min.js | 16 ++++++++-------- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/dist/immutable.es.js b/dist/immutable.es.js index 001877b482..6778144677 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -4142,6 +4142,7 @@ var Set = (function (SetCollection$$1) { if (iters.length === 0) { return this; } + iters = iters.map(function (iter) { return SetCollection$$1(iter); }); var toRemove = []; this.forEach(function (value) { if (iters.some(function (iter) { return iter.includes(value); })) { diff --git a/dist/immutable.js b/dist/immutable.js index fece69ba1d..539cd9ba0d 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -4148,6 +4148,7 @@ var Set = (function (SetCollection$$1) { if (iters.length === 0) { return this; } + iters = iters.map(function (iter) { return SetCollection$$1(iter); }); var toRemove = []; this.forEach(function (value) { if (iters.some(function (iter) { return iter.includes(value); })) { diff --git a/dist/immutable.min.js b/dist/immutable.min.js index 9b0141010a..6f5649d249 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -27,11 +27,11 @@ return Pt(this,t,e)},e.prototype.remove=function(t){return this.has(t)?0===t?thi Lr.mergeDeepIn=br.mergeDeepIn,Lr.withMutations=br.withMutations,Lr.asMutable=br.asMutable,Lr.asImmutable=br.asImmutable,Lr.wasAltered=br.wasAltered,Lr["@@transducer/init"]=Lr.asMutable,Lr["@@transducer/step"]=function(t,e){return t.push(e)},Lr["@@transducer/result"]=br["@@transducer/result"];var Tr=function(t,e){this.array=t,this.ownerID=e};Tr.prototype.removeBefore=function(t,e,r){if(r===e?1<>>e&je;if(n>=this.array.length)return new Tr([],t);var i,o=0===n;if(e>0){var u=this.array[n];if((i=u&&u.removeBefore(t,e-Ee,r))===u&&o)return this}if(o&&!i)return this;var s=Vt(this,t);if(!o)for(var a=0;a>>e&je;if(n>=this.array.length)return this;var i;if(e>0){var o=this.array[n];if((i=o&&o.removeAfter(t,e-Ee,r))===o&&n===this.array.length-1)return this}var u=Vt(this,t);return u.array.splice(n+1),i&&(u.array[n]=i),u};var Cr,Wr={},Br=function(t){function e(t){return null===t||void 0===t?Zt():Ft(t)?t:Zt().withMutations(function(e){var r=Be(t);yt(r.size),r.forEach(function(t,r){return e.set(r,t)})})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("OrderedMap {","}")},e.prototype.get=function(t,e){var r=this._map.get(t);return void 0!==r?this._list.get(r)[1]:e},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._map.clear(),this._list.clear(),this):Zt()},e.prototype.set=function(t,e){return $t(this,t,e)},e.prototype.remove=function(t){return $t(this,t,ke)},e.prototype.wasAltered=function(){return this._map.wasAltered()||this._list.wasAltered()},e.prototype.__iterate=function(t,e){var r=this;return this._list.__iterate(function(e){return e&&t(e[1],e[0],r)},e)},e.prototype.__iterator=function(t,e){return this._list.fromEntrySeq().__iterator(t,e)}, e.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var e=this._map.__ensureOwner(t),r=this._list.__ensureOwner(t);return t?Gt(e,r,t,this.__hash):0===this.size?Zt():(this.__ownerID=t,this._map=e,this._list=r,this)},e}(Sr);Br.isOrderedMap=Ft,Br.prototype[Te]=!0,Br.prototype.delete=Br.prototype.remove;var Jr,Pr=function(t){function e(t){return null===t||void 0===t?re():te(t)?t:re().pushAll(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("Stack [","]")},e.prototype.get=function(t,e){var r=this._head;for(t=u(this,t);r&&t--;)r=r.next;return r?r.value:e},e.prototype.peek=function(){return this._head&&this._head.value},e.prototype.push=function(){var t=arguments;if(0===arguments.length)return this;for(var e=this.size+arguments.length,r=this._head,n=arguments.length-1;n>=0;n--)r={value:t[n],next:r};return this.__ownerID?(this.size=e,this._head=r,this.__hash=void 0,this.__altered=!0,this):ee(e,r)},e.prototype.pushAll=function(e){if(e=t(e),0===e.size)return this;if(0===this.size&&te(e))return e;yt(e.size);var r=this.size,n=this._head;return e.__iterate(function(t){r++,n={value:t,next:n}},!0),this.__ownerID?(this.size=r,this._head=n,this.__hash=void 0,this.__altered=!0,this):ee(r,n)},e.prototype.pop=function(){return this.slice(1)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):re()},e.prototype.slice=function(e,r){if(a(e,r,this.size))return this;var n=c(e,this.size);if(h(r,this.size)!==this.size)return t.prototype.slice.call(this,e,r);for(var i=this.size-n,o=this._head;n--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):ee(i,o)},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?ee(this.size,this._head,t,this.__hash):0===this.size?re():(this.__ownerID=t,this.__altered=!1,this)}, e.prototype.__iterate=function(t,e){var r=this;if(e)return new rr(this.toArray()).__iterate(function(e,n){return t(e,n,r)},e);for(var n=0,i=this._head;i&&t(i.value,n++,r)!==!1;)i=i.next;return n},e.prototype.__iterator=function(t,e){if(e)return new rr(this.toArray()).__iterator(t,e);var r=0,n=this._head;return new Fe(function(){if(n){var e=n.value;return n=n.next,z(t,r++,e)}return S()})},e}(Je);Pr.isStack=te;var Nr="@@__IMMUTABLE_STACK__@@",Vr=Pr.prototype;Vr[Nr]=!0,Vr.withMutations=br.withMutations,Vr.asMutable=br.asMutable,Vr.asImmutable=br.asImmutable,Vr.wasAltered=br.wasAltered,Vr.shift=Vr.pop,Vr.unshift=Vr.push,Vr.unshiftAll=Vr.pushAll,Vr["@@transducer/init"]=Vr.asMutable,Vr["@@transducer/step"]=function(t,e){return t.unshift(e)},Vr["@@transducer/result"]=br["@@transducer/result"];var Hr,Yr=function(t){function e(e){return null===e||void 0===e?ae():oe(e)&&!g(e)?e:ae().withMutations(function(r){var n=t(e);yt(n.size),n.forEach(function(t){return r.add(t)})})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(Be(t).keySeq())},e.intersect=function(t){return t=We(t).toArray(),t.length?Xr.intersect.apply(e(t.pop()),t):ae()},e.union=function(t){return t=We(t).toArray(),t.length?Xr.union.apply(e(t.pop()),t):ae()},e.prototype.toString=function(){return this.__toString("Set {","}")},e.prototype.has=function(t){return this._map.has(t)},e.prototype.add=function(t){return ue(this,this._map.set(t,t))},e.prototype.remove=function(t){return ue(this,this._map.remove(t))},e.prototype.clear=function(){return ue(this,this._map.clear())},e.prototype.union=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return e=e.filter(function(t){return 0!==t.size}),0===e.length?this:0!==this.size||this.__ownerID||1!==e.length?this.withMutations(function(r){for(var n=0;n0;)e[r]=arguments[r+1];return this.union.apply(this,e)},e.prototype.sort=function(t){return rn(it(this,t))},e.prototype.sortBy=function(t,e){return rn(it(this,e,t))},e.prototype.wasAltered=function(){return this._map.wasAltered()},e.prototype.__iterate=function(t,e){var r=this;return this._map.__iterate(function(e){return t(e,e,r)},e)},e.prototype.__iterator=function(t,e){return this._map.__iterator(t,e)},e.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var e=this._map.__ensureOwner(t);return t?this.__make(e,t):0===this.size?this.__empty():(this.__ownerID=t,this._map=e,this)},e}(Pe);Yr.isSet=oe;var Qr="@@__IMMUTABLE_SET__@@",Xr=Yr.prototype;Xr[Qr]=!0,Xr.delete=Xr.remove,Xr.mergeDeep=Xr.merge,Xr.mergeDeepWith=Xr.mergeWith,Xr.withMutations=br.withMutations,Xr.asMutable=br.asMutable,Xr.asImmutable=br.asImmutable,Xr["@@transducer/init"]=Xr.asMutable,Xr["@@transducer/step"]=function(t,e){return t.add(e)},Xr["@@transducer/result"]=br["@@transducer/result"],Xr.__empty=ae,Xr.__make=se;var Fr,Gr,Zr=function(t){function e(t,r,n){if(!(this instanceof e))return new e(t,r,n);if(vt(0!==n,"Cannot step a Range by 0"),t=t||0,void 0===r&&(r=1/0),n=void 0===n?1:Math.abs(n),r=0&&e=0&&rthis.size?e:this.find(function(e,r){return r===t},void 0,e)},has:function(t){return(t=u(this,t))>=0&&(void 0!==this.size?this.size===1/0||t0;)e[r]=arguments[r+1];return this.union.apply(this,e)},e.prototype.sort=function(t){return rn(it(this,t))},e.prototype.sortBy=function(t,e){return rn(it(this,e,t))},e.prototype.wasAltered=function(){return this._map.wasAltered()},e.prototype.__iterate=function(t,e){var r=this;return this._map.__iterate(function(e){return t(e,e,r)},e)},e.prototype.__iterator=function(t,e){return this._map.__iterator(t,e)},e.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var e=this._map.__ensureOwner(t);return t?this.__make(e,t):0===this.size?this.__empty():(this.__ownerID=t,this._map=e,this)},e}(Pe);Yr.isSet=oe;var Qr="@@__IMMUTABLE_SET__@@",Xr=Yr.prototype;Xr[Qr]=!0,Xr.delete=Xr.remove,Xr.mergeDeep=Xr.merge,Xr.mergeDeepWith=Xr.mergeWith,Xr.withMutations=br.withMutations,Xr.asMutable=br.asMutable,Xr.asImmutable=br.asImmutable,Xr["@@transducer/init"]=Xr.asMutable,Xr["@@transducer/step"]=function(t,e){return t.add(e)},Xr["@@transducer/result"]=br["@@transducer/result"],Xr.__empty=ae,Xr.__make=se;var Fr,Gr,Zr=function(t){function e(t,r,n){if(!(this instanceof e))return new e(t,r,n);if(vt(0!==n,"Cannot step a Range by 0"),t=t||0,void 0===r&&(r=1/0),n=void 0===n?1:Math.abs(n),r=0&&e=0&&rthis.size?e:this.find(function(e,r){return r===t},void 0,e)},has:function(t){return(t=u(this,t))>=0&&(void 0!==this.size?this.size===1/0||t Date: Wed, 4 Oct 2017 23:22:20 +0000 Subject: [PATCH 033/242] Deploy master to NPM branch --- dist/immutable.es.js | 1 - dist/immutable.js | 1 - dist/immutable.min.js | 16 ++++++++-------- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/dist/immutable.es.js b/dist/immutable.es.js index 6778144677..001877b482 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -4142,7 +4142,6 @@ var Set = (function (SetCollection$$1) { if (iters.length === 0) { return this; } - iters = iters.map(function (iter) { return SetCollection$$1(iter); }); var toRemove = []; this.forEach(function (value) { if (iters.some(function (iter) { return iter.includes(value); })) { diff --git a/dist/immutable.js b/dist/immutable.js index 539cd9ba0d..fece69ba1d 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -4148,7 +4148,6 @@ var Set = (function (SetCollection$$1) { if (iters.length === 0) { return this; } - iters = iters.map(function (iter) { return SetCollection$$1(iter); }); var toRemove = []; this.forEach(function (value) { if (iters.some(function (iter) { return iter.includes(value); })) { diff --git a/dist/immutable.min.js b/dist/immutable.min.js index 6f5649d249..9b0141010a 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -27,11 +27,11 @@ return Pt(this,t,e)},e.prototype.remove=function(t){return this.has(t)?0===t?thi Lr.mergeDeepIn=br.mergeDeepIn,Lr.withMutations=br.withMutations,Lr.asMutable=br.asMutable,Lr.asImmutable=br.asImmutable,Lr.wasAltered=br.wasAltered,Lr["@@transducer/init"]=Lr.asMutable,Lr["@@transducer/step"]=function(t,e){return t.push(e)},Lr["@@transducer/result"]=br["@@transducer/result"];var Tr=function(t,e){this.array=t,this.ownerID=e};Tr.prototype.removeBefore=function(t,e,r){if(r===e?1<>>e&je;if(n>=this.array.length)return new Tr([],t);var i,o=0===n;if(e>0){var u=this.array[n];if((i=u&&u.removeBefore(t,e-Ee,r))===u&&o)return this}if(o&&!i)return this;var s=Vt(this,t);if(!o)for(var a=0;a>>e&je;if(n>=this.array.length)return this;var i;if(e>0){var o=this.array[n];if((i=o&&o.removeAfter(t,e-Ee,r))===o&&n===this.array.length-1)return this}var u=Vt(this,t);return u.array.splice(n+1),i&&(u.array[n]=i),u};var Cr,Wr={},Br=function(t){function e(t){return null===t||void 0===t?Zt():Ft(t)?t:Zt().withMutations(function(e){var r=Be(t);yt(r.size),r.forEach(function(t,r){return e.set(r,t)})})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("OrderedMap {","}")},e.prototype.get=function(t,e){var r=this._map.get(t);return void 0!==r?this._list.get(r)[1]:e},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._map.clear(),this._list.clear(),this):Zt()},e.prototype.set=function(t,e){return $t(this,t,e)},e.prototype.remove=function(t){return $t(this,t,ke)},e.prototype.wasAltered=function(){return this._map.wasAltered()||this._list.wasAltered()},e.prototype.__iterate=function(t,e){var r=this;return this._list.__iterate(function(e){return e&&t(e[1],e[0],r)},e)},e.prototype.__iterator=function(t,e){return this._list.fromEntrySeq().__iterator(t,e)}, e.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var e=this._map.__ensureOwner(t),r=this._list.__ensureOwner(t);return t?Gt(e,r,t,this.__hash):0===this.size?Zt():(this.__ownerID=t,this._map=e,this._list=r,this)},e}(Sr);Br.isOrderedMap=Ft,Br.prototype[Te]=!0,Br.prototype.delete=Br.prototype.remove;var Jr,Pr=function(t){function e(t){return null===t||void 0===t?re():te(t)?t:re().pushAll(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("Stack [","]")},e.prototype.get=function(t,e){var r=this._head;for(t=u(this,t);r&&t--;)r=r.next;return r?r.value:e},e.prototype.peek=function(){return this._head&&this._head.value},e.prototype.push=function(){var t=arguments;if(0===arguments.length)return this;for(var e=this.size+arguments.length,r=this._head,n=arguments.length-1;n>=0;n--)r={value:t[n],next:r};return this.__ownerID?(this.size=e,this._head=r,this.__hash=void 0,this.__altered=!0,this):ee(e,r)},e.prototype.pushAll=function(e){if(e=t(e),0===e.size)return this;if(0===this.size&&te(e))return e;yt(e.size);var r=this.size,n=this._head;return e.__iterate(function(t){r++,n={value:t,next:n}},!0),this.__ownerID?(this.size=r,this._head=n,this.__hash=void 0,this.__altered=!0,this):ee(r,n)},e.prototype.pop=function(){return this.slice(1)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):re()},e.prototype.slice=function(e,r){if(a(e,r,this.size))return this;var n=c(e,this.size);if(h(r,this.size)!==this.size)return t.prototype.slice.call(this,e,r);for(var i=this.size-n,o=this._head;n--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):ee(i,o)},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?ee(this.size,this._head,t,this.__hash):0===this.size?re():(this.__ownerID=t,this.__altered=!1,this)}, e.prototype.__iterate=function(t,e){var r=this;if(e)return new rr(this.toArray()).__iterate(function(e,n){return t(e,n,r)},e);for(var n=0,i=this._head;i&&t(i.value,n++,r)!==!1;)i=i.next;return n},e.prototype.__iterator=function(t,e){if(e)return new rr(this.toArray()).__iterator(t,e);var r=0,n=this._head;return new Fe(function(){if(n){var e=n.value;return n=n.next,z(t,r++,e)}return S()})},e}(Je);Pr.isStack=te;var Nr="@@__IMMUTABLE_STACK__@@",Vr=Pr.prototype;Vr[Nr]=!0,Vr.withMutations=br.withMutations,Vr.asMutable=br.asMutable,Vr.asImmutable=br.asImmutable,Vr.wasAltered=br.wasAltered,Vr.shift=Vr.pop,Vr.unshift=Vr.push,Vr.unshiftAll=Vr.pushAll,Vr["@@transducer/init"]=Vr.asMutable,Vr["@@transducer/step"]=function(t,e){return t.unshift(e)},Vr["@@transducer/result"]=br["@@transducer/result"];var Hr,Yr=function(t){function e(e){return null===e||void 0===e?ae():oe(e)&&!g(e)?e:ae().withMutations(function(r){var n=t(e);yt(n.size),n.forEach(function(t){return r.add(t)})})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(Be(t).keySeq())},e.intersect=function(t){return t=We(t).toArray(),t.length?Xr.intersect.apply(e(t.pop()),t):ae()},e.union=function(t){return t=We(t).toArray(),t.length?Xr.union.apply(e(t.pop()),t):ae()},e.prototype.toString=function(){return this.__toString("Set {","}")},e.prototype.has=function(t){return this._map.has(t)},e.prototype.add=function(t){return ue(this,this._map.set(t,t))},e.prototype.remove=function(t){return ue(this,this._map.remove(t))},e.prototype.clear=function(){return ue(this,this._map.clear())},e.prototype.union=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return e=e.filter(function(t){return 0!==t.size}),0===e.length?this:0!==this.size||this.__ownerID||1!==e.length?this.withMutations(function(r){for(var n=0;n0;)e[r]=arguments[r+1];return this.union.apply(this,e)},e.prototype.sort=function(t){return rn(it(this,t))},e.prototype.sortBy=function(t,e){return rn(it(this,e,t))},e.prototype.wasAltered=function(){return this._map.wasAltered()},e.prototype.__iterate=function(t,e){var r=this;return this._map.__iterate(function(e){return t(e,e,r)},e)},e.prototype.__iterator=function(t,e){return this._map.__iterator(t,e)},e.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var e=this._map.__ensureOwner(t);return t?this.__make(e,t):0===this.size?this.__empty():(this.__ownerID=t,this._map=e,this)},e}(Pe);Yr.isSet=oe;var Qr="@@__IMMUTABLE_SET__@@",Xr=Yr.prototype;Xr[Qr]=!0,Xr.delete=Xr.remove,Xr.mergeDeep=Xr.merge,Xr.mergeDeepWith=Xr.mergeWith,Xr.withMutations=br.withMutations,Xr.asMutable=br.asMutable,Xr.asImmutable=br.asImmutable,Xr["@@transducer/init"]=Xr.asMutable,Xr["@@transducer/step"]=function(t,e){return t.add(e)},Xr["@@transducer/result"]=br["@@transducer/result"],Xr.__empty=ae,Xr.__make=se;var Fr,Gr,Zr=function(t){function e(t,r,n){if(!(this instanceof e))return new e(t,r,n);if(vt(0!==n,"Cannot step a Range by 0"),t=t||0,void 0===r&&(r=1/0),n=void 0===n?1:Math.abs(n),r=0&&e=0&&rthis.size?e:this.find(function(e,r){return r===t},void 0,e)},has:function(t){return(t=u(this,t))>=0&&(void 0!==this.size?this.size===1/0||t0;)e[r]=arguments[r+1];return this.union.apply(this,e)},e.prototype.sort=function(t){return rn(it(this,t))},e.prototype.sortBy=function(t,e){return rn(it(this,e,t))},e.prototype.wasAltered=function(){return this._map.wasAltered()},e.prototype.__iterate=function(t,e){var r=this;return this._map.__iterate(function(e){return t(e,e,r)},e)},e.prototype.__iterator=function(t,e){return this._map.__iterator(t,e)},e.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var e=this._map.__ensureOwner(t);return t?this.__make(e,t):0===this.size?this.__empty():(this.__ownerID=t,this._map=e,this)},e}(Pe);Yr.isSet=oe;var Qr="@@__IMMUTABLE_SET__@@",Xr=Yr.prototype;Xr[Qr]=!0,Xr.delete=Xr.remove,Xr.mergeDeep=Xr.merge,Xr.mergeDeepWith=Xr.mergeWith,Xr.withMutations=br.withMutations,Xr.asMutable=br.asMutable,Xr.asImmutable=br.asImmutable,Xr["@@transducer/init"]=Xr.asMutable,Xr["@@transducer/step"]=function(t,e){return t.add(e)},Xr["@@transducer/result"]=br["@@transducer/result"],Xr.__empty=ae,Xr.__make=se;var Fr,Gr,Zr=function(t){function e(t,r,n){if(!(this instanceof e))return new e(t,r,n);if(vt(0!==n,"Cannot step a Range by 0"),t=t||0,void 0===r&&(r=1/0),n=void 0===n?1:Math.abs(n),r=0&&e=0&&rthis.size?e:this.find(function(e,r){return r===t},void 0,e)},has:function(t){return(t=u(this,t))>=0&&(void 0!==this.size?this.size===1/0||t Date: Thu, 5 Oct 2017 01:19:15 +0000 Subject: [PATCH 034/242] Deploy master to NPM branch --- dist/immutable.es.js | 7 ++++++- dist/immutable.js | 7 ++++++- dist/immutable.min.js | 40 ++++++++++++++++++++-------------------- 3 files changed, 32 insertions(+), 22 deletions(-) diff --git a/dist/immutable.es.js b/dist/immutable.es.js index 001877b482..f0249da440 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -1943,7 +1943,11 @@ function assertNotInfinite(size) { * Converts a value to a string, adding quotes if a string was provided. */ function quoteString(value) { - return typeof value === 'string' ? JSON.stringify(value) : String(value); + try { + return typeof value === 'string' ? JSON.stringify(value) : String(value); + } catch (_ignoreError) { + return JSON.stringify(value); + } } var Map = (function (KeyedCollection$$1) { @@ -4142,6 +4146,7 @@ var Set = (function (SetCollection$$1) { if (iters.length === 0) { return this; } + iters = iters.map(function (iter) { return SetCollection$$1(iter); }); var toRemove = []; this.forEach(function (value) { if (iters.some(function (iter) { return iter.includes(value); })) { diff --git a/dist/immutable.js b/dist/immutable.js index fece69ba1d..b6e28a54b1 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -1949,7 +1949,11 @@ function assertNotInfinite(size) { * Converts a value to a string, adding quotes if a string was provided. */ function quoteString(value) { - return typeof value === 'string' ? JSON.stringify(value) : String(value); + try { + return typeof value === 'string' ? JSON.stringify(value) : String(value); + } catch (_ignoreError) { + return JSON.stringify(value); + } } var Map = (function (KeyedCollection$$1) { @@ -4148,6 +4152,7 @@ var Set = (function (SetCollection$$1) { if (iters.length === 0) { return this; } + iters = iters.map(function (iter) { return SetCollection$$1(iter); }); var toRemove = []; this.forEach(function (value) { if (iters.some(function (iter) { return iter.includes(value); })) { diff --git a/dist/immutable.min.js b/dist/immutable.min.js index 9b0141010a..21a6a21156 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -5,17 +5,17 @@ * LICENSE file in the root directory of this source tree. */ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.Immutable=t.Immutable||{})}(this,function(t){"use strict";function e(t){return t.value=!1,t}function r(t){t&&(t.value=!0)}function n(){}function i(t,e){e=e||0;for(var r=Math.max(0,t.length-e),n=Array(r),i=0;i>>0;if(""+r!==e||4294967295===r)return NaN;e=r}return e<0?o(t)+e:e}function s(){return!0}function a(t,e,r){return(0===t&&!p(t)||void 0!==r&&t<=-r)&&(void 0===e||void 0!==r&&e>=r)}function c(t,e){return f(t,e,0)}function h(t,e){return f(t,e,e)}function f(t,e,r){return void 0===t?r:p(t)?e===1/0?e:0|Math.max(0,e+t):void 0===e||e===t?t:0|Math.min(e,t)}function p(t){return t<0||0===t&&1/t==-(1/0)}function _(t){return(l(t)||m(t))&&!t.__ownerID}function l(t){return!(!t||!t[Ue])}function v(t){return!(!t||!t[Ke])}function y(t){return!(!t||!t[Le])}function d(t){return v(t)||y(t)}function g(t){return!(!t||!t[Te])}function m(t){return!(!t||!t[Ce])}function w(t){return!(!t||"function"!=typeof t.equals||"function"!=typeof t.hashCode)}function z(t,e,r,n){var i=0===t?e:1===t?r:[e,r];return n?n.value=i:n={value:i,done:!1},n}function S(){return{value:void 0,done:!0}}function I(t){return!!M(t)}function b(t){return t&&"function"==typeof t.next}function O(t){var e=M(t);return e&&e.call(t)}function M(t){var e=t&&(Ye&&t[Ye]||t[Qe]);if("function"==typeof e)return e}function D(t){return t&&"number"==typeof t.length}function q(t){return!(!t||!t[er])}function E(){return ir||(ir=new rr([]))}function x(t){var e=Array.isArray(t)?new rr(t):b(t)?new sr(t):I(t)?new ur(t):void 0;if(e)return e.fromEntrySeq();if("object"==typeof t)return new nr(t);throw new TypeError("Expected Array or collection object of [k, v] entries, or keyed object: "+t)}function j(t){var e=A(t);if(e)return e;throw new TypeError("Expected Array or collection object of values: "+t)} -function k(t){var e=A(t);if(e)return e;if("object"==typeof t)return new nr(t);throw new TypeError("Expected Array or collection object of values, or keyed object: "+t)}function A(t){return D(t)?new rr(t):b(t)?new sr(t):I(t)?new ur(t):void 0}function R(t,e){if(t===e||t!==t&&e!==e)return!0;if(!t||!e)return!1;if("function"==typeof t.valueOf&&"function"==typeof e.valueOf){if(t=t.valueOf(),e=e.valueOf(),t===e||t!==t&&e!==e)return!0;if(!t||!e)return!1}return!!(w(t)&&w(e)&&t.equals(e))}function U(t,e){return K([],e||L,t,"",e&&e.length>2?[]:void 0,{"":t})}function K(t,e,r,n,i,o){var u=Array.isArray(r)?$e:T(r)?Ze:null;if(u){if(~t.indexOf(r))throw new TypeError("Cannot convert circular structure to Immutable");t.push(r),i&&""!==n&&i.push(n);var s=e.call(o,n,u(r).map(function(n,o){return K(t,e,n,o,i,r)}),i&&i.slice());return t.pop(),i&&i.pop(),s}return r}function L(t,e){return v(e)?e.toMap():e.toList()}function T(t){return t&&(t.constructor===Object||void 0===t.constructor)}function C(t){return t>>>1&1073741824|3221225471&t}function W(t){if(t===!1||null===t||void 0===t)return 0;if("function"==typeof t.valueOf&&((t=t.valueOf())===!1||null===t||void 0===t))return 0;if(t===!0)return 1;var e=typeof t;if("number"===e){if(t!==t||t===1/0)return 0;var r=0|t;for(r!==t&&(r^=4294967295*t);t>4294967295;)t/=4294967295,r^=t;return C(r)}if("string"===e)return t.length>lr?B(t):J(t);if("function"==typeof t.hashCode)return C(t.hashCode());if("object"===e)return P(t);if("function"==typeof t.toString)return J(""+t);throw Error("Value type "+e+" cannot be hashed.")}function B(t){var e=dr[t];return void 0===e&&(e=J(t),yr===vr&&(yr=0,dr={}),yr++,dr[t]=e),e}function J(t){for(var e=0,r=0;r0)switch(t.nodeType){case 1:return t.uniqueID;case 9:return t.documentElement&&t.documentElement.uniqueID}}function V(t){var e=ft(t);return e._iter=t,e.size=t.size,e.flip=function(){return t},e.reverse=function(){var e=t.reverse.apply(this);return e.flip=function(){return t.reverse()},e},e.has=function(e){return t.includes(e)},e.includes=function(e){return t.has(e)},e.cacheResult=pt,e.__iterateUncached=function(e,r){var n=this;return t.__iterate(function(t,r){return e(r,t,n)!==!1},r)},e.__iteratorUncached=function(e,r){if(e===He){var n=t.__iterator(e,r);return new Fe(function(){var t=n.next();if(!t.done){var e=t.value[0];t.value[0]=t.value[1],t.value[1]=e}return t})}return t.__iterator(e===Ve?Ne:Ve,r)},e}function H(t,e,r){var n=ft(t);return n.size=t.size,n.has=function(e){return t.has(e)},n.get=function(n,i){var o=t.get(n,ke);return o===ke?i:e.call(r,o,n,t)},n.__iterateUncached=function(n,i){var o=this;return t.__iterate(function(t,i,u){return n(e.call(r,t,i,u),i,o)!==!1},i)},n.__iteratorUncached=function(n,i){var o=t.__iterator(He,i);return new Fe(function(){var i=o.next();if(i.done)return i;var u=i.value,s=u[0];return z(n,s,e.call(r,u[1],s,t),i)})},n}function Y(t,e){var r=this,n=ft(t);return n._iter=t,n.size=t.size,n.reverse=function(){return t},t.flip&&(n.flip=function(){var e=V(t);return e.reverse=function(){return t.flip()},e}),n.get=function(r,n){return t.get(e?r:-1-r,n)},n.has=function(r){return t.has(e?r:-1-r)},n.includes=function(e){ +function k(t){var e=A(t);if(e)return e;if("object"==typeof t)return new nr(t);throw new TypeError("Expected Array or collection object of values, or keyed object: "+t)}function A(t){return D(t)?new rr(t):b(t)?new sr(t):I(t)?new ur(t):void 0}function R(t,e){if(t===e||t!==t&&e!==e)return!0;if(!t||!e)return!1;if("function"==typeof t.valueOf&&"function"==typeof e.valueOf){if(t=t.valueOf(),e=e.valueOf(),t===e||t!==t&&e!==e)return!0;if(!t||!e)return!1}return!!(w(t)&&w(e)&&t.equals(e))}function U(t,e){return K([],e||L,t,"",e&&e.length>2?[]:void 0,{"":t})}function K(t,e,r,n,i,o){var u=Array.isArray(r)?$e:T(r)?Ze:null;if(u){if(~t.indexOf(r))throw new TypeError("Cannot convert circular structure to Immutable");t.push(r),i&&""!==n&&i.push(n);var s=e.call(o,n,u(r).map(function(n,o){return K(t,e,n,o,i,r)}),i&&i.slice());return t.pop(),i&&i.pop(),s}return r}function L(t,e){return v(e)?e.toMap():e.toList()}function T(t){return t&&(t.constructor===Object||void 0===t.constructor)}function C(t){return t>>>1&1073741824|3221225471&t}function W(t){if(t===!1||null===t||void 0===t)return 0;if("function"==typeof t.valueOf&&((t=t.valueOf())===!1||null===t||void 0===t))return 0;if(t===!0)return 1;var e=typeof t;if("number"===e){if(t!==t||t===1/0)return 0;var r=0|t;for(r!==t&&(r^=4294967295*t);t>4294967295;)t/=4294967295,r^=t;return C(r)}if("string"===e)return t.length>lr?B(t):J(t);if("function"==typeof t.hashCode)return C(t.hashCode());if("object"===e)return N(t);if("function"==typeof t.toString)return J(""+t);throw Error("Value type "+e+" cannot be hashed.")}function B(t){var e=dr[t];return void 0===e&&(e=J(t),yr===vr&&(yr=0,dr={}),yr++,dr[t]=e),e}function J(t){for(var e=0,r=0;r0)switch(t.nodeType){case 1:return t.uniqueID;case 9:return t.documentElement&&t.documentElement.uniqueID}}function V(t){var e=ft(t);return e._iter=t,e.size=t.size,e.flip=function(){return t},e.reverse=function(){var e=t.reverse.apply(this);return e.flip=function(){return t.reverse()},e},e.has=function(e){return t.includes(e)},e.includes=function(e){return t.has(e)},e.cacheResult=pt,e.__iterateUncached=function(e,r){var n=this;return t.__iterate(function(t,r){return e(r,t,n)!==!1},r)},e.__iteratorUncached=function(e,r){if(e===He){var n=t.__iterator(e,r);return new Fe(function(){var t=n.next();if(!t.done){var e=t.value[0];t.value[0]=t.value[1],t.value[1]=e}return t})}return t.__iterator(e===Ve?Pe:Ve,r)},e}function H(t,e,r){var n=ft(t);return n.size=t.size,n.has=function(e){return t.has(e)},n.get=function(n,i){var o=t.get(n,ke);return o===ke?i:e.call(r,o,n,t)},n.__iterateUncached=function(n,i){var o=this;return t.__iterate(function(t,i,u){return n(e.call(r,t,i,u),i,o)!==!1},i)},n.__iteratorUncached=function(n,i){var o=t.__iterator(He,i);return new Fe(function(){var i=o.next();if(i.done)return i;var u=i.value,s=u[0];return z(n,s,e.call(r,u[1],s,t),i)})},n}function Y(t,e){var r=this,n=ft(t);return n._iter=t,n.size=t.size,n.reverse=function(){return t},t.flip&&(n.flip=function(){var e=V(t);return e.reverse=function(){return t.flip()},e}),n.get=function(r,n){return t.get(e?r:-1-r,n)},n.has=function(r){return t.has(e?r:-1-r)},n.includes=function(e){ return t.includes(e)},n.cacheResult=pt,n.__iterate=function(r,n){var i=this,u=0;return n&&o(t),t.__iterate(function(t,o){return r(t,e?o:n?i.size-++u:u++,i)},!n)},n.__iterator=function(n,i){var u=0;i&&o(t);var s=t.__iterator(He,!i);return new Fe(function(){var t=s.next();if(t.done)return t;var o=t.value;return z(n,e?o[0]:i?r.size-++u:u++,o[1],t)})},n}function Q(t,e,r,n){var i=ft(t);return n&&(i.has=function(n){var i=t.get(n,ke);return i!==ke&&!!e.call(r,i,n,t)},i.get=function(n,i){var o=t.get(n,ke);return o!==ke&&e.call(r,o,n,t)?o:i}),i.__iterateUncached=function(i,o){var u=this,s=0;return t.__iterate(function(t,o,a){if(e.call(r,t,o,a))return s++,i(t,n?o:s-1,u)},o),s},i.__iteratorUncached=function(i,o){var u=t.__iterator(He,o),s=0;return new Fe(function(){for(;;){var o=u.next();if(o.done)return o;var a=o.value,c=a[0],h=a[1];if(e.call(r,h,c,t))return z(i,n?c:s++,h,o)}})},i}function X(t,e,r){var n=Sr().asMutable();return t.__iterate(function(i,o){n.update(e.call(r,i,o,t),0,function(t){return t+1})}),n.asImmutable()}function F(t,e,r){var n=v(t),i=(g(t)?Br():Sr()).asMutable();t.__iterate(function(o,u){i.update(e.call(r,o,u,t),function(t){return t=t||[],t.push(n?[u,o]:o),t})});var o=ht(t);return i.map(function(e){return at(t,o(e))})}function G(t,e,r,n){var i=t.size;if(a(e,r,i))return t;var o=c(e,i),s=h(r,i);if(o!==o||s!==s)return G(t.toSeq().cacheResult(),e,r,n);var f,p=s-o;p===p&&(f=p<0?0:p);var _=ft(t);return _.size=0===f?f:t.size&&f||void 0,!n&&q(t)&&f>=0&&(_.get=function(e,r){return e=u(this,e),e>=0&&ef)return S();var t=i.next() -;return n||e===Ve||t.done?t:e===Ne?z(e,s-1,void 0,t):z(e,s-1,t.value[1],t)})},_}function Z(t,e,r){var n=ft(t);return n.__iterateUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterate(n,i);var u=0;return t.__iterate(function(t,i,s){return e.call(r,t,i,s)&&++u&&n(t,i,o)}),u},n.__iteratorUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterator(n,i);var u=t.__iterator(He,i),s=!0;return new Fe(function(){if(!s)return S();var t=u.next();if(t.done)return t;var i=t.value,a=i[0],c=i[1];return e.call(r,c,a,o)?n===He?t:z(n,a,c,t):(s=!1,S())})},n}function $(t,e,r,n){var i=ft(t);return i.__iterateUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterate(i,o);var s=!0,a=0;return t.__iterate(function(t,o,c){if(!s||!(s=e.call(r,t,o,c)))return a++,i(t,n?o:a-1,u)}),a},i.__iteratorUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterator(i,o);var s=t.__iterator(He,o),a=!0,c=0;return new Fe(function(){var t,o,h;do{if(t=s.next(),t.done)return n||i===Ve?t:i===Ne?z(i,c++,void 0,t):z(i,c++,t.value[1],t);var f=t.value;o=f[0],h=f[1],a&&(a=e.call(r,h,o,u))}while(a);return i===He?t:z(i,o,h,t)})},i}function tt(t,e){var r=v(t),n=[t].concat(e).map(function(t){return l(t)?r&&(t=Be(t)):t=r?x(t):j(Array.isArray(t)?t:[t]),t}).filter(function(t){return 0!==t.size});if(0===n.length)return t;if(1===n.length){var i=n[0];if(i===t||r&&v(i)||y(t)&&y(i))return i}var o=new rr(n);return r?o=o.toKeyedSeq():y(t)||(o=o.toSetSeq()),o=o.flatten(!0),o.size=n.reduce(function(t,e){if(void 0!==t){var r=e.size;if(void 0!==r)return t+r}},0),o}function et(t,e,r){var n=ft(t);return n.__iterateUncached=function(i,o){function u(t,c){t.__iterate(function(t,o){return(!e||c0}function st(t,e,r,n){var i=ft(t),o=new rr(r).map(function(t){return t.size});return i.size=n?o.max():o.min(),i.__iterate=function(t,e){for(var r,n=this,i=this.__iterator(Ve,e),o=0;!(r=i.next()).done&&t(r.value,o++,n)!==!1;);return o},i.__iteratorUncached=function(t,i){var o=r.map(function(t){return t=We(t),O(i?t.reverse():t)}),u=0,s=!1;return new Fe(function(){var r;return s||(r=o.map(function(t){return t.next()}),s=n?r.every(function(t){return t.done}):r.some(function(t){return t.done})),s?S():z(t,u++,e.apply(null,r.map(function(t){return t.value})))})},i}function at(t,e){return t===e?t:q(t)?e:t.constructor(e)}function ct(t){if(t!==Object(t))throw new TypeError("Expected [K, V] tuple: "+t)}function ht(t){return v(t)?Be:y(t)?Je:Pe}function ft(t){return Object.create((v(t)?Ze:y(t)?$e:tr).prototype)}function pt(){return this._iter.cacheResult?(this._iter.cacheResult(), -this.size=this._iter.size,this):Ge.prototype.cacheResult.call(this)}function _t(t,e){return void 0===t&&void 0===e?0:void 0===t?1:void 0===e?-1:t>e?1:t>>r)&je,s=(0===r?n:n>>>r)&je;return new Mr(e,1<>>=1)u[s]=1&r?e[o++]:void 0;return u[n]=i,new Dr(t,o+1,u)}function xt(t,e,r){for(var n=[],i=0;i>1&1431655765,t=(858993459&t)+(t>>2&858993459),t=t+(t>>4)&252645135,t+=t>>8,127&(t+=t>>16)}function Kt(t,e,r,n){var o=n?t:i(t);return o[e]=r,o}function Lt(t,e,r,n){var i=t.length+1;if(n&&e+1===i)return t[e]=r,t;for(var o=Array(i),u=0,s=0;so?0:o-r,c=u-r;return c>xe&&(c=xe),function(){if(i===c)return Wr;var t=e?--c:i++;return n&&n[t]}}function i(t,n,i){var s,a=t&&t.array,c=i>o?0:o-i>>n,h=1+(u-i>>n);return h>xe&&(h=xe),function(){for(;;){if(s){var t=s();if(t!==Wr)return t;s=null}if(c===h)return Wr;var o=e?--h:c++;s=r(a&&a[o],n-Ee,i+(o<=t.size||r<0)return t.withMutations(function(t){r<0?Yt(t,r).set(0,n):Yt(t,0,r+1).set(r,n)});r+=t._origin;var i=t._tail,o=t._root,s=e(Re);return r>=Xt(t._capacity)?i=Nt(i,t.__ownerID,0,r,n,s):o=Nt(o,t.__ownerID,t._level,r,n,s),s.value?t.__ownerID?(t._root=o,t._tail=i,t.__hash=void 0,t.__altered=!0,t):Bt(t._origin,t._capacity,t._level,o,i):t}function Nt(t,e,n,i,o,u){var s=i>>>n&je,a=t&&s0){var h=t&&t.array[s],f=Nt(h,e,n-Ee,i,o,u);return f===h?t:(c=Vt(t,e),c.array[s]=f,c)}return a&&t.array[s]===o?t:(r(u),c=Vt(t,e),void 0===o&&s===c.array.length-1?c.array.pop():c.array[s]=o,c)}function Vt(t,e){return e&&t&&e===t.ownerID?t:new Tr(t?t.array.slice():[],e)}function Ht(t,e){if(e>=Xt(t._capacity))return t._tail;if(e<1<0;)r=r.array[e>>>n&je],n-=Ee;return r}}function Yt(t,e,r){void 0!==e&&(e|=0),void 0!==r&&(r|=0);var i=t.__ownerID||new n,o=t._origin,u=t._capacity,s=o+e,a=void 0===r?u:r<0?u+r:o+r;if(s===o&&a===u)return t;if(s>=a)return t.clear();for(var c=t._level,h=t._root,f=0;s+f<0;)h=new Tr(h&&h.array.length?[void 0,h]:[],i),c+=Ee,f+=1<=1<p?new Tr([],i):l;if(l&&_>p&&sEe;d-=Ee){var g=p>>>d&je;y=y.array[g]=Vt(y.array[g],i)}y.array[p>>>Ee&je]=l}if(a=_)s-=_,a-=_,c=Ee,h=null,v=v&&v.removeBefore(i,0,s);else if(s>o||_>>c&je;if(m!==_>>>c&je)break;m&&(f+=(1<o&&(h=h.removeBefore(i,c,s-f)),h&&_i&&(i=s.size),l(u)||(s=s.map(function(t){return U(t)})),n.push(s)} -return i>t.size&&(t=t.setSize(i)),At(t,e,n)}function Xt(t){return t>>Ee<=xe&&u.size>=2*o.size?(i=u.filter(function(t,e){return void 0!==t&&s!==e}),n=i.toKeyedSeq().map(function(t){return t[0]}).flip().toMap(),t.__ownerID&&(n.__ownerID=i.__ownerID=t.__ownerID)):(n=o.remove(e),i=s===u.size-1?u.pop():u.set(s,void 0))}else if(a){if(r===u.get(s)[1])return t;n=o,i=u.set(s,[e,r])}else n=o.set(e,u.size),i=u.set(u.size,[e,r]);return t.__ownerID?(t.size=n.size,t._map=n,t._list=i,t.__hash=void 0,t):Gt(n,i)}function te(t){return!(!t||!t[Nr])}function ee(t,e,r,n){var i=Object.create(Vr);return i.size=t,i._head=e,i.__ownerID=r,i.__hash=n,i.__altered=!1,i}function re(){return Hr||(Hr=ee(0))}function ne(t,e){if(t===e)return!0;if(!l(e)||void 0!==t.size&&void 0!==e.size&&t.size!==e.size||void 0!==t.__hash&&void 0!==e.__hash&&t.__hash!==e.__hash||v(t)!==v(e)||y(t)!==y(e)||g(t)!==g(e))return!1;if(0===t.size&&0===e.size)return!0;var r=!d(t);if(g(t)){var n=t.entries();return e.every(function(t,e){var i=n.next().value;return i&&R(i[1],t)&&(r||R(i[0],e))})&&n.next().done}var i=!1;if(void 0===t.size)if(void 0===e.size)"function"==typeof t.cacheResult&&t.cacheResult();else{i=!0;var o=t;t=e,e=o}var u=!0,s=e.__iterate(function(e,n){if(r?!t.has(e):i?!R(e,t.get(n,ke)):!R(t.get(n,ke),e))return u=!1,!1});return u&&t.size===s}function ie(t,e){var r=function(r){t.prototype[r]=e[r]};return Object.keys(e).forEach(r),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(e).forEach(r),t}function oe(t){return!(!t||!t[Qr])}function ue(t,e){return t.__ownerID?(t.size=e.size,t._map=e,t):e===t._map?t:0===e.size?t.__empty():t.__make(e)}function se(t,e){var r=Object.create(Xr);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r} +;return n||e===Ve||t.done?t:e===Pe?z(e,s-1,void 0,t):z(e,s-1,t.value[1],t)})},_}function Z(t,e,r){var n=ft(t);return n.__iterateUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterate(n,i);var u=0;return t.__iterate(function(t,i,s){return e.call(r,t,i,s)&&++u&&n(t,i,o)}),u},n.__iteratorUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterator(n,i);var u=t.__iterator(He,i),s=!0;return new Fe(function(){if(!s)return S();var t=u.next();if(t.done)return t;var i=t.value,a=i[0],c=i[1];return e.call(r,c,a,o)?n===He?t:z(n,a,c,t):(s=!1,S())})},n}function $(t,e,r,n){var i=ft(t);return i.__iterateUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterate(i,o);var s=!0,a=0;return t.__iterate(function(t,o,c){if(!s||!(s=e.call(r,t,o,c)))return a++,i(t,n?o:a-1,u)}),a},i.__iteratorUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterator(i,o);var s=t.__iterator(He,o),a=!0,c=0;return new Fe(function(){var t,o,h;do{if(t=s.next(),t.done)return n||i===Ve?t:i===Pe?z(i,c++,void 0,t):z(i,c++,t.value[1],t);var f=t.value;o=f[0],h=f[1],a&&(a=e.call(r,h,o,u))}while(a);return i===He?t:z(i,o,h,t)})},i}function tt(t,e){var r=v(t),n=[t].concat(e).map(function(t){return l(t)?r&&(t=Be(t)):t=r?x(t):j(Array.isArray(t)?t:[t]),t}).filter(function(t){return 0!==t.size});if(0===n.length)return t;if(1===n.length){var i=n[0];if(i===t||r&&v(i)||y(t)&&y(i))return i}var o=new rr(n);return r?o=o.toKeyedSeq():y(t)||(o=o.toSetSeq()),o=o.flatten(!0),o.size=n.reduce(function(t,e){if(void 0!==t){var r=e.size;if(void 0!==r)return t+r}},0),o}function et(t,e,r){var n=ft(t);return n.__iterateUncached=function(i,o){function u(t,c){t.__iterate(function(t,o){return(!e||c0}function st(t,e,r,n){var i=ft(t),o=new rr(r).map(function(t){return t.size});return i.size=n?o.max():o.min(),i.__iterate=function(t,e){for(var r,n=this,i=this.__iterator(Ve,e),o=0;!(r=i.next()).done&&t(r.value,o++,n)!==!1;);return o},i.__iteratorUncached=function(t,i){var o=r.map(function(t){return t=We(t),O(i?t.reverse():t)}),u=0,s=!1;return new Fe(function(){var r;return s||(r=o.map(function(t){return t.next()}),s=n?r.every(function(t){return t.done}):r.some(function(t){return t.done})),s?S():z(t,u++,e.apply(null,r.map(function(t){return t.value})))})},i}function at(t,e){return t===e?t:q(t)?e:t.constructor(e)}function ct(t){if(t!==Object(t))throw new TypeError("Expected [K, V] tuple: "+t)}function ht(t){return v(t)?Be:y(t)?Je:Ne}function ft(t){return Object.create((v(t)?Ze:y(t)?$e:tr).prototype)}function pt(){return this._iter.cacheResult?(this._iter.cacheResult(), +this.size=this._iter.size,this):Ge.prototype.cacheResult.call(this)}function _t(t,e){return void 0===t&&void 0===e?0:void 0===t?1:void 0===e?-1:t>e?1:t>>r)&je,s=(0===r?n:n>>>r)&je;return new Mr(e,1<>>=1)u[s]=1&r?e[o++]:void 0;return u[n]=i,new Dr(t,o+1,u)}function xt(t,e,r){for(var n=[],i=0;i>1&1431655765,t=(858993459&t)+(t>>2&858993459),t=t+(t>>4)&252645135,t+=t>>8,127&(t+=t>>16)}function Kt(t,e,r,n){var o=n?t:i(t);return o[e]=r,o}function Lt(t,e,r,n){var i=t.length+1;if(n&&e+1===i)return t[e]=r,t;for(var o=Array(i),u=0,s=0;so?0:o-r,c=u-r;return c>xe&&(c=xe),function(){if(i===c)return Wr;var t=e?--c:i++;return n&&n[t]}}function i(t,n,i){var s,a=t&&t.array,c=i>o?0:o-i>>n,h=1+(u-i>>n);return h>xe&&(h=xe),function(){for(;;){if(s){var t=s();if(t!==Wr)return t;s=null}if(c===h)return Wr;var o=e?--h:c++;s=r(a&&a[o],n-Ee,i+(o<=t.size||r<0)return t.withMutations(function(t){r<0?Yt(t,r).set(0,n):Yt(t,0,r+1).set(r,n)});r+=t._origin;var i=t._tail,o=t._root,s=e(Re);return r>=Xt(t._capacity)?i=Pt(i,t.__ownerID,0,r,n,s):o=Pt(o,t.__ownerID,t._level,r,n,s),s.value?t.__ownerID?(t._root=o,t._tail=i,t.__hash=void 0,t.__altered=!0,t):Bt(t._origin,t._capacity,t._level,o,i):t}function Pt(t,e,n,i,o,u){var s=i>>>n&je,a=t&&s0){var h=t&&t.array[s],f=Pt(h,e,n-Ee,i,o,u);return f===h?t:(c=Vt(t,e),c.array[s]=f,c)}return a&&t.array[s]===o?t:(r(u),c=Vt(t,e),void 0===o&&s===c.array.length-1?c.array.pop():c.array[s]=o,c)}function Vt(t,e){return e&&t&&e===t.ownerID?t:new Tr(t?t.array.slice():[],e)}function Ht(t,e){if(e>=Xt(t._capacity))return t._tail;if(e<1<0;)r=r.array[e>>>n&je],n-=Ee;return r}}function Yt(t,e,r){void 0!==e&&(e|=0),void 0!==r&&(r|=0);var i=t.__ownerID||new n,o=t._origin,u=t._capacity,s=o+e,a=void 0===r?u:r<0?u+r:o+r;if(s===o&&a===u)return t;if(s>=a)return t.clear();for(var c=t._level,h=t._root,f=0;s+f<0;)h=new Tr(h&&h.array.length?[void 0,h]:[],i),c+=Ee,f+=1<=1<p?new Tr([],i):l;if(l&&_>p&&sEe;d-=Ee){var g=p>>>d&je;y=y.array[g]=Vt(y.array[g],i)}y.array[p>>>Ee&je]=l}if(a=_)s-=_,a-=_,c=Ee,h=null,v=v&&v.removeBefore(i,0,s);else if(s>o||_>>c&je;if(m!==_>>>c&je)break;m&&(f+=(1<o&&(h=h.removeBefore(i,c,s-f)),h&&_i&&(i=s.size),l(u)||(s=s.map(function(t){return U(t)})), +n.push(s)}return i>t.size&&(t=t.setSize(i)),At(t,e,n)}function Xt(t){return t>>Ee<=xe&&u.size>=2*o.size?(i=u.filter(function(t,e){return void 0!==t&&s!==e}),n=i.toKeyedSeq().map(function(t){return t[0]}).flip().toMap(),t.__ownerID&&(n.__ownerID=i.__ownerID=t.__ownerID)):(n=o.remove(e),i=s===u.size-1?u.pop():u.set(s,void 0))}else if(a){if(r===u.get(s)[1])return t;n=o,i=u.set(s,[e,r])}else n=o.set(e,u.size),i=u.set(u.size,[e,r]);return t.__ownerID?(t.size=n.size,t._map=n,t._list=i,t.__hash=void 0,t):Gt(n,i)}function te(t){return!(!t||!t[Pr])}function ee(t,e,r,n){var i=Object.create(Vr);return i.size=t,i._head=e,i.__ownerID=r,i.__hash=n,i.__altered=!1,i}function re(){return Hr||(Hr=ee(0))}function ne(t,e){if(t===e)return!0;if(!l(e)||void 0!==t.size&&void 0!==e.size&&t.size!==e.size||void 0!==t.__hash&&void 0!==e.__hash&&t.__hash!==e.__hash||v(t)!==v(e)||y(t)!==y(e)||g(t)!==g(e))return!1;if(0===t.size&&0===e.size)return!0;var r=!d(t);if(g(t)){var n=t.entries();return e.every(function(t,e){var i=n.next().value;return i&&R(i[1],t)&&(r||R(i[0],e))})&&n.next().done}var i=!1;if(void 0===t.size)if(void 0===e.size)"function"==typeof t.cacheResult&&t.cacheResult();else{i=!0;var o=t;t=e,e=o}var u=!0,s=e.__iterate(function(e,n){if(r?!t.has(e):i?!R(e,t.get(n,ke)):!R(t.get(n,ke),e))return u=!1,!1});return u&&t.size===s}function ie(t,e){var r=function(r){t.prototype[r]=e[r]};return Object.keys(e).forEach(r),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(e).forEach(r),t}function oe(t){return!(!t||!t[Qr])}function ue(t,e){return t.__ownerID?(t.size=e.size,t._map=e,t):e===t._map?t:0===e.size?t.__empty():t.__make(e)}function se(t,e){var r=Object.create(Xr);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r} function ae(){return Fr||(Fr=se(St()))}function ce(t,e,r,n,i,o){return yt(t.size),t.__iterate(function(t,o,u){i?(i=!1,r=t):r=e.call(n,r,t,o,u)},o),r}function he(t,e){return e}function fe(t,e){return[e,t]}function pe(t){return t&&"function"==typeof t.toJS?t.toJS():t}function _e(t){return function(){return!t.apply(this,arguments)}}function le(t){return function(){return-t.apply(this,arguments)}}function ve(){return i(arguments)}function ye(t,e){return te?-1:0}function de(t){if(t.size===1/0)return 0;var e=g(t),r=v(t),n=e?1:0;return ge(t.__iterate(r?e?function(t,e){n=31*n+me(W(t),W(e))|0}:function(t,e){n=n+me(W(t),W(e))|0}:e?function(t){n=31*n+W(t)|0}:function(t){n=n+W(t)|0}),n)}function ge(t,e){return e=ar(e,3432918353),e=ar(e<<15|e>>>-15,461845907),e=ar(e<<13|e>>>-13,5),e=(e+3864292196|0)^t,e=ar(e^e>>>16,2246822507),e=ar(e^e>>>13,3266489909),e=C(e^e>>>16)}function me(t,e){return t^e+2654435769+(t<<6)+(t>>2)|0}function we(t){if("object"!=typeof console||!console.warn)throw Error(t);console.warn(t)}function ze(t,e,r,n){for(var i=lt(r),o=0;o!==i.length;){if(!t||!t.get)return n&&we("Invalid keyPath: Value at ["+i.slice(0,o).map(dt)+"] does not have a .get() method: "+t+"\nThis warning will throw in a future version"),e;if((t=t.get(i[o++],ke))===ke)return e}return t}function Se(t){return oe(t)&&g(t)}function Ie(t,e){var r=Object.create(nn);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function be(){return on||(on=Ie(Zt()))}function Oe(t,e,r){var n=Object.create(Object.getPrototypeOf(t));return n._values=e,n.__ownerID=r,n}function Me(t){return t._name||t.constructor.name||"Record"}function De(t){return x(t._keys.map(function(e){return[e,t.get(e)]}))}function qe(t,e){try{Object.defineProperty(t,e,{get:function(){return this.get(e)},set:function(t){vt(this.__ownerID,"Cannot set on an immutable record."),this.set(e,t)}})}catch(t){}}var Ee=5,xe=1<=n.length){var e=r.next();if(e.done)return e;n[i]=e.value}return z(t,i,n[i++])})},e}($e),ar="function"==typeof Math.imul&&Math.imul(4294967295,2)===-2?Math.imul:function(t,e){t|=0,e|=0;var r=65535&t,n=65535&e;return r*n+((t>>>16)*n+r*(e>>>16)<<16>>>0)|0},cr=Object.isExtensible,hr=function(){try{return Object.defineProperty({},"@",{}),!0}catch(t){return!1}}(),fr="function"==typeof WeakMap;fr&&(or=new WeakMap);var pr=0,_r="__immutablehash__";"function"==typeof Symbol&&(_r=Symbol(_r));var lr=16,vr=255,yr=0,dr={},gr=function(t){function e(t,e){this._iter=t,this._useKeys=e,this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t,e){return this._iter.get(t,e)}, e.prototype.has=function(t){return this._iter.has(t)},e.prototype.valueSeq=function(){return this._iter.valueSeq()},e.prototype.reverse=function(){var t=this,e=Y(this,!0);return this._useKeys||(e.valueSeq=function(){return t._iter.toSeq().reverse()}),e},e.prototype.map=function(t,e){var r=this,n=H(this,t,e);return this._useKeys||(n.valueSeq=function(){return r._iter.toSeq().map(t,e)}),n},e.prototype.__iterate=function(t,e){var r=this;return this._iter.__iterate(function(e,n){return t(e,n,r)},e)},e.prototype.__iterator=function(t,e){return this._iter.__iterator(t,e)},e}(Ze);gr.prototype[Te]=!0;var mr=function(t){function e(t){this._iter=t,this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.includes=function(t){return this._iter.includes(t)},e.prototype.__iterate=function(t,e){var r=this,n=0;return e&&o(this),this._iter.__iterate(function(i){return t(i,e?r.size-++n:n++,r)},e)},e.prototype.__iterator=function(t,e){var r=this,n=this._iter.__iterator(Ve,e),i=0;return e&&o(this),new Fe(function(){var o=n.next();return o.done?o:z(t,e?r.size-++i:i++,o.value,o)})},e}($e),wr=function(t){function e(t){this._iter=t,this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.has=function(t){return this._iter.includes(t)},e.prototype.__iterate=function(t,e){var r=this;return this._iter.__iterate(function(e){return t(e,e,r)},e)},e.prototype.__iterator=function(t,e){var r=this._iter.__iterator(Ve,e);return new Fe(function(){var e=r.next();return e.done?e:z(t,e.value,e.value,e)})},e}(tr),zr=function(t){function e(t){this._iter=t,this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.entrySeq=function(){return this._iter.toSeq()},e.prototype.__iterate=function(t,e){var r=this;return this._iter.__iterate(function(e){if(e){ct(e);var n=l(e);return t(n?e.get(1):e[1],n?e.get(0):e[0],r)}},e)},e.prototype.__iterator=function(t,e){ @@ -23,15 +23,15 @@ var r=this._iter.__iterator(Ve,e);return new Fe(function(){for(;;){var e=r.next( ;return this.updateIn(t,St(),function(t){return"function"==typeof t.merge?t.merge.apply(t,e):e[e.length-1]})},e.prototype.mergeDeep=function(){return xt(this,jt,arguments)},e.prototype.mergeDeepWith=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return xt(this,kt(t),e)},e.prototype.mergeDeepIn=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return this.updateIn(t,St(),function(t){return"function"==typeof t.mergeDeep?t.mergeDeep.apply(t,e):e[e.length-1]})},e.prototype.sort=function(t){return Br(it(this,t))},e.prototype.sortBy=function(t,e){return Br(it(this,e,t))},e.prototype.withMutations=function(t){var e=this.asMutable();return t(e),e.wasAltered()?e.__ensureOwner(this.__ownerID):this},e.prototype.asMutable=function(){return this.__ownerID?this:this.__ensureOwner(new n)},e.prototype.asImmutable=function(){return this.__ensureOwner()},e.prototype.wasAltered=function(){return this.__altered},e.prototype.__iterator=function(t,e){return new jr(this,t,e)},e.prototype.__iterate=function(t,e){var r=this,n=0;return this._root&&this._root.iterate(function(e){return n++,t(e[1],e[0],r)},e),n},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?zt(this.size,this._root,t,this.__hash):0===this.size?St():(this.__ownerID=t,this.__altered=!1,this)},e}(Be);Sr.isMap=gt;var Ir="@@__IMMUTABLE_MAP__@@",br=Sr.prototype;br[Ir]=!0,br.delete=br.remove,br.removeIn=br.deleteIn,br.removeAll=br.deleteAll,br["@@transducer/init"]=br.asMutable,br["@@transducer/step"]=function(t,e){return t.set(e[0],e[1])},br["@@transducer/result"]=function(t){return t.asImmutable()};var Or=function(t,e){this.ownerID=t,this.entries=e};Or.prototype.get=function(t,e,r,n){for(var i=this.entries,o=0,u=i.length;o=kr)return Dt(t,h,o,u) ;var l=t&&t===this.ownerID,v=l?h:i(h);return _?c?f===p-1?v.pop():v[f]=v.pop():v[f]=[o,u]:v.push([o,u]),l?(this.entries=v,this):new Or(t,v)}};var Mr=function(t,e,r){this.ownerID=t,this.bitmap=e,this.nodes=r};Mr.prototype.get=function(t,e,r,n){void 0===e&&(e=W(r));var i=1<<((0===t?e:e>>>t)&je),o=this.bitmap;return 0==(o&i)?n:this.nodes[Ut(o&i-1)].get(t+Ee,e,r,n)},Mr.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=W(n));var s=(0===e?r:r>>>e)&je,a=1<=Ar)return Et(t,p,c,s,l);if(h&&!l&&2===p.length&&Ot(p[1^f]))return p[1^f];if(h&&l&&1===p.length&&Ot(l))return l;var v=t&&t===this.ownerID,y=h?l?c:c^a:c|a,d=h?l?Kt(p,f,l,v):Tt(p,f,v):Lt(p,f,l,v);return v?(this.bitmap=y,this.nodes=d,this):new Mr(t,y,d)};var Dr=function(t,e,r){this.ownerID=t,this.count=e,this.nodes=r};Dr.prototype.get=function(t,e,r,n){void 0===e&&(e=W(r));var i=(0===t?e:e>>>t)&je,o=this.nodes[i];return o?o.get(t+Ee,e,r,n):n},Dr.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=W(n));var s=(0===e?r:r>>>e)&je,a=i===ke,c=this.nodes,h=c[s];if(a&&!h)return this;var f=bt(h,t,e+Ee,r,n,i,o,u);if(f===h)return this;var p=this.count;if(h){if(!f&&--p0&&i=0&&t0;)e[r]=arguments[r+1];return Qt(this,t,e)},e.prototype.mergeDeep=function(){return Qt(this,jt,arguments)},e.prototype.mergeDeepWith=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Qt(this,kt(t),e)},e.prototype.setSize=function(t){return Yt(this,0,t)},e.prototype.slice=function(t,e){var r=this.size;return a(t,e,r)?this:Yt(this,c(t,r),h(e,r))},e.prototype.__iterator=function(t,e){var r=e?this.size:0,n=Wt(this,e);return new Fe(function(){var i=n();return i===Wr?S():z(t,e?--r:r++,i)})},e.prototype.__iterate=function(t,e){for(var r,n=this,i=e?this.size:0,o=Wt(this,e);(r=o())!==Wr&&t(r,e?--i:i++,n)!==!1;);return i},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Bt(this._origin,this._capacity,this._level,this._root,this._tail,t,this.__hash):0===this.size?Jt():(this.__ownerID=t,this.__altered=!1,this)},e}(Je);Ur.isList=Ct;var Kr="@@__IMMUTABLE_LIST__@@",Lr=Ur.prototype;Lr[Kr]=!0,Lr.delete=Lr.remove,Lr.setIn=br.setIn,Lr.deleteIn=Lr.removeIn=br.removeIn,Lr.update=br.update,Lr.updateIn=br.updateIn,Lr.mergeIn=br.mergeIn, +return Nt(this,t,e)},e.prototype.remove=function(t){return this.has(t)?0===t?this.shift():t===this.size-1?this.pop():this.splice(t,1):this},e.prototype.insert=function(t,e){return this.splice(t,0,e)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=this._origin=this._capacity=0,this._level=Ee,this._root=this._tail=null,this.__hash=void 0,this.__altered=!0,this):Jt()},e.prototype.push=function(){var t=arguments,e=this.size;return this.withMutations(function(r){Yt(r,0,e+t.length);for(var n=0;n0;)e[r]=arguments[r+1];return Qt(this,t,e)},e.prototype.mergeDeep=function(){return Qt(this,jt,arguments)},e.prototype.mergeDeepWith=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Qt(this,kt(t),e)},e.prototype.setSize=function(t){return Yt(this,0,t)},e.prototype.slice=function(t,e){var r=this.size;return a(t,e,r)?this:Yt(this,c(t,r),h(e,r))},e.prototype.__iterator=function(t,e){var r=e?this.size:0,n=Wt(this,e);return new Fe(function(){var i=n();return i===Wr?S():z(t,e?--r:r++,i)})},e.prototype.__iterate=function(t,e){for(var r,n=this,i=e?this.size:0,o=Wt(this,e);(r=o())!==Wr&&t(r,e?--i:i++,n)!==!1;);return i},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Bt(this._origin,this._capacity,this._level,this._root,this._tail,t,this.__hash):0===this.size?Jt():(this.__ownerID=t,this.__altered=!1,this)},e}(Je);Ur.isList=Ct;var Kr="@@__IMMUTABLE_LIST__@@",Lr=Ur.prototype;Lr[Kr]=!0,Lr.delete=Lr.remove,Lr.setIn=br.setIn,Lr.deleteIn=Lr.removeIn=br.removeIn,Lr.update=br.update,Lr.updateIn=br.updateIn,Lr.mergeIn=br.mergeIn, Lr.mergeDeepIn=br.mergeDeepIn,Lr.withMutations=br.withMutations,Lr.asMutable=br.asMutable,Lr.asImmutable=br.asImmutable,Lr.wasAltered=br.wasAltered,Lr["@@transducer/init"]=Lr.asMutable,Lr["@@transducer/step"]=function(t,e){return t.push(e)},Lr["@@transducer/result"]=br["@@transducer/result"];var Tr=function(t,e){this.array=t,this.ownerID=e};Tr.prototype.removeBefore=function(t,e,r){if(r===e?1<>>e&je;if(n>=this.array.length)return new Tr([],t);var i,o=0===n;if(e>0){var u=this.array[n];if((i=u&&u.removeBefore(t,e-Ee,r))===u&&o)return this}if(o&&!i)return this;var s=Vt(this,t);if(!o)for(var a=0;a>>e&je;if(n>=this.array.length)return this;var i;if(e>0){var o=this.array[n];if((i=o&&o.removeAfter(t,e-Ee,r))===o&&n===this.array.length-1)return this}var u=Vt(this,t);return u.array.splice(n+1),i&&(u.array[n]=i),u};var Cr,Wr={},Br=function(t){function e(t){return null===t||void 0===t?Zt():Ft(t)?t:Zt().withMutations(function(e){var r=Be(t);yt(r.size),r.forEach(function(t,r){return e.set(r,t)})})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("OrderedMap {","}")},e.prototype.get=function(t,e){var r=this._map.get(t);return void 0!==r?this._list.get(r)[1]:e},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._map.clear(),this._list.clear(),this):Zt()},e.prototype.set=function(t,e){return $t(this,t,e)},e.prototype.remove=function(t){return $t(this,t,ke)},e.prototype.wasAltered=function(){return this._map.wasAltered()||this._list.wasAltered()},e.prototype.__iterate=function(t,e){var r=this;return this._list.__iterate(function(e){return e&&t(e[1],e[0],r)},e)},e.prototype.__iterator=function(t,e){return this._list.fromEntrySeq().__iterator(t,e)}, -e.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var e=this._map.__ensureOwner(t),r=this._list.__ensureOwner(t);return t?Gt(e,r,t,this.__hash):0===this.size?Zt():(this.__ownerID=t,this._map=e,this._list=r,this)},e}(Sr);Br.isOrderedMap=Ft,Br.prototype[Te]=!0,Br.prototype.delete=Br.prototype.remove;var Jr,Pr=function(t){function e(t){return null===t||void 0===t?re():te(t)?t:re().pushAll(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("Stack [","]")},e.prototype.get=function(t,e){var r=this._head;for(t=u(this,t);r&&t--;)r=r.next;return r?r.value:e},e.prototype.peek=function(){return this._head&&this._head.value},e.prototype.push=function(){var t=arguments;if(0===arguments.length)return this;for(var e=this.size+arguments.length,r=this._head,n=arguments.length-1;n>=0;n--)r={value:t[n],next:r};return this.__ownerID?(this.size=e,this._head=r,this.__hash=void 0,this.__altered=!0,this):ee(e,r)},e.prototype.pushAll=function(e){if(e=t(e),0===e.size)return this;if(0===this.size&&te(e))return e;yt(e.size);var r=this.size,n=this._head;return e.__iterate(function(t){r++,n={value:t,next:n}},!0),this.__ownerID?(this.size=r,this._head=n,this.__hash=void 0,this.__altered=!0,this):ee(r,n)},e.prototype.pop=function(){return this.slice(1)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):re()},e.prototype.slice=function(e,r){if(a(e,r,this.size))return this;var n=c(e,this.size);if(h(r,this.size)!==this.size)return t.prototype.slice.call(this,e,r);for(var i=this.size-n,o=this._head;n--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):ee(i,o)},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?ee(this.size,this._head,t,this.__hash):0===this.size?re():(this.__ownerID=t,this.__altered=!1,this)}, -e.prototype.__iterate=function(t,e){var r=this;if(e)return new rr(this.toArray()).__iterate(function(e,n){return t(e,n,r)},e);for(var n=0,i=this._head;i&&t(i.value,n++,r)!==!1;)i=i.next;return n},e.prototype.__iterator=function(t,e){if(e)return new rr(this.toArray()).__iterator(t,e);var r=0,n=this._head;return new Fe(function(){if(n){var e=n.value;return n=n.next,z(t,r++,e)}return S()})},e}(Je);Pr.isStack=te;var Nr="@@__IMMUTABLE_STACK__@@",Vr=Pr.prototype;Vr[Nr]=!0,Vr.withMutations=br.withMutations,Vr.asMutable=br.asMutable,Vr.asImmutable=br.asImmutable,Vr.wasAltered=br.wasAltered,Vr.shift=Vr.pop,Vr.unshift=Vr.push,Vr.unshiftAll=Vr.pushAll,Vr["@@transducer/init"]=Vr.asMutable,Vr["@@transducer/step"]=function(t,e){return t.unshift(e)},Vr["@@transducer/result"]=br["@@transducer/result"];var Hr,Yr=function(t){function e(e){return null===e||void 0===e?ae():oe(e)&&!g(e)?e:ae().withMutations(function(r){var n=t(e);yt(n.size),n.forEach(function(t){return r.add(t)})})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(Be(t).keySeq())},e.intersect=function(t){return t=We(t).toArray(),t.length?Xr.intersect.apply(e(t.pop()),t):ae()},e.union=function(t){return t=We(t).toArray(),t.length?Xr.union.apply(e(t.pop()),t):ae()},e.prototype.toString=function(){return this.__toString("Set {","}")},e.prototype.has=function(t){return this._map.has(t)},e.prototype.add=function(t){return ue(this,this._map.set(t,t))},e.prototype.remove=function(t){return ue(this,this._map.remove(t))},e.prototype.clear=function(){return ue(this,this._map.clear())},e.prototype.union=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return e=e.filter(function(t){return 0!==t.size}),0===e.length?this:0!==this.size||this.__ownerID||1!==e.length?this.withMutations(function(r){for(var n=0;n0;)e[r]=arguments[r+1];return this.union.apply(this,e)},e.prototype.sort=function(t){return rn(it(this,t))},e.prototype.sortBy=function(t,e){return rn(it(this,e,t))},e.prototype.wasAltered=function(){return this._map.wasAltered()},e.prototype.__iterate=function(t,e){var r=this;return this._map.__iterate(function(e){return t(e,e,r)},e)},e.prototype.__iterator=function(t,e){return this._map.__iterator(t,e)},e.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var e=this._map.__ensureOwner(t);return t?this.__make(e,t):0===this.size?this.__empty():(this.__ownerID=t,this._map=e,this)},e}(Pe);Yr.isSet=oe;var Qr="@@__IMMUTABLE_SET__@@",Xr=Yr.prototype;Xr[Qr]=!0,Xr.delete=Xr.remove,Xr.mergeDeep=Xr.merge,Xr.mergeDeepWith=Xr.mergeWith,Xr.withMutations=br.withMutations,Xr.asMutable=br.asMutable,Xr.asImmutable=br.asImmutable,Xr["@@transducer/init"]=Xr.asMutable,Xr["@@transducer/step"]=function(t,e){return t.add(e)},Xr["@@transducer/result"]=br["@@transducer/result"],Xr.__empty=ae,Xr.__make=se;var Fr,Gr,Zr=function(t){function e(t,r,n){if(!(this instanceof e))return new e(t,r,n);if(vt(0!==n,"Cannot step a Range by 0"),t=t||0,void 0===r&&(r=1/0),n=void 0===n?1:Math.abs(n),r=0&&e=0&&rthis.size?e:this.find(function(e,r){return r===t},void 0,e)},has:function(t){return(t=u(this,t))>=0&&(void 0!==this.size?this.size===1/0||t=0;n--)r={value:t[n],next:r};return this.__ownerID?(this.size=e,this._head=r,this.__hash=void 0,this.__altered=!0,this):ee(e,r)},e.prototype.pushAll=function(e){if(e=t(e),0===e.size)return this;if(0===this.size&&te(e))return e;yt(e.size);var r=this.size,n=this._head;return e.__iterate(function(t){r++,n={value:t,next:n}},!0),this.__ownerID?(this.size=r,this._head=n,this.__hash=void 0,this.__altered=!0,this):ee(r,n)},e.prototype.pop=function(){return this.slice(1)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):re()},e.prototype.slice=function(e,r){if(a(e,r,this.size))return this;var n=c(e,this.size);if(h(r,this.size)!==this.size)return t.prototype.slice.call(this,e,r);for(var i=this.size-n,o=this._head;n--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):ee(i,o)},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?ee(this.size,this._head,t,this.__hash):0===this.size?re():(this.__ownerID=t,this.__altered=!1,this)}, +e.prototype.__iterate=function(t,e){var r=this;if(e)return new rr(this.toArray()).__iterate(function(e,n){return t(e,n,r)},e);for(var n=0,i=this._head;i&&t(i.value,n++,r)!==!1;)i=i.next;return n},e.prototype.__iterator=function(t,e){if(e)return new rr(this.toArray()).__iterator(t,e);var r=0,n=this._head;return new Fe(function(){if(n){var e=n.value;return n=n.next,z(t,r++,e)}return S()})},e}(Je);Nr.isStack=te;var Pr="@@__IMMUTABLE_STACK__@@",Vr=Nr.prototype;Vr[Pr]=!0,Vr.withMutations=br.withMutations,Vr.asMutable=br.asMutable,Vr.asImmutable=br.asImmutable,Vr.wasAltered=br.wasAltered,Vr.shift=Vr.pop,Vr.unshift=Vr.push,Vr.unshiftAll=Vr.pushAll,Vr["@@transducer/init"]=Vr.asMutable,Vr["@@transducer/step"]=function(t,e){return t.unshift(e)},Vr["@@transducer/result"]=br["@@transducer/result"];var Hr,Yr=function(t){function e(e){return null===e||void 0===e?ae():oe(e)&&!g(e)?e:ae().withMutations(function(r){var n=t(e);yt(n.size),n.forEach(function(t){return r.add(t)})})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(Be(t).keySeq())},e.intersect=function(t){return t=We(t).toArray(),t.length?Xr.intersect.apply(e(t.pop()),t):ae()},e.union=function(t){return t=We(t).toArray(),t.length?Xr.union.apply(e(t.pop()),t):ae()},e.prototype.toString=function(){return this.__toString("Set {","}")},e.prototype.has=function(t){return this._map.has(t)},e.prototype.add=function(t){return ue(this,this._map.set(t,t))},e.prototype.remove=function(t){return ue(this,this._map.remove(t))},e.prototype.clear=function(){return ue(this,this._map.clear())},e.prototype.union=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return e=e.filter(function(t){return 0!==t.size}),0===e.length?this:0!==this.size||this.__ownerID||1!==e.length?this.withMutations(function(r){for(var n=0;n0;)e[r]=arguments[r+1];return this.union.apply(this,e)},e.prototype.sort=function(t){return rn(it(this,t))},e.prototype.sortBy=function(t,e){return rn(it(this,e,t))},e.prototype.wasAltered=function(){return this._map.wasAltered()},e.prototype.__iterate=function(t,e){var r=this;return this._map.__iterate(function(e){return t(e,e,r)},e)},e.prototype.__iterator=function(t,e){return this._map.__iterator(t,e)},e.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var e=this._map.__ensureOwner(t);return t?this.__make(e,t):0===this.size?this.__empty():(this.__ownerID=t,this._map=e,this)},e}(Ne);Yr.isSet=oe;var Qr="@@__IMMUTABLE_SET__@@",Xr=Yr.prototype;Xr[Qr]=!0,Xr.delete=Xr.remove,Xr.mergeDeep=Xr.merge,Xr.mergeDeepWith=Xr.mergeWith,Xr.withMutations=br.withMutations,Xr.asMutable=br.asMutable,Xr.asImmutable=br.asImmutable,Xr["@@transducer/init"]=Xr.asMutable,Xr["@@transducer/step"]=function(t,e){return t.add(e)},Xr["@@transducer/result"]=br["@@transducer/result"],Xr.__empty=ae,Xr.__make=se;var Fr,Gr,Zr=function(t){function e(t,r,n){if(!(this instanceof e))return new e(t,r,n);if(vt(0!==n,"Cannot step a Range by 0"),t=t||0,void 0===r&&(r=1/0),n=void 0===n?1:Math.abs(n),r=0&&e=0&&rthis.size?e:this.find(function(e,r){return r===t},void 0,e)},has:function(t){return(t=u(this,t))>=0&&(void 0!==this.size?this.size===1/0||t Date: Thu, 5 Oct 2017 01:51:04 +0000 Subject: [PATCH 035/242] Deploy master to NPM branch --- dist/immutable-nonambient.d.ts | 12 ++++++++ dist/immutable.d.ts | 12 ++++++++ dist/immutable.js.flow | 50 +++++++++++++++++----------------- 3 files changed, 49 insertions(+), 25 deletions(-) diff --git a/dist/immutable-nonambient.d.ts b/dist/immutable-nonambient.d.ts index 6f45329260..6eba8c0b5b 100644 --- a/dist/immutable-nonambient.d.ts +++ b/dist/immutable-nonambient.d.ts @@ -900,6 +900,10 @@ * const b = List([ 3, 4, 5 ]); * const c = a.zipAll(b); // List [ [ 1, 3 ], [ 2, 4 ], [ undefined, 5 ] ] * ``` + * + * Note: Since zipAll will return a collection as large as the largest + * input, some results may contain undefined values. TypeScript cannot + * account for these without cases (as of v2.5). */ zipAll(other: Collection): List<[T,U]>; zipAll(other: Collection, other2: Collection): List<[T,U,V]>; @@ -2056,6 +2060,10 @@ * const b = OrderedSet([ 3, 4, 5 ]); * const c = a.zipAll(b); // OrderedSet [ [ 1, 3 ], [ 2, 4 ], [ undefined, 5 ] ] * ``` + * + * Note: Since zipAll will return a collection as large as the largest + * input, some results may contain undefined values. TypeScript cannot + * account for these without cases (as of v2.5). */ zipAll(other: Collection): OrderedSet<[T,U]>; zipAll(other1: Collection, other2: Collection): OrderedSet<[T,U,V]>; @@ -2294,6 +2302,10 @@ * const b = Stack([ 3, 4, 5 ]); * const c = a.zipAll(b); // Stack [ [ 1, 3 ], [ 2, 4 ], [ undefined, 5 ] ] * ``` + * + * Note: Since zipAll will return a collection as large as the largest + * input, some results may contain undefined values. TypeScript cannot + * account for these without cases (as of v2.5). */ zipAll(other: Collection): Stack<[T,U]>; zipAll(other: Collection, other2: Collection): Stack<[T,U,V]>; diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index 76f13f5db9..ceb3b21245 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -900,6 +900,10 @@ declare module Immutable { * const b = List([ 3, 4, 5 ]); * const c = a.zipAll(b); // List [ [ 1, 3 ], [ 2, 4 ], [ undefined, 5 ] ] * ``` + * + * Note: Since zipAll will return a collection as large as the largest + * input, some results may contain undefined values. TypeScript cannot + * account for these without cases (as of v2.5). */ zipAll(other: Collection): List<[T,U]>; zipAll(other: Collection, other2: Collection): List<[T,U,V]>; @@ -2056,6 +2060,10 @@ declare module Immutable { * const b = OrderedSet([ 3, 4, 5 ]); * const c = a.zipAll(b); // OrderedSet [ [ 1, 3 ], [ 2, 4 ], [ undefined, 5 ] ] * ``` + * + * Note: Since zipAll will return a collection as large as the largest + * input, some results may contain undefined values. TypeScript cannot + * account for these without cases (as of v2.5). */ zipAll(other: Collection): OrderedSet<[T,U]>; zipAll(other1: Collection, other2: Collection): OrderedSet<[T,U,V]>; @@ -2294,6 +2302,10 @@ declare module Immutable { * const b = Stack([ 3, 4, 5 ]); * const c = a.zipAll(b); // Stack [ [ 1, 3 ], [ 2, 4 ], [ undefined, 5 ] ] * ``` + * + * Note: Since zipAll will return a collection as large as the largest + * input, some results may contain undefined values. TypeScript cannot + * account for these without cases (as of v2.5). */ zipAll(other: Collection): Stack<[T,U]>; zipAll(other: Collection, other2: Collection): Stack<[T,U,V]>; diff --git a/dist/immutable.js.flow b/dist/immutable.js.flow index f306d3be41..67ebba04b9 100644 --- a/dist/immutable.js.flow +++ b/dist/immutable.js.flow @@ -292,25 +292,25 @@ declare class IndexedCollection<+T> extends Collection { zipAll( a: Iterable, ..._: [] - ): IndexedCollection<[T, A]>; + ): IndexedCollection<[T|void, A|void]>; zipAll( a: Iterable, b: Iterable, ..._: [] - ): IndexedCollection<[T, A, B]>; + ): IndexedCollection<[T|void, A|void, B|void]>; zipAll( a: Iterable, b: Iterable, c: Iterable, ..._: [] - ): IndexedCollection<[T, A, B, C]>; + ): IndexedCollection<[T|void, A|void, B|void, C|void]>; zipAll( a: Iterable, b: Iterable, c: Iterable, d: Iterable, ..._: [] - ): IndexedCollection<[T, A, B, C, D]>; + ): IndexedCollection<[T|void, A|void, B|void, C|void, D|void]>; zipAll( a: Iterable, b: Iterable, @@ -318,7 +318,7 @@ declare class IndexedCollection<+T> extends Collection { d: Iterable, e: Iterable, ..._: [] - ): IndexedCollection<[T, A, B, C, D, E]>; + ): IndexedCollection<[T|void, A|void, B|void, C|void, D|void, E|void]>; zipWith( zipper: (value: T, a: A) => R, @@ -519,25 +519,25 @@ declare class IndexedSeq<+T> extends Seq mixins IndexedCollection zipAll( a: Iterable, ..._: [] - ): IndexedSeq<[T, A]>; + ): IndexedSeq<[T|void, A|void]>; zipAll( a: Iterable, b: Iterable, ..._: [] - ): IndexedSeq<[T, A, B]>; + ): IndexedSeq<[T|void, A|void, B|void]>; zipAll( a: Iterable, b: Iterable, c: Iterable, ..._: [] - ): IndexedSeq<[T, A, B, C]>; + ): IndexedSeq<[T|void, A|void, B|void, C|void]>; zipAll( a: Iterable, b: Iterable, c: Iterable, d: Iterable, ..._: [] - ): IndexedSeq<[T, A, B, C, D]>; + ): IndexedSeq<[T|void, A|void, B|void, C|void, D|void]>; zipAll( a: Iterable, b: Iterable, @@ -545,7 +545,7 @@ declare class IndexedSeq<+T> extends Seq mixins IndexedCollection d: Iterable, e: Iterable, ..._: [] - ): IndexedSeq<[T, A, B, C, D, E]>; + ): IndexedSeq<[T|void, A|void, B|void, C|void, D|void, E|void]>; zipWith( zipper: (value: T, a: A) => R, @@ -719,25 +719,25 @@ declare class List<+T> extends IndexedCollection { zipAll( a: Iterable, ..._: [] - ): List<[T, A]>; + ): List<[T|void, A|void]>; zipAll( a: Iterable, b: Iterable, ..._: [] - ): List<[T, A, B]>; + ): List<[T|void, A|void, B|void]>; zipAll( a: Iterable, b: Iterable, c: Iterable, ..._: [] - ): List<[T, A, B, C]>; + ): List<[T|void, A|void, B|void, C|void]>; zipAll( a: Iterable, b: Iterable, c: Iterable, d: Iterable, ..._: [] - ): List<[T, A, B, C, D]>; + ): List<[T|void, A|void, B|void, C|void, D|void]>; zipAll( a: Iterable, b: Iterable, @@ -745,7 +745,7 @@ declare class List<+T> extends IndexedCollection { d: Iterable, e: Iterable, ..._: [] - ): List<[T, A, B, C, D, E]>; + ): List<[T|void, A|void, B|void, C|void, D|void, E|void]>; zipWith( zipper: (value: T, a: A) => R, @@ -1092,25 +1092,25 @@ declare class OrderedSet<+T> extends Set { zipAll( a: Iterable, ..._: [] - ): OrderedSet<[T, A]>; + ): OrderedSet<[T|void, A|void]>; zipAll( a: Iterable, b: Iterable, ..._: [] - ): OrderedSet<[T, A, B]>; + ): OrderedSet<[T|void, A|void, B|void]>; zipAll( a: Iterable, b: Iterable, c: Iterable, ..._: [] - ): OrderedSet<[T, A, B, C]>; + ): OrderedSet<[T|void, A|void, B|void, C|void]>; zipAll( a: Iterable, b: Iterable, c: Iterable, d: Iterable, ..._: [] - ): OrderedSet<[T, A, B, C, D]>; + ): OrderedSet<[T|void, A|void, B|void, C|void, D|void]>; zipAll( a: Iterable, b: Iterable, @@ -1118,7 +1118,7 @@ declare class OrderedSet<+T> extends Set { d: Iterable, e: Iterable, ..._: [] - ): OrderedSet<[T, A, B, C, D, E]>; + ): OrderedSet<[T|void, A|void, B|void, C|void, D|void, E|void]>; zipWith( zipper: (value: T, a: A) => R, @@ -1233,25 +1233,25 @@ declare class Stack<+T> extends IndexedCollection { zipAll( a: Iterable, ..._: [] - ): Stack<[T, A]>; + ): Stack<[T|void, A|void]>; zipAll( a: Iterable, b: Iterable, ..._: [] - ): Stack<[T, A, B]>; + ): Stack<[T|void, A|void, B|void]>; zipAll( a: Iterable, b: Iterable, c: Iterable, ..._: [] - ): Stack<[T, A, B, C]>; + ): Stack<[T|void, A|void, B|void, C|void]>; zipAll( a: Iterable, b: Iterable, c: Iterable, d: Iterable, ..._: [] - ): Stack<[T, A, B, C, D]>; + ): Stack<[T|void, A|void, B|void, C|void, D|void]>; zipAll( a: Iterable, b: Iterable, @@ -1259,7 +1259,7 @@ declare class Stack<+T> extends IndexedCollection { d: Iterable, e: Iterable, ..._: [] - ): Stack<[T, A, B, C, D, E]>; + ): Stack<[T|void, A|void, B|void, C|void, D|void, E|void]>; zipWith( zipper: (value: T, a: A) => R, From e58724a680e22f0320a15ad975c8d602f63f534b Mon Sep 17 00:00:00 2001 From: Travis CI Date: Thu, 5 Oct 2017 01:51:52 +0000 Subject: [PATCH 036/242] Deploy master to NPM branch --- dist/immutable-nonambient.d.ts | 11 ++-- dist/immutable.d.ts | 11 ++-- dist/immutable.es.js | 116 ++++++++++++++++----------------- dist/immutable.js | 116 ++++++++++++++++----------------- dist/immutable.min.js | 60 ++++++++--------- 5 files changed, 154 insertions(+), 160 deletions(-) diff --git a/dist/immutable-nonambient.d.ts b/dist/immutable-nonambient.d.ts index 6eba8c0b5b..958aaa77f1 100644 --- a/dist/immutable-nonambient.d.ts +++ b/dist/immutable-nonambient.d.ts @@ -1238,11 +1238,8 @@ * (or JS objects) into this Map. In other words, this takes each entry of * each collection and sets it on this Map. * - * If any of the values provided to `merge` are not Collection (would return - * false for `isCollection`) then they are deeply converted - * via `fromJS` before being merged. However, if the value is an - * Collection but includes non-collection JS objects or arrays, those nested - * values will be preserved. + * Note: Values provided to `merge` are shallowly converted before being + * merged. No nested values are altered. * * * ```js @@ -1284,6 +1281,10 @@ * Like `merge()`, but when two Collections conflict, it merges them as well, * recursing deeply through the nested data. * + * Note: Values provided to `merge` are shallowly converted before being + * merged. No nested values are altered unless they will also be merged at + * a deeper level. + * * * ```js * const { Map } = require('immutable@4.0.0-rc.4') diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index ceb3b21245..a329d8de4b 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -1238,11 +1238,8 @@ declare module Immutable { * (or JS objects) into this Map. In other words, this takes each entry of * each collection and sets it on this Map. * - * If any of the values provided to `merge` are not Collection (would return - * false for `isCollection`) then they are deeply converted - * via `fromJS` before being merged. However, if the value is an - * Collection but includes non-collection JS objects or arrays, those nested - * values will be preserved. + * Note: Values provided to `merge` are shallowly converted before being + * merged. No nested values are altered. * * * ```js @@ -1284,6 +1281,10 @@ declare module Immutable { * Like `merge()`, but when two Collections conflict, it merges them as well, * recursing deeply through the nested data. * + * Note: Values provided to `merge` are shallowly converted before being + * merged. No nested values are altered unless they will also be merged at + * a deeper level. + * * * ```js * const { Map } = require('immutable@4.0.0-rc.4') diff --git a/dist/immutable.es.js b/dist/immutable.es.js index f0249da440..4b952f60d4 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -771,51 +771,6 @@ function is(valueA, valueB) { ); } -function fromJS(value, converter) { - return fromJSWith( - [], - converter || defaultConverter, - value, - '', - converter && converter.length > 2 ? [] : undefined, - { '': value } - ); -} - -function fromJSWith(stack, converter, value, key, keyPath, parentValue) { - var toSeq = Array.isArray(value) - ? IndexedSeq - : isPlainObj(value) ? KeyedSeq : null; - if (toSeq) { - if (~stack.indexOf(value)) { - throw new TypeError('Cannot convert circular structure to Immutable'); - } - stack.push(value); - keyPath && key !== '' && keyPath.push(key); - var converted = converter.call( - parentValue, - key, - toSeq(value).map(function (v, k) { return fromJSWith(stack, converter, v, k, keyPath, value); } - ), - keyPath && keyPath.slice() - ); - stack.pop(); - keyPath && keyPath.pop(); - return converted; - } - return value; -} - -function defaultConverter(k, v) { - return isKeyed(v) ? v.toMap() : v.toList(); -} - -function isPlainObj(value) { - return ( - value && (value.constructor === Object || value.constructor === undefined) - ); -} - var imul = typeof Math.imul === 'function' && Math.imul(0xffffffff, 2) === -2 ? Math.imul @@ -2771,25 +2726,25 @@ function expandNodes(ownerID, nodes, bitmap, including, node) { function mergeIntoMapWith(map, merger, collections) { var iters = []; for (var ii = 0; ii < collections.length; ii++) { - var value = collections[ii]; - var iter = KeyedCollection(value); - if (!isCollection(value)) { - iter = iter.map(function (v) { return fromJS(v); }); - } - iters.push(iter); + iters.push(KeyedCollection(collections[ii])); } return mergeIntoCollectionWith(map, merger, iters); } function deepMerger(oldVal, newVal) { - return oldVal && oldVal.mergeDeep && isCollection(newVal) + return newVal && typeof newVal === 'object' && oldVal && oldVal.mergeDeep ? oldVal.mergeDeep(newVal) : is(oldVal, newVal) ? oldVal : newVal; } function deepMergerWith(merger) { return function (oldVal, newVal, key) { - if (oldVal && oldVal.mergeDeepWith && isCollection(newVal)) { + if ( + newVal && + typeof newVal === 'object' && + oldVal && + oldVal.mergeDeepWith + ) { return oldVal.mergeDeepWith(merger, newVal); } var nextValue = merger(oldVal, newVal, key); @@ -2806,7 +2761,7 @@ function mergeIntoCollectionWith(collection, merger, iters) { return collection.constructor(iters[0]); } return collection.withMutations(function (collection) { - var mergeIntoMap = merger + var mergeIntoCollection = merger ? function (value, key) { collection.update( key, @@ -2818,7 +2773,7 @@ function mergeIntoCollectionWith(collection, merger, iters) { collection.set(key, value); }; for (var ii = 0; ii < iters.length; ii++) { - iters[ii].forEach(mergeIntoMap); + iters[ii].forEach(mergeIntoCollection); } }); } @@ -3545,14 +3500,10 @@ function mergeIntoListWith(list, merger, collections) { var iters = []; var maxSize = 0; for (var ii = 0; ii < collections.length; ii++) { - var value = collections[ii]; - var iter = IndexedCollection(value); + var iter = IndexedCollection(collections[ii]); if (iter.size > maxSize) { maxSize = iter.size; } - if (!isCollection(value)) { - iter = iter.map(function (v) { return fromJS(v); }); - } iters.push(iter); } if (maxSize > list.size) { @@ -5558,6 +5509,51 @@ var Repeat = (function (IndexedSeq$$1) { var EMPTY_REPEAT; +function fromJS(value, converter) { + return fromJSWith( + [], + converter || defaultConverter, + value, + '', + converter && converter.length > 2 ? [] : undefined, + { '': value } + ); +} + +function fromJSWith(stack, converter, value, key, keyPath, parentValue) { + var toSeq = Array.isArray(value) + ? IndexedSeq + : isPlainObj(value) ? KeyedSeq : null; + if (toSeq) { + if (~stack.indexOf(value)) { + throw new TypeError('Cannot convert circular structure to Immutable'); + } + stack.push(value); + keyPath && key !== '' && keyPath.push(key); + var converted = converter.call( + parentValue, + key, + toSeq(value).map(function (v, k) { return fromJSWith(stack, converter, v, k, keyPath, value); } + ), + keyPath && keyPath.slice() + ); + stack.pop(); + keyPath && keyPath.pop(); + return converted; + } + return value; +} + +function defaultConverter(k, v) { + return isKeyed(v) ? v.toMap() : v.toList(); +} + +function isPlainObj(value) { + return ( + value && (value.constructor === Object || value.constructor === undefined) + ); +} + var Immutable = { Collection: Collection, // Note: Iterable is deprecated diff --git a/dist/immutable.js b/dist/immutable.js index b6e28a54b1..b9cf71dd0d 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -777,51 +777,6 @@ function is(valueA, valueB) { ); } -function fromJS(value, converter) { - return fromJSWith( - [], - converter || defaultConverter, - value, - '', - converter && converter.length > 2 ? [] : undefined, - { '': value } - ); -} - -function fromJSWith(stack, converter, value, key, keyPath, parentValue) { - var toSeq = Array.isArray(value) - ? IndexedSeq - : isPlainObj(value) ? KeyedSeq : null; - if (toSeq) { - if (~stack.indexOf(value)) { - throw new TypeError('Cannot convert circular structure to Immutable'); - } - stack.push(value); - keyPath && key !== '' && keyPath.push(key); - var converted = converter.call( - parentValue, - key, - toSeq(value).map(function (v, k) { return fromJSWith(stack, converter, v, k, keyPath, value); } - ), - keyPath && keyPath.slice() - ); - stack.pop(); - keyPath && keyPath.pop(); - return converted; - } - return value; -} - -function defaultConverter(k, v) { - return isKeyed(v) ? v.toMap() : v.toList(); -} - -function isPlainObj(value) { - return ( - value && (value.constructor === Object || value.constructor === undefined) - ); -} - var imul = typeof Math.imul === 'function' && Math.imul(0xffffffff, 2) === -2 ? Math.imul @@ -2777,25 +2732,25 @@ function expandNodes(ownerID, nodes, bitmap, including, node) { function mergeIntoMapWith(map, merger, collections) { var iters = []; for (var ii = 0; ii < collections.length; ii++) { - var value = collections[ii]; - var iter = KeyedCollection(value); - if (!isCollection(value)) { - iter = iter.map(function (v) { return fromJS(v); }); - } - iters.push(iter); + iters.push(KeyedCollection(collections[ii])); } return mergeIntoCollectionWith(map, merger, iters); } function deepMerger(oldVal, newVal) { - return oldVal && oldVal.mergeDeep && isCollection(newVal) + return newVal && typeof newVal === 'object' && oldVal && oldVal.mergeDeep ? oldVal.mergeDeep(newVal) : is(oldVal, newVal) ? oldVal : newVal; } function deepMergerWith(merger) { return function (oldVal, newVal, key) { - if (oldVal && oldVal.mergeDeepWith && isCollection(newVal)) { + if ( + newVal && + typeof newVal === 'object' && + oldVal && + oldVal.mergeDeepWith + ) { return oldVal.mergeDeepWith(merger, newVal); } var nextValue = merger(oldVal, newVal, key); @@ -2812,7 +2767,7 @@ function mergeIntoCollectionWith(collection, merger, iters) { return collection.constructor(iters[0]); } return collection.withMutations(function (collection) { - var mergeIntoMap = merger + var mergeIntoCollection = merger ? function (value, key) { collection.update( key, @@ -2824,7 +2779,7 @@ function mergeIntoCollectionWith(collection, merger, iters) { collection.set(key, value); }; for (var ii = 0; ii < iters.length; ii++) { - iters[ii].forEach(mergeIntoMap); + iters[ii].forEach(mergeIntoCollection); } }); } @@ -3551,14 +3506,10 @@ function mergeIntoListWith(list, merger, collections) { var iters = []; var maxSize = 0; for (var ii = 0; ii < collections.length; ii++) { - var value = collections[ii]; - var iter = IndexedCollection(value); + var iter = IndexedCollection(collections[ii]); if (iter.size > maxSize) { maxSize = iter.size; } - if (!isCollection(value)) { - iter = iter.map(function (v) { return fromJS(v); }); - } iters.push(iter); } if (maxSize > list.size) { @@ -5564,6 +5515,51 @@ var Repeat = (function (IndexedSeq$$1) { var EMPTY_REPEAT; +function fromJS(value, converter) { + return fromJSWith( + [], + converter || defaultConverter, + value, + '', + converter && converter.length > 2 ? [] : undefined, + { '': value } + ); +} + +function fromJSWith(stack, converter, value, key, keyPath, parentValue) { + var toSeq = Array.isArray(value) + ? IndexedSeq + : isPlainObj(value) ? KeyedSeq : null; + if (toSeq) { + if (~stack.indexOf(value)) { + throw new TypeError('Cannot convert circular structure to Immutable'); + } + stack.push(value); + keyPath && key !== '' && keyPath.push(key); + var converted = converter.call( + parentValue, + key, + toSeq(value).map(function (v, k) { return fromJSWith(stack, converter, v, k, keyPath, value); } + ), + keyPath && keyPath.slice() + ); + stack.pop(); + keyPath && keyPath.pop(); + return converted; + } + return value; +} + +function defaultConverter(k, v) { + return isKeyed(v) ? v.toMap() : v.toList(); +} + +function isPlainObj(value) { + return ( + value && (value.constructor === Object || value.constructor === undefined) + ); +} + var Immutable = { Collection: Collection, // Note: Iterable is deprecated diff --git a/dist/immutable.min.js b/dist/immutable.min.js index 21a6a21156..284454156e 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -5,33 +5,33 @@ * LICENSE file in the root directory of this source tree. */ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.Immutable=t.Immutable||{})}(this,function(t){"use strict";function e(t){return t.value=!1,t}function r(t){t&&(t.value=!0)}function n(){}function i(t,e){e=e||0;for(var r=Math.max(0,t.length-e),n=Array(r),i=0;i>>0;if(""+r!==e||4294967295===r)return NaN;e=r}return e<0?o(t)+e:e}function s(){return!0}function a(t,e,r){return(0===t&&!p(t)||void 0!==r&&t<=-r)&&(void 0===e||void 0!==r&&e>=r)}function c(t,e){return f(t,e,0)}function h(t,e){return f(t,e,e)}function f(t,e,r){return void 0===t?r:p(t)?e===1/0?e:0|Math.max(0,e+t):void 0===e||e===t?t:0|Math.min(e,t)}function p(t){return t<0||0===t&&1/t==-(1/0)}function _(t){return(l(t)||m(t))&&!t.__ownerID}function l(t){return!(!t||!t[Ue])}function v(t){return!(!t||!t[Ke])}function y(t){return!(!t||!t[Le])}function d(t){return v(t)||y(t)}function g(t){return!(!t||!t[Te])}function m(t){return!(!t||!t[Ce])}function w(t){return!(!t||"function"!=typeof t.equals||"function"!=typeof t.hashCode)}function z(t,e,r,n){var i=0===t?e:1===t?r:[e,r];return n?n.value=i:n={value:i,done:!1},n}function S(){return{value:void 0,done:!0}}function I(t){return!!M(t)}function b(t){return t&&"function"==typeof t.next}function O(t){var e=M(t);return e&&e.call(t)}function M(t){var e=t&&(Ye&&t[Ye]||t[Qe]);if("function"==typeof e)return e}function D(t){return t&&"number"==typeof t.length}function q(t){return!(!t||!t[er])}function E(){return ir||(ir=new rr([]))}function x(t){var e=Array.isArray(t)?new rr(t):b(t)?new sr(t):I(t)?new ur(t):void 0;if(e)return e.fromEntrySeq();if("object"==typeof t)return new nr(t);throw new TypeError("Expected Array or collection object of [k, v] entries, or keyed object: "+t)}function j(t){var e=A(t);if(e)return e;throw new TypeError("Expected Array or collection object of values: "+t)} -function k(t){var e=A(t);if(e)return e;if("object"==typeof t)return new nr(t);throw new TypeError("Expected Array or collection object of values, or keyed object: "+t)}function A(t){return D(t)?new rr(t):b(t)?new sr(t):I(t)?new ur(t):void 0}function R(t,e){if(t===e||t!==t&&e!==e)return!0;if(!t||!e)return!1;if("function"==typeof t.valueOf&&"function"==typeof e.valueOf){if(t=t.valueOf(),e=e.valueOf(),t===e||t!==t&&e!==e)return!0;if(!t||!e)return!1}return!!(w(t)&&w(e)&&t.equals(e))}function U(t,e){return K([],e||L,t,"",e&&e.length>2?[]:void 0,{"":t})}function K(t,e,r,n,i,o){var u=Array.isArray(r)?$e:T(r)?Ze:null;if(u){if(~t.indexOf(r))throw new TypeError("Cannot convert circular structure to Immutable");t.push(r),i&&""!==n&&i.push(n);var s=e.call(o,n,u(r).map(function(n,o){return K(t,e,n,o,i,r)}),i&&i.slice());return t.pop(),i&&i.pop(),s}return r}function L(t,e){return v(e)?e.toMap():e.toList()}function T(t){return t&&(t.constructor===Object||void 0===t.constructor)}function C(t){return t>>>1&1073741824|3221225471&t}function W(t){if(t===!1||null===t||void 0===t)return 0;if("function"==typeof t.valueOf&&((t=t.valueOf())===!1||null===t||void 0===t))return 0;if(t===!0)return 1;var e=typeof t;if("number"===e){if(t!==t||t===1/0)return 0;var r=0|t;for(r!==t&&(r^=4294967295*t);t>4294967295;)t/=4294967295,r^=t;return C(r)}if("string"===e)return t.length>lr?B(t):J(t);if("function"==typeof t.hashCode)return C(t.hashCode());if("object"===e)return N(t);if("function"==typeof t.toString)return J(""+t);throw Error("Value type "+e+" cannot be hashed.")}function B(t){var e=dr[t];return void 0===e&&(e=J(t),yr===vr&&(yr=0,dr={}),yr++,dr[t]=e),e}function J(t){for(var e=0,r=0;r0)switch(t.nodeType){case 1:return t.uniqueID;case 9:return t.documentElement&&t.documentElement.uniqueID}}function V(t){var e=ft(t);return e._iter=t,e.size=t.size,e.flip=function(){return t},e.reverse=function(){var e=t.reverse.apply(this);return e.flip=function(){return t.reverse()},e},e.has=function(e){return t.includes(e)},e.includes=function(e){return t.has(e)},e.cacheResult=pt,e.__iterateUncached=function(e,r){var n=this;return t.__iterate(function(t,r){return e(r,t,n)!==!1},r)},e.__iteratorUncached=function(e,r){if(e===He){var n=t.__iterator(e,r);return new Fe(function(){var t=n.next();if(!t.done){var e=t.value[0];t.value[0]=t.value[1],t.value[1]=e}return t})}return t.__iterator(e===Ve?Pe:Ve,r)},e}function H(t,e,r){var n=ft(t);return n.size=t.size,n.has=function(e){return t.has(e)},n.get=function(n,i){var o=t.get(n,ke);return o===ke?i:e.call(r,o,n,t)},n.__iterateUncached=function(n,i){var o=this;return t.__iterate(function(t,i,u){return n(e.call(r,t,i,u),i,o)!==!1},i)},n.__iteratorUncached=function(n,i){var o=t.__iterator(He,i);return new Fe(function(){var i=o.next();if(i.done)return i;var u=i.value,s=u[0];return z(n,s,e.call(r,u[1],s,t),i)})},n}function Y(t,e){var r=this,n=ft(t);return n._iter=t,n.size=t.size,n.reverse=function(){return t},t.flip&&(n.flip=function(){var e=V(t);return e.reverse=function(){return t.flip()},e}),n.get=function(r,n){return t.get(e?r:-1-r,n)},n.has=function(r){return t.has(e?r:-1-r)},n.includes=function(e){ -return t.includes(e)},n.cacheResult=pt,n.__iterate=function(r,n){var i=this,u=0;return n&&o(t),t.__iterate(function(t,o){return r(t,e?o:n?i.size-++u:u++,i)},!n)},n.__iterator=function(n,i){var u=0;i&&o(t);var s=t.__iterator(He,!i);return new Fe(function(){var t=s.next();if(t.done)return t;var o=t.value;return z(n,e?o[0]:i?r.size-++u:u++,o[1],t)})},n}function Q(t,e,r,n){var i=ft(t);return n&&(i.has=function(n){var i=t.get(n,ke);return i!==ke&&!!e.call(r,i,n,t)},i.get=function(n,i){var o=t.get(n,ke);return o!==ke&&e.call(r,o,n,t)?o:i}),i.__iterateUncached=function(i,o){var u=this,s=0;return t.__iterate(function(t,o,a){if(e.call(r,t,o,a))return s++,i(t,n?o:s-1,u)},o),s},i.__iteratorUncached=function(i,o){var u=t.__iterator(He,o),s=0;return new Fe(function(){for(;;){var o=u.next();if(o.done)return o;var a=o.value,c=a[0],h=a[1];if(e.call(r,h,c,t))return z(i,n?c:s++,h,o)}})},i}function X(t,e,r){var n=Sr().asMutable();return t.__iterate(function(i,o){n.update(e.call(r,i,o,t),0,function(t){return t+1})}),n.asImmutable()}function F(t,e,r){var n=v(t),i=(g(t)?Br():Sr()).asMutable();t.__iterate(function(o,u){i.update(e.call(r,o,u,t),function(t){return t=t||[],t.push(n?[u,o]:o),t})});var o=ht(t);return i.map(function(e){return at(t,o(e))})}function G(t,e,r,n){var i=t.size;if(a(e,r,i))return t;var o=c(e,i),s=h(r,i);if(o!==o||s!==s)return G(t.toSeq().cacheResult(),e,r,n);var f,p=s-o;p===p&&(f=p<0?0:p);var _=ft(t);return _.size=0===f?f:t.size&&f||void 0,!n&&q(t)&&f>=0&&(_.get=function(e,r){return e=u(this,e),e>=0&&ef)return S();var t=i.next() -;return n||e===Ve||t.done?t:e===Pe?z(e,s-1,void 0,t):z(e,s-1,t.value[1],t)})},_}function Z(t,e,r){var n=ft(t);return n.__iterateUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterate(n,i);var u=0;return t.__iterate(function(t,i,s){return e.call(r,t,i,s)&&++u&&n(t,i,o)}),u},n.__iteratorUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterator(n,i);var u=t.__iterator(He,i),s=!0;return new Fe(function(){if(!s)return S();var t=u.next();if(t.done)return t;var i=t.value,a=i[0],c=i[1];return e.call(r,c,a,o)?n===He?t:z(n,a,c,t):(s=!1,S())})},n}function $(t,e,r,n){var i=ft(t);return i.__iterateUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterate(i,o);var s=!0,a=0;return t.__iterate(function(t,o,c){if(!s||!(s=e.call(r,t,o,c)))return a++,i(t,n?o:a-1,u)}),a},i.__iteratorUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterator(i,o);var s=t.__iterator(He,o),a=!0,c=0;return new Fe(function(){var t,o,h;do{if(t=s.next(),t.done)return n||i===Ve?t:i===Pe?z(i,c++,void 0,t):z(i,c++,t.value[1],t);var f=t.value;o=f[0],h=f[1],a&&(a=e.call(r,h,o,u))}while(a);return i===He?t:z(i,o,h,t)})},i}function tt(t,e){var r=v(t),n=[t].concat(e).map(function(t){return l(t)?r&&(t=Be(t)):t=r?x(t):j(Array.isArray(t)?t:[t]),t}).filter(function(t){return 0!==t.size});if(0===n.length)return t;if(1===n.length){var i=n[0];if(i===t||r&&v(i)||y(t)&&y(i))return i}var o=new rr(n);return r?o=o.toKeyedSeq():y(t)||(o=o.toSetSeq()),o=o.flatten(!0),o.size=n.reduce(function(t,e){if(void 0!==t){var r=e.size;if(void 0!==r)return t+r}},0),o}function et(t,e,r){var n=ft(t);return n.__iterateUncached=function(i,o){function u(t,c){t.__iterate(function(t,o){return(!e||c0}function st(t,e,r,n){var i=ft(t),o=new rr(r).map(function(t){return t.size});return i.size=n?o.max():o.min(),i.__iterate=function(t,e){for(var r,n=this,i=this.__iterator(Ve,e),o=0;!(r=i.next()).done&&t(r.value,o++,n)!==!1;);return o},i.__iteratorUncached=function(t,i){var o=r.map(function(t){return t=We(t),O(i?t.reverse():t)}),u=0,s=!1;return new Fe(function(){var r;return s||(r=o.map(function(t){return t.next()}),s=n?r.every(function(t){return t.done}):r.some(function(t){return t.done})),s?S():z(t,u++,e.apply(null,r.map(function(t){return t.value})))})},i}function at(t,e){return t===e?t:q(t)?e:t.constructor(e)}function ct(t){if(t!==Object(t))throw new TypeError("Expected [K, V] tuple: "+t)}function ht(t){return v(t)?Be:y(t)?Je:Ne}function ft(t){return Object.create((v(t)?Ze:y(t)?$e:tr).prototype)}function pt(){return this._iter.cacheResult?(this._iter.cacheResult(), -this.size=this._iter.size,this):Ge.prototype.cacheResult.call(this)}function _t(t,e){return void 0===t&&void 0===e?0:void 0===t?1:void 0===e?-1:t>e?1:t>>r)&je,s=(0===r?n:n>>>r)&je;return new Mr(e,1<>>=1)u[s]=1&r?e[o++]:void 0;return u[n]=i,new Dr(t,o+1,u)}function xt(t,e,r){for(var n=[],i=0;i>1&1431655765,t=(858993459&t)+(t>>2&858993459),t=t+(t>>4)&252645135,t+=t>>8,127&(t+=t>>16)}function Kt(t,e,r,n){var o=n?t:i(t);return o[e]=r,o}function Lt(t,e,r,n){var i=t.length+1;if(n&&e+1===i)return t[e]=r,t;for(var o=Array(i),u=0,s=0;so?0:o-r,c=u-r;return c>xe&&(c=xe),function(){if(i===c)return Wr;var t=e?--c:i++;return n&&n[t]}}function i(t,n,i){var s,a=t&&t.array,c=i>o?0:o-i>>n,h=1+(u-i>>n);return h>xe&&(h=xe),function(){for(;;){if(s){var t=s();if(t!==Wr)return t;s=null}if(c===h)return Wr;var o=e?--h:c++;s=r(a&&a[o],n-Ee,i+(o<=t.size||r<0)return t.withMutations(function(t){r<0?Yt(t,r).set(0,n):Yt(t,0,r+1).set(r,n)});r+=t._origin;var i=t._tail,o=t._root,s=e(Re);return r>=Xt(t._capacity)?i=Pt(i,t.__ownerID,0,r,n,s):o=Pt(o,t.__ownerID,t._level,r,n,s),s.value?t.__ownerID?(t._root=o,t._tail=i,t.__hash=void 0,t.__altered=!0,t):Bt(t._origin,t._capacity,t._level,o,i):t}function Pt(t,e,n,i,o,u){var s=i>>>n&je,a=t&&s0){var h=t&&t.array[s],f=Pt(h,e,n-Ee,i,o,u);return f===h?t:(c=Vt(t,e),c.array[s]=f,c)}return a&&t.array[s]===o?t:(r(u),c=Vt(t,e),void 0===o&&s===c.array.length-1?c.array.pop():c.array[s]=o,c)}function Vt(t,e){return e&&t&&e===t.ownerID?t:new Tr(t?t.array.slice():[],e)}function Ht(t,e){if(e>=Xt(t._capacity))return t._tail;if(e<1<0;)r=r.array[e>>>n&je],n-=Ee;return r}}function Yt(t,e,r){void 0!==e&&(e|=0),void 0!==r&&(r|=0);var i=t.__ownerID||new n,o=t._origin,u=t._capacity,s=o+e,a=void 0===r?u:r<0?u+r:o+r;if(s===o&&a===u)return t;if(s>=a)return t.clear();for(var c=t._level,h=t._root,f=0;s+f<0;)h=new Tr(h&&h.array.length?[void 0,h]:[],i),c+=Ee,f+=1<=1<p?new Tr([],i):l;if(l&&_>p&&sEe;d-=Ee){var g=p>>>d&je;y=y.array[g]=Vt(y.array[g],i)}y.array[p>>>Ee&je]=l}if(a=_)s-=_,a-=_,c=Ee,h=null,v=v&&v.removeBefore(i,0,s);else if(s>o||_>>c&je;if(m!==_>>>c&je)break;m&&(f+=(1<o&&(h=h.removeBefore(i,c,s-f)),h&&_i&&(i=s.size),l(u)||(s=s.map(function(t){return U(t)})), -n.push(s)}return i>t.size&&(t=t.setSize(i)),At(t,e,n)}function Xt(t){return t>>Ee<=xe&&u.size>=2*o.size?(i=u.filter(function(t,e){return void 0!==t&&s!==e}),n=i.toKeyedSeq().map(function(t){return t[0]}).flip().toMap(),t.__ownerID&&(n.__ownerID=i.__ownerID=t.__ownerID)):(n=o.remove(e),i=s===u.size-1?u.pop():u.set(s,void 0))}else if(a){if(r===u.get(s)[1])return t;n=o,i=u.set(s,[e,r])}else n=o.set(e,u.size),i=u.set(u.size,[e,r]);return t.__ownerID?(t.size=n.size,t._map=n,t._list=i,t.__hash=void 0,t):Gt(n,i)}function te(t){return!(!t||!t[Pr])}function ee(t,e,r,n){var i=Object.create(Vr);return i.size=t,i._head=e,i.__ownerID=r,i.__hash=n,i.__altered=!1,i}function re(){return Hr||(Hr=ee(0))}function ne(t,e){if(t===e)return!0;if(!l(e)||void 0!==t.size&&void 0!==e.size&&t.size!==e.size||void 0!==t.__hash&&void 0!==e.__hash&&t.__hash!==e.__hash||v(t)!==v(e)||y(t)!==y(e)||g(t)!==g(e))return!1;if(0===t.size&&0===e.size)return!0;var r=!d(t);if(g(t)){var n=t.entries();return e.every(function(t,e){var i=n.next().value;return i&&R(i[1],t)&&(r||R(i[0],e))})&&n.next().done}var i=!1;if(void 0===t.size)if(void 0===e.size)"function"==typeof t.cacheResult&&t.cacheResult();else{i=!0;var o=t;t=e,e=o}var u=!0,s=e.__iterate(function(e,n){if(r?!t.has(e):i?!R(e,t.get(n,ke)):!R(t.get(n,ke),e))return u=!1,!1});return u&&t.size===s}function ie(t,e){var r=function(r){t.prototype[r]=e[r]};return Object.keys(e).forEach(r),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(e).forEach(r),t}function oe(t){return!(!t||!t[Qr])}function ue(t,e){return t.__ownerID?(t.size=e.size,t._map=e,t):e===t._map?t:0===e.size?t.__empty():t.__make(e)}function se(t,e){var r=Object.create(Xr);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r} -function ae(){return Fr||(Fr=se(St()))}function ce(t,e,r,n,i,o){return yt(t.size),t.__iterate(function(t,o,u){i?(i=!1,r=t):r=e.call(n,r,t,o,u)},o),r}function he(t,e){return e}function fe(t,e){return[e,t]}function pe(t){return t&&"function"==typeof t.toJS?t.toJS():t}function _e(t){return function(){return!t.apply(this,arguments)}}function le(t){return function(){return-t.apply(this,arguments)}}function ve(){return i(arguments)}function ye(t,e){return te?-1:0}function de(t){if(t.size===1/0)return 0;var e=g(t),r=v(t),n=e?1:0;return ge(t.__iterate(r?e?function(t,e){n=31*n+me(W(t),W(e))|0}:function(t,e){n=n+me(W(t),W(e))|0}:e?function(t){n=31*n+W(t)|0}:function(t){n=n+W(t)|0}),n)}function ge(t,e){return e=ar(e,3432918353),e=ar(e<<15|e>>>-15,461845907),e=ar(e<<13|e>>>-13,5),e=(e+3864292196|0)^t,e=ar(e^e>>>16,2246822507),e=ar(e^e>>>13,3266489909),e=C(e^e>>>16)}function me(t,e){return t^e+2654435769+(t<<6)+(t>>2)|0}function we(t){if("object"!=typeof console||!console.warn)throw Error(t);console.warn(t)}function ze(t,e,r,n){for(var i=lt(r),o=0;o!==i.length;){if(!t||!t.get)return n&&we("Invalid keyPath: Value at ["+i.slice(0,o).map(dt)+"] does not have a .get() method: "+t+"\nThis warning will throw in a future version"),e;if((t=t.get(i[o++],ke))===ke)return e}return t}function Se(t){return oe(t)&&g(t)}function Ie(t,e){var r=Object.create(nn);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function be(){return on||(on=Ie(Zt()))}function Oe(t,e,r){var n=Object.create(Object.getPrototypeOf(t));return n._values=e,n.__ownerID=r,n}function Me(t){return t._name||t.constructor.name||"Record"}function De(t){return x(t._keys.map(function(e){return[e,t.get(e)]}))}function qe(t,e){try{Object.defineProperty(t,e,{get:function(){return this.get(e)},set:function(t){vt(this.__ownerID,"Cannot set on an immutable record."),this.set(e,t)}})}catch(t){}}var Ee=5,xe=1<=n.length){var e=r.next();if(e.done)return e;n[i]=e.value}return z(t,i,n[i++])})},e}($e),ar="function"==typeof Math.imul&&Math.imul(4294967295,2)===-2?Math.imul:function(t,e){t|=0,e|=0;var r=65535&t,n=65535&e;return r*n+((t>>>16)*n+r*(e>>>16)<<16>>>0)|0},cr=Object.isExtensible,hr=function(){try{return Object.defineProperty({},"@",{}),!0}catch(t){return!1}}(),fr="function"==typeof WeakMap;fr&&(or=new WeakMap);var pr=0,_r="__immutablehash__";"function"==typeof Symbol&&(_r=Symbol(_r));var lr=16,vr=255,yr=0,dr={},gr=function(t){function e(t,e){this._iter=t,this._useKeys=e,this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t,e){return this._iter.get(t,e)}, -e.prototype.has=function(t){return this._iter.has(t)},e.prototype.valueSeq=function(){return this._iter.valueSeq()},e.prototype.reverse=function(){var t=this,e=Y(this,!0);return this._useKeys||(e.valueSeq=function(){return t._iter.toSeq().reverse()}),e},e.prototype.map=function(t,e){var r=this,n=H(this,t,e);return this._useKeys||(n.valueSeq=function(){return r._iter.toSeq().map(t,e)}),n},e.prototype.__iterate=function(t,e){var r=this;return this._iter.__iterate(function(e,n){return t(e,n,r)},e)},e.prototype.__iterator=function(t,e){return this._iter.__iterator(t,e)},e}(Ze);gr.prototype[Te]=!0;var mr=function(t){function e(t){this._iter=t,this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.includes=function(t){return this._iter.includes(t)},e.prototype.__iterate=function(t,e){var r=this,n=0;return e&&o(this),this._iter.__iterate(function(i){return t(i,e?r.size-++n:n++,r)},e)},e.prototype.__iterator=function(t,e){var r=this,n=this._iter.__iterator(Ve,e),i=0;return e&&o(this),new Fe(function(){var o=n.next();return o.done?o:z(t,e?r.size-++i:i++,o.value,o)})},e}($e),wr=function(t){function e(t){this._iter=t,this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.has=function(t){return this._iter.includes(t)},e.prototype.__iterate=function(t,e){var r=this;return this._iter.__iterate(function(e){return t(e,e,r)},e)},e.prototype.__iterator=function(t,e){var r=this._iter.__iterator(Ve,e);return new Fe(function(){var e=r.next();return e.done?e:z(t,e.value,e.value,e)})},e}(tr),zr=function(t){function e(t){this._iter=t,this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.entrySeq=function(){return this._iter.toSeq()},e.prototype.__iterate=function(t,e){var r=this;return this._iter.__iterate(function(e){if(e){ct(e);var n=l(e);return t(n?e.get(1):e[1],n?e.get(0):e[0],r)}},e)},e.prototype.__iterator=function(t,e){ -var r=this._iter.__iterator(Ve,e);return new Fe(function(){for(;;){var e=r.next();if(e.done)return e;var n=e.value;if(n){ct(n);var i=l(n);return z(t,i?n.get(0):n[0],i?n.get(1):n[1],e)}}})},e}(Ze);mr.prototype.cacheResult=gr.prototype.cacheResult=wr.prototype.cacheResult=zr.prototype.cacheResult=pt;var Sr=function(t){function e(e){return null===e||void 0===e?St():gt(e)&&!g(e)?e:St().withMutations(function(r){var n=t(e);yt(n.size),n.forEach(function(t,e){return r.set(e,t)})})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return St().withMutations(function(e){for(var r=0;r=t.length)throw Error("Missing value for key: "+t[r]);e.set(t[r],t[r+1])}})},e.prototype.toString=function(){return this.__toString("Map {","}")},e.prototype.get=function(t,e){return this._root?this._root.get(0,void 0,t,e):e},e.prototype.set=function(t,e){return It(this,t,e)},e.prototype.setIn=function(t,e){return this.updateIn(t,ke,function(){return e})},e.prototype.remove=function(t){return It(this,t,ke)},e.prototype.deleteIn=function(t){if(t=[].concat(lt(t)),t.length){var e=t.pop();return this.updateIn(t,function(t){return t&&t.remove(e)})}},e.prototype.deleteAll=function(t){var e=We(t);return 0===e.size?this:this.withMutations(function(t){e.forEach(function(e){return t.remove(e)})})},e.prototype.update=function(t,e,r){return 1===arguments.length?t(this):this.updateIn([t],e,r)},e.prototype.updateIn=function(t,e,r){r||(r=e,e=void 0);var n=Rt(this,lt(t),0,e,r);return n===ke?e:n},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):St()},e.prototype.merge=function(){return xt(this,void 0,arguments)},e.prototype.mergeWith=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return xt(this,t,e)},e.prototype.mergeIn=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1] -;return this.updateIn(t,St(),function(t){return"function"==typeof t.merge?t.merge.apply(t,e):e[e.length-1]})},e.prototype.mergeDeep=function(){return xt(this,jt,arguments)},e.prototype.mergeDeepWith=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return xt(this,kt(t),e)},e.prototype.mergeDeepIn=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return this.updateIn(t,St(),function(t){return"function"==typeof t.mergeDeep?t.mergeDeep.apply(t,e):e[e.length-1]})},e.prototype.sort=function(t){return Br(it(this,t))},e.prototype.sortBy=function(t,e){return Br(it(this,e,t))},e.prototype.withMutations=function(t){var e=this.asMutable();return t(e),e.wasAltered()?e.__ensureOwner(this.__ownerID):this},e.prototype.asMutable=function(){return this.__ownerID?this:this.__ensureOwner(new n)},e.prototype.asImmutable=function(){return this.__ensureOwner()},e.prototype.wasAltered=function(){return this.__altered},e.prototype.__iterator=function(t,e){return new jr(this,t,e)},e.prototype.__iterate=function(t,e){var r=this,n=0;return this._root&&this._root.iterate(function(e){return n++,t(e[1],e[0],r)},e),n},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?zt(this.size,this._root,t,this.__hash):0===this.size?St():(this.__ownerID=t,this.__altered=!1,this)},e}(Be);Sr.isMap=gt;var Ir="@@__IMMUTABLE_MAP__@@",br=Sr.prototype;br[Ir]=!0,br.delete=br.remove,br.removeIn=br.deleteIn,br.removeAll=br.deleteAll,br["@@transducer/init"]=br.asMutable,br["@@transducer/step"]=function(t,e){return t.set(e[0],e[1])},br["@@transducer/result"]=function(t){return t.asImmutable()};var Or=function(t,e){this.ownerID=t,this.entries=e};Or.prototype.get=function(t,e,r,n){for(var i=this.entries,o=0,u=i.length;o=kr)return Dt(t,h,o,u) -;var l=t&&t===this.ownerID,v=l?h:i(h);return _?c?f===p-1?v.pop():v[f]=v.pop():v[f]=[o,u]:v.push([o,u]),l?(this.entries=v,this):new Or(t,v)}};var Mr=function(t,e,r){this.ownerID=t,this.bitmap=e,this.nodes=r};Mr.prototype.get=function(t,e,r,n){void 0===e&&(e=W(r));var i=1<<((0===t?e:e>>>t)&je),o=this.bitmap;return 0==(o&i)?n:this.nodes[Ut(o&i-1)].get(t+Ee,e,r,n)},Mr.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=W(n));var s=(0===e?r:r>>>e)&je,a=1<=Ar)return Et(t,p,c,s,l);if(h&&!l&&2===p.length&&Ot(p[1^f]))return p[1^f];if(h&&l&&1===p.length&&Ot(l))return l;var v=t&&t===this.ownerID,y=h?l?c:c^a:c|a,d=h?l?Kt(p,f,l,v):Tt(p,f,v):Lt(p,f,l,v);return v?(this.bitmap=y,this.nodes=d,this):new Mr(t,y,d)};var Dr=function(t,e,r){this.ownerID=t,this.count=e,this.nodes=r};Dr.prototype.get=function(t,e,r,n){void 0===e&&(e=W(r));var i=(0===t?e:e>>>t)&je,o=this.nodes[i];return o?o.get(t+Ee,e,r,n):n},Dr.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=W(n));var s=(0===e?r:r>>>e)&je,a=i===ke,c=this.nodes,h=c[s];if(a&&!h)return this;var f=bt(h,t,e+Ee,r,n,i,o,u);if(f===h)return this;var p=this.count;if(h){if(!f&&--p0&&i=0&&t0;)e[r]=arguments[r+1];return Qt(this,t,e)},e.prototype.mergeDeep=function(){return Qt(this,jt,arguments)},e.prototype.mergeDeepWith=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Qt(this,kt(t),e)},e.prototype.setSize=function(t){return Yt(this,0,t)},e.prototype.slice=function(t,e){var r=this.size;return a(t,e,r)?this:Yt(this,c(t,r),h(e,r))},e.prototype.__iterator=function(t,e){var r=e?this.size:0,n=Wt(this,e);return new Fe(function(){var i=n();return i===Wr?S():z(t,e?--r:r++,i)})},e.prototype.__iterate=function(t,e){for(var r,n=this,i=e?this.size:0,o=Wt(this,e);(r=o())!==Wr&&t(r,e?--i:i++,n)!==!1;);return i},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Bt(this._origin,this._capacity,this._level,this._root,this._tail,t,this.__hash):0===this.size?Jt():(this.__ownerID=t,this.__altered=!1,this)},e}(Je);Ur.isList=Ct;var Kr="@@__IMMUTABLE_LIST__@@",Lr=Ur.prototype;Lr[Kr]=!0,Lr.delete=Lr.remove,Lr.setIn=br.setIn,Lr.deleteIn=Lr.removeIn=br.removeIn,Lr.update=br.update,Lr.updateIn=br.updateIn,Lr.mergeIn=br.mergeIn, -Lr.mergeDeepIn=br.mergeDeepIn,Lr.withMutations=br.withMutations,Lr.asMutable=br.asMutable,Lr.asImmutable=br.asImmutable,Lr.wasAltered=br.wasAltered,Lr["@@transducer/init"]=Lr.asMutable,Lr["@@transducer/step"]=function(t,e){return t.push(e)},Lr["@@transducer/result"]=br["@@transducer/result"];var Tr=function(t,e){this.array=t,this.ownerID=e};Tr.prototype.removeBefore=function(t,e,r){if(r===e?1<>>e&je;if(n>=this.array.length)return new Tr([],t);var i,o=0===n;if(e>0){var u=this.array[n];if((i=u&&u.removeBefore(t,e-Ee,r))===u&&o)return this}if(o&&!i)return this;var s=Vt(this,t);if(!o)for(var a=0;a>>e&je;if(n>=this.array.length)return this;var i;if(e>0){var o=this.array[n];if((i=o&&o.removeAfter(t,e-Ee,r))===o&&n===this.array.length-1)return this}var u=Vt(this,t);return u.array.splice(n+1),i&&(u.array[n]=i),u};var Cr,Wr={},Br=function(t){function e(t){return null===t||void 0===t?Zt():Ft(t)?t:Zt().withMutations(function(e){var r=Be(t);yt(r.size),r.forEach(function(t,r){return e.set(r,t)})})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("OrderedMap {","}")},e.prototype.get=function(t,e){var r=this._map.get(t);return void 0!==r?this._list.get(r)[1]:e},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._map.clear(),this._list.clear(),this):Zt()},e.prototype.set=function(t,e){return $t(this,t,e)},e.prototype.remove=function(t){return $t(this,t,ke)},e.prototype.wasAltered=function(){return this._map.wasAltered()||this._list.wasAltered()},e.prototype.__iterate=function(t,e){var r=this;return this._list.__iterate(function(e){return e&&t(e[1],e[0],r)},e)},e.prototype.__iterator=function(t,e){return this._list.fromEntrySeq().__iterator(t,e)}, -e.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var e=this._map.__ensureOwner(t),r=this._list.__ensureOwner(t);return t?Gt(e,r,t,this.__hash):0===this.size?Zt():(this.__ownerID=t,this._map=e,this._list=r,this)},e}(Sr);Br.isOrderedMap=Ft,Br.prototype[Te]=!0,Br.prototype.delete=Br.prototype.remove;var Jr,Nr=function(t){function e(t){return null===t||void 0===t?re():te(t)?t:re().pushAll(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("Stack [","]")},e.prototype.get=function(t,e){var r=this._head;for(t=u(this,t);r&&t--;)r=r.next;return r?r.value:e},e.prototype.peek=function(){return this._head&&this._head.value},e.prototype.push=function(){var t=arguments;if(0===arguments.length)return this;for(var e=this.size+arguments.length,r=this._head,n=arguments.length-1;n>=0;n--)r={value:t[n],next:r};return this.__ownerID?(this.size=e,this._head=r,this.__hash=void 0,this.__altered=!0,this):ee(e,r)},e.prototype.pushAll=function(e){if(e=t(e),0===e.size)return this;if(0===this.size&&te(e))return e;yt(e.size);var r=this.size,n=this._head;return e.__iterate(function(t){r++,n={value:t,next:n}},!0),this.__ownerID?(this.size=r,this._head=n,this.__hash=void 0,this.__altered=!0,this):ee(r,n)},e.prototype.pop=function(){return this.slice(1)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):re()},e.prototype.slice=function(e,r){if(a(e,r,this.size))return this;var n=c(e,this.size);if(h(r,this.size)!==this.size)return t.prototype.slice.call(this,e,r);for(var i=this.size-n,o=this._head;n--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):ee(i,o)},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?ee(this.size,this._head,t,this.__hash):0===this.size?re():(this.__ownerID=t,this.__altered=!1,this)}, -e.prototype.__iterate=function(t,e){var r=this;if(e)return new rr(this.toArray()).__iterate(function(e,n){return t(e,n,r)},e);for(var n=0,i=this._head;i&&t(i.value,n++,r)!==!1;)i=i.next;return n},e.prototype.__iterator=function(t,e){if(e)return new rr(this.toArray()).__iterator(t,e);var r=0,n=this._head;return new Fe(function(){if(n){var e=n.value;return n=n.next,z(t,r++,e)}return S()})},e}(Je);Nr.isStack=te;var Pr="@@__IMMUTABLE_STACK__@@",Vr=Nr.prototype;Vr[Pr]=!0,Vr.withMutations=br.withMutations,Vr.asMutable=br.asMutable,Vr.asImmutable=br.asImmutable,Vr.wasAltered=br.wasAltered,Vr.shift=Vr.pop,Vr.unshift=Vr.push,Vr.unshiftAll=Vr.pushAll,Vr["@@transducer/init"]=Vr.asMutable,Vr["@@transducer/step"]=function(t,e){return t.unshift(e)},Vr["@@transducer/result"]=br["@@transducer/result"];var Hr,Yr=function(t){function e(e){return null===e||void 0===e?ae():oe(e)&&!g(e)?e:ae().withMutations(function(r){var n=t(e);yt(n.size),n.forEach(function(t){return r.add(t)})})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(Be(t).keySeq())},e.intersect=function(t){return t=We(t).toArray(),t.length?Xr.intersect.apply(e(t.pop()),t):ae()},e.union=function(t){return t=We(t).toArray(),t.length?Xr.union.apply(e(t.pop()),t):ae()},e.prototype.toString=function(){return this.__toString("Set {","}")},e.prototype.has=function(t){return this._map.has(t)},e.prototype.add=function(t){return ue(this,this._map.set(t,t))},e.prototype.remove=function(t){return ue(this,this._map.remove(t))},e.prototype.clear=function(){return ue(this,this._map.clear())},e.prototype.union=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return e=e.filter(function(t){return 0!==t.size}),0===e.length?this:0!==this.size||this.__ownerID||1!==e.length?this.withMutations(function(r){for(var n=0;n0;)e[r]=arguments[r+1];return this.union.apply(this,e)},e.prototype.sort=function(t){return rn(it(this,t))},e.prototype.sortBy=function(t,e){return rn(it(this,e,t))},e.prototype.wasAltered=function(){return this._map.wasAltered()},e.prototype.__iterate=function(t,e){var r=this;return this._map.__iterate(function(e){return t(e,e,r)},e)},e.prototype.__iterator=function(t,e){return this._map.__iterator(t,e)},e.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var e=this._map.__ensureOwner(t);return t?this.__make(e,t):0===this.size?this.__empty():(this.__ownerID=t,this._map=e,this)},e}(Ne);Yr.isSet=oe;var Qr="@@__IMMUTABLE_SET__@@",Xr=Yr.prototype;Xr[Qr]=!0,Xr.delete=Xr.remove,Xr.mergeDeep=Xr.merge,Xr.mergeDeepWith=Xr.mergeWith,Xr.withMutations=br.withMutations,Xr.asMutable=br.asMutable,Xr.asImmutable=br.asImmutable,Xr["@@transducer/init"]=Xr.asMutable,Xr["@@transducer/step"]=function(t,e){return t.add(e)},Xr["@@transducer/result"]=br["@@transducer/result"],Xr.__empty=ae,Xr.__make=se;var Fr,Gr,Zr=function(t){function e(t,r,n){if(!(this instanceof e))return new e(t,r,n);if(vt(0!==n,"Cannot step a Range by 0"),t=t||0,void 0===r&&(r=1/0),n=void 0===n?1:Math.abs(n),r=0&&e=0&&rthis.size?e:this.find(function(e,r){return r===t},void 0,e)},has:function(t){return(t=u(this,t))>=0&&(void 0!==this.size?this.size===1/0||t>>1&1073741824|3221225471&t}function K(t){if(t===!1||null===t||void 0===t)return 0;if("function"==typeof t.valueOf&&((t=t.valueOf())===!1||null===t||void 0===t))return 0;if(t===!0)return 1;var e=typeof t;if("number"===e){if(t!==t||t===1/0)return 0;var r=0|t;for(r!==t&&(r^=4294967295*t);t>4294967295;)t/=4294967295,r^=t;return U(r)}if("string"===e)return t.length>lr?L(t):T(t);if("function"==typeof t.hashCode)return U(t.hashCode());if("object"===e)return C(t);if("function"==typeof t.toString)return T(""+t);throw Error("Value type "+e+" cannot be hashed.")}function L(t){var e=dr[t];return void 0===e&&(e=T(t),yr===vr&&(yr=0,dr={}),yr++,dr[t]=e),e}function T(t){for(var e=0,r=0;r0)switch(t.nodeType){case 1:return t.uniqueID;case 9:return t.documentElement&&t.documentElement.uniqueID}}function B(t){var e=st(t);return e._iter=t,e.size=t.size,e.flip=function(){return t},e.reverse=function(){var e=t.reverse.apply(this);return e.flip=function(){return t.reverse()},e},e.has=function(e){return t.includes(e)},e.includes=function(e){return t.has(e)},e.cacheResult=at,e.__iterateUncached=function(e,r){var n=this;return t.__iterate(function(t,r){return e(r,t,n)!==!1},r)},e.__iteratorUncached=function(e,r){if(e===He){var n=t.__iterator(e,r);return new Fe(function(){var t=n.next();if(!t.done){var e=t.value[0];t.value[0]=t.value[1],t.value[1]=e}return t})}return t.__iterator(e===Ve?Pe:Ve,r)},e}function J(t,e,r){var n=st(t);return n.size=t.size,n.has=function(e){return t.has(e)},n.get=function(n,i){var o=t.get(n,ke);return o===ke?i:e.call(r,o,n,t)},n.__iterateUncached=function(n,i){var o=this;return t.__iterate(function(t,i,u){return n(e.call(r,t,i,u),i,o)!==!1},i)},n.__iteratorUncached=function(n,i){var o=t.__iterator(He,i);return new Fe(function(){var i=o.next();if(i.done)return i;var u=i.value,s=u[0];return z(n,s,e.call(r,u[1],s,t),i)})},n}function N(t,e){var r=this,n=st(t);return n._iter=t,n.size=t.size,n.reverse=function(){return t},t.flip&&(n.flip=function(){var e=B(t);return e.reverse=function(){return t.flip()},e}),n.get=function(r,n){return t.get(e?r:-1-r,n)},n.has=function(r){return t.has(e?r:-1-r)},n.includes=function(e){return t.includes(e)},n.cacheResult=at,n.__iterate=function(r,n){var i=this,u=0;return n&&o(t),t.__iterate(function(t,o){return r(t,e?o:n?i.size-++u:u++,i)},!n)},n.__iterator=function(n,i){var u=0;i&&o(t);var s=t.__iterator(He,!i);return new Fe(function(){var t=s.next();if(t.done)return t;var o=t.value;return z(n,e?o[0]:i?r.size-++u:u++,o[1],t)})},n}function P(t,e,r,n){var i=st(t);return n&&(i.has=function(n){var i=t.get(n,ke);return i!==ke&&!!e.call(r,i,n,t)},i.get=function(n,i){var o=t.get(n,ke);return o!==ke&&e.call(r,o,n,t)?o:i}), +i.__iterateUncached=function(i,o){var u=this,s=0;return t.__iterate(function(t,o,a){if(e.call(r,t,o,a))return s++,i(t,n?o:s-1,u)},o),s},i.__iteratorUncached=function(i,o){var u=t.__iterator(He,o),s=0;return new Fe(function(){for(;;){var o=u.next();if(o.done)return o;var a=o.value,c=a[0],h=a[1];if(e.call(r,h,c,t))return z(i,n?c:s++,h,o)}})},i}function V(t,e,r){var n=Sr().asMutable();return t.__iterate(function(i,o){n.update(e.call(r,i,o,t),0,function(t){return t+1})}),n.asImmutable()}function H(t,e,r){var n=v(t),i=(g(t)?Br():Sr()).asMutable();t.__iterate(function(o,u){i.update(e.call(r,o,u,t),function(t){return t=t||[],t.push(n?[u,o]:o),t})});var o=ut(t);return i.map(function(e){return it(t,o(e))})}function Y(t,e,r,n){var i=t.size;if(a(e,r,i))return t;var o=c(e,i),s=h(r,i);if(o!==o||s!==s)return Y(t.toSeq().cacheResult(),e,r,n);var f,p=s-o;p===p&&(f=p<0?0:p);var _=st(t);return _.size=0===f?f:t.size&&f||void 0,!n&&q(t)&&f>=0&&(_.get=function(e,r){return e=u(this,e),e>=0&&ef)return S();var t=i.next();return n||e===Ve||t.done?t:e===Pe?z(e,s-1,void 0,t):z(e,s-1,t.value[1],t)})},_}function Q(t,e,r){var n=st(t);return n.__iterateUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterate(n,i);var u=0;return t.__iterate(function(t,i,s){return e.call(r,t,i,s)&&++u&&n(t,i,o)}),u},n.__iteratorUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterator(n,i);var u=t.__iterator(He,i),s=!0;return new Fe(function(){if(!s)return S();var t=u.next();if(t.done)return t;var i=t.value,a=i[0],c=i[1];return e.call(r,c,a,o)?n===He?t:z(n,a,c,t):(s=!1,S())})},n} +function X(t,e,r,n){var i=st(t);return i.__iterateUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterate(i,o);var s=!0,a=0;return t.__iterate(function(t,o,c){if(!s||!(s=e.call(r,t,o,c)))return a++,i(t,n?o:a-1,u)}),a},i.__iteratorUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterator(i,o);var s=t.__iterator(He,o),a=!0,c=0;return new Fe(function(){var t,o,h;do{if(t=s.next(),t.done)return n||i===Ve?t:i===Pe?z(i,c++,void 0,t):z(i,c++,t.value[1],t);var f=t.value;o=f[0],h=f[1],a&&(a=e.call(r,h,o,u))}while(a);return i===He?t:z(i,o,h,t)})},i}function F(t,e){var r=v(t),n=[t].concat(e).map(function(t){return l(t)?r&&(t=Be(t)):t=r?x(t):j(Array.isArray(t)?t:[t]),t}).filter(function(t){return 0!==t.size});if(0===n.length)return t;if(1===n.length){var i=n[0];if(i===t||r&&v(i)||y(t)&&y(i))return i}var o=new rr(n);return r?o=o.toKeyedSeq():y(t)||(o=o.toSetSeq()),o=o.flatten(!0),o.size=n.reduce(function(t,e){if(void 0!==t){var r=e.size;if(void 0!==r)return t+r}},0),o}function G(t,e,r){var n=st(t);return n.__iterateUncached=function(i,o){function u(t,c){t.__iterate(function(t,o){return(!e||c0}function nt(t,e,r,n){var i=st(t),o=new rr(r).map(function(t){return t.size});return i.size=n?o.max():o.min(),i.__iterate=function(t,e){for(var r,n=this,i=this.__iterator(Ve,e),o=0;!(r=i.next()).done&&t(r.value,o++,n)!==!1;);return o},i.__iteratorUncached=function(t,i){var o=r.map(function(t){return t=We(t),O(i?t.reverse():t)}),u=0,s=!1;return new Fe(function(){var r;return s||(r=o.map(function(t){return t.next()}),s=n?r.every(function(t){return t.done}):r.some(function(t){return t.done})),s?S():z(t,u++,e.apply(null,r.map(function(t){return t.value})))})},i}function it(t,e){return t===e?t:q(t)?e:t.constructor(e)}function ot(t){if(t!==Object(t))throw new TypeError("Expected [K, V] tuple: "+t)}function ut(t){return v(t)?Be:y(t)?Je:Ne}function st(t){return Object.create((v(t)?Ze:y(t)?$e:tr).prototype)}function at(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size,this):Ge.prototype.cacheResult.call(this)}function ct(t,e){return void 0===t&&void 0===e?0:void 0===t?1:void 0===e?-1:t>e?1:t>>r)&je,s=(0===r?n:n>>>r)&je;return new Mr(e,1<>>=1)u[s]=1&r?e[o++]:void 0;return u[n]=i,new Dr(t,o+1,u)}function Mt(t,e,r){for(var n=[],i=0;i>1&1431655765,t=(858993459&t)+(t>>2&858993459),t=t+(t>>4)&252645135,t+=t>>8,127&(t+=t>>16)}function kt(t,e,r,n){var o=n?t:i(t);return o[e]=r,o}function At(t,e,r,n){var i=t.length+1;if(n&&e+1===i)return t[e]=r,t;for(var o=Array(i),u=0,s=0;so?0:o-r,c=u-r;return c>xe&&(c=xe),function(){if(i===c)return Wr;var t=e?--c:i++;return n&&n[t]}}function i(t,n,i){var s,a=t&&t.array,c=i>o?0:o-i>>n,h=1+(u-i>>n);return h>xe&&(h=xe),function(){for(;;){if(s){var t=s();if(t!==Wr)return t;s=null}if(c===h)return Wr;var o=e?--h:c++;s=r(a&&a[o],n-Ee,i+(o<=t.size||r<0)return t.withMutations(function(t){r<0?Nt(t,r).set(0,n):Nt(t,0,r+1).set(r,n)});r+=t._origin;var i=t._tail,o=t._root,s=e(Re);return r>=Vt(t._capacity)?i=Wt(i,t.__ownerID,0,r,n,s):o=Wt(o,t.__ownerID,t._level,r,n,s),s.value?t.__ownerID?(t._root=o,t._tail=i,t.__hash=void 0,t.__altered=!0,t):Lt(t._origin,t._capacity,t._level,o,i):t}function Wt(t,e,n,i,o,u){var s=i>>>n&je,a=t&&s0){var h=t&&t.array[s],f=Wt(h,e,n-Ee,i,o,u);return f===h?t:(c=Bt(t,e), +c.array[s]=f,c)}return a&&t.array[s]===o?t:(r(u),c=Bt(t,e),void 0===o&&s===c.array.length-1?c.array.pop():c.array[s]=o,c)}function Bt(t,e){return e&&t&&e===t.ownerID?t:new Tr(t?t.array.slice():[],e)}function Jt(t,e){if(e>=Vt(t._capacity))return t._tail;if(e<1<0;)r=r.array[e>>>n&je],n-=Ee;return r}}function Nt(t,e,r){void 0!==e&&(e|=0),void 0!==r&&(r|=0);var i=t.__ownerID||new n,o=t._origin,u=t._capacity,s=o+e,a=void 0===r?u:r<0?u+r:o+r;if(s===o&&a===u)return t;if(s>=a)return t.clear();for(var c=t._level,h=t._root,f=0;s+f<0;)h=new Tr(h&&h.array.length?[void 0,h]:[],i),c+=Ee,f+=1<=1<p?new Tr([],i):l;if(l&&_>p&&sEe;d-=Ee){var g=p>>>d&je;y=y.array[g]=Bt(y.array[g],i)}y.array[p>>>Ee&je]=l}if(a=_)s-=_,a-=_,c=Ee,h=null,v=v&&v.removeBefore(i,0,s);else if(s>o||_>>c&je;if(m!==_>>>c&je)break;m&&(f+=(1<o&&(h=h.removeBefore(i,c,s-f)),h&&_i&&(i=u.size),n.push(u)}return i>t.size&&(t=t.setSize(i)),Et(t,e,n)}function Vt(t){return t>>Ee<=xe&&u.size>=2*o.size?(i=u.filter(function(t,e){return void 0!==t&&s!==e}),n=i.toKeyedSeq().map(function(t){return t[0]}).flip().toMap(),t.__ownerID&&(n.__ownerID=i.__ownerID=t.__ownerID)):(n=o.remove(e), +i=s===u.size-1?u.pop():u.set(s,void 0))}else if(a){if(r===u.get(s)[1])return t;n=o,i=u.set(s,[e,r])}else n=o.set(e,u.size),i=u.set(u.size,[e,r]);return t.__ownerID?(t.size=n.size,t._map=n,t._list=i,t.__hash=void 0,t):Yt(n,i)}function Ft(t){return!(!t||!t[Pr])}function Gt(t,e,r,n){var i=Object.create(Vr);return i.size=t,i._head=e,i.__ownerID=r,i.__hash=n,i.__altered=!1,i}function Zt(){return Hr||(Hr=Gt(0))}function $t(t,e){if(t===e)return!0;if(!l(e)||void 0!==t.size&&void 0!==e.size&&t.size!==e.size||void 0!==t.__hash&&void 0!==e.__hash&&t.__hash!==e.__hash||v(t)!==v(e)||y(t)!==y(e)||g(t)!==g(e))return!1;if(0===t.size&&0===e.size)return!0;var r=!d(t);if(g(t)){var n=t.entries();return e.every(function(t,e){var i=n.next().value;return i&&R(i[1],t)&&(r||R(i[0],e))})&&n.next().done}var i=!1;if(void 0===t.size)if(void 0===e.size)"function"==typeof t.cacheResult&&t.cacheResult();else{i=!0;var o=t;t=e,e=o}var u=!0,s=e.__iterate(function(e,n){if(r?!t.has(e):i?!R(e,t.get(n,ke)):!R(t.get(n,ke),e))return u=!1,!1});return u&&t.size===s}function te(t,e){var r=function(r){t.prototype[r]=e[r]};return Object.keys(e).forEach(r),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(e).forEach(r),t}function ee(t){return!(!t||!t[Qr])}function re(t,e){return t.__ownerID?(t.size=e.size,t._map=e,t):e===t._map?t:0===e.size?t.__empty():t.__make(e)}function ne(t,e){var r=Object.create(Xr);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function ie(){return Fr||(Fr=ne(gt()))}function oe(t,e,r,n,i,o){return pt(t.size),t.__iterate(function(t,o,u){i?(i=!1,r=t):r=e.call(n,r,t,o,u)},o),r}function ue(t,e){return e}function se(t,e){return[e,t]}function ae(t){return t&&"function"==typeof t.toJS?t.toJS():t}function ce(t){return function(){return!t.apply(this,arguments)}}function he(t){return function(){return-t.apply(this,arguments)}}function fe(){return i(arguments)}function pe(t,e){return te?-1:0}function _e(t){if(t.size===1/0)return 0;var e=g(t),r=v(t),n=e?1:0;return le(t.__iterate(r?e?function(t,e){n=31*n+ve(K(t),K(e))|0 +}:function(t,e){n=n+ve(K(t),K(e))|0}:e?function(t){n=31*n+K(t)|0}:function(t){n=n+K(t)|0}),n)}function le(t,e){return e=ar(e,3432918353),e=ar(e<<15|e>>>-15,461845907),e=ar(e<<13|e>>>-13,5),e=(e+3864292196|0)^t,e=ar(e^e>>>16,2246822507),e=ar(e^e>>>13,3266489909),e=U(e^e>>>16)}function ve(t,e){return t^e+2654435769+(t<<6)+(t>>2)|0}function ye(t){if("object"!=typeof console||!console.warn)throw Error(t);console.warn(t)}function de(t,e,r,n){for(var i=ht(r),o=0;o!==i.length;){if(!t||!t.get)return n&&ye("Invalid keyPath: Value at ["+i.slice(0,o).map(_t)+"] does not have a .get() method: "+t+"\nThis warning will throw in a future version"),e;if((t=t.get(i[o++],ke))===ke)return e}return t}function ge(t){return ee(t)&&g(t)}function me(t,e){var r=Object.create(nn);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function we(){return on||(on=me(Qt()))}function ze(t,e,r){var n=Object.create(Object.getPrototypeOf(t));return n._values=e,n.__ownerID=r,n}function Se(t){return t._name||t.constructor.name||"Record"}function Ie(t){return x(t._keys.map(function(e){return[e,t.get(e)]}))}function be(t,e){try{Object.defineProperty(t,e,{get:function(){return this.get(e)},set:function(t){ft(this.__ownerID,"Cannot set on an immutable record."),this.set(e,t)}})}catch(t){}}function Oe(t,e){return Me([],e||De,t,"",e&&e.length>2?[]:void 0,{"":t})}function Me(t,e,r,n,i,o){var u=Array.isArray(r)?$e:qe(r)?Ze:null;if(u){if(~t.indexOf(r))throw new TypeError("Cannot convert circular structure to Immutable");t.push(r),i&&""!==n&&i.push(n);var s=e.call(o,n,u(r).map(function(n,o){return Me(t,e,n,o,i,r)}),i&&i.slice());return t.pop(),i&&i.pop(),s}return r}function De(t,e){return v(e)?e.toMap():e.toList()}function qe(t){return t&&(t.constructor===Object||void 0===t.constructor)}var Ee=5,xe=1<=n.length){var e=r.next();if(e.done)return e;n[i]=e.value}return z(t,i,n[i++])})},e}($e),ar="function"==typeof Math.imul&&Math.imul(4294967295,2)===-2?Math.imul:function(t,e){t|=0,e|=0;var r=65535&t,n=65535&e;return r*n+((t>>>16)*n+r*(e>>>16)<<16>>>0)|0},cr=Object.isExtensible,hr=function(){try{return Object.defineProperty({},"@",{}),!0}catch(t){return!1}}(),fr="function"==typeof WeakMap;fr&&(or=new WeakMap);var pr=0,_r="__immutablehash__";"function"==typeof Symbol&&(_r=Symbol(_r));var lr=16,vr=255,yr=0,dr={},gr=function(t){function e(t,e){this._iter=t,this._useKeys=e,this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t,e){return this._iter.get(t,e)},e.prototype.has=function(t){return this._iter.has(t)},e.prototype.valueSeq=function(){return this._iter.valueSeq()},e.prototype.reverse=function(){ +var t=this,e=N(this,!0);return this._useKeys||(e.valueSeq=function(){return t._iter.toSeq().reverse()}),e},e.prototype.map=function(t,e){var r=this,n=J(this,t,e);return this._useKeys||(n.valueSeq=function(){return r._iter.toSeq().map(t,e)}),n},e.prototype.__iterate=function(t,e){var r=this;return this._iter.__iterate(function(e,n){return t(e,n,r)},e)},e.prototype.__iterator=function(t,e){return this._iter.__iterator(t,e)},e}(Ze);gr.prototype[Te]=!0;var mr=function(t){function e(t){this._iter=t,this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.includes=function(t){return this._iter.includes(t)},e.prototype.__iterate=function(t,e){var r=this,n=0;return e&&o(this),this._iter.__iterate(function(i){return t(i,e?r.size-++n:n++,r)},e)},e.prototype.__iterator=function(t,e){var r=this,n=this._iter.__iterator(Ve,e),i=0;return e&&o(this),new Fe(function(){var o=n.next();return o.done?o:z(t,e?r.size-++i:i++,o.value,o)})},e}($e),wr=function(t){function e(t){this._iter=t,this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.has=function(t){return this._iter.includes(t)},e.prototype.__iterate=function(t,e){var r=this;return this._iter.__iterate(function(e){return t(e,e,r)},e)},e.prototype.__iterator=function(t,e){var r=this._iter.__iterator(Ve,e);return new Fe(function(){var e=r.next();return e.done?e:z(t,e.value,e.value,e)})},e}(tr),zr=function(t){function e(t){this._iter=t,this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.entrySeq=function(){return this._iter.toSeq()},e.prototype.__iterate=function(t,e){var r=this;return this._iter.__iterate(function(e){if(e){ot(e);var n=l(e);return t(n?e.get(1):e[1],n?e.get(0):e[0],r)}},e)},e.prototype.__iterator=function(t,e){var r=this._iter.__iterator(Ve,e);return new Fe(function(){for(;;){var e=r.next();if(e.done)return e;var n=e.value;if(n){ot(n);var i=l(n) +;return z(t,i?n.get(0):n[0],i?n.get(1):n[1],e)}}})},e}(Ze);mr.prototype.cacheResult=gr.prototype.cacheResult=wr.prototype.cacheResult=zr.prototype.cacheResult=at;var Sr=function(t){function e(e){return null===e||void 0===e?gt():lt(e)&&!g(e)?e:gt().withMutations(function(r){var n=t(e);pt(n.size),n.forEach(function(t,e){return r.set(e,t)})})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return gt().withMutations(function(e){for(var r=0;r=t.length)throw Error("Missing value for key: "+t[r]);e.set(t[r],t[r+1])}})},e.prototype.toString=function(){return this.__toString("Map {","}")},e.prototype.get=function(t,e){return this._root?this._root.get(0,void 0,t,e):e},e.prototype.set=function(t,e){return mt(this,t,e)},e.prototype.setIn=function(t,e){return this.updateIn(t,ke,function(){return e})},e.prototype.remove=function(t){return mt(this,t,ke)},e.prototype.deleteIn=function(t){if(t=[].concat(ht(t)),t.length){var e=t.pop();return this.updateIn(t,function(t){return t&&t.remove(e)})}},e.prototype.deleteAll=function(t){var e=We(t);return 0===e.size?this:this.withMutations(function(t){e.forEach(function(e){return t.remove(e)})})},e.prototype.update=function(t,e,r){return 1===arguments.length?t(this):this.updateIn([t],e,r)},e.prototype.updateIn=function(t,e,r){r||(r=e,e=void 0);var n=xt(this,ht(t),0,e,r);return n===ke?e:n},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):gt()},e.prototype.merge=function(){return Mt(this,void 0,arguments)},e.prototype.mergeWith=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Mt(this,t,e)},e.prototype.mergeIn=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return this.updateIn(t,gt(),function(t){return"function"==typeof t.merge?t.merge.apply(t,e):e[e.length-1]})},e.prototype.mergeDeep=function(){ +return Mt(this,Dt,arguments)},e.prototype.mergeDeepWith=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Mt(this,qt(t),e)},e.prototype.mergeDeepIn=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return this.updateIn(t,gt(),function(t){return"function"==typeof t.mergeDeep?t.mergeDeep.apply(t,e):e[e.length-1]})},e.prototype.sort=function(t){return Br(tt(this,t))},e.prototype.sortBy=function(t,e){return Br(tt(this,e,t))},e.prototype.withMutations=function(t){var e=this.asMutable();return t(e),e.wasAltered()?e.__ensureOwner(this.__ownerID):this},e.prototype.asMutable=function(){return this.__ownerID?this:this.__ensureOwner(new n)},e.prototype.asImmutable=function(){return this.__ensureOwner()},e.prototype.wasAltered=function(){return this.__altered},e.prototype.__iterator=function(t,e){return new jr(this,t,e)},e.prototype.__iterate=function(t,e){var r=this,n=0;return this._root&&this._root.iterate(function(e){return n++,t(e[1],e[0],r)},e),n},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?dt(this.size,this._root,t,this.__hash):0===this.size?gt():(this.__ownerID=t,this.__altered=!1,this)},e}(Be);Sr.isMap=lt;var Ir="@@__IMMUTABLE_MAP__@@",br=Sr.prototype;br[Ir]=!0,br.delete=br.remove,br.removeIn=br.deleteIn,br.removeAll=br.deleteAll,br["@@transducer/init"]=br.asMutable,br["@@transducer/step"]=function(t,e){return t.set(e[0],e[1])},br["@@transducer/result"]=function(t){return t.asImmutable()};var Or=function(t,e){this.ownerID=t,this.entries=e};Or.prototype.get=function(t,e,r,n){for(var i=this.entries,o=0,u=i.length;o=kr)return It(t,h,o,u);var l=t&&t===this.ownerID,v=l?h:i(h);return _?c?f===p-1?v.pop():v[f]=v.pop():v[f]=[o,u]:v.push([o,u]),l?(this.entries=v,this):new Or(t,v)}} +;var Mr=function(t,e,r){this.ownerID=t,this.bitmap=e,this.nodes=r};Mr.prototype.get=function(t,e,r,n){void 0===e&&(e=K(r));var i=1<<((0===t?e:e>>>t)&je),o=this.bitmap;return 0==(o&i)?n:this.nodes[jt(o&i-1)].get(t+Ee,e,r,n)},Mr.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=K(n));var s=(0===e?r:r>>>e)&je,a=1<=Ar)return Ot(t,p,c,s,l);if(h&&!l&&2===p.length&&zt(p[1^f]))return p[1^f];if(h&&l&&1===p.length&&zt(l))return l;var v=t&&t===this.ownerID,y=h?l?c:c^a:c|a,d=h?l?kt(p,f,l,v):Rt(p,f,v):At(p,f,l,v);return v?(this.bitmap=y,this.nodes=d,this):new Mr(t,y,d)};var Dr=function(t,e,r){this.ownerID=t,this.count=e,this.nodes=r};Dr.prototype.get=function(t,e,r,n){void 0===e&&(e=K(r));var i=(0===t?e:e>>>t)&je,o=this.nodes[i];return o?o.get(t+Ee,e,r,n):n},Dr.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=K(n));var s=(0===e?r:r>>>e)&je,a=i===ke,c=this.nodes,h=c[s];if(a&&!h)return this;var f=wt(h,t,e+Ee,r,n,i,o,u);if(f===h)return this;var p=this.count;if(h){if(!f&&--p0&&i=0&&t0;)e[r]=arguments[r+1];return Pt(this,t,e)},e.prototype.mergeDeep=function(){return Pt(this,Dt,arguments)},e.prototype.mergeDeepWith=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Pt(this,qt(t),e)},e.prototype.setSize=function(t){return Nt(this,0,t)},e.prototype.slice=function(t,e){var r=this.size;return a(t,e,r)?this:Nt(this,c(t,r),h(e,r))},e.prototype.__iterator=function(t,e){var r=e?this.size:0,n=Kt(this,e);return new Fe(function(){var i=n();return i===Wr?S():z(t,e?--r:r++,i)})},e.prototype.__iterate=function(t,e){for(var r,n=this,i=e?this.size:0,o=Kt(this,e);(r=o())!==Wr&&t(r,e?--i:i++,n)!==!1;);return i},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Lt(this._origin,this._capacity,this._level,this._root,this._tail,t,this.__hash):0===this.size?Tt():(this.__ownerID=t,this.__altered=!1,this)},e}(Je);Ur.isList=Ut;var Kr="@@__IMMUTABLE_LIST__@@",Lr=Ur.prototype;Lr[Kr]=!0,Lr.delete=Lr.remove,Lr.setIn=br.setIn,Lr.deleteIn=Lr.removeIn=br.removeIn,Lr.update=br.update,Lr.updateIn=br.updateIn,Lr.mergeIn=br.mergeIn,Lr.mergeDeepIn=br.mergeDeepIn,Lr.withMutations=br.withMutations,Lr.asMutable=br.asMutable,Lr.asImmutable=br.asImmutable,Lr.wasAltered=br.wasAltered, +Lr["@@transducer/init"]=Lr.asMutable,Lr["@@transducer/step"]=function(t,e){return t.push(e)},Lr["@@transducer/result"]=br["@@transducer/result"];var Tr=function(t,e){this.array=t,this.ownerID=e};Tr.prototype.removeBefore=function(t,e,r){if(r===e?1<>>e&je;if(n>=this.array.length)return new Tr([],t);var i,o=0===n;if(e>0){var u=this.array[n];if((i=u&&u.removeBefore(t,e-Ee,r))===u&&o)return this}if(o&&!i)return this;var s=Bt(this,t);if(!o)for(var a=0;a>>e&je;if(n>=this.array.length)return this;var i;if(e>0){var o=this.array[n];if((i=o&&o.removeAfter(t,e-Ee,r))===o&&n===this.array.length-1)return this}var u=Bt(this,t);return u.array.splice(n+1),i&&(u.array[n]=i),u};var Cr,Wr={},Br=function(t){function e(t){return null===t||void 0===t?Qt():Ht(t)?t:Qt().withMutations(function(e){var r=Be(t);pt(r.size),r.forEach(function(t,r){return e.set(r,t)})})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("OrderedMap {","}")},e.prototype.get=function(t,e){var r=this._map.get(t);return void 0!==r?this._list.get(r)[1]:e},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._map.clear(),this._list.clear(),this):Qt()},e.prototype.set=function(t,e){return Xt(this,t,e)},e.prototype.remove=function(t){return Xt(this,t,ke)},e.prototype.wasAltered=function(){return this._map.wasAltered()||this._list.wasAltered()},e.prototype.__iterate=function(t,e){var r=this;return this._list.__iterate(function(e){return e&&t(e[1],e[0],r)},e)},e.prototype.__iterator=function(t,e){return this._list.fromEntrySeq().__iterator(t,e)},e.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var e=this._map.__ensureOwner(t),r=this._list.__ensureOwner(t) +;return t?Yt(e,r,t,this.__hash):0===this.size?Qt():(this.__ownerID=t,this._map=e,this._list=r,this)},e}(Sr);Br.isOrderedMap=Ht,Br.prototype[Te]=!0,Br.prototype.delete=Br.prototype.remove;var Jr,Nr=function(t){function e(t){return null===t||void 0===t?Zt():Ft(t)?t:Zt().pushAll(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("Stack [","]")},e.prototype.get=function(t,e){var r=this._head;for(t=u(this,t);r&&t--;)r=r.next;return r?r.value:e},e.prototype.peek=function(){return this._head&&this._head.value},e.prototype.push=function(){var t=arguments;if(0===arguments.length)return this;for(var e=this.size+arguments.length,r=this._head,n=arguments.length-1;n>=0;n--)r={value:t[n],next:r};return this.__ownerID?(this.size=e,this._head=r,this.__hash=void 0,this.__altered=!0,this):Gt(e,r)},e.prototype.pushAll=function(e){if(e=t(e),0===e.size)return this;if(0===this.size&&Ft(e))return e;pt(e.size);var r=this.size,n=this._head;return e.__iterate(function(t){r++,n={value:t,next:n}},!0),this.__ownerID?(this.size=r,this._head=n,this.__hash=void 0,this.__altered=!0,this):Gt(r,n)},e.prototype.pop=function(){return this.slice(1)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):Zt()},e.prototype.slice=function(e,r){if(a(e,r,this.size))return this;var n=c(e,this.size);if(h(r,this.size)!==this.size)return t.prototype.slice.call(this,e,r);for(var i=this.size-n,o=this._head;n--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):Gt(i,o)},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Gt(this.size,this._head,t,this.__hash):0===this.size?Zt():(this.__ownerID=t,this.__altered=!1,this)},e.prototype.__iterate=function(t,e){var r=this;if(e)return new rr(this.toArray()).__iterate(function(e,n){return t(e,n,r)},e) +;for(var n=0,i=this._head;i&&t(i.value,n++,r)!==!1;)i=i.next;return n},e.prototype.__iterator=function(t,e){if(e)return new rr(this.toArray()).__iterator(t,e);var r=0,n=this._head;return new Fe(function(){if(n){var e=n.value;return n=n.next,z(t,r++,e)}return S()})},e}(Je);Nr.isStack=Ft;var Pr="@@__IMMUTABLE_STACK__@@",Vr=Nr.prototype;Vr[Pr]=!0,Vr.withMutations=br.withMutations,Vr.asMutable=br.asMutable,Vr.asImmutable=br.asImmutable,Vr.wasAltered=br.wasAltered,Vr.shift=Vr.pop,Vr.unshift=Vr.push,Vr.unshiftAll=Vr.pushAll,Vr["@@transducer/init"]=Vr.asMutable,Vr["@@transducer/step"]=function(t,e){return t.unshift(e)},Vr["@@transducer/result"]=br["@@transducer/result"];var Hr,Yr=function(t){function e(e){return null===e||void 0===e?ie():ee(e)&&!g(e)?e:ie().withMutations(function(r){var n=t(e);pt(n.size),n.forEach(function(t){return r.add(t)})})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(Be(t).keySeq())},e.intersect=function(t){return t=We(t).toArray(),t.length?Xr.intersect.apply(e(t.pop()),t):ie()},e.union=function(t){return t=We(t).toArray(),t.length?Xr.union.apply(e(t.pop()),t):ie()},e.prototype.toString=function(){return this.__toString("Set {","}")},e.prototype.has=function(t){return this._map.has(t)},e.prototype.add=function(t){return re(this,this._map.set(t,t))},e.prototype.remove=function(t){return re(this,this._map.remove(t))},e.prototype.clear=function(){return re(this,this._map.clear())},e.prototype.union=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return e=e.filter(function(t){return 0!==t.size}),0===e.length?this:0!==this.size||this.__ownerID||1!==e.length?this.withMutations(function(r){for(var n=0;n0;)e[r]=arguments[r+1];return this.union.apply(this,e)},e.prototype.sort=function(t){return rn(tt(this,t))},e.prototype.sortBy=function(t,e){return rn(tt(this,e,t))},e.prototype.wasAltered=function(){return this._map.wasAltered()},e.prototype.__iterate=function(t,e){var r=this;return this._map.__iterate(function(e){return t(e,e,r)},e)},e.prototype.__iterator=function(t,e){return this._map.__iterator(t,e)},e.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var e=this._map.__ensureOwner(t);return t?this.__make(e,t):0===this.size?this.__empty():(this.__ownerID=t,this._map=e,this)},e}(Ne);Yr.isSet=ee;var Qr="@@__IMMUTABLE_SET__@@",Xr=Yr.prototype;Xr[Qr]=!0,Xr.delete=Xr.remove,Xr.mergeDeep=Xr.merge,Xr.mergeDeepWith=Xr.mergeWith,Xr.withMutations=br.withMutations,Xr.asMutable=br.asMutable,Xr.asImmutable=br.asImmutable,Xr["@@transducer/init"]=Xr.asMutable,Xr["@@transducer/step"]=function(t,e){return t.add(e)},Xr["@@transducer/result"]=br["@@transducer/result"],Xr.__empty=ie,Xr.__make=ne;var Fr,Gr,Zr=function(t){function e(t,r,n){if(!(this instanceof e))return new e(t,r,n);if(ft(0!==n,"Cannot step a Range by 0"),t=t||0,void 0===r&&(r=1/0),n=void 0===n?1:Math.abs(n),r=0&&e=0&&rthis.size?e:this.find(function(e,r){return r===t},void 0,e)},has:function(t){return(t=u(this,t))>=0&&(void 0!==this.size?this.size===1/0||t Date: Thu, 5 Oct 2017 02:34:26 +0000 Subject: [PATCH 037/242] Deploy master to NPM branch --- dist/immutable-nonambient.d.ts | 37 ++++++++++++++++++++++-- dist/immutable.d.ts | 37 ++++++++++++++++++++++-- dist/immutable.es.js | 8 ++++-- dist/immutable.js | 8 ++++-- dist/immutable.js.flow | 5 +++- dist/immutable.min.js | 52 +++++++++++++++++----------------- 6 files changed, 112 insertions(+), 35 deletions(-) diff --git a/dist/immutable-nonambient.d.ts b/dist/immutable-nonambient.d.ts index 958aaa77f1..2bdfdcd995 100644 --- a/dist/immutable-nonambient.d.ts +++ b/dist/immutable-nonambient.d.ts @@ -2674,6 +2674,11 @@ */ toJSON(): { [key: string]: V }; + /** + * Shallowly converts this collection to an Array. + */ + toArray(): Array<[K, V]>; + /** * Returns itself */ @@ -2785,6 +2790,11 @@ */ toJSON(): Array; + /** + * Shallowly converts this collection to an Array. + */ + toArray(): Array; + /** * Returns itself */ @@ -2929,6 +2939,11 @@ */ toJSON(): Array; + /** + * Shallowly converts this collection to an Array. + */ + toArray(): Array; + /** * Returns itself */ @@ -3195,6 +3210,11 @@ */ toJSON(): { [key: string]: V }; + /** + * Shallowly converts this collection to an Array. + */ + toArray(): Array<[K, V]>; + /** * Returns Seq.Keyed. * @override @@ -3343,6 +3363,11 @@ */ toJSON(): Array; + /** + * Shallowly converts this collection to an Array. + */ + toArray(): Array; + // Reading values /** @@ -3618,6 +3643,11 @@ */ toJSON(): Array; + /** + * Shallowly converts this collection to an Array. + */ + toArray(): Array; + /** * Returns Seq.Set. * @override @@ -3835,9 +3865,12 @@ toJSON(): Array | { [key: string]: V }; /** - * Shallowly converts this collection to an Array, discarding keys. + * Shallowly converts this collection to an Array. + * + * `Collection.Indexed`, and `Collection.Set` produce an Array of values. + * `Collection.Keyed` produce an Array of [key, value] tuples. */ - toArray(): Array; + toArray(): Array | Array<[K, V]>; /** * Shallowly converts this Collection to an Object. diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index a329d8de4b..61cf89f54b 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -2674,6 +2674,11 @@ declare module Immutable { */ toJSON(): { [key: string]: V }; + /** + * Shallowly converts this collection to an Array. + */ + toArray(): Array<[K, V]>; + /** * Returns itself */ @@ -2785,6 +2790,11 @@ declare module Immutable { */ toJSON(): Array; + /** + * Shallowly converts this collection to an Array. + */ + toArray(): Array; + /** * Returns itself */ @@ -2929,6 +2939,11 @@ declare module Immutable { */ toJSON(): Array; + /** + * Shallowly converts this collection to an Array. + */ + toArray(): Array; + /** * Returns itself */ @@ -3195,6 +3210,11 @@ declare module Immutable { */ toJSON(): { [key: string]: V }; + /** + * Shallowly converts this collection to an Array. + */ + toArray(): Array<[K, V]>; + /** * Returns Seq.Keyed. * @override @@ -3343,6 +3363,11 @@ declare module Immutable { */ toJSON(): Array; + /** + * Shallowly converts this collection to an Array. + */ + toArray(): Array; + // Reading values /** @@ -3618,6 +3643,11 @@ declare module Immutable { */ toJSON(): Array; + /** + * Shallowly converts this collection to an Array. + */ + toArray(): Array; + /** * Returns Seq.Set. * @override @@ -3835,9 +3865,12 @@ declare module Immutable { toJSON(): Array | { [key: string]: V }; /** - * Shallowly converts this collection to an Array, discarding keys. + * Shallowly converts this collection to an Array. + * + * `Collection.Indexed`, and `Collection.Set` produce an Array of values. + * `Collection.Keyed` produce an Array of [key, value] tuples. */ - toArray(): Array; + toArray(): Array | Array<[K, V]>; /** * Shallowly converts this Collection to an Object. diff --git a/dist/immutable.es.js b/dist/immutable.es.js index 4b952f60d4..8f7de12445 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -1723,6 +1723,7 @@ function sortFactory(collection, comparator, mapper) { var entries = collection .toSeq() .map(function (v, k) { return [k, v, index++, mapper ? mapper(v, k, collection) : v]; }) + .valueSeq() .toArray(); entries.sort(function (a, b) { return comparator(a[3], b[3]) || a[2] - b[2]; }).forEach( isKeyedCollection @@ -4368,8 +4369,11 @@ mixin(Collection, { toArray: function toArray() { assertNotInfinite(this.size); var array = new Array(this.size || 0); - this.valueSeq().__iterate(function (v, i) { - array[i] = v; + var useTuples = isKeyed(this); + var i = 0; + this.__iterate(function (v, k) { + // Keyed collections produce an array of tuples. + array[i++] = useTuples ? [k, v] : v; }); return array; }, diff --git a/dist/immutable.js b/dist/immutable.js index b9cf71dd0d..170f6584b3 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -1729,6 +1729,7 @@ function sortFactory(collection, comparator, mapper) { var entries = collection .toSeq() .map(function (v, k) { return [k, v, index++, mapper ? mapper(v, k, collection) : v]; }) + .valueSeq() .toArray(); entries.sort(function (a, b) { return comparator(a[3], b[3]) || a[2] - b[2]; }).forEach( isKeyedCollection @@ -4374,8 +4375,11 @@ mixin(Collection, { toArray: function toArray() { assertNotInfinite(this.size); var array = new Array(this.size || 0); - this.valueSeq().__iterate(function (v, i) { - array[i] = v; + var useTuples = isKeyed(this); + var i = 0; + this.__iterate(function (v, k) { + // Keyed collections produce an array of tuples. + array[i++] = useTuples ? [k, v] : v; }); return array; }, diff --git a/dist/immutable.js.flow b/dist/immutable.js.flow index 67ebba04b9..186cd8f614 100644 --- a/dist/immutable.js.flow +++ b/dist/immutable.js.flow @@ -50,7 +50,7 @@ declare class _Collection /*implements ValueObject*/ { toJS(): Array | { [key: string]: mixed }; toJSON(): Array | { [key: string]: V }; - toArray(): Array; + toArray(): Array | Array<[K,V]>; toObject(): { [key: string]: V }; toMap(): Map; toOrderedMap(): OrderedMap; @@ -209,6 +209,7 @@ declare class KeyedCollection extends Collection { toJS(): { [key: string]: mixed }; toJSON(): { [key: string]: V }; + toArray(): Array<[K, V]>; @@iterator(): Iterator<[K, V]>; toSeq(): KeyedSeq; flip(): KeyedCollection; @@ -247,6 +248,7 @@ declare class IndexedCollection<+T> extends Collection { toJS(): Array; toJSON(): Array; + toArray(): Array; @@iterator(): Iterator; toSeq(): IndexedSeq; fromEntrySeq(): KeyedSeq; @@ -388,6 +390,7 @@ declare class SetCollection<+T> extends Collection { toJS(): Array; toJSON(): Array; + toArray(): Array; @@iterator(): Iterator; toSeq(): SetSeq; diff --git a/dist/immutable.min.js b/dist/immutable.min.js index 284454156e..67286f25a2 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -9,29 +9,29 @@ function k(t){var e=A(t);if(e)return e;if("object"==typeof t)return new nr(t);th function W(t){if(t&&t.nodeType>0)switch(t.nodeType){case 1:return t.uniqueID;case 9:return t.documentElement&&t.documentElement.uniqueID}}function B(t){var e=st(t);return e._iter=t,e.size=t.size,e.flip=function(){return t},e.reverse=function(){var e=t.reverse.apply(this);return e.flip=function(){return t.reverse()},e},e.has=function(e){return t.includes(e)},e.includes=function(e){return t.has(e)},e.cacheResult=at,e.__iterateUncached=function(e,r){var n=this;return t.__iterate(function(t,r){return e(r,t,n)!==!1},r)},e.__iteratorUncached=function(e,r){if(e===He){var n=t.__iterator(e,r);return new Fe(function(){var t=n.next();if(!t.done){var e=t.value[0];t.value[0]=t.value[1],t.value[1]=e}return t})}return t.__iterator(e===Ve?Pe:Ve,r)},e}function J(t,e,r){var n=st(t);return n.size=t.size,n.has=function(e){return t.has(e)},n.get=function(n,i){var o=t.get(n,ke);return o===ke?i:e.call(r,o,n,t)},n.__iterateUncached=function(n,i){var o=this;return t.__iterate(function(t,i,u){return n(e.call(r,t,i,u),i,o)!==!1},i)},n.__iteratorUncached=function(n,i){var o=t.__iterator(He,i);return new Fe(function(){var i=o.next();if(i.done)return i;var u=i.value,s=u[0];return z(n,s,e.call(r,u[1],s,t),i)})},n}function N(t,e){var r=this,n=st(t);return n._iter=t,n.size=t.size,n.reverse=function(){return t},t.flip&&(n.flip=function(){var e=B(t);return e.reverse=function(){return t.flip()},e}),n.get=function(r,n){return t.get(e?r:-1-r,n)},n.has=function(r){return t.has(e?r:-1-r)},n.includes=function(e){return t.includes(e)},n.cacheResult=at,n.__iterate=function(r,n){var i=this,u=0;return n&&o(t),t.__iterate(function(t,o){return r(t,e?o:n?i.size-++u:u++,i)},!n)},n.__iterator=function(n,i){var u=0;i&&o(t);var s=t.__iterator(He,!i);return new Fe(function(){var t=s.next();if(t.done)return t;var o=t.value;return z(n,e?o[0]:i?r.size-++u:u++,o[1],t)})},n}function P(t,e,r,n){var i=st(t);return n&&(i.has=function(n){var i=t.get(n,ke);return i!==ke&&!!e.call(r,i,n,t)},i.get=function(n,i){var o=t.get(n,ke);return o!==ke&&e.call(r,o,n,t)?o:i}), i.__iterateUncached=function(i,o){var u=this,s=0;return t.__iterate(function(t,o,a){if(e.call(r,t,o,a))return s++,i(t,n?o:s-1,u)},o),s},i.__iteratorUncached=function(i,o){var u=t.__iterator(He,o),s=0;return new Fe(function(){for(;;){var o=u.next();if(o.done)return o;var a=o.value,c=a[0],h=a[1];if(e.call(r,h,c,t))return z(i,n?c:s++,h,o)}})},i}function V(t,e,r){var n=Sr().asMutable();return t.__iterate(function(i,o){n.update(e.call(r,i,o,t),0,function(t){return t+1})}),n.asImmutable()}function H(t,e,r){var n=v(t),i=(g(t)?Br():Sr()).asMutable();t.__iterate(function(o,u){i.update(e.call(r,o,u,t),function(t){return t=t||[],t.push(n?[u,o]:o),t})});var o=ut(t);return i.map(function(e){return it(t,o(e))})}function Y(t,e,r,n){var i=t.size;if(a(e,r,i))return t;var o=c(e,i),s=h(r,i);if(o!==o||s!==s)return Y(t.toSeq().cacheResult(),e,r,n);var f,p=s-o;p===p&&(f=p<0?0:p);var _=st(t);return _.size=0===f?f:t.size&&f||void 0,!n&&q(t)&&f>=0&&(_.get=function(e,r){return e=u(this,e),e>=0&&ef)return S();var t=i.next();return n||e===Ve||t.done?t:e===Pe?z(e,s-1,void 0,t):z(e,s-1,t.value[1],t)})},_}function Q(t,e,r){var n=st(t);return n.__iterateUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterate(n,i);var u=0;return t.__iterate(function(t,i,s){return e.call(r,t,i,s)&&++u&&n(t,i,o)}),u},n.__iteratorUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterator(n,i);var u=t.__iterator(He,i),s=!0;return new Fe(function(){if(!s)return S();var t=u.next();if(t.done)return t;var i=t.value,a=i[0],c=i[1];return e.call(r,c,a,o)?n===He?t:z(n,a,c,t):(s=!1,S())})},n} function X(t,e,r,n){var i=st(t);return i.__iterateUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterate(i,o);var s=!0,a=0;return t.__iterate(function(t,o,c){if(!s||!(s=e.call(r,t,o,c)))return a++,i(t,n?o:a-1,u)}),a},i.__iteratorUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterator(i,o);var s=t.__iterator(He,o),a=!0,c=0;return new Fe(function(){var t,o,h;do{if(t=s.next(),t.done)return n||i===Ve?t:i===Pe?z(i,c++,void 0,t):z(i,c++,t.value[1],t);var f=t.value;o=f[0],h=f[1],a&&(a=e.call(r,h,o,u))}while(a);return i===He?t:z(i,o,h,t)})},i}function F(t,e){var r=v(t),n=[t].concat(e).map(function(t){return l(t)?r&&(t=Be(t)):t=r?x(t):j(Array.isArray(t)?t:[t]),t}).filter(function(t){return 0!==t.size});if(0===n.length)return t;if(1===n.length){var i=n[0];if(i===t||r&&v(i)||y(t)&&y(i))return i}var o=new rr(n);return r?o=o.toKeyedSeq():y(t)||(o=o.toSetSeq()),o=o.flatten(!0),o.size=n.reduce(function(t,e){if(void 0!==t){var r=e.size;if(void 0!==r)return t+r}},0),o}function G(t,e,r){var n=st(t);return n.__iterateUncached=function(i,o){function u(t,c){t.__iterate(function(t,o){return(!e||c0}function nt(t,e,r,n){var i=st(t),o=new rr(r).map(function(t){return t.size});return i.size=n?o.max():o.min(),i.__iterate=function(t,e){for(var r,n=this,i=this.__iterator(Ve,e),o=0;!(r=i.next()).done&&t(r.value,o++,n)!==!1;);return o},i.__iteratorUncached=function(t,i){var o=r.map(function(t){return t=We(t),O(i?t.reverse():t)}),u=0,s=!1;return new Fe(function(){var r;return s||(r=o.map(function(t){return t.next()}),s=n?r.every(function(t){return t.done}):r.some(function(t){return t.done})),s?S():z(t,u++,e.apply(null,r.map(function(t){return t.value})))})},i}function it(t,e){return t===e?t:q(t)?e:t.constructor(e)}function ot(t){if(t!==Object(t))throw new TypeError("Expected [K, V] tuple: "+t)}function ut(t){return v(t)?Be:y(t)?Je:Ne}function st(t){return Object.create((v(t)?Ze:y(t)?$e:tr).prototype)}function at(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size,this):Ge.prototype.cacheResult.call(this)}function ct(t,e){return void 0===t&&void 0===e?0:void 0===t?1:void 0===e?-1:t>e?1:t>>r)&je,s=(0===r?n:n>>>r)&je;return new Mr(e,1<>>=1)u[s]=1&r?e[o++]:void 0;return u[n]=i,new Dr(t,o+1,u)}function Mt(t,e,r){for(var n=[],i=0;i>1&1431655765,t=(858993459&t)+(t>>2&858993459),t=t+(t>>4)&252645135,t+=t>>8,127&(t+=t>>16)}function kt(t,e,r,n){var o=n?t:i(t);return o[e]=r,o}function At(t,e,r,n){var i=t.length+1;if(n&&e+1===i)return t[e]=r,t;for(var o=Array(i),u=0,s=0;so?0:o-r,c=u-r;return c>xe&&(c=xe),function(){if(i===c)return Wr;var t=e?--c:i++;return n&&n[t]}}function i(t,n,i){var s,a=t&&t.array,c=i>o?0:o-i>>n,h=1+(u-i>>n);return h>xe&&(h=xe),function(){for(;;){if(s){var t=s();if(t!==Wr)return t;s=null}if(c===h)return Wr;var o=e?--h:c++;s=r(a&&a[o],n-Ee,i+(o<=t.size||r<0)return t.withMutations(function(t){r<0?Nt(t,r).set(0,n):Nt(t,0,r+1).set(r,n)});r+=t._origin;var i=t._tail,o=t._root,s=e(Re);return r>=Vt(t._capacity)?i=Wt(i,t.__ownerID,0,r,n,s):o=Wt(o,t.__ownerID,t._level,r,n,s),s.value?t.__ownerID?(t._root=o,t._tail=i,t.__hash=void 0,t.__altered=!0,t):Lt(t._origin,t._capacity,t._level,o,i):t}function Wt(t,e,n,i,o,u){var s=i>>>n&je,a=t&&s0){var h=t&&t.array[s],f=Wt(h,e,n-Ee,i,o,u);return f===h?t:(c=Bt(t,e), -c.array[s]=f,c)}return a&&t.array[s]===o?t:(r(u),c=Bt(t,e),void 0===o&&s===c.array.length-1?c.array.pop():c.array[s]=o,c)}function Bt(t,e){return e&&t&&e===t.ownerID?t:new Tr(t?t.array.slice():[],e)}function Jt(t,e){if(e>=Vt(t._capacity))return t._tail;if(e<1<0;)r=r.array[e>>>n&je],n-=Ee;return r}}function Nt(t,e,r){void 0!==e&&(e|=0),void 0!==r&&(r|=0);var i=t.__ownerID||new n,o=t._origin,u=t._capacity,s=o+e,a=void 0===r?u:r<0?u+r:o+r;if(s===o&&a===u)return t;if(s>=a)return t.clear();for(var c=t._level,h=t._root,f=0;s+f<0;)h=new Tr(h&&h.array.length?[void 0,h]:[],i),c+=Ee,f+=1<=1<p?new Tr([],i):l;if(l&&_>p&&sEe;d-=Ee){var g=p>>>d&je;y=y.array[g]=Bt(y.array[g],i)}y.array[p>>>Ee&je]=l}if(a=_)s-=_,a-=_,c=Ee,h=null,v=v&&v.removeBefore(i,0,s);else if(s>o||_>>c&je;if(m!==_>>>c&je)break;m&&(f+=(1<o&&(h=h.removeBefore(i,c,s-f)),h&&_i&&(i=u.size),n.push(u)}return i>t.size&&(t=t.setSize(i)),Et(t,e,n)}function Vt(t){return t>>Ee<=xe&&u.size>=2*o.size?(i=u.filter(function(t,e){return void 0!==t&&s!==e}),n=i.toKeyedSeq().map(function(t){return t[0]}).flip().toMap(),t.__ownerID&&(n.__ownerID=i.__ownerID=t.__ownerID)):(n=o.remove(e), -i=s===u.size-1?u.pop():u.set(s,void 0))}else if(a){if(r===u.get(s)[1])return t;n=o,i=u.set(s,[e,r])}else n=o.set(e,u.size),i=u.set(u.size,[e,r]);return t.__ownerID?(t.size=n.size,t._map=n,t._list=i,t.__hash=void 0,t):Yt(n,i)}function Ft(t){return!(!t||!t[Pr])}function Gt(t,e,r,n){var i=Object.create(Vr);return i.size=t,i._head=e,i.__ownerID=r,i.__hash=n,i.__altered=!1,i}function Zt(){return Hr||(Hr=Gt(0))}function $t(t,e){if(t===e)return!0;if(!l(e)||void 0!==t.size&&void 0!==e.size&&t.size!==e.size||void 0!==t.__hash&&void 0!==e.__hash&&t.__hash!==e.__hash||v(t)!==v(e)||y(t)!==y(e)||g(t)!==g(e))return!1;if(0===t.size&&0===e.size)return!0;var r=!d(t);if(g(t)){var n=t.entries();return e.every(function(t,e){var i=n.next().value;return i&&R(i[1],t)&&(r||R(i[0],e))})&&n.next().done}var i=!1;if(void 0===t.size)if(void 0===e.size)"function"==typeof t.cacheResult&&t.cacheResult();else{i=!0;var o=t;t=e,e=o}var u=!0,s=e.__iterate(function(e,n){if(r?!t.has(e):i?!R(e,t.get(n,ke)):!R(t.get(n,ke),e))return u=!1,!1});return u&&t.size===s}function te(t,e){var r=function(r){t.prototype[r]=e[r]};return Object.keys(e).forEach(r),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(e).forEach(r),t}function ee(t){return!(!t||!t[Qr])}function re(t,e){return t.__ownerID?(t.size=e.size,t._map=e,t):e===t._map?t:0===e.size?t.__empty():t.__make(e)}function ne(t,e){var r=Object.create(Xr);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function ie(){return Fr||(Fr=ne(gt()))}function oe(t,e,r,n,i,o){return pt(t.size),t.__iterate(function(t,o,u){i?(i=!1,r=t):r=e.call(n,r,t,o,u)},o),r}function ue(t,e){return e}function se(t,e){return[e,t]}function ae(t){return t&&"function"==typeof t.toJS?t.toJS():t}function ce(t){return function(){return!t.apply(this,arguments)}}function he(t){return function(){return-t.apply(this,arguments)}}function fe(){return i(arguments)}function pe(t,e){return te?-1:0}function _e(t){if(t.size===1/0)return 0;var e=g(t),r=v(t),n=e?1:0;return le(t.__iterate(r?e?function(t,e){n=31*n+ve(K(t),K(e))|0 -}:function(t,e){n=n+ve(K(t),K(e))|0}:e?function(t){n=31*n+K(t)|0}:function(t){n=n+K(t)|0}),n)}function le(t,e){return e=ar(e,3432918353),e=ar(e<<15|e>>>-15,461845907),e=ar(e<<13|e>>>-13,5),e=(e+3864292196|0)^t,e=ar(e^e>>>16,2246822507),e=ar(e^e>>>13,3266489909),e=U(e^e>>>16)}function ve(t,e){return t^e+2654435769+(t<<6)+(t>>2)|0}function ye(t){if("object"!=typeof console||!console.warn)throw Error(t);console.warn(t)}function de(t,e,r,n){for(var i=ht(r),o=0;o!==i.length;){if(!t||!t.get)return n&&ye("Invalid keyPath: Value at ["+i.slice(0,o).map(_t)+"] does not have a .get() method: "+t+"\nThis warning will throw in a future version"),e;if((t=t.get(i[o++],ke))===ke)return e}return t}function ge(t){return ee(t)&&g(t)}function me(t,e){var r=Object.create(nn);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function we(){return on||(on=me(Qt()))}function ze(t,e,r){var n=Object.create(Object.getPrototypeOf(t));return n._values=e,n.__ownerID=r,n}function Se(t){return t._name||t.constructor.name||"Record"}function Ie(t){return x(t._keys.map(function(e){return[e,t.get(e)]}))}function be(t,e){try{Object.defineProperty(t,e,{get:function(){return this.get(e)},set:function(t){ft(this.__ownerID,"Cannot set on an immutable record."),this.set(e,t)}})}catch(t){}}function Oe(t,e){return Me([],e||De,t,"",e&&e.length>2?[]:void 0,{"":t})}function Me(t,e,r,n,i,o){var u=Array.isArray(r)?$e:qe(r)?Ze:null;if(u){if(~t.indexOf(r))throw new TypeError("Cannot convert circular structure to Immutable");t.push(r),i&&""!==n&&i.push(n);var s=e.call(o,n,u(r).map(function(n,o){return Me(t,e,n,o,i,r)}),i&&i.slice());return t.pop(),i&&i.pop(),s}return r}function De(t,e){return v(e)?e.toMap():e.toList()}function qe(t){return t&&(t.constructor===Object||void 0===t.constructor)}var Ee=5,xe=1<=n.length){var e=r.next();if(e.done)return e;n[i]=e.value}return z(t,i,n[i++])})},e}($e),ar="function"==typeof Math.imul&&Math.imul(4294967295,2)===-2?Math.imul:function(t,e){t|=0,e|=0;var r=65535&t,n=65535&e;return r*n+((t>>>16)*n+r*(e>>>16)<<16>>>0)|0},cr=Object.isExtensible,hr=function(){try{return Object.defineProperty({},"@",{}),!0}catch(t){return!1}}(),fr="function"==typeof WeakMap;fr&&(or=new WeakMap);var pr=0,_r="__immutablehash__";"function"==typeof Symbol&&(_r=Symbol(_r));var lr=16,vr=255,yr=0,dr={},gr=function(t){function e(t,e){this._iter=t,this._useKeys=e,this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t,e){return this._iter.get(t,e)},e.prototype.has=function(t){return this._iter.has(t)},e.prototype.valueSeq=function(){return this._iter.valueSeq()},e.prototype.reverse=function(){ -var t=this,e=N(this,!0);return this._useKeys||(e.valueSeq=function(){return t._iter.toSeq().reverse()}),e},e.prototype.map=function(t,e){var r=this,n=J(this,t,e);return this._useKeys||(n.valueSeq=function(){return r._iter.toSeq().map(t,e)}),n},e.prototype.__iterate=function(t,e){var r=this;return this._iter.__iterate(function(e,n){return t(e,n,r)},e)},e.prototype.__iterator=function(t,e){return this._iter.__iterator(t,e)},e}(Ze);gr.prototype[Te]=!0;var mr=function(t){function e(t){this._iter=t,this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.includes=function(t){return this._iter.includes(t)},e.prototype.__iterate=function(t,e){var r=this,n=0;return e&&o(this),this._iter.__iterate(function(i){return t(i,e?r.size-++n:n++,r)},e)},e.prototype.__iterator=function(t,e){var r=this,n=this._iter.__iterator(Ve,e),i=0;return e&&o(this),new Fe(function(){var o=n.next();return o.done?o:z(t,e?r.size-++i:i++,o.value,o)})},e}($e),wr=function(t){function e(t){this._iter=t,this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.has=function(t){return this._iter.includes(t)},e.prototype.__iterate=function(t,e){var r=this;return this._iter.__iterate(function(e){return t(e,e,r)},e)},e.prototype.__iterator=function(t,e){var r=this._iter.__iterator(Ve,e);return new Fe(function(){var e=r.next();return e.done?e:z(t,e.value,e.value,e)})},e}(tr),zr=function(t){function e(t){this._iter=t,this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.entrySeq=function(){return this._iter.toSeq()},e.prototype.__iterate=function(t,e){var r=this;return this._iter.__iterate(function(e){if(e){ot(e);var n=l(e);return t(n?e.get(1):e[1],n?e.get(0):e[0],r)}},e)},e.prototype.__iterator=function(t,e){var r=this._iter.__iterator(Ve,e);return new Fe(function(){for(;;){var e=r.next();if(e.done)return e;var n=e.value;if(n){ot(n);var i=l(n) -;return z(t,i?n.get(0):n[0],i?n.get(1):n[1],e)}}})},e}(Ze);mr.prototype.cacheResult=gr.prototype.cacheResult=wr.prototype.cacheResult=zr.prototype.cacheResult=at;var Sr=function(t){function e(e){return null===e||void 0===e?gt():lt(e)&&!g(e)?e:gt().withMutations(function(r){var n=t(e);pt(n.size),n.forEach(function(t,e){return r.set(e,t)})})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return gt().withMutations(function(e){for(var r=0;r=t.length)throw Error("Missing value for key: "+t[r]);e.set(t[r],t[r+1])}})},e.prototype.toString=function(){return this.__toString("Map {","}")},e.prototype.get=function(t,e){return this._root?this._root.get(0,void 0,t,e):e},e.prototype.set=function(t,e){return mt(this,t,e)},e.prototype.setIn=function(t,e){return this.updateIn(t,ke,function(){return e})},e.prototype.remove=function(t){return mt(this,t,ke)},e.prototype.deleteIn=function(t){if(t=[].concat(ht(t)),t.length){var e=t.pop();return this.updateIn(t,function(t){return t&&t.remove(e)})}},e.prototype.deleteAll=function(t){var e=We(t);return 0===e.size?this:this.withMutations(function(t){e.forEach(function(e){return t.remove(e)})})},e.prototype.update=function(t,e,r){return 1===arguments.length?t(this):this.updateIn([t],e,r)},e.prototype.updateIn=function(t,e,r){r||(r=e,e=void 0);var n=xt(this,ht(t),0,e,r);return n===ke?e:n},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):gt()},e.prototype.merge=function(){return Mt(this,void 0,arguments)},e.prototype.mergeWith=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Mt(this,t,e)},e.prototype.mergeIn=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return this.updateIn(t,gt(),function(t){return"function"==typeof t.merge?t.merge.apply(t,e):e[e.length-1]})},e.prototype.mergeDeep=function(){ -return Mt(this,Dt,arguments)},e.prototype.mergeDeepWith=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Mt(this,qt(t),e)},e.prototype.mergeDeepIn=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return this.updateIn(t,gt(),function(t){return"function"==typeof t.mergeDeep?t.mergeDeep.apply(t,e):e[e.length-1]})},e.prototype.sort=function(t){return Br(tt(this,t))},e.prototype.sortBy=function(t,e){return Br(tt(this,e,t))},e.prototype.withMutations=function(t){var e=this.asMutable();return t(e),e.wasAltered()?e.__ensureOwner(this.__ownerID):this},e.prototype.asMutable=function(){return this.__ownerID?this:this.__ensureOwner(new n)},e.prototype.asImmutable=function(){return this.__ensureOwner()},e.prototype.wasAltered=function(){return this.__altered},e.prototype.__iterator=function(t,e){return new jr(this,t,e)},e.prototype.__iterate=function(t,e){var r=this,n=0;return this._root&&this._root.iterate(function(e){return n++,t(e[1],e[0],r)},e),n},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?dt(this.size,this._root,t,this.__hash):0===this.size?gt():(this.__ownerID=t,this.__altered=!1,this)},e}(Be);Sr.isMap=lt;var Ir="@@__IMMUTABLE_MAP__@@",br=Sr.prototype;br[Ir]=!0,br.delete=br.remove,br.removeIn=br.deleteIn,br.removeAll=br.deleteAll,br["@@transducer/init"]=br.asMutable,br["@@transducer/step"]=function(t,e){return t.set(e[0],e[1])},br["@@transducer/result"]=function(t){return t.asImmutable()};var Or=function(t,e){this.ownerID=t,this.entries=e};Or.prototype.get=function(t,e,r,n){for(var i=this.entries,o=0,u=i.length;o=kr)return It(t,h,o,u);var l=t&&t===this.ownerID,v=l?h:i(h);return _?c?f===p-1?v.pop():v[f]=v.pop():v[f]=[o,u]:v.push([o,u]),l?(this.entries=v,this):new Or(t,v)}} -;var Mr=function(t,e,r){this.ownerID=t,this.bitmap=e,this.nodes=r};Mr.prototype.get=function(t,e,r,n){void 0===e&&(e=K(r));var i=1<<((0===t?e:e>>>t)&je),o=this.bitmap;return 0==(o&i)?n:this.nodes[jt(o&i-1)].get(t+Ee,e,r,n)},Mr.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=K(n));var s=(0===e?r:r>>>e)&je,a=1<=Ar)return Ot(t,p,c,s,l);if(h&&!l&&2===p.length&&zt(p[1^f]))return p[1^f];if(h&&l&&1===p.length&&zt(l))return l;var v=t&&t===this.ownerID,y=h?l?c:c^a:c|a,d=h?l?kt(p,f,l,v):Rt(p,f,v):At(p,f,l,v);return v?(this.bitmap=y,this.nodes=d,this):new Mr(t,y,d)};var Dr=function(t,e,r){this.ownerID=t,this.count=e,this.nodes=r};Dr.prototype.get=function(t,e,r,n){void 0===e&&(e=K(r));var i=(0===t?e:e>>>t)&je,o=this.nodes[i];return o?o.get(t+Ee,e,r,n):n},Dr.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=K(n));var s=(0===e?r:r>>>e)&je,a=i===ke,c=this.nodes,h=c[s];if(a&&!h)return this;var f=wt(h,t,e+Ee,r,n,i,o,u);if(f===h)return this;var p=this.count;if(h){if(!f&&--p0&&i=0&&t0;)e[r]=arguments[r+1];return Pt(this,t,e)},e.prototype.mergeDeep=function(){return Pt(this,Dt,arguments)},e.prototype.mergeDeepWith=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Pt(this,qt(t),e)},e.prototype.setSize=function(t){return Nt(this,0,t)},e.prototype.slice=function(t,e){var r=this.size;return a(t,e,r)?this:Nt(this,c(t,r),h(e,r))},e.prototype.__iterator=function(t,e){var r=e?this.size:0,n=Kt(this,e);return new Fe(function(){var i=n();return i===Wr?S():z(t,e?--r:r++,i)})},e.prototype.__iterate=function(t,e){for(var r,n=this,i=e?this.size:0,o=Kt(this,e);(r=o())!==Wr&&t(r,e?--i:i++,n)!==!1;);return i},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Lt(this._origin,this._capacity,this._level,this._root,this._tail,t,this.__hash):0===this.size?Tt():(this.__ownerID=t,this.__altered=!1,this)},e}(Je);Ur.isList=Ut;var Kr="@@__IMMUTABLE_LIST__@@",Lr=Ur.prototype;Lr[Kr]=!0,Lr.delete=Lr.remove,Lr.setIn=br.setIn,Lr.deleteIn=Lr.removeIn=br.removeIn,Lr.update=br.update,Lr.updateIn=br.updateIn,Lr.mergeIn=br.mergeIn,Lr.mergeDeepIn=br.mergeDeepIn,Lr.withMutations=br.withMutations,Lr.asMutable=br.asMutable,Lr.asImmutable=br.asImmutable,Lr.wasAltered=br.wasAltered, -Lr["@@transducer/init"]=Lr.asMutable,Lr["@@transducer/step"]=function(t,e){return t.push(e)},Lr["@@transducer/result"]=br["@@transducer/result"];var Tr=function(t,e){this.array=t,this.ownerID=e};Tr.prototype.removeBefore=function(t,e,r){if(r===e?1<>>e&je;if(n>=this.array.length)return new Tr([],t);var i,o=0===n;if(e>0){var u=this.array[n];if((i=u&&u.removeBefore(t,e-Ee,r))===u&&o)return this}if(o&&!i)return this;var s=Bt(this,t);if(!o)for(var a=0;a>>e&je;if(n>=this.array.length)return this;var i;if(e>0){var o=this.array[n];if((i=o&&o.removeAfter(t,e-Ee,r))===o&&n===this.array.length-1)return this}var u=Bt(this,t);return u.array.splice(n+1),i&&(u.array[n]=i),u};var Cr,Wr={},Br=function(t){function e(t){return null===t||void 0===t?Qt():Ht(t)?t:Qt().withMutations(function(e){var r=Be(t);pt(r.size),r.forEach(function(t,r){return e.set(r,t)})})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("OrderedMap {","}")},e.prototype.get=function(t,e){var r=this._map.get(t);return void 0!==r?this._list.get(r)[1]:e},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._map.clear(),this._list.clear(),this):Qt()},e.prototype.set=function(t,e){return Xt(this,t,e)},e.prototype.remove=function(t){return Xt(this,t,ke)},e.prototype.wasAltered=function(){return this._map.wasAltered()||this._list.wasAltered()},e.prototype.__iterate=function(t,e){var r=this;return this._list.__iterate(function(e){return e&&t(e[1],e[0],r)},e)},e.prototype.__iterator=function(t,e){return this._list.fromEntrySeq().__iterator(t,e)},e.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var e=this._map.__ensureOwner(t),r=this._list.__ensureOwner(t) -;return t?Yt(e,r,t,this.__hash):0===this.size?Qt():(this.__ownerID=t,this._map=e,this._list=r,this)},e}(Sr);Br.isOrderedMap=Ht,Br.prototype[Te]=!0,Br.prototype.delete=Br.prototype.remove;var Jr,Nr=function(t){function e(t){return null===t||void 0===t?Zt():Ft(t)?t:Zt().pushAll(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("Stack [","]")},e.prototype.get=function(t,e){var r=this._head;for(t=u(this,t);r&&t--;)r=r.next;return r?r.value:e},e.prototype.peek=function(){return this._head&&this._head.value},e.prototype.push=function(){var t=arguments;if(0===arguments.length)return this;for(var e=this.size+arguments.length,r=this._head,n=arguments.length-1;n>=0;n--)r={value:t[n],next:r};return this.__ownerID?(this.size=e,this._head=r,this.__hash=void 0,this.__altered=!0,this):Gt(e,r)},e.prototype.pushAll=function(e){if(e=t(e),0===e.size)return this;if(0===this.size&&Ft(e))return e;pt(e.size);var r=this.size,n=this._head;return e.__iterate(function(t){r++,n={value:t,next:n}},!0),this.__ownerID?(this.size=r,this._head=n,this.__hash=void 0,this.__altered=!0,this):Gt(r,n)},e.prototype.pop=function(){return this.slice(1)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):Zt()},e.prototype.slice=function(e,r){if(a(e,r,this.size))return this;var n=c(e,this.size);if(h(r,this.size)!==this.size)return t.prototype.slice.call(this,e,r);for(var i=this.size-n,o=this._head;n--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):Gt(i,o)},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Gt(this.size,this._head,t,this.__hash):0===this.size?Zt():(this.__ownerID=t,this.__altered=!1,this)},e.prototype.__iterate=function(t,e){var r=this;if(e)return new rr(this.toArray()).__iterate(function(e,n){return t(e,n,r)},e) -;for(var n=0,i=this._head;i&&t(i.value,n++,r)!==!1;)i=i.next;return n},e.prototype.__iterator=function(t,e){if(e)return new rr(this.toArray()).__iterator(t,e);var r=0,n=this._head;return new Fe(function(){if(n){var e=n.value;return n=n.next,z(t,r++,e)}return S()})},e}(Je);Nr.isStack=Ft;var Pr="@@__IMMUTABLE_STACK__@@",Vr=Nr.prototype;Vr[Pr]=!0,Vr.withMutations=br.withMutations,Vr.asMutable=br.asMutable,Vr.asImmutable=br.asImmutable,Vr.wasAltered=br.wasAltered,Vr.shift=Vr.pop,Vr.unshift=Vr.push,Vr.unshiftAll=Vr.pushAll,Vr["@@transducer/init"]=Vr.asMutable,Vr["@@transducer/step"]=function(t,e){return t.unshift(e)},Vr["@@transducer/result"]=br["@@transducer/result"];var Hr,Yr=function(t){function e(e){return null===e||void 0===e?ie():ee(e)&&!g(e)?e:ie().withMutations(function(r){var n=t(e);pt(n.size),n.forEach(function(t){return r.add(t)})})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(Be(t).keySeq())},e.intersect=function(t){return t=We(t).toArray(),t.length?Xr.intersect.apply(e(t.pop()),t):ie()},e.union=function(t){return t=We(t).toArray(),t.length?Xr.union.apply(e(t.pop()),t):ie()},e.prototype.toString=function(){return this.__toString("Set {","}")},e.prototype.has=function(t){return this._map.has(t)},e.prototype.add=function(t){return re(this,this._map.set(t,t))},e.prototype.remove=function(t){return re(this,this._map.remove(t))},e.prototype.clear=function(){return re(this,this._map.clear())},e.prototype.union=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return e=e.filter(function(t){return 0!==t.size}),0===e.length?this:0!==this.size||this.__ownerID||1!==e.length?this.withMutations(function(r){for(var n=0;n0;)e[r]=arguments[r+1];return this.union.apply(this,e)},e.prototype.sort=function(t){return rn(tt(this,t))},e.prototype.sortBy=function(t,e){return rn(tt(this,e,t))},e.prototype.wasAltered=function(){return this._map.wasAltered()},e.prototype.__iterate=function(t,e){var r=this;return this._map.__iterate(function(e){return t(e,e,r)},e)},e.prototype.__iterator=function(t,e){return this._map.__iterator(t,e)},e.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var e=this._map.__ensureOwner(t);return t?this.__make(e,t):0===this.size?this.__empty():(this.__ownerID=t,this._map=e,this)},e}(Ne);Yr.isSet=ee;var Qr="@@__IMMUTABLE_SET__@@",Xr=Yr.prototype;Xr[Qr]=!0,Xr.delete=Xr.remove,Xr.mergeDeep=Xr.merge,Xr.mergeDeepWith=Xr.mergeWith,Xr.withMutations=br.withMutations,Xr.asMutable=br.asMutable,Xr.asImmutable=br.asImmutable,Xr["@@transducer/init"]=Xr.asMutable,Xr["@@transducer/step"]=function(t,e){return t.add(e)},Xr["@@transducer/result"]=br["@@transducer/result"],Xr.__empty=ie,Xr.__make=ne;var Fr,Gr,Zr=function(t){function e(t,r,n){if(!(this instanceof e))return new e(t,r,n);if(ft(0!==n,"Cannot step a Range by 0"),t=t||0,void 0===r&&(r=1/0),n=void 0===n?1:Math.abs(n),r=0&&e=0&&rthis.size?e:this.find(function(e,r){return r===t},void 0,e)},has:function(t){return(t=u(this,t))>=0&&(void 0!==this.size?this.size===1/0||t0}function nt(t,e,r,n){var i=st(t),o=new rr(r).map(function(t){return t.size});return i.size=n?o.max():o.min(),i.__iterate=function(t,e){for(var r,n=this,i=this.__iterator(Ve,e),o=0;!(r=i.next()).done&&t(r.value,o++,n)!==!1;);return o},i.__iteratorUncached=function(t,i){var o=r.map(function(t){return t=We(t),O(i?t.reverse():t)}),u=0,s=!1;return new Fe(function(){var r;return s||(r=o.map(function(t){return t.next()}),s=n?r.every(function(t){return t.done}):r.some(function(t){return t.done})),s?S():z(t,u++,e.apply(null,r.map(function(t){return t.value})))})},i}function it(t,e){return t===e?t:q(t)?e:t.constructor(e)}function ot(t){if(t!==Object(t))throw new TypeError("Expected [K, V] tuple: "+t)}function ut(t){return v(t)?Be:y(t)?Je:Ne}function st(t){return Object.create((v(t)?Ze:y(t)?$e:tr).prototype)}function at(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size,this):Ge.prototype.cacheResult.call(this)}function ct(t,e){return void 0===t&&void 0===e?0:void 0===t?1:void 0===e?-1:t>e?1:t>>r)&je,s=(0===r?n:n>>>r)&je;return new Mr(e,1<>>=1)u[s]=1&r?e[o++]:void 0;return u[n]=i,new Dr(t,o+1,u)}function Mt(t,e,r){for(var n=[],i=0;i>1&1431655765,t=(858993459&t)+(t>>2&858993459),t=t+(t>>4)&252645135,t+=t>>8,127&(t+=t>>16)}function kt(t,e,r,n){var o=n?t:i(t);return o[e]=r,o}function At(t,e,r,n){var i=t.length+1;if(n&&e+1===i)return t[e]=r,t;for(var o=Array(i),u=0,s=0;so?0:o-r,c=u-r;return c>xe&&(c=xe),function(){if(i===c)return Wr;var t=e?--c:i++;return n&&n[t]}}function i(t,n,i){var s,a=t&&t.array,c=i>o?0:o-i>>n,h=1+(u-i>>n);return h>xe&&(h=xe),function(){for(;;){if(s){var t=s();if(t!==Wr)return t;s=null}if(c===h)return Wr;var o=e?--h:c++;s=r(a&&a[o],n-Ee,i+(o<=t.size||r<0)return t.withMutations(function(t){r<0?Nt(t,r).set(0,n):Nt(t,0,r+1).set(r,n)});r+=t._origin;var i=t._tail,o=t._root,s=e(Re);return r>=Vt(t._capacity)?i=Wt(i,t.__ownerID,0,r,n,s):o=Wt(o,t.__ownerID,t._level,r,n,s),s.value?t.__ownerID?(t._root=o,t._tail=i,t.__hash=void 0,t.__altered=!0,t):Lt(t._origin,t._capacity,t._level,o,i):t}function Wt(t,e,n,i,o,u){var s=i>>>n&je,a=t&&s0){var h=t&&t.array[s],f=Wt(h,e,n-Ee,i,o,u) +;return f===h?t:(c=Bt(t,e),c.array[s]=f,c)}return a&&t.array[s]===o?t:(r(u),c=Bt(t,e),void 0===o&&s===c.array.length-1?c.array.pop():c.array[s]=o,c)}function Bt(t,e){return e&&t&&e===t.ownerID?t:new Tr(t?t.array.slice():[],e)}function Jt(t,e){if(e>=Vt(t._capacity))return t._tail;if(e<1<0;)r=r.array[e>>>n&je],n-=Ee;return r}}function Nt(t,e,r){void 0!==e&&(e|=0),void 0!==r&&(r|=0);var i=t.__ownerID||new n,o=t._origin,u=t._capacity,s=o+e,a=void 0===r?u:r<0?u+r:o+r;if(s===o&&a===u)return t;if(s>=a)return t.clear();for(var c=t._level,h=t._root,f=0;s+f<0;)h=new Tr(h&&h.array.length?[void 0,h]:[],i),c+=Ee,f+=1<=1<p?new Tr([],i):l;if(l&&_>p&&sEe;d-=Ee){var g=p>>>d&je;y=y.array[g]=Bt(y.array[g],i)}y.array[p>>>Ee&je]=l}if(a=_)s-=_,a-=_,c=Ee,h=null,v=v&&v.removeBefore(i,0,s);else if(s>o||_>>c&je;if(m!==_>>>c&je)break;m&&(f+=(1<o&&(h=h.removeBefore(i,c,s-f)),h&&_i&&(i=u.size),n.push(u)}return i>t.size&&(t=t.setSize(i)),Et(t,e,n)}function Vt(t){return t>>Ee<=xe&&u.size>=2*o.size?(i=u.filter(function(t,e){return void 0!==t&&s!==e}),n=i.toKeyedSeq().map(function(t){return t[0]}).flip().toMap(), +t.__ownerID&&(n.__ownerID=i.__ownerID=t.__ownerID)):(n=o.remove(e),i=s===u.size-1?u.pop():u.set(s,void 0))}else if(a){if(r===u.get(s)[1])return t;n=o,i=u.set(s,[e,r])}else n=o.set(e,u.size),i=u.set(u.size,[e,r]);return t.__ownerID?(t.size=n.size,t._map=n,t._list=i,t.__hash=void 0,t):Yt(n,i)}function Ft(t){return!(!t||!t[Pr])}function Gt(t,e,r,n){var i=Object.create(Vr);return i.size=t,i._head=e,i.__ownerID=r,i.__hash=n,i.__altered=!1,i}function Zt(){return Hr||(Hr=Gt(0))}function $t(t,e){if(t===e)return!0;if(!l(e)||void 0!==t.size&&void 0!==e.size&&t.size!==e.size||void 0!==t.__hash&&void 0!==e.__hash&&t.__hash!==e.__hash||v(t)!==v(e)||y(t)!==y(e)||g(t)!==g(e))return!1;if(0===t.size&&0===e.size)return!0;var r=!d(t);if(g(t)){var n=t.entries();return e.every(function(t,e){var i=n.next().value;return i&&R(i[1],t)&&(r||R(i[0],e))})&&n.next().done}var i=!1;if(void 0===t.size)if(void 0===e.size)"function"==typeof t.cacheResult&&t.cacheResult();else{i=!0;var o=t;t=e,e=o}var u=!0,s=e.__iterate(function(e,n){if(r?!t.has(e):i?!R(e,t.get(n,ke)):!R(t.get(n,ke),e))return u=!1,!1});return u&&t.size===s}function te(t,e){var r=function(r){t.prototype[r]=e[r]};return Object.keys(e).forEach(r),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(e).forEach(r),t}function ee(t){return!(!t||!t[Qr])}function re(t,e){return t.__ownerID?(t.size=e.size,t._map=e,t):e===t._map?t:0===e.size?t.__empty():t.__make(e)}function ne(t,e){var r=Object.create(Xr);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function ie(){return Fr||(Fr=ne(gt()))}function oe(t,e,r,n,i,o){return pt(t.size),t.__iterate(function(t,o,u){i?(i=!1,r=t):r=e.call(n,r,t,o,u)},o),r}function ue(t,e){return e}function se(t,e){return[e,t]}function ae(t){return t&&"function"==typeof t.toJS?t.toJS():t}function ce(t){return function(){return!t.apply(this,arguments)}}function he(t){return function(){return-t.apply(this,arguments)}}function fe(){return i(arguments)}function pe(t,e){return te?-1:0}function _e(t){if(t.size===1/0)return 0;var e=g(t),r=v(t),n=e?1:0 +;return le(t.__iterate(r?e?function(t,e){n=31*n+ve(K(t),K(e))|0}:function(t,e){n=n+ve(K(t),K(e))|0}:e?function(t){n=31*n+K(t)|0}:function(t){n=n+K(t)|0}),n)}function le(t,e){return e=ar(e,3432918353),e=ar(e<<15|e>>>-15,461845907),e=ar(e<<13|e>>>-13,5),e=(e+3864292196|0)^t,e=ar(e^e>>>16,2246822507),e=ar(e^e>>>13,3266489909),e=U(e^e>>>16)}function ve(t,e){return t^e+2654435769+(t<<6)+(t>>2)|0}function ye(t){if("object"!=typeof console||!console.warn)throw Error(t);console.warn(t)}function de(t,e,r,n){for(var i=ht(r),o=0;o!==i.length;){if(!t||!t.get)return n&&ye("Invalid keyPath: Value at ["+i.slice(0,o).map(_t)+"] does not have a .get() method: "+t+"\nThis warning will throw in a future version"),e;if((t=t.get(i[o++],ke))===ke)return e}return t}function ge(t){return ee(t)&&g(t)}function me(t,e){var r=Object.create(nn);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function we(){return on||(on=me(Qt()))}function ze(t,e,r){var n=Object.create(Object.getPrototypeOf(t));return n._values=e,n.__ownerID=r,n}function Se(t){return t._name||t.constructor.name||"Record"}function Ie(t){return x(t._keys.map(function(e){return[e,t.get(e)]}))}function be(t,e){try{Object.defineProperty(t,e,{get:function(){return this.get(e)},set:function(t){ft(this.__ownerID,"Cannot set on an immutable record."),this.set(e,t)}})}catch(t){}}function Oe(t,e){return Me([],e||De,t,"",e&&e.length>2?[]:void 0,{"":t})}function Me(t,e,r,n,i,o){var u=Array.isArray(r)?$e:qe(r)?Ze:null;if(u){if(~t.indexOf(r))throw new TypeError("Cannot convert circular structure to Immutable");t.push(r),i&&""!==n&&i.push(n);var s=e.call(o,n,u(r).map(function(n,o){return Me(t,e,n,o,i,r)}),i&&i.slice());return t.pop(),i&&i.pop(),s}return r}function De(t,e){return v(e)?e.toMap():e.toList()}function qe(t){return t&&(t.constructor===Object||void 0===t.constructor)}var Ee=5,xe=1<=n.length){var e=r.next();if(e.done)return e;n[i]=e.value}return z(t,i,n[i++])})},e}($e),ar="function"==typeof Math.imul&&Math.imul(4294967295,2)===-2?Math.imul:function(t,e){t|=0,e|=0;var r=65535&t,n=65535&e;return r*n+((t>>>16)*n+r*(e>>>16)<<16>>>0)|0},cr=Object.isExtensible,hr=function(){try{return Object.defineProperty({},"@",{}),!0}catch(t){return!1}}(),fr="function"==typeof WeakMap;fr&&(or=new WeakMap);var pr=0,_r="__immutablehash__";"function"==typeof Symbol&&(_r=Symbol(_r));var lr=16,vr=255,yr=0,dr={},gr=function(t){function e(t,e){this._iter=t,this._useKeys=e,this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t,e){return this._iter.get(t,e)}, +e.prototype.has=function(t){return this._iter.has(t)},e.prototype.valueSeq=function(){return this._iter.valueSeq()},e.prototype.reverse=function(){var t=this,e=N(this,!0);return this._useKeys||(e.valueSeq=function(){return t._iter.toSeq().reverse()}),e},e.prototype.map=function(t,e){var r=this,n=J(this,t,e);return this._useKeys||(n.valueSeq=function(){return r._iter.toSeq().map(t,e)}),n},e.prototype.__iterate=function(t,e){var r=this;return this._iter.__iterate(function(e,n){return t(e,n,r)},e)},e.prototype.__iterator=function(t,e){return this._iter.__iterator(t,e)},e}(Ze);gr.prototype[Te]=!0;var mr=function(t){function e(t){this._iter=t,this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.includes=function(t){return this._iter.includes(t)},e.prototype.__iterate=function(t,e){var r=this,n=0;return e&&o(this),this._iter.__iterate(function(i){return t(i,e?r.size-++n:n++,r)},e)},e.prototype.__iterator=function(t,e){var r=this,n=this._iter.__iterator(Ve,e),i=0;return e&&o(this),new Fe(function(){var o=n.next();return o.done?o:z(t,e?r.size-++i:i++,o.value,o)})},e}($e),wr=function(t){function e(t){this._iter=t,this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.has=function(t){return this._iter.includes(t)},e.prototype.__iterate=function(t,e){var r=this;return this._iter.__iterate(function(e){return t(e,e,r)},e)},e.prototype.__iterator=function(t,e){var r=this._iter.__iterator(Ve,e);return new Fe(function(){var e=r.next();return e.done?e:z(t,e.value,e.value,e)})},e}(tr),zr=function(t){function e(t){this._iter=t,this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.entrySeq=function(){return this._iter.toSeq()},e.prototype.__iterate=function(t,e){var r=this;return this._iter.__iterate(function(e){if(e){ot(e);var n=l(e);return t(n?e.get(1):e[1],n?e.get(0):e[0],r)}},e)},e.prototype.__iterator=function(t,e){ +var r=this._iter.__iterator(Ve,e);return new Fe(function(){for(;;){var e=r.next();if(e.done)return e;var n=e.value;if(n){ot(n);var i=l(n);return z(t,i?n.get(0):n[0],i?n.get(1):n[1],e)}}})},e}(Ze);mr.prototype.cacheResult=gr.prototype.cacheResult=wr.prototype.cacheResult=zr.prototype.cacheResult=at;var Sr=function(t){function e(e){return null===e||void 0===e?gt():lt(e)&&!g(e)?e:gt().withMutations(function(r){var n=t(e);pt(n.size),n.forEach(function(t,e){return r.set(e,t)})})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return gt().withMutations(function(e){for(var r=0;r=t.length)throw Error("Missing value for key: "+t[r]);e.set(t[r],t[r+1])}})},e.prototype.toString=function(){return this.__toString("Map {","}")},e.prototype.get=function(t,e){return this._root?this._root.get(0,void 0,t,e):e},e.prototype.set=function(t,e){return mt(this,t,e)},e.prototype.setIn=function(t,e){return this.updateIn(t,ke,function(){return e})},e.prototype.remove=function(t){return mt(this,t,ke)},e.prototype.deleteIn=function(t){if(t=[].concat(ht(t)),t.length){var e=t.pop();return this.updateIn(t,function(t){return t&&t.remove(e)})}},e.prototype.deleteAll=function(t){var e=We(t);return 0===e.size?this:this.withMutations(function(t){e.forEach(function(e){return t.remove(e)})})},e.prototype.update=function(t,e,r){return 1===arguments.length?t(this):this.updateIn([t],e,r)},e.prototype.updateIn=function(t,e,r){r||(r=e,e=void 0);var n=xt(this,ht(t),0,e,r);return n===ke?e:n},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):gt()},e.prototype.merge=function(){return Mt(this,void 0,arguments)},e.prototype.mergeWith=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Mt(this,t,e)},e.prototype.mergeIn=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1] +;return this.updateIn(t,gt(),function(t){return"function"==typeof t.merge?t.merge.apply(t,e):e[e.length-1]})},e.prototype.mergeDeep=function(){return Mt(this,Dt,arguments)},e.prototype.mergeDeepWith=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Mt(this,qt(t),e)},e.prototype.mergeDeepIn=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return this.updateIn(t,gt(),function(t){return"function"==typeof t.mergeDeep?t.mergeDeep.apply(t,e):e[e.length-1]})},e.prototype.sort=function(t){return Br(tt(this,t))},e.prototype.sortBy=function(t,e){return Br(tt(this,e,t))},e.prototype.withMutations=function(t){var e=this.asMutable();return t(e),e.wasAltered()?e.__ensureOwner(this.__ownerID):this},e.prototype.asMutable=function(){return this.__ownerID?this:this.__ensureOwner(new n)},e.prototype.asImmutable=function(){return this.__ensureOwner()},e.prototype.wasAltered=function(){return this.__altered},e.prototype.__iterator=function(t,e){return new jr(this,t,e)},e.prototype.__iterate=function(t,e){var r=this,n=0;return this._root&&this._root.iterate(function(e){return n++,t(e[1],e[0],r)},e),n},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?dt(this.size,this._root,t,this.__hash):0===this.size?gt():(this.__ownerID=t,this.__altered=!1,this)},e}(Be);Sr.isMap=lt;var Ir="@@__IMMUTABLE_MAP__@@",br=Sr.prototype;br[Ir]=!0,br.delete=br.remove,br.removeIn=br.deleteIn,br.removeAll=br.deleteAll,br["@@transducer/init"]=br.asMutable,br["@@transducer/step"]=function(t,e){return t.set(e[0],e[1])},br["@@transducer/result"]=function(t){return t.asImmutable()};var Or=function(t,e){this.ownerID=t,this.entries=e};Or.prototype.get=function(t,e,r,n){for(var i=this.entries,o=0,u=i.length;o=kr)return It(t,h,o,u) +;var l=t&&t===this.ownerID,v=l?h:i(h);return _?c?f===p-1?v.pop():v[f]=v.pop():v[f]=[o,u]:v.push([o,u]),l?(this.entries=v,this):new Or(t,v)}};var Mr=function(t,e,r){this.ownerID=t,this.bitmap=e,this.nodes=r};Mr.prototype.get=function(t,e,r,n){void 0===e&&(e=K(r));var i=1<<((0===t?e:e>>>t)&je),o=this.bitmap;return 0==(o&i)?n:this.nodes[jt(o&i-1)].get(t+Ee,e,r,n)},Mr.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=K(n));var s=(0===e?r:r>>>e)&je,a=1<=Ar)return Ot(t,p,c,s,l);if(h&&!l&&2===p.length&&zt(p[1^f]))return p[1^f];if(h&&l&&1===p.length&&zt(l))return l;var v=t&&t===this.ownerID,y=h?l?c:c^a:c|a,d=h?l?kt(p,f,l,v):Rt(p,f,v):At(p,f,l,v);return v?(this.bitmap=y,this.nodes=d,this):new Mr(t,y,d)};var Dr=function(t,e,r){this.ownerID=t,this.count=e,this.nodes=r};Dr.prototype.get=function(t,e,r,n){void 0===e&&(e=K(r));var i=(0===t?e:e>>>t)&je,o=this.nodes[i];return o?o.get(t+Ee,e,r,n):n},Dr.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=K(n));var s=(0===e?r:r>>>e)&je,a=i===ke,c=this.nodes,h=c[s];if(a&&!h)return this;var f=wt(h,t,e+Ee,r,n,i,o,u);if(f===h)return this;var p=this.count;if(h){if(!f&&--p0&&i=0&&t0;)e[r]=arguments[r+1];return Pt(this,t,e)},e.prototype.mergeDeep=function(){return Pt(this,Dt,arguments)},e.prototype.mergeDeepWith=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Pt(this,qt(t),e)},e.prototype.setSize=function(t){return Nt(this,0,t)},e.prototype.slice=function(t,e){var r=this.size;return a(t,e,r)?this:Nt(this,c(t,r),h(e,r))},e.prototype.__iterator=function(t,e){var r=e?this.size:0,n=Kt(this,e);return new Fe(function(){var i=n();return i===Wr?S():z(t,e?--r:r++,i)})},e.prototype.__iterate=function(t,e){for(var r,n=this,i=e?this.size:0,o=Kt(this,e);(r=o())!==Wr&&t(r,e?--i:i++,n)!==!1;);return i},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Lt(this._origin,this._capacity,this._level,this._root,this._tail,t,this.__hash):0===this.size?Tt():(this.__ownerID=t,this.__altered=!1,this)},e}(Je);Ur.isList=Ut;var Kr="@@__IMMUTABLE_LIST__@@",Lr=Ur.prototype;Lr[Kr]=!0,Lr.delete=Lr.remove,Lr.setIn=br.setIn,Lr.deleteIn=Lr.removeIn=br.removeIn,Lr.update=br.update,Lr.updateIn=br.updateIn,Lr.mergeIn=br.mergeIn, +Lr.mergeDeepIn=br.mergeDeepIn,Lr.withMutations=br.withMutations,Lr.asMutable=br.asMutable,Lr.asImmutable=br.asImmutable,Lr.wasAltered=br.wasAltered,Lr["@@transducer/init"]=Lr.asMutable,Lr["@@transducer/step"]=function(t,e){return t.push(e)},Lr["@@transducer/result"]=br["@@transducer/result"];var Tr=function(t,e){this.array=t,this.ownerID=e};Tr.prototype.removeBefore=function(t,e,r){if(r===e?1<>>e&je;if(n>=this.array.length)return new Tr([],t);var i,o=0===n;if(e>0){var u=this.array[n];if((i=u&&u.removeBefore(t,e-Ee,r))===u&&o)return this}if(o&&!i)return this;var s=Bt(this,t);if(!o)for(var a=0;a>>e&je;if(n>=this.array.length)return this;var i;if(e>0){var o=this.array[n];if((i=o&&o.removeAfter(t,e-Ee,r))===o&&n===this.array.length-1)return this}var u=Bt(this,t);return u.array.splice(n+1),i&&(u.array[n]=i),u};var Cr,Wr={},Br=function(t){function e(t){return null===t||void 0===t?Qt():Ht(t)?t:Qt().withMutations(function(e){var r=Be(t);pt(r.size),r.forEach(function(t,r){return e.set(r,t)})})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("OrderedMap {","}")},e.prototype.get=function(t,e){var r=this._map.get(t);return void 0!==r?this._list.get(r)[1]:e},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._map.clear(),this._list.clear(),this):Qt()},e.prototype.set=function(t,e){return Xt(this,t,e)},e.prototype.remove=function(t){return Xt(this,t,ke)},e.prototype.wasAltered=function(){return this._map.wasAltered()||this._list.wasAltered()},e.prototype.__iterate=function(t,e){var r=this;return this._list.__iterate(function(e){return e&&t(e[1],e[0],r)},e)},e.prototype.__iterator=function(t,e){return this._list.fromEntrySeq().__iterator(t,e)}, +e.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var e=this._map.__ensureOwner(t),r=this._list.__ensureOwner(t);return t?Yt(e,r,t,this.__hash):0===this.size?Qt():(this.__ownerID=t,this._map=e,this._list=r,this)},e}(Sr);Br.isOrderedMap=Ht,Br.prototype[Te]=!0,Br.prototype.delete=Br.prototype.remove;var Jr,Nr=function(t){function e(t){return null===t||void 0===t?Zt():Ft(t)?t:Zt().pushAll(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("Stack [","]")},e.prototype.get=function(t,e){var r=this._head;for(t=u(this,t);r&&t--;)r=r.next;return r?r.value:e},e.prototype.peek=function(){return this._head&&this._head.value},e.prototype.push=function(){var t=arguments;if(0===arguments.length)return this;for(var e=this.size+arguments.length,r=this._head,n=arguments.length-1;n>=0;n--)r={value:t[n],next:r};return this.__ownerID?(this.size=e,this._head=r,this.__hash=void 0,this.__altered=!0,this):Gt(e,r)},e.prototype.pushAll=function(e){if(e=t(e),0===e.size)return this;if(0===this.size&&Ft(e))return e;pt(e.size);var r=this.size,n=this._head;return e.__iterate(function(t){r++,n={value:t,next:n}},!0),this.__ownerID?(this.size=r,this._head=n,this.__hash=void 0,this.__altered=!0,this):Gt(r,n)},e.prototype.pop=function(){return this.slice(1)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):Zt()},e.prototype.slice=function(e,r){if(a(e,r,this.size))return this;var n=c(e,this.size);if(h(r,this.size)!==this.size)return t.prototype.slice.call(this,e,r);for(var i=this.size-n,o=this._head;n--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):Gt(i,o)},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Gt(this.size,this._head,t,this.__hash):0===this.size?Zt():(this.__ownerID=t,this.__altered=!1,this)}, +e.prototype.__iterate=function(t,e){var r=this;if(e)return new rr(this.toArray()).__iterate(function(e,n){return t(e,n,r)},e);for(var n=0,i=this._head;i&&t(i.value,n++,r)!==!1;)i=i.next;return n},e.prototype.__iterator=function(t,e){if(e)return new rr(this.toArray()).__iterator(t,e);var r=0,n=this._head;return new Fe(function(){if(n){var e=n.value;return n=n.next,z(t,r++,e)}return S()})},e}(Je);Nr.isStack=Ft;var Pr="@@__IMMUTABLE_STACK__@@",Vr=Nr.prototype;Vr[Pr]=!0,Vr.withMutations=br.withMutations,Vr.asMutable=br.asMutable,Vr.asImmutable=br.asImmutable,Vr.wasAltered=br.wasAltered,Vr.shift=Vr.pop,Vr.unshift=Vr.push,Vr.unshiftAll=Vr.pushAll,Vr["@@transducer/init"]=Vr.asMutable,Vr["@@transducer/step"]=function(t,e){return t.unshift(e)},Vr["@@transducer/result"]=br["@@transducer/result"];var Hr,Yr=function(t){function e(e){return null===e||void 0===e?ie():ee(e)&&!g(e)?e:ie().withMutations(function(r){var n=t(e);pt(n.size),n.forEach(function(t){return r.add(t)})})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(Be(t).keySeq())},e.intersect=function(t){return t=We(t).toArray(),t.length?Xr.intersect.apply(e(t.pop()),t):ie()},e.union=function(t){return t=We(t).toArray(),t.length?Xr.union.apply(e(t.pop()),t):ie()},e.prototype.toString=function(){return this.__toString("Set {","}")},e.prototype.has=function(t){return this._map.has(t)},e.prototype.add=function(t){return re(this,this._map.set(t,t))},e.prototype.remove=function(t){return re(this,this._map.remove(t))},e.prototype.clear=function(){return re(this,this._map.clear())},e.prototype.union=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return e=e.filter(function(t){return 0!==t.size}),0===e.length?this:0!==this.size||this.__ownerID||1!==e.length?this.withMutations(function(r){for(var n=0;n0;)e[r]=arguments[r+1];return this.union.apply(this,e)},e.prototype.sort=function(t){return rn(tt(this,t))},e.prototype.sortBy=function(t,e){return rn(tt(this,e,t))},e.prototype.wasAltered=function(){return this._map.wasAltered()},e.prototype.__iterate=function(t,e){var r=this;return this._map.__iterate(function(e){return t(e,e,r)},e)},e.prototype.__iterator=function(t,e){return this._map.__iterator(t,e)},e.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var e=this._map.__ensureOwner(t);return t?this.__make(e,t):0===this.size?this.__empty():(this.__ownerID=t,this._map=e,this)},e}(Ne);Yr.isSet=ee;var Qr="@@__IMMUTABLE_SET__@@",Xr=Yr.prototype;Xr[Qr]=!0,Xr.delete=Xr.remove,Xr.mergeDeep=Xr.merge,Xr.mergeDeepWith=Xr.mergeWith,Xr.withMutations=br.withMutations,Xr.asMutable=br.asMutable,Xr.asImmutable=br.asImmutable,Xr["@@transducer/init"]=Xr.asMutable,Xr["@@transducer/step"]=function(t,e){return t.add(e)},Xr["@@transducer/result"]=br["@@transducer/result"],Xr.__empty=ie,Xr.__make=ne;var Fr,Gr,Zr=function(t){function e(t,r,n){if(!(this instanceof e))return new e(t,r,n);if(ft(0!==n,"Cannot step a Range by 0"),t=t||0,void 0===r&&(r=1/0),n=void 0===n?1:Math.abs(n),r=0&&e=0&&rthis.size?e:this.find(function(e,r){return r===t},void 0,e)},has:function(t){return(t=u(this,t))>=0&&(void 0!==this.size?this.size===1/0||t Date: Thu, 5 Oct 2017 02:58:01 +0000 Subject: [PATCH 038/242] Deploy master to NPM branch --- dist/immutable-nonambient.d.ts | 27 +++++++++++++++++++++++++++ dist/immutable.d.ts | 27 +++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/dist/immutable-nonambient.d.ts b/dist/immutable-nonambient.d.ts index 2bdfdcd995..946f3a76e7 100644 --- a/dist/immutable-nonambient.d.ts +++ b/dist/immutable-nonambient.d.ts @@ -2428,6 +2428,33 @@ * var myRecord = new ABRecord({b: 3}) * myRecord.getAB() // 4 * ``` + * + * + * **Flow Typing Records:** + * + * Immutable.js exports two Flow types designed to make it easier to use + * Records with flow typed code, `RecordOf` and `RecordFactory`. + * + * When defining a new kind of Record factory function, use a flow type that + * describes the values the record contains along with `RecordFactory`. + * To type instances of the Record (which the factory function returns), + * use `RecordOf`. + * + * Typically, new Record definitions will export both the Record factory + * function as well as the Record instance type for use in other code. + * + * ```js + * import type { RecordFactory, RecordOf } from 'immutable'; + * + * // Use RecordFactory for defining new Record factory functions. + * type Point3DFields = { x: number, y: number, z: number }; + * const makePoint3D: RecordFactory = Record({ x: 0, y: 0, z: 0 }); + * export makePoint3D; + * + * // Use RecordOf for defining new instances of that Record. + * export type Point3D = RecordOf; + * const some3DPoint: Point3D = makePoint3D({ x: 10, y: 20, z: 30 }); + * ``` */ export module Record { diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index 61cf89f54b..95650b665c 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -2428,6 +2428,33 @@ declare module Immutable { * var myRecord = new ABRecord({b: 3}) * myRecord.getAB() // 4 * ``` + * + * + * **Flow Typing Records:** + * + * Immutable.js exports two Flow types designed to make it easier to use + * Records with flow typed code, `RecordOf` and `RecordFactory`. + * + * When defining a new kind of Record factory function, use a flow type that + * describes the values the record contains along with `RecordFactory`. + * To type instances of the Record (which the factory function returns), + * use `RecordOf`. + * + * Typically, new Record definitions will export both the Record factory + * function as well as the Record instance type for use in other code. + * + * ```js + * import type { RecordFactory, RecordOf } from 'immutable'; + * + * // Use RecordFactory for defining new Record factory functions. + * type Point3DFields = { x: number, y: number, z: number }; + * const makePoint3D: RecordFactory = Record({ x: 0, y: 0, z: 0 }); + * export makePoint3D; + * + * // Use RecordOf for defining new instances of that Record. + * export type Point3D = RecordOf; + * const some3DPoint: Point3D = makePoint3D({ x: 10, y: 20, z: 30 }); + * ``` */ export module Record { From 9402b69a25af31401938bc5409acf90d2b035ce9 Mon Sep 17 00:00:00 2001 From: Travis CI Date: Thu, 5 Oct 2017 03:44:04 +0000 Subject: [PATCH 039/242] Deploy master to NPM branch --- bower.json | 3 ++- dist/immutable.es.js | 6 +++++- dist/immutable.js | 5 +++++ dist/immutable.min.js | 2 +- package.json | 3 ++- 5 files changed, 15 insertions(+), 4 deletions(-) diff --git a/bower.json b/bower.json index f014012f69..d6ecb96303 100644 --- a/bower.json +++ b/bower.json @@ -38,5 +38,6 @@ "stateless", "sequence", "iteration" - ] + ], + "dependencies": {} } \ No newline at end of file diff --git a/dist/immutable.es.js b/dist/immutable.es.js index 8f7de12445..0debe0db3a 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -5558,7 +5558,11 @@ function isPlainObj(value) { ); } +var version = "4.0.0-rc.4"; + var Immutable = { + version: version, + Collection: Collection, // Note: Iterable is deprecated Iterable: Collection, @@ -5591,4 +5595,4 @@ var Immutable = { // Note: Iterable is deprecated var Iterable = Collection; -export { Collection, Iterable, Seq, Map, OrderedMap, List, Stack, Set, OrderedSet, Record, Range, Repeat, is, fromJS, hash, isImmutable, isCollection, isKeyed, isIndexed, isAssociative, isOrdered, isValueObject };export default Immutable; +export { version, Collection, Iterable, Seq, Map, OrderedMap, List, Stack, Set, OrderedSet, Record, Range, Repeat, is, fromJS, hash, isImmutable, isCollection, isKeyed, isIndexed, isAssociative, isOrdered, isValueObject };export default Immutable; diff --git a/dist/immutable.js b/dist/immutable.js index 170f6584b3..22d8aa2fc2 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -5564,7 +5564,11 @@ function isPlainObj(value) { ); } +var version = "4.0.0-rc.4"; + var Immutable = { + version: version, + Collection: Collection, // Note: Iterable is deprecated Iterable: Collection, @@ -5598,6 +5602,7 @@ var Immutable = { var Iterable = Collection; exports['default'] = Immutable; +exports.version = version; exports.Collection = Collection; exports.Iterable = Iterable; exports.Seq = Seq; diff --git a/dist/immutable.min.js b/dist/immutable.min.js index 67286f25a2..de8ad7f45f 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -34,4 +34,4 @@ return new wr(this)},toSeq:function(){return y(this)?this.toIndexedSeq():v(this) takeUntil:function(t,e){return this.takeWhile(ce(t),e)},update:function(t){return t(this)},valueSeq:function(){return this.toIndexedSeq()},hashCode:function(){return this.__hash||(this.__hash=_e(this))}});var $r=We.prototype;$r[Ue]=!0,$r[Xe]=$r.values,$r.toJSON=$r.toArray,$r.__toStringMapper=_t,$r.inspect=$r.toSource=function(){return""+this},$r.chain=$r.flatMap,$r.contains=$r.includes,te(Be,{flip:function(){return it(this,B(this))},mapEntries:function(t,e){var r=this,n=0;return it(this,this.toSeq().map(function(i,o){return t.call(e,[o,i],n++,r)}).fromEntrySeq())},mapKeys:function(t,e){var r=this;return it(this,this.toSeq().flip().map(function(n,i){return t.call(e,n,i,r)}).flip())}});var tn=Be.prototype;tn[Ke]=!0,tn[Xe]=$r.entries,tn.toJSON=$r.toObject,tn.__toStringMapper=function(t,e){return _t(e)+": "+_t(t)},te(Je,{toKeyedSeq:function(){return new gr(this,!1)},filter:function(t,e){return it(this,P(this,t,e,!1))},findIndex:function(t,e){var r=this.findEntry(t,e);return r?r[0]:-1},indexOf:function(t){var e=this.keyOf(t);return void 0===e?-1:e},lastIndexOf:function(t){var e=this.lastKeyOf(t);return void 0===e?-1:e},reverse:function(){return it(this,N(this,!1))},slice:function(t,e){return it(this,Y(this,t,e,!1))},splice:function(t,e){var r=arguments.length;if(e=Math.max(e||0,0),0===r||2===r&&!e)return this;t=c(t,t<0?this.count():this.size);var n=this.slice(0,t);return it(this,1===r?n:n.concat(i(arguments,2),this.slice(t+e)))},findLastIndex:function(t,e){var r=this.findLastEntry(t,e);return r?r[0]:-1},first:function(){return this.get(0)},flatten:function(t){return it(this,G(this,t,!1))},get:function(t,e){return t=u(this,t),t<0||this.size===1/0||void 0!==this.size&&t>this.size?e:this.find(function(e,r){return r===t},void 0,e)},has:function(t){return(t=u(this,t))>=0&&(void 0!==this.size?this.size===1/0||t Date: Thu, 5 Oct 2017 03:46:39 +0000 Subject: [PATCH 040/242] Deploy master to NPM branch --- dist/immutable-nonambient.d.ts | 38 +++-------------- dist/immutable.d.ts | 38 +++-------------- dist/immutable.es.js | 76 +++++++--------------------------- dist/immutable.js | 76 +++++++--------------------------- dist/immutable.js.flow | 12 ------ dist/immutable.min.js | 62 +++++++++++++-------------- 6 files changed, 69 insertions(+), 233 deletions(-) diff --git a/dist/immutable-nonambient.d.ts b/dist/immutable-nonambient.d.ts index 946f3a76e7..805b459d90 100644 --- a/dist/immutable-nonambient.d.ts +++ b/dist/immutable-nonambient.d.ts @@ -675,39 +675,6 @@ update(index: number, updater: (value: T) => T): this; update(updater: (value: this) => R): R; - /** - * Note: `merge` can be used in `withMutations`. - * - * @see `Map#merge` - */ - merge(...collections: Array>): this; - - /** - * Note: `mergeWith` can be used in `withMutations`. - * - * @see `Map#mergeWith` - */ - mergeWith( - merger: (oldVal: T, newVal: T, key: number) => T, - ...collections: Array> - ): this; - - /** - * Note: `mergeDeep` can be used in `withMutations`. - * - * @see `Map#mergeDeep` - */ - mergeDeep(...collections: Array>): this; - - /** - * Note: `mergeDeepWith` can be used in `withMutations`. - * @see `Map#mergeDeepWith` - */ - mergeDeepWith( - merger: (oldVal: T, newVal: T, key: number) => T, - ...collections: Array> - ): this; - /** * Returns a new List with size `size`. If `size` is less than this * List's size, the new List will exclude values at the higher indices. @@ -819,8 +786,13 @@ /** * Returns a new List with other values or collections concatenated to this one. + * + * Note: `concat` *cannot* be safely used in `withMutations`. + * + * @alias merge */ concat(...valuesOrCollections: Array | C>): List; + merge(...collections: Array): List; /** * Returns a new List with values passed through a diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index 95650b665c..91bbbce48a 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -675,39 +675,6 @@ declare module Immutable { update(index: number, updater: (value: T) => T): this; update(updater: (value: this) => R): R; - /** - * Note: `merge` can be used in `withMutations`. - * - * @see `Map#merge` - */ - merge(...collections: Array>): this; - - /** - * Note: `mergeWith` can be used in `withMutations`. - * - * @see `Map#mergeWith` - */ - mergeWith( - merger: (oldVal: T, newVal: T, key: number) => T, - ...collections: Array> - ): this; - - /** - * Note: `mergeDeep` can be used in `withMutations`. - * - * @see `Map#mergeDeep` - */ - mergeDeep(...collections: Array>): this; - - /** - * Note: `mergeDeepWith` can be used in `withMutations`. - * @see `Map#mergeDeepWith` - */ - mergeDeepWith( - merger: (oldVal: T, newVal: T, key: number) => T, - ...collections: Array> - ): this; - /** * Returns a new List with size `size`. If `size` is less than this * List's size, the new List will exclude values at the higher indices. @@ -819,8 +786,13 @@ declare module Immutable { /** * Returns a new List with other values or collections concatenated to this one. + * + * Note: `concat` *cannot* be safely used in `withMutations`. + * + * @alias merge */ concat(...valuesOrCollections: Array | C>): List; + merge(...collections: Array): List; /** * Returns a new List with values passed through a diff --git a/dist/immutable.es.js b/dist/immutable.es.js index 0debe0db3a..879d4f26aa 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -2045,7 +2045,7 @@ var Map = (function (KeyedCollection$$1) { }; Map.prototype.mergeDeep = function mergeDeep (/*...iters*/) { - return mergeIntoMapWith(this, deepMerger, arguments); + return mergeIntoMapWith(this, deepMergerWith(alwaysNewVal), arguments); }; Map.prototype.mergeDeepWith = function mergeDeepWith (merger) { @@ -2732,21 +2732,19 @@ function mergeIntoMapWith(map, merger, collections) { return mergeIntoCollectionWith(map, merger, iters); } -function deepMerger(oldVal, newVal) { - return newVal && typeof newVal === 'object' && oldVal && oldVal.mergeDeep - ? oldVal.mergeDeep(newVal) - : is(oldVal, newVal) ? oldVal : newVal; +function alwaysNewVal(oldVal, newVal) { + return newVal; } function deepMergerWith(merger) { - return function (oldVal, newVal, key) { - if ( - newVal && - typeof newVal === 'object' && - oldVal && - oldVal.mergeDeepWith - ) { - return oldVal.mergeDeepWith(merger, newVal); + return function(oldVal, newVal, key) { + if (oldVal && newVal && typeof newVal === 'object') { + if (oldVal.mergeDeepWith) { + return oldVal.mergeDeepWith(merger, newVal); + } + if (oldVal.merge) { + return oldVal.merge(newVal); + } } var nextValue = merger(oldVal, newVal, key); return is(oldVal, nextValue) ? oldVal : nextValue; @@ -2977,26 +2975,8 @@ var List = (function (IndexedCollection$$1) { // @pragma Composition - List.prototype.merge = function merge (/*...iters*/) { - return mergeIntoListWith(this, undefined, arguments); - }; - - List.prototype.mergeWith = function mergeWith (merger) { - var iters = [], len = arguments.length - 1; - while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; - - return mergeIntoListWith(this, merger, iters); - }; - - List.prototype.mergeDeep = function mergeDeep (/*...iters*/) { - return mergeIntoListWith(this, deepMerger, arguments); - }; - - List.prototype.mergeDeepWith = function mergeDeepWith (merger) { - var iters = [], len = arguments.length - 1; - while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; - - return mergeIntoListWith(this, deepMergerWith(merger), iters); + List.prototype.merge = function merge (/*...collections*/) { + return this.concat.apply(this, arguments); }; List.prototype.setSize = function setSize (size) { @@ -3497,22 +3477,6 @@ function setListBounds(list, begin, end) { return makeList(newOrigin, newCapacity, newLevel, newRoot, newTail); } -function mergeIntoListWith(list, merger, collections) { - var iters = []; - var maxSize = 0; - for (var ii = 0; ii < collections.length; ii++) { - var iter = IndexedCollection(collections[ii]); - if (iter.size > maxSize) { - maxSize = iter.size; - } - iters.push(iter); - } - if (maxSize > list.size) { - list = list.setSize(maxSize); - } - return mergeIntoCollectionWith(list, merger, iters); -} - function getTailOffset(size) { return size < SIZE ? 0 : ((size - 1) >>> SHIFT) << SHIFT; } @@ -4112,17 +4076,6 @@ var Set = (function (SetCollection$$1) { }); }; - Set.prototype.merge = function merge () { - return this.union.apply(this, arguments); - }; - - Set.prototype.mergeWith = function mergeWith (merger) { - var iters = [], len = arguments.length - 1; - while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; - - return this.union.apply(this, iters); - }; - Set.prototype.sort = function sort (comparator) { // Late binding return OrderedSet(sortFactory(this, comparator)); @@ -4177,8 +4130,7 @@ var IS_SET_SENTINEL = '@@__IMMUTABLE_SET__@@'; var SetPrototype = Set.prototype; SetPrototype[IS_SET_SENTINEL] = true; SetPrototype[DELETE] = SetPrototype.remove; -SetPrototype.mergeDeep = SetPrototype.merge; -SetPrototype.mergeDeepWith = SetPrototype.mergeWith; +SetPrototype.merge = SetPrototype.union; SetPrototype.withMutations = MapPrototype.withMutations; SetPrototype.asMutable = MapPrototype.asMutable; SetPrototype.asImmutable = MapPrototype.asImmutable; diff --git a/dist/immutable.js b/dist/immutable.js index 22d8aa2fc2..1ef7aeca13 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -2051,7 +2051,7 @@ var Map = (function (KeyedCollection$$1) { }; Map.prototype.mergeDeep = function mergeDeep (/*...iters*/) { - return mergeIntoMapWith(this, deepMerger, arguments); + return mergeIntoMapWith(this, deepMergerWith(alwaysNewVal), arguments); }; Map.prototype.mergeDeepWith = function mergeDeepWith (merger) { @@ -2738,21 +2738,19 @@ function mergeIntoMapWith(map, merger, collections) { return mergeIntoCollectionWith(map, merger, iters); } -function deepMerger(oldVal, newVal) { - return newVal && typeof newVal === 'object' && oldVal && oldVal.mergeDeep - ? oldVal.mergeDeep(newVal) - : is(oldVal, newVal) ? oldVal : newVal; +function alwaysNewVal(oldVal, newVal) { + return newVal; } function deepMergerWith(merger) { - return function (oldVal, newVal, key) { - if ( - newVal && - typeof newVal === 'object' && - oldVal && - oldVal.mergeDeepWith - ) { - return oldVal.mergeDeepWith(merger, newVal); + return function(oldVal, newVal, key) { + if (oldVal && newVal && typeof newVal === 'object') { + if (oldVal.mergeDeepWith) { + return oldVal.mergeDeepWith(merger, newVal); + } + if (oldVal.merge) { + return oldVal.merge(newVal); + } } var nextValue = merger(oldVal, newVal, key); return is(oldVal, nextValue) ? oldVal : nextValue; @@ -2983,26 +2981,8 @@ var List = (function (IndexedCollection$$1) { // @pragma Composition - List.prototype.merge = function merge (/*...iters*/) { - return mergeIntoListWith(this, undefined, arguments); - }; - - List.prototype.mergeWith = function mergeWith (merger) { - var iters = [], len = arguments.length - 1; - while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; - - return mergeIntoListWith(this, merger, iters); - }; - - List.prototype.mergeDeep = function mergeDeep (/*...iters*/) { - return mergeIntoListWith(this, deepMerger, arguments); - }; - - List.prototype.mergeDeepWith = function mergeDeepWith (merger) { - var iters = [], len = arguments.length - 1; - while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; - - return mergeIntoListWith(this, deepMergerWith(merger), iters); + List.prototype.merge = function merge (/*...collections*/) { + return this.concat.apply(this, arguments); }; List.prototype.setSize = function setSize (size) { @@ -3503,22 +3483,6 @@ function setListBounds(list, begin, end) { return makeList(newOrigin, newCapacity, newLevel, newRoot, newTail); } -function mergeIntoListWith(list, merger, collections) { - var iters = []; - var maxSize = 0; - for (var ii = 0; ii < collections.length; ii++) { - var iter = IndexedCollection(collections[ii]); - if (iter.size > maxSize) { - maxSize = iter.size; - } - iters.push(iter); - } - if (maxSize > list.size) { - list = list.setSize(maxSize); - } - return mergeIntoCollectionWith(list, merger, iters); -} - function getTailOffset(size) { return size < SIZE ? 0 : ((size - 1) >>> SHIFT) << SHIFT; } @@ -4118,17 +4082,6 @@ var Set = (function (SetCollection$$1) { }); }; - Set.prototype.merge = function merge () { - return this.union.apply(this, arguments); - }; - - Set.prototype.mergeWith = function mergeWith (merger) { - var iters = [], len = arguments.length - 1; - while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; - - return this.union.apply(this, iters); - }; - Set.prototype.sort = function sort (comparator) { // Late binding return OrderedSet(sortFactory(this, comparator)); @@ -4183,8 +4136,7 @@ var IS_SET_SENTINEL = '@@__IMMUTABLE_SET__@@'; var SetPrototype = Set.prototype; SetPrototype[IS_SET_SENTINEL] = true; SetPrototype[DELETE] = SetPrototype.remove; -SetPrototype.mergeDeep = SetPrototype.merge; -SetPrototype.mergeDeepWith = SetPrototype.mergeWith; +SetPrototype.merge = SetPrototype.union; SetPrototype.withMutations = MapPrototype.withMutations; SetPrototype.asMutable = MapPrototype.asMutable; SetPrototype.asImmutable = MapPrototype.asImmutable; diff --git a/dist/immutable.js.flow b/dist/immutable.js.flow index 186cd8f614..50b909722a 100644 --- a/dist/immutable.js.flow +++ b/dist/immutable.js.flow @@ -636,18 +636,6 @@ declare class List<+T> extends IndexedCollection { merge(...collections: Iterable[]): List; - mergeWith( - merger: (oldVal: T, newVal: U, key: number) => V, - ...collections: Iterable[] - ): List; - - mergeDeep(...collections: Iterable[]): List; - - mergeDeepWith( - merger: (oldVal: T, newVal: U, key: number) => V, - ...collections: Iterable[] - ): List; - setSize(size: number): this; setIn(keyPath: Iterable, value: mixed): this; deleteIn(keyPath: Iterable, value: mixed): this; diff --git a/dist/immutable.min.js b/dist/immutable.min.js index de8ad7f45f..a4aa91f873 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -4,34 +4,34 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.Immutable=t.Immutable||{})}(this,function(t){"use strict";function e(t){return t.value=!1,t}function r(t){t&&(t.value=!0)}function n(){}function i(t,e){e=e||0;for(var r=Math.max(0,t.length-e),n=Array(r),i=0;i>>0;if(""+r!==e||4294967295===r)return NaN;e=r}return e<0?o(t)+e:e}function s(){return!0}function a(t,e,r){return(0===t&&!p(t)||void 0!==r&&t<=-r)&&(void 0===e||void 0!==r&&e>=r)}function c(t,e){return f(t,e,0)}function h(t,e){return f(t,e,e)}function f(t,e,r){return void 0===t?r:p(t)?e===1/0?e:0|Math.max(0,e+t):void 0===e||e===t?t:0|Math.min(e,t)}function p(t){return t<0||0===t&&1/t==-(1/0)}function _(t){return(l(t)||m(t))&&!t.__ownerID}function l(t){return!(!t||!t[Ue])}function v(t){return!(!t||!t[Ke])}function y(t){return!(!t||!t[Le])}function d(t){return v(t)||y(t)}function g(t){return!(!t||!t[Te])}function m(t){return!(!t||!t[Ce])}function w(t){return!(!t||"function"!=typeof t.equals||"function"!=typeof t.hashCode)}function z(t,e,r,n){var i=0===t?e:1===t?r:[e,r];return n?n.value=i:n={value:i,done:!1},n}function S(){return{value:void 0,done:!0}}function I(t){return!!M(t)}function b(t){return t&&"function"==typeof t.next}function O(t){var e=M(t);return e&&e.call(t)}function M(t){var e=t&&(Ye&&t[Ye]||t[Qe]);if("function"==typeof e)return e}function D(t){return t&&"number"==typeof t.length}function q(t){return!(!t||!t[er])}function E(){return ir||(ir=new rr([]))}function x(t){var e=Array.isArray(t)?new rr(t):b(t)?new sr(t):I(t)?new ur(t):void 0;if(e)return e.fromEntrySeq();if("object"==typeof t)return new nr(t);throw new TypeError("Expected Array or collection object of [k, v] entries, or keyed object: "+t)}function j(t){var e=A(t);if(e)return e;throw new TypeError("Expected Array or collection object of values: "+t)} -function k(t){var e=A(t);if(e)return e;if("object"==typeof t)return new nr(t);throw new TypeError("Expected Array or collection object of values, or keyed object: "+t)}function A(t){return D(t)?new rr(t):b(t)?new sr(t):I(t)?new ur(t):void 0}function R(t,e){if(t===e||t!==t&&e!==e)return!0;if(!t||!e)return!1;if("function"==typeof t.valueOf&&"function"==typeof e.valueOf){if(t=t.valueOf(),e=e.valueOf(),t===e||t!==t&&e!==e)return!0;if(!t||!e)return!1}return!!(w(t)&&w(e)&&t.equals(e))}function U(t){return t>>>1&1073741824|3221225471&t}function K(t){if(t===!1||null===t||void 0===t)return 0;if("function"==typeof t.valueOf&&((t=t.valueOf())===!1||null===t||void 0===t))return 0;if(t===!0)return 1;var e=typeof t;if("number"===e){if(t!==t||t===1/0)return 0;var r=0|t;for(r!==t&&(r^=4294967295*t);t>4294967295;)t/=4294967295,r^=t;return U(r)}if("string"===e)return t.length>lr?L(t):T(t);if("function"==typeof t.hashCode)return U(t.hashCode());if("object"===e)return C(t);if("function"==typeof t.toString)return T(""+t);throw Error("Value type "+e+" cannot be hashed.")}function L(t){var e=dr[t];return void 0===e&&(e=T(t),yr===vr&&(yr=0,dr={}),yr++,dr[t]=e),e}function T(t){for(var e=0,r=0;r0)switch(t.nodeType){case 1:return t.uniqueID;case 9:return t.documentElement&&t.documentElement.uniqueID}}function B(t){var e=st(t);return e._iter=t,e.size=t.size,e.flip=function(){return t},e.reverse=function(){var e=t.reverse.apply(this);return e.flip=function(){return t.reverse()},e},e.has=function(e){return t.includes(e)},e.includes=function(e){return t.has(e)},e.cacheResult=at,e.__iterateUncached=function(e,r){var n=this;return t.__iterate(function(t,r){return e(r,t,n)!==!1},r)},e.__iteratorUncached=function(e,r){if(e===He){var n=t.__iterator(e,r);return new Fe(function(){var t=n.next();if(!t.done){var e=t.value[0];t.value[0]=t.value[1],t.value[1]=e}return t})}return t.__iterator(e===Ve?Pe:Ve,r)},e}function J(t,e,r){var n=st(t);return n.size=t.size,n.has=function(e){return t.has(e)},n.get=function(n,i){var o=t.get(n,ke);return o===ke?i:e.call(r,o,n,t)},n.__iterateUncached=function(n,i){var o=this;return t.__iterate(function(t,i,u){return n(e.call(r,t,i,u),i,o)!==!1},i)},n.__iteratorUncached=function(n,i){var o=t.__iterator(He,i);return new Fe(function(){var i=o.next();if(i.done)return i;var u=i.value,s=u[0];return z(n,s,e.call(r,u[1],s,t),i)})},n}function N(t,e){var r=this,n=st(t);return n._iter=t,n.size=t.size,n.reverse=function(){return t},t.flip&&(n.flip=function(){var e=B(t);return e.reverse=function(){return t.flip()},e}),n.get=function(r,n){return t.get(e?r:-1-r,n)},n.has=function(r){return t.has(e?r:-1-r)},n.includes=function(e){return t.includes(e)},n.cacheResult=at,n.__iterate=function(r,n){var i=this,u=0;return n&&o(t),t.__iterate(function(t,o){return r(t,e?o:n?i.size-++u:u++,i)},!n)},n.__iterator=function(n,i){var u=0;i&&o(t);var s=t.__iterator(He,!i);return new Fe(function(){var t=s.next();if(t.done)return t;var o=t.value;return z(n,e?o[0]:i?r.size-++u:u++,o[1],t)})},n}function P(t,e,r,n){var i=st(t);return n&&(i.has=function(n){var i=t.get(n,ke);return i!==ke&&!!e.call(r,i,n,t)},i.get=function(n,i){var o=t.get(n,ke);return o!==ke&&e.call(r,o,n,t)?o:i}), -i.__iterateUncached=function(i,o){var u=this,s=0;return t.__iterate(function(t,o,a){if(e.call(r,t,o,a))return s++,i(t,n?o:s-1,u)},o),s},i.__iteratorUncached=function(i,o){var u=t.__iterator(He,o),s=0;return new Fe(function(){for(;;){var o=u.next();if(o.done)return o;var a=o.value,c=a[0],h=a[1];if(e.call(r,h,c,t))return z(i,n?c:s++,h,o)}})},i}function V(t,e,r){var n=Sr().asMutable();return t.__iterate(function(i,o){n.update(e.call(r,i,o,t),0,function(t){return t+1})}),n.asImmutable()}function H(t,e,r){var n=v(t),i=(g(t)?Br():Sr()).asMutable();t.__iterate(function(o,u){i.update(e.call(r,o,u,t),function(t){return t=t||[],t.push(n?[u,o]:o),t})});var o=ut(t);return i.map(function(e){return it(t,o(e))})}function Y(t,e,r,n){var i=t.size;if(a(e,r,i))return t;var o=c(e,i),s=h(r,i);if(o!==o||s!==s)return Y(t.toSeq().cacheResult(),e,r,n);var f,p=s-o;p===p&&(f=p<0?0:p);var _=st(t);return _.size=0===f?f:t.size&&f||void 0,!n&&q(t)&&f>=0&&(_.get=function(e,r){return e=u(this,e),e>=0&&ef)return S();var t=i.next();return n||e===Ve||t.done?t:e===Pe?z(e,s-1,void 0,t):z(e,s-1,t.value[1],t)})},_}function Q(t,e,r){var n=st(t);return n.__iterateUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterate(n,i);var u=0;return t.__iterate(function(t,i,s){return e.call(r,t,i,s)&&++u&&n(t,i,o)}),u},n.__iteratorUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterator(n,i);var u=t.__iterator(He,i),s=!0;return new Fe(function(){if(!s)return S();var t=u.next();if(t.done)return t;var i=t.value,a=i[0],c=i[1];return e.call(r,c,a,o)?n===He?t:z(n,a,c,t):(s=!1,S())})},n} -function X(t,e,r,n){var i=st(t);return i.__iterateUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterate(i,o);var s=!0,a=0;return t.__iterate(function(t,o,c){if(!s||!(s=e.call(r,t,o,c)))return a++,i(t,n?o:a-1,u)}),a},i.__iteratorUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterator(i,o);var s=t.__iterator(He,o),a=!0,c=0;return new Fe(function(){var t,o,h;do{if(t=s.next(),t.done)return n||i===Ve?t:i===Pe?z(i,c++,void 0,t):z(i,c++,t.value[1],t);var f=t.value;o=f[0],h=f[1],a&&(a=e.call(r,h,o,u))}while(a);return i===He?t:z(i,o,h,t)})},i}function F(t,e){var r=v(t),n=[t].concat(e).map(function(t){return l(t)?r&&(t=Be(t)):t=r?x(t):j(Array.isArray(t)?t:[t]),t}).filter(function(t){return 0!==t.size});if(0===n.length)return t;if(1===n.length){var i=n[0];if(i===t||r&&v(i)||y(t)&&y(i))return i}var o=new rr(n);return r?o=o.toKeyedSeq():y(t)||(o=o.toSetSeq()),o=o.flatten(!0),o.size=n.reduce(function(t,e){if(void 0!==t){var r=e.size;if(void 0!==r)return t+r}},0),o}function G(t,e,r){var n=st(t);return n.__iterateUncached=function(i,o){function u(t,c){t.__iterate(function(t,o){return(!e||c0}function nt(t,e,r,n){var i=st(t),o=new rr(r).map(function(t){return t.size});return i.size=n?o.max():o.min(),i.__iterate=function(t,e){for(var r,n=this,i=this.__iterator(Ve,e),o=0;!(r=i.next()).done&&t(r.value,o++,n)!==!1;);return o},i.__iteratorUncached=function(t,i){var o=r.map(function(t){return t=We(t),O(i?t.reverse():t)}),u=0,s=!1;return new Fe(function(){var r;return s||(r=o.map(function(t){return t.next()}),s=n?r.every(function(t){return t.done}):r.some(function(t){return t.done})),s?S():z(t,u++,e.apply(null,r.map(function(t){return t.value})))})},i}function it(t,e){return t===e?t:q(t)?e:t.constructor(e)}function ot(t){if(t!==Object(t))throw new TypeError("Expected [K, V] tuple: "+t)}function ut(t){return v(t)?Be:y(t)?Je:Ne}function st(t){return Object.create((v(t)?Ze:y(t)?$e:tr).prototype)}function at(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size,this):Ge.prototype.cacheResult.call(this)}function ct(t,e){return void 0===t&&void 0===e?0:void 0===t?1:void 0===e?-1:t>e?1:t>>r)&je,s=(0===r?n:n>>>r)&je;return new Mr(e,1<>>=1)u[s]=1&r?e[o++]:void 0;return u[n]=i,new Dr(t,o+1,u)}function Mt(t,e,r){for(var n=[],i=0;i>1&1431655765,t=(858993459&t)+(t>>2&858993459),t=t+(t>>4)&252645135,t+=t>>8,127&(t+=t>>16)}function kt(t,e,r,n){var o=n?t:i(t);return o[e]=r,o}function At(t,e,r,n){var i=t.length+1;if(n&&e+1===i)return t[e]=r,t;for(var o=Array(i),u=0,s=0;so?0:o-r,c=u-r;return c>xe&&(c=xe),function(){if(i===c)return Wr;var t=e?--c:i++;return n&&n[t]}}function i(t,n,i){var s,a=t&&t.array,c=i>o?0:o-i>>n,h=1+(u-i>>n);return h>xe&&(h=xe),function(){for(;;){if(s){var t=s();if(t!==Wr)return t;s=null}if(c===h)return Wr;var o=e?--h:c++;s=r(a&&a[o],n-Ee,i+(o<=t.size||r<0)return t.withMutations(function(t){r<0?Nt(t,r).set(0,n):Nt(t,0,r+1).set(r,n)});r+=t._origin;var i=t._tail,o=t._root,s=e(Re);return r>=Vt(t._capacity)?i=Wt(i,t.__ownerID,0,r,n,s):o=Wt(o,t.__ownerID,t._level,r,n,s),s.value?t.__ownerID?(t._root=o,t._tail=i,t.__hash=void 0,t.__altered=!0,t):Lt(t._origin,t._capacity,t._level,o,i):t}function Wt(t,e,n,i,o,u){var s=i>>>n&je,a=t&&s0){var h=t&&t.array[s],f=Wt(h,e,n-Ee,i,o,u) -;return f===h?t:(c=Bt(t,e),c.array[s]=f,c)}return a&&t.array[s]===o?t:(r(u),c=Bt(t,e),void 0===o&&s===c.array.length-1?c.array.pop():c.array[s]=o,c)}function Bt(t,e){return e&&t&&e===t.ownerID?t:new Tr(t?t.array.slice():[],e)}function Jt(t,e){if(e>=Vt(t._capacity))return t._tail;if(e<1<0;)r=r.array[e>>>n&je],n-=Ee;return r}}function Nt(t,e,r){void 0!==e&&(e|=0),void 0!==r&&(r|=0);var i=t.__ownerID||new n,o=t._origin,u=t._capacity,s=o+e,a=void 0===r?u:r<0?u+r:o+r;if(s===o&&a===u)return t;if(s>=a)return t.clear();for(var c=t._level,h=t._root,f=0;s+f<0;)h=new Tr(h&&h.array.length?[void 0,h]:[],i),c+=Ee,f+=1<=1<p?new Tr([],i):l;if(l&&_>p&&sEe;d-=Ee){var g=p>>>d&je;y=y.array[g]=Bt(y.array[g],i)}y.array[p>>>Ee&je]=l}if(a=_)s-=_,a-=_,c=Ee,h=null,v=v&&v.removeBefore(i,0,s);else if(s>o||_>>c&je;if(m!==_>>>c&je)break;m&&(f+=(1<o&&(h=h.removeBefore(i,c,s-f)),h&&_i&&(i=u.size),n.push(u)}return i>t.size&&(t=t.setSize(i)),Et(t,e,n)}function Vt(t){return t>>Ee<=xe&&u.size>=2*o.size?(i=u.filter(function(t,e){return void 0!==t&&s!==e}),n=i.toKeyedSeq().map(function(t){return t[0]}).flip().toMap(), -t.__ownerID&&(n.__ownerID=i.__ownerID=t.__ownerID)):(n=o.remove(e),i=s===u.size-1?u.pop():u.set(s,void 0))}else if(a){if(r===u.get(s)[1])return t;n=o,i=u.set(s,[e,r])}else n=o.set(e,u.size),i=u.set(u.size,[e,r]);return t.__ownerID?(t.size=n.size,t._map=n,t._list=i,t.__hash=void 0,t):Yt(n,i)}function Ft(t){return!(!t||!t[Pr])}function Gt(t,e,r,n){var i=Object.create(Vr);return i.size=t,i._head=e,i.__ownerID=r,i.__hash=n,i.__altered=!1,i}function Zt(){return Hr||(Hr=Gt(0))}function $t(t,e){if(t===e)return!0;if(!l(e)||void 0!==t.size&&void 0!==e.size&&t.size!==e.size||void 0!==t.__hash&&void 0!==e.__hash&&t.__hash!==e.__hash||v(t)!==v(e)||y(t)!==y(e)||g(t)!==g(e))return!1;if(0===t.size&&0===e.size)return!0;var r=!d(t);if(g(t)){var n=t.entries();return e.every(function(t,e){var i=n.next().value;return i&&R(i[1],t)&&(r||R(i[0],e))})&&n.next().done}var i=!1;if(void 0===t.size)if(void 0===e.size)"function"==typeof t.cacheResult&&t.cacheResult();else{i=!0;var o=t;t=e,e=o}var u=!0,s=e.__iterate(function(e,n){if(r?!t.has(e):i?!R(e,t.get(n,ke)):!R(t.get(n,ke),e))return u=!1,!1});return u&&t.size===s}function te(t,e){var r=function(r){t.prototype[r]=e[r]};return Object.keys(e).forEach(r),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(e).forEach(r),t}function ee(t){return!(!t||!t[Qr])}function re(t,e){return t.__ownerID?(t.size=e.size,t._map=e,t):e===t._map?t:0===e.size?t.__empty():t.__make(e)}function ne(t,e){var r=Object.create(Xr);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function ie(){return Fr||(Fr=ne(gt()))}function oe(t,e,r,n,i,o){return pt(t.size),t.__iterate(function(t,o,u){i?(i=!1,r=t):r=e.call(n,r,t,o,u)},o),r}function ue(t,e){return e}function se(t,e){return[e,t]}function ae(t){return t&&"function"==typeof t.toJS?t.toJS():t}function ce(t){return function(){return!t.apply(this,arguments)}}function he(t){return function(){return-t.apply(this,arguments)}}function fe(){return i(arguments)}function pe(t,e){return te?-1:0}function _e(t){if(t.size===1/0)return 0;var e=g(t),r=v(t),n=e?1:0 -;return le(t.__iterate(r?e?function(t,e){n=31*n+ve(K(t),K(e))|0}:function(t,e){n=n+ve(K(t),K(e))|0}:e?function(t){n=31*n+K(t)|0}:function(t){n=n+K(t)|0}),n)}function le(t,e){return e=ar(e,3432918353),e=ar(e<<15|e>>>-15,461845907),e=ar(e<<13|e>>>-13,5),e=(e+3864292196|0)^t,e=ar(e^e>>>16,2246822507),e=ar(e^e>>>13,3266489909),e=U(e^e>>>16)}function ve(t,e){return t^e+2654435769+(t<<6)+(t>>2)|0}function ye(t){if("object"!=typeof console||!console.warn)throw Error(t);console.warn(t)}function de(t,e,r,n){for(var i=ht(r),o=0;o!==i.length;){if(!t||!t.get)return n&&ye("Invalid keyPath: Value at ["+i.slice(0,o).map(_t)+"] does not have a .get() method: "+t+"\nThis warning will throw in a future version"),e;if((t=t.get(i[o++],ke))===ke)return e}return t}function ge(t){return ee(t)&&g(t)}function me(t,e){var r=Object.create(nn);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function we(){return on||(on=me(Qt()))}function ze(t,e,r){var n=Object.create(Object.getPrototypeOf(t));return n._values=e,n.__ownerID=r,n}function Se(t){return t._name||t.constructor.name||"Record"}function Ie(t){return x(t._keys.map(function(e){return[e,t.get(e)]}))}function be(t,e){try{Object.defineProperty(t,e,{get:function(){return this.get(e)},set:function(t){ft(this.__ownerID,"Cannot set on an immutable record."),this.set(e,t)}})}catch(t){}}function Oe(t,e){return Me([],e||De,t,"",e&&e.length>2?[]:void 0,{"":t})}function Me(t,e,r,n,i,o){var u=Array.isArray(r)?$e:qe(r)?Ze:null;if(u){if(~t.indexOf(r))throw new TypeError("Cannot convert circular structure to Immutable");t.push(r),i&&""!==n&&i.push(n);var s=e.call(o,n,u(r).map(function(n,o){return Me(t,e,n,o,i,r)}),i&&i.slice());return t.pop(),i&&i.pop(),s}return r}function De(t,e){return v(e)?e.toMap():e.toList()}function qe(t){return t&&(t.constructor===Object||void 0===t.constructor)}var Ee=5,xe=1<=n.length){var e=r.next();if(e.done)return e;n[i]=e.value}return z(t,i,n[i++])})},e}($e),ar="function"==typeof Math.imul&&Math.imul(4294967295,2)===-2?Math.imul:function(t,e){t|=0,e|=0;var r=65535&t,n=65535&e;return r*n+((t>>>16)*n+r*(e>>>16)<<16>>>0)|0},cr=Object.isExtensible,hr=function(){try{return Object.defineProperty({},"@",{}),!0}catch(t){return!1}}(),fr="function"==typeof WeakMap;fr&&(or=new WeakMap);var pr=0,_r="__immutablehash__";"function"==typeof Symbol&&(_r=Symbol(_r));var lr=16,vr=255,yr=0,dr={},gr=function(t){function e(t,e){this._iter=t,this._useKeys=e,this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t,e){return this._iter.get(t,e)}, -e.prototype.has=function(t){return this._iter.has(t)},e.prototype.valueSeq=function(){return this._iter.valueSeq()},e.prototype.reverse=function(){var t=this,e=N(this,!0);return this._useKeys||(e.valueSeq=function(){return t._iter.toSeq().reverse()}),e},e.prototype.map=function(t,e){var r=this,n=J(this,t,e);return this._useKeys||(n.valueSeq=function(){return r._iter.toSeq().map(t,e)}),n},e.prototype.__iterate=function(t,e){var r=this;return this._iter.__iterate(function(e,n){return t(e,n,r)},e)},e.prototype.__iterator=function(t,e){return this._iter.__iterator(t,e)},e}(Ze);gr.prototype[Te]=!0;var mr=function(t){function e(t){this._iter=t,this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.includes=function(t){return this._iter.includes(t)},e.prototype.__iterate=function(t,e){var r=this,n=0;return e&&o(this),this._iter.__iterate(function(i){return t(i,e?r.size-++n:n++,r)},e)},e.prototype.__iterator=function(t,e){var r=this,n=this._iter.__iterator(Ve,e),i=0;return e&&o(this),new Fe(function(){var o=n.next();return o.done?o:z(t,e?r.size-++i:i++,o.value,o)})},e}($e),wr=function(t){function e(t){this._iter=t,this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.has=function(t){return this._iter.includes(t)},e.prototype.__iterate=function(t,e){var r=this;return this._iter.__iterate(function(e){return t(e,e,r)},e)},e.prototype.__iterator=function(t,e){var r=this._iter.__iterator(Ve,e);return new Fe(function(){var e=r.next();return e.done?e:z(t,e.value,e.value,e)})},e}(tr),zr=function(t){function e(t){this._iter=t,this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.entrySeq=function(){return this._iter.toSeq()},e.prototype.__iterate=function(t,e){var r=this;return this._iter.__iterate(function(e){if(e){ot(e);var n=l(e);return t(n?e.get(1):e[1],n?e.get(0):e[0],r)}},e)},e.prototype.__iterator=function(t,e){ -var r=this._iter.__iterator(Ve,e);return new Fe(function(){for(;;){var e=r.next();if(e.done)return e;var n=e.value;if(n){ot(n);var i=l(n);return z(t,i?n.get(0):n[0],i?n.get(1):n[1],e)}}})},e}(Ze);mr.prototype.cacheResult=gr.prototype.cacheResult=wr.prototype.cacheResult=zr.prototype.cacheResult=at;var Sr=function(t){function e(e){return null===e||void 0===e?gt():lt(e)&&!g(e)?e:gt().withMutations(function(r){var n=t(e);pt(n.size),n.forEach(function(t,e){return r.set(e,t)})})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return gt().withMutations(function(e){for(var r=0;r=t.length)throw Error("Missing value for key: "+t[r]);e.set(t[r],t[r+1])}})},e.prototype.toString=function(){return this.__toString("Map {","}")},e.prototype.get=function(t,e){return this._root?this._root.get(0,void 0,t,e):e},e.prototype.set=function(t,e){return mt(this,t,e)},e.prototype.setIn=function(t,e){return this.updateIn(t,ke,function(){return e})},e.prototype.remove=function(t){return mt(this,t,ke)},e.prototype.deleteIn=function(t){if(t=[].concat(ht(t)),t.length){var e=t.pop();return this.updateIn(t,function(t){return t&&t.remove(e)})}},e.prototype.deleteAll=function(t){var e=We(t);return 0===e.size?this:this.withMutations(function(t){e.forEach(function(e){return t.remove(e)})})},e.prototype.update=function(t,e,r){return 1===arguments.length?t(this):this.updateIn([t],e,r)},e.prototype.updateIn=function(t,e,r){r||(r=e,e=void 0);var n=xt(this,ht(t),0,e,r);return n===ke?e:n},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):gt()},e.prototype.merge=function(){return Mt(this,void 0,arguments)},e.prototype.mergeWith=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Mt(this,t,e)},e.prototype.mergeIn=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1] -;return this.updateIn(t,gt(),function(t){return"function"==typeof t.merge?t.merge.apply(t,e):e[e.length-1]})},e.prototype.mergeDeep=function(){return Mt(this,Dt,arguments)},e.prototype.mergeDeepWith=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Mt(this,qt(t),e)},e.prototype.mergeDeepIn=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return this.updateIn(t,gt(),function(t){return"function"==typeof t.mergeDeep?t.mergeDeep.apply(t,e):e[e.length-1]})},e.prototype.sort=function(t){return Br(tt(this,t))},e.prototype.sortBy=function(t,e){return Br(tt(this,e,t))},e.prototype.withMutations=function(t){var e=this.asMutable();return t(e),e.wasAltered()?e.__ensureOwner(this.__ownerID):this},e.prototype.asMutable=function(){return this.__ownerID?this:this.__ensureOwner(new n)},e.prototype.asImmutable=function(){return this.__ensureOwner()},e.prototype.wasAltered=function(){return this.__altered},e.prototype.__iterator=function(t,e){return new jr(this,t,e)},e.prototype.__iterate=function(t,e){var r=this,n=0;return this._root&&this._root.iterate(function(e){return n++,t(e[1],e[0],r)},e),n},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?dt(this.size,this._root,t,this.__hash):0===this.size?gt():(this.__ownerID=t,this.__altered=!1,this)},e}(Be);Sr.isMap=lt;var Ir="@@__IMMUTABLE_MAP__@@",br=Sr.prototype;br[Ir]=!0,br.delete=br.remove,br.removeIn=br.deleteIn,br.removeAll=br.deleteAll,br["@@transducer/init"]=br.asMutable,br["@@transducer/step"]=function(t,e){return t.set(e[0],e[1])},br["@@transducer/result"]=function(t){return t.asImmutable()};var Or=function(t,e){this.ownerID=t,this.entries=e};Or.prototype.get=function(t,e,r,n){for(var i=this.entries,o=0,u=i.length;o=kr)return It(t,h,o,u) -;var l=t&&t===this.ownerID,v=l?h:i(h);return _?c?f===p-1?v.pop():v[f]=v.pop():v[f]=[o,u]:v.push([o,u]),l?(this.entries=v,this):new Or(t,v)}};var Mr=function(t,e,r){this.ownerID=t,this.bitmap=e,this.nodes=r};Mr.prototype.get=function(t,e,r,n){void 0===e&&(e=K(r));var i=1<<((0===t?e:e>>>t)&je),o=this.bitmap;return 0==(o&i)?n:this.nodes[jt(o&i-1)].get(t+Ee,e,r,n)},Mr.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=K(n));var s=(0===e?r:r>>>e)&je,a=1<=Ar)return Ot(t,p,c,s,l);if(h&&!l&&2===p.length&&zt(p[1^f]))return p[1^f];if(h&&l&&1===p.length&&zt(l))return l;var v=t&&t===this.ownerID,y=h?l?c:c^a:c|a,d=h?l?kt(p,f,l,v):Rt(p,f,v):At(p,f,l,v);return v?(this.bitmap=y,this.nodes=d,this):new Mr(t,y,d)};var Dr=function(t,e,r){this.ownerID=t,this.count=e,this.nodes=r};Dr.prototype.get=function(t,e,r,n){void 0===e&&(e=K(r));var i=(0===t?e:e>>>t)&je,o=this.nodes[i];return o?o.get(t+Ee,e,r,n):n},Dr.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=K(n));var s=(0===e?r:r>>>e)&je,a=i===ke,c=this.nodes,h=c[s];if(a&&!h)return this;var f=wt(h,t,e+Ee,r,n,i,o,u);if(f===h)return this;var p=this.count;if(h){if(!f&&--p0&&i=0&&t0;)e[r]=arguments[r+1];return Pt(this,t,e)},e.prototype.mergeDeep=function(){return Pt(this,Dt,arguments)},e.prototype.mergeDeepWith=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Pt(this,qt(t),e)},e.prototype.setSize=function(t){return Nt(this,0,t)},e.prototype.slice=function(t,e){var r=this.size;return a(t,e,r)?this:Nt(this,c(t,r),h(e,r))},e.prototype.__iterator=function(t,e){var r=e?this.size:0,n=Kt(this,e);return new Fe(function(){var i=n();return i===Wr?S():z(t,e?--r:r++,i)})},e.prototype.__iterate=function(t,e){for(var r,n=this,i=e?this.size:0,o=Kt(this,e);(r=o())!==Wr&&t(r,e?--i:i++,n)!==!1;);return i},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Lt(this._origin,this._capacity,this._level,this._root,this._tail,t,this.__hash):0===this.size?Tt():(this.__ownerID=t,this.__altered=!1,this)},e}(Je);Ur.isList=Ut;var Kr="@@__IMMUTABLE_LIST__@@",Lr=Ur.prototype;Lr[Kr]=!0,Lr.delete=Lr.remove,Lr.setIn=br.setIn,Lr.deleteIn=Lr.removeIn=br.removeIn,Lr.update=br.update,Lr.updateIn=br.updateIn,Lr.mergeIn=br.mergeIn, -Lr.mergeDeepIn=br.mergeDeepIn,Lr.withMutations=br.withMutations,Lr.asMutable=br.asMutable,Lr.asImmutable=br.asImmutable,Lr.wasAltered=br.wasAltered,Lr["@@transducer/init"]=Lr.asMutable,Lr["@@transducer/step"]=function(t,e){return t.push(e)},Lr["@@transducer/result"]=br["@@transducer/result"];var Tr=function(t,e){this.array=t,this.ownerID=e};Tr.prototype.removeBefore=function(t,e,r){if(r===e?1<>>e&je;if(n>=this.array.length)return new Tr([],t);var i,o=0===n;if(e>0){var u=this.array[n];if((i=u&&u.removeBefore(t,e-Ee,r))===u&&o)return this}if(o&&!i)return this;var s=Bt(this,t);if(!o)for(var a=0;a>>e&je;if(n>=this.array.length)return this;var i;if(e>0){var o=this.array[n];if((i=o&&o.removeAfter(t,e-Ee,r))===o&&n===this.array.length-1)return this}var u=Bt(this,t);return u.array.splice(n+1),i&&(u.array[n]=i),u};var Cr,Wr={},Br=function(t){function e(t){return null===t||void 0===t?Qt():Ht(t)?t:Qt().withMutations(function(e){var r=Be(t);pt(r.size),r.forEach(function(t,r){return e.set(r,t)})})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("OrderedMap {","}")},e.prototype.get=function(t,e){var r=this._map.get(t);return void 0!==r?this._list.get(r)[1]:e},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._map.clear(),this._list.clear(),this):Qt()},e.prototype.set=function(t,e){return Xt(this,t,e)},e.prototype.remove=function(t){return Xt(this,t,ke)},e.prototype.wasAltered=function(){return this._map.wasAltered()||this._list.wasAltered()},e.prototype.__iterate=function(t,e){var r=this;return this._list.__iterate(function(e){return e&&t(e[1],e[0],r)},e)},e.prototype.__iterator=function(t,e){return this._list.fromEntrySeq().__iterator(t,e)}, -e.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var e=this._map.__ensureOwner(t),r=this._list.__ensureOwner(t);return t?Yt(e,r,t,this.__hash):0===this.size?Qt():(this.__ownerID=t,this._map=e,this._list=r,this)},e}(Sr);Br.isOrderedMap=Ht,Br.prototype[Te]=!0,Br.prototype.delete=Br.prototype.remove;var Jr,Nr=function(t){function e(t){return null===t||void 0===t?Zt():Ft(t)?t:Zt().pushAll(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("Stack [","]")},e.prototype.get=function(t,e){var r=this._head;for(t=u(this,t);r&&t--;)r=r.next;return r?r.value:e},e.prototype.peek=function(){return this._head&&this._head.value},e.prototype.push=function(){var t=arguments;if(0===arguments.length)return this;for(var e=this.size+arguments.length,r=this._head,n=arguments.length-1;n>=0;n--)r={value:t[n],next:r};return this.__ownerID?(this.size=e,this._head=r,this.__hash=void 0,this.__altered=!0,this):Gt(e,r)},e.prototype.pushAll=function(e){if(e=t(e),0===e.size)return this;if(0===this.size&&Ft(e))return e;pt(e.size);var r=this.size,n=this._head;return e.__iterate(function(t){r++,n={value:t,next:n}},!0),this.__ownerID?(this.size=r,this._head=n,this.__hash=void 0,this.__altered=!0,this):Gt(r,n)},e.prototype.pop=function(){return this.slice(1)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):Zt()},e.prototype.slice=function(e,r){if(a(e,r,this.size))return this;var n=c(e,this.size);if(h(r,this.size)!==this.size)return t.prototype.slice.call(this,e,r);for(var i=this.size-n,o=this._head;n--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):Gt(i,o)},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Gt(this.size,this._head,t,this.__hash):0===this.size?Zt():(this.__ownerID=t,this.__altered=!1,this)}, -e.prototype.__iterate=function(t,e){var r=this;if(e)return new rr(this.toArray()).__iterate(function(e,n){return t(e,n,r)},e);for(var n=0,i=this._head;i&&t(i.value,n++,r)!==!1;)i=i.next;return n},e.prototype.__iterator=function(t,e){if(e)return new rr(this.toArray()).__iterator(t,e);var r=0,n=this._head;return new Fe(function(){if(n){var e=n.value;return n=n.next,z(t,r++,e)}return S()})},e}(Je);Nr.isStack=Ft;var Pr="@@__IMMUTABLE_STACK__@@",Vr=Nr.prototype;Vr[Pr]=!0,Vr.withMutations=br.withMutations,Vr.asMutable=br.asMutable,Vr.asImmutable=br.asImmutable,Vr.wasAltered=br.wasAltered,Vr.shift=Vr.pop,Vr.unshift=Vr.push,Vr.unshiftAll=Vr.pushAll,Vr["@@transducer/init"]=Vr.asMutable,Vr["@@transducer/step"]=function(t,e){return t.unshift(e)},Vr["@@transducer/result"]=br["@@transducer/result"];var Hr,Yr=function(t){function e(e){return null===e||void 0===e?ie():ee(e)&&!g(e)?e:ie().withMutations(function(r){var n=t(e);pt(n.size),n.forEach(function(t){return r.add(t)})})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(Be(t).keySeq())},e.intersect=function(t){return t=We(t).toArray(),t.length?Xr.intersect.apply(e(t.pop()),t):ie()},e.union=function(t){return t=We(t).toArray(),t.length?Xr.union.apply(e(t.pop()),t):ie()},e.prototype.toString=function(){return this.__toString("Set {","}")},e.prototype.has=function(t){return this._map.has(t)},e.prototype.add=function(t){return re(this,this._map.set(t,t))},e.prototype.remove=function(t){return re(this,this._map.remove(t))},e.prototype.clear=function(){return re(this,this._map.clear())},e.prototype.union=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return e=e.filter(function(t){return 0!==t.size}),0===e.length?this:0!==this.size||this.__ownerID||1!==e.length?this.withMutations(function(r){for(var n=0;n0;)e[r]=arguments[r+1];return this.union.apply(this,e)},e.prototype.sort=function(t){return rn(tt(this,t))},e.prototype.sortBy=function(t,e){return rn(tt(this,e,t))},e.prototype.wasAltered=function(){return this._map.wasAltered()},e.prototype.__iterate=function(t,e){var r=this;return this._map.__iterate(function(e){return t(e,e,r)},e)},e.prototype.__iterator=function(t,e){return this._map.__iterator(t,e)},e.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var e=this._map.__ensureOwner(t);return t?this.__make(e,t):0===this.size?this.__empty():(this.__ownerID=t,this._map=e,this)},e}(Ne);Yr.isSet=ee;var Qr="@@__IMMUTABLE_SET__@@",Xr=Yr.prototype;Xr[Qr]=!0,Xr.delete=Xr.remove,Xr.mergeDeep=Xr.merge,Xr.mergeDeepWith=Xr.mergeWith,Xr.withMutations=br.withMutations,Xr.asMutable=br.asMutable,Xr.asImmutable=br.asImmutable,Xr["@@transducer/init"]=Xr.asMutable,Xr["@@transducer/step"]=function(t,e){return t.add(e)},Xr["@@transducer/result"]=br["@@transducer/result"],Xr.__empty=ie,Xr.__make=ne;var Fr,Gr,Zr=function(t){function e(t,r,n){if(!(this instanceof e))return new e(t,r,n);if(ft(0!==n,"Cannot step a Range by 0"),t=t||0,void 0===r&&(r=1/0),n=void 0===n?1:Math.abs(n),r=0&&e=0&&rthis.size?e:this.find(function(e,r){return r===t},void 0,e)},has:function(t){return(t=u(this,t))>=0&&(void 0!==this.size?this.size===1/0||t>>0;if(""+r!==e||4294967295===r)return NaN;e=r}return e<0?o(t)+e:e}function s(){return!0}function a(t,e,r){return(0===t&&!p(t)||void 0!==r&&t<=-r)&&(void 0===e||void 0!==r&&e>=r)}function c(t,e){return f(t,e,0)}function h(t,e){return f(t,e,e)}function f(t,e,r){return void 0===t?r:p(t)?e===1/0?e:0|Math.max(0,e+t):void 0===e||e===t?t:0|Math.min(e,t)}function p(t){return t<0||0===t&&1/t==-(1/0)}function _(t){return(l(t)||m(t))&&!t.__ownerID}function l(t){return!(!t||!t[Re])}function v(t){return!(!t||!t[Ue])}function y(t){return!(!t||!t[Ke])}function d(t){return v(t)||y(t)}function g(t){return!(!t||!t[Le])}function m(t){return!(!t||!t[Te])}function w(t){return!(!t||"function"!=typeof t.equals||"function"!=typeof t.hashCode)}function S(t,e,r,n){var i=0===t?e:1===t?r:[e,r];return n?n.value=i:n={value:i,done:!1},n}function I(){return{value:void 0,done:!0}}function z(t){return!!M(t)}function b(t){return t&&"function"==typeof t.next}function O(t){var e=M(t);return e&&e.call(t)}function M(t){var e=t&&(He&&t[He]||t[Ye]);if("function"==typeof e)return e}function q(t){return t&&"number"==typeof t.length}function D(t){return!(!t||!t[tr])}function E(){return nr||(nr=new er([]))}function x(t){var e=Array.isArray(t)?new er(t):b(t)?new ur(t):z(t)?new or(t):void 0;if(e)return e.fromEntrySeq();if("object"==typeof t)return new rr(t);throw new TypeError("Expected Array or collection object of [k, v] entries, or keyed object: "+t)}function j(t){var e=A(t);if(e)return e;throw new TypeError("Expected Array or collection object of values: "+t)} +function k(t){var e=A(t);if(e)return e;if("object"==typeof t)return new rr(t);throw new TypeError("Expected Array or collection object of values, or keyed object: "+t)}function A(t){return q(t)?new er(t):b(t)?new ur(t):z(t)?new or(t):void 0}function R(t,e){if(t===e||t!==t&&e!==e)return!0;if(!t||!e)return!1;if("function"==typeof t.valueOf&&"function"==typeof e.valueOf){if(t=t.valueOf(),e=e.valueOf(),t===e||t!==t&&e!==e)return!0;if(!t||!e)return!1}return!!(w(t)&&w(e)&&t.equals(e))}function U(t){return t>>>1&1073741824|3221225471&t}function K(t){if(t===!1||null===t||void 0===t)return 0;if("function"==typeof t.valueOf&&((t=t.valueOf())===!1||null===t||void 0===t))return 0;if(t===!0)return 1;var e=typeof t;if("number"===e){if(t!==t||t===1/0)return 0;var r=0|t;for(r!==t&&(r^=4294967295*t);t>4294967295;)t/=4294967295,r^=t;return U(r)}if("string"===e)return t.length>_r?L(t):T(t);if("function"==typeof t.hashCode)return U(t.hashCode());if("object"===e)return C(t);if("function"==typeof t.toString)return T(""+t);throw Error("Value type "+e+" cannot be hashed.")}function L(t){var e=yr[t];return void 0===e&&(e=T(t),vr===lr&&(vr=0,yr={}),vr++,yr[t]=e),e}function T(t){for(var e=0,r=0;r0)switch(t.nodeType){case 1:return t.uniqueID;case 9:return t.documentElement&&t.documentElement.uniqueID}}function W(t){var e=st(t);return e._iter=t,e.size=t.size,e.flip=function(){return t},e.reverse=function(){var e=t.reverse.apply(this);return e.flip=function(){return t.reverse()},e},e.has=function(e){return t.includes(e)},e.includes=function(e){return t.has(e)},e.cacheResult=at,e.__iterateUncached=function(e,r){var n=this;return t.__iterate(function(t,r){return e(r,t,n)!==!1},r)},e.__iteratorUncached=function(e,r){if(e===Ve){var n=t.__iterator(e,r);return new Xe(function(){var t=n.next();if(!t.done){var e=t.value[0];t.value[0]=t.value[1],t.value[1]=e}return t})}return t.__iterator(e===Pe?Ne:Pe,r)},e}function J(t,e,r){var n=st(t);return n.size=t.size,n.has=function(e){return t.has(e)},n.get=function(n,i){var o=t.get(n,je);return o===je?i:e.call(r,o,n,t)},n.__iterateUncached=function(n,i){var o=this;return t.__iterate(function(t,i,u){return n(e.call(r,t,i,u),i,o)!==!1},i)},n.__iteratorUncached=function(n,i){var o=t.__iterator(Ve,i);return new Xe(function(){var i=o.next();if(i.done)return i;var u=i.value,s=u[0];return S(n,s,e.call(r,u[1],s,t),i)})},n}function N(t,e){var r=this,n=st(t);return n._iter=t,n.size=t.size,n.reverse=function(){return t},t.flip&&(n.flip=function(){var e=W(t);return e.reverse=function(){return t.flip()},e}),n.get=function(r,n){return t.get(e?r:-1-r,n)},n.has=function(r){return t.has(e?r:-1-r)},n.includes=function(e){return t.includes(e)},n.cacheResult=at,n.__iterate=function(r,n){var i=this,u=0;return n&&o(t),t.__iterate(function(t,o){return r(t,e?o:n?i.size-++u:u++,i)},!n)},n.__iterator=function(n,i){var u=0;i&&o(t);var s=t.__iterator(Ve,!i);return new Xe(function(){var t=s.next();if(t.done)return t;var o=t.value;return S(n,e?o[0]:i?r.size-++u:u++,o[1],t)})},n}function P(t,e,r,n){var i=st(t);return n&&(i.has=function(n){var i=t.get(n,je);return i!==je&&!!e.call(r,i,n,t)},i.get=function(n,i){var o=t.get(n,je);return o!==je&&e.call(r,o,n,t)?o:i}), +i.__iterateUncached=function(i,o){var u=this,s=0;return t.__iterate(function(t,o,a){if(e.call(r,t,o,a))return s++,i(t,n?o:s-1,u)},o),s},i.__iteratorUncached=function(i,o){var u=t.__iterator(Ve,o),s=0;return new Xe(function(){for(;;){var o=u.next();if(o.done)return o;var a=o.value,c=a[0],h=a[1];if(e.call(r,h,c,t))return S(i,n?c:s++,h,o)}})},i}function V(t,e,r){var n=Sr().asMutable();return t.__iterate(function(i,o){n.update(e.call(r,i,o,t),0,function(t){return t+1})}),n.asImmutable()}function H(t,e,r){var n=v(t),i=(g(t)?Br():Sr()).asMutable();t.__iterate(function(o,u){i.update(e.call(r,o,u,t),function(t){return t=t||[],t.push(n?[u,o]:o),t})});var o=ut(t);return i.map(function(e){return it(t,o(e))})}function Y(t,e,r,n){var i=t.size;if(a(e,r,i))return t;var o=c(e,i),s=h(r,i);if(o!==o||s!==s)return Y(t.toSeq().cacheResult(),e,r,n);var f,p=s-o;p===p&&(f=p<0?0:p);var _=st(t);return _.size=0===f?f:t.size&&f||void 0,!n&&D(t)&&f>=0&&(_.get=function(e,r){return e=u(this,e),e>=0&&ef)return I();var t=i.next();return n||e===Pe||t.done?t:e===Ne?S(e,s-1,void 0,t):S(e,s-1,t.value[1],t)})},_}function Q(t,e,r){var n=st(t);return n.__iterateUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterate(n,i);var u=0;return t.__iterate(function(t,i,s){return e.call(r,t,i,s)&&++u&&n(t,i,o)}),u},n.__iteratorUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterator(n,i);var u=t.__iterator(Ve,i),s=!0;return new Xe(function(){if(!s)return I();var t=u.next();if(t.done)return t;var i=t.value,a=i[0],c=i[1];return e.call(r,c,a,o)?n===Ve?t:S(n,a,c,t):(s=!1,I())})},n} +function X(t,e,r,n){var i=st(t);return i.__iterateUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterate(i,o);var s=!0,a=0;return t.__iterate(function(t,o,c){if(!s||!(s=e.call(r,t,o,c)))return a++,i(t,n?o:a-1,u)}),a},i.__iteratorUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterator(i,o);var s=t.__iterator(Ve,o),a=!0,c=0;return new Xe(function(){var t,o,h;do{if(t=s.next(),t.done)return n||i===Pe?t:i===Ne?S(i,c++,void 0,t):S(i,c++,t.value[1],t);var f=t.value;o=f[0],h=f[1],a&&(a=e.call(r,h,o,u))}while(a);return i===Ve?t:S(i,o,h,t)})},i}function F(t,e){var r=v(t),n=[t].concat(e).map(function(t){return l(t)?r&&(t=Be(t)):t=r?x(t):j(Array.isArray(t)?t:[t]),t}).filter(function(t){return 0!==t.size});if(0===n.length)return t;if(1===n.length){var i=n[0];if(i===t||r&&v(i)||y(t)&&y(i))return i}var o=new er(n);return r?o=o.toKeyedSeq():y(t)||(o=o.toSetSeq()),o=o.flatten(!0),o.size=n.reduce(function(t,e){if(void 0!==t){var r=e.size;if(void 0!==r)return t+r}},0),o}function G(t,e,r){var n=st(t);return n.__iterateUncached=function(i,o){function u(t,c){t.__iterate(function(t,o){return(!e||c0}function nt(t,e,r,n){var i=st(t),o=new er(r).map(function(t){return t.size});return i.size=n?o.max():o.min(),i.__iterate=function(t,e){for(var r,n=this,i=this.__iterator(Pe,e),o=0;!(r=i.next()).done&&t(r.value,o++,n)!==!1;);return o},i.__iteratorUncached=function(t,i){var o=r.map(function(t){return t=Ce(t),O(i?t.reverse():t)}),u=0,s=!1;return new Xe(function(){var r;return s||(r=o.map(function(t){return t.next()}),s=n?r.every(function(t){return t.done}):r.some(function(t){return t.done})),s?I():S(t,u++,e.apply(null,r.map(function(t){return t.value})))})},i}function it(t,e){return t===e?t:D(t)?e:t.constructor(e)}function ot(t){if(t!==Object(t))throw new TypeError("Expected [K, V] tuple: "+t)}function ut(t){return v(t)?Be:y(t)?We:Je}function st(t){return Object.create((v(t)?Ge:y(t)?Ze:$e).prototype)}function at(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size,this):Fe.prototype.cacheResult.call(this)}function ct(t,e){return void 0===t&&void 0===e?0:void 0===t?1:void 0===e?-1:t>e?1:t>>r)&xe,s=(0===r?n:n>>>r)&xe;return new Or(e,1<>>=1)u[s]=1&r?e[o++]:void 0;return u[n]=i,new Mr(t,o+1,u)}function Mt(t,e,r){for(var n=[],i=0;i>1&1431655765,t=(858993459&t)+(t>>2&858993459),t=t+(t>>4)&252645135,t+=t>>8,127&(t+=t>>16)}function kt(t,e,r,n){var o=n?t:i(t);return o[e]=r,o}function At(t,e,r,n){var i=t.length+1;if(n&&e+1===i)return t[e]=r,t;for(var o=Array(i),u=0,s=0;so?0:o-r,c=u-r;return c>Ee&&(c=Ee),function(){if(i===c)return Cr;var t=e?--c:i++;return n&&n[t]}}function i(t,n,i){var s,a=t&&t.array,c=i>o?0:o-i>>n,h=1+(u-i>>n);return h>Ee&&(h=Ee),function(){for(;;){if(s){var t=s();if(t!==Cr)return t;s=null}if(c===h)return Cr;var o=e?--h:c++;s=r(a&&a[o],n-De,i+(o<=t.size||r<0)return t.withMutations(function(t){r<0?Nt(t,r).set(0,n):Nt(t,0,r+1).set(r,n)});r+=t._origin;var i=t._tail,o=t._root,s=e(Ae);return r>=Pt(t._capacity)?i=Bt(i,t.__ownerID,0,r,n,s):o=Bt(o,t.__ownerID,t._level,r,n,s),s.value?t.__ownerID?(t._root=o,t._tail=i,t.__hash=void 0,t.__altered=!0,t):Lt(t._origin,t._capacity,t._level,o,i):t}function Bt(t,e,n,i,o,u){var s=i>>>n&xe,a=t&&s0){var h=t&&t.array[s],f=Bt(h,e,n-De,i,o,u);return f===h?t:(c=Wt(t,e),c.array[s]=f,c)} +return a&&t.array[s]===o?t:(r(u),c=Wt(t,e),void 0===o&&s===c.array.length-1?c.array.pop():c.array[s]=o,c)}function Wt(t,e){return e&&t&&e===t.ownerID?t:new Lr(t?t.array.slice():[],e)}function Jt(t,e){if(e>=Pt(t._capacity))return t._tail;if(e<1<0;)r=r.array[e>>>n&xe],n-=De;return r}}function Nt(t,e,r){void 0!==e&&(e|=0),void 0!==r&&(r|=0);var i=t.__ownerID||new n,o=t._origin,u=t._capacity,s=o+e,a=void 0===r?u:r<0?u+r:o+r;if(s===o&&a===u)return t;if(s>=a)return t.clear();for(var c=t._level,h=t._root,f=0;s+f<0;)h=new Lr(h&&h.array.length?[void 0,h]:[],i),c+=De,f+=1<=1<p?new Lr([],i):l;if(l&&_>p&&sDe;d-=De){var g=p>>>d&xe;y=y.array[g]=Wt(y.array[g],i)}y.array[p>>>De&xe]=l}if(a=_)s-=_,a-=_,c=De,h=null,v=v&&v.removeBefore(i,0,s);else if(s>o||_>>c&xe;if(m!==_>>>c&xe)break;m&&(f+=(1<o&&(h=h.removeBefore(i,c,s-f)),h&&_>>De<=Ee&&u.size>=2*o.size?(i=u.filter(function(t,e){return void 0!==t&&s!==e}),n=i.toKeyedSeq().map(function(t){return t[0]}).flip().toMap(),t.__ownerID&&(n.__ownerID=i.__ownerID=t.__ownerID)):(n=o.remove(e),i=s===u.size-1?u.pop():u.set(s,void 0))}else if(a){if(r===u.get(s)[1])return t;n=o,i=u.set(s,[e,r])}else n=o.set(e,u.size),i=u.set(u.size,[e,r]) +;return t.__ownerID?(t.size=n.size,t._map=n,t._list=i,t.__hash=void 0,t):Ht(n,i)}function Xt(t){return!(!t||!t[Nr])}function Ft(t,e,r,n){var i=Object.create(Pr);return i.size=t,i._head=e,i.__ownerID=r,i.__hash=n,i.__altered=!1,i}function Gt(){return Vr||(Vr=Ft(0))}function Zt(t,e){if(t===e)return!0;if(!l(e)||void 0!==t.size&&void 0!==e.size&&t.size!==e.size||void 0!==t.__hash&&void 0!==e.__hash&&t.__hash!==e.__hash||v(t)!==v(e)||y(t)!==y(e)||g(t)!==g(e))return!1;if(0===t.size&&0===e.size)return!0;var r=!d(t);if(g(t)){var n=t.entries();return e.every(function(t,e){var i=n.next().value;return i&&R(i[1],t)&&(r||R(i[0],e))})&&n.next().done}var i=!1;if(void 0===t.size)if(void 0===e.size)"function"==typeof t.cacheResult&&t.cacheResult();else{i=!0;var o=t;t=e,e=o}var u=!0,s=e.__iterate(function(e,n){if(r?!t.has(e):i?!R(e,t.get(n,je)):!R(t.get(n,je),e))return u=!1,!1});return u&&t.size===s}function $t(t,e){var r=function(r){t.prototype[r]=e[r]};return Object.keys(e).forEach(r),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(e).forEach(r),t}function te(t){return!(!t||!t[Yr])}function ee(t,e){return t.__ownerID?(t.size=e.size,t._map=e,t):e===t._map?t:0===e.size?t.__empty():t.__make(e)}function re(t,e){var r=Object.create(Qr);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function ne(){return Xr||(Xr=re(gt()))}function ie(t,e,r,n,i,o){return pt(t.size),t.__iterate(function(t,o,u){i?(i=!1,r=t):r=e.call(n,r,t,o,u)},o),r}function oe(t,e){return e}function ue(t,e){return[e,t]}function se(t){return t&&"function"==typeof t.toJS?t.toJS():t}function ae(t){return function(){return!t.apply(this,arguments)}}function ce(t){return function(){return-t.apply(this,arguments)}}function he(){return i(arguments)}function fe(t,e){return te?-1:0}function pe(t){if(t.size===1/0)return 0;var e=g(t),r=v(t),n=e?1:0;return _e(t.__iterate(r?e?function(t,e){n=31*n+le(K(t),K(e))|0}:function(t,e){n=n+le(K(t),K(e))|0}:e?function(t){n=31*n+K(t)|0}:function(t){n=n+K(t)|0}),n)}function _e(t,e){return e=sr(e,3432918353), +e=sr(e<<15|e>>>-15,461845907),e=sr(e<<13|e>>>-13,5),e=(e+3864292196|0)^t,e=sr(e^e>>>16,2246822507),e=sr(e^e>>>13,3266489909),e=U(e^e>>>16)}function le(t,e){return t^e+2654435769+(t<<6)+(t>>2)|0}function ve(t){if("object"!=typeof console||!console.warn)throw Error(t);console.warn(t)}function ye(t,e,r,n){for(var i=ht(r),o=0;o!==i.length;){if(!t||!t.get)return n&&ve("Invalid keyPath: Value at ["+i.slice(0,o).map(_t)+"] does not have a .get() method: "+t+"\nThis warning will throw in a future version"),e;if((t=t.get(i[o++],je))===je)return e}return t}function de(t){return te(t)&&g(t)}function ge(t,e){var r=Object.create(rn);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function me(){return nn||(nn=ge(Yt()))}function we(t,e,r){var n=Object.create(Object.getPrototypeOf(t));return n._values=e,n.__ownerID=r,n}function Se(t){return t._name||t.constructor.name||"Record"}function Ie(t){return x(t._keys.map(function(e){return[e,t.get(e)]}))}function ze(t,e){try{Object.defineProperty(t,e,{get:function(){return this.get(e)},set:function(t){ft(this.__ownerID,"Cannot set on an immutable record."),this.set(e,t)}})}catch(t){}}function be(t,e){return Oe([],e||Me,t,"",e&&e.length>2?[]:void 0,{"":t})}function Oe(t,e,r,n,i,o){var u=Array.isArray(r)?Ze:qe(r)?Ge:null;if(u){if(~t.indexOf(r))throw new TypeError("Cannot convert circular structure to Immutable");t.push(r),i&&""!==n&&i.push(n);var s=e.call(o,n,u(r).map(function(n,o){return Oe(t,e,n,o,i,r)}),i&&i.slice());return t.pop(),i&&i.pop(),s}return r}function Me(t,e){return v(e)?e.toMap():e.toList()}function qe(t){return t&&(t.constructor===Object||void 0===t.constructor)}var De=5,Ee=1<=n.length){var e=r.next();if(e.done)return e;n[i]=e.value}return S(t,i,n[i++])})},e}(Ze),sr="function"==typeof Math.imul&&Math.imul(4294967295,2)===-2?Math.imul:function(t,e){t|=0,e|=0;var r=65535&t,n=65535&e;return r*n+((t>>>16)*n+r*(e>>>16)<<16>>>0)|0},ar=Object.isExtensible,cr=function(){try{return Object.defineProperty({},"@",{}),!0}catch(t){return!1}}(),hr="function"==typeof WeakMap;hr&&(ir=new WeakMap);var fr=0,pr="__immutablehash__";"function"==typeof Symbol&&(pr=Symbol(pr));var _r=16,lr=255,vr=0,yr={},dr=function(t){function e(t,e){this._iter=t,this._useKeys=e,this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t,e){return this._iter.get(t,e)},e.prototype.has=function(t){return this._iter.has(t)},e.prototype.valueSeq=function(){return this._iter.valueSeq()},e.prototype.reverse=function(){var t=this,e=N(this,!0);return this._useKeys||(e.valueSeq=function(){return t._iter.toSeq().reverse()}),e},e.prototype.map=function(t,e){var r=this,n=J(this,t,e);return this._useKeys||(n.valueSeq=function(){ +return r._iter.toSeq().map(t,e)}),n},e.prototype.__iterate=function(t,e){var r=this;return this._iter.__iterate(function(e,n){return t(e,n,r)},e)},e.prototype.__iterator=function(t,e){return this._iter.__iterator(t,e)},e}(Ge);dr.prototype[Le]=!0;var gr=function(t){function e(t){this._iter=t,this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.includes=function(t){return this._iter.includes(t)},e.prototype.__iterate=function(t,e){var r=this,n=0;return e&&o(this),this._iter.__iterate(function(i){return t(i,e?r.size-++n:n++,r)},e)},e.prototype.__iterator=function(t,e){var r=this,n=this._iter.__iterator(Pe,e),i=0;return e&&o(this),new Xe(function(){var o=n.next();return o.done?o:S(t,e?r.size-++i:i++,o.value,o)})},e}(Ze),mr=function(t){function e(t){this._iter=t,this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.has=function(t){return this._iter.includes(t)},e.prototype.__iterate=function(t,e){var r=this;return this._iter.__iterate(function(e){return t(e,e,r)},e)},e.prototype.__iterator=function(t,e){var r=this._iter.__iterator(Pe,e);return new Xe(function(){var e=r.next();return e.done?e:S(t,e.value,e.value,e)})},e}($e),wr=function(t){function e(t){this._iter=t,this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.entrySeq=function(){return this._iter.toSeq()},e.prototype.__iterate=function(t,e){var r=this;return this._iter.__iterate(function(e){if(e){ot(e);var n=l(e);return t(n?e.get(1):e[1],n?e.get(0):e[0],r)}},e)},e.prototype.__iterator=function(t,e){var r=this._iter.__iterator(Pe,e);return new Xe(function(){for(;;){var e=r.next();if(e.done)return e;var n=e.value;if(n){ot(n);var i=l(n);return S(t,i?n.get(0):n[0],i?n.get(1):n[1],e)}}})},e}(Ge);gr.prototype.cacheResult=dr.prototype.cacheResult=mr.prototype.cacheResult=wr.prototype.cacheResult=at;var Sr=function(t){function e(e){ +return null===e||void 0===e?gt():lt(e)&&!g(e)?e:gt().withMutations(function(r){var n=t(e);pt(n.size),n.forEach(function(t,e){return r.set(e,t)})})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return gt().withMutations(function(e){for(var r=0;r=t.length)throw Error("Missing value for key: "+t[r]);e.set(t[r],t[r+1])}})},e.prototype.toString=function(){return this.__toString("Map {","}")},e.prototype.get=function(t,e){return this._root?this._root.get(0,void 0,t,e):e},e.prototype.set=function(t,e){return mt(this,t,e)},e.prototype.setIn=function(t,e){return this.updateIn(t,je,function(){return e})},e.prototype.remove=function(t){return mt(this,t,je)},e.prototype.deleteIn=function(t){if(t=[].concat(ht(t)),t.length){var e=t.pop();return this.updateIn(t,function(t){return t&&t.remove(e)})}},e.prototype.deleteAll=function(t){var e=Ce(t);return 0===e.size?this:this.withMutations(function(t){e.forEach(function(e){return t.remove(e)})})},e.prototype.update=function(t,e,r){return 1===arguments.length?t(this):this.updateIn([t],e,r)},e.prototype.updateIn=function(t,e,r){r||(r=e,e=void 0);var n=xt(this,ht(t),0,e,r);return n===je?e:n},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):gt()},e.prototype.merge=function(){return Mt(this,void 0,arguments)},e.prototype.mergeWith=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Mt(this,t,e)},e.prototype.mergeIn=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return this.updateIn(t,gt(),function(t){return"function"==typeof t.merge?t.merge.apply(t,e):e[e.length-1]})},e.prototype.mergeDeep=function(){return Mt(this,Dt(qt),arguments)},e.prototype.mergeDeepWith=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Mt(this,Dt(t),e)},e.prototype.mergeDeepIn=function(t){ +for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return this.updateIn(t,gt(),function(t){return"function"==typeof t.mergeDeep?t.mergeDeep.apply(t,e):e[e.length-1]})},e.prototype.sort=function(t){return Br(tt(this,t))},e.prototype.sortBy=function(t,e){return Br(tt(this,e,t))},e.prototype.withMutations=function(t){var e=this.asMutable();return t(e),e.wasAltered()?e.__ensureOwner(this.__ownerID):this},e.prototype.asMutable=function(){return this.__ownerID?this:this.__ensureOwner(new n)},e.prototype.asImmutable=function(){return this.__ensureOwner()},e.prototype.wasAltered=function(){return this.__altered},e.prototype.__iterator=function(t,e){return new xr(this,t,e)},e.prototype.__iterate=function(t,e){var r=this,n=0;return this._root&&this._root.iterate(function(e){return n++,t(e[1],e[0],r)},e),n},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?dt(this.size,this._root,t,this.__hash):0===this.size?gt():(this.__ownerID=t,this.__altered=!1,this)},e}(Be);Sr.isMap=lt;var Ir="@@__IMMUTABLE_MAP__@@",zr=Sr.prototype;zr[Ir]=!0,zr.delete=zr.remove,zr.removeIn=zr.deleteIn,zr.removeAll=zr.deleteAll,zr["@@transducer/init"]=zr.asMutable,zr["@@transducer/step"]=function(t,e){return t.set(e[0],e[1])},zr["@@transducer/result"]=function(t){return t.asImmutable()};var br=function(t,e){this.ownerID=t,this.entries=e};br.prototype.get=function(t,e,r,n){for(var i=this.entries,o=0,u=i.length;o=jr)return zt(t,h,o,u);var l=t&&t===this.ownerID,v=l?h:i(h);return _?c?f===p-1?v.pop():v[f]=v.pop():v[f]=[o,u]:v.push([o,u]),l?(this.entries=v,this):new br(t,v)}};var Or=function(t,e,r){this.ownerID=t,this.bitmap=e,this.nodes=r};Or.prototype.get=function(t,e,r,n){void 0===e&&(e=K(r));var i=1<<((0===t?e:e>>>t)&xe),o=this.bitmap +;return 0==(o&i)?n:this.nodes[jt(o&i-1)].get(t+De,e,r,n)},Or.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=K(n));var s=(0===e?r:r>>>e)&xe,a=1<=kr)return Ot(t,p,c,s,l);if(h&&!l&&2===p.length&&St(p[1^f]))return p[1^f];if(h&&l&&1===p.length&&St(l))return l;var v=t&&t===this.ownerID,y=h?l?c:c^a:c|a,d=h?l?kt(p,f,l,v):Rt(p,f,v):At(p,f,l,v);return v?(this.bitmap=y,this.nodes=d,this):new Or(t,y,d)};var Mr=function(t,e,r){this.ownerID=t,this.count=e,this.nodes=r};Mr.prototype.get=function(t,e,r,n){void 0===e&&(e=K(r));var i=(0===t?e:e>>>t)&xe,o=this.nodes[i];return o?o.get(t+De,e,r,n):n},Mr.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=K(n));var s=(0===e?r:r>>>e)&xe,a=i===je,c=this.nodes,h=c[s];if(a&&!h)return this;var f=wt(h,t,e+De,r,n,i,o,u);if(f===h)return this;var p=this.count;if(h){if(!f&&--p0&&i=0&&t>>e&xe;if(n>=this.array.length)return new Lr([],t);var i,o=0===n;if(e>0){var u=this.array[n] +;if((i=u&&u.removeBefore(t,e-De,r))===u&&o)return this}if(o&&!i)return this;var s=Wt(this,t);if(!o)for(var a=0;a>>e&xe;if(n>=this.array.length)return this;var i;if(e>0){var o=this.array[n];if((i=o&&o.removeAfter(t,e-De,r))===o&&n===this.array.length-1)return this}var u=Wt(this,t);return u.array.splice(n+1),i&&(u.array[n]=i),u};var Tr,Cr={},Br=function(t){function e(t){return null===t||void 0===t?Yt():Vt(t)?t:Yt().withMutations(function(e){var r=Be(t);pt(r.size),r.forEach(function(t,r){return e.set(r,t)})})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("OrderedMap {","}")},e.prototype.get=function(t,e){var r=this._map.get(t);return void 0!==r?this._list.get(r)[1]:e},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._map.clear(),this._list.clear(),this):Yt()},e.prototype.set=function(t,e){return Qt(this,t,e)},e.prototype.remove=function(t){return Qt(this,t,je)},e.prototype.wasAltered=function(){return this._map.wasAltered()||this._list.wasAltered()},e.prototype.__iterate=function(t,e){var r=this;return this._list.__iterate(function(e){return e&&t(e[1],e[0],r)},e)},e.prototype.__iterator=function(t,e){return this._list.fromEntrySeq().__iterator(t,e)},e.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var e=this._map.__ensureOwner(t),r=this._list.__ensureOwner(t);return t?Ht(e,r,t,this.__hash):0===this.size?Yt():(this.__ownerID=t,this._map=e,this._list=r,this)},e}(Sr);Br.isOrderedMap=Vt,Br.prototype[Le]=!0,Br.prototype.delete=Br.prototype.remove;var Wr,Jr=function(t){function e(t){return null===t||void 0===t?Gt():Xt(t)?t:Gt().pushAll(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){ +return this(arguments)},e.prototype.toString=function(){return this.__toString("Stack [","]")},e.prototype.get=function(t,e){var r=this._head;for(t=u(this,t);r&&t--;)r=r.next;return r?r.value:e},e.prototype.peek=function(){return this._head&&this._head.value},e.prototype.push=function(){var t=arguments;if(0===arguments.length)return this;for(var e=this.size+arguments.length,r=this._head,n=arguments.length-1;n>=0;n--)r={value:t[n],next:r};return this.__ownerID?(this.size=e,this._head=r,this.__hash=void 0,this.__altered=!0,this):Ft(e,r)},e.prototype.pushAll=function(e){if(e=t(e),0===e.size)return this;if(0===this.size&&Xt(e))return e;pt(e.size);var r=this.size,n=this._head;return e.__iterate(function(t){r++,n={value:t,next:n}},!0),this.__ownerID?(this.size=r,this._head=n,this.__hash=void 0,this.__altered=!0,this):Ft(r,n)},e.prototype.pop=function(){return this.slice(1)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):Gt()},e.prototype.slice=function(e,r){if(a(e,r,this.size))return this;var n=c(e,this.size);if(h(r,this.size)!==this.size)return t.prototype.slice.call(this,e,r);for(var i=this.size-n,o=this._head;n--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):Ft(i,o)},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Ft(this.size,this._head,t,this.__hash):0===this.size?Gt():(this.__ownerID=t,this.__altered=!1,this)},e.prototype.__iterate=function(t,e){var r=this;if(e)return new er(this.toArray()).__iterate(function(e,n){return t(e,n,r)},e);for(var n=0,i=this._head;i&&t(i.value,n++,r)!==!1;)i=i.next;return n},e.prototype.__iterator=function(t,e){if(e)return new er(this.toArray()).__iterator(t,e);var r=0,n=this._head;return new Xe(function(){if(n){var e=n.value;return n=n.next,S(t,r++,e)}return I()})},e}(We);Jr.isStack=Xt;var Nr="@@__IMMUTABLE_STACK__@@",Pr=Jr.prototype;Pr[Nr]=!0,Pr.withMutations=zr.withMutations,Pr.asMutable=zr.asMutable, +Pr.asImmutable=zr.asImmutable,Pr.wasAltered=zr.wasAltered,Pr.shift=Pr.pop,Pr.unshift=Pr.push,Pr.unshiftAll=Pr.pushAll,Pr["@@transducer/init"]=Pr.asMutable,Pr["@@transducer/step"]=function(t,e){return t.unshift(e)},Pr["@@transducer/result"]=zr["@@transducer/result"];var Vr,Hr=function(t){function e(e){return null===e||void 0===e?ne():te(e)&&!g(e)?e:ne().withMutations(function(r){var n=t(e);pt(n.size),n.forEach(function(t){return r.add(t)})})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(Be(t).keySeq())},e.intersect=function(t){return t=Ce(t).toArray(),t.length?Qr.intersect.apply(e(t.pop()),t):ne()},e.union=function(t){return t=Ce(t).toArray(),t.length?Qr.union.apply(e(t.pop()),t):ne()},e.prototype.toString=function(){return this.__toString("Set {","}")},e.prototype.has=function(t){return this._map.has(t)},e.prototype.add=function(t){return ee(this,this._map.set(t,t))},e.prototype.remove=function(t){return ee(this,this._map.remove(t))},e.prototype.clear=function(){return ee(this,this._map.clear())},e.prototype.union=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return e=e.filter(function(t){return 0!==t.size}),0===e.length?this:0!==this.size||this.__ownerID||1!==e.length?this.withMutations(function(r){for(var n=0;n=0&&e=0&&rthis.size?e:this.find(function(e,r){return r===t},void 0,e)},has:function(t){return(t=u(this,t))>=0&&(void 0!==this.size?this.size===1/0||t Date: Thu, 5 Oct 2017 04:28:01 +0000 Subject: [PATCH 041/242] Deploy master to NPM branch --- dist/immutable.es.js | 3 ++- dist/immutable.js | 2 +- dist/immutable.min.js | 44 +++++++++++++++++++++---------------------- 3 files changed, 25 insertions(+), 24 deletions(-) diff --git a/dist/immutable.es.js b/dist/immutable.es.js index 879d4f26aa..fd87654fc5 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -5547,4 +5547,5 @@ var Immutable = { // Note: Iterable is deprecated var Iterable = Collection; -export { version, Collection, Iterable, Seq, Map, OrderedMap, List, Stack, Set, OrderedSet, Record, Range, Repeat, is, fromJS, hash, isImmutable, isCollection, isKeyed, isIndexed, isAssociative, isOrdered, isValueObject };export default Immutable; +export { version, Collection, Iterable, Seq, Map, OrderedMap, List, Stack, Set, OrderedSet, Record, Range, Repeat, is, fromJS, hash, isImmutable, isCollection, isKeyed, isIndexed, isAssociative, isOrdered, isValueObject }; +export default Immutable; diff --git a/dist/immutable.js b/dist/immutable.js index 1ef7aeca13..444366c530 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -8,7 +8,7 @@ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : - (factory((global.Immutable = global.Immutable || {}))); + (factory((global.Immutable = {}))); }(this, (function (exports) { 'use strict'; // Used for setting prototype methods that IE8 chokes on. diff --git a/dist/immutable.min.js b/dist/immutable.min.js index a4aa91f873..d6de80ec5f 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -4,34 +4,34 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.Immutable=t.Immutable||{})}(this,function(t){"use strict";function e(t){return t.value=!1,t}function r(t){t&&(t.value=!0)}function n(){}function i(t,e){e=e||0;for(var r=Math.max(0,t.length-e),n=Array(r),i=0;i>>0;if(""+r!==e||4294967295===r)return NaN;e=r}return e<0?o(t)+e:e}function s(){return!0}function a(t,e,r){return(0===t&&!p(t)||void 0!==r&&t<=-r)&&(void 0===e||void 0!==r&&e>=r)}function c(t,e){return f(t,e,0)}function h(t,e){return f(t,e,e)}function f(t,e,r){return void 0===t?r:p(t)?e===1/0?e:0|Math.max(0,e+t):void 0===e||e===t?t:0|Math.min(e,t)}function p(t){return t<0||0===t&&1/t==-(1/0)}function _(t){return(l(t)||m(t))&&!t.__ownerID}function l(t){return!(!t||!t[Re])}function v(t){return!(!t||!t[Ue])}function y(t){return!(!t||!t[Ke])}function d(t){return v(t)||y(t)}function g(t){return!(!t||!t[Le])}function m(t){return!(!t||!t[Te])}function w(t){return!(!t||"function"!=typeof t.equals||"function"!=typeof t.hashCode)}function S(t,e,r,n){var i=0===t?e:1===t?r:[e,r];return n?n.value=i:n={value:i,done:!1},n}function I(){return{value:void 0,done:!0}}function z(t){return!!M(t)}function b(t){return t&&"function"==typeof t.next}function O(t){var e=M(t);return e&&e.call(t)}function M(t){var e=t&&(He&&t[He]||t[Ye]);if("function"==typeof e)return e}function q(t){return t&&"number"==typeof t.length}function D(t){return!(!t||!t[tr])}function E(){return nr||(nr=new er([]))}function x(t){var e=Array.isArray(t)?new er(t):b(t)?new ur(t):z(t)?new or(t):void 0;if(e)return e.fromEntrySeq();if("object"==typeof t)return new rr(t);throw new TypeError("Expected Array or collection object of [k, v] entries, or keyed object: "+t)}function j(t){var e=A(t);if(e)return e;throw new TypeError("Expected Array or collection object of values: "+t)} -function k(t){var e=A(t);if(e)return e;if("object"==typeof t)return new rr(t);throw new TypeError("Expected Array or collection object of values, or keyed object: "+t)}function A(t){return q(t)?new er(t):b(t)?new ur(t):z(t)?new or(t):void 0}function R(t,e){if(t===e||t!==t&&e!==e)return!0;if(!t||!e)return!1;if("function"==typeof t.valueOf&&"function"==typeof e.valueOf){if(t=t.valueOf(),e=e.valueOf(),t===e||t!==t&&e!==e)return!0;if(!t||!e)return!1}return!!(w(t)&&w(e)&&t.equals(e))}function U(t){return t>>>1&1073741824|3221225471&t}function K(t){if(t===!1||null===t||void 0===t)return 0;if("function"==typeof t.valueOf&&((t=t.valueOf())===!1||null===t||void 0===t))return 0;if(t===!0)return 1;var e=typeof t;if("number"===e){if(t!==t||t===1/0)return 0;var r=0|t;for(r!==t&&(r^=4294967295*t);t>4294967295;)t/=4294967295,r^=t;return U(r)}if("string"===e)return t.length>_r?L(t):T(t);if("function"==typeof t.hashCode)return U(t.hashCode());if("object"===e)return C(t);if("function"==typeof t.toString)return T(""+t);throw Error("Value type "+e+" cannot be hashed.")}function L(t){var e=yr[t];return void 0===e&&(e=T(t),vr===lr&&(vr=0,yr={}),vr++,yr[t]=e),e}function T(t){for(var e=0,r=0;r0)switch(t.nodeType){case 1:return t.uniqueID;case 9:return t.documentElement&&t.documentElement.uniqueID}}function W(t){var e=st(t);return e._iter=t,e.size=t.size,e.flip=function(){return t},e.reverse=function(){var e=t.reverse.apply(this);return e.flip=function(){return t.reverse()},e},e.has=function(e){return t.includes(e)},e.includes=function(e){return t.has(e)},e.cacheResult=at,e.__iterateUncached=function(e,r){var n=this;return t.__iterate(function(t,r){return e(r,t,n)!==!1},r)},e.__iteratorUncached=function(e,r){if(e===Ve){var n=t.__iterator(e,r);return new Xe(function(){var t=n.next();if(!t.done){var e=t.value[0];t.value[0]=t.value[1],t.value[1]=e}return t})}return t.__iterator(e===Pe?Ne:Pe,r)},e}function J(t,e,r){var n=st(t);return n.size=t.size,n.has=function(e){return t.has(e)},n.get=function(n,i){var o=t.get(n,je);return o===je?i:e.call(r,o,n,t)},n.__iterateUncached=function(n,i){var o=this;return t.__iterate(function(t,i,u){return n(e.call(r,t,i,u),i,o)!==!1},i)},n.__iteratorUncached=function(n,i){var o=t.__iterator(Ve,i);return new Xe(function(){var i=o.next();if(i.done)return i;var u=i.value,s=u[0];return S(n,s,e.call(r,u[1],s,t),i)})},n}function N(t,e){var r=this,n=st(t);return n._iter=t,n.size=t.size,n.reverse=function(){return t},t.flip&&(n.flip=function(){var e=W(t);return e.reverse=function(){return t.flip()},e}),n.get=function(r,n){return t.get(e?r:-1-r,n)},n.has=function(r){return t.has(e?r:-1-r)},n.includes=function(e){return t.includes(e)},n.cacheResult=at,n.__iterate=function(r,n){var i=this,u=0;return n&&o(t),t.__iterate(function(t,o){return r(t,e?o:n?i.size-++u:u++,i)},!n)},n.__iterator=function(n,i){var u=0;i&&o(t);var s=t.__iterator(Ve,!i);return new Xe(function(){var t=s.next();if(t.done)return t;var o=t.value;return S(n,e?o[0]:i?r.size-++u:u++,o[1],t)})},n}function P(t,e,r,n){var i=st(t);return n&&(i.has=function(n){var i=t.get(n,je);return i!==je&&!!e.call(r,i,n,t)},i.get=function(n,i){var o=t.get(n,je);return o!==je&&e.call(r,o,n,t)?o:i}), -i.__iterateUncached=function(i,o){var u=this,s=0;return t.__iterate(function(t,o,a){if(e.call(r,t,o,a))return s++,i(t,n?o:s-1,u)},o),s},i.__iteratorUncached=function(i,o){var u=t.__iterator(Ve,o),s=0;return new Xe(function(){for(;;){var o=u.next();if(o.done)return o;var a=o.value,c=a[0],h=a[1];if(e.call(r,h,c,t))return S(i,n?c:s++,h,o)}})},i}function V(t,e,r){var n=Sr().asMutable();return t.__iterate(function(i,o){n.update(e.call(r,i,o,t),0,function(t){return t+1})}),n.asImmutable()}function H(t,e,r){var n=v(t),i=(g(t)?Br():Sr()).asMutable();t.__iterate(function(o,u){i.update(e.call(r,o,u,t),function(t){return t=t||[],t.push(n?[u,o]:o),t})});var o=ut(t);return i.map(function(e){return it(t,o(e))})}function Y(t,e,r,n){var i=t.size;if(a(e,r,i))return t;var o=c(e,i),s=h(r,i);if(o!==o||s!==s)return Y(t.toSeq().cacheResult(),e,r,n);var f,p=s-o;p===p&&(f=p<0?0:p);var _=st(t);return _.size=0===f?f:t.size&&f||void 0,!n&&D(t)&&f>=0&&(_.get=function(e,r){return e=u(this,e),e>=0&&ef)return I();var t=i.next();return n||e===Pe||t.done?t:e===Ne?S(e,s-1,void 0,t):S(e,s-1,t.value[1],t)})},_}function Q(t,e,r){var n=st(t);return n.__iterateUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterate(n,i);var u=0;return t.__iterate(function(t,i,s){return e.call(r,t,i,s)&&++u&&n(t,i,o)}),u},n.__iteratorUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterator(n,i);var u=t.__iterator(Ve,i),s=!0;return new Xe(function(){if(!s)return I();var t=u.next();if(t.done)return t;var i=t.value,a=i[0],c=i[1];return e.call(r,c,a,o)?n===Ve?t:S(n,a,c,t):(s=!1,I())})},n} -function X(t,e,r,n){var i=st(t);return i.__iterateUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterate(i,o);var s=!0,a=0;return t.__iterate(function(t,o,c){if(!s||!(s=e.call(r,t,o,c)))return a++,i(t,n?o:a-1,u)}),a},i.__iteratorUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterator(i,o);var s=t.__iterator(Ve,o),a=!0,c=0;return new Xe(function(){var t,o,h;do{if(t=s.next(),t.done)return n||i===Pe?t:i===Ne?S(i,c++,void 0,t):S(i,c++,t.value[1],t);var f=t.value;o=f[0],h=f[1],a&&(a=e.call(r,h,o,u))}while(a);return i===Ve?t:S(i,o,h,t)})},i}function F(t,e){var r=v(t),n=[t].concat(e).map(function(t){return l(t)?r&&(t=Be(t)):t=r?x(t):j(Array.isArray(t)?t:[t]),t}).filter(function(t){return 0!==t.size});if(0===n.length)return t;if(1===n.length){var i=n[0];if(i===t||r&&v(i)||y(t)&&y(i))return i}var o=new er(n);return r?o=o.toKeyedSeq():y(t)||(o=o.toSetSeq()),o=o.flatten(!0),o.size=n.reduce(function(t,e){if(void 0!==t){var r=e.size;if(void 0!==r)return t+r}},0),o}function G(t,e,r){var n=st(t);return n.__iterateUncached=function(i,o){function u(t,c){t.__iterate(function(t,o){return(!e||c0}function nt(t,e,r,n){var i=st(t),o=new er(r).map(function(t){return t.size});return i.size=n?o.max():o.min(),i.__iterate=function(t,e){for(var r,n=this,i=this.__iterator(Pe,e),o=0;!(r=i.next()).done&&t(r.value,o++,n)!==!1;);return o},i.__iteratorUncached=function(t,i){var o=r.map(function(t){return t=Ce(t),O(i?t.reverse():t)}),u=0,s=!1;return new Xe(function(){var r;return s||(r=o.map(function(t){return t.next()}),s=n?r.every(function(t){return t.done}):r.some(function(t){return t.done})),s?I():S(t,u++,e.apply(null,r.map(function(t){return t.value})))})},i}function it(t,e){return t===e?t:D(t)?e:t.constructor(e)}function ot(t){if(t!==Object(t))throw new TypeError("Expected [K, V] tuple: "+t)}function ut(t){return v(t)?Be:y(t)?We:Je}function st(t){return Object.create((v(t)?Ge:y(t)?Ze:$e).prototype)}function at(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size,this):Fe.prototype.cacheResult.call(this)}function ct(t,e){return void 0===t&&void 0===e?0:void 0===t?1:void 0===e?-1:t>e?1:t>>r)&xe,s=(0===r?n:n>>>r)&xe;return new Or(e,1<>>=1)u[s]=1&r?e[o++]:void 0;return u[n]=i,new Mr(t,o+1,u)}function Mt(t,e,r){for(var n=[],i=0;i>>0;if(""+r!==e||4294967295===r)return NaN;e=r}return e<0?o(t)+e:e}function s(){return!0}function a(t,e,r){return(0===t&&!p(t)||void 0!==r&&t<=-r)&&(void 0===e||void 0!==r&&e>=r)}function c(t,e){return f(t,e,0)}function h(t,e){return f(t,e,e)}function f(t,e,r){return void 0===t?r:p(t)?e===1/0?e:0|Math.max(0,e+t):void 0===e||e===t?t:0|Math.min(e,t)}function p(t){return t<0||0===t&&1/t==-(1/0)}function _(t){return(l(t)||m(t))&&!t.__ownerID}function l(t){return!(!t||!t[Re])}function v(t){return!(!t||!t[Ue])}function y(t){return!(!t||!t[Ke])}function d(t){return v(t)||y(t)}function g(t){return!(!t||!t[Le])}function m(t){return!(!t||!t[Te])}function w(t){return!(!t||"function"!=typeof t.equals||"function"!=typeof t.hashCode)}function S(t,e,r,n){var i=0===t?e:1===t?r:[e,r];return n?n.value=i:n={value:i,done:!1},n}function z(){return{value:void 0,done:!0}}function I(t){return!!M(t)}function b(t){return t&&"function"==typeof t.next}function O(t){var e=M(t);return e&&e.call(t)}function M(t){var e=t&&(He&&t[He]||t[Ye]);if("function"==typeof e)return e}function q(t){return t&&"number"==typeof t.length}function D(t){return!(!t||!t[tr])}function E(){return nr||(nr=new er([]))}function x(t){var e=Array.isArray(t)?new er(t):b(t)?new ur(t):I(t)?new or(t):void 0;if(e)return e.fromEntrySeq();if("object"==typeof t)return new rr(t);throw new TypeError("Expected Array or collection object of [k, v] entries, or keyed object: "+t)}function j(t){var e=A(t);if(e)return e;throw new TypeError("Expected Array or collection object of values: "+t)}function k(t){ +var e=A(t);if(e)return e;if("object"==typeof t)return new rr(t);throw new TypeError("Expected Array or collection object of values, or keyed object: "+t)}function A(t){return q(t)?new er(t):b(t)?new ur(t):I(t)?new or(t):void 0}function R(t,e){if(t===e||t!==t&&e!==e)return!0;if(!t||!e)return!1;if("function"==typeof t.valueOf&&"function"==typeof e.valueOf){if(t=t.valueOf(),e=e.valueOf(),t===e||t!==t&&e!==e)return!0;if(!t||!e)return!1}return!!(w(t)&&w(e)&&t.equals(e))}function U(t){return t>>>1&1073741824|3221225471&t}function K(t){if(t===!1||null===t||void 0===t)return 0;if("function"==typeof t.valueOf&&((t=t.valueOf())===!1||null===t||void 0===t))return 0;if(t===!0)return 1;var e=typeof t;if("number"===e){if(t!==t||t===1/0)return 0;var r=0|t;for(r!==t&&(r^=4294967295*t);t>4294967295;)t/=4294967295,r^=t;return U(r)}if("string"===e)return t.length>_r?L(t):T(t);if("function"==typeof t.hashCode)return U(t.hashCode());if("object"===e)return C(t);if("function"==typeof t.toString)return T(""+t);throw Error("Value type "+e+" cannot be hashed.")}function L(t){var e=yr[t];return void 0===e&&(e=T(t),vr===lr&&(vr=0,yr={}),vr++,yr[t]=e),e}function T(t){for(var e=0,r=0;r0)switch(t.nodeType){case 1:return t.uniqueID;case 9:return t.documentElement&&t.documentElement.uniqueID}}function W(t){var e=st(t);return e._iter=t,e.size=t.size,e.flip=function(){return t},e.reverse=function(){var e=t.reverse.apply(this);return e.flip=function(){return t.reverse()},e},e.has=function(e){return t.includes(e)},e.includes=function(e){return t.has(e)},e.cacheResult=at,e.__iterateUncached=function(e,r){var n=this;return t.__iterate(function(t,r){return e(r,t,n)!==!1},r)},e.__iteratorUncached=function(e,r){if(e===Ve){var n=t.__iterator(e,r);return new Xe(function(){var t=n.next();if(!t.done){var e=t.value[0];t.value[0]=t.value[1],t.value[1]=e}return t})}return t.__iterator(e===Pe?Ne:Pe,r)},e}function J(t,e,r){var n=st(t);return n.size=t.size,n.has=function(e){return t.has(e)},n.get=function(n,i){var o=t.get(n,je);return o===je?i:e.call(r,o,n,t)},n.__iterateUncached=function(n,i){var o=this;return t.__iterate(function(t,i,u){return n(e.call(r,t,i,u),i,o)!==!1},i)},n.__iteratorUncached=function(n,i){var o=t.__iterator(Ve,i);return new Xe(function(){var i=o.next();if(i.done)return i;var u=i.value,s=u[0];return S(n,s,e.call(r,u[1],s,t),i)})},n}function N(t,e){var r=this,n=st(t);return n._iter=t,n.size=t.size,n.reverse=function(){return t},t.flip&&(n.flip=function(){var e=W(t);return e.reverse=function(){return t.flip()},e}),n.get=function(r,n){return t.get(e?r:-1-r,n)},n.has=function(r){return t.has(e?r:-1-r)},n.includes=function(e){return t.includes(e)},n.cacheResult=at,n.__iterate=function(r,n){var i=this,u=0;return n&&o(t),t.__iterate(function(t,o){return r(t,e?o:n?i.size-++u:u++,i)},!n)},n.__iterator=function(n,i){var u=0;i&&o(t);var s=t.__iterator(Ve,!i);return new Xe(function(){var t=s.next();if(t.done)return t;var o=t.value;return S(n,e?o[0]:i?r.size-++u:u++,o[1],t)})},n}function P(t,e,r,n){var i=st(t);return n&&(i.has=function(n){var i=t.get(n,je);return i!==je&&!!e.call(r,i,n,t)},i.get=function(n,i){var o=t.get(n,je);return o!==je&&e.call(r,o,n,t)?o:i}), +i.__iterateUncached=function(i,o){var u=this,s=0;return t.__iterate(function(t,o,a){if(e.call(r,t,o,a))return s++,i(t,n?o:s-1,u)},o),s},i.__iteratorUncached=function(i,o){var u=t.__iterator(Ve,o),s=0;return new Xe(function(){for(;;){var o=u.next();if(o.done)return o;var a=o.value,c=a[0],h=a[1];if(e.call(r,h,c,t))return S(i,n?c:s++,h,o)}})},i}function V(t,e,r){var n=Sr().asMutable();return t.__iterate(function(i,o){n.update(e.call(r,i,o,t),0,function(t){return t+1})}),n.asImmutable()}function H(t,e,r){var n=v(t),i=(g(t)?Br():Sr()).asMutable();t.__iterate(function(o,u){i.update(e.call(r,o,u,t),function(t){return t=t||[],t.push(n?[u,o]:o),t})});var o=ut(t);return i.map(function(e){return it(t,o(e))})}function Y(t,e,r,n){var i=t.size;if(a(e,r,i))return t;var o=c(e,i),s=h(r,i);if(o!==o||s!==s)return Y(t.toSeq().cacheResult(),e,r,n);var f,p=s-o;p===p&&(f=p<0?0:p);var _=st(t);return _.size=0===f?f:t.size&&f||void 0,!n&&D(t)&&f>=0&&(_.get=function(e,r){return e=u(this,e),e>=0&&ef)return z();var t=i.next();return n||e===Pe||t.done?t:e===Ne?S(e,s-1,void 0,t):S(e,s-1,t.value[1],t)})},_}function Q(t,e,r){var n=st(t);return n.__iterateUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterate(n,i);var u=0;return t.__iterate(function(t,i,s){return e.call(r,t,i,s)&&++u&&n(t,i,o)}),u},n.__iteratorUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterator(n,i);var u=t.__iterator(Ve,i),s=!0;return new Xe(function(){if(!s)return z();var t=u.next();if(t.done)return t;var i=t.value,a=i[0],c=i[1];return e.call(r,c,a,o)?n===Ve?t:S(n,a,c,t):(s=!1,z())})},n} +function X(t,e,r,n){var i=st(t);return i.__iterateUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterate(i,o);var s=!0,a=0;return t.__iterate(function(t,o,c){if(!s||!(s=e.call(r,t,o,c)))return a++,i(t,n?o:a-1,u)}),a},i.__iteratorUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterator(i,o);var s=t.__iterator(Ve,o),a=!0,c=0;return new Xe(function(){var t,o,h;do{if(t=s.next(),t.done)return n||i===Pe?t:i===Ne?S(i,c++,void 0,t):S(i,c++,t.value[1],t);var f=t.value;o=f[0],h=f[1],a&&(a=e.call(r,h,o,u))}while(a);return i===Ve?t:S(i,o,h,t)})},i}function F(t,e){var r=v(t),n=[t].concat(e).map(function(t){return l(t)?r&&(t=Be(t)):t=r?x(t):j(Array.isArray(t)?t:[t]),t}).filter(function(t){return 0!==t.size});if(0===n.length)return t;if(1===n.length){var i=n[0];if(i===t||r&&v(i)||y(t)&&y(i))return i}var o=new er(n);return r?o=o.toKeyedSeq():y(t)||(o=o.toSetSeq()),o=o.flatten(!0),o.size=n.reduce(function(t,e){if(void 0!==t){var r=e.size;if(void 0!==r)return t+r}},0),o}function G(t,e,r){var n=st(t);return n.__iterateUncached=function(i,o){function u(t,c){t.__iterate(function(t,o){return(!e||c0}function nt(t,e,r,n){var i=st(t),o=new er(r).map(function(t){return t.size});return i.size=n?o.max():o.min(),i.__iterate=function(t,e){for(var r,n=this,i=this.__iterator(Pe,e),o=0;!(r=i.next()).done&&t(r.value,o++,n)!==!1;);return o},i.__iteratorUncached=function(t,i){var o=r.map(function(t){return t=Ce(t),O(i?t.reverse():t)}),u=0,s=!1;return new Xe(function(){var r;return s||(r=o.map(function(t){return t.next()}),s=n?r.every(function(t){return t.done}):r.some(function(t){return t.done})),s?z():S(t,u++,e.apply(null,r.map(function(t){return t.value})))})},i}function it(t,e){return t===e?t:D(t)?e:t.constructor(e)}function ot(t){if(t!==Object(t))throw new TypeError("Expected [K, V] tuple: "+t)}function ut(t){return v(t)?Be:y(t)?We:Je}function st(t){return Object.create((v(t)?Ge:y(t)?Ze:$e).prototype)}function at(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size,this):Fe.prototype.cacheResult.call(this)}function ct(t,e){return void 0===t&&void 0===e?0:void 0===t?1:void 0===e?-1:t>e?1:t>>r)&xe,s=(0===r?n:n>>>r)&xe;return new Or(e,1<>>=1)u[s]=1&r?e[o++]:void 0;return u[n]=i,new Mr(t,o+1,u)}function Mt(t,e,r){for(var n=[],i=0;i>1&1431655765,t=(858993459&t)+(t>>2&858993459),t=t+(t>>4)&252645135,t+=t>>8,127&(t+=t>>16)}function kt(t,e,r,n){var o=n?t:i(t);return o[e]=r,o}function At(t,e,r,n){var i=t.length+1;if(n&&e+1===i)return t[e]=r,t;for(var o=Array(i),u=0,s=0;so?0:o-r,c=u-r;return c>Ee&&(c=Ee),function(){if(i===c)return Cr;var t=e?--c:i++;return n&&n[t]}}function i(t,n,i){var s,a=t&&t.array,c=i>o?0:o-i>>n,h=1+(u-i>>n);return h>Ee&&(h=Ee),function(){for(;;){if(s){var t=s();if(t!==Cr)return t;s=null}if(c===h)return Cr;var o=e?--h:c++;s=r(a&&a[o],n-De,i+(o<=t.size||r<0)return t.withMutations(function(t){r<0?Nt(t,r).set(0,n):Nt(t,0,r+1).set(r,n)});r+=t._origin;var i=t._tail,o=t._root,s=e(Ae);return r>=Pt(t._capacity)?i=Bt(i,t.__ownerID,0,r,n,s):o=Bt(o,t.__ownerID,t._level,r,n,s),s.value?t.__ownerID?(t._root=o,t._tail=i,t.__hash=void 0,t.__altered=!0,t):Lt(t._origin,t._capacity,t._level,o,i):t}function Bt(t,e,n,i,o,u){var s=i>>>n&xe,a=t&&s0){var h=t&&t.array[s],f=Bt(h,e,n-De,i,o,u);return f===h?t:(c=Wt(t,e),c.array[s]=f,c)} return a&&t.array[s]===o?t:(r(u),c=Wt(t,e),void 0===o&&s===c.array.length-1?c.array.pop():c.array[s]=o,c)}function Wt(t,e){return e&&t&&e===t.ownerID?t:new Lr(t?t.array.slice():[],e)}function Jt(t,e){if(e>=Pt(t._capacity))return t._tail;if(e<1<0;)r=r.array[e>>>n&xe],n-=De;return r}}function Nt(t,e,r){void 0!==e&&(e|=0),void 0!==r&&(r|=0);var i=t.__ownerID||new n,o=t._origin,u=t._capacity,s=o+e,a=void 0===r?u:r<0?u+r:o+r;if(s===o&&a===u)return t;if(s>=a)return t.clear();for(var c=t._level,h=t._root,f=0;s+f<0;)h=new Lr(h&&h.array.length?[void 0,h]:[],i),c+=De,f+=1<=1<p?new Lr([],i):l;if(l&&_>p&&sDe;d-=De){var g=p>>>d&xe;y=y.array[g]=Wt(y.array[g],i)}y.array[p>>>De&xe]=l}if(a=_)s-=_,a-=_,c=De,h=null,v=v&&v.removeBefore(i,0,s);else if(s>o||_>>c&xe;if(m!==_>>>c&xe)break;m&&(f+=(1<o&&(h=h.removeBefore(i,c,s-f)),h&&_>>De<=Ee&&u.size>=2*o.size?(i=u.filter(function(t,e){return void 0!==t&&s!==e}),n=i.toKeyedSeq().map(function(t){return t[0]}).flip().toMap(),t.__ownerID&&(n.__ownerID=i.__ownerID=t.__ownerID)):(n=o.remove(e),i=s===u.size-1?u.pop():u.set(s,void 0))}else if(a){if(r===u.get(s)[1])return t;n=o,i=u.set(s,[e,r])}else n=o.set(e,u.size),i=u.set(u.size,[e,r]) ;return t.__ownerID?(t.size=n.size,t._map=n,t._list=i,t.__hash=void 0,t):Ht(n,i)}function Xt(t){return!(!t||!t[Nr])}function Ft(t,e,r,n){var i=Object.create(Pr);return i.size=t,i._head=e,i.__ownerID=r,i.__hash=n,i.__altered=!1,i}function Gt(){return Vr||(Vr=Ft(0))}function Zt(t,e){if(t===e)return!0;if(!l(e)||void 0!==t.size&&void 0!==e.size&&t.size!==e.size||void 0!==t.__hash&&void 0!==e.__hash&&t.__hash!==e.__hash||v(t)!==v(e)||y(t)!==y(e)||g(t)!==g(e))return!1;if(0===t.size&&0===e.size)return!0;var r=!d(t);if(g(t)){var n=t.entries();return e.every(function(t,e){var i=n.next().value;return i&&R(i[1],t)&&(r||R(i[0],e))})&&n.next().done}var i=!1;if(void 0===t.size)if(void 0===e.size)"function"==typeof t.cacheResult&&t.cacheResult();else{i=!0;var o=t;t=e,e=o}var u=!0,s=e.__iterate(function(e,n){if(r?!t.has(e):i?!R(e,t.get(n,je)):!R(t.get(n,je),e))return u=!1,!1});return u&&t.size===s}function $t(t,e){var r=function(r){t.prototype[r]=e[r]};return Object.keys(e).forEach(r),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(e).forEach(r),t}function te(t){return!(!t||!t[Yr])}function ee(t,e){return t.__ownerID?(t.size=e.size,t._map=e,t):e===t._map?t:0===e.size?t.__empty():t.__make(e)}function re(t,e){var r=Object.create(Qr);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function ne(){return Xr||(Xr=re(gt()))}function ie(t,e,r,n,i,o){return pt(t.size),t.__iterate(function(t,o,u){i?(i=!1,r=t):r=e.call(n,r,t,o,u)},o),r}function oe(t,e){return e}function ue(t,e){return[e,t]}function se(t){return t&&"function"==typeof t.toJS?t.toJS():t}function ae(t){return function(){return!t.apply(this,arguments)}}function ce(t){return function(){return-t.apply(this,arguments)}}function he(){return i(arguments)}function fe(t,e){return te?-1:0}function pe(t){if(t.size===1/0)return 0;var e=g(t),r=v(t),n=e?1:0;return _e(t.__iterate(r?e?function(t,e){n=31*n+le(K(t),K(e))|0}:function(t,e){n=n+le(K(t),K(e))|0}:e?function(t){n=31*n+K(t)|0}:function(t){n=n+K(t)|0}),n)}function _e(t,e){return e=sr(e,3432918353), -e=sr(e<<15|e>>>-15,461845907),e=sr(e<<13|e>>>-13,5),e=(e+3864292196|0)^t,e=sr(e^e>>>16,2246822507),e=sr(e^e>>>13,3266489909),e=U(e^e>>>16)}function le(t,e){return t^e+2654435769+(t<<6)+(t>>2)|0}function ve(t){if("object"!=typeof console||!console.warn)throw Error(t);console.warn(t)}function ye(t,e,r,n){for(var i=ht(r),o=0;o!==i.length;){if(!t||!t.get)return n&&ve("Invalid keyPath: Value at ["+i.slice(0,o).map(_t)+"] does not have a .get() method: "+t+"\nThis warning will throw in a future version"),e;if((t=t.get(i[o++],je))===je)return e}return t}function de(t){return te(t)&&g(t)}function ge(t,e){var r=Object.create(rn);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function me(){return nn||(nn=ge(Yt()))}function we(t,e,r){var n=Object.create(Object.getPrototypeOf(t));return n._values=e,n.__ownerID=r,n}function Se(t){return t._name||t.constructor.name||"Record"}function Ie(t){return x(t._keys.map(function(e){return[e,t.get(e)]}))}function ze(t,e){try{Object.defineProperty(t,e,{get:function(){return this.get(e)},set:function(t){ft(this.__ownerID,"Cannot set on an immutable record."),this.set(e,t)}})}catch(t){}}function be(t,e){return Oe([],e||Me,t,"",e&&e.length>2?[]:void 0,{"":t})}function Oe(t,e,r,n,i,o){var u=Array.isArray(r)?Ze:qe(r)?Ge:null;if(u){if(~t.indexOf(r))throw new TypeError("Cannot convert circular structure to Immutable");t.push(r),i&&""!==n&&i.push(n);var s=e.call(o,n,u(r).map(function(n,o){return Oe(t,e,n,o,i,r)}),i&&i.slice());return t.pop(),i&&i.pop(),s}return r}function Me(t,e){return v(e)?e.toMap():e.toList()}function qe(t){return t&&(t.constructor===Object||void 0===t.constructor)}var De=5,Ee=1<=n.length){var e=r.next();if(e.done)return e;n[i]=e.value}return S(t,i,n[i++])})},e}(Ze),sr="function"==typeof Math.imul&&Math.imul(4294967295,2)===-2?Math.imul:function(t,e){t|=0,e|=0;var r=65535&t,n=65535&e;return r*n+((t>>>16)*n+r*(e>>>16)<<16>>>0)|0},ar=Object.isExtensible,cr=function(){try{return Object.defineProperty({},"@",{}),!0}catch(t){return!1}}(),hr="function"==typeof WeakMap;hr&&(ir=new WeakMap);var fr=0,pr="__immutablehash__";"function"==typeof Symbol&&(pr=Symbol(pr));var _r=16,lr=255,vr=0,yr={},dr=function(t){function e(t,e){this._iter=t,this._useKeys=e,this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t,e){return this._iter.get(t,e)},e.prototype.has=function(t){return this._iter.has(t)},e.prototype.valueSeq=function(){return this._iter.valueSeq()},e.prototype.reverse=function(){var t=this,e=N(this,!0);return this._useKeys||(e.valueSeq=function(){return t._iter.toSeq().reverse()}),e},e.prototype.map=function(t,e){var r=this,n=J(this,t,e);return this._useKeys||(n.valueSeq=function(){ +e=sr(e<<15|e>>>-15,461845907),e=sr(e<<13|e>>>-13,5),e=(e+3864292196|0)^t,e=sr(e^e>>>16,2246822507),e=sr(e^e>>>13,3266489909),e=U(e^e>>>16)}function le(t,e){return t^e+2654435769+(t<<6)+(t>>2)|0}function ve(t){if("object"!=typeof console||!console.warn)throw Error(t);console.warn(t)}function ye(t,e,r,n){for(var i=ht(r),o=0;o!==i.length;){if(!t||!t.get)return n&&ve("Invalid keyPath: Value at ["+i.slice(0,o).map(_t)+"] does not have a .get() method: "+t+"\nThis warning will throw in a future version"),e;if((t=t.get(i[o++],je))===je)return e}return t}function de(t){return te(t)&&g(t)}function ge(t,e){var r=Object.create(rn);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function me(){return nn||(nn=ge(Yt()))}function we(t,e,r){var n=Object.create(Object.getPrototypeOf(t));return n._values=e,n.__ownerID=r,n}function Se(t){return t._name||t.constructor.name||"Record"}function ze(t){return x(t._keys.map(function(e){return[e,t.get(e)]}))}function Ie(t,e){try{Object.defineProperty(t,e,{get:function(){return this.get(e)},set:function(t){ft(this.__ownerID,"Cannot set on an immutable record."),this.set(e,t)}})}catch(t){}}function be(t,e){return Oe([],e||Me,t,"",e&&e.length>2?[]:void 0,{"":t})}function Oe(t,e,r,n,i,o){var u=Array.isArray(r)?Ze:qe(r)?Ge:null;if(u){if(~t.indexOf(r))throw new TypeError("Cannot convert circular structure to Immutable");t.push(r),i&&""!==n&&i.push(n);var s=e.call(o,n,u(r).map(function(n,o){return Oe(t,e,n,o,i,r)}),i&&i.slice());return t.pop(),i&&i.pop(),s}return r}function Me(t,e){return v(e)?e.toMap():e.toList()}function qe(t){return t&&(t.constructor===Object||void 0===t.constructor)}var De=5,Ee=1<=n.length){var e=r.next();if(e.done)return e;n[i]=e.value}return S(t,i,n[i++])})},e}(Ze),sr="function"==typeof Math.imul&&Math.imul(4294967295,2)===-2?Math.imul:function(t,e){t|=0,e|=0;var r=65535&t,n=65535&e;return r*n+((t>>>16)*n+r*(e>>>16)<<16>>>0)|0},ar=Object.isExtensible,cr=function(){try{return Object.defineProperty({},"@",{}),!0}catch(t){return!1}}(),hr="function"==typeof WeakMap;hr&&(ir=new WeakMap);var fr=0,pr="__immutablehash__";"function"==typeof Symbol&&(pr=Symbol(pr));var _r=16,lr=255,vr=0,yr={},dr=function(t){function e(t,e){this._iter=t,this._useKeys=e,this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t,e){return this._iter.get(t,e)},e.prototype.has=function(t){return this._iter.has(t)},e.prototype.valueSeq=function(){return this._iter.valueSeq()},e.prototype.reverse=function(){var t=this,e=N(this,!0);return this._useKeys||(e.valueSeq=function(){return t._iter.toSeq().reverse()}),e},e.prototype.map=function(t,e){var r=this,n=J(this,t,e);return this._useKeys||(n.valueSeq=function(){ return r._iter.toSeq().map(t,e)}),n},e.prototype.__iterate=function(t,e){var r=this;return this._iter.__iterate(function(e,n){return t(e,n,r)},e)},e.prototype.__iterator=function(t,e){return this._iter.__iterator(t,e)},e}(Ge);dr.prototype[Le]=!0;var gr=function(t){function e(t){this._iter=t,this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.includes=function(t){return this._iter.includes(t)},e.prototype.__iterate=function(t,e){var r=this,n=0;return e&&o(this),this._iter.__iterate(function(i){return t(i,e?r.size-++n:n++,r)},e)},e.prototype.__iterator=function(t,e){var r=this,n=this._iter.__iterator(Pe,e),i=0;return e&&o(this),new Xe(function(){var o=n.next();return o.done?o:S(t,e?r.size-++i:i++,o.value,o)})},e}(Ze),mr=function(t){function e(t){this._iter=t,this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.has=function(t){return this._iter.includes(t)},e.prototype.__iterate=function(t,e){var r=this;return this._iter.__iterate(function(e){return t(e,e,r)},e)},e.prototype.__iterator=function(t,e){var r=this._iter.__iterator(Pe,e);return new Xe(function(){var e=r.next();return e.done?e:S(t,e.value,e.value,e)})},e}($e),wr=function(t){function e(t){this._iter=t,this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.entrySeq=function(){return this._iter.toSeq()},e.prototype.__iterate=function(t,e){var r=this;return this._iter.__iterate(function(e){if(e){ot(e);var n=l(e);return t(n?e.get(1):e[1],n?e.get(0):e[0],r)}},e)},e.prototype.__iterator=function(t,e){var r=this._iter.__iterator(Pe,e);return new Xe(function(){for(;;){var e=r.next();if(e.done)return e;var n=e.value;if(n){ot(n);var i=l(n);return S(t,i?n.get(0):n[0],i?n.get(1):n[1],e)}}})},e}(Ge);gr.prototype.cacheResult=dr.prototype.cacheResult=mr.prototype.cacheResult=wr.prototype.cacheResult=at;var Sr=function(t){function e(e){ return null===e||void 0===e?gt():lt(e)&&!g(e)?e:gt().withMutations(function(r){var n=t(e);pt(n.size),n.forEach(function(t,e){return r.set(e,t)})})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return gt().withMutations(function(e){for(var r=0;r=t.length)throw Error("Missing value for key: "+t[r]);e.set(t[r],t[r+1])}})},e.prototype.toString=function(){return this.__toString("Map {","}")},e.prototype.get=function(t,e){return this._root?this._root.get(0,void 0,t,e):e},e.prototype.set=function(t,e){return mt(this,t,e)},e.prototype.setIn=function(t,e){return this.updateIn(t,je,function(){return e})},e.prototype.remove=function(t){return mt(this,t,je)},e.prototype.deleteIn=function(t){if(t=[].concat(ht(t)),t.length){var e=t.pop();return this.updateIn(t,function(t){return t&&t.remove(e)})}},e.prototype.deleteAll=function(t){var e=Ce(t);return 0===e.size?this:this.withMutations(function(t){e.forEach(function(e){return t.remove(e)})})},e.prototype.update=function(t,e,r){return 1===arguments.length?t(this):this.updateIn([t],e,r)},e.prototype.updateIn=function(t,e,r){r||(r=e,e=void 0);var n=xt(this,ht(t),0,e,r);return n===je?e:n},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):gt()},e.prototype.merge=function(){return Mt(this,void 0,arguments)},e.prototype.mergeWith=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Mt(this,t,e)},e.prototype.mergeIn=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return this.updateIn(t,gt(),function(t){return"function"==typeof t.merge?t.merge.apply(t,e):e[e.length-1]})},e.prototype.mergeDeep=function(){return Mt(this,Dt(qt),arguments)},e.prototype.mergeDeepWith=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Mt(this,Dt(t),e)},e.prototype.mergeDeepIn=function(t){ -for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return this.updateIn(t,gt(),function(t){return"function"==typeof t.mergeDeep?t.mergeDeep.apply(t,e):e[e.length-1]})},e.prototype.sort=function(t){return Br(tt(this,t))},e.prototype.sortBy=function(t,e){return Br(tt(this,e,t))},e.prototype.withMutations=function(t){var e=this.asMutable();return t(e),e.wasAltered()?e.__ensureOwner(this.__ownerID):this},e.prototype.asMutable=function(){return this.__ownerID?this:this.__ensureOwner(new n)},e.prototype.asImmutable=function(){return this.__ensureOwner()},e.prototype.wasAltered=function(){return this.__altered},e.prototype.__iterator=function(t,e){return new xr(this,t,e)},e.prototype.__iterate=function(t,e){var r=this,n=0;return this._root&&this._root.iterate(function(e){return n++,t(e[1],e[0],r)},e),n},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?dt(this.size,this._root,t,this.__hash):0===this.size?gt():(this.__ownerID=t,this.__altered=!1,this)},e}(Be);Sr.isMap=lt;var Ir="@@__IMMUTABLE_MAP__@@",zr=Sr.prototype;zr[Ir]=!0,zr.delete=zr.remove,zr.removeIn=zr.deleteIn,zr.removeAll=zr.deleteAll,zr["@@transducer/init"]=zr.asMutable,zr["@@transducer/step"]=function(t,e){return t.set(e[0],e[1])},zr["@@transducer/result"]=function(t){return t.asImmutable()};var br=function(t,e){this.ownerID=t,this.entries=e};br.prototype.get=function(t,e,r,n){for(var i=this.entries,o=0,u=i.length;o=jr)return zt(t,h,o,u);var l=t&&t===this.ownerID,v=l?h:i(h);return _?c?f===p-1?v.pop():v[f]=v.pop():v[f]=[o,u]:v.push([o,u]),l?(this.entries=v,this):new br(t,v)}};var Or=function(t,e,r){this.ownerID=t,this.bitmap=e,this.nodes=r};Or.prototype.get=function(t,e,r,n){void 0===e&&(e=K(r));var i=1<<((0===t?e:e>>>t)&xe),o=this.bitmap -;return 0==(o&i)?n:this.nodes[jt(o&i-1)].get(t+De,e,r,n)},Or.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=K(n));var s=(0===e?r:r>>>e)&xe,a=1<=kr)return Ot(t,p,c,s,l);if(h&&!l&&2===p.length&&St(p[1^f]))return p[1^f];if(h&&l&&1===p.length&&St(l))return l;var v=t&&t===this.ownerID,y=h?l?c:c^a:c|a,d=h?l?kt(p,f,l,v):Rt(p,f,v):At(p,f,l,v);return v?(this.bitmap=y,this.nodes=d,this):new Or(t,y,d)};var Mr=function(t,e,r){this.ownerID=t,this.count=e,this.nodes=r};Mr.prototype.get=function(t,e,r,n){void 0===e&&(e=K(r));var i=(0===t?e:e>>>t)&xe,o=this.nodes[i];return o?o.get(t+De,e,r,n):n},Mr.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=K(n));var s=(0===e?r:r>>>e)&xe,a=i===je,c=this.nodes,h=c[s];if(a&&!h)return this;var f=wt(h,t,e+De,r,n,i,o,u);if(f===h)return this;var p=this.count;if(h){if(!f&&--p0&&i=0&&t>>e&xe;if(n>=this.array.length)return new Lr([],t);var i,o=0===n;if(e>0){var u=this.array[n] +for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return this.updateIn(t,gt(),function(t){return"function"==typeof t.mergeDeep?t.mergeDeep.apply(t,e):e[e.length-1]})},e.prototype.sort=function(t){return Br(tt(this,t))},e.prototype.sortBy=function(t,e){return Br(tt(this,e,t))},e.prototype.withMutations=function(t){var e=this.asMutable();return t(e),e.wasAltered()?e.__ensureOwner(this.__ownerID):this},e.prototype.asMutable=function(){return this.__ownerID?this:this.__ensureOwner(new n)},e.prototype.asImmutable=function(){return this.__ensureOwner()},e.prototype.wasAltered=function(){return this.__altered},e.prototype.__iterator=function(t,e){return new xr(this,t,e)},e.prototype.__iterate=function(t,e){var r=this,n=0;return this._root&&this._root.iterate(function(e){return n++,t(e[1],e[0],r)},e),n},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?dt(this.size,this._root,t,this.__hash):0===this.size?gt():(this.__ownerID=t,this.__altered=!1,this)},e}(Be);Sr.isMap=lt;var zr="@@__IMMUTABLE_MAP__@@",Ir=Sr.prototype;Ir[zr]=!0,Ir.delete=Ir.remove,Ir.removeIn=Ir.deleteIn,Ir.removeAll=Ir.deleteAll,Ir["@@transducer/init"]=Ir.asMutable,Ir["@@transducer/step"]=function(t,e){return t.set(e[0],e[1])},Ir["@@transducer/result"]=function(t){return t.asImmutable()};var br=function(t,e){this.ownerID=t,this.entries=e};br.prototype.get=function(t,e,r,n){for(var i=this.entries,o=0,u=i.length;o=jr)return It(t,h,o,u);var l=t&&t===this.ownerID,v=l?h:i(h);return _?c?f===p-1?v.pop():v[f]=v.pop():v[f]=[o,u]:v.push([o,u]),l?(this.entries=v,this):new br(t,v)}};var Or=function(t,e,r){this.ownerID=t,this.bitmap=e,this.nodes=r};Or.prototype.get=function(t,e,r,n){void 0===e&&(e=K(r));var i=1<<((0===t?e:e>>>t)&xe),o=this.bitmap +;return 0==(o&i)?n:this.nodes[jt(o&i-1)].get(t+De,e,r,n)},Or.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=K(n));var s=(0===e?r:r>>>e)&xe,a=1<=kr)return Ot(t,p,c,s,l);if(h&&!l&&2===p.length&&St(p[1^f]))return p[1^f];if(h&&l&&1===p.length&&St(l))return l;var v=t&&t===this.ownerID,y=h?l?c:c^a:c|a,d=h?l?kt(p,f,l,v):Rt(p,f,v):At(p,f,l,v);return v?(this.bitmap=y,this.nodes=d,this):new Or(t,y,d)};var Mr=function(t,e,r){this.ownerID=t,this.count=e,this.nodes=r};Mr.prototype.get=function(t,e,r,n){void 0===e&&(e=K(r));var i=(0===t?e:e>>>t)&xe,o=this.nodes[i];return o?o.get(t+De,e,r,n):n},Mr.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=K(n));var s=(0===e?r:r>>>e)&xe,a=i===je,c=this.nodes,h=c[s];if(a&&!h)return this;var f=wt(h,t,e+De,r,n,i,o,u);if(f===h)return this;var p=this.count;if(h){if(!f&&--p0&&i=0&&t>>e&xe;if(n>=this.array.length)return new Lr([],t);var i,o=0===n;if(e>0){var u=this.array[n] ;if((i=u&&u.removeBefore(t,e-De,r))===u&&o)return this}if(o&&!i)return this;var s=Wt(this,t);if(!o)for(var a=0;a>>e&xe;if(n>=this.array.length)return this;var i;if(e>0){var o=this.array[n];if((i=o&&o.removeAfter(t,e-De,r))===o&&n===this.array.length-1)return this}var u=Wt(this,t);return u.array.splice(n+1),i&&(u.array[n]=i),u};var Tr,Cr={},Br=function(t){function e(t){return null===t||void 0===t?Yt():Vt(t)?t:Yt().withMutations(function(e){var r=Be(t);pt(r.size),r.forEach(function(t,r){return e.set(r,t)})})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("OrderedMap {","}")},e.prototype.get=function(t,e){var r=this._map.get(t);return void 0!==r?this._list.get(r)[1]:e},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._map.clear(),this._list.clear(),this):Yt()},e.prototype.set=function(t,e){return Qt(this,t,e)},e.prototype.remove=function(t){return Qt(this,t,je)},e.prototype.wasAltered=function(){return this._map.wasAltered()||this._list.wasAltered()},e.prototype.__iterate=function(t,e){var r=this;return this._list.__iterate(function(e){return e&&t(e[1],e[0],r)},e)},e.prototype.__iterator=function(t,e){return this._list.fromEntrySeq().__iterator(t,e)},e.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var e=this._map.__ensureOwner(t),r=this._list.__ensureOwner(t);return t?Ht(e,r,t,this.__hash):0===this.size?Yt():(this.__ownerID=t,this._map=e,this._list=r,this)},e}(Sr);Br.isOrderedMap=Vt,Br.prototype[Le]=!0,Br.prototype.delete=Br.prototype.remove;var Wr,Jr=function(t){function e(t){return null===t||void 0===t?Gt():Xt(t)?t:Gt().pushAll(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){ -return this(arguments)},e.prototype.toString=function(){return this.__toString("Stack [","]")},e.prototype.get=function(t,e){var r=this._head;for(t=u(this,t);r&&t--;)r=r.next;return r?r.value:e},e.prototype.peek=function(){return this._head&&this._head.value},e.prototype.push=function(){var t=arguments;if(0===arguments.length)return this;for(var e=this.size+arguments.length,r=this._head,n=arguments.length-1;n>=0;n--)r={value:t[n],next:r};return this.__ownerID?(this.size=e,this._head=r,this.__hash=void 0,this.__altered=!0,this):Ft(e,r)},e.prototype.pushAll=function(e){if(e=t(e),0===e.size)return this;if(0===this.size&&Xt(e))return e;pt(e.size);var r=this.size,n=this._head;return e.__iterate(function(t){r++,n={value:t,next:n}},!0),this.__ownerID?(this.size=r,this._head=n,this.__hash=void 0,this.__altered=!0,this):Ft(r,n)},e.prototype.pop=function(){return this.slice(1)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):Gt()},e.prototype.slice=function(e,r){if(a(e,r,this.size))return this;var n=c(e,this.size);if(h(r,this.size)!==this.size)return t.prototype.slice.call(this,e,r);for(var i=this.size-n,o=this._head;n--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):Ft(i,o)},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Ft(this.size,this._head,t,this.__hash):0===this.size?Gt():(this.__ownerID=t,this.__altered=!1,this)},e.prototype.__iterate=function(t,e){var r=this;if(e)return new er(this.toArray()).__iterate(function(e,n){return t(e,n,r)},e);for(var n=0,i=this._head;i&&t(i.value,n++,r)!==!1;)i=i.next;return n},e.prototype.__iterator=function(t,e){if(e)return new er(this.toArray()).__iterator(t,e);var r=0,n=this._head;return new Xe(function(){if(n){var e=n.value;return n=n.next,S(t,r++,e)}return I()})},e}(We);Jr.isStack=Xt;var Nr="@@__IMMUTABLE_STACK__@@",Pr=Jr.prototype;Pr[Nr]=!0,Pr.withMutations=zr.withMutations,Pr.asMutable=zr.asMutable, -Pr.asImmutable=zr.asImmutable,Pr.wasAltered=zr.wasAltered,Pr.shift=Pr.pop,Pr.unshift=Pr.push,Pr.unshiftAll=Pr.pushAll,Pr["@@transducer/init"]=Pr.asMutable,Pr["@@transducer/step"]=function(t,e){return t.unshift(e)},Pr["@@transducer/result"]=zr["@@transducer/result"];var Vr,Hr=function(t){function e(e){return null===e||void 0===e?ne():te(e)&&!g(e)?e:ne().withMutations(function(r){var n=t(e);pt(n.size),n.forEach(function(t){return r.add(t)})})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(Be(t).keySeq())},e.intersect=function(t){return t=Ce(t).toArray(),t.length?Qr.intersect.apply(e(t.pop()),t):ne()},e.union=function(t){return t=Ce(t).toArray(),t.length?Qr.union.apply(e(t.pop()),t):ne()},e.prototype.toString=function(){return this.__toString("Set {","}")},e.prototype.has=function(t){return this._map.has(t)},e.prototype.add=function(t){return ee(this,this._map.set(t,t))},e.prototype.remove=function(t){return ee(this,this._map.remove(t))},e.prototype.clear=function(){return ee(this,this._map.clear())},e.prototype.union=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return e=e.filter(function(t){return 0!==t.size}),0===e.length?this:0!==this.size||this.__ownerID||1!==e.length?this.withMutations(function(r){for(var n=0;n=0&&e=0&&r=0;n--)r={value:t[n],next:r};return this.__ownerID?(this.size=e,this._head=r,this.__hash=void 0,this.__altered=!0,this):Ft(e,r)},e.prototype.pushAll=function(e){if(e=t(e),0===e.size)return this;if(0===this.size&&Xt(e))return e;pt(e.size);var r=this.size,n=this._head;return e.__iterate(function(t){r++,n={value:t,next:n}},!0),this.__ownerID?(this.size=r,this._head=n,this.__hash=void 0,this.__altered=!0,this):Ft(r,n)},e.prototype.pop=function(){return this.slice(1)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):Gt()},e.prototype.slice=function(e,r){if(a(e,r,this.size))return this;var n=c(e,this.size);if(h(r,this.size)!==this.size)return t.prototype.slice.call(this,e,r);for(var i=this.size-n,o=this._head;n--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):Ft(i,o)},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Ft(this.size,this._head,t,this.__hash):0===this.size?Gt():(this.__ownerID=t,this.__altered=!1,this)},e.prototype.__iterate=function(t,e){var r=this;if(e)return new er(this.toArray()).__iterate(function(e,n){return t(e,n,r)},e);for(var n=0,i=this._head;i&&t(i.value,n++,r)!==!1;)i=i.next;return n},e.prototype.__iterator=function(t,e){if(e)return new er(this.toArray()).__iterator(t,e);var r=0,n=this._head;return new Xe(function(){if(n){var e=n.value;return n=n.next,S(t,r++,e)}return z()})},e}(We);Jr.isStack=Xt;var Nr="@@__IMMUTABLE_STACK__@@",Pr=Jr.prototype;Pr[Nr]=!0,Pr.withMutations=Ir.withMutations,Pr.asMutable=Ir.asMutable, +Pr.asImmutable=Ir.asImmutable,Pr.wasAltered=Ir.wasAltered,Pr.shift=Pr.pop,Pr.unshift=Pr.push,Pr.unshiftAll=Pr.pushAll,Pr["@@transducer/init"]=Pr.asMutable,Pr["@@transducer/step"]=function(t,e){return t.unshift(e)},Pr["@@transducer/result"]=Ir["@@transducer/result"];var Vr,Hr=function(t){function e(e){return null===e||void 0===e?ne():te(e)&&!g(e)?e:ne().withMutations(function(r){var n=t(e);pt(n.size),n.forEach(function(t){return r.add(t)})})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(Be(t).keySeq())},e.intersect=function(t){return t=Ce(t).toArray(),t.length?Qr.intersect.apply(e(t.pop()),t):ne()},e.union=function(t){return t=Ce(t).toArray(),t.length?Qr.union.apply(e(t.pop()),t):ne()},e.prototype.toString=function(){return this.__toString("Set {","}")},e.prototype.has=function(t){return this._map.has(t)},e.prototype.add=function(t){return ee(this,this._map.set(t,t))},e.prototype.remove=function(t){return ee(this,this._map.remove(t))},e.prototype.clear=function(){return ee(this,this._map.clear())},e.prototype.union=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return e=e.filter(function(t){return 0!==t.size}),0===e.length?this:0!==this.size||this.__ownerID||1!==e.length?this.withMutations(function(r){for(var n=0;n=0&&e=0&&rthis.size?e:this.find(function(e,r){return r===t},void 0,e)},has:function(t){return(t=u(this,t))>=0&&(void 0!==this.size?this.size===1/0||t Date: Thu, 5 Oct 2017 05:11:06 +0000 Subject: [PATCH 042/242] Deploy master to NPM branch --- dist/immutable-nonambient.d.ts | 14 ++------------ dist/immutable.d.ts | 14 ++------------ 2 files changed, 4 insertions(+), 24 deletions(-) diff --git a/dist/immutable-nonambient.d.ts b/dist/immutable-nonambient.d.ts index 805b459d90..9a4d8c3172 100644 --- a/dist/immutable-nonambient.d.ts +++ b/dist/immutable-nonambient.d.ts @@ -4057,20 +4057,10 @@ ): Collection; /** - * Returns a new Collection of the same type with values passed through a - * `mapper` function. - * - * - * ```js - * const { Collection } = require('immutable@4.0.0-rc.4') - * Collection({ a: 1, b: 2 }).map(x => 10 * x) - * // Seq { "a": 10, "b": 20 } - * ``` - * - * Note: `map()` always returns a new instance, even if it produced the same - * value at every step. * Note: used only for sets, which return Collection but are otherwise * identical to normal `map()`. + * + * @ignore */ map(...args: never[]): any; diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index 91bbbce48a..2b9ccae113 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -4057,20 +4057,10 @@ declare module Immutable { ): Collection; /** - * Returns a new Collection of the same type with values passed through a - * `mapper` function. - * - * - * ```js - * const { Collection } = require('immutable@4.0.0-rc.4') - * Collection({ a: 1, b: 2 }).map(x => 10 * x) - * // Seq { "a": 10, "b": 20 } - * ``` - * - * Note: `map()` always returns a new instance, even if it produced the same - * value at every step. * Note: used only for sets, which return Collection but are otherwise * identical to normal `map()`. + * + * @ignore */ map(...args: never[]): any; From f234d08fff6a80b7f87e237232ed57fdda7d4555 Mon Sep 17 00:00:00 2001 From: Travis CI Date: Thu, 5 Oct 2017 05:14:18 +0000 Subject: [PATCH 043/242] Deploy master to NPM branch --- PATENTS | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 PATENTS diff --git a/PATENTS b/PATENTS deleted file mode 100644 index b145145264..0000000000 --- a/PATENTS +++ /dev/null @@ -1,11 +0,0 @@ -Additional Grant of Patent Rights Version 2 - -"Software" means the Immutable JS software distributed by Facebook, Inc. - -Facebook, Inc. (“Facebook”) hereby grants to each recipient of the Software (“you”) a perpetual, worldwide, royalty-free, non-exclusive, irrevocable (subject to the termination provision below) license under any Necessary Claims, to make, have made, use, sell, offer to sell, import, and otherwise transfer the Software. For avoidance of doubt, no license is granted under Facebook’s rights in any patent claims that are infringed by (i) modifications to the Software made by you or any third party or (ii) the Software in combination with any software or other technology. - -The license granted hereunder will terminate, automatically and without notice, if you (or any of your subsidiaries, corporate affiliates or agents) initiate directly or indirectly, or take a direct financial interest in, any Patent Assertion: (i) against Facebook or any of its subsidiaries or corporate affiliates, (ii) against any party if such Patent Assertion arises in whole or in part from any software, technology, product or service of Facebook or any of its subsidiaries or corporate affiliates, or (iii) against any party relating to the Software. Notwithstanding the foregoing, if Facebook or any of its subsidiaries or corporate affiliates files a lawsuit alleging patent infringement against you in the first instance, and you respond by filing a patent infringement counterclaim in that lawsuit against that party that is unrelated to the Software, the license granted hereunder will not terminate under section (i) of this paragraph due to such counterclaim. - -A “Necessary Claim” is a claim of a patent owned by Facebook that is necessarily infringed by the Software standing alone. - -A “Patent Assertion” is any lawsuit or other action alleging direct, indirect, or contributory infringement or inducement to infringe any patent, including a cross-claim or counterclaim. From e308f919e8c9673d150f5c108d2314ecedcb3d22 Mon Sep 17 00:00:00 2001 From: Travis CI Date: Thu, 5 Oct 2017 06:22:28 +0000 Subject: [PATCH 044/242] Deploy 4dc23165ef5f03a800e869ad2ff4640645fd2051 to NPM branch --- dist/immutable-nonambient.d.ts | 257 ++++++++++++++++++++------------- dist/immutable.d.ts | 257 ++++++++++++++++++++------------- 2 files changed, 316 insertions(+), 198 deletions(-) diff --git a/dist/immutable-nonambient.d.ts b/dist/immutable-nonambient.d.ts index 9a4d8c3172..61aa4cc2ff 100644 --- a/dist/immutable-nonambient.d.ts +++ b/dist/immutable-nonambient.d.ts @@ -2343,9 +2343,11 @@ /** - * Creates a new Class which produces Record instances. A record is similar to - * a JS object, but enforces a specific set of allowed string keys, and has - * default values. + * A record is similar to a JS object, but enforces a specific set of allowed + * string keys, and has default values. + * + * The `Record()` function produces new Record Factories, which when called + * create Record instances. * * ```js * const { Record } = require('immutable@4.0.0-rc.4') @@ -2405,10 +2407,10 @@ * **Flow Typing Records:** * * Immutable.js exports two Flow types designed to make it easier to use - * Records with flow typed code, `RecordOf` and `RecordFactory`. + * Records with flow typed code, `RecordOf` and `RecordFactory`. * * When defining a new kind of Record factory function, use a flow type that - * describes the values the record contains along with `RecordFactory`. + * describes the values the record contains along with `RecordFactory`. * To type instances of the Record (which the factory function returns), * use `RecordOf`. * @@ -2418,13 +2420,13 @@ * ```js * import type { RecordFactory, RecordOf } from 'immutable'; * - * // Use RecordFactory for defining new Record factory functions. - * type Point3DFields = { x: number, y: number, z: number }; - * const makePoint3D: RecordFactory = Record({ x: 0, y: 0, z: 0 }); + * // Use RecordFactory for defining new Record factory functions. + * type Point3DProps = { x: number, y: number, z: number }; + * const makePoint3D: RecordFactory = Record({ x: 0, y: 0, z: 0 }); * export makePoint3D; * * // Use RecordOf for defining new instances of that Record. - * export type Point3D = RecordOf; + * export type Point3D = RecordOf; * const some3DPoint: Point3D = makePoint3D({ x: 10, y: 20, z: 30 }); * ``` */ @@ -2433,7 +2435,7 @@ /** * True if `maybeRecord` is an instance of a Record. */ - export function isRecord(maybeRecord: any): maybeRecord is Record.Instance; + export function isRecord(maybeRecord: any): maybeRecord is Record; /** * Records allow passing a second parameter to supply a descriptive name @@ -2452,126 +2454,183 @@ * Record.getDescriptiveName(me) // "Person" * ``` */ - export function getDescriptiveName(record: Instance): string; + export function getDescriptiveName(record: Record): string; + + /** + * A Record.Factory is created by the `Record()` function. Record instances + * are created by passing it some of the accepted values for that Record + * type: + * + * + * ```js + * // makePerson is a Record Factory function + * const makePerson = Record({ name: null, favoriteColor: 'unknown' }); + * + * // alan is a Record instance + * const alan = makePerson({ name: 'Alan' }); + * ``` + * + * Note that Record Factories return `Record & Readonly`, + * this allows use of both the Record instance API, and direct property + * access on the resulting instances: + * + * + * ```js + * // Use the Record API + * console.log('Record API: ' + alan.get('name')) + * + * // Or direct property access (Readonly) + * console.log('property access: ' + alan.name) + * ``` + * + * **Flow Typing Records:** + * + * Use the `RecordFactory` Flow type to get high quality type checking of + * Records: + * + * ```js + * import type { RecordFactory, RecordOf } from 'immutable'; + * + * // Use RecordFactory for defining new Record factory functions. + * type PersonProps = { name: ?string, favoriteColor: string }; + * const makePerson: RecordFactory = Record({ name: null, favoriteColor: 'unknown' }); + * + * // Use RecordOf for defining new instances of that Record. + * type Person = RecordOf; + * const alan: Person = makePerson({ name: 'Alan' }); + * ``` + */ + export module Factory {} - export interface Class { - (values?: Partial | Iterable<[string, any]>): Instance & Readonly; - new (values?: Partial | Iterable<[string, any]>): Instance & Readonly; + export interface Factory { + (values?: Partial | Iterable<[string, any]>): Record & Readonly; + new (values?: Partial | Iterable<[string, any]>): Record & Readonly; } - export interface Instance { + export function Factory(values?: Partial | Iterable<[string, any]>): Record & Readonly; + } - // Reading values + /** + * Unlike other types in Immutable.js, the `Record()` function creates a new + * Record Factory, which is a function that creates Record instances. + * + * See above for examples of using `Record()`. + */ + export function Record(defaultValues: TProps, name?: string): Record.Factory; - has(key: string): key is keyof T; - get(key: K): T[K]; + export interface Record { - // Reading deep values + // Reading values - hasIn(keyPath: Iterable): boolean; - getIn(keyPath: Iterable): any; + has(key: string): key is keyof TProps; + get(key: K): TProps[K]; - // Value equality + // Reading deep values - equals(other: any): boolean; - hashCode(): number; + hasIn(keyPath: Iterable): boolean; + getIn(keyPath: Iterable): any; - // Persistent changes + // Value equality - set(key: K, value: T[K]): this; - update(key: K, updater: (value: T[K]) => T[K]): this; - merge(...collections: Array | Iterable<[string, any]>>): this; - mergeDeep(...collections: Array | Iterable<[string, any]>>): this; + equals(other: any): boolean; + hashCode(): number; - mergeWith( - merger: (oldVal: any, newVal: any, key: keyof T) => any, - ...collections: Array | Iterable<[string, any]>> - ): this; - mergeDeepWith( - merger: (oldVal: any, newVal: any, key: any) => any, - ...collections: Array | Iterable<[string, any]>> - ): this; + // Persistent changes - /** - * Returns a new instance of this Record type with the value for the - * specific key set to its default value. - * - * @alias remove - */ - delete(key: K): this; - remove(key: K): this; + set(key: K, value: TProps[K]): this; + update(key: K, updater: (value: TProps[K]) => TProps[K]): this; + merge(...collections: Array | Iterable<[string, any]>>): this; + mergeDeep(...collections: Array | Iterable<[string, any]>>): this; - /** - * Returns a new instance of this Record type with all values set - * to their default values. - */ - clear(): this; + mergeWith( + merger: (oldVal: any, newVal: any, key: keyof TProps) => any, + ...collections: Array | Iterable<[string, any]>> + ): this; + mergeDeepWith( + merger: (oldVal: any, newVal: any, key: any) => any, + ...collections: Array | Iterable<[string, any]>> + ): this; - // Deep persistent changes + /** + * Returns a new instance of this Record type with the value for the + * specific key set to its default value. + * + * @alias remove + */ + delete(key: K): this; + remove(key: K): this; - setIn(keyPath: Iterable, value: any): this; - updateIn(keyPath: Iterable, updater: (value: any) => any): this; - mergeIn(keyPath: Iterable, ...collections: Array): this; - mergeDeepIn(keyPath: Iterable, ...collections: Array): this; + /** + * Returns a new instance of this Record type with all values set + * to their default values. + */ + clear(): this; - /** - * @alias removeIn - */ - deleteIn(keyPath: Iterable): this; - removeIn(keyPath: Iterable): this; + // Deep persistent changes - // Conversion to JavaScript types + setIn(keyPath: Iterable, value: any): this; + updateIn(keyPath: Iterable, updater: (value: any) => any): this; + mergeIn(keyPath: Iterable, ...collections: Array): this; + mergeDeepIn(keyPath: Iterable, ...collections: Array): this; - /** - * Deeply converts this Record to equivalent native JavaScript Object. - */ - toJS(): { [K in keyof T]: any }; + /** + * @alias removeIn + */ + deleteIn(keyPath: Iterable): this; + removeIn(keyPath: Iterable): this; - /** - * Shallowly converts this Record to equivalent native JavaScript Object. - */ - toJSON(): T; + // Conversion to JavaScript types - /** - * Shallowly converts this Record to equivalent JavaScript Object. - */ - toObject(): T; + /** + * Deeply converts this Record to equivalent native JavaScript Object. + */ + toJS(): { [K in keyof TProps]: any }; - // Transient changes + /** + * Shallowly converts this Record to equivalent native JavaScript Object. + */ + toJSON(): TProps; - /** - * Note: Not all methods can be used on a mutable collection or within - * `withMutations`! Only `set` may be used mutatively. - * - * @see `Map#withMutations` - */ - withMutations(mutator: (mutable: this) => any): this; + /** + * Shallowly converts this Record to equivalent JavaScript Object. + */ + toObject(): TProps; - /** - * @see `Map#asMutable` - */ - asMutable(): this; + // Transient changes - /** - * @see `Map#wasAltered` - */ - wasAltered(): boolean; + /** + * Note: Not all methods can be used on a mutable collection or within + * `withMutations`! Only `set` may be used mutatively. + * + * @see `Map#withMutations` + */ + withMutations(mutator: (mutable: this) => any): this; - /** - * @see `Map#asImmutable` - */ - asImmutable(): this; + /** + * @see `Map#asMutable` + */ + asMutable(): this; - // Sequence algorithms + /** + * @see `Map#wasAltered` + */ + wasAltered(): boolean; - toSeq(): Seq.Keyed; + /** + * @see `Map#asImmutable` + */ + asImmutable(): this; - [Symbol.iterator](): IterableIterator<[keyof T, T[keyof T]]>; - } - } + // Sequence algorithms - export function Record(defaultValues: T, name?: string): Record.Class; + toSeq(): Seq.Keyed; + [Symbol.iterator](): IterableIterator<[keyof TProps, TProps[keyof TProps]]>; + } /** * Represents a sequence of values, but may not be backed by a concrete data diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index 2b9ccae113..e369cf5524 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -2343,9 +2343,11 @@ declare module Immutable { /** - * Creates a new Class which produces Record instances. A record is similar to - * a JS object, but enforces a specific set of allowed string keys, and has - * default values. + * A record is similar to a JS object, but enforces a specific set of allowed + * string keys, and has default values. + * + * The `Record()` function produces new Record Factories, which when called + * create Record instances. * * ```js * const { Record } = require('immutable@4.0.0-rc.4') @@ -2405,10 +2407,10 @@ declare module Immutable { * **Flow Typing Records:** * * Immutable.js exports two Flow types designed to make it easier to use - * Records with flow typed code, `RecordOf` and `RecordFactory`. + * Records with flow typed code, `RecordOf` and `RecordFactory`. * * When defining a new kind of Record factory function, use a flow type that - * describes the values the record contains along with `RecordFactory`. + * describes the values the record contains along with `RecordFactory`. * To type instances of the Record (which the factory function returns), * use `RecordOf`. * @@ -2418,13 +2420,13 @@ declare module Immutable { * ```js * import type { RecordFactory, RecordOf } from 'immutable'; * - * // Use RecordFactory for defining new Record factory functions. - * type Point3DFields = { x: number, y: number, z: number }; - * const makePoint3D: RecordFactory = Record({ x: 0, y: 0, z: 0 }); + * // Use RecordFactory for defining new Record factory functions. + * type Point3DProps = { x: number, y: number, z: number }; + * const makePoint3D: RecordFactory = Record({ x: 0, y: 0, z: 0 }); * export makePoint3D; * * // Use RecordOf for defining new instances of that Record. - * export type Point3D = RecordOf; + * export type Point3D = RecordOf; * const some3DPoint: Point3D = makePoint3D({ x: 10, y: 20, z: 30 }); * ``` */ @@ -2433,7 +2435,7 @@ declare module Immutable { /** * True if `maybeRecord` is an instance of a Record. */ - export function isRecord(maybeRecord: any): maybeRecord is Record.Instance; + export function isRecord(maybeRecord: any): maybeRecord is Record; /** * Records allow passing a second parameter to supply a descriptive name @@ -2452,126 +2454,183 @@ declare module Immutable { * Record.getDescriptiveName(me) // "Person" * ``` */ - export function getDescriptiveName(record: Instance): string; + export function getDescriptiveName(record: Record): string; + + /** + * A Record.Factory is created by the `Record()` function. Record instances + * are created by passing it some of the accepted values for that Record + * type: + * + * + * ```js + * // makePerson is a Record Factory function + * const makePerson = Record({ name: null, favoriteColor: 'unknown' }); + * + * // alan is a Record instance + * const alan = makePerson({ name: 'Alan' }); + * ``` + * + * Note that Record Factories return `Record & Readonly`, + * this allows use of both the Record instance API, and direct property + * access on the resulting instances: + * + * + * ```js + * // Use the Record API + * console.log('Record API: ' + alan.get('name')) + * + * // Or direct property access (Readonly) + * console.log('property access: ' + alan.name) + * ``` + * + * **Flow Typing Records:** + * + * Use the `RecordFactory` Flow type to get high quality type checking of + * Records: + * + * ```js + * import type { RecordFactory, RecordOf } from 'immutable'; + * + * // Use RecordFactory for defining new Record factory functions. + * type PersonProps = { name: ?string, favoriteColor: string }; + * const makePerson: RecordFactory = Record({ name: null, favoriteColor: 'unknown' }); + * + * // Use RecordOf for defining new instances of that Record. + * type Person = RecordOf; + * const alan: Person = makePerson({ name: 'Alan' }); + * ``` + */ + export module Factory {} - export interface Class { - (values?: Partial | Iterable<[string, any]>): Instance & Readonly; - new (values?: Partial | Iterable<[string, any]>): Instance & Readonly; + export interface Factory { + (values?: Partial | Iterable<[string, any]>): Record & Readonly; + new (values?: Partial | Iterable<[string, any]>): Record & Readonly; } - export interface Instance { + export function Factory(values?: Partial | Iterable<[string, any]>): Record & Readonly; + } - // Reading values + /** + * Unlike other types in Immutable.js, the `Record()` function creates a new + * Record Factory, which is a function that creates Record instances. + * + * See above for examples of using `Record()`. + */ + export function Record(defaultValues: TProps, name?: string): Record.Factory; - has(key: string): key is keyof T; - get(key: K): T[K]; + export interface Record { - // Reading deep values + // Reading values - hasIn(keyPath: Iterable): boolean; - getIn(keyPath: Iterable): any; + has(key: string): key is keyof TProps; + get(key: K): TProps[K]; - // Value equality + // Reading deep values - equals(other: any): boolean; - hashCode(): number; + hasIn(keyPath: Iterable): boolean; + getIn(keyPath: Iterable): any; - // Persistent changes + // Value equality - set(key: K, value: T[K]): this; - update(key: K, updater: (value: T[K]) => T[K]): this; - merge(...collections: Array | Iterable<[string, any]>>): this; - mergeDeep(...collections: Array | Iterable<[string, any]>>): this; + equals(other: any): boolean; + hashCode(): number; - mergeWith( - merger: (oldVal: any, newVal: any, key: keyof T) => any, - ...collections: Array | Iterable<[string, any]>> - ): this; - mergeDeepWith( - merger: (oldVal: any, newVal: any, key: any) => any, - ...collections: Array | Iterable<[string, any]>> - ): this; + // Persistent changes - /** - * Returns a new instance of this Record type with the value for the - * specific key set to its default value. - * - * @alias remove - */ - delete(key: K): this; - remove(key: K): this; + set(key: K, value: TProps[K]): this; + update(key: K, updater: (value: TProps[K]) => TProps[K]): this; + merge(...collections: Array | Iterable<[string, any]>>): this; + mergeDeep(...collections: Array | Iterable<[string, any]>>): this; - /** - * Returns a new instance of this Record type with all values set - * to their default values. - */ - clear(): this; + mergeWith( + merger: (oldVal: any, newVal: any, key: keyof TProps) => any, + ...collections: Array | Iterable<[string, any]>> + ): this; + mergeDeepWith( + merger: (oldVal: any, newVal: any, key: any) => any, + ...collections: Array | Iterable<[string, any]>> + ): this; - // Deep persistent changes + /** + * Returns a new instance of this Record type with the value for the + * specific key set to its default value. + * + * @alias remove + */ + delete(key: K): this; + remove(key: K): this; - setIn(keyPath: Iterable, value: any): this; - updateIn(keyPath: Iterable, updater: (value: any) => any): this; - mergeIn(keyPath: Iterable, ...collections: Array): this; - mergeDeepIn(keyPath: Iterable, ...collections: Array): this; + /** + * Returns a new instance of this Record type with all values set + * to their default values. + */ + clear(): this; - /** - * @alias removeIn - */ - deleteIn(keyPath: Iterable): this; - removeIn(keyPath: Iterable): this; + // Deep persistent changes - // Conversion to JavaScript types + setIn(keyPath: Iterable, value: any): this; + updateIn(keyPath: Iterable, updater: (value: any) => any): this; + mergeIn(keyPath: Iterable, ...collections: Array): this; + mergeDeepIn(keyPath: Iterable, ...collections: Array): this; - /** - * Deeply converts this Record to equivalent native JavaScript Object. - */ - toJS(): { [K in keyof T]: any }; + /** + * @alias removeIn + */ + deleteIn(keyPath: Iterable): this; + removeIn(keyPath: Iterable): this; - /** - * Shallowly converts this Record to equivalent native JavaScript Object. - */ - toJSON(): T; + // Conversion to JavaScript types - /** - * Shallowly converts this Record to equivalent JavaScript Object. - */ - toObject(): T; + /** + * Deeply converts this Record to equivalent native JavaScript Object. + */ + toJS(): { [K in keyof TProps]: any }; - // Transient changes + /** + * Shallowly converts this Record to equivalent native JavaScript Object. + */ + toJSON(): TProps; - /** - * Note: Not all methods can be used on a mutable collection or within - * `withMutations`! Only `set` may be used mutatively. - * - * @see `Map#withMutations` - */ - withMutations(mutator: (mutable: this) => any): this; + /** + * Shallowly converts this Record to equivalent JavaScript Object. + */ + toObject(): TProps; - /** - * @see `Map#asMutable` - */ - asMutable(): this; + // Transient changes - /** - * @see `Map#wasAltered` - */ - wasAltered(): boolean; + /** + * Note: Not all methods can be used on a mutable collection or within + * `withMutations`! Only `set` may be used mutatively. + * + * @see `Map#withMutations` + */ + withMutations(mutator: (mutable: this) => any): this; - /** - * @see `Map#asImmutable` - */ - asImmutable(): this; + /** + * @see `Map#asMutable` + */ + asMutable(): this; - // Sequence algorithms + /** + * @see `Map#wasAltered` + */ + wasAltered(): boolean; - toSeq(): Seq.Keyed; + /** + * @see `Map#asImmutable` + */ + asImmutable(): this; - [Symbol.iterator](): IterableIterator<[keyof T, T[keyof T]]>; - } - } + // Sequence algorithms - export function Record(defaultValues: T, name?: string): Record.Class; + toSeq(): Seq.Keyed; + [Symbol.iterator](): IterableIterator<[keyof TProps, TProps[keyof TProps]]>; + } /** * Represents a sequence of values, but may not be backed by a concrete data From 103918ae4411731fb10b61303f2743cbe9eaf0fc Mon Sep 17 00:00:00 2001 From: Travis CI Date: Thu, 5 Oct 2017 06:41:09 +0000 Subject: [PATCH 045/242] Deploy aa672d39ad6c509859faa5b5ac611886a9b4deb0 to NPM branch --- bower.json | 2 +- dist/immutable-nonambient.d.ts | 154 ++++++++++++++++----------------- dist/immutable.d.ts | 154 ++++++++++++++++----------------- dist/immutable.es.js | 2 +- dist/immutable.js | 2 +- dist/immutable.min.js | 2 +- package.json | 2 +- 7 files changed, 159 insertions(+), 159 deletions(-) diff --git a/bower.json b/bower.json index d6ecb96303..59787af6b0 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "immutable", - "version": "4.0.0-rc.4", + "version": "4.0.0-rc.5", "description": "Immutable Data Collections", "license": "MIT", "homepage": "https://facebook.github.com/immutable-js", diff --git a/dist/immutable-nonambient.d.ts b/dist/immutable-nonambient.d.ts index 61aa4cc2ff..3bd962b14d 100644 --- a/dist/immutable-nonambient.d.ts +++ b/dist/immutable-nonambient.d.ts @@ -118,7 +118,7 @@ * * * ```js - * const { fromJS, isKeyed } = require('immutable@4.0.0-rc.4') + * const { fromJS, isKeyed } = require('immutable@4.0.0-rc.5') * function (key, value) { * return isKeyed(value) ? value.Map() : value.toList() * } @@ -132,7 +132,7 @@ * * * ```js - * const { fromJS, isKeyed } = require('immutable@4.0.0-rc.4') + * const { fromJS, isKeyed } = require('immutable@4.0.0-rc.5') * fromJS({ a: {b: [10, 20, 30]}, c: 40}, function (key, value, path) { * console.log(key, value, path) * return isKeyed(value) ? value.toOrderedMap() : value.toList() @@ -149,7 +149,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.4') + * const { Map } = require('immutable@4.0.0-rc.5') * let obj = { 1: "one" }; * Object.keys(obj); // [ "1" ] * assert.equal(obj["1"], obj[1]); // "one" === "one" @@ -185,7 +185,7 @@ * * * ```js - * const { Map, is } = require('immutable@4.0.0-rc.4') + * const { Map, is } = require('immutable@4.0.0-rc.5') * const map1 = Map({ a: 1, b: 1, c: 1 }) * const map2 = Map({ a: 1, b: 1, c: 1 }) * assert.equal(map1 !== map2, true) @@ -232,7 +232,7 @@ * * * ```js - * const { isImmutable, Map, List, Stack } = require('immutable@4.0.0-rc.4'); + * const { isImmutable, Map, List, Stack } = require('immutable@4.0.0-rc.5'); * isImmutable([]); // false * isImmutable({}); // false * isImmutable(Map()); // true @@ -248,7 +248,7 @@ * * * ```js - * const { isCollection, Map, List, Stack } = require('immutable@4.0.0-rc.4'); + * const { isCollection, Map, List, Stack } = require('immutable@4.0.0-rc.5'); * isCollection([]); // false * isCollection({}); // false * isCollection(Map()); // true @@ -263,7 +263,7 @@ * * * ```js - * const { isKeyed, Map, List, Stack } = require('immutable@4.0.0-rc.4'); + * const { isKeyed, Map, List, Stack } = require('immutable@4.0.0-rc.5'); * isKeyed([]); // false * isKeyed({}); // false * isKeyed(Map()); // true @@ -278,7 +278,7 @@ * * * ```js - * const { isIndexed, Map, List, Stack, Set } = require('immutable@4.0.0-rc.4'); + * const { isIndexed, Map, List, Stack, Set } = require('immutable@4.0.0-rc.5'); * isIndexed([]); // false * isIndexed({}); // false * isIndexed(Map()); // false @@ -294,7 +294,7 @@ * * * ```js - * const { isAssociative, Map, List, Stack, Set } = require('immutable@4.0.0-rc.4'); + * const { isAssociative, Map, List, Stack, Set } = require('immutable@4.0.0-rc.5'); * isAssociative([]); // false * isAssociative({}); // false * isAssociative(Map()); // true @@ -311,7 +311,7 @@ * * * ```js - * const { isOrdered, Map, OrderedMap, List, Set } = require('immutable@4.0.0-rc.4'); + * const { isOrdered, Map, OrderedMap, List, Set } = require('immutable@4.0.0-rc.5'); * isOrdered([]); // false * isOrdered({}); // false * isOrdered(Map()); // false @@ -353,7 +353,7 @@ * * * ```js - * const { List, Set } = require('immutable@4.0.0-rc.4'); + * const { List, Set } = require('immutable@4.0.0-rc.5'); * const a = List([ 1, 2, 3 ]); * const b = List([ 1, 2, 3 ]); * assert.notStrictEqual(a, b); // different instances @@ -399,7 +399,7 @@ * * * ```js - * const { List } = require('immutable@4.0.0-rc.4'); + * const { List } = require('immutable@4.0.0-rc.5'); * List.isList([]); // false * List.isList(List()); // true * ``` @@ -411,7 +411,7 @@ * * * ```js - * const { List } = require('immutable@4.0.0-rc.4'); + * const { List } = require('immutable@4.0.0-rc.5'); * List.of(1, 2, 3, 4) * // List [ 1, 2, 3, 4 ] * ``` @@ -420,7 +420,7 @@ * * * ```js - * const { List } = require('immutable@4.0.0-rc.4'); + * const { List } = require('immutable@4.0.0-rc.5'); * List.of({x:1}, 2, [3], 4) * // List [ { x: 1 }, 2, [ 3 ], 4 ] * ``` @@ -434,7 +434,7 @@ * * * ```js - * const { List, Set } = require('immutable@4.0.0-rc.4') + * const { List, Set } = require('immutable@4.0.0-rc.5') * * const emptyList = List() * // List [] @@ -927,7 +927,7 @@ * * * ```js - * const { Map, List } = require('immutable@4.0.0-rc.4'); + * const { Map, List } = require('immutable@4.0.0-rc.5'); * Map().set(List([ 1 ]), 'listofone').get(List([ 1 ])); * // 'listofone' * ``` @@ -945,7 +945,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.4') + * const { Map } = require('immutable@4.0.0-rc.5') * Map.isMap({}) // false * Map.isMap(Map()) // true * ``` @@ -957,7 +957,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.4') + * const { Map } = require('immutable@4.0.0-rc.5') * Map.of( * 'key', 'value', * 'numerical value', 3, @@ -979,7 +979,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.4') + * const { Map } = require('immutable@4.0.0-rc.5') * Map({ key: "value" }) * Map([ [ "key", "value" ] ]) * ``` @@ -1025,7 +1025,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.4') + * const { Map } = require('immutable@4.0.0-rc.5') * const originalMap = Map() * const newerMap = originalMap.set('key', 'value') * const newestMap = newerMap.set('key', 'newer value') @@ -1050,7 +1050,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.4') + * const { Map } = require('immutable@4.0.0-rc.5') * const originalMap = Map({ * key: 'value', * otherKey: 'other value' @@ -1072,7 +1072,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.4') + * const { Map } = require('immutable@4.0.0-rc.5') * const names = Map({ a: "Aaron", b: "Barry", c: "Connor" }) * names.deleteAll([ 'a', 'c' ]) * // Map { "b": "Barry" } @@ -1090,7 +1090,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.4') + * const { Map } = require('immutable@4.0.0-rc.5') * Map({ key: 'value' }).clear() * // Map {} * ``` @@ -1107,7 +1107,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.4') + * const { Map } = require('immutable@4.0.0-rc.5') * const aMap = Map({ key: 'value' }) * const newMap = aMap.update('key', value => value + value) * // Map { "key": "valuevalue" } @@ -1215,7 +1215,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.4') + * const { Map } = require('immutable@4.0.0-rc.5') * const one = Map({ a: 10, b: 20, c: 30 }) * const two = Map({ b: 40, a: 50, d: 60 }) * one.merge(two) // Map { "a": 50, "b": 40, "c": 30, "d": 60 } @@ -1233,7 +1233,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.4') + * const { Map } = require('immutable@4.0.0-rc.5') * const one = Map({ a: 10, b: 20, c: 30 }) * const two = Map({ b: 40, a: 50, d: 60 }) * one.mergeWith((oldVal, newVal) => oldVal / newVal, two) @@ -1259,7 +1259,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.4') + * const { Map } = require('immutable@4.0.0-rc.5') * const one = Map({ a: Map({ x: 10, y: 10 }), b: Map({ x: 20, y: 50 }) }) * const two = Map({ a: Map({ x: 2 }), b: Map({ y: 5 }), c: Map({ z: 3 }) }) * one.mergeDeep(two) @@ -1280,7 +1280,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.4') + * const { Map } = require('immutable@4.0.0-rc.5') * const one = Map({ a: Map({ x: 10, y: 10 }), b: Map({ x: 20, y: 50 }) }) * const two = Map({ a: Map({ x: 2 }), b: Map({ y: 5 }), c: Map({ z: 3 }) }) * one.mergeDeepWith((oldVal, newVal) => oldVal / newVal, two) @@ -1307,7 +1307,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.4') + * const { Map } = require('immutable@4.0.0-rc.5') * const originalMap = Map({ * subObject: Map({ * subKey: 'subvalue', @@ -1365,7 +1365,7 @@ * * * ```js - * const { Map, List } = require('immutable@4.0.0-rc.4') + * const { Map, List } = require('immutable@4.0.0-rc.5') * const map = Map({ inMap: Map({ inList: List([ 1, 2, 3 ]) }) }) * const newMap = map.updateIn(['inMap', 'inList'], list => list.push(4)) * // Map { "inMap": Map { "inList": List [ 1, 2, 3, 4 ] } } @@ -1377,7 +1377,7 @@ * provided, otherwise `undefined`. * * * ```js * const map = Map({ a: Map({ b: Map({ c: 10 }) }) }) @@ -1389,7 +1389,7 @@ * no change will occur. This is still true if `notSetValue` is provided. * * * ```js * const map = Map({ a: Map({ b: Map({ c: 10 }) }) }) @@ -1405,7 +1405,7 @@ * The previous example behaves differently when written with default values: * * * ```js * const map = Map({ a: Map({ b: Map({ c: 10 }) }) }) @@ -1464,7 +1464,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.4') + * const { Map } = require('immutable@4.0.0-rc.5') * const map1 = Map() * const map2 = map1.withMutations(map => { * map.set('a', 1).set('b', 2).set('c', 3) @@ -1735,7 +1735,7 @@ * a collection of other sets. * * ```js - * const { Set } = require('immutable@4.0.0-rc.4') + * const { Set } = require('immutable@4.0.0-rc.5') * const intersected = Set.intersect([ * Set([ 'a', 'b', 'c' ]) * Set([ 'c', 'a', 't' ]) @@ -1750,7 +1750,7 @@ * collection of other sets. * * ```js - * const { Set } = require('immutable@4.0.0-rc.4') + * const { Set } = require('immutable@4.0.0-rc.5') * const unioned = Set.union([ * Set([ 'a', 'b', 'c' ]) * Set([ 'c', 'a', 't' ]) @@ -2317,7 +2317,7 @@ * infinity. When `start` is equal to `end`, returns empty range. * * ```js - * const { Range } = require('immutable@4.0.0-rc.4') + * const { Range } = require('immutable@4.0.0-rc.5') * Range() // [ 0, 1, 2, 3, ... ] * Range(10) // [ 10, 11, 12, 13, ... ] * Range(10, 15) // [ 10, 11, 12, 13, 14 ] @@ -2334,7 +2334,7 @@ * not defined, returns an infinite `Seq` of `value`. * * ```js - * const { Repeat } = require('immutable@4.0.0-rc.4') + * const { Repeat } = require('immutable@4.0.0-rc.5') * Repeat('foo') // [ 'foo', 'foo', 'foo', ... ] * Repeat('bar', 4) // [ 'bar', 'bar', 'bar', 'bar' ] * ``` @@ -2350,7 +2350,7 @@ * create Record instances. * * ```js - * const { Record } = require('immutable@4.0.0-rc.4') + * const { Record } = require('immutable@4.0.0-rc.5') * const ABRecord = Record({ a: 1, b: 2 }) * const myRecord = new ABRecord({ b: 3 }) * ``` @@ -2444,7 +2444,7 @@ * method. If one was not provided, the string "Record" is returned. * * ```js - * const { Record } = require('immutable@4.0.0-rc.4') + * const { Record } = require('immutable@4.0.0-rc.5') * const Person = Record({ * name: null * }, 'Person') @@ -2462,7 +2462,7 @@ * type: * * * ```js * // makePerson is a Record Factory function @@ -2477,7 +2477,7 @@ * access on the resulting instances: * * * ```js * // Use the Record API @@ -2649,7 +2649,7 @@ * Seq's values are never iterated: * * ```js - * const { Seq } = require('immutable@4.0.0-rc.4') + * const { Seq } = require('immutable@4.0.0-rc.5') * const oddSquares = Seq([ 1, 2, 3, 4, 5, 6, 7, 8 ]) * .filter(x => x % 2 !== 0) * .map(x => x * x) @@ -2677,7 +2677,7 @@ * As well as expressing logic that would otherwise be memory or time limited: * * ```js - * const { Range } = require('immutable@4.0.0-rc.4') + * const { Range } = require('immutable@4.0.0-rc.5') * Range(1, Infinity) * .skip(1000) * .map(n => -n) @@ -2756,7 +2756,7 @@ * `mapper` function. * * ```js - * const { Seq } = require('immutable@4.0.0-rc.4') + * const { Seq } = require('immutable@4.0.0-rc.5') * Seq.Keyed({ a: 1, b: 2 }).map(x => 10 * x) * // Seq { "a": 10, "b": 20 } * ``` @@ -2868,7 +2868,7 @@ * `mapper` function. * * ```js - * const { Seq } = require('immutable@4.0.0-rc.4') + * const { Seq } = require('immutable@4.0.0-rc.5') * Seq.Indexed([ 1, 2 ]).map(x => 10 * x) * // Seq [ 10, 20 ] * ``` @@ -3128,7 +3128,7 @@ * `mapper` function. * * ```js - * const { Seq } = require('immutable@4.0.0-rc.4') + * const { Seq } = require('immutable@4.0.0-rc.5') * Seq([ 1, 2 ]).map(x => 10 * x) * // Seq [ 10, 20 ] * ``` @@ -3146,7 +3146,7 @@ * `mapper` function. * * ```js - * const { Seq } = require('immutable@4.0.0-rc.4') + * const { Seq } = require('immutable@4.0.0-rc.5') * Seq([ 1, 2 ]).map(x => 10 * x) * // Seq [ 10, 20 ] * ``` @@ -3215,22 +3215,22 @@ export module Collection { /** - * @deprecated use `const { isKeyed } = require('immutable@4.0.0-rc.4')` + * @deprecated use `const { isKeyed } = require('immutable@4.0.0-rc.5')` */ function isKeyed(maybeKeyed: any): maybeKeyed is Collection.Keyed; /** - * @deprecated use `const { isIndexed } = require('immutable@4.0.0-rc.4')` + * @deprecated use `const { isIndexed } = require('immutable@4.0.0-rc.5')` */ function isIndexed(maybeIndexed: any): maybeIndexed is Collection.Indexed; /** - * @deprecated use `const { isAssociative } = require('immutable@4.0.0-rc.4')` + * @deprecated use `const { isAssociative } = require('immutable@4.0.0-rc.5')` */ function isAssociative(maybeAssociative: any): maybeAssociative is Collection.Keyed | Collection.Indexed; /** - * @deprecated use `const { isOrdered } = require('immutable@4.0.0-rc.4')` + * @deprecated use `const { isOrdered } = require('immutable@4.0.0-rc.5')` */ function isOrdered(maybeOrdered: any): boolean; @@ -3288,7 +3288,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.4') + * const { Map } = require('immutable@4.0.0-rc.5') * Map({ a: 'z', b: 'y' }).flip() * // Map { "z": "a", "y": "b" } * ``` @@ -3306,7 +3306,7 @@ * `mapper` function. * * ```js - * const { Collection } = require('immutable@4.0.0-rc.4') + * const { Collection } = require('immutable@4.0.0-rc.5') * Collection.Keyed({ a: 1, b: 2 }).map(x => 10 * x) * // Seq { "a": 10, "b": 20 } * ``` @@ -3325,7 +3325,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.4') + * const { Map } = require('immutable@4.0.0-rc.5') * Map({ a: 1, b: 2 }).mapKeys(x => x.toUpperCase()) * // Map { "A": 1, "B": 2 } * ``` @@ -3344,7 +3344,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.4') + * const { Map } = require('immutable@4.0.0-rc.5') * Map({ a: 1, b: 2 }) * .mapEntries(([ k, v ]) => [ k.toUpperCase(), v * 2 ]) * // Map { "A": 2, "B": 4 } @@ -3470,10 +3470,10 @@ * second from each, etc. * * * ```js - * const { List } = require('immutable@4.0.0-rc.4') + * const { List } = require('immutable@4.0.0-rc.5') * List([ 1, 2, 3 ]).interleave(List([ 'A', 'B', 'C' ])) * // List [ 1, "A", 2, "B", 3, "C"" ] * ``` @@ -3481,7 +3481,7 @@ * The shortest Collection stops interleave. * * * ```js * List([ 1, 2, 3 ]).interleave( @@ -3503,7 +3503,7 @@ * * * ```js - * const { List } = require('immutable@4.0.0-rc.4') + * const { List } = require('immutable@4.0.0-rc.5') * List([ 'a', 'b', 'c', 'd' ]).splice(1, 2, 'q', 'r', 's') * // List [ "a", "q", "r", "s", "d" ] * ``` @@ -3522,7 +3522,7 @@ * * * * ```js * const a = List([ 1, 2, 3 ]); @@ -3555,7 +3555,7 @@ * collections by using a custom `zipper` function. * * * ```js * const a = List([ 1, 2, 3 ]); @@ -3623,7 +3623,7 @@ * `mapper` function. * * ```js - * const { Collection } = require('immutable@4.0.0-rc.4') + * const { Collection } = require('immutable@4.0.0-rc.5') * Collection.Indexed([1,2]).map(x => 10 * x) * // Seq [ 1, 2 ] * ``` @@ -3675,7 +3675,7 @@ * the value as both the first and second arguments to the provided function. * * ```js - * const { Collection } = require('immutable@4.0.0-rc.4') + * const { Collection } = require('immutable@4.0.0-rc.5') * const seq = Collection.Set([ 'A', 'B', 'C' ]) * // Seq { "A", "B", "C" } * seq.forEach((v, k) => @@ -3807,7 +3807,7 @@ * lookup via a different instance. * * * ```js * const a = List([ 1, 2, 3 ]); @@ -3888,7 +3888,7 @@ * * * ```js - * const { Seq } = require('immutable@4.0.0-rc.4') + * const { Seq } = require('immutable@4.0.0-rc.5') * * function sum(collection) { * return collection.reduce((sum, x) => sum + x, 0) @@ -3984,7 +3984,7 @@ * * * ```js - * const { Map, List } = require('immutable@4.0.0-rc.4') + * const { Map, List } = require('immutable@4.0.0-rc.5') * var myMap = Map({ a: 'Apple', b: 'Banana' }) * List(myMap) // List [ [ "a", "Apple" ], [ "b", "Banana" ] ] * myMap.toList() // List [ "Apple", "Banana" ] @@ -4021,7 +4021,7 @@ * * * ```js - * const { Seq } = require('immutable@4.0.0-rc.4') + * const { Seq } = require('immutable@4.0.0-rc.5') * const indexedSeq = Seq([ 'A', 'B', 'C' ]) * // Seq [ "A", "B", "C" ] * indexedSeq.filter(v => v === 'B') @@ -4102,7 +4102,7 @@ * * * ```js - * const { Collection } = require('immutable@4.0.0-rc.4') + * const { Collection } = require('immutable@4.0.0-rc.5') * Collection({ a: 1, b: 2 }).map(x => 10 * x) * // Seq { "a": 10, "b": 20 } * ``` @@ -4129,7 +4129,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.4') + * const { Map } = require('immutable@4.0.0-rc.5') * Map({ a: 1, b: 2, c: 3, d: 4}).filter(x => x % 2 === 0) * // Map { "b": 2, "d": 4 } * ``` @@ -4152,7 +4152,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.4') + * const { Map } = require('immutable@4.0.0-rc.5') * Map({ a: 1, b: 2, c: 3, d: 4}).filterNot(x => x % 2 === 0) * // Map { "a": 1, "c": 3 } * ``` @@ -4189,7 +4189,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.4') + * const { Map } = require('immutable@4.0.0-rc.5') * Map({ "c": 3, "a": 1, "b": 2 }).sort((a, b) => { * if (a < b) { return -1; } * if (a > b) { return 1; } @@ -4229,7 +4229,7 @@ * * * ```js - * const { List, Map } = require('immutable@4.0.0-rc.4') + * const { List, Map } = require('immutable@4.0.0-rc.5') * const listOfMaps = List([ * Map({ v: 0 }), * Map({ v: 1 }), @@ -4316,7 +4316,7 @@ * * * ```js - * const { List } = require('immutable@4.0.0-rc.4') + * const { List } = require('immutable@4.0.0-rc.5') * List([ 'dog', 'frog', 'cat', 'hat', 'god' ]) * .skipWhile(x => x.match(/g/)) * // List [ "cat", "hat", "god"" ] @@ -4333,7 +4333,7 @@ * * * ```js - * const { List } = require('immutable@4.0.0-rc.4') + * const { List } = require('immutable@4.0.0-rc.5') * List([ 'dog', 'frog', 'cat', 'hat', 'god' ]) * .skipUntil(x => x.match(/hat/)) * // List [ "hat", "god"" ] @@ -4362,7 +4362,7 @@ * * * ```js - * const { List } = require('immutable@4.0.0-rc.4') + * const { List } = require('immutable@4.0.0-rc.5') * List([ 'dog', 'frog', 'cat', 'hat', 'god' ]) * .takeWhile(x => x.match(/o/)) * // List [ "dog", "frog" ] @@ -4379,7 +4379,7 @@ * * * ```js - * const { List } = require('immutable@4.0.0-rc.4') + * const { List } = require('immutable@4.0.0-rc.5') * List([ 'dog', 'frog', 'cat', 'hat', 'god' ]) * .takeUntil(x => x.match(/at/)) * // List [ "dog", "frog" ] diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index e369cf5524..d196949211 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -118,7 +118,7 @@ declare module Immutable { * * * ```js - * const { fromJS, isKeyed } = require('immutable@4.0.0-rc.4') + * const { fromJS, isKeyed } = require('immutable@4.0.0-rc.5') * function (key, value) { * return isKeyed(value) ? value.Map() : value.toList() * } @@ -132,7 +132,7 @@ declare module Immutable { * * * ```js - * const { fromJS, isKeyed } = require('immutable@4.0.0-rc.4') + * const { fromJS, isKeyed } = require('immutable@4.0.0-rc.5') * fromJS({ a: {b: [10, 20, 30]}, c: 40}, function (key, value, path) { * console.log(key, value, path) * return isKeyed(value) ? value.toOrderedMap() : value.toList() @@ -149,7 +149,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.4') + * const { Map } = require('immutable@4.0.0-rc.5') * let obj = { 1: "one" }; * Object.keys(obj); // [ "1" ] * assert.equal(obj["1"], obj[1]); // "one" === "one" @@ -185,7 +185,7 @@ declare module Immutable { * * * ```js - * const { Map, is } = require('immutable@4.0.0-rc.4') + * const { Map, is } = require('immutable@4.0.0-rc.5') * const map1 = Map({ a: 1, b: 1, c: 1 }) * const map2 = Map({ a: 1, b: 1, c: 1 }) * assert.equal(map1 !== map2, true) @@ -232,7 +232,7 @@ declare module Immutable { * * * ```js - * const { isImmutable, Map, List, Stack } = require('immutable@4.0.0-rc.4'); + * const { isImmutable, Map, List, Stack } = require('immutable@4.0.0-rc.5'); * isImmutable([]); // false * isImmutable({}); // false * isImmutable(Map()); // true @@ -248,7 +248,7 @@ declare module Immutable { * * * ```js - * const { isCollection, Map, List, Stack } = require('immutable@4.0.0-rc.4'); + * const { isCollection, Map, List, Stack } = require('immutable@4.0.0-rc.5'); * isCollection([]); // false * isCollection({}); // false * isCollection(Map()); // true @@ -263,7 +263,7 @@ declare module Immutable { * * * ```js - * const { isKeyed, Map, List, Stack } = require('immutable@4.0.0-rc.4'); + * const { isKeyed, Map, List, Stack } = require('immutable@4.0.0-rc.5'); * isKeyed([]); // false * isKeyed({}); // false * isKeyed(Map()); // true @@ -278,7 +278,7 @@ declare module Immutable { * * * ```js - * const { isIndexed, Map, List, Stack, Set } = require('immutable@4.0.0-rc.4'); + * const { isIndexed, Map, List, Stack, Set } = require('immutable@4.0.0-rc.5'); * isIndexed([]); // false * isIndexed({}); // false * isIndexed(Map()); // false @@ -294,7 +294,7 @@ declare module Immutable { * * * ```js - * const { isAssociative, Map, List, Stack, Set } = require('immutable@4.0.0-rc.4'); + * const { isAssociative, Map, List, Stack, Set } = require('immutable@4.0.0-rc.5'); * isAssociative([]); // false * isAssociative({}); // false * isAssociative(Map()); // true @@ -311,7 +311,7 @@ declare module Immutable { * * * ```js - * const { isOrdered, Map, OrderedMap, List, Set } = require('immutable@4.0.0-rc.4'); + * const { isOrdered, Map, OrderedMap, List, Set } = require('immutable@4.0.0-rc.5'); * isOrdered([]); // false * isOrdered({}); // false * isOrdered(Map()); // false @@ -353,7 +353,7 @@ declare module Immutable { * * * ```js - * const { List, Set } = require('immutable@4.0.0-rc.4'); + * const { List, Set } = require('immutable@4.0.0-rc.5'); * const a = List([ 1, 2, 3 ]); * const b = List([ 1, 2, 3 ]); * assert.notStrictEqual(a, b); // different instances @@ -399,7 +399,7 @@ declare module Immutable { * * * ```js - * const { List } = require('immutable@4.0.0-rc.4'); + * const { List } = require('immutable@4.0.0-rc.5'); * List.isList([]); // false * List.isList(List()); // true * ``` @@ -411,7 +411,7 @@ declare module Immutable { * * * ```js - * const { List } = require('immutable@4.0.0-rc.4'); + * const { List } = require('immutable@4.0.0-rc.5'); * List.of(1, 2, 3, 4) * // List [ 1, 2, 3, 4 ] * ``` @@ -420,7 +420,7 @@ declare module Immutable { * * * ```js - * const { List } = require('immutable@4.0.0-rc.4'); + * const { List } = require('immutable@4.0.0-rc.5'); * List.of({x:1}, 2, [3], 4) * // List [ { x: 1 }, 2, [ 3 ], 4 ] * ``` @@ -434,7 +434,7 @@ declare module Immutable { * * * ```js - * const { List, Set } = require('immutable@4.0.0-rc.4') + * const { List, Set } = require('immutable@4.0.0-rc.5') * * const emptyList = List() * // List [] @@ -927,7 +927,7 @@ declare module Immutable { * * * ```js - * const { Map, List } = require('immutable@4.0.0-rc.4'); + * const { Map, List } = require('immutable@4.0.0-rc.5'); * Map().set(List([ 1 ]), 'listofone').get(List([ 1 ])); * // 'listofone' * ``` @@ -945,7 +945,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.4') + * const { Map } = require('immutable@4.0.0-rc.5') * Map.isMap({}) // false * Map.isMap(Map()) // true * ``` @@ -957,7 +957,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.4') + * const { Map } = require('immutable@4.0.0-rc.5') * Map.of( * 'key', 'value', * 'numerical value', 3, @@ -979,7 +979,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.4') + * const { Map } = require('immutable@4.0.0-rc.5') * Map({ key: "value" }) * Map([ [ "key", "value" ] ]) * ``` @@ -1025,7 +1025,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.4') + * const { Map } = require('immutable@4.0.0-rc.5') * const originalMap = Map() * const newerMap = originalMap.set('key', 'value') * const newestMap = newerMap.set('key', 'newer value') @@ -1050,7 +1050,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.4') + * const { Map } = require('immutable@4.0.0-rc.5') * const originalMap = Map({ * key: 'value', * otherKey: 'other value' @@ -1072,7 +1072,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.4') + * const { Map } = require('immutable@4.0.0-rc.5') * const names = Map({ a: "Aaron", b: "Barry", c: "Connor" }) * names.deleteAll([ 'a', 'c' ]) * // Map { "b": "Barry" } @@ -1090,7 +1090,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.4') + * const { Map } = require('immutable@4.0.0-rc.5') * Map({ key: 'value' }).clear() * // Map {} * ``` @@ -1107,7 +1107,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.4') + * const { Map } = require('immutable@4.0.0-rc.5') * const aMap = Map({ key: 'value' }) * const newMap = aMap.update('key', value => value + value) * // Map { "key": "valuevalue" } @@ -1215,7 +1215,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.4') + * const { Map } = require('immutable@4.0.0-rc.5') * const one = Map({ a: 10, b: 20, c: 30 }) * const two = Map({ b: 40, a: 50, d: 60 }) * one.merge(two) // Map { "a": 50, "b": 40, "c": 30, "d": 60 } @@ -1233,7 +1233,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.4') + * const { Map } = require('immutable@4.0.0-rc.5') * const one = Map({ a: 10, b: 20, c: 30 }) * const two = Map({ b: 40, a: 50, d: 60 }) * one.mergeWith((oldVal, newVal) => oldVal / newVal, two) @@ -1259,7 +1259,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.4') + * const { Map } = require('immutable@4.0.0-rc.5') * const one = Map({ a: Map({ x: 10, y: 10 }), b: Map({ x: 20, y: 50 }) }) * const two = Map({ a: Map({ x: 2 }), b: Map({ y: 5 }), c: Map({ z: 3 }) }) * one.mergeDeep(two) @@ -1280,7 +1280,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.4') + * const { Map } = require('immutable@4.0.0-rc.5') * const one = Map({ a: Map({ x: 10, y: 10 }), b: Map({ x: 20, y: 50 }) }) * const two = Map({ a: Map({ x: 2 }), b: Map({ y: 5 }), c: Map({ z: 3 }) }) * one.mergeDeepWith((oldVal, newVal) => oldVal / newVal, two) @@ -1307,7 +1307,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.4') + * const { Map } = require('immutable@4.0.0-rc.5') * const originalMap = Map({ * subObject: Map({ * subKey: 'subvalue', @@ -1365,7 +1365,7 @@ declare module Immutable { * * * ```js - * const { Map, List } = require('immutable@4.0.0-rc.4') + * const { Map, List } = require('immutable@4.0.0-rc.5') * const map = Map({ inMap: Map({ inList: List([ 1, 2, 3 ]) }) }) * const newMap = map.updateIn(['inMap', 'inList'], list => list.push(4)) * // Map { "inMap": Map { "inList": List [ 1, 2, 3, 4 ] } } @@ -1377,7 +1377,7 @@ declare module Immutable { * provided, otherwise `undefined`. * * * ```js * const map = Map({ a: Map({ b: Map({ c: 10 }) }) }) @@ -1389,7 +1389,7 @@ declare module Immutable { * no change will occur. This is still true if `notSetValue` is provided. * * * ```js * const map = Map({ a: Map({ b: Map({ c: 10 }) }) }) @@ -1405,7 +1405,7 @@ declare module Immutable { * The previous example behaves differently when written with default values: * * * ```js * const map = Map({ a: Map({ b: Map({ c: 10 }) }) }) @@ -1464,7 +1464,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.4') + * const { Map } = require('immutable@4.0.0-rc.5') * const map1 = Map() * const map2 = map1.withMutations(map => { * map.set('a', 1).set('b', 2).set('c', 3) @@ -1735,7 +1735,7 @@ declare module Immutable { * a collection of other sets. * * ```js - * const { Set } = require('immutable@4.0.0-rc.4') + * const { Set } = require('immutable@4.0.0-rc.5') * const intersected = Set.intersect([ * Set([ 'a', 'b', 'c' ]) * Set([ 'c', 'a', 't' ]) @@ -1750,7 +1750,7 @@ declare module Immutable { * collection of other sets. * * ```js - * const { Set } = require('immutable@4.0.0-rc.4') + * const { Set } = require('immutable@4.0.0-rc.5') * const unioned = Set.union([ * Set([ 'a', 'b', 'c' ]) * Set([ 'c', 'a', 't' ]) @@ -2317,7 +2317,7 @@ declare module Immutable { * infinity. When `start` is equal to `end`, returns empty range. * * ```js - * const { Range } = require('immutable@4.0.0-rc.4') + * const { Range } = require('immutable@4.0.0-rc.5') * Range() // [ 0, 1, 2, 3, ... ] * Range(10) // [ 10, 11, 12, 13, ... ] * Range(10, 15) // [ 10, 11, 12, 13, 14 ] @@ -2334,7 +2334,7 @@ declare module Immutable { * not defined, returns an infinite `Seq` of `value`. * * ```js - * const { Repeat } = require('immutable@4.0.0-rc.4') + * const { Repeat } = require('immutable@4.0.0-rc.5') * Repeat('foo') // [ 'foo', 'foo', 'foo', ... ] * Repeat('bar', 4) // [ 'bar', 'bar', 'bar', 'bar' ] * ``` @@ -2350,7 +2350,7 @@ declare module Immutable { * create Record instances. * * ```js - * const { Record } = require('immutable@4.0.0-rc.4') + * const { Record } = require('immutable@4.0.0-rc.5') * const ABRecord = Record({ a: 1, b: 2 }) * const myRecord = new ABRecord({ b: 3 }) * ``` @@ -2444,7 +2444,7 @@ declare module Immutable { * method. If one was not provided, the string "Record" is returned. * * ```js - * const { Record } = require('immutable@4.0.0-rc.4') + * const { Record } = require('immutable@4.0.0-rc.5') * const Person = Record({ * name: null * }, 'Person') @@ -2462,7 +2462,7 @@ declare module Immutable { * type: * * * ```js * // makePerson is a Record Factory function @@ -2477,7 +2477,7 @@ declare module Immutable { * access on the resulting instances: * * * ```js * // Use the Record API @@ -2649,7 +2649,7 @@ declare module Immutable { * Seq's values are never iterated: * * ```js - * const { Seq } = require('immutable@4.0.0-rc.4') + * const { Seq } = require('immutable@4.0.0-rc.5') * const oddSquares = Seq([ 1, 2, 3, 4, 5, 6, 7, 8 ]) * .filter(x => x % 2 !== 0) * .map(x => x * x) @@ -2677,7 +2677,7 @@ declare module Immutable { * As well as expressing logic that would otherwise be memory or time limited: * * ```js - * const { Range } = require('immutable@4.0.0-rc.4') + * const { Range } = require('immutable@4.0.0-rc.5') * Range(1, Infinity) * .skip(1000) * .map(n => -n) @@ -2756,7 +2756,7 @@ declare module Immutable { * `mapper` function. * * ```js - * const { Seq } = require('immutable@4.0.0-rc.4') + * const { Seq } = require('immutable@4.0.0-rc.5') * Seq.Keyed({ a: 1, b: 2 }).map(x => 10 * x) * // Seq { "a": 10, "b": 20 } * ``` @@ -2868,7 +2868,7 @@ declare module Immutable { * `mapper` function. * * ```js - * const { Seq } = require('immutable@4.0.0-rc.4') + * const { Seq } = require('immutable@4.0.0-rc.5') * Seq.Indexed([ 1, 2 ]).map(x => 10 * x) * // Seq [ 10, 20 ] * ``` @@ -3128,7 +3128,7 @@ declare module Immutable { * `mapper` function. * * ```js - * const { Seq } = require('immutable@4.0.0-rc.4') + * const { Seq } = require('immutable@4.0.0-rc.5') * Seq([ 1, 2 ]).map(x => 10 * x) * // Seq [ 10, 20 ] * ``` @@ -3146,7 +3146,7 @@ declare module Immutable { * `mapper` function. * * ```js - * const { Seq } = require('immutable@4.0.0-rc.4') + * const { Seq } = require('immutable@4.0.0-rc.5') * Seq([ 1, 2 ]).map(x => 10 * x) * // Seq [ 10, 20 ] * ``` @@ -3215,22 +3215,22 @@ declare module Immutable { export module Collection { /** - * @deprecated use `const { isKeyed } = require('immutable@4.0.0-rc.4')` + * @deprecated use `const { isKeyed } = require('immutable@4.0.0-rc.5')` */ function isKeyed(maybeKeyed: any): maybeKeyed is Collection.Keyed; /** - * @deprecated use `const { isIndexed } = require('immutable@4.0.0-rc.4')` + * @deprecated use `const { isIndexed } = require('immutable@4.0.0-rc.5')` */ function isIndexed(maybeIndexed: any): maybeIndexed is Collection.Indexed; /** - * @deprecated use `const { isAssociative } = require('immutable@4.0.0-rc.4')` + * @deprecated use `const { isAssociative } = require('immutable@4.0.0-rc.5')` */ function isAssociative(maybeAssociative: any): maybeAssociative is Collection.Keyed | Collection.Indexed; /** - * @deprecated use `const { isOrdered } = require('immutable@4.0.0-rc.4')` + * @deprecated use `const { isOrdered } = require('immutable@4.0.0-rc.5')` */ function isOrdered(maybeOrdered: any): boolean; @@ -3288,7 +3288,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.4') + * const { Map } = require('immutable@4.0.0-rc.5') * Map({ a: 'z', b: 'y' }).flip() * // Map { "z": "a", "y": "b" } * ``` @@ -3306,7 +3306,7 @@ declare module Immutable { * `mapper` function. * * ```js - * const { Collection } = require('immutable@4.0.0-rc.4') + * const { Collection } = require('immutable@4.0.0-rc.5') * Collection.Keyed({ a: 1, b: 2 }).map(x => 10 * x) * // Seq { "a": 10, "b": 20 } * ``` @@ -3325,7 +3325,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.4') + * const { Map } = require('immutable@4.0.0-rc.5') * Map({ a: 1, b: 2 }).mapKeys(x => x.toUpperCase()) * // Map { "A": 1, "B": 2 } * ``` @@ -3344,7 +3344,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.4') + * const { Map } = require('immutable@4.0.0-rc.5') * Map({ a: 1, b: 2 }) * .mapEntries(([ k, v ]) => [ k.toUpperCase(), v * 2 ]) * // Map { "A": 2, "B": 4 } @@ -3470,10 +3470,10 @@ declare module Immutable { * second from each, etc. * * * ```js - * const { List } = require('immutable@4.0.0-rc.4') + * const { List } = require('immutable@4.0.0-rc.5') * List([ 1, 2, 3 ]).interleave(List([ 'A', 'B', 'C' ])) * // List [ 1, "A", 2, "B", 3, "C"" ] * ``` @@ -3481,7 +3481,7 @@ declare module Immutable { * The shortest Collection stops interleave. * * * ```js * List([ 1, 2, 3 ]).interleave( @@ -3503,7 +3503,7 @@ declare module Immutable { * * * ```js - * const { List } = require('immutable@4.0.0-rc.4') + * const { List } = require('immutable@4.0.0-rc.5') * List([ 'a', 'b', 'c', 'd' ]).splice(1, 2, 'q', 'r', 's') * // List [ "a", "q", "r", "s", "d" ] * ``` @@ -3522,7 +3522,7 @@ declare module Immutable { * * * * ```js * const a = List([ 1, 2, 3 ]); @@ -3555,7 +3555,7 @@ declare module Immutable { * collections by using a custom `zipper` function. * * * ```js * const a = List([ 1, 2, 3 ]); @@ -3623,7 +3623,7 @@ declare module Immutable { * `mapper` function. * * ```js - * const { Collection } = require('immutable@4.0.0-rc.4') + * const { Collection } = require('immutable@4.0.0-rc.5') * Collection.Indexed([1,2]).map(x => 10 * x) * // Seq [ 1, 2 ] * ``` @@ -3675,7 +3675,7 @@ declare module Immutable { * the value as both the first and second arguments to the provided function. * * ```js - * const { Collection } = require('immutable@4.0.0-rc.4') + * const { Collection } = require('immutable@4.0.0-rc.5') * const seq = Collection.Set([ 'A', 'B', 'C' ]) * // Seq { "A", "B", "C" } * seq.forEach((v, k) => @@ -3807,7 +3807,7 @@ declare module Immutable { * lookup via a different instance. * * * ```js * const a = List([ 1, 2, 3 ]); @@ -3888,7 +3888,7 @@ declare module Immutable { * * * ```js - * const { Seq } = require('immutable@4.0.0-rc.4') + * const { Seq } = require('immutable@4.0.0-rc.5') * * function sum(collection) { * return collection.reduce((sum, x) => sum + x, 0) @@ -3984,7 +3984,7 @@ declare module Immutable { * * * ```js - * const { Map, List } = require('immutable@4.0.0-rc.4') + * const { Map, List } = require('immutable@4.0.0-rc.5') * var myMap = Map({ a: 'Apple', b: 'Banana' }) * List(myMap) // List [ [ "a", "Apple" ], [ "b", "Banana" ] ] * myMap.toList() // List [ "Apple", "Banana" ] @@ -4021,7 +4021,7 @@ declare module Immutable { * * * ```js - * const { Seq } = require('immutable@4.0.0-rc.4') + * const { Seq } = require('immutable@4.0.0-rc.5') * const indexedSeq = Seq([ 'A', 'B', 'C' ]) * // Seq [ "A", "B", "C" ] * indexedSeq.filter(v => v === 'B') @@ -4102,7 +4102,7 @@ declare module Immutable { * * * ```js - * const { Collection } = require('immutable@4.0.0-rc.4') + * const { Collection } = require('immutable@4.0.0-rc.5') * Collection({ a: 1, b: 2 }).map(x => 10 * x) * // Seq { "a": 10, "b": 20 } * ``` @@ -4129,7 +4129,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.4') + * const { Map } = require('immutable@4.0.0-rc.5') * Map({ a: 1, b: 2, c: 3, d: 4}).filter(x => x % 2 === 0) * // Map { "b": 2, "d": 4 } * ``` @@ -4152,7 +4152,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.4') + * const { Map } = require('immutable@4.0.0-rc.5') * Map({ a: 1, b: 2, c: 3, d: 4}).filterNot(x => x % 2 === 0) * // Map { "a": 1, "c": 3 } * ``` @@ -4189,7 +4189,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.4') + * const { Map } = require('immutable@4.0.0-rc.5') * Map({ "c": 3, "a": 1, "b": 2 }).sort((a, b) => { * if (a < b) { return -1; } * if (a > b) { return 1; } @@ -4229,7 +4229,7 @@ declare module Immutable { * * * ```js - * const { List, Map } = require('immutable@4.0.0-rc.4') + * const { List, Map } = require('immutable@4.0.0-rc.5') * const listOfMaps = List([ * Map({ v: 0 }), * Map({ v: 1 }), @@ -4316,7 +4316,7 @@ declare module Immutable { * * * ```js - * const { List } = require('immutable@4.0.0-rc.4') + * const { List } = require('immutable@4.0.0-rc.5') * List([ 'dog', 'frog', 'cat', 'hat', 'god' ]) * .skipWhile(x => x.match(/g/)) * // List [ "cat", "hat", "god"" ] @@ -4333,7 +4333,7 @@ declare module Immutable { * * * ```js - * const { List } = require('immutable@4.0.0-rc.4') + * const { List } = require('immutable@4.0.0-rc.5') * List([ 'dog', 'frog', 'cat', 'hat', 'god' ]) * .skipUntil(x => x.match(/hat/)) * // List [ "hat", "god"" ] @@ -4362,7 +4362,7 @@ declare module Immutable { * * * ```js - * const { List } = require('immutable@4.0.0-rc.4') + * const { List } = require('immutable@4.0.0-rc.5') * List([ 'dog', 'frog', 'cat', 'hat', 'god' ]) * .takeWhile(x => x.match(/o/)) * // List [ "dog", "frog" ] @@ -4379,7 +4379,7 @@ declare module Immutable { * * * ```js - * const { List } = require('immutable@4.0.0-rc.4') + * const { List } = require('immutable@4.0.0-rc.5') * List([ 'dog', 'frog', 'cat', 'hat', 'god' ]) * .takeUntil(x => x.match(/at/)) * // List [ "dog", "frog" ] diff --git a/dist/immutable.es.js b/dist/immutable.es.js index fd87654fc5..f75e22ff50 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -5510,7 +5510,7 @@ function isPlainObj(value) { ); } -var version = "4.0.0-rc.4"; +var version = "4.0.0-rc.5"; var Immutable = { version: version, diff --git a/dist/immutable.js b/dist/immutable.js index 444366c530..eb3fc2ea95 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -5516,7 +5516,7 @@ function isPlainObj(value) { ); } -var version = "4.0.0-rc.4"; +var version = "4.0.0-rc.5"; var Immutable = { version: version, diff --git a/dist/immutable.min.js b/dist/immutable.min.js index d6de80ec5f..0370b87299 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -34,4 +34,4 @@ getIn:function(t,e){return ye(this,e,t,!0)},groupBy:function(t,e){return H(this, $r.toJSON=Zr.toObject,$r.__toStringMapper=function(t,e){return _t(e)+": "+_t(t)},$t(We,{toKeyedSeq:function(){return new dr(this,!1)},filter:function(t,e){return it(this,P(this,t,e,!1))},findIndex:function(t,e){var r=this.findEntry(t,e);return r?r[0]:-1},indexOf:function(t){var e=this.keyOf(t);return void 0===e?-1:e},lastIndexOf:function(t){var e=this.lastKeyOf(t);return void 0===e?-1:e},reverse:function(){return it(this,N(this,!1))},slice:function(t,e){return it(this,Y(this,t,e,!1))},splice:function(t,e){var r=arguments.length;if(e=Math.max(e||0,0),0===r||2===r&&!e)return this;t=c(t,t<0?this.count():this.size);var n=this.slice(0,t);return it(this,1===r?n:n.concat(i(arguments,2),this.slice(t+e)))},findLastIndex:function(t,e){var r=this.findLastEntry(t,e);return r?r[0]:-1},first:function(){return this.get(0)},flatten:function(t){return it(this,G(this,t,!1))},get:function(t,e){return t=u(this,t),t<0||this.size===1/0||void 0!==this.size&&t>this.size?e:this.find(function(e,r){return r===t},void 0,e)},has:function(t){return(t=u(this,t))>=0&&(void 0!==this.size?this.size===1/0||t Date: Thu, 5 Oct 2017 10:21:34 +0000 Subject: [PATCH 046/242] Deploy 03bf6ec961aaead2cdab8d9995758a0bcdaf93ae to NPM branch --- dist/immutable.js.flow | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dist/immutable.js.flow b/dist/immutable.js.flow index 50b909722a..59842f5079 100644 --- a/dist/immutable.js.flow +++ b/dist/immutable.js.flow @@ -1341,6 +1341,8 @@ declare class RecordInstance { clear(): this & T; setIn(keyPath: Iterable, value: any): this & T; + getIn(searchKeyPath: Iterable, notSetValue?: mixed): any; + hasIn(searchKeyPath: Iterable): boolean; updateIn(keyPath: Iterable, updater: (value: any) => any): this & T; mergeIn(keyPath: Iterable, ...collections: Array): this & T; mergeDeepIn(keyPath: Iterable, ...collections: Array): this & T; From ddf86270a24d839ebefba31cd7cc18c70a42486e Mon Sep 17 00:00:00 2001 From: Travis CI Date: Thu, 5 Oct 2017 10:33:14 +0000 Subject: [PATCH 047/242] Deploy 7015a4814b0f3ee1bd5bca4333f1aac798efa3df to NPM branch --- dist/immutable.js.flow | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/dist/immutable.js.flow b/dist/immutable.js.flow index 59842f5079..3f32a6e929 100644 --- a/dist/immutable.js.flow +++ b/dist/immutable.js.flow @@ -43,8 +43,8 @@ declare class _Collection /*implements ValueObject*/ { first(): V | void; last(): V | void; - getIn(searchKeyPath: Iterable, notSetValue?: mixed): any; - hasIn(searchKeyPath: Iterable): boolean; + getIn(keyPath: Iterable, notSetValue?: mixed): any; + hasIn(keyPath: Iterable): boolean; update(updater: (value: this) => U): U; @@ -829,12 +829,12 @@ declare class Map extends KeyedCollection { ): this; mergeIn( - keyPath: Iterable, - ...collections: (Iterable | PlainObjInput)[] + keyPath: Iterable, + ...collections: (Iterable | PlainObjInput)[] ): this; mergeDeepIn( - keyPath: Iterable, - ...collections: (Iterable | PlainObjInput)[] + keyPath: Iterable, + ...collections: (Iterable | PlainObjInput)[] ): this; withMutations(mutator: (mutable: this) => mixed): this; @@ -924,12 +924,12 @@ declare class OrderedMap extends Map { ): this; mergeIn( - keyPath: Iterable, - ...collections: (Iterable | PlainObjInput)[] + keyPath: Iterable, + ...collections: (Iterable | PlainObjInput)[] ): this; mergeDeepIn( - keyPath: Iterable, - ...collections: (Iterable | PlainObjInput)[] + keyPath: Iterable, + ...collections: (Iterable | PlainObjInput)[] ): this; withMutations(mutator: (mutable: this) => mixed): this; @@ -1319,6 +1319,9 @@ declare class RecordInstance { has(key: string): boolean; get>(key: K): $ElementType; + hasIn(keyPath: Iterable): boolean; + getIn(keyPath: Iterable, notSetValue?: mixed): any; + equals(other: any): boolean; hashCode(): number; @@ -1340,14 +1343,12 @@ declare class RecordInstance { remove>(key: K): this & T; clear(): this & T; - setIn(keyPath: Iterable, value: any): this & T; - getIn(searchKeyPath: Iterable, notSetValue?: mixed): any; - hasIn(searchKeyPath: Iterable): boolean; - updateIn(keyPath: Iterable, updater: (value: any) => any): this & T; - mergeIn(keyPath: Iterable, ...collections: Array): this & T; - mergeDeepIn(keyPath: Iterable, ...collections: Array): this & T; - deleteIn(keyPath: Iterable): this & T; - removeIn(keyPath: Iterable): this & T; + setIn(keyPath: Iterable, value: any): this & T; + updateIn(keyPath: Iterable, updater: (value: any) => any): this & T; + mergeIn(keyPath: Iterable, ...collections: Array): this & T; + mergeDeepIn(keyPath: Iterable, ...collections: Array): this & T; + deleteIn(keyPath: Iterable): this & T; + removeIn(keyPath: Iterable): this & T; toSeq(): KeyedSeq<$Keys, any>; From 4c79b8bb35c571f07e8a7b854586094bf7853fa2 Mon Sep 17 00:00:00 2001 From: Travis CI Date: Thu, 5 Oct 2017 10:47:34 +0000 Subject: [PATCH 048/242] Deploy d5c0b0ecd1e6e19c60b9dcb26e0a0dff57f913eb to NPM branch --- dist/immutable.js.flow | 85 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 76 insertions(+), 9 deletions(-) diff --git a/dist/immutable.js.flow b/dist/immutable.js.flow index 3f32a6e929..1b2d814504 100644 --- a/dist/immutable.js.flow +++ b/dist/immutable.js.flow @@ -101,11 +101,6 @@ declare class _Collection /*implements ValueObject*/ { takeWhile(predicate: (value: V, key: K, iter: this) => mixed, context?: mixed): this; takeUntil(predicate: (value: V, key: K, iter: this) => mixed, context?: mixed): this; - filter( - predicate: (value: V, key: K, iter: this) => mixed, - context?: mixed - ): this; - filterNot( predicate: (value: V, key: K, iter: this) => mixed, context?: mixed @@ -217,6 +212,12 @@ declare class KeyedCollection extends Collection { concat(...iters: Array>): KeyedCollection; concat(...iters: Array>): KeyedCollection; + filter(predicate: typeof Boolean): KeyedCollection>; + filter( + predicate: (value: V, key: K, iter: this) => mixed, + context?: mixed + ): KeyedCollection; + map( mapper: (value: V, key: K, iter: this) => M, context?: mixed @@ -371,6 +372,12 @@ declare class IndexedCollection<+T> extends Collection { concat(...iters: Array | C>): IndexedCollection; + filter(predicate: typeof Boolean): IndexedCollection<$NonMaybeType>; + filter( + predicate: (value: T, index: number, iter: this) => mixed, + context?: mixed + ): IndexedCollection; + map( mapper: (value: T, index: number, iter: this) => M, context?: mixed @@ -396,10 +403,16 @@ declare class SetCollection<+T> extends Collection { concat(...iters: Array | C>): SetCollection; - // `map` and `flatMap` cannot be defined further up the hierarchy, because the - // implementation for `KeyedCollection` allows the value type to change without - // constraining the key type. That does not work for `SetCollection` - the value - // and key types *must* match. + // `filter`, `map` and `flatMap` cannot be defined further up the hierarchy, + // because the implementation for `KeyedCollection` allows the value type to + // change without constraining the key type. That does not work for + // `SetCollection` - the value and key types *must* match. + filter(predicate: typeof Boolean): SetCollection<$NonMaybeType>; + filter( + predicate: (value: T, value: T, iter: this) => mixed, + context?: mixed + ): SetCollection; + map( mapper: (value: T, value: T, iter: this) => M, context?: mixed @@ -442,6 +455,12 @@ declare class KeyedSeq extends Seq mixins KeyedCollection { concat(...iters: Array>): KeyedSeq; concat(...iters: Array>): KeyedSeq; + filter(predicate: typeof Boolean): KeyedSeq>; + filter( + predicate: (value: V, key: K, iter: this) => mixed, + context?: mixed + ): KeyedSeq; + map( mapper: (value: V, key: K, iter: this) => M, context?: mixed @@ -475,6 +494,12 @@ declare class IndexedSeq<+T> extends Seq mixins IndexedCollection concat(...iters: Array | C>): IndexedSeq; + filter(predicate: typeof Boolean): IndexedSeq<$NonMaybeType>; + filter( + predicate: (value: T, index: number, iter: this) => mixed, + context?: mixed + ): IndexedSeq; + map( mapper: (value: T, index: number, iter: this) => M, context?: mixed @@ -596,6 +621,12 @@ declare class SetSeq<+T> extends Seq mixins SetCollection { concat(...iters: Array | C>): SetSeq; + filter(predicate: typeof Boolean): SetSeq<$NonMaybeType>; + filter( + predicate: (value: T, value: T, iter: this) => mixed, + context?: mixed + ): SetSeq; + map( mapper: (value: T, value: T, iter: this) => M, context?: mixed @@ -663,6 +694,12 @@ declare class List<+T> extends IndexedCollection { concat(...iters: Array | C>): List; + filter(predicate: typeof Boolean): List<$NonMaybeType>; + filter( + predicate: (value: T, index: number, iter: this) => mixed, + context?: mixed + ): List; + map( mapper: (value: T, index: number, iter: this) => M, context?: mixed @@ -849,6 +886,12 @@ declare class Map extends KeyedCollection { concat(...iters: Array>): Map; concat(...iters: Array>): Map; + filter(predicate: typeof Boolean): Map>; + filter( + predicate: (value: V, key: K, iter: this) => mixed, + context?: mixed + ): Map; + map( mapper: (value: V, key: K, iter: this) => M, context?: mixed @@ -944,6 +987,12 @@ declare class OrderedMap extends Map { concat(...iters: Array>): OrderedMap; concat(...iters: Array>): OrderedMap; + filter(predicate: typeof Boolean): OrderedMap>; + filter( + predicate: (value: V, key: K, iter: this) => mixed, + context?: mixed + ): OrderedMap; + map( mapper: (value: V, key: K, iter: this) => M, context?: mixed @@ -1001,6 +1050,12 @@ declare class Set<+T> extends SetCollection { concat(...iters: Array | C>): Set; + filter(predicate: typeof Boolean): Set<$NonMaybeType>; + filter( + predicate: (value: T, value: T, iter: this) => mixed, + context?: mixed + ): Set; + map( mapper: (value: T, value: T, iter: this) => M, context?: mixed @@ -1036,6 +1091,12 @@ declare class OrderedSet<+T> extends Set { concat(...iters: Array | C>): OrderedSet; + filter(predicate: typeof Boolean): OrderedSet<$NonMaybeType>; + filter( + predicate: (value: T, value: T, iter: this) => mixed, + context?: mixed + ): OrderedSet; + map( mapper: (value: T, value: T, iter: this) => M, context?: mixed @@ -1177,6 +1238,12 @@ declare class Stack<+T> extends IndexedCollection { concat(...iters: Array | C>): Stack; + filter(predicate: typeof Boolean): Stack<$NonMaybeType>; + filter( + predicate: (value: T, index: number, iter: this) => mixed, + context?: mixed + ): Stack; + map( mapper: (value: T, index: number, iter: this) => M, context?: mixed From c83614e6985473b68c5c8f587a381bcc7518b0d8 Mon Sep 17 00:00:00 2001 From: Travis CI Date: Thu, 5 Oct 2017 10:49:44 +0000 Subject: [PATCH 049/242] Deploy 1c863bd67452125c6ffbf795ce91bfabe40f06cf to NPM branch --- bower.json | 2 +- dist/immutable-nonambient.d.ts | 154 ++++++++++++++++----------------- dist/immutable.d.ts | 154 ++++++++++++++++----------------- dist/immutable.es.js | 2 +- dist/immutable.js | 2 +- dist/immutable.min.js | 2 +- package.json | 2 +- 7 files changed, 159 insertions(+), 159 deletions(-) diff --git a/bower.json b/bower.json index 59787af6b0..711d698e47 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "immutable", - "version": "4.0.0-rc.5", + "version": "4.0.0-rc.6", "description": "Immutable Data Collections", "license": "MIT", "homepage": "https://facebook.github.com/immutable-js", diff --git a/dist/immutable-nonambient.d.ts b/dist/immutable-nonambient.d.ts index 3bd962b14d..c5cdf3bdb1 100644 --- a/dist/immutable-nonambient.d.ts +++ b/dist/immutable-nonambient.d.ts @@ -118,7 +118,7 @@ * * * ```js - * const { fromJS, isKeyed } = require('immutable@4.0.0-rc.5') + * const { fromJS, isKeyed } = require('immutable@4.0.0-rc.6') * function (key, value) { * return isKeyed(value) ? value.Map() : value.toList() * } @@ -132,7 +132,7 @@ * * * ```js - * const { fromJS, isKeyed } = require('immutable@4.0.0-rc.5') + * const { fromJS, isKeyed } = require('immutable@4.0.0-rc.6') * fromJS({ a: {b: [10, 20, 30]}, c: 40}, function (key, value, path) { * console.log(key, value, path) * return isKeyed(value) ? value.toOrderedMap() : value.toList() @@ -149,7 +149,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.5') + * const { Map } = require('immutable@4.0.0-rc.6') * let obj = { 1: "one" }; * Object.keys(obj); // [ "1" ] * assert.equal(obj["1"], obj[1]); // "one" === "one" @@ -185,7 +185,7 @@ * * * ```js - * const { Map, is } = require('immutable@4.0.0-rc.5') + * const { Map, is } = require('immutable@4.0.0-rc.6') * const map1 = Map({ a: 1, b: 1, c: 1 }) * const map2 = Map({ a: 1, b: 1, c: 1 }) * assert.equal(map1 !== map2, true) @@ -232,7 +232,7 @@ * * * ```js - * const { isImmutable, Map, List, Stack } = require('immutable@4.0.0-rc.5'); + * const { isImmutable, Map, List, Stack } = require('immutable@4.0.0-rc.6'); * isImmutable([]); // false * isImmutable({}); // false * isImmutable(Map()); // true @@ -248,7 +248,7 @@ * * * ```js - * const { isCollection, Map, List, Stack } = require('immutable@4.0.0-rc.5'); + * const { isCollection, Map, List, Stack } = require('immutable@4.0.0-rc.6'); * isCollection([]); // false * isCollection({}); // false * isCollection(Map()); // true @@ -263,7 +263,7 @@ * * * ```js - * const { isKeyed, Map, List, Stack } = require('immutable@4.0.0-rc.5'); + * const { isKeyed, Map, List, Stack } = require('immutable@4.0.0-rc.6'); * isKeyed([]); // false * isKeyed({}); // false * isKeyed(Map()); // true @@ -278,7 +278,7 @@ * * * ```js - * const { isIndexed, Map, List, Stack, Set } = require('immutable@4.0.0-rc.5'); + * const { isIndexed, Map, List, Stack, Set } = require('immutable@4.0.0-rc.6'); * isIndexed([]); // false * isIndexed({}); // false * isIndexed(Map()); // false @@ -294,7 +294,7 @@ * * * ```js - * const { isAssociative, Map, List, Stack, Set } = require('immutable@4.0.0-rc.5'); + * const { isAssociative, Map, List, Stack, Set } = require('immutable@4.0.0-rc.6'); * isAssociative([]); // false * isAssociative({}); // false * isAssociative(Map()); // true @@ -311,7 +311,7 @@ * * * ```js - * const { isOrdered, Map, OrderedMap, List, Set } = require('immutable@4.0.0-rc.5'); + * const { isOrdered, Map, OrderedMap, List, Set } = require('immutable@4.0.0-rc.6'); * isOrdered([]); // false * isOrdered({}); // false * isOrdered(Map()); // false @@ -353,7 +353,7 @@ * * * ```js - * const { List, Set } = require('immutable@4.0.0-rc.5'); + * const { List, Set } = require('immutable@4.0.0-rc.6'); * const a = List([ 1, 2, 3 ]); * const b = List([ 1, 2, 3 ]); * assert.notStrictEqual(a, b); // different instances @@ -399,7 +399,7 @@ * * * ```js - * const { List } = require('immutable@4.0.0-rc.5'); + * const { List } = require('immutable@4.0.0-rc.6'); * List.isList([]); // false * List.isList(List()); // true * ``` @@ -411,7 +411,7 @@ * * * ```js - * const { List } = require('immutable@4.0.0-rc.5'); + * const { List } = require('immutable@4.0.0-rc.6'); * List.of(1, 2, 3, 4) * // List [ 1, 2, 3, 4 ] * ``` @@ -420,7 +420,7 @@ * * * ```js - * const { List } = require('immutable@4.0.0-rc.5'); + * const { List } = require('immutable@4.0.0-rc.6'); * List.of({x:1}, 2, [3], 4) * // List [ { x: 1 }, 2, [ 3 ], 4 ] * ``` @@ -434,7 +434,7 @@ * * * ```js - * const { List, Set } = require('immutable@4.0.0-rc.5') + * const { List, Set } = require('immutable@4.0.0-rc.6') * * const emptyList = List() * // List [] @@ -927,7 +927,7 @@ * * * ```js - * const { Map, List } = require('immutable@4.0.0-rc.5'); + * const { Map, List } = require('immutable@4.0.0-rc.6'); * Map().set(List([ 1 ]), 'listofone').get(List([ 1 ])); * // 'listofone' * ``` @@ -945,7 +945,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.5') + * const { Map } = require('immutable@4.0.0-rc.6') * Map.isMap({}) // false * Map.isMap(Map()) // true * ``` @@ -957,7 +957,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.5') + * const { Map } = require('immutable@4.0.0-rc.6') * Map.of( * 'key', 'value', * 'numerical value', 3, @@ -979,7 +979,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.5') + * const { Map } = require('immutable@4.0.0-rc.6') * Map({ key: "value" }) * Map([ [ "key", "value" ] ]) * ``` @@ -1025,7 +1025,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.5') + * const { Map } = require('immutable@4.0.0-rc.6') * const originalMap = Map() * const newerMap = originalMap.set('key', 'value') * const newestMap = newerMap.set('key', 'newer value') @@ -1050,7 +1050,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.5') + * const { Map } = require('immutable@4.0.0-rc.6') * const originalMap = Map({ * key: 'value', * otherKey: 'other value' @@ -1072,7 +1072,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.5') + * const { Map } = require('immutable@4.0.0-rc.6') * const names = Map({ a: "Aaron", b: "Barry", c: "Connor" }) * names.deleteAll([ 'a', 'c' ]) * // Map { "b": "Barry" } @@ -1090,7 +1090,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.5') + * const { Map } = require('immutable@4.0.0-rc.6') * Map({ key: 'value' }).clear() * // Map {} * ``` @@ -1107,7 +1107,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.5') + * const { Map } = require('immutable@4.0.0-rc.6') * const aMap = Map({ key: 'value' }) * const newMap = aMap.update('key', value => value + value) * // Map { "key": "valuevalue" } @@ -1215,7 +1215,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.5') + * const { Map } = require('immutable@4.0.0-rc.6') * const one = Map({ a: 10, b: 20, c: 30 }) * const two = Map({ b: 40, a: 50, d: 60 }) * one.merge(two) // Map { "a": 50, "b": 40, "c": 30, "d": 60 } @@ -1233,7 +1233,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.5') + * const { Map } = require('immutable@4.0.0-rc.6') * const one = Map({ a: 10, b: 20, c: 30 }) * const two = Map({ b: 40, a: 50, d: 60 }) * one.mergeWith((oldVal, newVal) => oldVal / newVal, two) @@ -1259,7 +1259,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.5') + * const { Map } = require('immutable@4.0.0-rc.6') * const one = Map({ a: Map({ x: 10, y: 10 }), b: Map({ x: 20, y: 50 }) }) * const two = Map({ a: Map({ x: 2 }), b: Map({ y: 5 }), c: Map({ z: 3 }) }) * one.mergeDeep(two) @@ -1280,7 +1280,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.5') + * const { Map } = require('immutable@4.0.0-rc.6') * const one = Map({ a: Map({ x: 10, y: 10 }), b: Map({ x: 20, y: 50 }) }) * const two = Map({ a: Map({ x: 2 }), b: Map({ y: 5 }), c: Map({ z: 3 }) }) * one.mergeDeepWith((oldVal, newVal) => oldVal / newVal, two) @@ -1307,7 +1307,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.5') + * const { Map } = require('immutable@4.0.0-rc.6') * const originalMap = Map({ * subObject: Map({ * subKey: 'subvalue', @@ -1365,7 +1365,7 @@ * * * ```js - * const { Map, List } = require('immutable@4.0.0-rc.5') + * const { Map, List } = require('immutable@4.0.0-rc.6') * const map = Map({ inMap: Map({ inList: List([ 1, 2, 3 ]) }) }) * const newMap = map.updateIn(['inMap', 'inList'], list => list.push(4)) * // Map { "inMap": Map { "inList": List [ 1, 2, 3, 4 ] } } @@ -1377,7 +1377,7 @@ * provided, otherwise `undefined`. * * * ```js * const map = Map({ a: Map({ b: Map({ c: 10 }) }) }) @@ -1389,7 +1389,7 @@ * no change will occur. This is still true if `notSetValue` is provided. * * * ```js * const map = Map({ a: Map({ b: Map({ c: 10 }) }) }) @@ -1405,7 +1405,7 @@ * The previous example behaves differently when written with default values: * * * ```js * const map = Map({ a: Map({ b: Map({ c: 10 }) }) }) @@ -1464,7 +1464,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.5') + * const { Map } = require('immutable@4.0.0-rc.6') * const map1 = Map() * const map2 = map1.withMutations(map => { * map.set('a', 1).set('b', 2).set('c', 3) @@ -1735,7 +1735,7 @@ * a collection of other sets. * * ```js - * const { Set } = require('immutable@4.0.0-rc.5') + * const { Set } = require('immutable@4.0.0-rc.6') * const intersected = Set.intersect([ * Set([ 'a', 'b', 'c' ]) * Set([ 'c', 'a', 't' ]) @@ -1750,7 +1750,7 @@ * collection of other sets. * * ```js - * const { Set } = require('immutable@4.0.0-rc.5') + * const { Set } = require('immutable@4.0.0-rc.6') * const unioned = Set.union([ * Set([ 'a', 'b', 'c' ]) * Set([ 'c', 'a', 't' ]) @@ -2317,7 +2317,7 @@ * infinity. When `start` is equal to `end`, returns empty range. * * ```js - * const { Range } = require('immutable@4.0.0-rc.5') + * const { Range } = require('immutable@4.0.0-rc.6') * Range() // [ 0, 1, 2, 3, ... ] * Range(10) // [ 10, 11, 12, 13, ... ] * Range(10, 15) // [ 10, 11, 12, 13, 14 ] @@ -2334,7 +2334,7 @@ * not defined, returns an infinite `Seq` of `value`. * * ```js - * const { Repeat } = require('immutable@4.0.0-rc.5') + * const { Repeat } = require('immutable@4.0.0-rc.6') * Repeat('foo') // [ 'foo', 'foo', 'foo', ... ] * Repeat('bar', 4) // [ 'bar', 'bar', 'bar', 'bar' ] * ``` @@ -2350,7 +2350,7 @@ * create Record instances. * * ```js - * const { Record } = require('immutable@4.0.0-rc.5') + * const { Record } = require('immutable@4.0.0-rc.6') * const ABRecord = Record({ a: 1, b: 2 }) * const myRecord = new ABRecord({ b: 3 }) * ``` @@ -2444,7 +2444,7 @@ * method. If one was not provided, the string "Record" is returned. * * ```js - * const { Record } = require('immutable@4.0.0-rc.5') + * const { Record } = require('immutable@4.0.0-rc.6') * const Person = Record({ * name: null * }, 'Person') @@ -2462,7 +2462,7 @@ * type: * * * ```js * // makePerson is a Record Factory function @@ -2477,7 +2477,7 @@ * access on the resulting instances: * * * ```js * // Use the Record API @@ -2649,7 +2649,7 @@ * Seq's values are never iterated: * * ```js - * const { Seq } = require('immutable@4.0.0-rc.5') + * const { Seq } = require('immutable@4.0.0-rc.6') * const oddSquares = Seq([ 1, 2, 3, 4, 5, 6, 7, 8 ]) * .filter(x => x % 2 !== 0) * .map(x => x * x) @@ -2677,7 +2677,7 @@ * As well as expressing logic that would otherwise be memory or time limited: * * ```js - * const { Range } = require('immutable@4.0.0-rc.5') + * const { Range } = require('immutable@4.0.0-rc.6') * Range(1, Infinity) * .skip(1000) * .map(n => -n) @@ -2756,7 +2756,7 @@ * `mapper` function. * * ```js - * const { Seq } = require('immutable@4.0.0-rc.5') + * const { Seq } = require('immutable@4.0.0-rc.6') * Seq.Keyed({ a: 1, b: 2 }).map(x => 10 * x) * // Seq { "a": 10, "b": 20 } * ``` @@ -2868,7 +2868,7 @@ * `mapper` function. * * ```js - * const { Seq } = require('immutable@4.0.0-rc.5') + * const { Seq } = require('immutable@4.0.0-rc.6') * Seq.Indexed([ 1, 2 ]).map(x => 10 * x) * // Seq [ 10, 20 ] * ``` @@ -3128,7 +3128,7 @@ * `mapper` function. * * ```js - * const { Seq } = require('immutable@4.0.0-rc.5') + * const { Seq } = require('immutable@4.0.0-rc.6') * Seq([ 1, 2 ]).map(x => 10 * x) * // Seq [ 10, 20 ] * ``` @@ -3146,7 +3146,7 @@ * `mapper` function. * * ```js - * const { Seq } = require('immutable@4.0.0-rc.5') + * const { Seq } = require('immutable@4.0.0-rc.6') * Seq([ 1, 2 ]).map(x => 10 * x) * // Seq [ 10, 20 ] * ``` @@ -3215,22 +3215,22 @@ export module Collection { /** - * @deprecated use `const { isKeyed } = require('immutable@4.0.0-rc.5')` + * @deprecated use `const { isKeyed } = require('immutable@4.0.0-rc.6')` */ function isKeyed(maybeKeyed: any): maybeKeyed is Collection.Keyed; /** - * @deprecated use `const { isIndexed } = require('immutable@4.0.0-rc.5')` + * @deprecated use `const { isIndexed } = require('immutable@4.0.0-rc.6')` */ function isIndexed(maybeIndexed: any): maybeIndexed is Collection.Indexed; /** - * @deprecated use `const { isAssociative } = require('immutable@4.0.0-rc.5')` + * @deprecated use `const { isAssociative } = require('immutable@4.0.0-rc.6')` */ function isAssociative(maybeAssociative: any): maybeAssociative is Collection.Keyed | Collection.Indexed; /** - * @deprecated use `const { isOrdered } = require('immutable@4.0.0-rc.5')` + * @deprecated use `const { isOrdered } = require('immutable@4.0.0-rc.6')` */ function isOrdered(maybeOrdered: any): boolean; @@ -3288,7 +3288,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.5') + * const { Map } = require('immutable@4.0.0-rc.6') * Map({ a: 'z', b: 'y' }).flip() * // Map { "z": "a", "y": "b" } * ``` @@ -3306,7 +3306,7 @@ * `mapper` function. * * ```js - * const { Collection } = require('immutable@4.0.0-rc.5') + * const { Collection } = require('immutable@4.0.0-rc.6') * Collection.Keyed({ a: 1, b: 2 }).map(x => 10 * x) * // Seq { "a": 10, "b": 20 } * ``` @@ -3325,7 +3325,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.5') + * const { Map } = require('immutable@4.0.0-rc.6') * Map({ a: 1, b: 2 }).mapKeys(x => x.toUpperCase()) * // Map { "A": 1, "B": 2 } * ``` @@ -3344,7 +3344,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.5') + * const { Map } = require('immutable@4.0.0-rc.6') * Map({ a: 1, b: 2 }) * .mapEntries(([ k, v ]) => [ k.toUpperCase(), v * 2 ]) * // Map { "A": 2, "B": 4 } @@ -3470,10 +3470,10 @@ * second from each, etc. * * * ```js - * const { List } = require('immutable@4.0.0-rc.5') + * const { List } = require('immutable@4.0.0-rc.6') * List([ 1, 2, 3 ]).interleave(List([ 'A', 'B', 'C' ])) * // List [ 1, "A", 2, "B", 3, "C"" ] * ``` @@ -3481,7 +3481,7 @@ * The shortest Collection stops interleave. * * * ```js * List([ 1, 2, 3 ]).interleave( @@ -3503,7 +3503,7 @@ * * * ```js - * const { List } = require('immutable@4.0.0-rc.5') + * const { List } = require('immutable@4.0.0-rc.6') * List([ 'a', 'b', 'c', 'd' ]).splice(1, 2, 'q', 'r', 's') * // List [ "a", "q", "r", "s", "d" ] * ``` @@ -3522,7 +3522,7 @@ * * * * ```js * const a = List([ 1, 2, 3 ]); @@ -3555,7 +3555,7 @@ * collections by using a custom `zipper` function. * * * ```js * const a = List([ 1, 2, 3 ]); @@ -3623,7 +3623,7 @@ * `mapper` function. * * ```js - * const { Collection } = require('immutable@4.0.0-rc.5') + * const { Collection } = require('immutable@4.0.0-rc.6') * Collection.Indexed([1,2]).map(x => 10 * x) * // Seq [ 1, 2 ] * ``` @@ -3675,7 +3675,7 @@ * the value as both the first and second arguments to the provided function. * * ```js - * const { Collection } = require('immutable@4.0.0-rc.5') + * const { Collection } = require('immutable@4.0.0-rc.6') * const seq = Collection.Set([ 'A', 'B', 'C' ]) * // Seq { "A", "B", "C" } * seq.forEach((v, k) => @@ -3807,7 +3807,7 @@ * lookup via a different instance. * * * ```js * const a = List([ 1, 2, 3 ]); @@ -3888,7 +3888,7 @@ * * * ```js - * const { Seq } = require('immutable@4.0.0-rc.5') + * const { Seq } = require('immutable@4.0.0-rc.6') * * function sum(collection) { * return collection.reduce((sum, x) => sum + x, 0) @@ -3984,7 +3984,7 @@ * * * ```js - * const { Map, List } = require('immutable@4.0.0-rc.5') + * const { Map, List } = require('immutable@4.0.0-rc.6') * var myMap = Map({ a: 'Apple', b: 'Banana' }) * List(myMap) // List [ [ "a", "Apple" ], [ "b", "Banana" ] ] * myMap.toList() // List [ "Apple", "Banana" ] @@ -4021,7 +4021,7 @@ * * * ```js - * const { Seq } = require('immutable@4.0.0-rc.5') + * const { Seq } = require('immutable@4.0.0-rc.6') * const indexedSeq = Seq([ 'A', 'B', 'C' ]) * // Seq [ "A", "B", "C" ] * indexedSeq.filter(v => v === 'B') @@ -4102,7 +4102,7 @@ * * * ```js - * const { Collection } = require('immutable@4.0.0-rc.5') + * const { Collection } = require('immutable@4.0.0-rc.6') * Collection({ a: 1, b: 2 }).map(x => 10 * x) * // Seq { "a": 10, "b": 20 } * ``` @@ -4129,7 +4129,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.5') + * const { Map } = require('immutable@4.0.0-rc.6') * Map({ a: 1, b: 2, c: 3, d: 4}).filter(x => x % 2 === 0) * // Map { "b": 2, "d": 4 } * ``` @@ -4152,7 +4152,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.5') + * const { Map } = require('immutable@4.0.0-rc.6') * Map({ a: 1, b: 2, c: 3, d: 4}).filterNot(x => x % 2 === 0) * // Map { "a": 1, "c": 3 } * ``` @@ -4189,7 +4189,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.5') + * const { Map } = require('immutable@4.0.0-rc.6') * Map({ "c": 3, "a": 1, "b": 2 }).sort((a, b) => { * if (a < b) { return -1; } * if (a > b) { return 1; } @@ -4229,7 +4229,7 @@ * * * ```js - * const { List, Map } = require('immutable@4.0.0-rc.5') + * const { List, Map } = require('immutable@4.0.0-rc.6') * const listOfMaps = List([ * Map({ v: 0 }), * Map({ v: 1 }), @@ -4316,7 +4316,7 @@ * * * ```js - * const { List } = require('immutable@4.0.0-rc.5') + * const { List } = require('immutable@4.0.0-rc.6') * List([ 'dog', 'frog', 'cat', 'hat', 'god' ]) * .skipWhile(x => x.match(/g/)) * // List [ "cat", "hat", "god"" ] @@ -4333,7 +4333,7 @@ * * * ```js - * const { List } = require('immutable@4.0.0-rc.5') + * const { List } = require('immutable@4.0.0-rc.6') * List([ 'dog', 'frog', 'cat', 'hat', 'god' ]) * .skipUntil(x => x.match(/hat/)) * // List [ "hat", "god"" ] @@ -4362,7 +4362,7 @@ * * * ```js - * const { List } = require('immutable@4.0.0-rc.5') + * const { List } = require('immutable@4.0.0-rc.6') * List([ 'dog', 'frog', 'cat', 'hat', 'god' ]) * .takeWhile(x => x.match(/o/)) * // List [ "dog", "frog" ] @@ -4379,7 +4379,7 @@ * * * ```js - * const { List } = require('immutable@4.0.0-rc.5') + * const { List } = require('immutable@4.0.0-rc.6') * List([ 'dog', 'frog', 'cat', 'hat', 'god' ]) * .takeUntil(x => x.match(/at/)) * // List [ "dog", "frog" ] diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index d196949211..60e3be8249 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -118,7 +118,7 @@ declare module Immutable { * * * ```js - * const { fromJS, isKeyed } = require('immutable@4.0.0-rc.5') + * const { fromJS, isKeyed } = require('immutable@4.0.0-rc.6') * function (key, value) { * return isKeyed(value) ? value.Map() : value.toList() * } @@ -132,7 +132,7 @@ declare module Immutable { * * * ```js - * const { fromJS, isKeyed } = require('immutable@4.0.0-rc.5') + * const { fromJS, isKeyed } = require('immutable@4.0.0-rc.6') * fromJS({ a: {b: [10, 20, 30]}, c: 40}, function (key, value, path) { * console.log(key, value, path) * return isKeyed(value) ? value.toOrderedMap() : value.toList() @@ -149,7 +149,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.5') + * const { Map } = require('immutable@4.0.0-rc.6') * let obj = { 1: "one" }; * Object.keys(obj); // [ "1" ] * assert.equal(obj["1"], obj[1]); // "one" === "one" @@ -185,7 +185,7 @@ declare module Immutable { * * * ```js - * const { Map, is } = require('immutable@4.0.0-rc.5') + * const { Map, is } = require('immutable@4.0.0-rc.6') * const map1 = Map({ a: 1, b: 1, c: 1 }) * const map2 = Map({ a: 1, b: 1, c: 1 }) * assert.equal(map1 !== map2, true) @@ -232,7 +232,7 @@ declare module Immutable { * * * ```js - * const { isImmutable, Map, List, Stack } = require('immutable@4.0.0-rc.5'); + * const { isImmutable, Map, List, Stack } = require('immutable@4.0.0-rc.6'); * isImmutable([]); // false * isImmutable({}); // false * isImmutable(Map()); // true @@ -248,7 +248,7 @@ declare module Immutable { * * * ```js - * const { isCollection, Map, List, Stack } = require('immutable@4.0.0-rc.5'); + * const { isCollection, Map, List, Stack } = require('immutable@4.0.0-rc.6'); * isCollection([]); // false * isCollection({}); // false * isCollection(Map()); // true @@ -263,7 +263,7 @@ declare module Immutable { * * * ```js - * const { isKeyed, Map, List, Stack } = require('immutable@4.0.0-rc.5'); + * const { isKeyed, Map, List, Stack } = require('immutable@4.0.0-rc.6'); * isKeyed([]); // false * isKeyed({}); // false * isKeyed(Map()); // true @@ -278,7 +278,7 @@ declare module Immutable { * * * ```js - * const { isIndexed, Map, List, Stack, Set } = require('immutable@4.0.0-rc.5'); + * const { isIndexed, Map, List, Stack, Set } = require('immutable@4.0.0-rc.6'); * isIndexed([]); // false * isIndexed({}); // false * isIndexed(Map()); // false @@ -294,7 +294,7 @@ declare module Immutable { * * * ```js - * const { isAssociative, Map, List, Stack, Set } = require('immutable@4.0.0-rc.5'); + * const { isAssociative, Map, List, Stack, Set } = require('immutable@4.0.0-rc.6'); * isAssociative([]); // false * isAssociative({}); // false * isAssociative(Map()); // true @@ -311,7 +311,7 @@ declare module Immutable { * * * ```js - * const { isOrdered, Map, OrderedMap, List, Set } = require('immutable@4.0.0-rc.5'); + * const { isOrdered, Map, OrderedMap, List, Set } = require('immutable@4.0.0-rc.6'); * isOrdered([]); // false * isOrdered({}); // false * isOrdered(Map()); // false @@ -353,7 +353,7 @@ declare module Immutable { * * * ```js - * const { List, Set } = require('immutable@4.0.0-rc.5'); + * const { List, Set } = require('immutable@4.0.0-rc.6'); * const a = List([ 1, 2, 3 ]); * const b = List([ 1, 2, 3 ]); * assert.notStrictEqual(a, b); // different instances @@ -399,7 +399,7 @@ declare module Immutable { * * * ```js - * const { List } = require('immutable@4.0.0-rc.5'); + * const { List } = require('immutable@4.0.0-rc.6'); * List.isList([]); // false * List.isList(List()); // true * ``` @@ -411,7 +411,7 @@ declare module Immutable { * * * ```js - * const { List } = require('immutable@4.0.0-rc.5'); + * const { List } = require('immutable@4.0.0-rc.6'); * List.of(1, 2, 3, 4) * // List [ 1, 2, 3, 4 ] * ``` @@ -420,7 +420,7 @@ declare module Immutable { * * * ```js - * const { List } = require('immutable@4.0.0-rc.5'); + * const { List } = require('immutable@4.0.0-rc.6'); * List.of({x:1}, 2, [3], 4) * // List [ { x: 1 }, 2, [ 3 ], 4 ] * ``` @@ -434,7 +434,7 @@ declare module Immutable { * * * ```js - * const { List, Set } = require('immutable@4.0.0-rc.5') + * const { List, Set } = require('immutable@4.0.0-rc.6') * * const emptyList = List() * // List [] @@ -927,7 +927,7 @@ declare module Immutable { * * * ```js - * const { Map, List } = require('immutable@4.0.0-rc.5'); + * const { Map, List } = require('immutable@4.0.0-rc.6'); * Map().set(List([ 1 ]), 'listofone').get(List([ 1 ])); * // 'listofone' * ``` @@ -945,7 +945,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.5') + * const { Map } = require('immutable@4.0.0-rc.6') * Map.isMap({}) // false * Map.isMap(Map()) // true * ``` @@ -957,7 +957,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.5') + * const { Map } = require('immutable@4.0.0-rc.6') * Map.of( * 'key', 'value', * 'numerical value', 3, @@ -979,7 +979,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.5') + * const { Map } = require('immutable@4.0.0-rc.6') * Map({ key: "value" }) * Map([ [ "key", "value" ] ]) * ``` @@ -1025,7 +1025,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.5') + * const { Map } = require('immutable@4.0.0-rc.6') * const originalMap = Map() * const newerMap = originalMap.set('key', 'value') * const newestMap = newerMap.set('key', 'newer value') @@ -1050,7 +1050,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.5') + * const { Map } = require('immutable@4.0.0-rc.6') * const originalMap = Map({ * key: 'value', * otherKey: 'other value' @@ -1072,7 +1072,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.5') + * const { Map } = require('immutable@4.0.0-rc.6') * const names = Map({ a: "Aaron", b: "Barry", c: "Connor" }) * names.deleteAll([ 'a', 'c' ]) * // Map { "b": "Barry" } @@ -1090,7 +1090,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.5') + * const { Map } = require('immutable@4.0.0-rc.6') * Map({ key: 'value' }).clear() * // Map {} * ``` @@ -1107,7 +1107,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.5') + * const { Map } = require('immutable@4.0.0-rc.6') * const aMap = Map({ key: 'value' }) * const newMap = aMap.update('key', value => value + value) * // Map { "key": "valuevalue" } @@ -1215,7 +1215,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.5') + * const { Map } = require('immutable@4.0.0-rc.6') * const one = Map({ a: 10, b: 20, c: 30 }) * const two = Map({ b: 40, a: 50, d: 60 }) * one.merge(two) // Map { "a": 50, "b": 40, "c": 30, "d": 60 } @@ -1233,7 +1233,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.5') + * const { Map } = require('immutable@4.0.0-rc.6') * const one = Map({ a: 10, b: 20, c: 30 }) * const two = Map({ b: 40, a: 50, d: 60 }) * one.mergeWith((oldVal, newVal) => oldVal / newVal, two) @@ -1259,7 +1259,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.5') + * const { Map } = require('immutable@4.0.0-rc.6') * const one = Map({ a: Map({ x: 10, y: 10 }), b: Map({ x: 20, y: 50 }) }) * const two = Map({ a: Map({ x: 2 }), b: Map({ y: 5 }), c: Map({ z: 3 }) }) * one.mergeDeep(two) @@ -1280,7 +1280,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.5') + * const { Map } = require('immutable@4.0.0-rc.6') * const one = Map({ a: Map({ x: 10, y: 10 }), b: Map({ x: 20, y: 50 }) }) * const two = Map({ a: Map({ x: 2 }), b: Map({ y: 5 }), c: Map({ z: 3 }) }) * one.mergeDeepWith((oldVal, newVal) => oldVal / newVal, two) @@ -1307,7 +1307,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.5') + * const { Map } = require('immutable@4.0.0-rc.6') * const originalMap = Map({ * subObject: Map({ * subKey: 'subvalue', @@ -1365,7 +1365,7 @@ declare module Immutable { * * * ```js - * const { Map, List } = require('immutable@4.0.0-rc.5') + * const { Map, List } = require('immutable@4.0.0-rc.6') * const map = Map({ inMap: Map({ inList: List([ 1, 2, 3 ]) }) }) * const newMap = map.updateIn(['inMap', 'inList'], list => list.push(4)) * // Map { "inMap": Map { "inList": List [ 1, 2, 3, 4 ] } } @@ -1377,7 +1377,7 @@ declare module Immutable { * provided, otherwise `undefined`. * * * ```js * const map = Map({ a: Map({ b: Map({ c: 10 }) }) }) @@ -1389,7 +1389,7 @@ declare module Immutable { * no change will occur. This is still true if `notSetValue` is provided. * * * ```js * const map = Map({ a: Map({ b: Map({ c: 10 }) }) }) @@ -1405,7 +1405,7 @@ declare module Immutable { * The previous example behaves differently when written with default values: * * * ```js * const map = Map({ a: Map({ b: Map({ c: 10 }) }) }) @@ -1464,7 +1464,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.5') + * const { Map } = require('immutable@4.0.0-rc.6') * const map1 = Map() * const map2 = map1.withMutations(map => { * map.set('a', 1).set('b', 2).set('c', 3) @@ -1735,7 +1735,7 @@ declare module Immutable { * a collection of other sets. * * ```js - * const { Set } = require('immutable@4.0.0-rc.5') + * const { Set } = require('immutable@4.0.0-rc.6') * const intersected = Set.intersect([ * Set([ 'a', 'b', 'c' ]) * Set([ 'c', 'a', 't' ]) @@ -1750,7 +1750,7 @@ declare module Immutable { * collection of other sets. * * ```js - * const { Set } = require('immutable@4.0.0-rc.5') + * const { Set } = require('immutable@4.0.0-rc.6') * const unioned = Set.union([ * Set([ 'a', 'b', 'c' ]) * Set([ 'c', 'a', 't' ]) @@ -2317,7 +2317,7 @@ declare module Immutable { * infinity. When `start` is equal to `end`, returns empty range. * * ```js - * const { Range } = require('immutable@4.0.0-rc.5') + * const { Range } = require('immutable@4.0.0-rc.6') * Range() // [ 0, 1, 2, 3, ... ] * Range(10) // [ 10, 11, 12, 13, ... ] * Range(10, 15) // [ 10, 11, 12, 13, 14 ] @@ -2334,7 +2334,7 @@ declare module Immutable { * not defined, returns an infinite `Seq` of `value`. * * ```js - * const { Repeat } = require('immutable@4.0.0-rc.5') + * const { Repeat } = require('immutable@4.0.0-rc.6') * Repeat('foo') // [ 'foo', 'foo', 'foo', ... ] * Repeat('bar', 4) // [ 'bar', 'bar', 'bar', 'bar' ] * ``` @@ -2350,7 +2350,7 @@ declare module Immutable { * create Record instances. * * ```js - * const { Record } = require('immutable@4.0.0-rc.5') + * const { Record } = require('immutable@4.0.0-rc.6') * const ABRecord = Record({ a: 1, b: 2 }) * const myRecord = new ABRecord({ b: 3 }) * ``` @@ -2444,7 +2444,7 @@ declare module Immutable { * method. If one was not provided, the string "Record" is returned. * * ```js - * const { Record } = require('immutable@4.0.0-rc.5') + * const { Record } = require('immutable@4.0.0-rc.6') * const Person = Record({ * name: null * }, 'Person') @@ -2462,7 +2462,7 @@ declare module Immutable { * type: * * * ```js * // makePerson is a Record Factory function @@ -2477,7 +2477,7 @@ declare module Immutable { * access on the resulting instances: * * * ```js * // Use the Record API @@ -2649,7 +2649,7 @@ declare module Immutable { * Seq's values are never iterated: * * ```js - * const { Seq } = require('immutable@4.0.0-rc.5') + * const { Seq } = require('immutable@4.0.0-rc.6') * const oddSquares = Seq([ 1, 2, 3, 4, 5, 6, 7, 8 ]) * .filter(x => x % 2 !== 0) * .map(x => x * x) @@ -2677,7 +2677,7 @@ declare module Immutable { * As well as expressing logic that would otherwise be memory or time limited: * * ```js - * const { Range } = require('immutable@4.0.0-rc.5') + * const { Range } = require('immutable@4.0.0-rc.6') * Range(1, Infinity) * .skip(1000) * .map(n => -n) @@ -2756,7 +2756,7 @@ declare module Immutable { * `mapper` function. * * ```js - * const { Seq } = require('immutable@4.0.0-rc.5') + * const { Seq } = require('immutable@4.0.0-rc.6') * Seq.Keyed({ a: 1, b: 2 }).map(x => 10 * x) * // Seq { "a": 10, "b": 20 } * ``` @@ -2868,7 +2868,7 @@ declare module Immutable { * `mapper` function. * * ```js - * const { Seq } = require('immutable@4.0.0-rc.5') + * const { Seq } = require('immutable@4.0.0-rc.6') * Seq.Indexed([ 1, 2 ]).map(x => 10 * x) * // Seq [ 10, 20 ] * ``` @@ -3128,7 +3128,7 @@ declare module Immutable { * `mapper` function. * * ```js - * const { Seq } = require('immutable@4.0.0-rc.5') + * const { Seq } = require('immutable@4.0.0-rc.6') * Seq([ 1, 2 ]).map(x => 10 * x) * // Seq [ 10, 20 ] * ``` @@ -3146,7 +3146,7 @@ declare module Immutable { * `mapper` function. * * ```js - * const { Seq } = require('immutable@4.0.0-rc.5') + * const { Seq } = require('immutable@4.0.0-rc.6') * Seq([ 1, 2 ]).map(x => 10 * x) * // Seq [ 10, 20 ] * ``` @@ -3215,22 +3215,22 @@ declare module Immutable { export module Collection { /** - * @deprecated use `const { isKeyed } = require('immutable@4.0.0-rc.5')` + * @deprecated use `const { isKeyed } = require('immutable@4.0.0-rc.6')` */ function isKeyed(maybeKeyed: any): maybeKeyed is Collection.Keyed; /** - * @deprecated use `const { isIndexed } = require('immutable@4.0.0-rc.5')` + * @deprecated use `const { isIndexed } = require('immutable@4.0.0-rc.6')` */ function isIndexed(maybeIndexed: any): maybeIndexed is Collection.Indexed; /** - * @deprecated use `const { isAssociative } = require('immutable@4.0.0-rc.5')` + * @deprecated use `const { isAssociative } = require('immutable@4.0.0-rc.6')` */ function isAssociative(maybeAssociative: any): maybeAssociative is Collection.Keyed | Collection.Indexed; /** - * @deprecated use `const { isOrdered } = require('immutable@4.0.0-rc.5')` + * @deprecated use `const { isOrdered } = require('immutable@4.0.0-rc.6')` */ function isOrdered(maybeOrdered: any): boolean; @@ -3288,7 +3288,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.5') + * const { Map } = require('immutable@4.0.0-rc.6') * Map({ a: 'z', b: 'y' }).flip() * // Map { "z": "a", "y": "b" } * ``` @@ -3306,7 +3306,7 @@ declare module Immutable { * `mapper` function. * * ```js - * const { Collection } = require('immutable@4.0.0-rc.5') + * const { Collection } = require('immutable@4.0.0-rc.6') * Collection.Keyed({ a: 1, b: 2 }).map(x => 10 * x) * // Seq { "a": 10, "b": 20 } * ``` @@ -3325,7 +3325,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.5') + * const { Map } = require('immutable@4.0.0-rc.6') * Map({ a: 1, b: 2 }).mapKeys(x => x.toUpperCase()) * // Map { "A": 1, "B": 2 } * ``` @@ -3344,7 +3344,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.5') + * const { Map } = require('immutable@4.0.0-rc.6') * Map({ a: 1, b: 2 }) * .mapEntries(([ k, v ]) => [ k.toUpperCase(), v * 2 ]) * // Map { "A": 2, "B": 4 } @@ -3470,10 +3470,10 @@ declare module Immutable { * second from each, etc. * * * ```js - * const { List } = require('immutable@4.0.0-rc.5') + * const { List } = require('immutable@4.0.0-rc.6') * List([ 1, 2, 3 ]).interleave(List([ 'A', 'B', 'C' ])) * // List [ 1, "A", 2, "B", 3, "C"" ] * ``` @@ -3481,7 +3481,7 @@ declare module Immutable { * The shortest Collection stops interleave. * * * ```js * List([ 1, 2, 3 ]).interleave( @@ -3503,7 +3503,7 @@ declare module Immutable { * * * ```js - * const { List } = require('immutable@4.0.0-rc.5') + * const { List } = require('immutable@4.0.0-rc.6') * List([ 'a', 'b', 'c', 'd' ]).splice(1, 2, 'q', 'r', 's') * // List [ "a", "q", "r", "s", "d" ] * ``` @@ -3522,7 +3522,7 @@ declare module Immutable { * * * * ```js * const a = List([ 1, 2, 3 ]); @@ -3555,7 +3555,7 @@ declare module Immutable { * collections by using a custom `zipper` function. * * * ```js * const a = List([ 1, 2, 3 ]); @@ -3623,7 +3623,7 @@ declare module Immutable { * `mapper` function. * * ```js - * const { Collection } = require('immutable@4.0.0-rc.5') + * const { Collection } = require('immutable@4.0.0-rc.6') * Collection.Indexed([1,2]).map(x => 10 * x) * // Seq [ 1, 2 ] * ``` @@ -3675,7 +3675,7 @@ declare module Immutable { * the value as both the first and second arguments to the provided function. * * ```js - * const { Collection } = require('immutable@4.0.0-rc.5') + * const { Collection } = require('immutable@4.0.0-rc.6') * const seq = Collection.Set([ 'A', 'B', 'C' ]) * // Seq { "A", "B", "C" } * seq.forEach((v, k) => @@ -3807,7 +3807,7 @@ declare module Immutable { * lookup via a different instance. * * * ```js * const a = List([ 1, 2, 3 ]); @@ -3888,7 +3888,7 @@ declare module Immutable { * * * ```js - * const { Seq } = require('immutable@4.0.0-rc.5') + * const { Seq } = require('immutable@4.0.0-rc.6') * * function sum(collection) { * return collection.reduce((sum, x) => sum + x, 0) @@ -3984,7 +3984,7 @@ declare module Immutable { * * * ```js - * const { Map, List } = require('immutable@4.0.0-rc.5') + * const { Map, List } = require('immutable@4.0.0-rc.6') * var myMap = Map({ a: 'Apple', b: 'Banana' }) * List(myMap) // List [ [ "a", "Apple" ], [ "b", "Banana" ] ] * myMap.toList() // List [ "Apple", "Banana" ] @@ -4021,7 +4021,7 @@ declare module Immutable { * * * ```js - * const { Seq } = require('immutable@4.0.0-rc.5') + * const { Seq } = require('immutable@4.0.0-rc.6') * const indexedSeq = Seq([ 'A', 'B', 'C' ]) * // Seq [ "A", "B", "C" ] * indexedSeq.filter(v => v === 'B') @@ -4102,7 +4102,7 @@ declare module Immutable { * * * ```js - * const { Collection } = require('immutable@4.0.0-rc.5') + * const { Collection } = require('immutable@4.0.0-rc.6') * Collection({ a: 1, b: 2 }).map(x => 10 * x) * // Seq { "a": 10, "b": 20 } * ``` @@ -4129,7 +4129,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.5') + * const { Map } = require('immutable@4.0.0-rc.6') * Map({ a: 1, b: 2, c: 3, d: 4}).filter(x => x % 2 === 0) * // Map { "b": 2, "d": 4 } * ``` @@ -4152,7 +4152,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.5') + * const { Map } = require('immutable@4.0.0-rc.6') * Map({ a: 1, b: 2, c: 3, d: 4}).filterNot(x => x % 2 === 0) * // Map { "a": 1, "c": 3 } * ``` @@ -4189,7 +4189,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.5') + * const { Map } = require('immutable@4.0.0-rc.6') * Map({ "c": 3, "a": 1, "b": 2 }).sort((a, b) => { * if (a < b) { return -1; } * if (a > b) { return 1; } @@ -4229,7 +4229,7 @@ declare module Immutable { * * * ```js - * const { List, Map } = require('immutable@4.0.0-rc.5') + * const { List, Map } = require('immutable@4.0.0-rc.6') * const listOfMaps = List([ * Map({ v: 0 }), * Map({ v: 1 }), @@ -4316,7 +4316,7 @@ declare module Immutable { * * * ```js - * const { List } = require('immutable@4.0.0-rc.5') + * const { List } = require('immutable@4.0.0-rc.6') * List([ 'dog', 'frog', 'cat', 'hat', 'god' ]) * .skipWhile(x => x.match(/g/)) * // List [ "cat", "hat", "god"" ] @@ -4333,7 +4333,7 @@ declare module Immutable { * * * ```js - * const { List } = require('immutable@4.0.0-rc.5') + * const { List } = require('immutable@4.0.0-rc.6') * List([ 'dog', 'frog', 'cat', 'hat', 'god' ]) * .skipUntil(x => x.match(/hat/)) * // List [ "hat", "god"" ] @@ -4362,7 +4362,7 @@ declare module Immutable { * * * ```js - * const { List } = require('immutable@4.0.0-rc.5') + * const { List } = require('immutable@4.0.0-rc.6') * List([ 'dog', 'frog', 'cat', 'hat', 'god' ]) * .takeWhile(x => x.match(/o/)) * // List [ "dog", "frog" ] @@ -4379,7 +4379,7 @@ declare module Immutable { * * * ```js - * const { List } = require('immutable@4.0.0-rc.5') + * const { List } = require('immutable@4.0.0-rc.6') * List([ 'dog', 'frog', 'cat', 'hat', 'god' ]) * .takeUntil(x => x.match(/at/)) * // List [ "dog", "frog" ] diff --git a/dist/immutable.es.js b/dist/immutable.es.js index f75e22ff50..950b267b29 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -5510,7 +5510,7 @@ function isPlainObj(value) { ); } -var version = "4.0.0-rc.5"; +var version = "4.0.0-rc.6"; var Immutable = { version: version, diff --git a/dist/immutable.js b/dist/immutable.js index eb3fc2ea95..29e2606a06 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -5516,7 +5516,7 @@ function isPlainObj(value) { ); } -var version = "4.0.0-rc.5"; +var version = "4.0.0-rc.6"; var Immutable = { version: version, diff --git a/dist/immutable.min.js b/dist/immutable.min.js index 0370b87299..b811e8b604 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -34,4 +34,4 @@ getIn:function(t,e){return ye(this,e,t,!0)},groupBy:function(t,e){return H(this, $r.toJSON=Zr.toObject,$r.__toStringMapper=function(t,e){return _t(e)+": "+_t(t)},$t(We,{toKeyedSeq:function(){return new dr(this,!1)},filter:function(t,e){return it(this,P(this,t,e,!1))},findIndex:function(t,e){var r=this.findEntry(t,e);return r?r[0]:-1},indexOf:function(t){var e=this.keyOf(t);return void 0===e?-1:e},lastIndexOf:function(t){var e=this.lastKeyOf(t);return void 0===e?-1:e},reverse:function(){return it(this,N(this,!1))},slice:function(t,e){return it(this,Y(this,t,e,!1))},splice:function(t,e){var r=arguments.length;if(e=Math.max(e||0,0),0===r||2===r&&!e)return this;t=c(t,t<0?this.count():this.size);var n=this.slice(0,t);return it(this,1===r?n:n.concat(i(arguments,2),this.slice(t+e)))},findLastIndex:function(t,e){var r=this.findLastEntry(t,e);return r?r[0]:-1},first:function(){return this.get(0)},flatten:function(t){return it(this,G(this,t,!1))},get:function(t,e){return t=u(this,t),t<0||this.size===1/0||void 0!==this.size&&t>this.size?e:this.find(function(e,r){return r===t},void 0,e)},has:function(t){return(t=u(this,t))>=0&&(void 0!==this.size?this.size===1/0||t Date: Thu, 5 Oct 2017 16:50:18 +0000 Subject: [PATCH 050/242] Deploy a08c2d657661542b450a8fd83d25ee0ccc11affe to NPM branch --- dist/immutable-nonambient.d.ts | 4 ++-- dist/immutable.d.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dist/immutable-nonambient.d.ts b/dist/immutable-nonambient.d.ts index c5cdf3bdb1..2983fa717b 100644 --- a/dist/immutable-nonambient.d.ts +++ b/dist/immutable-nonambient.d.ts @@ -792,7 +792,7 @@ * @alias merge */ concat(...valuesOrCollections: Array | C>): List; - merge(...collections: Array): List; + merge(...collections: Array>): List; /** * Returns a new List with values passed through a @@ -2511,7 +2511,7 @@ new (values?: Partial | Iterable<[string, any]>): Record & Readonly; } - export function Factory(values?: Partial | Iterable<[string, any]>): Record & Readonly; + export function Factory(values?: Partial | Iterable<[string, any]>): Record & Readonly; } /** diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index 60e3be8249..297050ec3c 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -792,7 +792,7 @@ declare module Immutable { * @alias merge */ concat(...valuesOrCollections: Array | C>): List; - merge(...collections: Array): List; + merge(...collections: Array>): List; /** * Returns a new List with values passed through a @@ -2511,7 +2511,7 @@ declare module Immutable { new (values?: Partial | Iterable<[string, any]>): Record & Readonly; } - export function Factory(values?: Partial | Iterable<[string, any]>): Record & Readonly; + export function Factory(values?: Partial | Iterable<[string, any]>): Record & Readonly; } /** From af2a61d855596851a809b2180110fdca8478ce99 Mon Sep 17 00:00:00 2001 From: Travis CI Date: Thu, 5 Oct 2017 16:54:45 +0000 Subject: [PATCH 051/242] Deploy 5023b0dd8a16f43f4aa8aeeb2603b484abc6750e to NPM branch --- bower.json | 2 +- dist/immutable-nonambient.d.ts | 154 ++++++++++++++++----------------- dist/immutable.d.ts | 154 ++++++++++++++++----------------- dist/immutable.es.js | 2 +- dist/immutable.js | 2 +- dist/immutable.min.js | 2 +- package.json | 2 +- 7 files changed, 159 insertions(+), 159 deletions(-) diff --git a/bower.json b/bower.json index 711d698e47..0ad7a3934f 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "immutable", - "version": "4.0.0-rc.6", + "version": "4.0.0-rc.7", "description": "Immutable Data Collections", "license": "MIT", "homepage": "https://facebook.github.com/immutable-js", diff --git a/dist/immutable-nonambient.d.ts b/dist/immutable-nonambient.d.ts index 2983fa717b..4e8c893fde 100644 --- a/dist/immutable-nonambient.d.ts +++ b/dist/immutable-nonambient.d.ts @@ -118,7 +118,7 @@ * * * ```js - * const { fromJS, isKeyed } = require('immutable@4.0.0-rc.6') + * const { fromJS, isKeyed } = require('immutable@4.0.0-rc.7') * function (key, value) { * return isKeyed(value) ? value.Map() : value.toList() * } @@ -132,7 +132,7 @@ * * * ```js - * const { fromJS, isKeyed } = require('immutable@4.0.0-rc.6') + * const { fromJS, isKeyed } = require('immutable@4.0.0-rc.7') * fromJS({ a: {b: [10, 20, 30]}, c: 40}, function (key, value, path) { * console.log(key, value, path) * return isKeyed(value) ? value.toOrderedMap() : value.toList() @@ -149,7 +149,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.6') + * const { Map } = require('immutable@4.0.0-rc.7') * let obj = { 1: "one" }; * Object.keys(obj); // [ "1" ] * assert.equal(obj["1"], obj[1]); // "one" === "one" @@ -185,7 +185,7 @@ * * * ```js - * const { Map, is } = require('immutable@4.0.0-rc.6') + * const { Map, is } = require('immutable@4.0.0-rc.7') * const map1 = Map({ a: 1, b: 1, c: 1 }) * const map2 = Map({ a: 1, b: 1, c: 1 }) * assert.equal(map1 !== map2, true) @@ -232,7 +232,7 @@ * * * ```js - * const { isImmutable, Map, List, Stack } = require('immutable@4.0.0-rc.6'); + * const { isImmutable, Map, List, Stack } = require('immutable@4.0.0-rc.7'); * isImmutable([]); // false * isImmutable({}); // false * isImmutable(Map()); // true @@ -248,7 +248,7 @@ * * * ```js - * const { isCollection, Map, List, Stack } = require('immutable@4.0.0-rc.6'); + * const { isCollection, Map, List, Stack } = require('immutable@4.0.0-rc.7'); * isCollection([]); // false * isCollection({}); // false * isCollection(Map()); // true @@ -263,7 +263,7 @@ * * * ```js - * const { isKeyed, Map, List, Stack } = require('immutable@4.0.0-rc.6'); + * const { isKeyed, Map, List, Stack } = require('immutable@4.0.0-rc.7'); * isKeyed([]); // false * isKeyed({}); // false * isKeyed(Map()); // true @@ -278,7 +278,7 @@ * * * ```js - * const { isIndexed, Map, List, Stack, Set } = require('immutable@4.0.0-rc.6'); + * const { isIndexed, Map, List, Stack, Set } = require('immutable@4.0.0-rc.7'); * isIndexed([]); // false * isIndexed({}); // false * isIndexed(Map()); // false @@ -294,7 +294,7 @@ * * * ```js - * const { isAssociative, Map, List, Stack, Set } = require('immutable@4.0.0-rc.6'); + * const { isAssociative, Map, List, Stack, Set } = require('immutable@4.0.0-rc.7'); * isAssociative([]); // false * isAssociative({}); // false * isAssociative(Map()); // true @@ -311,7 +311,7 @@ * * * ```js - * const { isOrdered, Map, OrderedMap, List, Set } = require('immutable@4.0.0-rc.6'); + * const { isOrdered, Map, OrderedMap, List, Set } = require('immutable@4.0.0-rc.7'); * isOrdered([]); // false * isOrdered({}); // false * isOrdered(Map()); // false @@ -353,7 +353,7 @@ * * * ```js - * const { List, Set } = require('immutable@4.0.0-rc.6'); + * const { List, Set } = require('immutable@4.0.0-rc.7'); * const a = List([ 1, 2, 3 ]); * const b = List([ 1, 2, 3 ]); * assert.notStrictEqual(a, b); // different instances @@ -399,7 +399,7 @@ * * * ```js - * const { List } = require('immutable@4.0.0-rc.6'); + * const { List } = require('immutable@4.0.0-rc.7'); * List.isList([]); // false * List.isList(List()); // true * ``` @@ -411,7 +411,7 @@ * * * ```js - * const { List } = require('immutable@4.0.0-rc.6'); + * const { List } = require('immutable@4.0.0-rc.7'); * List.of(1, 2, 3, 4) * // List [ 1, 2, 3, 4 ] * ``` @@ -420,7 +420,7 @@ * * * ```js - * const { List } = require('immutable@4.0.0-rc.6'); + * const { List } = require('immutable@4.0.0-rc.7'); * List.of({x:1}, 2, [3], 4) * // List [ { x: 1 }, 2, [ 3 ], 4 ] * ``` @@ -434,7 +434,7 @@ * * * ```js - * const { List, Set } = require('immutable@4.0.0-rc.6') + * const { List, Set } = require('immutable@4.0.0-rc.7') * * const emptyList = List() * // List [] @@ -927,7 +927,7 @@ * * * ```js - * const { Map, List } = require('immutable@4.0.0-rc.6'); + * const { Map, List } = require('immutable@4.0.0-rc.7'); * Map().set(List([ 1 ]), 'listofone').get(List([ 1 ])); * // 'listofone' * ``` @@ -945,7 +945,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.6') + * const { Map } = require('immutable@4.0.0-rc.7') * Map.isMap({}) // false * Map.isMap(Map()) // true * ``` @@ -957,7 +957,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.6') + * const { Map } = require('immutable@4.0.0-rc.7') * Map.of( * 'key', 'value', * 'numerical value', 3, @@ -979,7 +979,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.6') + * const { Map } = require('immutable@4.0.0-rc.7') * Map({ key: "value" }) * Map([ [ "key", "value" ] ]) * ``` @@ -1025,7 +1025,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.6') + * const { Map } = require('immutable@4.0.0-rc.7') * const originalMap = Map() * const newerMap = originalMap.set('key', 'value') * const newestMap = newerMap.set('key', 'newer value') @@ -1050,7 +1050,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.6') + * const { Map } = require('immutable@4.0.0-rc.7') * const originalMap = Map({ * key: 'value', * otherKey: 'other value' @@ -1072,7 +1072,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.6') + * const { Map } = require('immutable@4.0.0-rc.7') * const names = Map({ a: "Aaron", b: "Barry", c: "Connor" }) * names.deleteAll([ 'a', 'c' ]) * // Map { "b": "Barry" } @@ -1090,7 +1090,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.6') + * const { Map } = require('immutable@4.0.0-rc.7') * Map({ key: 'value' }).clear() * // Map {} * ``` @@ -1107,7 +1107,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.6') + * const { Map } = require('immutable@4.0.0-rc.7') * const aMap = Map({ key: 'value' }) * const newMap = aMap.update('key', value => value + value) * // Map { "key": "valuevalue" } @@ -1215,7 +1215,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.6') + * const { Map } = require('immutable@4.0.0-rc.7') * const one = Map({ a: 10, b: 20, c: 30 }) * const two = Map({ b: 40, a: 50, d: 60 }) * one.merge(two) // Map { "a": 50, "b": 40, "c": 30, "d": 60 } @@ -1233,7 +1233,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.6') + * const { Map } = require('immutable@4.0.0-rc.7') * const one = Map({ a: 10, b: 20, c: 30 }) * const two = Map({ b: 40, a: 50, d: 60 }) * one.mergeWith((oldVal, newVal) => oldVal / newVal, two) @@ -1259,7 +1259,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.6') + * const { Map } = require('immutable@4.0.0-rc.7') * const one = Map({ a: Map({ x: 10, y: 10 }), b: Map({ x: 20, y: 50 }) }) * const two = Map({ a: Map({ x: 2 }), b: Map({ y: 5 }), c: Map({ z: 3 }) }) * one.mergeDeep(two) @@ -1280,7 +1280,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.6') + * const { Map } = require('immutable@4.0.0-rc.7') * const one = Map({ a: Map({ x: 10, y: 10 }), b: Map({ x: 20, y: 50 }) }) * const two = Map({ a: Map({ x: 2 }), b: Map({ y: 5 }), c: Map({ z: 3 }) }) * one.mergeDeepWith((oldVal, newVal) => oldVal / newVal, two) @@ -1307,7 +1307,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.6') + * const { Map } = require('immutable@4.0.0-rc.7') * const originalMap = Map({ * subObject: Map({ * subKey: 'subvalue', @@ -1365,7 +1365,7 @@ * * * ```js - * const { Map, List } = require('immutable@4.0.0-rc.6') + * const { Map, List } = require('immutable@4.0.0-rc.7') * const map = Map({ inMap: Map({ inList: List([ 1, 2, 3 ]) }) }) * const newMap = map.updateIn(['inMap', 'inList'], list => list.push(4)) * // Map { "inMap": Map { "inList": List [ 1, 2, 3, 4 ] } } @@ -1377,7 +1377,7 @@ * provided, otherwise `undefined`. * * * ```js * const map = Map({ a: Map({ b: Map({ c: 10 }) }) }) @@ -1389,7 +1389,7 @@ * no change will occur. This is still true if `notSetValue` is provided. * * * ```js * const map = Map({ a: Map({ b: Map({ c: 10 }) }) }) @@ -1405,7 +1405,7 @@ * The previous example behaves differently when written with default values: * * * ```js * const map = Map({ a: Map({ b: Map({ c: 10 }) }) }) @@ -1464,7 +1464,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.6') + * const { Map } = require('immutable@4.0.0-rc.7') * const map1 = Map() * const map2 = map1.withMutations(map => { * map.set('a', 1).set('b', 2).set('c', 3) @@ -1735,7 +1735,7 @@ * a collection of other sets. * * ```js - * const { Set } = require('immutable@4.0.0-rc.6') + * const { Set } = require('immutable@4.0.0-rc.7') * const intersected = Set.intersect([ * Set([ 'a', 'b', 'c' ]) * Set([ 'c', 'a', 't' ]) @@ -1750,7 +1750,7 @@ * collection of other sets. * * ```js - * const { Set } = require('immutable@4.0.0-rc.6') + * const { Set } = require('immutable@4.0.0-rc.7') * const unioned = Set.union([ * Set([ 'a', 'b', 'c' ]) * Set([ 'c', 'a', 't' ]) @@ -2317,7 +2317,7 @@ * infinity. When `start` is equal to `end`, returns empty range. * * ```js - * const { Range } = require('immutable@4.0.0-rc.6') + * const { Range } = require('immutable@4.0.0-rc.7') * Range() // [ 0, 1, 2, 3, ... ] * Range(10) // [ 10, 11, 12, 13, ... ] * Range(10, 15) // [ 10, 11, 12, 13, 14 ] @@ -2334,7 +2334,7 @@ * not defined, returns an infinite `Seq` of `value`. * * ```js - * const { Repeat } = require('immutable@4.0.0-rc.6') + * const { Repeat } = require('immutable@4.0.0-rc.7') * Repeat('foo') // [ 'foo', 'foo', 'foo', ... ] * Repeat('bar', 4) // [ 'bar', 'bar', 'bar', 'bar' ] * ``` @@ -2350,7 +2350,7 @@ * create Record instances. * * ```js - * const { Record } = require('immutable@4.0.0-rc.6') + * const { Record } = require('immutable@4.0.0-rc.7') * const ABRecord = Record({ a: 1, b: 2 }) * const myRecord = new ABRecord({ b: 3 }) * ``` @@ -2444,7 +2444,7 @@ * method. If one was not provided, the string "Record" is returned. * * ```js - * const { Record } = require('immutable@4.0.0-rc.6') + * const { Record } = require('immutable@4.0.0-rc.7') * const Person = Record({ * name: null * }, 'Person') @@ -2462,7 +2462,7 @@ * type: * * * ```js * // makePerson is a Record Factory function @@ -2477,7 +2477,7 @@ * access on the resulting instances: * * * ```js * // Use the Record API @@ -2649,7 +2649,7 @@ * Seq's values are never iterated: * * ```js - * const { Seq } = require('immutable@4.0.0-rc.6') + * const { Seq } = require('immutable@4.0.0-rc.7') * const oddSquares = Seq([ 1, 2, 3, 4, 5, 6, 7, 8 ]) * .filter(x => x % 2 !== 0) * .map(x => x * x) @@ -2677,7 +2677,7 @@ * As well as expressing logic that would otherwise be memory or time limited: * * ```js - * const { Range } = require('immutable@4.0.0-rc.6') + * const { Range } = require('immutable@4.0.0-rc.7') * Range(1, Infinity) * .skip(1000) * .map(n => -n) @@ -2756,7 +2756,7 @@ * `mapper` function. * * ```js - * const { Seq } = require('immutable@4.0.0-rc.6') + * const { Seq } = require('immutable@4.0.0-rc.7') * Seq.Keyed({ a: 1, b: 2 }).map(x => 10 * x) * // Seq { "a": 10, "b": 20 } * ``` @@ -2868,7 +2868,7 @@ * `mapper` function. * * ```js - * const { Seq } = require('immutable@4.0.0-rc.6') + * const { Seq } = require('immutable@4.0.0-rc.7') * Seq.Indexed([ 1, 2 ]).map(x => 10 * x) * // Seq [ 10, 20 ] * ``` @@ -3128,7 +3128,7 @@ * `mapper` function. * * ```js - * const { Seq } = require('immutable@4.0.0-rc.6') + * const { Seq } = require('immutable@4.0.0-rc.7') * Seq([ 1, 2 ]).map(x => 10 * x) * // Seq [ 10, 20 ] * ``` @@ -3146,7 +3146,7 @@ * `mapper` function. * * ```js - * const { Seq } = require('immutable@4.0.0-rc.6') + * const { Seq } = require('immutable@4.0.0-rc.7') * Seq([ 1, 2 ]).map(x => 10 * x) * // Seq [ 10, 20 ] * ``` @@ -3215,22 +3215,22 @@ export module Collection { /** - * @deprecated use `const { isKeyed } = require('immutable@4.0.0-rc.6')` + * @deprecated use `const { isKeyed } = require('immutable@4.0.0-rc.7')` */ function isKeyed(maybeKeyed: any): maybeKeyed is Collection.Keyed; /** - * @deprecated use `const { isIndexed } = require('immutable@4.0.0-rc.6')` + * @deprecated use `const { isIndexed } = require('immutable@4.0.0-rc.7')` */ function isIndexed(maybeIndexed: any): maybeIndexed is Collection.Indexed; /** - * @deprecated use `const { isAssociative } = require('immutable@4.0.0-rc.6')` + * @deprecated use `const { isAssociative } = require('immutable@4.0.0-rc.7')` */ function isAssociative(maybeAssociative: any): maybeAssociative is Collection.Keyed | Collection.Indexed; /** - * @deprecated use `const { isOrdered } = require('immutable@4.0.0-rc.6')` + * @deprecated use `const { isOrdered } = require('immutable@4.0.0-rc.7')` */ function isOrdered(maybeOrdered: any): boolean; @@ -3288,7 +3288,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.6') + * const { Map } = require('immutable@4.0.0-rc.7') * Map({ a: 'z', b: 'y' }).flip() * // Map { "z": "a", "y": "b" } * ``` @@ -3306,7 +3306,7 @@ * `mapper` function. * * ```js - * const { Collection } = require('immutable@4.0.0-rc.6') + * const { Collection } = require('immutable@4.0.0-rc.7') * Collection.Keyed({ a: 1, b: 2 }).map(x => 10 * x) * // Seq { "a": 10, "b": 20 } * ``` @@ -3325,7 +3325,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.6') + * const { Map } = require('immutable@4.0.0-rc.7') * Map({ a: 1, b: 2 }).mapKeys(x => x.toUpperCase()) * // Map { "A": 1, "B": 2 } * ``` @@ -3344,7 +3344,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.6') + * const { Map } = require('immutable@4.0.0-rc.7') * Map({ a: 1, b: 2 }) * .mapEntries(([ k, v ]) => [ k.toUpperCase(), v * 2 ]) * // Map { "A": 2, "B": 4 } @@ -3470,10 +3470,10 @@ * second from each, etc. * * * ```js - * const { List } = require('immutable@4.0.0-rc.6') + * const { List } = require('immutable@4.0.0-rc.7') * List([ 1, 2, 3 ]).interleave(List([ 'A', 'B', 'C' ])) * // List [ 1, "A", 2, "B", 3, "C"" ] * ``` @@ -3481,7 +3481,7 @@ * The shortest Collection stops interleave. * * * ```js * List([ 1, 2, 3 ]).interleave( @@ -3503,7 +3503,7 @@ * * * ```js - * const { List } = require('immutable@4.0.0-rc.6') + * const { List } = require('immutable@4.0.0-rc.7') * List([ 'a', 'b', 'c', 'd' ]).splice(1, 2, 'q', 'r', 's') * // List [ "a", "q", "r", "s", "d" ] * ``` @@ -3522,7 +3522,7 @@ * * * * ```js * const a = List([ 1, 2, 3 ]); @@ -3555,7 +3555,7 @@ * collections by using a custom `zipper` function. * * * ```js * const a = List([ 1, 2, 3 ]); @@ -3623,7 +3623,7 @@ * `mapper` function. * * ```js - * const { Collection } = require('immutable@4.0.0-rc.6') + * const { Collection } = require('immutable@4.0.0-rc.7') * Collection.Indexed([1,2]).map(x => 10 * x) * // Seq [ 1, 2 ] * ``` @@ -3675,7 +3675,7 @@ * the value as both the first and second arguments to the provided function. * * ```js - * const { Collection } = require('immutable@4.0.0-rc.6') + * const { Collection } = require('immutable@4.0.0-rc.7') * const seq = Collection.Set([ 'A', 'B', 'C' ]) * // Seq { "A", "B", "C" } * seq.forEach((v, k) => @@ -3807,7 +3807,7 @@ * lookup via a different instance. * * * ```js * const a = List([ 1, 2, 3 ]); @@ -3888,7 +3888,7 @@ * * * ```js - * const { Seq } = require('immutable@4.0.0-rc.6') + * const { Seq } = require('immutable@4.0.0-rc.7') * * function sum(collection) { * return collection.reduce((sum, x) => sum + x, 0) @@ -3984,7 +3984,7 @@ * * * ```js - * const { Map, List } = require('immutable@4.0.0-rc.6') + * const { Map, List } = require('immutable@4.0.0-rc.7') * var myMap = Map({ a: 'Apple', b: 'Banana' }) * List(myMap) // List [ [ "a", "Apple" ], [ "b", "Banana" ] ] * myMap.toList() // List [ "Apple", "Banana" ] @@ -4021,7 +4021,7 @@ * * * ```js - * const { Seq } = require('immutable@4.0.0-rc.6') + * const { Seq } = require('immutable@4.0.0-rc.7') * const indexedSeq = Seq([ 'A', 'B', 'C' ]) * // Seq [ "A", "B", "C" ] * indexedSeq.filter(v => v === 'B') @@ -4102,7 +4102,7 @@ * * * ```js - * const { Collection } = require('immutable@4.0.0-rc.6') + * const { Collection } = require('immutable@4.0.0-rc.7') * Collection({ a: 1, b: 2 }).map(x => 10 * x) * // Seq { "a": 10, "b": 20 } * ``` @@ -4129,7 +4129,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.6') + * const { Map } = require('immutable@4.0.0-rc.7') * Map({ a: 1, b: 2, c: 3, d: 4}).filter(x => x % 2 === 0) * // Map { "b": 2, "d": 4 } * ``` @@ -4152,7 +4152,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.6') + * const { Map } = require('immutable@4.0.0-rc.7') * Map({ a: 1, b: 2, c: 3, d: 4}).filterNot(x => x % 2 === 0) * // Map { "a": 1, "c": 3 } * ``` @@ -4189,7 +4189,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.6') + * const { Map } = require('immutable@4.0.0-rc.7') * Map({ "c": 3, "a": 1, "b": 2 }).sort((a, b) => { * if (a < b) { return -1; } * if (a > b) { return 1; } @@ -4229,7 +4229,7 @@ * * * ```js - * const { List, Map } = require('immutable@4.0.0-rc.6') + * const { List, Map } = require('immutable@4.0.0-rc.7') * const listOfMaps = List([ * Map({ v: 0 }), * Map({ v: 1 }), @@ -4316,7 +4316,7 @@ * * * ```js - * const { List } = require('immutable@4.0.0-rc.6') + * const { List } = require('immutable@4.0.0-rc.7') * List([ 'dog', 'frog', 'cat', 'hat', 'god' ]) * .skipWhile(x => x.match(/g/)) * // List [ "cat", "hat", "god"" ] @@ -4333,7 +4333,7 @@ * * * ```js - * const { List } = require('immutable@4.0.0-rc.6') + * const { List } = require('immutable@4.0.0-rc.7') * List([ 'dog', 'frog', 'cat', 'hat', 'god' ]) * .skipUntil(x => x.match(/hat/)) * // List [ "hat", "god"" ] @@ -4362,7 +4362,7 @@ * * * ```js - * const { List } = require('immutable@4.0.0-rc.6') + * const { List } = require('immutable@4.0.0-rc.7') * List([ 'dog', 'frog', 'cat', 'hat', 'god' ]) * .takeWhile(x => x.match(/o/)) * // List [ "dog", "frog" ] @@ -4379,7 +4379,7 @@ * * * ```js - * const { List } = require('immutable@4.0.0-rc.6') + * const { List } = require('immutable@4.0.0-rc.7') * List([ 'dog', 'frog', 'cat', 'hat', 'god' ]) * .takeUntil(x => x.match(/at/)) * // List [ "dog", "frog" ] diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index 297050ec3c..bf3de10a7d 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -118,7 +118,7 @@ declare module Immutable { * * * ```js - * const { fromJS, isKeyed } = require('immutable@4.0.0-rc.6') + * const { fromJS, isKeyed } = require('immutable@4.0.0-rc.7') * function (key, value) { * return isKeyed(value) ? value.Map() : value.toList() * } @@ -132,7 +132,7 @@ declare module Immutable { * * * ```js - * const { fromJS, isKeyed } = require('immutable@4.0.0-rc.6') + * const { fromJS, isKeyed } = require('immutable@4.0.0-rc.7') * fromJS({ a: {b: [10, 20, 30]}, c: 40}, function (key, value, path) { * console.log(key, value, path) * return isKeyed(value) ? value.toOrderedMap() : value.toList() @@ -149,7 +149,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.6') + * const { Map } = require('immutable@4.0.0-rc.7') * let obj = { 1: "one" }; * Object.keys(obj); // [ "1" ] * assert.equal(obj["1"], obj[1]); // "one" === "one" @@ -185,7 +185,7 @@ declare module Immutable { * * * ```js - * const { Map, is } = require('immutable@4.0.0-rc.6') + * const { Map, is } = require('immutable@4.0.0-rc.7') * const map1 = Map({ a: 1, b: 1, c: 1 }) * const map2 = Map({ a: 1, b: 1, c: 1 }) * assert.equal(map1 !== map2, true) @@ -232,7 +232,7 @@ declare module Immutable { * * * ```js - * const { isImmutable, Map, List, Stack } = require('immutable@4.0.0-rc.6'); + * const { isImmutable, Map, List, Stack } = require('immutable@4.0.0-rc.7'); * isImmutable([]); // false * isImmutable({}); // false * isImmutable(Map()); // true @@ -248,7 +248,7 @@ declare module Immutable { * * * ```js - * const { isCollection, Map, List, Stack } = require('immutable@4.0.0-rc.6'); + * const { isCollection, Map, List, Stack } = require('immutable@4.0.0-rc.7'); * isCollection([]); // false * isCollection({}); // false * isCollection(Map()); // true @@ -263,7 +263,7 @@ declare module Immutable { * * * ```js - * const { isKeyed, Map, List, Stack } = require('immutable@4.0.0-rc.6'); + * const { isKeyed, Map, List, Stack } = require('immutable@4.0.0-rc.7'); * isKeyed([]); // false * isKeyed({}); // false * isKeyed(Map()); // true @@ -278,7 +278,7 @@ declare module Immutable { * * * ```js - * const { isIndexed, Map, List, Stack, Set } = require('immutable@4.0.0-rc.6'); + * const { isIndexed, Map, List, Stack, Set } = require('immutable@4.0.0-rc.7'); * isIndexed([]); // false * isIndexed({}); // false * isIndexed(Map()); // false @@ -294,7 +294,7 @@ declare module Immutable { * * * ```js - * const { isAssociative, Map, List, Stack, Set } = require('immutable@4.0.0-rc.6'); + * const { isAssociative, Map, List, Stack, Set } = require('immutable@4.0.0-rc.7'); * isAssociative([]); // false * isAssociative({}); // false * isAssociative(Map()); // true @@ -311,7 +311,7 @@ declare module Immutable { * * * ```js - * const { isOrdered, Map, OrderedMap, List, Set } = require('immutable@4.0.0-rc.6'); + * const { isOrdered, Map, OrderedMap, List, Set } = require('immutable@4.0.0-rc.7'); * isOrdered([]); // false * isOrdered({}); // false * isOrdered(Map()); // false @@ -353,7 +353,7 @@ declare module Immutable { * * * ```js - * const { List, Set } = require('immutable@4.0.0-rc.6'); + * const { List, Set } = require('immutable@4.0.0-rc.7'); * const a = List([ 1, 2, 3 ]); * const b = List([ 1, 2, 3 ]); * assert.notStrictEqual(a, b); // different instances @@ -399,7 +399,7 @@ declare module Immutable { * * * ```js - * const { List } = require('immutable@4.0.0-rc.6'); + * const { List } = require('immutable@4.0.0-rc.7'); * List.isList([]); // false * List.isList(List()); // true * ``` @@ -411,7 +411,7 @@ declare module Immutable { * * * ```js - * const { List } = require('immutable@4.0.0-rc.6'); + * const { List } = require('immutable@4.0.0-rc.7'); * List.of(1, 2, 3, 4) * // List [ 1, 2, 3, 4 ] * ``` @@ -420,7 +420,7 @@ declare module Immutable { * * * ```js - * const { List } = require('immutable@4.0.0-rc.6'); + * const { List } = require('immutable@4.0.0-rc.7'); * List.of({x:1}, 2, [3], 4) * // List [ { x: 1 }, 2, [ 3 ], 4 ] * ``` @@ -434,7 +434,7 @@ declare module Immutable { * * * ```js - * const { List, Set } = require('immutable@4.0.0-rc.6') + * const { List, Set } = require('immutable@4.0.0-rc.7') * * const emptyList = List() * // List [] @@ -927,7 +927,7 @@ declare module Immutable { * * * ```js - * const { Map, List } = require('immutable@4.0.0-rc.6'); + * const { Map, List } = require('immutable@4.0.0-rc.7'); * Map().set(List([ 1 ]), 'listofone').get(List([ 1 ])); * // 'listofone' * ``` @@ -945,7 +945,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.6') + * const { Map } = require('immutable@4.0.0-rc.7') * Map.isMap({}) // false * Map.isMap(Map()) // true * ``` @@ -957,7 +957,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.6') + * const { Map } = require('immutable@4.0.0-rc.7') * Map.of( * 'key', 'value', * 'numerical value', 3, @@ -979,7 +979,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.6') + * const { Map } = require('immutable@4.0.0-rc.7') * Map({ key: "value" }) * Map([ [ "key", "value" ] ]) * ``` @@ -1025,7 +1025,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.6') + * const { Map } = require('immutable@4.0.0-rc.7') * const originalMap = Map() * const newerMap = originalMap.set('key', 'value') * const newestMap = newerMap.set('key', 'newer value') @@ -1050,7 +1050,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.6') + * const { Map } = require('immutable@4.0.0-rc.7') * const originalMap = Map({ * key: 'value', * otherKey: 'other value' @@ -1072,7 +1072,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.6') + * const { Map } = require('immutable@4.0.0-rc.7') * const names = Map({ a: "Aaron", b: "Barry", c: "Connor" }) * names.deleteAll([ 'a', 'c' ]) * // Map { "b": "Barry" } @@ -1090,7 +1090,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.6') + * const { Map } = require('immutable@4.0.0-rc.7') * Map({ key: 'value' }).clear() * // Map {} * ``` @@ -1107,7 +1107,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.6') + * const { Map } = require('immutable@4.0.0-rc.7') * const aMap = Map({ key: 'value' }) * const newMap = aMap.update('key', value => value + value) * // Map { "key": "valuevalue" } @@ -1215,7 +1215,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.6') + * const { Map } = require('immutable@4.0.0-rc.7') * const one = Map({ a: 10, b: 20, c: 30 }) * const two = Map({ b: 40, a: 50, d: 60 }) * one.merge(two) // Map { "a": 50, "b": 40, "c": 30, "d": 60 } @@ -1233,7 +1233,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.6') + * const { Map } = require('immutable@4.0.0-rc.7') * const one = Map({ a: 10, b: 20, c: 30 }) * const two = Map({ b: 40, a: 50, d: 60 }) * one.mergeWith((oldVal, newVal) => oldVal / newVal, two) @@ -1259,7 +1259,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.6') + * const { Map } = require('immutable@4.0.0-rc.7') * const one = Map({ a: Map({ x: 10, y: 10 }), b: Map({ x: 20, y: 50 }) }) * const two = Map({ a: Map({ x: 2 }), b: Map({ y: 5 }), c: Map({ z: 3 }) }) * one.mergeDeep(two) @@ -1280,7 +1280,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.6') + * const { Map } = require('immutable@4.0.0-rc.7') * const one = Map({ a: Map({ x: 10, y: 10 }), b: Map({ x: 20, y: 50 }) }) * const two = Map({ a: Map({ x: 2 }), b: Map({ y: 5 }), c: Map({ z: 3 }) }) * one.mergeDeepWith((oldVal, newVal) => oldVal / newVal, two) @@ -1307,7 +1307,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.6') + * const { Map } = require('immutable@4.0.0-rc.7') * const originalMap = Map({ * subObject: Map({ * subKey: 'subvalue', @@ -1365,7 +1365,7 @@ declare module Immutable { * * * ```js - * const { Map, List } = require('immutable@4.0.0-rc.6') + * const { Map, List } = require('immutable@4.0.0-rc.7') * const map = Map({ inMap: Map({ inList: List([ 1, 2, 3 ]) }) }) * const newMap = map.updateIn(['inMap', 'inList'], list => list.push(4)) * // Map { "inMap": Map { "inList": List [ 1, 2, 3, 4 ] } } @@ -1377,7 +1377,7 @@ declare module Immutable { * provided, otherwise `undefined`. * * * ```js * const map = Map({ a: Map({ b: Map({ c: 10 }) }) }) @@ -1389,7 +1389,7 @@ declare module Immutable { * no change will occur. This is still true if `notSetValue` is provided. * * * ```js * const map = Map({ a: Map({ b: Map({ c: 10 }) }) }) @@ -1405,7 +1405,7 @@ declare module Immutable { * The previous example behaves differently when written with default values: * * * ```js * const map = Map({ a: Map({ b: Map({ c: 10 }) }) }) @@ -1464,7 +1464,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.6') + * const { Map } = require('immutable@4.0.0-rc.7') * const map1 = Map() * const map2 = map1.withMutations(map => { * map.set('a', 1).set('b', 2).set('c', 3) @@ -1735,7 +1735,7 @@ declare module Immutable { * a collection of other sets. * * ```js - * const { Set } = require('immutable@4.0.0-rc.6') + * const { Set } = require('immutable@4.0.0-rc.7') * const intersected = Set.intersect([ * Set([ 'a', 'b', 'c' ]) * Set([ 'c', 'a', 't' ]) @@ -1750,7 +1750,7 @@ declare module Immutable { * collection of other sets. * * ```js - * const { Set } = require('immutable@4.0.0-rc.6') + * const { Set } = require('immutable@4.0.0-rc.7') * const unioned = Set.union([ * Set([ 'a', 'b', 'c' ]) * Set([ 'c', 'a', 't' ]) @@ -2317,7 +2317,7 @@ declare module Immutable { * infinity. When `start` is equal to `end`, returns empty range. * * ```js - * const { Range } = require('immutable@4.0.0-rc.6') + * const { Range } = require('immutable@4.0.0-rc.7') * Range() // [ 0, 1, 2, 3, ... ] * Range(10) // [ 10, 11, 12, 13, ... ] * Range(10, 15) // [ 10, 11, 12, 13, 14 ] @@ -2334,7 +2334,7 @@ declare module Immutable { * not defined, returns an infinite `Seq` of `value`. * * ```js - * const { Repeat } = require('immutable@4.0.0-rc.6') + * const { Repeat } = require('immutable@4.0.0-rc.7') * Repeat('foo') // [ 'foo', 'foo', 'foo', ... ] * Repeat('bar', 4) // [ 'bar', 'bar', 'bar', 'bar' ] * ``` @@ -2350,7 +2350,7 @@ declare module Immutable { * create Record instances. * * ```js - * const { Record } = require('immutable@4.0.0-rc.6') + * const { Record } = require('immutable@4.0.0-rc.7') * const ABRecord = Record({ a: 1, b: 2 }) * const myRecord = new ABRecord({ b: 3 }) * ``` @@ -2444,7 +2444,7 @@ declare module Immutable { * method. If one was not provided, the string "Record" is returned. * * ```js - * const { Record } = require('immutable@4.0.0-rc.6') + * const { Record } = require('immutable@4.0.0-rc.7') * const Person = Record({ * name: null * }, 'Person') @@ -2462,7 +2462,7 @@ declare module Immutable { * type: * * * ```js * // makePerson is a Record Factory function @@ -2477,7 +2477,7 @@ declare module Immutable { * access on the resulting instances: * * * ```js * // Use the Record API @@ -2649,7 +2649,7 @@ declare module Immutable { * Seq's values are never iterated: * * ```js - * const { Seq } = require('immutable@4.0.0-rc.6') + * const { Seq } = require('immutable@4.0.0-rc.7') * const oddSquares = Seq([ 1, 2, 3, 4, 5, 6, 7, 8 ]) * .filter(x => x % 2 !== 0) * .map(x => x * x) @@ -2677,7 +2677,7 @@ declare module Immutable { * As well as expressing logic that would otherwise be memory or time limited: * * ```js - * const { Range } = require('immutable@4.0.0-rc.6') + * const { Range } = require('immutable@4.0.0-rc.7') * Range(1, Infinity) * .skip(1000) * .map(n => -n) @@ -2756,7 +2756,7 @@ declare module Immutable { * `mapper` function. * * ```js - * const { Seq } = require('immutable@4.0.0-rc.6') + * const { Seq } = require('immutable@4.0.0-rc.7') * Seq.Keyed({ a: 1, b: 2 }).map(x => 10 * x) * // Seq { "a": 10, "b": 20 } * ``` @@ -2868,7 +2868,7 @@ declare module Immutable { * `mapper` function. * * ```js - * const { Seq } = require('immutable@4.0.0-rc.6') + * const { Seq } = require('immutable@4.0.0-rc.7') * Seq.Indexed([ 1, 2 ]).map(x => 10 * x) * // Seq [ 10, 20 ] * ``` @@ -3128,7 +3128,7 @@ declare module Immutable { * `mapper` function. * * ```js - * const { Seq } = require('immutable@4.0.0-rc.6') + * const { Seq } = require('immutable@4.0.0-rc.7') * Seq([ 1, 2 ]).map(x => 10 * x) * // Seq [ 10, 20 ] * ``` @@ -3146,7 +3146,7 @@ declare module Immutable { * `mapper` function. * * ```js - * const { Seq } = require('immutable@4.0.0-rc.6') + * const { Seq } = require('immutable@4.0.0-rc.7') * Seq([ 1, 2 ]).map(x => 10 * x) * // Seq [ 10, 20 ] * ``` @@ -3215,22 +3215,22 @@ declare module Immutable { export module Collection { /** - * @deprecated use `const { isKeyed } = require('immutable@4.0.0-rc.6')` + * @deprecated use `const { isKeyed } = require('immutable@4.0.0-rc.7')` */ function isKeyed(maybeKeyed: any): maybeKeyed is Collection.Keyed; /** - * @deprecated use `const { isIndexed } = require('immutable@4.0.0-rc.6')` + * @deprecated use `const { isIndexed } = require('immutable@4.0.0-rc.7')` */ function isIndexed(maybeIndexed: any): maybeIndexed is Collection.Indexed; /** - * @deprecated use `const { isAssociative } = require('immutable@4.0.0-rc.6')` + * @deprecated use `const { isAssociative } = require('immutable@4.0.0-rc.7')` */ function isAssociative(maybeAssociative: any): maybeAssociative is Collection.Keyed | Collection.Indexed; /** - * @deprecated use `const { isOrdered } = require('immutable@4.0.0-rc.6')` + * @deprecated use `const { isOrdered } = require('immutable@4.0.0-rc.7')` */ function isOrdered(maybeOrdered: any): boolean; @@ -3288,7 +3288,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.6') + * const { Map } = require('immutable@4.0.0-rc.7') * Map({ a: 'z', b: 'y' }).flip() * // Map { "z": "a", "y": "b" } * ``` @@ -3306,7 +3306,7 @@ declare module Immutable { * `mapper` function. * * ```js - * const { Collection } = require('immutable@4.0.0-rc.6') + * const { Collection } = require('immutable@4.0.0-rc.7') * Collection.Keyed({ a: 1, b: 2 }).map(x => 10 * x) * // Seq { "a": 10, "b": 20 } * ``` @@ -3325,7 +3325,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.6') + * const { Map } = require('immutable@4.0.0-rc.7') * Map({ a: 1, b: 2 }).mapKeys(x => x.toUpperCase()) * // Map { "A": 1, "B": 2 } * ``` @@ -3344,7 +3344,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.6') + * const { Map } = require('immutable@4.0.0-rc.7') * Map({ a: 1, b: 2 }) * .mapEntries(([ k, v ]) => [ k.toUpperCase(), v * 2 ]) * // Map { "A": 2, "B": 4 } @@ -3470,10 +3470,10 @@ declare module Immutable { * second from each, etc. * * * ```js - * const { List } = require('immutable@4.0.0-rc.6') + * const { List } = require('immutable@4.0.0-rc.7') * List([ 1, 2, 3 ]).interleave(List([ 'A', 'B', 'C' ])) * // List [ 1, "A", 2, "B", 3, "C"" ] * ``` @@ -3481,7 +3481,7 @@ declare module Immutable { * The shortest Collection stops interleave. * * * ```js * List([ 1, 2, 3 ]).interleave( @@ -3503,7 +3503,7 @@ declare module Immutable { * * * ```js - * const { List } = require('immutable@4.0.0-rc.6') + * const { List } = require('immutable@4.0.0-rc.7') * List([ 'a', 'b', 'c', 'd' ]).splice(1, 2, 'q', 'r', 's') * // List [ "a", "q", "r", "s", "d" ] * ``` @@ -3522,7 +3522,7 @@ declare module Immutable { * * * * ```js * const a = List([ 1, 2, 3 ]); @@ -3555,7 +3555,7 @@ declare module Immutable { * collections by using a custom `zipper` function. * * * ```js * const a = List([ 1, 2, 3 ]); @@ -3623,7 +3623,7 @@ declare module Immutable { * `mapper` function. * * ```js - * const { Collection } = require('immutable@4.0.0-rc.6') + * const { Collection } = require('immutable@4.0.0-rc.7') * Collection.Indexed([1,2]).map(x => 10 * x) * // Seq [ 1, 2 ] * ``` @@ -3675,7 +3675,7 @@ declare module Immutable { * the value as both the first and second arguments to the provided function. * * ```js - * const { Collection } = require('immutable@4.0.0-rc.6') + * const { Collection } = require('immutable@4.0.0-rc.7') * const seq = Collection.Set([ 'A', 'B', 'C' ]) * // Seq { "A", "B", "C" } * seq.forEach((v, k) => @@ -3807,7 +3807,7 @@ declare module Immutable { * lookup via a different instance. * * * ```js * const a = List([ 1, 2, 3 ]); @@ -3888,7 +3888,7 @@ declare module Immutable { * * * ```js - * const { Seq } = require('immutable@4.0.0-rc.6') + * const { Seq } = require('immutable@4.0.0-rc.7') * * function sum(collection) { * return collection.reduce((sum, x) => sum + x, 0) @@ -3984,7 +3984,7 @@ declare module Immutable { * * * ```js - * const { Map, List } = require('immutable@4.0.0-rc.6') + * const { Map, List } = require('immutable@4.0.0-rc.7') * var myMap = Map({ a: 'Apple', b: 'Banana' }) * List(myMap) // List [ [ "a", "Apple" ], [ "b", "Banana" ] ] * myMap.toList() // List [ "Apple", "Banana" ] @@ -4021,7 +4021,7 @@ declare module Immutable { * * * ```js - * const { Seq } = require('immutable@4.0.0-rc.6') + * const { Seq } = require('immutable@4.0.0-rc.7') * const indexedSeq = Seq([ 'A', 'B', 'C' ]) * // Seq [ "A", "B", "C" ] * indexedSeq.filter(v => v === 'B') @@ -4102,7 +4102,7 @@ declare module Immutable { * * * ```js - * const { Collection } = require('immutable@4.0.0-rc.6') + * const { Collection } = require('immutable@4.0.0-rc.7') * Collection({ a: 1, b: 2 }).map(x => 10 * x) * // Seq { "a": 10, "b": 20 } * ``` @@ -4129,7 +4129,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.6') + * const { Map } = require('immutable@4.0.0-rc.7') * Map({ a: 1, b: 2, c: 3, d: 4}).filter(x => x % 2 === 0) * // Map { "b": 2, "d": 4 } * ``` @@ -4152,7 +4152,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.6') + * const { Map } = require('immutable@4.0.0-rc.7') * Map({ a: 1, b: 2, c: 3, d: 4}).filterNot(x => x % 2 === 0) * // Map { "a": 1, "c": 3 } * ``` @@ -4189,7 +4189,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.6') + * const { Map } = require('immutable@4.0.0-rc.7') * Map({ "c": 3, "a": 1, "b": 2 }).sort((a, b) => { * if (a < b) { return -1; } * if (a > b) { return 1; } @@ -4229,7 +4229,7 @@ declare module Immutable { * * * ```js - * const { List, Map } = require('immutable@4.0.0-rc.6') + * const { List, Map } = require('immutable@4.0.0-rc.7') * const listOfMaps = List([ * Map({ v: 0 }), * Map({ v: 1 }), @@ -4316,7 +4316,7 @@ declare module Immutable { * * * ```js - * const { List } = require('immutable@4.0.0-rc.6') + * const { List } = require('immutable@4.0.0-rc.7') * List([ 'dog', 'frog', 'cat', 'hat', 'god' ]) * .skipWhile(x => x.match(/g/)) * // List [ "cat", "hat", "god"" ] @@ -4333,7 +4333,7 @@ declare module Immutable { * * * ```js - * const { List } = require('immutable@4.0.0-rc.6') + * const { List } = require('immutable@4.0.0-rc.7') * List([ 'dog', 'frog', 'cat', 'hat', 'god' ]) * .skipUntil(x => x.match(/hat/)) * // List [ "hat", "god"" ] @@ -4362,7 +4362,7 @@ declare module Immutable { * * * ```js - * const { List } = require('immutable@4.0.0-rc.6') + * const { List } = require('immutable@4.0.0-rc.7') * List([ 'dog', 'frog', 'cat', 'hat', 'god' ]) * .takeWhile(x => x.match(/o/)) * // List [ "dog", "frog" ] @@ -4379,7 +4379,7 @@ declare module Immutable { * * * ```js - * const { List } = require('immutable@4.0.0-rc.6') + * const { List } = require('immutable@4.0.0-rc.7') * List([ 'dog', 'frog', 'cat', 'hat', 'god' ]) * .takeUntil(x => x.match(/at/)) * // List [ "dog", "frog" ] diff --git a/dist/immutable.es.js b/dist/immutable.es.js index 950b267b29..79da1acdac 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -5510,7 +5510,7 @@ function isPlainObj(value) { ); } -var version = "4.0.0-rc.6"; +var version = "4.0.0-rc.7"; var Immutable = { version: version, diff --git a/dist/immutable.js b/dist/immutable.js index 29e2606a06..b7c4a440e7 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -5516,7 +5516,7 @@ function isPlainObj(value) { ); } -var version = "4.0.0-rc.6"; +var version = "4.0.0-rc.7"; var Immutable = { version: version, diff --git a/dist/immutable.min.js b/dist/immutable.min.js index b811e8b604..a5fafeef58 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -34,4 +34,4 @@ getIn:function(t,e){return ye(this,e,t,!0)},groupBy:function(t,e){return H(this, $r.toJSON=Zr.toObject,$r.__toStringMapper=function(t,e){return _t(e)+": "+_t(t)},$t(We,{toKeyedSeq:function(){return new dr(this,!1)},filter:function(t,e){return it(this,P(this,t,e,!1))},findIndex:function(t,e){var r=this.findEntry(t,e);return r?r[0]:-1},indexOf:function(t){var e=this.keyOf(t);return void 0===e?-1:e},lastIndexOf:function(t){var e=this.lastKeyOf(t);return void 0===e?-1:e},reverse:function(){return it(this,N(this,!1))},slice:function(t,e){return it(this,Y(this,t,e,!1))},splice:function(t,e){var r=arguments.length;if(e=Math.max(e||0,0),0===r||2===r&&!e)return this;t=c(t,t<0?this.count():this.size);var n=this.slice(0,t);return it(this,1===r?n:n.concat(i(arguments,2),this.slice(t+e)))},findLastIndex:function(t,e){var r=this.findLastEntry(t,e);return r?r[0]:-1},first:function(){return this.get(0)},flatten:function(t){return it(this,G(this,t,!1))},get:function(t,e){return t=u(this,t),t<0||this.size===1/0||void 0!==this.size&&t>this.size?e:this.find(function(e,r){return r===t},void 0,e)},has:function(t){return(t=u(this,t))>=0&&(void 0!==this.size?this.size===1/0||t Date: Tue, 10 Oct 2017 02:24:54 +0000 Subject: [PATCH 052/242] Deploy 7b7dba90d0bba84a7d6da719ab6f3d636c8a4125 to NPM branch --- dist/immutable.es.js | 4 ++++ dist/immutable.js | 4 ++++ dist/immutable.min.js | 6 +++--- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/dist/immutable.es.js b/dist/immutable.es.js index 79da1acdac..e9699623f9 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -5071,6 +5071,10 @@ function getIn(value, notSetValue, searchKeyPath, reportBadKeyPath) { var keyPath = coerceKeyPath(searchKeyPath); var i = 0; while (i !== keyPath.length) { + // Intermediate null/undefined value along path + if (value == null) { + return notSetValue; + } if (!value || !value.get) { if (reportBadKeyPath) { warn( diff --git a/dist/immutable.js b/dist/immutable.js index b7c4a440e7..036388e211 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -5077,6 +5077,10 @@ function getIn(value, notSetValue, searchKeyPath, reportBadKeyPath) { var keyPath = coerceKeyPath(searchKeyPath); var i = 0; while (i !== keyPath.length) { + // Intermediate null/undefined value along path + if (value == null) { + return notSetValue; + } if (!value || !value.get) { if (reportBadKeyPath) { warn( diff --git a/dist/immutable.min.js b/dist/immutable.min.js index a5fafeef58..8839b21eb9 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -14,9 +14,9 @@ function lt(t){return!(!t||!t[zr])}function vt(t,e){return S(t,e[0],e[1])}functi ;return s===u?t:s}if(!(o||t&&t.set))throw new TypeError("Invalid keyPath: Value at ["+e.slice(0,r).map(_t)+"] does not have a .set() method and cannot be updated: "+t);var a=e[r],c=o?je:t.get(a,je),h=xt(c,e,r+1,n,i);return h===c?t:h===je?t.remove(a):(o?gt():t).set(a,h)}function jt(t){return t-=t>>1&1431655765,t=(858993459&t)+(t>>2&858993459),t=t+(t>>4)&252645135,t+=t>>8,127&(t+=t>>16)}function kt(t,e,r,n){var o=n?t:i(t);return o[e]=r,o}function At(t,e,r,n){var i=t.length+1;if(n&&e+1===i)return t[e]=r,t;for(var o=Array(i),u=0,s=0;so?0:o-r,c=u-r;return c>Ee&&(c=Ee),function(){if(i===c)return Cr;var t=e?--c:i++;return n&&n[t]}}function i(t,n,i){var s,a=t&&t.array,c=i>o?0:o-i>>n,h=1+(u-i>>n);return h>Ee&&(h=Ee),function(){for(;;){if(s){var t=s();if(t!==Cr)return t;s=null}if(c===h)return Cr;var o=e?--h:c++;s=r(a&&a[o],n-De,i+(o<=t.size||r<0)return t.withMutations(function(t){r<0?Nt(t,r).set(0,n):Nt(t,0,r+1).set(r,n)});r+=t._origin;var i=t._tail,o=t._root,s=e(Ae);return r>=Pt(t._capacity)?i=Bt(i,t.__ownerID,0,r,n,s):o=Bt(o,t.__ownerID,t._level,r,n,s),s.value?t.__ownerID?(t._root=o,t._tail=i,t.__hash=void 0,t.__altered=!0,t):Lt(t._origin,t._capacity,t._level,o,i):t}function Bt(t,e,n,i,o,u){var s=i>>>n&xe,a=t&&s0){var h=t&&t.array[s],f=Bt(h,e,n-De,i,o,u);return f===h?t:(c=Wt(t,e),c.array[s]=f,c)} return a&&t.array[s]===o?t:(r(u),c=Wt(t,e),void 0===o&&s===c.array.length-1?c.array.pop():c.array[s]=o,c)}function Wt(t,e){return e&&t&&e===t.ownerID?t:new Lr(t?t.array.slice():[],e)}function Jt(t,e){if(e>=Pt(t._capacity))return t._tail;if(e<1<0;)r=r.array[e>>>n&xe],n-=De;return r}}function Nt(t,e,r){void 0!==e&&(e|=0),void 0!==r&&(r|=0);var i=t.__ownerID||new n,o=t._origin,u=t._capacity,s=o+e,a=void 0===r?u:r<0?u+r:o+r;if(s===o&&a===u)return t;if(s>=a)return t.clear();for(var c=t._level,h=t._root,f=0;s+f<0;)h=new Lr(h&&h.array.length?[void 0,h]:[],i),c+=De,f+=1<=1<p?new Lr([],i):l;if(l&&_>p&&sDe;d-=De){var g=p>>>d&xe;y=y.array[g]=Wt(y.array[g],i)}y.array[p>>>De&xe]=l}if(a=_)s-=_,a-=_,c=De,h=null,v=v&&v.removeBefore(i,0,s);else if(s>o||_>>c&xe;if(m!==_>>>c&xe)break;m&&(f+=(1<o&&(h=h.removeBefore(i,c,s-f)),h&&_>>De<=Ee&&u.size>=2*o.size?(i=u.filter(function(t,e){return void 0!==t&&s!==e}),n=i.toKeyedSeq().map(function(t){return t[0]}).flip().toMap(),t.__ownerID&&(n.__ownerID=i.__ownerID=t.__ownerID)):(n=o.remove(e),i=s===u.size-1?u.pop():u.set(s,void 0))}else if(a){if(r===u.get(s)[1])return t;n=o,i=u.set(s,[e,r])}else n=o.set(e,u.size),i=u.set(u.size,[e,r]) ;return t.__ownerID?(t.size=n.size,t._map=n,t._list=i,t.__hash=void 0,t):Ht(n,i)}function Xt(t){return!(!t||!t[Nr])}function Ft(t,e,r,n){var i=Object.create(Pr);return i.size=t,i._head=e,i.__ownerID=r,i.__hash=n,i.__altered=!1,i}function Gt(){return Vr||(Vr=Ft(0))}function Zt(t,e){if(t===e)return!0;if(!l(e)||void 0!==t.size&&void 0!==e.size&&t.size!==e.size||void 0!==t.__hash&&void 0!==e.__hash&&t.__hash!==e.__hash||v(t)!==v(e)||y(t)!==y(e)||g(t)!==g(e))return!1;if(0===t.size&&0===e.size)return!0;var r=!d(t);if(g(t)){var n=t.entries();return e.every(function(t,e){var i=n.next().value;return i&&R(i[1],t)&&(r||R(i[0],e))})&&n.next().done}var i=!1;if(void 0===t.size)if(void 0===e.size)"function"==typeof t.cacheResult&&t.cacheResult();else{i=!0;var o=t;t=e,e=o}var u=!0,s=e.__iterate(function(e,n){if(r?!t.has(e):i?!R(e,t.get(n,je)):!R(t.get(n,je),e))return u=!1,!1});return u&&t.size===s}function $t(t,e){var r=function(r){t.prototype[r]=e[r]};return Object.keys(e).forEach(r),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(e).forEach(r),t}function te(t){return!(!t||!t[Yr])}function ee(t,e){return t.__ownerID?(t.size=e.size,t._map=e,t):e===t._map?t:0===e.size?t.__empty():t.__make(e)}function re(t,e){var r=Object.create(Qr);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function ne(){return Xr||(Xr=re(gt()))}function ie(t,e,r,n,i,o){return pt(t.size),t.__iterate(function(t,o,u){i?(i=!1,r=t):r=e.call(n,r,t,o,u)},o),r}function oe(t,e){return e}function ue(t,e){return[e,t]}function se(t){return t&&"function"==typeof t.toJS?t.toJS():t}function ae(t){return function(){return!t.apply(this,arguments)}}function ce(t){return function(){return-t.apply(this,arguments)}}function he(){return i(arguments)}function fe(t,e){return te?-1:0}function pe(t){if(t.size===1/0)return 0;var e=g(t),r=v(t),n=e?1:0;return _e(t.__iterate(r?e?function(t,e){n=31*n+le(K(t),K(e))|0}:function(t,e){n=n+le(K(t),K(e))|0}:e?function(t){n=31*n+K(t)|0}:function(t){n=n+K(t)|0}),n)}function _e(t,e){return e=sr(e,3432918353), -e=sr(e<<15|e>>>-15,461845907),e=sr(e<<13|e>>>-13,5),e=(e+3864292196|0)^t,e=sr(e^e>>>16,2246822507),e=sr(e^e>>>13,3266489909),e=U(e^e>>>16)}function le(t,e){return t^e+2654435769+(t<<6)+(t>>2)|0}function ve(t){if("object"!=typeof console||!console.warn)throw Error(t);console.warn(t)}function ye(t,e,r,n){for(var i=ht(r),o=0;o!==i.length;){if(!t||!t.get)return n&&ve("Invalid keyPath: Value at ["+i.slice(0,o).map(_t)+"] does not have a .get() method: "+t+"\nThis warning will throw in a future version"),e;if((t=t.get(i[o++],je))===je)return e}return t}function de(t){return te(t)&&g(t)}function ge(t,e){var r=Object.create(rn);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function me(){return nn||(nn=ge(Yt()))}function we(t,e,r){var n=Object.create(Object.getPrototypeOf(t));return n._values=e,n.__ownerID=r,n}function Se(t){return t._name||t.constructor.name||"Record"}function ze(t){return x(t._keys.map(function(e){return[e,t.get(e)]}))}function Ie(t,e){try{Object.defineProperty(t,e,{get:function(){return this.get(e)},set:function(t){ft(this.__ownerID,"Cannot set on an immutable record."),this.set(e,t)}})}catch(t){}}function be(t,e){return Oe([],e||Me,t,"",e&&e.length>2?[]:void 0,{"":t})}function Oe(t,e,r,n,i,o){var u=Array.isArray(r)?Ze:qe(r)?Ge:null;if(u){if(~t.indexOf(r))throw new TypeError("Cannot convert circular structure to Immutable");t.push(r),i&&""!==n&&i.push(n);var s=e.call(o,n,u(r).map(function(n,o){return Oe(t,e,n,o,i,r)}),i&&i.slice());return t.pop(),i&&i.pop(),s}return r}function Me(t,e){return v(e)?e.toMap():e.toList()}function qe(t){return t&&(t.constructor===Object||void 0===t.constructor)}var De=5,Ee=1<>>-15,461845907),e=sr(e<<13|e>>>-13,5),e=(e+3864292196|0)^t,e=sr(e^e>>>16,2246822507),e=sr(e^e>>>13,3266489909),e=U(e^e>>>16)}function le(t,e){return t^e+2654435769+(t<<6)+(t>>2)|0}function ve(t){if("object"!=typeof console||!console.warn)throw Error(t);console.warn(t)}function ye(t,e,r,n){for(var i=ht(r),o=0;o!==i.length;){if(null==t)return e;if(!t||!t.get)return n&&ve("Invalid keyPath: Value at ["+i.slice(0,o).map(_t)+"] does not have a .get() method: "+t+"\nThis warning will throw in a future version"),e;if((t=t.get(i[o++],je))===je)return e}return t}function de(t){return te(t)&&g(t)}function ge(t,e){var r=Object.create(rn);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function me(){return nn||(nn=ge(Yt()))}function we(t,e,r){var n=Object.create(Object.getPrototypeOf(t));return n._values=e,n.__ownerID=r,n}function Se(t){return t._name||t.constructor.name||"Record"}function ze(t){return x(t._keys.map(function(e){return[e,t.get(e)]}))}function Ie(t,e){try{Object.defineProperty(t,e,{get:function(){return this.get(e)},set:function(t){ft(this.__ownerID,"Cannot set on an immutable record."),this.set(e,t)}})}catch(t){}}function be(t,e){return Oe([],e||Me,t,"",e&&e.length>2?[]:void 0,{"":t})}function Oe(t,e,r,n,i,o){var u=Array.isArray(r)?Ze:qe(r)?Ge:null;if(u){if(~t.indexOf(r))throw new TypeError("Cannot convert circular structure to Immutable");t.push(r),i&&""!==n&&i.push(n);var s=e.call(o,n,u(r).map(function(n,o){return Oe(t,e,n,o,i,r)}),i&&i.slice());return t.pop(),i&&i.pop(),s}return r}function Me(t,e){return v(e)?e.toMap():e.toList()}function qe(t){return t&&(t.constructor===Object||void 0===t.constructor)}var De=5,Ee=1<=n.length){var e=r.next();if(e.done)return e;n[i]=e.value}return S(t,i,n[i++])})},e}(Ze),sr="function"==typeof Math.imul&&Math.imul(4294967295,2)===-2?Math.imul:function(t,e){t|=0,e|=0;var r=65535&t,n=65535&e;return r*n+((t>>>16)*n+r*(e>>>16)<<16>>>0)|0},ar=Object.isExtensible,cr=function(){try{return Object.defineProperty({},"@",{}),!0}catch(t){return!1}}(),hr="function"==typeof WeakMap;hr&&(ir=new WeakMap);var fr=0,pr="__immutablehash__";"function"==typeof Symbol&&(pr=Symbol(pr));var _r=16,lr=255,vr=0,yr={},dr=function(t){function e(t,e){this._iter=t,this._useKeys=e,this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t,e){return this._iter.get(t,e)},e.prototype.has=function(t){return this._iter.has(t)},e.prototype.valueSeq=function(){return this._iter.valueSeq()},e.prototype.reverse=function(){var t=this,e=N(this,!0);return this._useKeys||(e.valueSeq=function(){return t._iter.toSeq().reverse()}),e},e.prototype.map=function(t,e){var r=this,n=J(this,t,e);return this._useKeys||(n.valueSeq=function(){ return r._iter.toSeq().map(t,e)}),n},e.prototype.__iterate=function(t,e){var r=this;return this._iter.__iterate(function(e,n){return t(e,n,r)},e)},e.prototype.__iterator=function(t,e){return this._iter.__iterator(t,e)},e}(Ge);dr.prototype[Le]=!0;var gr=function(t){function e(t){this._iter=t,this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.includes=function(t){return this._iter.includes(t)},e.prototype.__iterate=function(t,e){var r=this,n=0;return e&&o(this),this._iter.__iterate(function(i){return t(i,e?r.size-++n:n++,r)},e)},e.prototype.__iterator=function(t,e){var r=this,n=this._iter.__iterator(Pe,e),i=0;return e&&o(this),new Xe(function(){var o=n.next();return o.done?o:S(t,e?r.size-++i:i++,o.value,o)})},e}(Ze),mr=function(t){function e(t){this._iter=t,this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.has=function(t){return this._iter.includes(t)},e.prototype.__iterate=function(t,e){var r=this;return this._iter.__iterate(function(e){return t(e,e,r)},e)},e.prototype.__iterator=function(t,e){var r=this._iter.__iterator(Pe,e);return new Xe(function(){var e=r.next();return e.done?e:S(t,e.value,e.value,e)})},e}($e),wr=function(t){function e(t){this._iter=t,this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.entrySeq=function(){return this._iter.toSeq()},e.prototype.__iterate=function(t,e){var r=this;return this._iter.__iterate(function(e){if(e){ot(e);var n=l(e);return t(n?e.get(1):e[1],n?e.get(0):e[0],r)}},e)},e.prototype.__iterator=function(t,e){var r=this._iter.__iterator(Pe,e);return new Xe(function(){for(;;){var e=r.next();if(e.done)return e;var n=e.value;if(n){ot(n);var i=l(n);return S(t,i?n.get(0):n[0],i?n.get(1):n[1],e)}}})},e}(Ge);gr.prototype.cacheResult=dr.prototype.cacheResult=mr.prototype.cacheResult=wr.prototype.cacheResult=at;var Sr=function(t){function e(e){ return null===e||void 0===e?gt():lt(e)&&!g(e)?e:gt().withMutations(function(r){var n=t(e);pt(n.size),n.forEach(function(t,e){return r.set(e,t)})})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return gt().withMutations(function(e){for(var r=0;r=t.length)throw Error("Missing value for key: "+t[r]);e.set(t[r],t[r+1])}})},e.prototype.toString=function(){return this.__toString("Map {","}")},e.prototype.get=function(t,e){return this._root?this._root.get(0,void 0,t,e):e},e.prototype.set=function(t,e){return mt(this,t,e)},e.prototype.setIn=function(t,e){return this.updateIn(t,je,function(){return e})},e.prototype.remove=function(t){return mt(this,t,je)},e.prototype.deleteIn=function(t){if(t=[].concat(ht(t)),t.length){var e=t.pop();return this.updateIn(t,function(t){return t&&t.remove(e)})}},e.prototype.deleteAll=function(t){var e=Ce(t);return 0===e.size?this:this.withMutations(function(t){e.forEach(function(e){return t.remove(e)})})},e.prototype.update=function(t,e,r){return 1===arguments.length?t(this):this.updateIn([t],e,r)},e.prototype.updateIn=function(t,e,r){r||(r=e,e=void 0);var n=xt(this,ht(t),0,e,r);return n===je?e:n},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):gt()},e.prototype.merge=function(){return Mt(this,void 0,arguments)},e.prototype.mergeWith=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Mt(this,t,e)},e.prototype.mergeIn=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return this.updateIn(t,gt(),function(t){return"function"==typeof t.merge?t.merge.apply(t,e):e[e.length-1]})},e.prototype.mergeDeep=function(){return Mt(this,Dt(qt),arguments)},e.prototype.mergeDeepWith=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Mt(this,Dt(t),e)},e.prototype.mergeDeepIn=function(t){ From 21fe037f3ed62c3756496aabb50fb55292e9f29b Mon Sep 17 00:00:00 2001 From: Travis CI Date: Wed, 11 Oct 2017 02:00:13 +0000 Subject: [PATCH 053/242] Deploy 550ba5ccc9a2a03bb686e7cfce41dfe7b6d6ae59 to NPM branch --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ae4f9b236b..ab155b3078 100644 --- a/README.md +++ b/README.md @@ -88,7 +88,7 @@ Use these Immutable collections and sequences as you would use native collections in your [Flowtype](https://flowtype.org/) or [TypeScript](http://typescriptlang.org) programs while still taking advantage of type generics, error detection, and auto-complete in your IDE. -Installing `immutable` via npm brings with it type definitions for Flow (v0.39.0 or higher) +Installing `immutable` via npm brings with it type definitions for Flow (v0.55.0 or higher) and TypeScript (v2.1.0 or higher), so you shouldn't need to do anything at all! #### Using TypeScript with Immutable.js v4 From f551acd1693f956e2e5b21145d3bd31e434f261e Mon Sep 17 00:00:00 2001 From: Travis CI Date: Wed, 11 Oct 2017 02:18:04 +0000 Subject: [PATCH 054/242] Deploy c1656b1e74b6ab2a39a4b04f95f3f422117ad13f to NPM branch --- dist/immutable-nonambient.d.ts | 75 ++++++++++++++++++++++------------ dist/immutable.d.ts | 75 ++++++++++++++++++++++------------ dist/immutable.es.js | 30 ++++++++++++-- dist/immutable.js | 30 ++++++++++++-- dist/immutable.js.flow | 22 +++++----- dist/immutable.min.js | 50 +++++++++++------------ 6 files changed, 187 insertions(+), 95 deletions(-) diff --git a/dist/immutable-nonambient.d.ts b/dist/immutable-nonambient.d.ts index 4e8c893fde..90de274d6f 100644 --- a/dist/immutable-nonambient.d.ts +++ b/dist/immutable-nonambient.d.ts @@ -787,7 +787,7 @@ /** * Returns a new List with other values or collections concatenated to this one. * - * Note: `concat` *cannot* be safely used in `withMutations`. + * Note: `concat` can be used in `withMutations`. * * @alias merge */ @@ -1223,8 +1223,13 @@ * ``` * * Note: `merge` can be used in `withMutations`. + * + * @alias concat */ - merge(...collections: Array | {[key: string]: V}>): this; + merge(...collections: Array>): Map; + merge(...collections: Array<{[key: string]: C}>): Map; + concat(...collections: Array>): Map; + concat(...collections: Array<{[key: string]: C}>): Map; /** * Like `merge()`, `mergeWith()` returns a new Map resulting from merging @@ -1512,12 +1517,6 @@ // Sequence algorithms - /** - * Returns a new Map with other collections concatenated to this one. - */ - concat(...collections: Array>): Map; - concat(...collections: Array<{[key: string]: C}>): Map; - /** * Returns a new Map with values passed through a * `mapper` function. @@ -1628,14 +1627,34 @@ */ readonly size: number; - // Sequence algorithms - /** - * Returns a new OrderedMap with other collections concatenated to this one. + * Returns a new OrderedMap resulting from merging the provided Collections + * (or JS objects) into this OrderedMap. In other words, this takes each + * entry of each collection and sets it on this OrderedMap. + * + * Note: Values provided to `merge` are shallowly converted before being + * merged. No nested values are altered. + * + * + * ```js + * const { OrderedMap } = require('immutable@4.0.0-rc.7') + * const one = OrderedMap({ a: 10, b: 20, c: 30 }) + * const two = OrderedMap({ b: 40, a: 50, d: 60 }) + * one.merge(two) // OrderedMap { "a": 50, "b": 40, "c": 30, "d": 60 } + * two.merge(one) // OrderedMap { "b": 20, "a": 10, "d": 60, "c": 30 } + * ``` + * + * Note: `merge` can be used in `withMutations`. + * + * @alias concat */ + merge(...collections: Array>): OrderedMap; + merge(...collections: Array<{[key: string]: C}>): OrderedMap; concat(...collections: Array>): OrderedMap; concat(...collections: Array<{[key: string]: C}>): OrderedMap; + // Sequence algorithms + /** * Returns a new OrderedMap with values passed through a * `mapper` function. @@ -1811,9 +1830,11 @@ * * Note: `union` can be used in `withMutations`. * @alias merge + * @alias concat */ - union(...collections: Array>): this; - merge(...collections: Array>): this; + union(...collections: Array>): Set; + merge(...collections: Array>): Set; + concat(...collections: Array>): Set; /** * Returns a Set which has removed any values not also contained @@ -1821,14 +1842,14 @@ * * Note: `intersect` can be used in `withMutations`. */ - intersect(...collections: Array | Array>): this; + intersect(...collections: Array>): this; /** * Returns a Set excluding any values contained within `collections`. * * Note: `subtract` can be used in `withMutations`. */ - subtract(...collections: Array | Array>): this; + subtract(...collections: Array>): this; // Transient changes @@ -1863,11 +1884,6 @@ // Sequence algorithms - /** - * Returns a new Set with other collections concatenated to this one. - */ - concat(...valuesOrCollections: Array | C>): Set; - /** * Returns a new Set with values passed through a * `mapper` function. @@ -1956,12 +1972,19 @@ */ readonly size: number; - // Sequence algorithms - /** - * Returns a new OrderedSet with other collections concatenated to this one. + * Returns an OrderedSet including any value from `collections` that does + * not already exist in this OrderedSet. + * + * Note: `union` can be used in `withMutations`. + * @alias merge + * @alias concat */ - concat(...valuesOrCollections: Array | C>): OrderedSet; + union(...collections: Array>): OrderedSet; + merge(...collections: Array>): OrderedSet; + concat(...collections: Array>): OrderedSet; + + // Sequence algorithms /** * Returns a new Set with values passed through a @@ -3013,7 +3036,7 @@ * All entries will be present in the resulting Seq, even if they * are duplicates. */ - concat(...valuesOrCollections: Array | C>): Seq.Set; + concat(...collections: Array>): Seq.Set; /** * Returns a new Seq.Set with values passed through a @@ -3717,7 +3740,7 @@ /** * Returns a new Collection with other collections concatenated to this one. */ - concat(...valuesOrCollections: Array | C>): Collection.Set; + concat(...collections: Array>): Collection.Set; /** * Returns a new Collection.Set with values passed through a diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index bf3de10a7d..e9900c67b4 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -787,7 +787,7 @@ declare module Immutable { /** * Returns a new List with other values or collections concatenated to this one. * - * Note: `concat` *cannot* be safely used in `withMutations`. + * Note: `concat` can be used in `withMutations`. * * @alias merge */ @@ -1223,8 +1223,13 @@ declare module Immutable { * ``` * * Note: `merge` can be used in `withMutations`. + * + * @alias concat */ - merge(...collections: Array | {[key: string]: V}>): this; + merge(...collections: Array>): Map; + merge(...collections: Array<{[key: string]: C}>): Map; + concat(...collections: Array>): Map; + concat(...collections: Array<{[key: string]: C}>): Map; /** * Like `merge()`, `mergeWith()` returns a new Map resulting from merging @@ -1512,12 +1517,6 @@ declare module Immutable { // Sequence algorithms - /** - * Returns a new Map with other collections concatenated to this one. - */ - concat(...collections: Array>): Map; - concat(...collections: Array<{[key: string]: C}>): Map; - /** * Returns a new Map with values passed through a * `mapper` function. @@ -1628,14 +1627,34 @@ declare module Immutable { */ readonly size: number; - // Sequence algorithms - /** - * Returns a new OrderedMap with other collections concatenated to this one. + * Returns a new OrderedMap resulting from merging the provided Collections + * (or JS objects) into this OrderedMap. In other words, this takes each + * entry of each collection and sets it on this OrderedMap. + * + * Note: Values provided to `merge` are shallowly converted before being + * merged. No nested values are altered. + * + * + * ```js + * const { OrderedMap } = require('immutable@4.0.0-rc.7') + * const one = OrderedMap({ a: 10, b: 20, c: 30 }) + * const two = OrderedMap({ b: 40, a: 50, d: 60 }) + * one.merge(two) // OrderedMap { "a": 50, "b": 40, "c": 30, "d": 60 } + * two.merge(one) // OrderedMap { "b": 20, "a": 10, "d": 60, "c": 30 } + * ``` + * + * Note: `merge` can be used in `withMutations`. + * + * @alias concat */ + merge(...collections: Array>): OrderedMap; + merge(...collections: Array<{[key: string]: C}>): OrderedMap; concat(...collections: Array>): OrderedMap; concat(...collections: Array<{[key: string]: C}>): OrderedMap; + // Sequence algorithms + /** * Returns a new OrderedMap with values passed through a * `mapper` function. @@ -1811,9 +1830,11 @@ declare module Immutable { * * Note: `union` can be used in `withMutations`. * @alias merge + * @alias concat */ - union(...collections: Array>): this; - merge(...collections: Array>): this; + union(...collections: Array>): Set; + merge(...collections: Array>): Set; + concat(...collections: Array>): Set; /** * Returns a Set which has removed any values not also contained @@ -1821,14 +1842,14 @@ declare module Immutable { * * Note: `intersect` can be used in `withMutations`. */ - intersect(...collections: Array | Array>): this; + intersect(...collections: Array>): this; /** * Returns a Set excluding any values contained within `collections`. * * Note: `subtract` can be used in `withMutations`. */ - subtract(...collections: Array | Array>): this; + subtract(...collections: Array>): this; // Transient changes @@ -1863,11 +1884,6 @@ declare module Immutable { // Sequence algorithms - /** - * Returns a new Set with other collections concatenated to this one. - */ - concat(...valuesOrCollections: Array | C>): Set; - /** * Returns a new Set with values passed through a * `mapper` function. @@ -1956,12 +1972,19 @@ declare module Immutable { */ readonly size: number; - // Sequence algorithms - /** - * Returns a new OrderedSet with other collections concatenated to this one. + * Returns an OrderedSet including any value from `collections` that does + * not already exist in this OrderedSet. + * + * Note: `union` can be used in `withMutations`. + * @alias merge + * @alias concat */ - concat(...valuesOrCollections: Array | C>): OrderedSet; + union(...collections: Array>): OrderedSet; + merge(...collections: Array>): OrderedSet; + concat(...collections: Array>): OrderedSet; + + // Sequence algorithms /** * Returns a new Set with values passed through a @@ -3013,7 +3036,7 @@ declare module Immutable { * All entries will be present in the resulting Seq, even if they * are duplicates. */ - concat(...valuesOrCollections: Array | C>): Seq.Set; + concat(...collections: Array>): Seq.Set; /** * Returns a new Seq.Set with values passed through a @@ -3717,7 +3740,7 @@ declare module Immutable { /** * Returns a new Collection with other collections concatenated to this one. */ - concat(...valuesOrCollections: Array | C>): Collection.Set; + concat(...collections: Array>): Collection.Set; /** * Returns a new Collection.Set with values passed through a diff --git a/dist/immutable.es.js b/dist/immutable.es.js index e9699623f9..0bb67f3d92 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -2145,6 +2145,7 @@ MapPrototype[IS_MAP_SENTINEL] = true; MapPrototype[DELETE] = MapPrototype.remove; MapPrototype.removeIn = MapPrototype.deleteIn; MapPrototype.removeAll = MapPrototype.deleteAll; +MapPrototype.concat = MapPrototype.merge; MapPrototype['@@transducer/init'] = MapPrototype.asMutable; MapPrototype['@@transducer/step'] = function(result, arr) { return result.set(arr[0], arr[1]); @@ -2975,8 +2976,30 @@ var List = (function (IndexedCollection$$1) { // @pragma Composition - List.prototype.merge = function merge (/*...collections*/) { - return this.concat.apply(this, arguments); + List.prototype.concat = function concat (/*...collections*/) { + var arguments$1 = arguments; + + var seqs = []; + for (var i = 0; i < arguments.length; i++) { + var argument = arguments$1[i]; + var seq = IndexedCollection$$1( + typeof argument !== 'string' && hasIterator(argument) + ? argument + : [argument] + ); + if (seq.size !== 0) { + seqs.push(seq); + } + } + if (seqs.length === 0) { + return this; + } + if (this.size === 0 && !this.__ownerID && seqs.length === 1) { + return this.constructor(seqs[0]); + } + return this.withMutations(function (list) { + seqs.forEach(function (seq) { return seq.forEach(function (value) { return list.push(value); }); }); + }); }; List.prototype.setSize = function setSize (size) { @@ -3059,6 +3082,7 @@ var IS_LIST_SENTINEL = '@@__IMMUTABLE_LIST__@@'; var ListPrototype = List.prototype; ListPrototype[IS_LIST_SENTINEL] = true; ListPrototype[DELETE] = ListPrototype.remove; +ListPrototype.merge = ListPrototype.concat; ListPrototype.setIn = MapPrototype.setIn; ListPrototype.deleteIn = ListPrototype.removeIn = MapPrototype.removeIn; ListPrototype.update = MapPrototype.update; @@ -4130,7 +4154,7 @@ var IS_SET_SENTINEL = '@@__IMMUTABLE_SET__@@'; var SetPrototype = Set.prototype; SetPrototype[IS_SET_SENTINEL] = true; SetPrototype[DELETE] = SetPrototype.remove; -SetPrototype.merge = SetPrototype.union; +SetPrototype.merge = SetPrototype.concat = SetPrototype.union; SetPrototype.withMutations = MapPrototype.withMutations; SetPrototype.asMutable = MapPrototype.asMutable; SetPrototype.asImmutable = MapPrototype.asImmutable; diff --git a/dist/immutable.js b/dist/immutable.js index 036388e211..7b5d880153 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -2151,6 +2151,7 @@ MapPrototype[IS_MAP_SENTINEL] = true; MapPrototype[DELETE] = MapPrototype.remove; MapPrototype.removeIn = MapPrototype.deleteIn; MapPrototype.removeAll = MapPrototype.deleteAll; +MapPrototype.concat = MapPrototype.merge; MapPrototype['@@transducer/init'] = MapPrototype.asMutable; MapPrototype['@@transducer/step'] = function(result, arr) { return result.set(arr[0], arr[1]); @@ -2981,8 +2982,30 @@ var List = (function (IndexedCollection$$1) { // @pragma Composition - List.prototype.merge = function merge (/*...collections*/) { - return this.concat.apply(this, arguments); + List.prototype.concat = function concat (/*...collections*/) { + var arguments$1 = arguments; + + var seqs = []; + for (var i = 0; i < arguments.length; i++) { + var argument = arguments$1[i]; + var seq = IndexedCollection$$1( + typeof argument !== 'string' && hasIterator(argument) + ? argument + : [argument] + ); + if (seq.size !== 0) { + seqs.push(seq); + } + } + if (seqs.length === 0) { + return this; + } + if (this.size === 0 && !this.__ownerID && seqs.length === 1) { + return this.constructor(seqs[0]); + } + return this.withMutations(function (list) { + seqs.forEach(function (seq) { return seq.forEach(function (value) { return list.push(value); }); }); + }); }; List.prototype.setSize = function setSize (size) { @@ -3065,6 +3088,7 @@ var IS_LIST_SENTINEL = '@@__IMMUTABLE_LIST__@@'; var ListPrototype = List.prototype; ListPrototype[IS_LIST_SENTINEL] = true; ListPrototype[DELETE] = ListPrototype.remove; +ListPrototype.merge = ListPrototype.concat; ListPrototype.setIn = MapPrototype.setIn; ListPrototype.deleteIn = ListPrototype.removeIn = MapPrototype.removeIn; ListPrototype.update = MapPrototype.update; @@ -4136,7 +4160,7 @@ var IS_SET_SENTINEL = '@@__IMMUTABLE_SET__@@'; var SetPrototype = Set.prototype; SetPrototype[IS_SET_SENTINEL] = true; SetPrototype[DELETE] = SetPrototype.remove; -SetPrototype.merge = SetPrototype.union; +SetPrototype.merge = SetPrototype.concat = SetPrototype.union; SetPrototype.withMutations = MapPrototype.withMutations; SetPrototype.asMutable = MapPrototype.asMutable; SetPrototype.asImmutable = MapPrototype.asImmutable; diff --git a/dist/immutable.js.flow b/dist/immutable.js.flow index 1b2d814504..7c431bc2a0 100644 --- a/dist/immutable.js.flow +++ b/dist/immutable.js.flow @@ -401,7 +401,7 @@ declare class SetCollection<+T> extends Collection { @@iterator(): Iterator; toSeq(): SetSeq; - concat(...iters: Array | C>): SetCollection; + concat(...collections: Iterable[]): SetCollection; // `filter`, `map` and `flatMap` cannot be defined further up the hierarchy, // because the implementation for `KeyedCollection` allows the value type to @@ -619,7 +619,7 @@ declare class SetSeq<+T> extends Seq mixins SetCollection { // Override specialized return types - concat(...iters: Array | C>): SetSeq; + concat(...collections: Iterable[]): SetSeq; filter(predicate: typeof Boolean): SetSeq<$NonMaybeType>; filter( @@ -836,6 +836,9 @@ declare class Map extends KeyedCollection { merge( ...collections: (Iterable<[K_, V_]> | PlainObjInput)[] ): Map; + concat( + ...collections: (Iterable<[K_, V_]> | PlainObjInput)[] + ): Map; mergeWith( merger: (oldVal: V, newVal: W, key: K) => X, @@ -883,9 +886,6 @@ declare class Map extends KeyedCollection { flip(): Map; - concat(...iters: Array>): Map; - concat(...iters: Array>): Map; - filter(predicate: typeof Boolean): Map>; filter( predicate: (value: V, key: K, iter: this) => mixed, @@ -937,6 +937,9 @@ declare class OrderedMap extends Map { merge( ...collections: (Iterable<[K_, V_]> | PlainObjInput)[] ): OrderedMap; + concat( + ...collections: (Iterable<[K_, V_]> | PlainObjInput)[] + ): OrderedMap; mergeWith( merger: (oldVal: V, newVal: W, key: K) => X, @@ -984,9 +987,6 @@ declare class OrderedMap extends Map { flip(): OrderedMap; - concat(...iters: Array>): OrderedMap; - concat(...iters: Array>): OrderedMap; - filter(predicate: typeof Boolean): OrderedMap>; filter( predicate: (value: V, key: K, iter: this) => mixed, @@ -1038,6 +1038,7 @@ declare class Set<+T> extends SetCollection { clear(): this; union(...collections: Iterable[]): Set; merge(...collections: Iterable[]): Set; + concat(...collections: Iterable[]): Set; intersect(...collections: Iterable[]): Set; subtract(...collections: Iterable[]): this; @@ -1048,8 +1049,6 @@ declare class Set<+T> extends SetCollection { // Override specialized return types - concat(...iters: Array | C>): Set; - filter(predicate: typeof Boolean): Set<$NonMaybeType>; filter( predicate: (value: T, value: T, iter: this) => mixed, @@ -1087,10 +1086,9 @@ declare class OrderedSet<+T> extends Set { add(value: U): OrderedSet; union(...collections: Iterable[]): OrderedSet; merge(...collections: Iterable[]): OrderedSet; + concat(...collections: Iterable[]): OrderedSet; intersect(...collections: Iterable[]): OrderedSet; - concat(...iters: Array | C>): OrderedSet; - filter(predicate: typeof Boolean): OrderedSet<$NonMaybeType>; filter( predicate: (value: T, value: T, iter: this) => mixed, diff --git a/dist/immutable.min.js b/dist/immutable.min.js index 8839b21eb9..7eca1e5425 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -4,34 +4,34 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.Immutable={})}(this,function(t){"use strict";function e(t){return t.value=!1,t}function r(t){t&&(t.value=!0)}function n(){}function i(t,e){e=e||0;for(var r=Math.max(0,t.length-e),n=Array(r),i=0;i>>0;if(""+r!==e||4294967295===r)return NaN;e=r}return e<0?o(t)+e:e}function s(){return!0}function a(t,e,r){return(0===t&&!p(t)||void 0!==r&&t<=-r)&&(void 0===e||void 0!==r&&e>=r)}function c(t,e){return f(t,e,0)}function h(t,e){return f(t,e,e)}function f(t,e,r){return void 0===t?r:p(t)?e===1/0?e:0|Math.max(0,e+t):void 0===e||e===t?t:0|Math.min(e,t)}function p(t){return t<0||0===t&&1/t==-(1/0)}function _(t){return(l(t)||m(t))&&!t.__ownerID}function l(t){return!(!t||!t[Re])}function v(t){return!(!t||!t[Ue])}function y(t){return!(!t||!t[Ke])}function d(t){return v(t)||y(t)}function g(t){return!(!t||!t[Le])}function m(t){return!(!t||!t[Te])}function w(t){return!(!t||"function"!=typeof t.equals||"function"!=typeof t.hashCode)}function S(t,e,r,n){var i=0===t?e:1===t?r:[e,r];return n?n.value=i:n={value:i,done:!1},n}function z(){return{value:void 0,done:!0}}function I(t){return!!M(t)}function b(t){return t&&"function"==typeof t.next}function O(t){var e=M(t);return e&&e.call(t)}function M(t){var e=t&&(He&&t[He]||t[Ye]);if("function"==typeof e)return e}function q(t){return t&&"number"==typeof t.length}function D(t){return!(!t||!t[tr])}function E(){return nr||(nr=new er([]))}function x(t){var e=Array.isArray(t)?new er(t):b(t)?new ur(t):I(t)?new or(t):void 0;if(e)return e.fromEntrySeq();if("object"==typeof t)return new rr(t);throw new TypeError("Expected Array or collection object of [k, v] entries, or keyed object: "+t)}function j(t){var e=A(t);if(e)return e;throw new TypeError("Expected Array or collection object of values: "+t)}function k(t){ +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.Immutable={})}(this,function(t){"use strict";function e(t){return t.value=!1,t}function r(t){t&&(t.value=!0)}function n(){}function i(t,e){e=e||0;for(var r=Math.max(0,t.length-e),n=Array(r),i=0;i>>0;if(""+r!==e||4294967295===r)return NaN;e=r}return e<0?o(t)+e:e}function s(){return!0}function a(t,e,r){return(0===t&&!p(t)||void 0!==r&&t<=-r)&&(void 0===e||void 0!==r&&e>=r)}function c(t,e){return f(t,e,0)}function h(t,e){return f(t,e,e)}function f(t,e,r){return void 0===t?r:p(t)?e===1/0?e:0|Math.max(0,e+t):void 0===e||e===t?t:0|Math.min(e,t)}function p(t){return t<0||0===t&&1/t==-(1/0)}function _(t){return(l(t)||m(t))&&!t.__ownerID}function l(t){return!(!t||!t[Re])}function v(t){return!(!t||!t[Ue])}function y(t){return!(!t||!t[Ke])}function d(t){return v(t)||y(t)}function g(t){return!(!t||!t[Le])}function m(t){return!(!t||!t[Te])}function w(t){return!(!t||"function"!=typeof t.equals||"function"!=typeof t.hashCode)}function S(t,e,r,n){var i=0===t?e:1===t?r:[e,r];return n?n.value=i:n={value:i,done:!1},n}function z(){return{value:void 0,done:!0}}function I(t){return!!M(t)}function b(t){return t&&"function"==typeof t.next}function O(t){var e=M(t);return e&&e.call(t)}function M(t){var e=t&&(He&&t[He]||t[Ye]);if("function"==typeof e)return e}function q(t){return t&&"number"==typeof t.length}function E(t){return!(!t||!t[tr])}function D(){return nr||(nr=new er([]))}function x(t){var e=Array.isArray(t)?new er(t):b(t)?new ur(t):I(t)?new or(t):void 0;if(e)return e.fromEntrySeq();if("object"==typeof t)return new rr(t);throw new TypeError("Expected Array or collection object of [k, v] entries, or keyed object: "+t)}function j(t){var e=A(t);if(e)return e;throw new TypeError("Expected Array or collection object of values: "+t)}function k(t){ var e=A(t);if(e)return e;if("object"==typeof t)return new rr(t);throw new TypeError("Expected Array or collection object of values, or keyed object: "+t)}function A(t){return q(t)?new er(t):b(t)?new ur(t):I(t)?new or(t):void 0}function R(t,e){if(t===e||t!==t&&e!==e)return!0;if(!t||!e)return!1;if("function"==typeof t.valueOf&&"function"==typeof e.valueOf){if(t=t.valueOf(),e=e.valueOf(),t===e||t!==t&&e!==e)return!0;if(!t||!e)return!1}return!!(w(t)&&w(e)&&t.equals(e))}function U(t){return t>>>1&1073741824|3221225471&t}function K(t){if(t===!1||null===t||void 0===t)return 0;if("function"==typeof t.valueOf&&((t=t.valueOf())===!1||null===t||void 0===t))return 0;if(t===!0)return 1;var e=typeof t;if("number"===e){if(t!==t||t===1/0)return 0;var r=0|t;for(r!==t&&(r^=4294967295*t);t>4294967295;)t/=4294967295,r^=t;return U(r)}if("string"===e)return t.length>_r?L(t):T(t);if("function"==typeof t.hashCode)return U(t.hashCode());if("object"===e)return C(t);if("function"==typeof t.toString)return T(""+t);throw Error("Value type "+e+" cannot be hashed.")}function L(t){var e=yr[t];return void 0===e&&(e=T(t),vr===lr&&(vr=0,yr={}),vr++,yr[t]=e),e}function T(t){for(var e=0,r=0;r0)switch(t.nodeType){case 1:return t.uniqueID;case 9:return t.documentElement&&t.documentElement.uniqueID}}function W(t){var e=st(t);return e._iter=t,e.size=t.size,e.flip=function(){return t},e.reverse=function(){var e=t.reverse.apply(this);return e.flip=function(){return t.reverse()},e},e.has=function(e){return t.includes(e)},e.includes=function(e){return t.has(e)},e.cacheResult=at,e.__iterateUncached=function(e,r){var n=this;return t.__iterate(function(t,r){return e(r,t,n)!==!1},r)},e.__iteratorUncached=function(e,r){if(e===Ve){var n=t.__iterator(e,r);return new Xe(function(){var t=n.next();if(!t.done){var e=t.value[0];t.value[0]=t.value[1],t.value[1]=e}return t})}return t.__iterator(e===Pe?Ne:Pe,r)},e}function J(t,e,r){var n=st(t);return n.size=t.size,n.has=function(e){return t.has(e)},n.get=function(n,i){var o=t.get(n,je);return o===je?i:e.call(r,o,n,t)},n.__iterateUncached=function(n,i){var o=this;return t.__iterate(function(t,i,u){return n(e.call(r,t,i,u),i,o)!==!1},i)},n.__iteratorUncached=function(n,i){var o=t.__iterator(Ve,i);return new Xe(function(){var i=o.next();if(i.done)return i;var u=i.value,s=u[0];return S(n,s,e.call(r,u[1],s,t),i)})},n}function N(t,e){var r=this,n=st(t);return n._iter=t,n.size=t.size,n.reverse=function(){return t},t.flip&&(n.flip=function(){var e=W(t);return e.reverse=function(){return t.flip()},e}),n.get=function(r,n){return t.get(e?r:-1-r,n)},n.has=function(r){return t.has(e?r:-1-r)},n.includes=function(e){return t.includes(e)},n.cacheResult=at,n.__iterate=function(r,n){var i=this,u=0;return n&&o(t),t.__iterate(function(t,o){return r(t,e?o:n?i.size-++u:u++,i)},!n)},n.__iterator=function(n,i){var u=0;i&&o(t);var s=t.__iterator(Ve,!i);return new Xe(function(){var t=s.next();if(t.done)return t;var o=t.value;return S(n,e?o[0]:i?r.size-++u:u++,o[1],t)})},n}function P(t,e,r,n){var i=st(t);return n&&(i.has=function(n){var i=t.get(n,je);return i!==je&&!!e.call(r,i,n,t)},i.get=function(n,i){var o=t.get(n,je);return o!==je&&e.call(r,o,n,t)?o:i}), -i.__iterateUncached=function(i,o){var u=this,s=0;return t.__iterate(function(t,o,a){if(e.call(r,t,o,a))return s++,i(t,n?o:s-1,u)},o),s},i.__iteratorUncached=function(i,o){var u=t.__iterator(Ve,o),s=0;return new Xe(function(){for(;;){var o=u.next();if(o.done)return o;var a=o.value,c=a[0],h=a[1];if(e.call(r,h,c,t))return S(i,n?c:s++,h,o)}})},i}function V(t,e,r){var n=Sr().asMutable();return t.__iterate(function(i,o){n.update(e.call(r,i,o,t),0,function(t){return t+1})}),n.asImmutable()}function H(t,e,r){var n=v(t),i=(g(t)?Br():Sr()).asMutable();t.__iterate(function(o,u){i.update(e.call(r,o,u,t),function(t){return t=t||[],t.push(n?[u,o]:o),t})});var o=ut(t);return i.map(function(e){return it(t,o(e))})}function Y(t,e,r,n){var i=t.size;if(a(e,r,i))return t;var o=c(e,i),s=h(r,i);if(o!==o||s!==s)return Y(t.toSeq().cacheResult(),e,r,n);var f,p=s-o;p===p&&(f=p<0?0:p);var _=st(t);return _.size=0===f?f:t.size&&f||void 0,!n&&D(t)&&f>=0&&(_.get=function(e,r){return e=u(this,e),e>=0&&ef)return z();var t=i.next();return n||e===Pe||t.done?t:e===Ne?S(e,s-1,void 0,t):S(e,s-1,t.value[1],t)})},_}function Q(t,e,r){var n=st(t);return n.__iterateUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterate(n,i);var u=0;return t.__iterate(function(t,i,s){return e.call(r,t,i,s)&&++u&&n(t,i,o)}),u},n.__iteratorUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterator(n,i);var u=t.__iterator(Ve,i),s=!0;return new Xe(function(){if(!s)return z();var t=u.next();if(t.done)return t;var i=t.value,a=i[0],c=i[1];return e.call(r,c,a,o)?n===Ve?t:S(n,a,c,t):(s=!1,z())})},n} +i.__iterateUncached=function(i,o){var u=this,s=0;return t.__iterate(function(t,o,a){if(e.call(r,t,o,a))return s++,i(t,n?o:s-1,u)},o),s},i.__iteratorUncached=function(i,o){var u=t.__iterator(Ve,o),s=0;return new Xe(function(){for(;;){var o=u.next();if(o.done)return o;var a=o.value,c=a[0],h=a[1];if(e.call(r,h,c,t))return S(i,n?c:s++,h,o)}})},i}function V(t,e,r){var n=Sr().asMutable();return t.__iterate(function(i,o){n.update(e.call(r,i,o,t),0,function(t){return t+1})}),n.asImmutable()}function H(t,e,r){var n=v(t),i=(g(t)?Br():Sr()).asMutable();t.__iterate(function(o,u){i.update(e.call(r,o,u,t),function(t){return t=t||[],t.push(n?[u,o]:o),t})});var o=ut(t);return i.map(function(e){return it(t,o(e))})}function Y(t,e,r,n){var i=t.size;if(a(e,r,i))return t;var o=c(e,i),s=h(r,i);if(o!==o||s!==s)return Y(t.toSeq().cacheResult(),e,r,n);var f,p=s-o;p===p&&(f=p<0?0:p);var _=st(t);return _.size=0===f?f:t.size&&f||void 0,!n&&E(t)&&f>=0&&(_.get=function(e,r){return e=u(this,e),e>=0&&ef)return z();var t=i.next();return n||e===Pe||t.done?t:e===Ne?S(e,s-1,void 0,t):S(e,s-1,t.value[1],t)})},_}function Q(t,e,r){var n=st(t);return n.__iterateUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterate(n,i);var u=0;return t.__iterate(function(t,i,s){return e.call(r,t,i,s)&&++u&&n(t,i,o)}),u},n.__iteratorUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterator(n,i);var u=t.__iterator(Ve,i),s=!0;return new Xe(function(){if(!s)return z();var t=u.next();if(t.done)return t;var i=t.value,a=i[0],c=i[1];return e.call(r,c,a,o)?n===Ve?t:S(n,a,c,t):(s=!1,z())})},n} function X(t,e,r,n){var i=st(t);return i.__iterateUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterate(i,o);var s=!0,a=0;return t.__iterate(function(t,o,c){if(!s||!(s=e.call(r,t,o,c)))return a++,i(t,n?o:a-1,u)}),a},i.__iteratorUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterator(i,o);var s=t.__iterator(Ve,o),a=!0,c=0;return new Xe(function(){var t,o,h;do{if(t=s.next(),t.done)return n||i===Pe?t:i===Ne?S(i,c++,void 0,t):S(i,c++,t.value[1],t);var f=t.value;o=f[0],h=f[1],a&&(a=e.call(r,h,o,u))}while(a);return i===Ve?t:S(i,o,h,t)})},i}function F(t,e){var r=v(t),n=[t].concat(e).map(function(t){return l(t)?r&&(t=Be(t)):t=r?x(t):j(Array.isArray(t)?t:[t]),t}).filter(function(t){return 0!==t.size});if(0===n.length)return t;if(1===n.length){var i=n[0];if(i===t||r&&v(i)||y(t)&&y(i))return i}var o=new er(n);return r?o=o.toKeyedSeq():y(t)||(o=o.toSetSeq()),o=o.flatten(!0),o.size=n.reduce(function(t,e){if(void 0!==t){var r=e.size;if(void 0!==r)return t+r}},0),o}function G(t,e,r){var n=st(t);return n.__iterateUncached=function(i,o){function u(t,c){t.__iterate(function(t,o){return(!e||c0}function nt(t,e,r,n){var i=st(t),o=new er(r).map(function(t){return t.size});return i.size=n?o.max():o.min(),i.__iterate=function(t,e){for(var r,n=this,i=this.__iterator(Pe,e),o=0;!(r=i.next()).done&&t(r.value,o++,n)!==!1;);return o},i.__iteratorUncached=function(t,i){var o=r.map(function(t){return t=Ce(t),O(i?t.reverse():t)}),u=0,s=!1;return new Xe(function(){var r;return s||(r=o.map(function(t){return t.next()}),s=n?r.every(function(t){return t.done}):r.some(function(t){return t.done})),s?z():S(t,u++,e.apply(null,r.map(function(t){return t.value})))})},i}function it(t,e){return t===e?t:D(t)?e:t.constructor(e)}function ot(t){if(t!==Object(t))throw new TypeError("Expected [K, V] tuple: "+t)}function ut(t){return v(t)?Be:y(t)?We:Je}function st(t){return Object.create((v(t)?Ge:y(t)?Ze:$e).prototype)}function at(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size,this):Fe.prototype.cacheResult.call(this)}function ct(t,e){return void 0===t&&void 0===e?0:void 0===t?1:void 0===e?-1:t>e?1:t>>r)&xe,s=(0===r?n:n>>>r)&xe;return new Or(e,1<>>=1)u[s]=1&r?e[o++]:void 0;return u[n]=i,new Mr(t,o+1,u)}function Mt(t,e,r){for(var n=[],i=0;i>1&1431655765,t=(858993459&t)+(t>>2&858993459),t=t+(t>>4)&252645135,t+=t>>8,127&(t+=t>>16)}function kt(t,e,r,n){var o=n?t:i(t);return o[e]=r,o}function At(t,e,r,n){var i=t.length+1;if(n&&e+1===i)return t[e]=r,t;for(var o=Array(i),u=0,s=0;so?0:o-r,c=u-r;return c>Ee&&(c=Ee),function(){if(i===c)return Cr;var t=e?--c:i++;return n&&n[t]}}function i(t,n,i){var s,a=t&&t.array,c=i>o?0:o-i>>n,h=1+(u-i>>n);return h>Ee&&(h=Ee),function(){for(;;){if(s){var t=s();if(t!==Cr)return t;s=null}if(c===h)return Cr;var o=e?--h:c++;s=r(a&&a[o],n-De,i+(o<=t.size||r<0)return t.withMutations(function(t){r<0?Nt(t,r).set(0,n):Nt(t,0,r+1).set(r,n)});r+=t._origin;var i=t._tail,o=t._root,s=e(Ae);return r>=Pt(t._capacity)?i=Bt(i,t.__ownerID,0,r,n,s):o=Bt(o,t.__ownerID,t._level,r,n,s),s.value?t.__ownerID?(t._root=o,t._tail=i,t.__hash=void 0,t.__altered=!0,t):Lt(t._origin,t._capacity,t._level,o,i):t}function Bt(t,e,n,i,o,u){var s=i>>>n&xe,a=t&&s0){var h=t&&t.array[s],f=Bt(h,e,n-De,i,o,u);return f===h?t:(c=Wt(t,e),c.array[s]=f,c)} -return a&&t.array[s]===o?t:(r(u),c=Wt(t,e),void 0===o&&s===c.array.length-1?c.array.pop():c.array[s]=o,c)}function Wt(t,e){return e&&t&&e===t.ownerID?t:new Lr(t?t.array.slice():[],e)}function Jt(t,e){if(e>=Pt(t._capacity))return t._tail;if(e<1<0;)r=r.array[e>>>n&xe],n-=De;return r}}function Nt(t,e,r){void 0!==e&&(e|=0),void 0!==r&&(r|=0);var i=t.__ownerID||new n,o=t._origin,u=t._capacity,s=o+e,a=void 0===r?u:r<0?u+r:o+r;if(s===o&&a===u)return t;if(s>=a)return t.clear();for(var c=t._level,h=t._root,f=0;s+f<0;)h=new Lr(h&&h.array.length?[void 0,h]:[],i),c+=De,f+=1<=1<p?new Lr([],i):l;if(l&&_>p&&sDe;d-=De){var g=p>>>d&xe;y=y.array[g]=Wt(y.array[g],i)}y.array[p>>>De&xe]=l}if(a=_)s-=_,a-=_,c=De,h=null,v=v&&v.removeBefore(i,0,s);else if(s>o||_>>c&xe;if(m!==_>>>c&xe)break;m&&(f+=(1<o&&(h=h.removeBefore(i,c,s-f)),h&&_>>De<=Ee&&u.size>=2*o.size?(i=u.filter(function(t,e){return void 0!==t&&s!==e}),n=i.toKeyedSeq().map(function(t){return t[0]}).flip().toMap(),t.__ownerID&&(n.__ownerID=i.__ownerID=t.__ownerID)):(n=o.remove(e),i=s===u.size-1?u.pop():u.set(s,void 0))}else if(a){if(r===u.get(s)[1])return t;n=o,i=u.set(s,[e,r])}else n=o.set(e,u.size),i=u.set(u.size,[e,r]) +i.done)?i:u%2?S(r,u++,e):S(r,u++,i.value,i)})},r}function tt(t,e,r){e||(e=ct);var n=v(t),i=0,o=t.toSeq().map(function(e,n){return[n,e,i++,r?r(e,n,t):e]}).valueSeq().toArray();return o.sort(function(t,r){return e(t[3],r[3])||t[2]-r[2]}).forEach(n?function(t,e){o[e].length=2}:function(t,e){o[e]=t[1]}),n?Ge(o):y(t)?Ze(o):$e(o)}function et(t,e,r){if(e||(e=ct),r){var n=t.toSeq().map(function(e,n){return[e,r(e,n,t)]}).reduce(function(t,r){return rt(e,t[1],r[1])?r:t});return n&&n[0]}return t.reduce(function(t,r){return rt(e,t,r)?r:t})}function rt(t,e,r){var n=t(r,e);return 0===n&&r!==e&&(void 0===r||null===r||r!==r)||n>0}function nt(t,e,r,n){var i=st(t),o=new er(r).map(function(t){return t.size});return i.size=n?o.max():o.min(),i.__iterate=function(t,e){for(var r,n=this,i=this.__iterator(Pe,e),o=0;!(r=i.next()).done&&t(r.value,o++,n)!==!1;);return o},i.__iteratorUncached=function(t,i){var o=r.map(function(t){return t=Ce(t),O(i?t.reverse():t)}),u=0,s=!1;return new Xe(function(){var r;return s||(r=o.map(function(t){return t.next()}),s=n?r.every(function(t){return t.done}):r.some(function(t){return t.done})),s?z():S(t,u++,e.apply(null,r.map(function(t){return t.value})))})},i}function it(t,e){return t===e?t:E(t)?e:t.constructor(e)}function ot(t){if(t!==Object(t))throw new TypeError("Expected [K, V] tuple: "+t)}function ut(t){return v(t)?Be:y(t)?We:Je}function st(t){return Object.create((v(t)?Ge:y(t)?Ze:$e).prototype)}function at(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size,this):Fe.prototype.cacheResult.call(this)}function ct(t,e){return void 0===t&&void 0===e?0:void 0===t?1:void 0===e?-1:t>e?1:t>>r)&xe,s=(0===r?n:n>>>r)&xe;return new Or(e,1<>>=1)u[s]=1&r?e[o++]:void 0;return u[n]=i,new Mr(t,o+1,u)}function Mt(t,e,r){for(var n=[],i=0;i>1&1431655765,t=(858993459&t)+(t>>2&858993459),t=t+(t>>4)&252645135,t+=t>>8,127&(t+=t>>16)}function kt(t,e,r,n){var o=n?t:i(t);return o[e]=r,o}function At(t,e,r,n){var i=t.length+1;if(n&&e+1===i)return t[e]=r,t;for(var o=Array(i),u=0,s=0;so?0:o-r,c=u-r;return c>De&&(c=De),function(){if(i===c)return Cr;var t=e?--c:i++;return n&&n[t]}}function i(t,n,i){var s,a=t&&t.array,c=i>o?0:o-i>>n,h=1+(u-i>>n);return h>De&&(h=De),function(){for(;;){if(s){var t=s();if(t!==Cr)return t;s=null}if(c===h)return Cr;var o=e?--h:c++;s=r(a&&a[o],n-Ee,i+(o<=t.size||r<0)return t.withMutations(function(t){r<0?Nt(t,r).set(0,n):Nt(t,0,r+1).set(r,n)});r+=t._origin;var i=t._tail,o=t._root,s=e(Ae);return r>=Pt(t._capacity)?i=Bt(i,t.__ownerID,0,r,n,s):o=Bt(o,t.__ownerID,t._level,r,n,s),s.value?t.__ownerID?(t._root=o,t._tail=i,t.__hash=void 0,t.__altered=!0,t):Lt(t._origin,t._capacity,t._level,o,i):t}function Bt(t,e,n,i,o,u){var s=i>>>n&xe,a=t&&s0){var h=t&&t.array[s],f=Bt(h,e,n-Ee,i,o,u);return f===h?t:(c=Wt(t,e),c.array[s]=f,c)} +return a&&t.array[s]===o?t:(r(u),c=Wt(t,e),void 0===o&&s===c.array.length-1?c.array.pop():c.array[s]=o,c)}function Wt(t,e){return e&&t&&e===t.ownerID?t:new Lr(t?t.array.slice():[],e)}function Jt(t,e){if(e>=Pt(t._capacity))return t._tail;if(e<1<0;)r=r.array[e>>>n&xe],n-=Ee;return r}}function Nt(t,e,r){void 0!==e&&(e|=0),void 0!==r&&(r|=0);var i=t.__ownerID||new n,o=t._origin,u=t._capacity,s=o+e,a=void 0===r?u:r<0?u+r:o+r;if(s===o&&a===u)return t;if(s>=a)return t.clear();for(var c=t._level,h=t._root,f=0;s+f<0;)h=new Lr(h&&h.array.length?[void 0,h]:[],i),c+=Ee,f+=1<=1<p?new Lr([],i):l;if(l&&_>p&&sEe;d-=Ee){var g=p>>>d&xe;y=y.array[g]=Wt(y.array[g],i)}y.array[p>>>Ee&xe]=l}if(a=_)s-=_,a-=_,c=Ee,h=null,v=v&&v.removeBefore(i,0,s);else if(s>o||_>>c&xe;if(m!==_>>>c&xe)break;m&&(f+=(1<o&&(h=h.removeBefore(i,c,s-f)),h&&_>>Ee<=De&&u.size>=2*o.size?(i=u.filter(function(t,e){return void 0!==t&&s!==e}),n=i.toKeyedSeq().map(function(t){return t[0]}).flip().toMap(),t.__ownerID&&(n.__ownerID=i.__ownerID=t.__ownerID)):(n=o.remove(e),i=s===u.size-1?u.pop():u.set(s,void 0))}else if(a){if(r===u.get(s)[1])return t;n=o,i=u.set(s,[e,r])}else n=o.set(e,u.size),i=u.set(u.size,[e,r]) ;return t.__ownerID?(t.size=n.size,t._map=n,t._list=i,t.__hash=void 0,t):Ht(n,i)}function Xt(t){return!(!t||!t[Nr])}function Ft(t,e,r,n){var i=Object.create(Pr);return i.size=t,i._head=e,i.__ownerID=r,i.__hash=n,i.__altered=!1,i}function Gt(){return Vr||(Vr=Ft(0))}function Zt(t,e){if(t===e)return!0;if(!l(e)||void 0!==t.size&&void 0!==e.size&&t.size!==e.size||void 0!==t.__hash&&void 0!==e.__hash&&t.__hash!==e.__hash||v(t)!==v(e)||y(t)!==y(e)||g(t)!==g(e))return!1;if(0===t.size&&0===e.size)return!0;var r=!d(t);if(g(t)){var n=t.entries();return e.every(function(t,e){var i=n.next().value;return i&&R(i[1],t)&&(r||R(i[0],e))})&&n.next().done}var i=!1;if(void 0===t.size)if(void 0===e.size)"function"==typeof t.cacheResult&&t.cacheResult();else{i=!0;var o=t;t=e,e=o}var u=!0,s=e.__iterate(function(e,n){if(r?!t.has(e):i?!R(e,t.get(n,je)):!R(t.get(n,je),e))return u=!1,!1});return u&&t.size===s}function $t(t,e){var r=function(r){t.prototype[r]=e[r]};return Object.keys(e).forEach(r),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(e).forEach(r),t}function te(t){return!(!t||!t[Yr])}function ee(t,e){return t.__ownerID?(t.size=e.size,t._map=e,t):e===t._map?t:0===e.size?t.__empty():t.__make(e)}function re(t,e){var r=Object.create(Qr);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function ne(){return Xr||(Xr=re(gt()))}function ie(t,e,r,n,i,o){return pt(t.size),t.__iterate(function(t,o,u){i?(i=!1,r=t):r=e.call(n,r,t,o,u)},o),r}function oe(t,e){return e}function ue(t,e){return[e,t]}function se(t){return t&&"function"==typeof t.toJS?t.toJS():t}function ae(t){return function(){return!t.apply(this,arguments)}}function ce(t){return function(){return-t.apply(this,arguments)}}function he(){return i(arguments)}function fe(t,e){return te?-1:0}function pe(t){if(t.size===1/0)return 0;var e=g(t),r=v(t),n=e?1:0;return _e(t.__iterate(r?e?function(t,e){n=31*n+le(K(t),K(e))|0}:function(t,e){n=n+le(K(t),K(e))|0}:e?function(t){n=31*n+K(t)|0}:function(t){n=n+K(t)|0}),n)}function _e(t,e){return e=sr(e,3432918353), -e=sr(e<<15|e>>>-15,461845907),e=sr(e<<13|e>>>-13,5),e=(e+3864292196|0)^t,e=sr(e^e>>>16,2246822507),e=sr(e^e>>>13,3266489909),e=U(e^e>>>16)}function le(t,e){return t^e+2654435769+(t<<6)+(t>>2)|0}function ve(t){if("object"!=typeof console||!console.warn)throw Error(t);console.warn(t)}function ye(t,e,r,n){for(var i=ht(r),o=0;o!==i.length;){if(null==t)return e;if(!t||!t.get)return n&&ve("Invalid keyPath: Value at ["+i.slice(0,o).map(_t)+"] does not have a .get() method: "+t+"\nThis warning will throw in a future version"),e;if((t=t.get(i[o++],je))===je)return e}return t}function de(t){return te(t)&&g(t)}function ge(t,e){var r=Object.create(rn);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function me(){return nn||(nn=ge(Yt()))}function we(t,e,r){var n=Object.create(Object.getPrototypeOf(t));return n._values=e,n.__ownerID=r,n}function Se(t){return t._name||t.constructor.name||"Record"}function ze(t){return x(t._keys.map(function(e){return[e,t.get(e)]}))}function Ie(t,e){try{Object.defineProperty(t,e,{get:function(){return this.get(e)},set:function(t){ft(this.__ownerID,"Cannot set on an immutable record."),this.set(e,t)}})}catch(t){}}function be(t,e){return Oe([],e||Me,t,"",e&&e.length>2?[]:void 0,{"":t})}function Oe(t,e,r,n,i,o){var u=Array.isArray(r)?Ze:qe(r)?Ge:null;if(u){if(~t.indexOf(r))throw new TypeError("Cannot convert circular structure to Immutable");t.push(r),i&&""!==n&&i.push(n);var s=e.call(o,n,u(r).map(function(n,o){return Oe(t,e,n,o,i,r)}),i&&i.slice());return t.pop(),i&&i.pop(),s}return r}function Me(t,e){return v(e)?e.toMap():e.toList()}function qe(t){return t&&(t.constructor===Object||void 0===t.constructor)}var De=5,Ee=1<>>-15,461845907),e=sr(e<<13|e>>>-13,5),e=(e+3864292196|0)^t,e=sr(e^e>>>16,2246822507),e=sr(e^e>>>13,3266489909),e=U(e^e>>>16)}function le(t,e){return t^e+2654435769+(t<<6)+(t>>2)|0}function ve(t){if("object"!=typeof console||!console.warn)throw Error(t);console.warn(t)}function ye(t,e,r,n){for(var i=ht(r),o=0;o!==i.length;){if(null==t)return e;if(!t||!t.get)return n&&ve("Invalid keyPath: Value at ["+i.slice(0,o).map(_t)+"] does not have a .get() method: "+t+"\nThis warning will throw in a future version"),e;if((t=t.get(i[o++],je))===je)return e}return t}function de(t){return te(t)&&g(t)}function ge(t,e){var r=Object.create(rn);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function me(){return nn||(nn=ge(Yt()))}function we(t,e,r){var n=Object.create(Object.getPrototypeOf(t));return n._values=e,n.__ownerID=r,n}function Se(t){return t._name||t.constructor.name||"Record"}function ze(t){return x(t._keys.map(function(e){return[e,t.get(e)]}))}function Ie(t,e){try{Object.defineProperty(t,e,{get:function(){return this.get(e)},set:function(t){ft(this.__ownerID,"Cannot set on an immutable record."),this.set(e,t)}})}catch(t){}}function be(t,e){return Oe([],e||Me,t,"",e&&e.length>2?[]:void 0,{"":t})}function Oe(t,e,r,n,i,o){var u=Array.isArray(r)?Ze:qe(r)?Ge:null;if(u){if(~t.indexOf(r))throw new TypeError("Cannot convert circular structure to Immutable");t.push(r),i&&""!==n&&i.push(n);var s=e.call(o,n,u(r).map(function(n,o){return Oe(t,e,n,o,i,r)}),i&&i.slice());return t.pop(),i&&i.pop(),s}return r}function Me(t,e){return v(e)?e.toMap():e.toList()}function qe(t){return t&&(t.constructor===Object||void 0===t.constructor)}var Ee=5,De=1<=n.length){var e=r.next();if(e.done)return e;n[i]=e.value}return S(t,i,n[i++])})},e}(Ze),sr="function"==typeof Math.imul&&Math.imul(4294967295,2)===-2?Math.imul:function(t,e){t|=0,e|=0;var r=65535&t,n=65535&e;return r*n+((t>>>16)*n+r*(e>>>16)<<16>>>0)|0},ar=Object.isExtensible,cr=function(){try{return Object.defineProperty({},"@",{}),!0}catch(t){return!1}}(),hr="function"==typeof WeakMap;hr&&(ir=new WeakMap);var fr=0,pr="__immutablehash__";"function"==typeof Symbol&&(pr=Symbol(pr));var _r=16,lr=255,vr=0,yr={},dr=function(t){function e(t,e){this._iter=t,this._useKeys=e,this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t,e){return this._iter.get(t,e)},e.prototype.has=function(t){return this._iter.has(t)},e.prototype.valueSeq=function(){return this._iter.valueSeq()},e.prototype.reverse=function(){var t=this,e=N(this,!0);return this._useKeys||(e.valueSeq=function(){return t._iter.toSeq().reverse()}),e},e.prototype.map=function(t,e){var r=this,n=J(this,t,e);return this._useKeys||(n.valueSeq=function(){ return r._iter.toSeq().map(t,e)}),n},e.prototype.__iterate=function(t,e){var r=this;return this._iter.__iterate(function(e,n){return t(e,n,r)},e)},e.prototype.__iterator=function(t,e){return this._iter.__iterator(t,e)},e}(Ge);dr.prototype[Le]=!0;var gr=function(t){function e(t){this._iter=t,this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.includes=function(t){return this._iter.includes(t)},e.prototype.__iterate=function(t,e){var r=this,n=0;return e&&o(this),this._iter.__iterate(function(i){return t(i,e?r.size-++n:n++,r)},e)},e.prototype.__iterator=function(t,e){var r=this,n=this._iter.__iterator(Pe,e),i=0;return e&&o(this),new Xe(function(){var o=n.next();return o.done?o:S(t,e?r.size-++i:i++,o.value,o)})},e}(Ze),mr=function(t){function e(t){this._iter=t,this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.has=function(t){return this._iter.includes(t)},e.prototype.__iterate=function(t,e){var r=this;return this._iter.__iterate(function(e){return t(e,e,r)},e)},e.prototype.__iterator=function(t,e){var r=this._iter.__iterator(Pe,e);return new Xe(function(){var e=r.next();return e.done?e:S(t,e.value,e.value,e)})},e}($e),wr=function(t){function e(t){this._iter=t,this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.entrySeq=function(){return this._iter.toSeq()},e.prototype.__iterate=function(t,e){var r=this;return this._iter.__iterate(function(e){if(e){ot(e);var n=l(e);return t(n?e.get(1):e[1],n?e.get(0):e[0],r)}},e)},e.prototype.__iterator=function(t,e){var r=this._iter.__iterator(Pe,e);return new Xe(function(){for(;;){var e=r.next();if(e.done)return e;var n=e.value;if(n){ot(n);var i=l(n);return S(t,i?n.get(0):n[0],i?n.get(1):n[1],e)}}})},e}(Ge);gr.prototype.cacheResult=dr.prototype.cacheResult=mr.prototype.cacheResult=wr.prototype.cacheResult=at;var Sr=function(t){function e(e){ -return null===e||void 0===e?gt():lt(e)&&!g(e)?e:gt().withMutations(function(r){var n=t(e);pt(n.size),n.forEach(function(t,e){return r.set(e,t)})})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return gt().withMutations(function(e){for(var r=0;r=t.length)throw Error("Missing value for key: "+t[r]);e.set(t[r],t[r+1])}})},e.prototype.toString=function(){return this.__toString("Map {","}")},e.prototype.get=function(t,e){return this._root?this._root.get(0,void 0,t,e):e},e.prototype.set=function(t,e){return mt(this,t,e)},e.prototype.setIn=function(t,e){return this.updateIn(t,je,function(){return e})},e.prototype.remove=function(t){return mt(this,t,je)},e.prototype.deleteIn=function(t){if(t=[].concat(ht(t)),t.length){var e=t.pop();return this.updateIn(t,function(t){return t&&t.remove(e)})}},e.prototype.deleteAll=function(t){var e=Ce(t);return 0===e.size?this:this.withMutations(function(t){e.forEach(function(e){return t.remove(e)})})},e.prototype.update=function(t,e,r){return 1===arguments.length?t(this):this.updateIn([t],e,r)},e.prototype.updateIn=function(t,e,r){r||(r=e,e=void 0);var n=xt(this,ht(t),0,e,r);return n===je?e:n},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):gt()},e.prototype.merge=function(){return Mt(this,void 0,arguments)},e.prototype.mergeWith=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Mt(this,t,e)},e.prototype.mergeIn=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return this.updateIn(t,gt(),function(t){return"function"==typeof t.merge?t.merge.apply(t,e):e[e.length-1]})},e.prototype.mergeDeep=function(){return Mt(this,Dt(qt),arguments)},e.prototype.mergeDeepWith=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Mt(this,Dt(t),e)},e.prototype.mergeDeepIn=function(t){ -for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return this.updateIn(t,gt(),function(t){return"function"==typeof t.mergeDeep?t.mergeDeep.apply(t,e):e[e.length-1]})},e.prototype.sort=function(t){return Br(tt(this,t))},e.prototype.sortBy=function(t,e){return Br(tt(this,e,t))},e.prototype.withMutations=function(t){var e=this.asMutable();return t(e),e.wasAltered()?e.__ensureOwner(this.__ownerID):this},e.prototype.asMutable=function(){return this.__ownerID?this:this.__ensureOwner(new n)},e.prototype.asImmutable=function(){return this.__ensureOwner()},e.prototype.wasAltered=function(){return this.__altered},e.prototype.__iterator=function(t,e){return new xr(this,t,e)},e.prototype.__iterate=function(t,e){var r=this,n=0;return this._root&&this._root.iterate(function(e){return n++,t(e[1],e[0],r)},e),n},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?dt(this.size,this._root,t,this.__hash):0===this.size?gt():(this.__ownerID=t,this.__altered=!1,this)},e}(Be);Sr.isMap=lt;var zr="@@__IMMUTABLE_MAP__@@",Ir=Sr.prototype;Ir[zr]=!0,Ir.delete=Ir.remove,Ir.removeIn=Ir.deleteIn,Ir.removeAll=Ir.deleteAll,Ir["@@transducer/init"]=Ir.asMutable,Ir["@@transducer/step"]=function(t,e){return t.set(e[0],e[1])},Ir["@@transducer/result"]=function(t){return t.asImmutable()};var br=function(t,e){this.ownerID=t,this.entries=e};br.prototype.get=function(t,e,r,n){for(var i=this.entries,o=0,u=i.length;o=jr)return It(t,h,o,u);var l=t&&t===this.ownerID,v=l?h:i(h);return _?c?f===p-1?v.pop():v[f]=v.pop():v[f]=[o,u]:v.push([o,u]),l?(this.entries=v,this):new br(t,v)}};var Or=function(t,e,r){this.ownerID=t,this.bitmap=e,this.nodes=r};Or.prototype.get=function(t,e,r,n){void 0===e&&(e=K(r));var i=1<<((0===t?e:e>>>t)&xe),o=this.bitmap -;return 0==(o&i)?n:this.nodes[jt(o&i-1)].get(t+De,e,r,n)},Or.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=K(n));var s=(0===e?r:r>>>e)&xe,a=1<=kr)return Ot(t,p,c,s,l);if(h&&!l&&2===p.length&&St(p[1^f]))return p[1^f];if(h&&l&&1===p.length&&St(l))return l;var v=t&&t===this.ownerID,y=h?l?c:c^a:c|a,d=h?l?kt(p,f,l,v):Rt(p,f,v):At(p,f,l,v);return v?(this.bitmap=y,this.nodes=d,this):new Or(t,y,d)};var Mr=function(t,e,r){this.ownerID=t,this.count=e,this.nodes=r};Mr.prototype.get=function(t,e,r,n){void 0===e&&(e=K(r));var i=(0===t?e:e>>>t)&xe,o=this.nodes[i];return o?o.get(t+De,e,r,n):n},Mr.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=K(n));var s=(0===e?r:r>>>e)&xe,a=i===je,c=this.nodes,h=c[s];if(a&&!h)return this;var f=wt(h,t,e+De,r,n,i,o,u);if(f===h)return this;var p=this.count;if(h){if(!f&&--p0&&i=0&&t>>e&xe;if(n>=this.array.length)return new Lr([],t);var i,o=0===n;if(e>0){var u=this.array[n] -;if((i=u&&u.removeBefore(t,e-De,r))===u&&o)return this}if(o&&!i)return this;var s=Wt(this,t);if(!o)for(var a=0;a>>e&xe;if(n>=this.array.length)return this;var i;if(e>0){var o=this.array[n];if((i=o&&o.removeAfter(t,e-De,r))===o&&n===this.array.length-1)return this}var u=Wt(this,t);return u.array.splice(n+1),i&&(u.array[n]=i),u};var Tr,Cr={},Br=function(t){function e(t){return null===t||void 0===t?Yt():Vt(t)?t:Yt().withMutations(function(e){var r=Be(t);pt(r.size),r.forEach(function(t,r){return e.set(r,t)})})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("OrderedMap {","}")},e.prototype.get=function(t,e){var r=this._map.get(t);return void 0!==r?this._list.get(r)[1]:e},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._map.clear(),this._list.clear(),this):Yt()},e.prototype.set=function(t,e){return Qt(this,t,e)},e.prototype.remove=function(t){return Qt(this,t,je)},e.prototype.wasAltered=function(){return this._map.wasAltered()||this._list.wasAltered()},e.prototype.__iterate=function(t,e){var r=this;return this._list.__iterate(function(e){return e&&t(e[1],e[0],r)},e)},e.prototype.__iterator=function(t,e){return this._list.fromEntrySeq().__iterator(t,e)},e.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var e=this._map.__ensureOwner(t),r=this._list.__ensureOwner(t);return t?Ht(e,r,t,this.__hash):0===this.size?Yt():(this.__ownerID=t,this._map=e,this._list=r,this)},e}(Sr);Br.isOrderedMap=Vt,Br.prototype[Le]=!0,Br.prototype.delete=Br.prototype.remove;var Wr,Jr=function(t){function e(t){return null===t||void 0===t?Gt():Xt(t)?t:Gt().pushAll(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){ -return this(arguments)},e.prototype.toString=function(){return this.__toString("Stack [","]")},e.prototype.get=function(t,e){var r=this._head;for(t=u(this,t);r&&t--;)r=r.next;return r?r.value:e},e.prototype.peek=function(){return this._head&&this._head.value},e.prototype.push=function(){var t=arguments;if(0===arguments.length)return this;for(var e=this.size+arguments.length,r=this._head,n=arguments.length-1;n>=0;n--)r={value:t[n],next:r};return this.__ownerID?(this.size=e,this._head=r,this.__hash=void 0,this.__altered=!0,this):Ft(e,r)},e.prototype.pushAll=function(e){if(e=t(e),0===e.size)return this;if(0===this.size&&Xt(e))return e;pt(e.size);var r=this.size,n=this._head;return e.__iterate(function(t){r++,n={value:t,next:n}},!0),this.__ownerID?(this.size=r,this._head=n,this.__hash=void 0,this.__altered=!0,this):Ft(r,n)},e.prototype.pop=function(){return this.slice(1)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):Gt()},e.prototype.slice=function(e,r){if(a(e,r,this.size))return this;var n=c(e,this.size);if(h(r,this.size)!==this.size)return t.prototype.slice.call(this,e,r);for(var i=this.size-n,o=this._head;n--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):Ft(i,o)},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Ft(this.size,this._head,t,this.__hash):0===this.size?Gt():(this.__ownerID=t,this.__altered=!1,this)},e.prototype.__iterate=function(t,e){var r=this;if(e)return new er(this.toArray()).__iterate(function(e,n){return t(e,n,r)},e);for(var n=0,i=this._head;i&&t(i.value,n++,r)!==!1;)i=i.next;return n},e.prototype.__iterator=function(t,e){if(e)return new er(this.toArray()).__iterator(t,e);var r=0,n=this._head;return new Xe(function(){if(n){var e=n.value;return n=n.next,S(t,r++,e)}return z()})},e}(We);Jr.isStack=Xt;var Nr="@@__IMMUTABLE_STACK__@@",Pr=Jr.prototype;Pr[Nr]=!0,Pr.withMutations=Ir.withMutations,Pr.asMutable=Ir.asMutable, -Pr.asImmutable=Ir.asImmutable,Pr.wasAltered=Ir.wasAltered,Pr.shift=Pr.pop,Pr.unshift=Pr.push,Pr.unshiftAll=Pr.pushAll,Pr["@@transducer/init"]=Pr.asMutable,Pr["@@transducer/step"]=function(t,e){return t.unshift(e)},Pr["@@transducer/result"]=Ir["@@transducer/result"];var Vr,Hr=function(t){function e(e){return null===e||void 0===e?ne():te(e)&&!g(e)?e:ne().withMutations(function(r){var n=t(e);pt(n.size),n.forEach(function(t){return r.add(t)})})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(Be(t).keySeq())},e.intersect=function(t){return t=Ce(t).toArray(),t.length?Qr.intersect.apply(e(t.pop()),t):ne()},e.union=function(t){return t=Ce(t).toArray(),t.length?Qr.union.apply(e(t.pop()),t):ne()},e.prototype.toString=function(){return this.__toString("Set {","}")},e.prototype.has=function(t){return this._map.has(t)},e.prototype.add=function(t){return ee(this,this._map.set(t,t))},e.prototype.remove=function(t){return ee(this,this._map.remove(t))},e.prototype.clear=function(){return ee(this,this._map.clear())},e.prototype.union=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return e=e.filter(function(t){return 0!==t.size}),0===e.length?this:0!==this.size||this.__ownerID||1!==e.length?this.withMutations(function(r){for(var n=0;n=0&&e=0&&rthis.size?e:this.find(function(e,r){return r===t},void 0,e)},has:function(t){return(t=u(this,t))>=0&&(void 0!==this.size?this.size===1/0||t=t.length)throw Error("Missing value for key: "+t[r]);e.set(t[r],t[r+1])}})},e.prototype.toString=function(){return this.__toString("Map {","}")},e.prototype.get=function(t,e){return this._root?this._root.get(0,void 0,t,e):e},e.prototype.set=function(t,e){return mt(this,t,e)},e.prototype.setIn=function(t,e){return this.updateIn(t,je,function(){return e})},e.prototype.remove=function(t){return mt(this,t,je)},e.prototype.deleteIn=function(t){if(t=[].concat(ht(t)),t.length){var e=t.pop();return this.updateIn(t,function(t){return t&&t.remove(e)})}},e.prototype.deleteAll=function(t){var e=Ce(t);return 0===e.size?this:this.withMutations(function(t){e.forEach(function(e){return t.remove(e)})})},e.prototype.update=function(t,e,r){return 1===arguments.length?t(this):this.updateIn([t],e,r)},e.prototype.updateIn=function(t,e,r){r||(r=e,e=void 0);var n=xt(this,ht(t),0,e,r);return n===je?e:n},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):gt()},e.prototype.merge=function(){return Mt(this,void 0,arguments)},e.prototype.mergeWith=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Mt(this,t,e)},e.prototype.mergeIn=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return this.updateIn(t,gt(),function(t){return"function"==typeof t.merge?t.merge.apply(t,e):e[e.length-1]})},e.prototype.mergeDeep=function(){return Mt(this,Et(qt),arguments)},e.prototype.mergeDeepWith=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Mt(this,Et(t),e)},e.prototype.mergeDeepIn=function(t){ +for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return this.updateIn(t,gt(),function(t){return"function"==typeof t.mergeDeep?t.mergeDeep.apply(t,e):e[e.length-1]})},e.prototype.sort=function(t){return Br(tt(this,t))},e.prototype.sortBy=function(t,e){return Br(tt(this,e,t))},e.prototype.withMutations=function(t){var e=this.asMutable();return t(e),e.wasAltered()?e.__ensureOwner(this.__ownerID):this},e.prototype.asMutable=function(){return this.__ownerID?this:this.__ensureOwner(new n)},e.prototype.asImmutable=function(){return this.__ensureOwner()},e.prototype.wasAltered=function(){return this.__altered},e.prototype.__iterator=function(t,e){return new xr(this,t,e)},e.prototype.__iterate=function(t,e){var r=this,n=0;return this._root&&this._root.iterate(function(e){return n++,t(e[1],e[0],r)},e),n},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?dt(this.size,this._root,t,this.__hash):0===this.size?gt():(this.__ownerID=t,this.__altered=!1,this)},e}(Be);Sr.isMap=lt;var zr="@@__IMMUTABLE_MAP__@@",Ir=Sr.prototype;Ir[zr]=!0,Ir.delete=Ir.remove,Ir.removeIn=Ir.deleteIn,Ir.removeAll=Ir.deleteAll,Ir.concat=Ir.merge,Ir["@@transducer/init"]=Ir.asMutable,Ir["@@transducer/step"]=function(t,e){return t.set(e[0],e[1])},Ir["@@transducer/result"]=function(t){return t.asImmutable()};var br=function(t,e){this.ownerID=t,this.entries=e};br.prototype.get=function(t,e,r,n){for(var i=this.entries,o=0,u=i.length;o=jr)return It(t,h,o,u);var l=t&&t===this.ownerID,v=l?h:i(h);return _?c?f===p-1?v.pop():v[f]=v.pop():v[f]=[o,u]:v.push([o,u]),l?(this.entries=v,this):new br(t,v)}};var Or=function(t,e,r){this.ownerID=t,this.bitmap=e,this.nodes=r};Or.prototype.get=function(t,e,r,n){void 0===e&&(e=K(r));var i=1<<((0===t?e:e>>>t)&xe),o=this.bitmap +;return 0==(o&i)?n:this.nodes[jt(o&i-1)].get(t+Ee,e,r,n)},Or.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=K(n));var s=(0===e?r:r>>>e)&xe,a=1<=kr)return Ot(t,p,c,s,l);if(h&&!l&&2===p.length&&St(p[1^f]))return p[1^f];if(h&&l&&1===p.length&&St(l))return l;var v=t&&t===this.ownerID,y=h?l?c:c^a:c|a,d=h?l?kt(p,f,l,v):Rt(p,f,v):At(p,f,l,v);return v?(this.bitmap=y,this.nodes=d,this):new Or(t,y,d)};var Mr=function(t,e,r){this.ownerID=t,this.count=e,this.nodes=r};Mr.prototype.get=function(t,e,r,n){void 0===e&&(e=K(r));var i=(0===t?e:e>>>t)&xe,o=this.nodes[i];return o?o.get(t+Ee,e,r,n):n},Mr.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=K(n));var s=(0===e?r:r>>>e)&xe,a=i===je,c=this.nodes,h=c[s];if(a&&!h)return this;var f=wt(h,t,e+Ee,r,n,i,o,u);if(f===h)return this;var p=this.count;if(h){if(!f&&--p0&&i=0&&t>>e&xe;if(n>=this.array.length)return new Lr([],t);var i,o=0===n;if(e>0){var u=this.array[n];if((i=u&&u.removeBefore(t,e-Ee,r))===u&&o)return this}if(o&&!i)return this;var s=Wt(this,t);if(!o)for(var a=0;a>>e&xe;if(n>=this.array.length)return this;var i;if(e>0){var o=this.array[n];if((i=o&&o.removeAfter(t,e-Ee,r))===o&&n===this.array.length-1)return this}var u=Wt(this,t);return u.array.splice(n+1),i&&(u.array[n]=i),u};var Tr,Cr={},Br=function(t){function e(t){return null===t||void 0===t?Yt():Vt(t)?t:Yt().withMutations(function(e){var r=Be(t);pt(r.size),r.forEach(function(t,r){return e.set(r,t)})})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("OrderedMap {","}")},e.prototype.get=function(t,e){var r=this._map.get(t);return void 0!==r?this._list.get(r)[1]:e},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._map.clear(),this._list.clear(),this):Yt()},e.prototype.set=function(t,e){return Qt(this,t,e)},e.prototype.remove=function(t){return Qt(this,t,je)},e.prototype.wasAltered=function(){return this._map.wasAltered()||this._list.wasAltered()},e.prototype.__iterate=function(t,e){var r=this;return this._list.__iterate(function(e){return e&&t(e[1],e[0],r)},e)},e.prototype.__iterator=function(t,e){return this._list.fromEntrySeq().__iterator(t,e)},e.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var e=this._map.__ensureOwner(t),r=this._list.__ensureOwner(t);return t?Ht(e,r,t,this.__hash):0===this.size?Yt():(this.__ownerID=t,this._map=e,this._list=r,this)},e}(Sr) +;Br.isOrderedMap=Vt,Br.prototype[Le]=!0,Br.prototype.delete=Br.prototype.remove;var Wr,Jr=function(t){function e(t){return null===t||void 0===t?Gt():Xt(t)?t:Gt().pushAll(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("Stack [","]")},e.prototype.get=function(t,e){var r=this._head;for(t=u(this,t);r&&t--;)r=r.next;return r?r.value:e},e.prototype.peek=function(){return this._head&&this._head.value},e.prototype.push=function(){var t=arguments;if(0===arguments.length)return this;for(var e=this.size+arguments.length,r=this._head,n=arguments.length-1;n>=0;n--)r={value:t[n],next:r};return this.__ownerID?(this.size=e,this._head=r,this.__hash=void 0,this.__altered=!0,this):Ft(e,r)},e.prototype.pushAll=function(e){if(e=t(e),0===e.size)return this;if(0===this.size&&Xt(e))return e;pt(e.size);var r=this.size,n=this._head;return e.__iterate(function(t){r++,n={value:t,next:n}},!0),this.__ownerID?(this.size=r,this._head=n,this.__hash=void 0,this.__altered=!0,this):Ft(r,n)},e.prototype.pop=function(){return this.slice(1)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):Gt()},e.prototype.slice=function(e,r){if(a(e,r,this.size))return this;var n=c(e,this.size);if(h(r,this.size)!==this.size)return t.prototype.slice.call(this,e,r);for(var i=this.size-n,o=this._head;n--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):Ft(i,o)},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Ft(this.size,this._head,t,this.__hash):0===this.size?Gt():(this.__ownerID=t,this.__altered=!1,this)},e.prototype.__iterate=function(t,e){var r=this;if(e)return new er(this.toArray()).__iterate(function(e,n){return t(e,n,r)},e);for(var n=0,i=this._head;i&&t(i.value,n++,r)!==!1;)i=i.next;return n},e.prototype.__iterator=function(t,e){ +if(e)return new er(this.toArray()).__iterator(t,e);var r=0,n=this._head;return new Xe(function(){if(n){var e=n.value;return n=n.next,S(t,r++,e)}return z()})},e}(We);Jr.isStack=Xt;var Nr="@@__IMMUTABLE_STACK__@@",Pr=Jr.prototype;Pr[Nr]=!0,Pr.withMutations=Ir.withMutations,Pr.asMutable=Ir.asMutable,Pr.asImmutable=Ir.asImmutable,Pr.wasAltered=Ir.wasAltered,Pr.shift=Pr.pop,Pr.unshift=Pr.push,Pr.unshiftAll=Pr.pushAll,Pr["@@transducer/init"]=Pr.asMutable,Pr["@@transducer/step"]=function(t,e){return t.unshift(e)},Pr["@@transducer/result"]=Ir["@@transducer/result"];var Vr,Hr=function(t){function e(e){return null===e||void 0===e?ne():te(e)&&!g(e)?e:ne().withMutations(function(r){var n=t(e);pt(n.size),n.forEach(function(t){return r.add(t)})})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(Be(t).keySeq())},e.intersect=function(t){return t=Ce(t).toArray(),t.length?Qr.intersect.apply(e(t.pop()),t):ne()},e.union=function(t){return t=Ce(t).toArray(),t.length?Qr.union.apply(e(t.pop()),t):ne()},e.prototype.toString=function(){return this.__toString("Set {","}")},e.prototype.has=function(t){return this._map.has(t)},e.prototype.add=function(t){return ee(this,this._map.set(t,t))},e.prototype.remove=function(t){return ee(this,this._map.remove(t))},e.prototype.clear=function(){return ee(this,this._map.clear())},e.prototype.union=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return e=e.filter(function(t){return 0!==t.size}),0===e.length?this:0!==this.size||this.__ownerID||1!==e.length?this.withMutations(function(r){for(var n=0;n=0&&e=0&&rthis.size?e:this.find(function(e,r){return r===t},void 0,e)},has:function(t){return(t=u(this,t))>=0&&(void 0!==this.size?this.size===1/0||t Date: Wed, 11 Oct 2017 05:27:06 +0000 Subject: [PATCH 055/242] Deploy d11e5079b1dd82ffed5d186d2f20e506d1b0ba05 to NPM branch --- dist/immutable-nonambient.d.ts | 4 +++- dist/immutable.d.ts | 4 +++- dist/immutable.es.js | 9 ++------- dist/immutable.js | 9 ++------- dist/immutable.min.js | 6 +++--- 5 files changed, 13 insertions(+), 19 deletions(-) diff --git a/dist/immutable-nonambient.d.ts b/dist/immutable-nonambient.d.ts index 90de274d6f..b5ea82b6f6 100644 --- a/dist/immutable-nonambient.d.ts +++ b/dist/immutable-nonambient.d.ts @@ -230,6 +230,8 @@ /** * True if `maybeImmutable` is an Immutable Collection or Record. * + * Note: Still returns true even if the collections is within a `withMutations()`. + * * * ```js * const { isImmutable, Map, List, Stack } = require('immutable@4.0.0-rc.7'); @@ -238,7 +240,7 @@ * isImmutable(Map()); // true * isImmutable(List()); // true * isImmutable(Stack()); // true - * isImmutable(Map().asMutable()); // false + * isImmutable(Map().asMutable()); // true * ``` */ export function isImmutable(maybeImmutable: any): maybeImmutable is Collection; diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index e9900c67b4..bc478926e0 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -230,6 +230,8 @@ declare module Immutable { /** * True if `maybeImmutable` is an Immutable Collection or Record. * + * Note: Still returns true even if the collections is within a `withMutations()`. + * * * ```js * const { isImmutable, Map, List, Stack } = require('immutable@4.0.0-rc.7'); @@ -238,7 +240,7 @@ declare module Immutable { * isImmutable(Map()); // true * isImmutable(List()); // true * isImmutable(Stack()); // true - * isImmutable(Map().asMutable()); // false + * isImmutable(Map().asMutable()); // true * ``` */ export function isImmutable(maybeImmutable: any): maybeImmutable is Collection; diff --git a/dist/immutable.es.js b/dist/immutable.es.js index 0bb67f3d92..fb9e067a2f 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -109,10 +109,7 @@ function isNeg(value) { } function isImmutable(maybeImmutable) { - return ( - (isCollection(maybeImmutable) || isRecord(maybeImmutable)) && - !maybeImmutable.__ownerID - ); + return isCollection(maybeImmutable) || isRecord(maybeImmutable); } function isCollection(maybeCollection) { @@ -271,9 +268,7 @@ var Seq = (function (Collection$$1) { function Seq(value) { return value === null || value === undefined ? emptySequence() - : isCollection(value) || isRecord(value) - ? value.toSeq() - : seqFromValue(value); + : isImmutable(value) ? value.toSeq() : seqFromValue(value); } if ( Collection$$1 ) Seq.__proto__ = Collection$$1; diff --git a/dist/immutable.js b/dist/immutable.js index 7b5d880153..0f7afab0f4 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -115,10 +115,7 @@ function isNeg(value) { } function isImmutable(maybeImmutable) { - return ( - (isCollection(maybeImmutable) || isRecord(maybeImmutable)) && - !maybeImmutable.__ownerID - ); + return isCollection(maybeImmutable) || isRecord(maybeImmutable); } function isCollection(maybeCollection) { @@ -277,9 +274,7 @@ var Seq = (function (Collection$$1) { function Seq(value) { return value === null || value === undefined ? emptySequence() - : isCollection(value) || isRecord(value) - ? value.toSeq() - : seqFromValue(value); + : isImmutable(value) ? value.toSeq() : seqFromValue(value); } if ( Collection$$1 ) Seq.__proto__ = Collection$$1; diff --git a/dist/immutable.min.js b/dist/immutable.min.js index 7eca1e5425..54ff26590e 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -4,8 +4,8 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.Immutable={})}(this,function(t){"use strict";function e(t){return t.value=!1,t}function r(t){t&&(t.value=!0)}function n(){}function i(t,e){e=e||0;for(var r=Math.max(0,t.length-e),n=Array(r),i=0;i>>0;if(""+r!==e||4294967295===r)return NaN;e=r}return e<0?o(t)+e:e}function s(){return!0}function a(t,e,r){return(0===t&&!p(t)||void 0!==r&&t<=-r)&&(void 0===e||void 0!==r&&e>=r)}function c(t,e){return f(t,e,0)}function h(t,e){return f(t,e,e)}function f(t,e,r){return void 0===t?r:p(t)?e===1/0?e:0|Math.max(0,e+t):void 0===e||e===t?t:0|Math.min(e,t)}function p(t){return t<0||0===t&&1/t==-(1/0)}function _(t){return(l(t)||m(t))&&!t.__ownerID}function l(t){return!(!t||!t[Re])}function v(t){return!(!t||!t[Ue])}function y(t){return!(!t||!t[Ke])}function d(t){return v(t)||y(t)}function g(t){return!(!t||!t[Le])}function m(t){return!(!t||!t[Te])}function w(t){return!(!t||"function"!=typeof t.equals||"function"!=typeof t.hashCode)}function S(t,e,r,n){var i=0===t?e:1===t?r:[e,r];return n?n.value=i:n={value:i,done:!1},n}function z(){return{value:void 0,done:!0}}function I(t){return!!M(t)}function b(t){return t&&"function"==typeof t.next}function O(t){var e=M(t);return e&&e.call(t)}function M(t){var e=t&&(He&&t[He]||t[Ye]);if("function"==typeof e)return e}function q(t){return t&&"number"==typeof t.length}function E(t){return!(!t||!t[tr])}function D(){return nr||(nr=new er([]))}function x(t){var e=Array.isArray(t)?new er(t):b(t)?new ur(t):I(t)?new or(t):void 0;if(e)return e.fromEntrySeq();if("object"==typeof t)return new rr(t);throw new TypeError("Expected Array or collection object of [k, v] entries, or keyed object: "+t)}function j(t){var e=A(t);if(e)return e;throw new TypeError("Expected Array or collection object of values: "+t)}function k(t){ -var e=A(t);if(e)return e;if("object"==typeof t)return new rr(t);throw new TypeError("Expected Array or collection object of values, or keyed object: "+t)}function A(t){return q(t)?new er(t):b(t)?new ur(t):I(t)?new or(t):void 0}function R(t,e){if(t===e||t!==t&&e!==e)return!0;if(!t||!e)return!1;if("function"==typeof t.valueOf&&"function"==typeof e.valueOf){if(t=t.valueOf(),e=e.valueOf(),t===e||t!==t&&e!==e)return!0;if(!t||!e)return!1}return!!(w(t)&&w(e)&&t.equals(e))}function U(t){return t>>>1&1073741824|3221225471&t}function K(t){if(t===!1||null===t||void 0===t)return 0;if("function"==typeof t.valueOf&&((t=t.valueOf())===!1||null===t||void 0===t))return 0;if(t===!0)return 1;var e=typeof t;if("number"===e){if(t!==t||t===1/0)return 0;var r=0|t;for(r!==t&&(r^=4294967295*t);t>4294967295;)t/=4294967295,r^=t;return U(r)}if("string"===e)return t.length>_r?L(t):T(t);if("function"==typeof t.hashCode)return U(t.hashCode());if("object"===e)return C(t);if("function"==typeof t.toString)return T(""+t);throw Error("Value type "+e+" cannot be hashed.")}function L(t){var e=yr[t];return void 0===e&&(e=T(t),vr===lr&&(vr=0,yr={}),vr++,yr[t]=e),e}function T(t){for(var e=0,r=0;r>>0;if(""+r!==e||4294967295===r)return NaN;e=r}return e<0?o(t)+e:e}function s(){return!0}function a(t,e,r){return(0===t&&!p(t)||void 0!==r&&t<=-r)&&(void 0===e||void 0!==r&&e>=r)}function c(t,e){return f(t,e,0)}function h(t,e){return f(t,e,e)}function f(t,e,r){return void 0===t?r:p(t)?e===1/0?e:0|Math.max(0,e+t):void 0===e||e===t?t:0|Math.min(e,t)}function p(t){return t<0||0===t&&1/t==-(1/0)}function _(t){return l(t)||m(t)}function l(t){return!(!t||!t[Re])}function v(t){return!(!t||!t[Ue])}function y(t){return!(!t||!t[Ke])}function d(t){return v(t)||y(t)}function g(t){return!(!t||!t[Le])}function m(t){return!(!t||!t[Te])}function w(t){return!(!t||"function"!=typeof t.equals||"function"!=typeof t.hashCode)}function S(t,e,r,n){var i=0===t?e:1===t?r:[e,r];return n?n.value=i:n={value:i,done:!1},n}function z(){return{value:void 0,done:!0}}function I(t){return!!M(t)}function b(t){return t&&"function"==typeof t.next}function O(t){var e=M(t);return e&&e.call(t)}function M(t){var e=t&&(He&&t[He]||t[Ye]);if("function"==typeof e)return e}function q(t){return t&&"number"==typeof t.length}function E(t){return!(!t||!t[tr])}function D(){return nr||(nr=new er([]))}function x(t){var e=Array.isArray(t)?new er(t):b(t)?new ur(t):I(t)?new or(t):void 0;if(e)return e.fromEntrySeq();if("object"==typeof t)return new rr(t);throw new TypeError("Expected Array or collection object of [k, v] entries, or keyed object: "+t)}function j(t){var e=A(t);if(e)return e;throw new TypeError("Expected Array or collection object of values: "+t)}function k(t){var e=A(t) +;if(e)return e;if("object"==typeof t)return new rr(t);throw new TypeError("Expected Array or collection object of values, or keyed object: "+t)}function A(t){return q(t)?new er(t):b(t)?new ur(t):I(t)?new or(t):void 0}function R(t,e){if(t===e||t!==t&&e!==e)return!0;if(!t||!e)return!1;if("function"==typeof t.valueOf&&"function"==typeof e.valueOf){if(t=t.valueOf(),e=e.valueOf(),t===e||t!==t&&e!==e)return!0;if(!t||!e)return!1}return!!(w(t)&&w(e)&&t.equals(e))}function U(t){return t>>>1&1073741824|3221225471&t}function K(t){if(t===!1||null===t||void 0===t)return 0;if("function"==typeof t.valueOf&&((t=t.valueOf())===!1||null===t||void 0===t))return 0;if(t===!0)return 1;var e=typeof t;if("number"===e){if(t!==t||t===1/0)return 0;var r=0|t;for(r!==t&&(r^=4294967295*t);t>4294967295;)t/=4294967295,r^=t;return U(r)}if("string"===e)return t.length>_r?L(t):T(t);if("function"==typeof t.hashCode)return U(t.hashCode());if("object"===e)return C(t);if("function"==typeof t.toString)return T(""+t);throw Error("Value type "+e+" cannot be hashed.")}function L(t){var e=yr[t];return void 0===e&&(e=T(t),vr===lr&&(vr=0,yr={}),vr++,yr[t]=e),e}function T(t){for(var e=0,r=0;r0)switch(t.nodeType){case 1:return t.uniqueID;case 9:return t.documentElement&&t.documentElement.uniqueID}}function W(t){var e=st(t);return e._iter=t,e.size=t.size,e.flip=function(){return t},e.reverse=function(){var e=t.reverse.apply(this);return e.flip=function(){return t.reverse()},e},e.has=function(e){return t.includes(e)},e.includes=function(e){return t.has(e)},e.cacheResult=at,e.__iterateUncached=function(e,r){var n=this;return t.__iterate(function(t,r){return e(r,t,n)!==!1},r)},e.__iteratorUncached=function(e,r){if(e===Ve){var n=t.__iterator(e,r);return new Xe(function(){var t=n.next();if(!t.done){var e=t.value[0];t.value[0]=t.value[1],t.value[1]=e}return t})}return t.__iterator(e===Pe?Ne:Pe,r)},e}function J(t,e,r){var n=st(t);return n.size=t.size,n.has=function(e){return t.has(e)},n.get=function(n,i){var o=t.get(n,je);return o===je?i:e.call(r,o,n,t)},n.__iterateUncached=function(n,i){var o=this;return t.__iterate(function(t,i,u){return n(e.call(r,t,i,u),i,o)!==!1},i)},n.__iteratorUncached=function(n,i){var o=t.__iterator(Ve,i);return new Xe(function(){var i=o.next();if(i.done)return i;var u=i.value,s=u[0];return S(n,s,e.call(r,u[1],s,t),i)})},n}function N(t,e){var r=this,n=st(t);return n._iter=t,n.size=t.size,n.reverse=function(){return t},t.flip&&(n.flip=function(){var e=W(t);return e.reverse=function(){return t.flip()},e}),n.get=function(r,n){return t.get(e?r:-1-r,n)},n.has=function(r){return t.has(e?r:-1-r)},n.includes=function(e){return t.includes(e)},n.cacheResult=at,n.__iterate=function(r,n){var i=this,u=0;return n&&o(t),t.__iterate(function(t,o){return r(t,e?o:n?i.size-++u:u++,i)},!n)},n.__iterator=function(n,i){var u=0;i&&o(t);var s=t.__iterator(Ve,!i);return new Xe(function(){var t=s.next();if(t.done)return t;var o=t.value;return S(n,e?o[0]:i?r.size-++u:u++,o[1],t)})},n}function P(t,e,r,n){var i=st(t);return n&&(i.has=function(n){var i=t.get(n,je);return i!==je&&!!e.call(r,i,n,t)},i.get=function(n,i){var o=t.get(n,je);return o!==je&&e.call(r,o,n,t)?o:i}), i.__iterateUncached=function(i,o){var u=this,s=0;return t.__iterate(function(t,o,a){if(e.call(r,t,o,a))return s++,i(t,n?o:s-1,u)},o),s},i.__iteratorUncached=function(i,o){var u=t.__iterator(Ve,o),s=0;return new Xe(function(){for(;;){var o=u.next();if(o.done)return o;var a=o.value,c=a[0],h=a[1];if(e.call(r,h,c,t))return S(i,n?c:s++,h,o)}})},i}function V(t,e,r){var n=Sr().asMutable();return t.__iterate(function(i,o){n.update(e.call(r,i,o,t),0,function(t){return t+1})}),n.asImmutable()}function H(t,e,r){var n=v(t),i=(g(t)?Br():Sr()).asMutable();t.__iterate(function(o,u){i.update(e.call(r,o,u,t),function(t){return t=t||[],t.push(n?[u,o]:o),t})});var o=ut(t);return i.map(function(e){return it(t,o(e))})}function Y(t,e,r,n){var i=t.size;if(a(e,r,i))return t;var o=c(e,i),s=h(r,i);if(o!==o||s!==s)return Y(t.toSeq().cacheResult(),e,r,n);var f,p=s-o;p===p&&(f=p<0?0:p);var _=st(t);return _.size=0===f?f:t.size&&f||void 0,!n&&E(t)&&f>=0&&(_.get=function(e,r){return e=u(this,e),e>=0&&ef)return z();var t=i.next();return n||e===Pe||t.done?t:e===Ne?S(e,s-1,void 0,t):S(e,s-1,t.value[1],t)})},_}function Q(t,e,r){var n=st(t);return n.__iterateUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterate(n,i);var u=0;return t.__iterate(function(t,i,s){return e.call(r,t,i,s)&&++u&&n(t,i,o)}),u},n.__iteratorUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterator(n,i);var u=t.__iterator(Ve,i),s=!0;return new Xe(function(){if(!s)return z();var t=u.next();if(t.done)return t;var i=t.value,a=i[0],c=i[1];return e.call(r,c,a,o)?n===Ve?t:S(n,a,c,t):(s=!1,z())})},n} function X(t,e,r,n){var i=st(t);return i.__iterateUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterate(i,o);var s=!0,a=0;return t.__iterate(function(t,o,c){if(!s||!(s=e.call(r,t,o,c)))return a++,i(t,n?o:a-1,u)}),a},i.__iteratorUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterator(i,o);var s=t.__iterator(Ve,o),a=!0,c=0;return new Xe(function(){var t,o,h;do{if(t=s.next(),t.done)return n||i===Pe?t:i===Ne?S(i,c++,void 0,t):S(i,c++,t.value[1],t);var f=t.value;o=f[0],h=f[1],a&&(a=e.call(r,h,o,u))}while(a);return i===Ve?t:S(i,o,h,t)})},i}function F(t,e){var r=v(t),n=[t].concat(e).map(function(t){return l(t)?r&&(t=Be(t)):t=r?x(t):j(Array.isArray(t)?t:[t]),t}).filter(function(t){return 0!==t.size});if(0===n.length)return t;if(1===n.length){var i=n[0];if(i===t||r&&v(i)||y(t)&&y(i))return i}var o=new er(n);return r?o=o.toKeyedSeq():y(t)||(o=o.toSetSeq()),o=o.flatten(!0),o.size=n.reduce(function(t,e){if(void 0!==t){var r=e.size;if(void 0!==r)return t+r}},0),o}function G(t,e,r){var n=st(t);return n.__iterateUncached=function(i,o){function u(t,c){t.__iterate(function(t,o){return(!e||c=Pt(t._capacity))return t._tail;if(e<1<0;)r=r.array[e>>>n&xe],n-=Ee;return r}}function Nt(t,e,r){void 0!==e&&(e|=0),void 0!==r&&(r|=0);var i=t.__ownerID||new n,o=t._origin,u=t._capacity,s=o+e,a=void 0===r?u:r<0?u+r:o+r;if(s===o&&a===u)return t;if(s>=a)return t.clear();for(var c=t._level,h=t._root,f=0;s+f<0;)h=new Lr(h&&h.array.length?[void 0,h]:[],i),c+=Ee,f+=1<=1<p?new Lr([],i):l;if(l&&_>p&&sEe;d-=Ee){var g=p>>>d&xe;y=y.array[g]=Wt(y.array[g],i)}y.array[p>>>Ee&xe]=l}if(a=_)s-=_,a-=_,c=Ee,h=null,v=v&&v.removeBefore(i,0,s);else if(s>o||_>>c&xe;if(m!==_>>>c&xe)break;m&&(f+=(1<o&&(h=h.removeBefore(i,c,s-f)),h&&_>>Ee<=De&&u.size>=2*o.size?(i=u.filter(function(t,e){return void 0!==t&&s!==e}),n=i.toKeyedSeq().map(function(t){return t[0]}).flip().toMap(),t.__ownerID&&(n.__ownerID=i.__ownerID=t.__ownerID)):(n=o.remove(e),i=s===u.size-1?u.pop():u.set(s,void 0))}else if(a){if(r===u.get(s)[1])return t;n=o,i=u.set(s,[e,r])}else n=o.set(e,u.size),i=u.set(u.size,[e,r]) ;return t.__ownerID?(t.size=n.size,t._map=n,t._list=i,t.__hash=void 0,t):Ht(n,i)}function Xt(t){return!(!t||!t[Nr])}function Ft(t,e,r,n){var i=Object.create(Pr);return i.size=t,i._head=e,i.__ownerID=r,i.__hash=n,i.__altered=!1,i}function Gt(){return Vr||(Vr=Ft(0))}function Zt(t,e){if(t===e)return!0;if(!l(e)||void 0!==t.size&&void 0!==e.size&&t.size!==e.size||void 0!==t.__hash&&void 0!==e.__hash&&t.__hash!==e.__hash||v(t)!==v(e)||y(t)!==y(e)||g(t)!==g(e))return!1;if(0===t.size&&0===e.size)return!0;var r=!d(t);if(g(t)){var n=t.entries();return e.every(function(t,e){var i=n.next().value;return i&&R(i[1],t)&&(r||R(i[0],e))})&&n.next().done}var i=!1;if(void 0===t.size)if(void 0===e.size)"function"==typeof t.cacheResult&&t.cacheResult();else{i=!0;var o=t;t=e,e=o}var u=!0,s=e.__iterate(function(e,n){if(r?!t.has(e):i?!R(e,t.get(n,je)):!R(t.get(n,je),e))return u=!1,!1});return u&&t.size===s}function $t(t,e){var r=function(r){t.prototype[r]=e[r]};return Object.keys(e).forEach(r),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(e).forEach(r),t}function te(t){return!(!t||!t[Yr])}function ee(t,e){return t.__ownerID?(t.size=e.size,t._map=e,t):e===t._map?t:0===e.size?t.__empty():t.__make(e)}function re(t,e){var r=Object.create(Qr);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function ne(){return Xr||(Xr=re(gt()))}function ie(t,e,r,n,i,o){return pt(t.size),t.__iterate(function(t,o,u){i?(i=!1,r=t):r=e.call(n,r,t,o,u)},o),r}function oe(t,e){return e}function ue(t,e){return[e,t]}function se(t){return t&&"function"==typeof t.toJS?t.toJS():t}function ae(t){return function(){return!t.apply(this,arguments)}}function ce(t){return function(){return-t.apply(this,arguments)}}function he(){return i(arguments)}function fe(t,e){return te?-1:0}function pe(t){if(t.size===1/0)return 0;var e=g(t),r=v(t),n=e?1:0;return _e(t.__iterate(r?e?function(t,e){n=31*n+le(K(t),K(e))|0}:function(t,e){n=n+le(K(t),K(e))|0}:e?function(t){n=31*n+K(t)|0}:function(t){n=n+K(t)|0}),n)}function _e(t,e){return e=sr(e,3432918353), e=sr(e<<15|e>>>-15,461845907),e=sr(e<<13|e>>>-13,5),e=(e+3864292196|0)^t,e=sr(e^e>>>16,2246822507),e=sr(e^e>>>13,3266489909),e=U(e^e>>>16)}function le(t,e){return t^e+2654435769+(t<<6)+(t>>2)|0}function ve(t){if("object"!=typeof console||!console.warn)throw Error(t);console.warn(t)}function ye(t,e,r,n){for(var i=ht(r),o=0;o!==i.length;){if(null==t)return e;if(!t||!t.get)return n&&ve("Invalid keyPath: Value at ["+i.slice(0,o).map(_t)+"] does not have a .get() method: "+t+"\nThis warning will throw in a future version"),e;if((t=t.get(i[o++],je))===je)return e}return t}function de(t){return te(t)&&g(t)}function ge(t,e){var r=Object.create(rn);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function me(){return nn||(nn=ge(Yt()))}function we(t,e,r){var n=Object.create(Object.getPrototypeOf(t));return n._values=e,n.__ownerID=r,n}function Se(t){return t._name||t.constructor.name||"Record"}function ze(t){return x(t._keys.map(function(e){return[e,t.get(e)]}))}function Ie(t,e){try{Object.defineProperty(t,e,{get:function(){return this.get(e)},set:function(t){ft(this.__ownerID,"Cannot set on an immutable record."),this.set(e,t)}})}catch(t){}}function be(t,e){return Oe([],e||Me,t,"",e&&e.length>2?[]:void 0,{"":t})}function Oe(t,e,r,n,i,o){var u=Array.isArray(r)?Ze:qe(r)?Ge:null;if(u){if(~t.indexOf(r))throw new TypeError("Cannot convert circular structure to Immutable");t.push(r),i&&""!==n&&i.push(n);var s=e.call(o,n,u(r).map(function(n,o){return Oe(t,e,n,o,i,r)}),i&&i.slice());return t.pop(),i&&i.pop(),s}return r}function Me(t,e){return v(e)?e.toMap():e.toList()}function qe(t){return t&&(t.constructor===Object||void 0===t.constructor)}var Ee=5,De=1<=n.length){var e=r.next();if(e.done)return e;n[i]=e.value}return S(t,i,n[i++])})},e}(Ze),sr="function"==typeof Math.imul&&Math.imul(4294967295,2)===-2?Math.imul:function(t,e){t|=0,e|=0;var r=65535&t,n=65535&e;return r*n+((t>>>16)*n+r*(e>>>16)<<16>>>0)|0},ar=Object.isExtensible,cr=function(){try{return Object.defineProperty({},"@",{}),!0}catch(t){return!1}}(),hr="function"==typeof WeakMap;hr&&(ir=new WeakMap);var fr=0,pr="__immutablehash__";"function"==typeof Symbol&&(pr=Symbol(pr));var _r=16,lr=255,vr=0,yr={},dr=function(t){function e(t,e){this._iter=t,this._useKeys=e,this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t,e){return this._iter.get(t,e)},e.prototype.has=function(t){return this._iter.has(t)},e.prototype.valueSeq=function(){return this._iter.valueSeq()},e.prototype.reverse=function(){var t=this,e=N(this,!0);return this._useKeys||(e.valueSeq=function(){return t._iter.toSeq().reverse()}),e},e.prototype.map=function(t,e){var r=this,n=J(this,t,e);return this._useKeys||(n.valueSeq=function(){ return r._iter.toSeq().map(t,e)}),n},e.prototype.__iterate=function(t,e){var r=this;return this._iter.__iterate(function(e,n){return t(e,n,r)},e)},e.prototype.__iterator=function(t,e){return this._iter.__iterator(t,e)},e}(Ge);dr.prototype[Le]=!0;var gr=function(t){function e(t){this._iter=t,this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.includes=function(t){return this._iter.includes(t)},e.prototype.__iterate=function(t,e){var r=this,n=0;return e&&o(this),this._iter.__iterate(function(i){return t(i,e?r.size-++n:n++,r)},e)},e.prototype.__iterator=function(t,e){var r=this,n=this._iter.__iterator(Pe,e),i=0;return e&&o(this),new Xe(function(){var o=n.next();return o.done?o:S(t,e?r.size-++i:i++,o.value,o)})},e}(Ze),mr=function(t){function e(t){this._iter=t,this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.has=function(t){return this._iter.includes(t)},e.prototype.__iterate=function(t,e){var r=this;return this._iter.__iterate(function(e){return t(e,e,r)},e)},e.prototype.__iterator=function(t,e){var r=this._iter.__iterator(Pe,e);return new Xe(function(){var e=r.next();return e.done?e:S(t,e.value,e.value,e)})},e}($e),wr=function(t){function e(t){this._iter=t,this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.entrySeq=function(){return this._iter.toSeq()},e.prototype.__iterate=function(t,e){var r=this;return this._iter.__iterate(function(e){if(e){ot(e);var n=l(e);return t(n?e.get(1):e[1],n?e.get(0):e[0],r)}},e)},e.prototype.__iterator=function(t,e){var r=this._iter.__iterator(Pe,e);return new Xe(function(){for(;;){var e=r.next();if(e.done)return e;var n=e.value;if(n){ot(n);var i=l(n);return S(t,i?n.get(0):n[0],i?n.get(1):n[1],e)}}})},e}(Ge);gr.prototype.cacheResult=dr.prototype.cacheResult=mr.prototype.cacheResult=wr.prototype.cacheResult=at;var Sr=function(t){function e(e){ From 90d67aed8ab5870793d835da5f0c8e5ba5a5aa0b Mon Sep 17 00:00:00 2001 From: Travis CI Date: Wed, 11 Oct 2017 18:55:29 +0000 Subject: [PATCH 056/242] Deploy 411a8ea95e883dade832cc1971b0f7e8b28172f4 to NPM branch --- dist/immutable.js.flow | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/dist/immutable.js.flow b/dist/immutable.js.flow index 7c431bc2a0..c4ab588a24 100644 --- a/dist/immutable.js.flow +++ b/dist/immutable.js.flow @@ -32,6 +32,21 @@ // some constructors and functions. type PlainObjInput = {[key: K]: V, __proto__: null}; +// Helper types to extract the "keys" and "values" use by the *In() methods. +// Exported for experimental use only, may change. +export type $KeyOf = $Call< + & ((?_Collection) => K) + & ((?RecordInstance) => $Keys), + C +>; + +export type $ValOf> = $Call< + & ((?_Collection) => V) + & (>(?RecordInstance, K) => $ElementType), + C, + K +>; + declare class _Collection /*implements ValueObject*/ { equals(other: mixed): boolean; hashCode(): number; @@ -43,9 +58,15 @@ declare class _Collection /*implements ValueObject*/ { first(): V | void; last(): V | void; - getIn(keyPath: Iterable, notSetValue?: mixed): any; hasIn(keyPath: Iterable): boolean; + getIn(keyPath: [], notSetValue?: mixed): this; + getIn(keyPath: [K], notSetValue: NSV): V | NSV; + getIn>(keyPath: [K, K2], notSetValue: NSV): $ValOf | NSV; + getIn, K3: $KeyOf<$ValOf>>(keyPath: [K, K2, K3], notSetValue: NSV): $ValOf<$ValOf, K3> | NSV; + getIn, K3: $KeyOf<$ValOf>, K4: $KeyOf<$ValOf<$ValOf, K3>>>(keyPath: [K, K2, K3, K4], notSetValue: NSV): $ValOf<$ValOf<$ValOf, K3>, K4> | NSV; + getIn, K3: $KeyOf<$ValOf>, K4: $KeyOf<$ValOf<$ValOf, K3>>, K5: $KeyOf<$ValOf<$ValOf<$ValOf, K3>, K4>>>(keyPath: [K, K2, K3, K4, K5], notSetValue: NSV): $ValOf<$ValOf<$ValOf<$ValOf, K3>, K4>, K5> | NSV; + update(updater: (value: this) => U): U; toJS(): Array | { [key: string]: mixed }; @@ -1385,7 +1406,13 @@ declare class RecordInstance { get>(key: K): $ElementType; hasIn(keyPath: Iterable): boolean; - getIn(keyPath: Iterable, notSetValue?: mixed): any; + + getIn(keyPath: [], notSetValue?: mixed): this & T; + getIn>(keyPath: [K], notSetValue?: mixed): $ElementType; + getIn, K2: $KeyOf<$ElementType>>(keyPath: [K, K2], notSetValue: NSV): $ValOf<$ElementType, K2> | NSV; + getIn, K2: $KeyOf<$ElementType>, K3: $KeyOf<$ValOf<$ElementType, K2>>>(keyPath: [K, K2, K3], notSetValue: NSV): $ValOf<$ValOf<$ElementType, K2>, K3> | NSV; + getIn, K2: $KeyOf<$ElementType>, K3: $KeyOf<$ValOf<$ElementType, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ElementType, K2>, K3>>>(keyPath: [K, K2, K3, K4], notSetValue: NSV): $ValOf<$ValOf<$ValOf<$ElementType, K2>, K3>, K4> | NSV; + getIn, K2: $KeyOf<$ElementType>, K3: $KeyOf<$ValOf<$ElementType, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ElementType, K2>, K3>>, K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ElementType, K2>, K3>, K4>>>(keyPath: [K, K2, K3, K4, K5], notSetValue: NSV): $ValOf<$ValOf<$ValOf<$ValOf<$ElementType, K2>, K3>, K4>, K5> | NSV; equals(other: any): boolean; hashCode(): number; From 69830bce6395cc15045cd68069a4e22350a61a80 Mon Sep 17 00:00:00 2001 From: Travis CI Date: Thu, 12 Oct 2017 01:31:50 +0000 Subject: [PATCH 057/242] Deploy 07db3063043d5e1bb2c2f38d2152e3d48d20d7b6 to NPM branch --- dist/immutable.js.flow | 121 +++++++++++++++++++++++++---------------- 1 file changed, 73 insertions(+), 48 deletions(-) diff --git a/dist/immutable.js.flow b/dist/immutable.js.flow index c4ab588a24..24e8e4dbb6 100644 --- a/dist/immutable.js.flow +++ b/dist/immutable.js.flow @@ -662,8 +662,44 @@ declare class SetSeq<+T> extends Seq mixins SetCollection { flatten(shallow?: boolean): SetSeq; } +declare class UpdatableInCollection { + setIn(keyPath: [], value: S): S; + setIn(keyPath: [K], value: V): this; + setIn, S: $ValOf>(keyPath: [K, K2], value: S): this; + setIn, K3: $KeyOf<$ValOf>, S: $ValOf<$ValOf, K3>>(keyPath: [K, K2, K3], value: S): this; + setIn, K3: $KeyOf<$ValOf>, K4: $KeyOf<$ValOf<$ValOf, K3>>, S: $ValOf<$ValOf<$ValOf, K3>, K4>>(keyPath: [K, K2, K3, K4], value: S): this; + setIn, K3: $KeyOf<$ValOf>, K4: $KeyOf<$ValOf<$ValOf, K3>>, K5: $KeyOf<$ValOf<$ValOf<$ValOf, K3>, K4>>, S: $ValOf<$ValOf<$ValOf<$ValOf, K3>, K4>, K5>>(keyPath: [K, K2, K3, K4, K5], value: S): this; + + deleteIn(keyPath: []): void; + deleteIn(keyPath: [K]): this; + deleteIn>(keyPath: [K, K2]): this; + deleteIn, K3: $KeyOf<$ValOf>>(keyPath: [K, K2, K3]): this; + deleteIn, K3: $KeyOf<$ValOf>, K4: $KeyOf<$ValOf<$ValOf, K3>>>(keyPath: [K, K2, K3, K4]): this; + deleteIn, K3: $KeyOf<$ValOf>, K4: $KeyOf<$ValOf<$ValOf, K3>>, K5: $KeyOf<$ValOf<$ValOf<$ValOf, K3>, K4>>>(keyPath: [K, K2, K3, K4, K5]): this; + + removeIn(keyPath: []): void; + removeIn(keyPath: [K]): this; + removeIn>(keyPath: [K, K2]): this; + removeIn, K3: $KeyOf<$ValOf>>(keyPath: [K, K2, K3]): this; + removeIn, K3: $KeyOf<$ValOf>, K4: $KeyOf<$ValOf<$ValOf, K3>>>(keyPath: [K, K2, K3, K4]): this; + removeIn, K3: $KeyOf<$ValOf>, K4: $KeyOf<$ValOf<$ValOf, K3>>, K5: $KeyOf<$ValOf<$ValOf<$ValOf, K3>, K4>>>(keyPath: [K, K2, K3, K4, K5]): this; + + updateIn(keyPath: [], notSetValue: mixed, updater: (value: this) => U): U; + updateIn(keyPath: [], updater: (value: this) => U): U; + updateIn(keyPath: [K], notSetValue: NSV, updater: (value: V) => V): this; + updateIn(keyPath: [K], updater: (value: V) => V): this; + updateIn, S: $ValOf>(keyPath: [K, K2], notSetValue: NSV, updater: (value: $ValOf | NSV) => S): this; + updateIn, S: $ValOf>(keyPath: [K, K2], updater: (value: $ValOf) => S): this; + updateIn, K3: $KeyOf<$ValOf>, S: $ValOf<$ValOf, K3>>(keyPath: [K, K2, K3], notSetValue: NSV, updater: (value: $ValOf<$ValOf, K3> | NSV) => S): this; + updateIn, K3: $KeyOf<$ValOf>, S: $ValOf<$ValOf, K3>>(keyPath: [K, K2, K3], updater: (value: $ValOf<$ValOf, K3>) => S): this; + updateIn, K3: $KeyOf<$ValOf>, K4: $KeyOf<$ValOf<$ValOf, K3>>, S: $ValOf<$ValOf<$ValOf, K3>, K4>>(keyPath: [K, K2, K3, K4], notSetValue: NSV, updater: (value: $ValOf<$ValOf<$ValOf, K3>, K4> | NSV) => S): this; + updateIn, K3: $KeyOf<$ValOf>, K4: $KeyOf<$ValOf<$ValOf, K3>>, S: $ValOf<$ValOf<$ValOf, K3>, K4>>(keyPath: [K, K2, K3, K4], updater: (value: $ValOf<$ValOf<$ValOf, K3>, K4>) => S): this; + updateIn, K3: $KeyOf<$ValOf>, K4: $KeyOf<$ValOf<$ValOf, K3>>, K5: $KeyOf<$ValOf<$ValOf<$ValOf, K3>, K4>>, S: $ValOf<$ValOf<$ValOf<$ValOf, K3>, K4>, K5>>(keyPath: [K, K2, K3, K4, K5], notSetValue: NSV, updater: (value: $ValOf<$ValOf<$ValOf<$ValOf, K3>, K4>, K5> | NSV) => S): this; + updateIn, K3: $KeyOf<$ValOf>, K4: $KeyOf<$ValOf<$ValOf, K3>>, K5: $KeyOf<$ValOf<$ValOf<$ValOf, K3>, K4>>, S: $ValOf<$ValOf<$ValOf<$ValOf, K3>, K4>, K5>>(keyPath: [K, K2, K3, K4, K5], updater: (value: $ValOf<$ValOf<$ValOf<$ValOf, K3>, K4>, K5>) => S): this; +} + declare function isList(maybeList: mixed): boolean %checks(maybeList instanceof List); -declare class List<+T> extends IndexedCollection { +declare class List<+T> extends IndexedCollection mixins UpdatableInCollection { static (collection?: Iterable): List; static of(...values: T[]): List; @@ -689,19 +725,6 @@ declare class List<+T> extends IndexedCollection { merge(...collections: Iterable[]): List; setSize(size: number): this; - setIn(keyPath: Iterable, value: mixed): this; - deleteIn(keyPath: Iterable, value: mixed): this; - removeIn(keyPath: Iterable, value: mixed): this; - - updateIn( - keyPath: Iterable, - notSetValue: mixed, - updater: (value: any) => mixed - ): this; - updateIn( - keyPath: Iterable, - updater: (value: any) => mixed - ): this; mergeIn(keyPath: Iterable, ...collections: Iterable[]): this; mergeDeepIn(keyPath: Iterable, ...collections: Iterable[]): this; @@ -834,7 +857,7 @@ declare class List<+T> extends IndexedCollection { } declare function isMap(maybeMap: mixed): boolean %checks(maybeMap instanceof Map); -declare class Map extends KeyedCollection { +declare class Map extends KeyedCollection mixins UpdatableInCollection { static (collection: Iterable<[K, V]>): Map; static (obj?: PlainObjInput): Map; @@ -875,20 +898,6 @@ declare class Map extends KeyedCollection { ...collections: (Iterable<[K_, W]> | PlainObjInput)[] ): Map; - setIn(keyPath: Iterable, value: mixed): this; - deleteIn(keyPath: Iterable, value: mixed): this; - removeIn(keyPath: Iterable, value: mixed): this; - - updateIn( - keyPath: Iterable, - notSetValue: mixed, - updater: (value: any) => mixed - ): this; - updateIn( - keyPath: Iterable, - updater: (value: any) => mixed - ): this; - mergeIn( keyPath: Iterable, ...collections: (Iterable | PlainObjInput)[] @@ -938,7 +947,7 @@ declare class Map extends KeyedCollection { } declare function isOrderedMap(maybeOrderedMap: mixed): boolean %checks(maybeOrderedMap instanceof OrderedMap); -declare class OrderedMap extends Map { +declare class OrderedMap extends Map mixins UpdatableInCollection { static (collection: Iterable<[K, V]>): OrderedMap; static (obj?: PlainObjInput): OrderedMap; @@ -976,20 +985,6 @@ declare class OrderedMap extends Map { ...collections: (Iterable<[K_, W]> | PlainObjInput)[] ): OrderedMap; - setIn(keyPath: Iterable, value: mixed): this; - deleteIn(keyPath: Iterable, value: mixed): this; - removeIn(keyPath: Iterable, value: mixed): this; - - updateIn( - keyPath: Iterable, - notSetValue: mixed, - updater: (value: any) => mixed - ): this; - updateIn( - keyPath: Iterable, - updater: (value: any) => mixed - ): this; - mergeIn( keyPath: Iterable, ...collections: (Iterable | PlainObjInput)[] @@ -1435,12 +1430,42 @@ declare class RecordInstance { remove>(key: K): this & T; clear(): this & T; - setIn(keyPath: Iterable, value: any): this & T; - updateIn(keyPath: Iterable, updater: (value: any) => any): this & T; + setIn(keyPath: [], value: S): S; + setIn, S: $ElementType>(keyPath: [K], value: S): this & T; + setIn, K2: $KeyOf<$ElementType>, S: $ValOf<$ElementType, K2>>(keyPath: [K, K2], value: S): this & T; + setIn, K2: $KeyOf<$ElementType>, K3: $KeyOf<$ValOf<$ElementType, K2>>, S: $ValOf<$ValOf<$ElementType, K2>, K3>>(keyPath: [K, K2, K3], value: S): this & T; + setIn, K2: $KeyOf<$ElementType>, K3: $KeyOf<$ValOf<$ElementType, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ElementType, K2>, K3>>, S: $ValOf<$ValOf<$ValOf<$ElementType, K2>, K3>, K4>>(keyPath: [K, K2, K3, K4], value: S): this & T; + setIn, K2: $KeyOf<$ElementType>, K3: $KeyOf<$ValOf<$ElementType, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ElementType, K2>, K3>>, K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ElementType, K2>, K3>, K4>>, S: $ValOf<$ValOf<$ValOf<$ValOf<$ElementType, K2>, K3>, K4>, K5>>(keyPath: [K, K2, K3, K4, K5], value: S): this & T; + + deleteIn(keyPath: []): void; + deleteIn>(keyPath: [K]): this & T; + deleteIn, K2: $KeyOf<$ElementType>>(keyPath: [K, K2]): this & T; + deleteIn, K2: $KeyOf<$ElementType>, K3: $KeyOf<$ValOf<$ElementType, K2>>>(keyPath: [K, K2, K3]): this & T; + deleteIn, K2: $KeyOf<$ElementType>, K3: $KeyOf<$ValOf<$ElementType, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ElementType, K2>, K3>>>(keyPath: [K, K2, K3, K4]): this & T; + deleteIn, K2: $KeyOf<$ElementType>, K3: $KeyOf<$ValOf<$ElementType, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ElementType, K2>, K3>>, K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ElementType, K2>, K3>, K4>>>(keyPath: [K, K2, K3, K4, K5]): this & T; + + removeIn(keyPath: []): void; + removeIn>(keyPath: [K]): this & T; + removeIn, K2: $KeyOf<$ElementType>>(keyPath: [K, K2]): this & T; + removeIn, K2: $KeyOf<$ElementType>, K3: $KeyOf<$ValOf<$ElementType, K2>>>(keyPath: [K, K2, K3]): this & T; + removeIn, K2: $KeyOf<$ElementType>, K3: $KeyOf<$ValOf<$ElementType, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ElementType, K2>, K3>>>(keyPath: [K, K2, K3, K4]): this & T; + removeIn, K2: $KeyOf<$ElementType>, K3: $KeyOf<$ValOf<$ElementType, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ElementType, K2>, K3>>, K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ElementType, K2>, K3>, K4>>>(keyPath: [K, K2, K3, K4, K5]): this & T; + + updateIn(keyPath: [], notSetValue: mixed, updater: (value: this) => U): U; + updateIn(keyPath: [], updater: (value: this) => U): U; + updateIn, S: $ElementType>(keyPath: [K], notSetValue: NSV, updater: (value: $ElementType) => S): this & T; + updateIn, S: $ElementType>(keyPath: [K], updater: (value: $ElementType) => S): this & T; + updateIn, K2: $KeyOf<$ElementType>, S: $ValOf<$ElementType, K2>>(keyPath: [K, K2], notSetValue: NSV, updater: (value: $ValOf<$ElementType, K2> | NSV) => S): this & T; + updateIn, K2: $KeyOf<$ElementType>, S: $ValOf<$ElementType, K2>>(keyPath: [K, K2], updater: (value: $ValOf<$ElementType, K2>) => S): this & T; + updateIn, K2: $KeyOf<$ElementType>, K3: $KeyOf<$ValOf<$ElementType, K2>>, S: $ValOf<$ValOf<$ElementType, K2>, K3>>(keyPath: [K, K2, K3], notSetValue: NSV, updater: (value: $ValOf<$ValOf<$ElementType, K2>, K3> | NSV) => S): this & T; + updateIn, K2: $KeyOf<$ElementType>, K3: $KeyOf<$ValOf<$ElementType, K2>>, S: $ValOf<$ValOf<$ElementType, K2>, K3>>(keyPath: [K, K2, K3], updater: (value: $ValOf<$ValOf<$ElementType, K2>, K3>) => S): this & T; + updateIn, K2: $KeyOf<$ElementType>, K3: $KeyOf<$ValOf<$ElementType, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ElementType, K2>, K3>>, S: $ValOf<$ValOf<$ValOf<$ElementType, K2>, K3>, K4>>(keyPath: [K, K2, K3, K4], notSetValue: NSV, updater: (value: $ValOf<$ValOf<$ValOf<$ElementType, K2>, K3>, K4> | NSV) => S): this & T; + updateIn, K2: $KeyOf<$ElementType>, K3: $KeyOf<$ValOf<$ElementType, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ElementType, K2>, K3>>, S: $ValOf<$ValOf<$ValOf<$ElementType, K2>, K3>, K4>>(keyPath: [K, K2, K3, K4], updater: (value: $ValOf<$ValOf<$ValOf<$ElementType, K2>, K3>, K4>) => S): this & T; + updateIn, K2: $KeyOf<$ElementType>, K3: $KeyOf<$ValOf<$ElementType, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ElementType, K2>, K3>>, K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ElementType, K2>, K3>, K4>>, S: $ValOf<$ValOf<$ValOf<$ValOf<$ElementType, K2>, K3>, K4>, K5>>(keyPath: [K, K2, K3, K4, K5], notSetValue: NSV, updater: (value: $ValOf<$ValOf<$ValOf<$ValOf<$ElementType, K2>, K3>, K4>, K5> | NSV) => S): this & T; + updateIn, K2: $KeyOf<$ElementType>, K3: $KeyOf<$ValOf<$ElementType, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ElementType, K2>, K3>>, K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ElementType, K2>, K3>, K4>>, S: $ValOf<$ValOf<$ValOf<$ValOf<$ElementType, K2>, K3>, K4>, K5>>(keyPath: [K, K2, K3, K4, K5], updater: (value: $ValOf<$ValOf<$ValOf<$ValOf<$ElementType, K2>, K3>, K4>, K5>) => S): this & T; + mergeIn(keyPath: Iterable, ...collections: Array): this & T; mergeDeepIn(keyPath: Iterable, ...collections: Array): this & T; - deleteIn(keyPath: Iterable): this & T; - removeIn(keyPath: Iterable): this & T; toSeq(): KeyedSeq<$Keys, any>; From 5bb86b1ea474319f5da7c5a8c7289cf896f67cd2 Mon Sep 17 00:00:00 2001 From: Travis CI Date: Thu, 12 Oct 2017 02:04:44 +0000 Subject: [PATCH 058/242] Deploy f9f058aed6e789b1dfd9329019aa41a7d06201b3 to NPM branch --- dist/immutable.js.flow | 49 +++++++++++++++++------------------------- 1 file changed, 20 insertions(+), 29 deletions(-) diff --git a/dist/immutable.js.flow b/dist/immutable.js.flow index 24e8e4dbb6..e6884f1b14 100644 --- a/dist/immutable.js.flow +++ b/dist/immutable.js.flow @@ -220,8 +220,7 @@ declare class Collection extends _Collection { } declare class KeyedCollection extends Collection { - static (iter?: Iterable<[K, V]>): KeyedCollection; - static (obj?: PlainObjInput): KeyedCollection; + static (values?: Iterable<[K, V]> | PlainObjInput): KeyedCollection; toJS(): { [key: string]: mixed }; toJSON(): { [key: string]: V }; @@ -230,8 +229,7 @@ declare class KeyedCollection extends Collection { toSeq(): KeyedSeq; flip(): KeyedCollection; - concat(...iters: Array>): KeyedCollection; - concat(...iters: Array>): KeyedCollection; + concat(...iters: Array | PlainObjInput>): KeyedCollection; filter(predicate: typeof Boolean): KeyedCollection>; filter( @@ -454,10 +452,10 @@ declare class Seq extends _Collection { static Indexed: typeof IndexedSeq; static Set: typeof SetSeq; - static (iter: KeyedSeq): KeyedSeq; - static (iter: SetSeq): SetSeq; - static (iter?: Iterable): IndexedSeq; - static (iter: PlainObjInput): KeyedSeq; + static (values: KeyedSeq): KeyedSeq; + static (values: SetSeq): SetSeq; + static (values: Iterable): IndexedSeq; + static (values?: PlainObjInput): KeyedSeq; static isSeq: typeof isSeq; @@ -467,14 +465,12 @@ declare class Seq extends _Collection { } declare class KeyedSeq extends Seq mixins KeyedCollection { - static (iter?: Iterable<[K, V]>): KeyedSeq; - static (iter?: PlainObjInput): KeyedSeq; + static (values?: Iterable<[K, V]> | PlainObjInput): KeyedSeq; // Override specialized return types flip(): KeyedSeq; - concat(...iters: Array>): KeyedSeq; - concat(...iters: Array>): KeyedSeq; + concat(...iters: Array | PlainObjInput>): KeyedSeq; filter(predicate: typeof Boolean): KeyedSeq>; filter( @@ -858,8 +854,7 @@ declare class List<+T> extends IndexedCollection mixins UpdatableInCollection declare function isMap(maybeMap: mixed): boolean %checks(maybeMap instanceof Map); declare class Map extends KeyedCollection mixins UpdatableInCollection { - static (collection: Iterable<[K, V]>): Map; - static (obj?: PlainObjInput): Map; + static (values?: Iterable<[K, V]> | PlainObjInput): Map; static isMap: typeof isMap; @@ -948,8 +943,7 @@ declare class Map extends KeyedCollection mixins UpdatableInCollect declare function isOrderedMap(maybeOrderedMap: mixed): boolean %checks(maybeOrderedMap instanceof OrderedMap); declare class OrderedMap extends Map mixins UpdatableInCollection { - static (collection: Iterable<[K, V]>): OrderedMap; - static (obj?: PlainObjInput): OrderedMap; + static (values?: Iterable<[K, V]> | PlainObjInput): OrderedMap; static isOrderedMap: typeof isOrderedMap; @@ -1035,11 +1029,10 @@ declare class OrderedMap extends Map mixins UpdatableInCollection extends SetCollection { - static (collection?: Iterable): Set; + static (values?: Iterable): Set; static of(...values: T[]): Set; - static fromKeys(iter: Iterable<[T, mixed]>): Set; - static fromKeys(object: PlainObjInput): Set; + static fromKeys(values: Iterable<[T, mixed]> | PlainObjInput): Set; static intersect(sets: Iterable>): Set; static union(sets: Iterable>): Set; @@ -1088,12 +1081,10 @@ declare class Set<+T> extends SetCollection { // Overrides except for `isOrderedSet` are for specialized return types declare function isOrderedSet(maybeOrderedSet: mixed): boolean %checks(maybeOrderedSet instanceof OrderedSet); declare class OrderedSet<+T> extends Set { - static (collection: Iterable): OrderedSet; - static (_: void): OrderedSet; + static (values?: Iterable): OrderedSet; static of(...values: T[]): OrderedSet; - static fromKeys(iter: Iterable<[T, mixed]>): OrderedSet; - static fromKeys(object: PlainObjInput): OrderedSet; + static fromKeys(values: Iterable<[T, mixed]> | PlainObjInput): OrderedSet; static isOrderedSet: typeof isOrderedSet; @@ -1390,10 +1381,10 @@ declare class Record { } declare class RecordInstance { - static (values?: $Shape | Iterable<[string, any]>): RecordOf; + static (values?: $Shape | Iterable<[$Keys, any]>): RecordOf; // Note: a constructor can only create an instance of RecordInstance, // it's encouraged to not use `new` when creating Records. - constructor (values?: $Shape | Iterable<[string, any]>): void; + constructor (values?: $Shape | Iterable<[$Keys, any]>): void; size: number; @@ -1414,16 +1405,16 @@ declare class RecordInstance { set>(key: K, value: $ElementType): this & T; update>(key: K, updater: (value: $ElementType) => $ElementType): this & T; - merge(...collections: Array<$Shape | Iterable<[string, any]>>): this & T; - mergeDeep(...collections: Array<$Shape | Iterable<[string, any]>>): this & T; + merge(...collections: Array<$Shape | Iterable<[$Keys, any]>>): this & T; + mergeDeep(...collections: Array<$Shape | Iterable<[$Keys, any]>>): this & T; mergeWith( merger: (oldVal: any, newVal: any, key: $Keys) => any, - ...collections: Array<$Shape | Iterable<[string, any]>> + ...collections: Array<$Shape | Iterable<[$Keys, any]>> ): this & T; mergeDeepWith( merger: (oldVal: any, newVal: any, key: any) => any, - ...collections: Array<$Shape | Iterable<[string, any]>> + ...collections: Array<$Shape | Iterable<[$Keys, any]>> ): this & T; delete>(key: K): this & T; From 2e7966a90830d45f69a2bca4ccddf7a8845160e4 Mon Sep 17 00:00:00 2001 From: Travis CI Date: Thu, 12 Oct 2017 02:05:29 +0000 Subject: [PATCH 059/242] Deploy af7dc6f56f3ce3ae491ec8e0395fc513c9fa8f21 to NPM branch --- dist/immutable-nonambient.d.ts | 11 ++++++++++- dist/immutable.d.ts | 11 ++++++++++- dist/immutable.js.flow | 2 +- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/dist/immutable-nonambient.d.ts b/dist/immutable-nonambient.d.ts index b5ea82b6f6..db10e53c01 100644 --- a/dist/immutable-nonambient.d.ts +++ b/dist/immutable-nonambient.d.ts @@ -2552,7 +2552,16 @@ // Reading values has(key: string): key is keyof TProps; - get(key: K): TProps[K]; + + /** + * Returns the value associated with the provided key, which may be the + * default value defined when creating the Record factory function. + * + * If the requested key is not defined by this Record type, then + * notSetValue will be returned if provided. Note that this scenario would + * produce an error when using Flow or TypeScript. + */ + get(key: K, notSetValue: any): TProps[K]; // Reading deep values diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index bc478926e0..648e769787 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -2552,7 +2552,16 @@ declare module Immutable { // Reading values has(key: string): key is keyof TProps; - get(key: K): TProps[K]; + + /** + * Returns the value associated with the provided key, which may be the + * default value defined when creating the Record factory function. + * + * If the requested key is not defined by this Record type, then + * notSetValue will be returned if provided. Note that this scenario would + * produce an error when using Flow or TypeScript. + */ + get(key: K, notSetValue: any): TProps[K]; // Reading deep values diff --git a/dist/immutable.js.flow b/dist/immutable.js.flow index e6884f1b14..305baf9f10 100644 --- a/dist/immutable.js.flow +++ b/dist/immutable.js.flow @@ -1389,7 +1389,7 @@ declare class RecordInstance { size: number; has(key: string): boolean; - get>(key: K): $ElementType; + get>(key: K, notSetValue: mixed): $ElementType; hasIn(keyPath: Iterable): boolean; From b087e4241bc96f3a1ac7705c307c70c51c3512d5 Mon Sep 17 00:00:00 2001 From: Travis CI Date: Thu, 12 Oct 2017 02:10:57 +0000 Subject: [PATCH 060/242] Deploy 3e671a2b6dc76ab3dd141c65659bce55ffd64f44 to NPM branch --- dist/immutable.js.flow | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/immutable.js.flow b/dist/immutable.js.flow index 305baf9f10..0ed51e91b0 100644 --- a/dist/immutable.js.flow +++ b/dist/immutable.js.flow @@ -503,7 +503,7 @@ declare class KeyedSeq extends Seq mixins KeyedCollection { } declare class IndexedSeq<+T> extends Seq mixins IndexedCollection { - static (iter?: Iterable): IndexedSeq; + static (values?: Iterable): IndexedSeq; static of(...values: T[]): IndexedSeq; @@ -630,7 +630,7 @@ declare class IndexedSeq<+T> extends Seq mixins IndexedCollection } declare class SetSeq<+T> extends Seq mixins SetCollection { - static (iter?: Iterable): IndexedSeq; + static (values?: Iterable): SetSeq; static of(...values: T[]): SetSeq; From 9a432f141dbba2a0669e5aab8c5be7b69c83d835 Mon Sep 17 00:00:00 2001 From: Travis CI Date: Fri, 13 Oct 2017 01:50:20 +0000 Subject: [PATCH 061/242] Deploy 5101b076f293151d745f2fa75f184f19242d59dc to NPM branch --- dist/immutable-nonambient.d.ts | 44 +++++++++++++++++----------------- dist/immutable.d.ts | 44 +++++++++++++++++----------------- 2 files changed, 44 insertions(+), 44 deletions(-) diff --git a/dist/immutable-nonambient.d.ts b/dist/immutable-nonambient.d.ts index db10e53c01..31cd68ae1c 100644 --- a/dist/immutable-nonambient.d.ts +++ b/dist/immutable-nonambient.d.ts @@ -482,7 +482,7 @@ * enough to include the `index`. * * * ```js * const originalList = List([ 0 ]); @@ -515,7 +515,7 @@ * Note: `delete` cannot be safely used in IE8 * * * ```js * List([ 0, 1, 2, 3, 4 ]).delete(0); @@ -536,7 +536,7 @@ * This is synonymous with `list.splice(index, 0, value)`. * * * ```js * List([ 0, 1, 2, 3, 4 ]).insert(6, 5) @@ -551,7 +551,7 @@ * Returns a new List with 0 size and no values. * * * ```js * List([ 1, 2, 3, 4 ]).clear() @@ -567,7 +567,7 @@ * List's `size`. * * * ```js * List([ 1, 2, 3, 4 ]).push(5) @@ -600,7 +600,7 @@ * values ahead to higher indices. * * * ```js * List([ 2, 3, 4]).unshift(1); @@ -620,7 +620,7 @@ * value in this List. * * * ```js * List([ 0, 1, 2, 3, 4 ]).shift(); @@ -641,7 +641,7 @@ * List. `v.update(-1)` updates the last item in the List. * * * ```js * const list = List([ 'a', 'b', 'c' ]) @@ -655,7 +655,7 @@ * For example, to sum a List after mapping and filtering: * * * ```js * function sum(collection) { @@ -701,7 +701,7 @@ * * * ```js - * const { List } = require("immutable") + * const { List } = require('immutable@4.0.0-rc.7') * const list = List([ 0, 1, 2, List([ 3, 4 ])]) * list.setIn([3, 0], 999); * // List [ 0, 1, 2, List [ 999, 4 ] ] @@ -717,7 +717,7 @@ * * * ```js - * const { List } = require("immutable") + * const { List } = require('immutable@4.0.0-rc.7') * const list = List([ 0, 1, 2, List([ 3, 4 ])]) * list.deleteIn([3, 0]); * // List [ 0, 1, 2, List [ 4 ] ] @@ -801,7 +801,7 @@ * `mapper` function. * * * ```js * List([ 1, 2 ]).map(x => 10 * x) @@ -848,7 +848,7 @@ * Like `zipWith`, but using the default `zipper`: creating an `Array`. * * * ```js * const a = List([ 1, 2, 3 ]); @@ -867,7 +867,7 @@ * exhausted. Missing values from shorter collections are filled with `undefined`. * * * ```js * const a = List([ 1, 2 ]); @@ -888,7 +888,7 @@ * custom `zipper` function. * * * ```js * const a = List([ 1, 2, 3 ]); @@ -991,7 +991,7 @@ * quote-less shorthand, while Immutable Maps accept keys of any type. * * * ```js * let obj = { 1: "one" } @@ -1120,7 +1120,7 @@ * `update` and `push` can be used together: * * * ```js * const aMap = Map({ nestedList: List([ 1, 2, 3 ]) }) @@ -1132,7 +1132,7 @@ * function when the value at the key does not exist in the Map. * * * ```js * const aMap = Map({ key: 'value' }) @@ -1145,7 +1145,7 @@ * is provided. * * * ```js * const aMap = Map({ apples: 10 }) @@ -1161,7 +1161,7 @@ * The previous example behaves differently when written with default values: * * * ```js * const aMap = Map({ apples: 10 }) @@ -1173,7 +1173,7 @@ * returned as well. * * * ```js * const aMap = Map({ key: 'value' }) @@ -1187,7 +1187,7 @@ * For example, to sum the values in a Map * * * ```js * function sum(collection) { diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index 648e769787..ba4f0d8d41 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -482,7 +482,7 @@ declare module Immutable { * enough to include the `index`. * * * ```js * const originalList = List([ 0 ]); @@ -515,7 +515,7 @@ declare module Immutable { * Note: `delete` cannot be safely used in IE8 * * * ```js * List([ 0, 1, 2, 3, 4 ]).delete(0); @@ -536,7 +536,7 @@ declare module Immutable { * This is synonymous with `list.splice(index, 0, value)`. * * * ```js * List([ 0, 1, 2, 3, 4 ]).insert(6, 5) @@ -551,7 +551,7 @@ declare module Immutable { * Returns a new List with 0 size and no values. * * * ```js * List([ 1, 2, 3, 4 ]).clear() @@ -567,7 +567,7 @@ declare module Immutable { * List's `size`. * * * ```js * List([ 1, 2, 3, 4 ]).push(5) @@ -600,7 +600,7 @@ declare module Immutable { * values ahead to higher indices. * * * ```js * List([ 2, 3, 4]).unshift(1); @@ -620,7 +620,7 @@ declare module Immutable { * value in this List. * * * ```js * List([ 0, 1, 2, 3, 4 ]).shift(); @@ -641,7 +641,7 @@ declare module Immutable { * List. `v.update(-1)` updates the last item in the List. * * * ```js * const list = List([ 'a', 'b', 'c' ]) @@ -655,7 +655,7 @@ declare module Immutable { * For example, to sum a List after mapping and filtering: * * * ```js * function sum(collection) { @@ -701,7 +701,7 @@ declare module Immutable { * * * ```js - * const { List } = require("immutable") + * const { List } = require('immutable@4.0.0-rc.7') * const list = List([ 0, 1, 2, List([ 3, 4 ])]) * list.setIn([3, 0], 999); * // List [ 0, 1, 2, List [ 999, 4 ] ] @@ -717,7 +717,7 @@ declare module Immutable { * * * ```js - * const { List } = require("immutable") + * const { List } = require('immutable@4.0.0-rc.7') * const list = List([ 0, 1, 2, List([ 3, 4 ])]) * list.deleteIn([3, 0]); * // List [ 0, 1, 2, List [ 4 ] ] @@ -801,7 +801,7 @@ declare module Immutable { * `mapper` function. * * * ```js * List([ 1, 2 ]).map(x => 10 * x) @@ -848,7 +848,7 @@ declare module Immutable { * Like `zipWith`, but using the default `zipper`: creating an `Array`. * * * ```js * const a = List([ 1, 2, 3 ]); @@ -867,7 +867,7 @@ declare module Immutable { * exhausted. Missing values from shorter collections are filled with `undefined`. * * * ```js * const a = List([ 1, 2 ]); @@ -888,7 +888,7 @@ declare module Immutable { * custom `zipper` function. * * * ```js * const a = List([ 1, 2, 3 ]); @@ -991,7 +991,7 @@ declare module Immutable { * quote-less shorthand, while Immutable Maps accept keys of any type. * * * ```js * let obj = { 1: "one" } @@ -1120,7 +1120,7 @@ declare module Immutable { * `update` and `push` can be used together: * * * ```js * const aMap = Map({ nestedList: List([ 1, 2, 3 ]) }) @@ -1132,7 +1132,7 @@ declare module Immutable { * function when the value at the key does not exist in the Map. * * * ```js * const aMap = Map({ key: 'value' }) @@ -1145,7 +1145,7 @@ declare module Immutable { * is provided. * * * ```js * const aMap = Map({ apples: 10 }) @@ -1161,7 +1161,7 @@ declare module Immutable { * The previous example behaves differently when written with default values: * * * ```js * const aMap = Map({ apples: 10 }) @@ -1173,7 +1173,7 @@ declare module Immutable { * returned as well. * * * ```js * const aMap = Map({ key: 'value' }) @@ -1187,7 +1187,7 @@ declare module Immutable { * For example, to sum the values in a Map * * * ```js * function sum(collection) { From fba87975b492518105dd598e1ebfa68d108971ce Mon Sep 17 00:00:00 2001 From: Travis CI Date: Sat, 14 Oct 2017 01:09:26 +0000 Subject: [PATCH 062/242] Deploy 316150f9c86b7b879ec6dbc1926f93a0ddbc6f47 to NPM branch --- dist/immutable.es.js | 20 ++++++++------- dist/immutable.js | 20 ++++++++------- dist/immutable.min.js | 60 +++++++++++++++++++++---------------------- 3 files changed, 52 insertions(+), 48 deletions(-) diff --git a/dist/immutable.es.js b/dist/immutable.es.js index fb9e067a2f..fd36b4a817 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -3970,6 +3970,14 @@ function mixin(ctor, methods) { return ctor; } +function toJS(value) { + return isImmutable(value) + ? Collection(value) + .map(toJS) + .toJSON() + : value; +} + var Set = (function (SetCollection$$1) { function Set(value) { return value === null || value === undefined @@ -4354,9 +4362,7 @@ mixin(Collection, { }, toJS: function toJS$1() { - return this.toSeq() - .map(toJS) - .toJSON(); + return toJS(this); }, toKeyedSeq: function toKeyedSeq() { @@ -5010,10 +5016,6 @@ function entryMapper(v, k) { return [k, v]; } -function toJS(value) { - return value && typeof value.toJS === 'function' ? value.toJS() : value; -} - function not(predicate) { return function() { return !predicate.apply(this, arguments); @@ -5304,8 +5306,8 @@ Record.prototype.toSeq = function toSeq () { return recordSeq(this); }; -Record.prototype.toJS = function toJS () { - return recordSeq(this).toJS(); +Record.prototype.toJS = function toJS$1 () { + return toJS(this); }; Record.prototype.__iterator = function __iterator (type, reverse) { diff --git a/dist/immutable.js b/dist/immutable.js index 0f7afab0f4..fb3078feca 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -3976,6 +3976,14 @@ function mixin(ctor, methods) { return ctor; } +function toJS(value) { + return isImmutable(value) + ? Collection(value) + .map(toJS) + .toJSON() + : value; +} + var Set = (function (SetCollection$$1) { function Set(value) { return value === null || value === undefined @@ -4360,9 +4368,7 @@ mixin(Collection, { }, toJS: function toJS$1() { - return this.toSeq() - .map(toJS) - .toJSON(); + return toJS(this); }, toKeyedSeq: function toKeyedSeq() { @@ -5016,10 +5022,6 @@ function entryMapper(v, k) { return [k, v]; } -function toJS(value) { - return value && typeof value.toJS === 'function' ? value.toJS() : value; -} - function not(predicate) { return function() { return !predicate.apply(this, arguments); @@ -5310,8 +5312,8 @@ Record.prototype.toSeq = function toSeq () { return recordSeq(this); }; -Record.prototype.toJS = function toJS () { - return recordSeq(this).toJS(); +Record.prototype.toJS = function toJS$1 () { + return toJS(this); }; Record.prototype.__iterator = function __iterator (type, reverse) { diff --git a/dist/immutable.min.js b/dist/immutable.min.js index 54ff26590e..d91ec06c39 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -4,34 +4,34 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.Immutable={})}(this,function(t){"use strict";function e(t){return t.value=!1,t}function r(t){t&&(t.value=!0)}function n(){}function i(t,e){e=e||0;for(var r=Math.max(0,t.length-e),n=Array(r),i=0;i>>0;if(""+r!==e||4294967295===r)return NaN;e=r}return e<0?o(t)+e:e}function s(){return!0}function a(t,e,r){return(0===t&&!p(t)||void 0!==r&&t<=-r)&&(void 0===e||void 0!==r&&e>=r)}function c(t,e){return f(t,e,0)}function h(t,e){return f(t,e,e)}function f(t,e,r){return void 0===t?r:p(t)?e===1/0?e:0|Math.max(0,e+t):void 0===e||e===t?t:0|Math.min(e,t)}function p(t){return t<0||0===t&&1/t==-(1/0)}function _(t){return l(t)||m(t)}function l(t){return!(!t||!t[Re])}function v(t){return!(!t||!t[Ue])}function y(t){return!(!t||!t[Ke])}function d(t){return v(t)||y(t)}function g(t){return!(!t||!t[Le])}function m(t){return!(!t||!t[Te])}function w(t){return!(!t||"function"!=typeof t.equals||"function"!=typeof t.hashCode)}function S(t,e,r,n){var i=0===t?e:1===t?r:[e,r];return n?n.value=i:n={value:i,done:!1},n}function z(){return{value:void 0,done:!0}}function I(t){return!!M(t)}function b(t){return t&&"function"==typeof t.next}function O(t){var e=M(t);return e&&e.call(t)}function M(t){var e=t&&(He&&t[He]||t[Ye]);if("function"==typeof e)return e}function q(t){return t&&"number"==typeof t.length}function E(t){return!(!t||!t[tr])}function D(){return nr||(nr=new er([]))}function x(t){var e=Array.isArray(t)?new er(t):b(t)?new ur(t):I(t)?new or(t):void 0;if(e)return e.fromEntrySeq();if("object"==typeof t)return new rr(t);throw new TypeError("Expected Array or collection object of [k, v] entries, or keyed object: "+t)}function j(t){var e=A(t);if(e)return e;throw new TypeError("Expected Array or collection object of values: "+t)}function k(t){var e=A(t) -;if(e)return e;if("object"==typeof t)return new rr(t);throw new TypeError("Expected Array or collection object of values, or keyed object: "+t)}function A(t){return q(t)?new er(t):b(t)?new ur(t):I(t)?new or(t):void 0}function R(t,e){if(t===e||t!==t&&e!==e)return!0;if(!t||!e)return!1;if("function"==typeof t.valueOf&&"function"==typeof e.valueOf){if(t=t.valueOf(),e=e.valueOf(),t===e||t!==t&&e!==e)return!0;if(!t||!e)return!1}return!!(w(t)&&w(e)&&t.equals(e))}function U(t){return t>>>1&1073741824|3221225471&t}function K(t){if(t===!1||null===t||void 0===t)return 0;if("function"==typeof t.valueOf&&((t=t.valueOf())===!1||null===t||void 0===t))return 0;if(t===!0)return 1;var e=typeof t;if("number"===e){if(t!==t||t===1/0)return 0;var r=0|t;for(r!==t&&(r^=4294967295*t);t>4294967295;)t/=4294967295,r^=t;return U(r)}if("string"===e)return t.length>_r?L(t):T(t);if("function"==typeof t.hashCode)return U(t.hashCode());if("object"===e)return C(t);if("function"==typeof t.toString)return T(""+t);throw Error("Value type "+e+" cannot be hashed.")}function L(t){var e=yr[t];return void 0===e&&(e=T(t),vr===lr&&(vr=0,yr={}),vr++,yr[t]=e),e}function T(t){for(var e=0,r=0;r0)switch(t.nodeType){case 1:return t.uniqueID;case 9:return t.documentElement&&t.documentElement.uniqueID}}function W(t){var e=st(t);return e._iter=t,e.size=t.size,e.flip=function(){return t},e.reverse=function(){var e=t.reverse.apply(this);return e.flip=function(){return t.reverse()},e},e.has=function(e){return t.includes(e)},e.includes=function(e){return t.has(e)},e.cacheResult=at,e.__iterateUncached=function(e,r){var n=this;return t.__iterate(function(t,r){return e(r,t,n)!==!1},r)},e.__iteratorUncached=function(e,r){if(e===Ve){var n=t.__iterator(e,r);return new Xe(function(){var t=n.next();if(!t.done){var e=t.value[0];t.value[0]=t.value[1],t.value[1]=e}return t})}return t.__iterator(e===Pe?Ne:Pe,r)},e}function J(t,e,r){var n=st(t);return n.size=t.size,n.has=function(e){return t.has(e)},n.get=function(n,i){var o=t.get(n,je);return o===je?i:e.call(r,o,n,t)},n.__iterateUncached=function(n,i){var o=this;return t.__iterate(function(t,i,u){return n(e.call(r,t,i,u),i,o)!==!1},i)},n.__iteratorUncached=function(n,i){var o=t.__iterator(Ve,i);return new Xe(function(){var i=o.next();if(i.done)return i;var u=i.value,s=u[0];return S(n,s,e.call(r,u[1],s,t),i)})},n}function N(t,e){var r=this,n=st(t);return n._iter=t,n.size=t.size,n.reverse=function(){return t},t.flip&&(n.flip=function(){var e=W(t);return e.reverse=function(){return t.flip()},e}),n.get=function(r,n){return t.get(e?r:-1-r,n)},n.has=function(r){return t.has(e?r:-1-r)},n.includes=function(e){return t.includes(e)},n.cacheResult=at,n.__iterate=function(r,n){var i=this,u=0;return n&&o(t),t.__iterate(function(t,o){return r(t,e?o:n?i.size-++u:u++,i)},!n)},n.__iterator=function(n,i){var u=0;i&&o(t);var s=t.__iterator(Ve,!i);return new Xe(function(){var t=s.next();if(t.done)return t;var o=t.value;return S(n,e?o[0]:i?r.size-++u:u++,o[1],t)})},n}function P(t,e,r,n){var i=st(t);return n&&(i.has=function(n){var i=t.get(n,je);return i!==je&&!!e.call(r,i,n,t)},i.get=function(n,i){var o=t.get(n,je);return o!==je&&e.call(r,o,n,t)?o:i}), -i.__iterateUncached=function(i,o){var u=this,s=0;return t.__iterate(function(t,o,a){if(e.call(r,t,o,a))return s++,i(t,n?o:s-1,u)},o),s},i.__iteratorUncached=function(i,o){var u=t.__iterator(Ve,o),s=0;return new Xe(function(){for(;;){var o=u.next();if(o.done)return o;var a=o.value,c=a[0],h=a[1];if(e.call(r,h,c,t))return S(i,n?c:s++,h,o)}})},i}function V(t,e,r){var n=Sr().asMutable();return t.__iterate(function(i,o){n.update(e.call(r,i,o,t),0,function(t){return t+1})}),n.asImmutable()}function H(t,e,r){var n=v(t),i=(g(t)?Br():Sr()).asMutable();t.__iterate(function(o,u){i.update(e.call(r,o,u,t),function(t){return t=t||[],t.push(n?[u,o]:o),t})});var o=ut(t);return i.map(function(e){return it(t,o(e))})}function Y(t,e,r,n){var i=t.size;if(a(e,r,i))return t;var o=c(e,i),s=h(r,i);if(o!==o||s!==s)return Y(t.toSeq().cacheResult(),e,r,n);var f,p=s-o;p===p&&(f=p<0?0:p);var _=st(t);return _.size=0===f?f:t.size&&f||void 0,!n&&E(t)&&f>=0&&(_.get=function(e,r){return e=u(this,e),e>=0&&ef)return z();var t=i.next();return n||e===Pe||t.done?t:e===Ne?S(e,s-1,void 0,t):S(e,s-1,t.value[1],t)})},_}function Q(t,e,r){var n=st(t);return n.__iterateUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterate(n,i);var u=0;return t.__iterate(function(t,i,s){return e.call(r,t,i,s)&&++u&&n(t,i,o)}),u},n.__iteratorUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterator(n,i);var u=t.__iterator(Ve,i),s=!0;return new Xe(function(){if(!s)return z();var t=u.next();if(t.done)return t;var i=t.value,a=i[0],c=i[1];return e.call(r,c,a,o)?n===Ve?t:S(n,a,c,t):(s=!1,z())})},n} -function X(t,e,r,n){var i=st(t);return i.__iterateUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterate(i,o);var s=!0,a=0;return t.__iterate(function(t,o,c){if(!s||!(s=e.call(r,t,o,c)))return a++,i(t,n?o:a-1,u)}),a},i.__iteratorUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterator(i,o);var s=t.__iterator(Ve,o),a=!0,c=0;return new Xe(function(){var t,o,h;do{if(t=s.next(),t.done)return n||i===Pe?t:i===Ne?S(i,c++,void 0,t):S(i,c++,t.value[1],t);var f=t.value;o=f[0],h=f[1],a&&(a=e.call(r,h,o,u))}while(a);return i===Ve?t:S(i,o,h,t)})},i}function F(t,e){var r=v(t),n=[t].concat(e).map(function(t){return l(t)?r&&(t=Be(t)):t=r?x(t):j(Array.isArray(t)?t:[t]),t}).filter(function(t){return 0!==t.size});if(0===n.length)return t;if(1===n.length){var i=n[0];if(i===t||r&&v(i)||y(t)&&y(i))return i}var o=new er(n);return r?o=o.toKeyedSeq():y(t)||(o=o.toSetSeq()),o=o.flatten(!0),o.size=n.reduce(function(t,e){if(void 0!==t){var r=e.size;if(void 0!==r)return t+r}},0),o}function G(t,e,r){var n=st(t);return n.__iterateUncached=function(i,o){function u(t,c){t.__iterate(function(t,o){return(!e||c0}function nt(t,e,r,n){var i=st(t),o=new er(r).map(function(t){return t.size});return i.size=n?o.max():o.min(),i.__iterate=function(t,e){for(var r,n=this,i=this.__iterator(Pe,e),o=0;!(r=i.next()).done&&t(r.value,o++,n)!==!1;);return o},i.__iteratorUncached=function(t,i){var o=r.map(function(t){return t=Ce(t),O(i?t.reverse():t)}),u=0,s=!1;return new Xe(function(){var r;return s||(r=o.map(function(t){return t.next()}),s=n?r.every(function(t){return t.done}):r.some(function(t){return t.done})),s?z():S(t,u++,e.apply(null,r.map(function(t){return t.value})))})},i}function it(t,e){return t===e?t:E(t)?e:t.constructor(e)}function ot(t){if(t!==Object(t))throw new TypeError("Expected [K, V] tuple: "+t)}function ut(t){return v(t)?Be:y(t)?We:Je}function st(t){return Object.create((v(t)?Ge:y(t)?Ze:$e).prototype)}function at(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size,this):Fe.prototype.cacheResult.call(this)}function ct(t,e){return void 0===t&&void 0===e?0:void 0===t?1:void 0===e?-1:t>e?1:t>>r)&xe,s=(0===r?n:n>>>r)&xe;return new Or(e,1<>>=1)u[s]=1&r?e[o++]:void 0;return u[n]=i,new Mr(t,o+1,u)}function Mt(t,e,r){for(var n=[],i=0;i>1&1431655765,t=(858993459&t)+(t>>2&858993459),t=t+(t>>4)&252645135,t+=t>>8,127&(t+=t>>16)}function kt(t,e,r,n){var o=n?t:i(t);return o[e]=r,o}function At(t,e,r,n){var i=t.length+1;if(n&&e+1===i)return t[e]=r,t;for(var o=Array(i),u=0,s=0;so?0:o-r,c=u-r;return c>De&&(c=De),function(){if(i===c)return Cr;var t=e?--c:i++;return n&&n[t]}}function i(t,n,i){var s,a=t&&t.array,c=i>o?0:o-i>>n,h=1+(u-i>>n);return h>De&&(h=De),function(){for(;;){if(s){var t=s();if(t!==Cr)return t;s=null}if(c===h)return Cr;var o=e?--h:c++;s=r(a&&a[o],n-Ee,i+(o<=t.size||r<0)return t.withMutations(function(t){r<0?Nt(t,r).set(0,n):Nt(t,0,r+1).set(r,n)});r+=t._origin;var i=t._tail,o=t._root,s=e(Ae);return r>=Pt(t._capacity)?i=Bt(i,t.__ownerID,0,r,n,s):o=Bt(o,t.__ownerID,t._level,r,n,s),s.value?t.__ownerID?(t._root=o,t._tail=i,t.__hash=void 0,t.__altered=!0,t):Lt(t._origin,t._capacity,t._level,o,i):t}function Bt(t,e,n,i,o,u){var s=i>>>n&xe,a=t&&s0){var h=t&&t.array[s],f=Bt(h,e,n-Ee,i,o,u);return f===h?t:(c=Wt(t,e),c.array[s]=f,c)} -return a&&t.array[s]===o?t:(r(u),c=Wt(t,e),void 0===o&&s===c.array.length-1?c.array.pop():c.array[s]=o,c)}function Wt(t,e){return e&&t&&e===t.ownerID?t:new Lr(t?t.array.slice():[],e)}function Jt(t,e){if(e>=Pt(t._capacity))return t._tail;if(e<1<0;)r=r.array[e>>>n&xe],n-=Ee;return r}}function Nt(t,e,r){void 0!==e&&(e|=0),void 0!==r&&(r|=0);var i=t.__ownerID||new n,o=t._origin,u=t._capacity,s=o+e,a=void 0===r?u:r<0?u+r:o+r;if(s===o&&a===u)return t;if(s>=a)return t.clear();for(var c=t._level,h=t._root,f=0;s+f<0;)h=new Lr(h&&h.array.length?[void 0,h]:[],i),c+=Ee,f+=1<=1<p?new Lr([],i):l;if(l&&_>p&&sEe;d-=Ee){var g=p>>>d&xe;y=y.array[g]=Wt(y.array[g],i)}y.array[p>>>Ee&xe]=l}if(a=_)s-=_,a-=_,c=Ee,h=null,v=v&&v.removeBefore(i,0,s);else if(s>o||_>>c&xe;if(m!==_>>>c&xe)break;m&&(f+=(1<o&&(h=h.removeBefore(i,c,s-f)),h&&_>>Ee<=De&&u.size>=2*o.size?(i=u.filter(function(t,e){return void 0!==t&&s!==e}),n=i.toKeyedSeq().map(function(t){return t[0]}).flip().toMap(),t.__ownerID&&(n.__ownerID=i.__ownerID=t.__ownerID)):(n=o.remove(e),i=s===u.size-1?u.pop():u.set(s,void 0))}else if(a){if(r===u.get(s)[1])return t;n=o,i=u.set(s,[e,r])}else n=o.set(e,u.size),i=u.set(u.size,[e,r]) -;return t.__ownerID?(t.size=n.size,t._map=n,t._list=i,t.__hash=void 0,t):Ht(n,i)}function Xt(t){return!(!t||!t[Nr])}function Ft(t,e,r,n){var i=Object.create(Pr);return i.size=t,i._head=e,i.__ownerID=r,i.__hash=n,i.__altered=!1,i}function Gt(){return Vr||(Vr=Ft(0))}function Zt(t,e){if(t===e)return!0;if(!l(e)||void 0!==t.size&&void 0!==e.size&&t.size!==e.size||void 0!==t.__hash&&void 0!==e.__hash&&t.__hash!==e.__hash||v(t)!==v(e)||y(t)!==y(e)||g(t)!==g(e))return!1;if(0===t.size&&0===e.size)return!0;var r=!d(t);if(g(t)){var n=t.entries();return e.every(function(t,e){var i=n.next().value;return i&&R(i[1],t)&&(r||R(i[0],e))})&&n.next().done}var i=!1;if(void 0===t.size)if(void 0===e.size)"function"==typeof t.cacheResult&&t.cacheResult();else{i=!0;var o=t;t=e,e=o}var u=!0,s=e.__iterate(function(e,n){if(r?!t.has(e):i?!R(e,t.get(n,je)):!R(t.get(n,je),e))return u=!1,!1});return u&&t.size===s}function $t(t,e){var r=function(r){t.prototype[r]=e[r]};return Object.keys(e).forEach(r),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(e).forEach(r),t}function te(t){return!(!t||!t[Yr])}function ee(t,e){return t.__ownerID?(t.size=e.size,t._map=e,t):e===t._map?t:0===e.size?t.__empty():t.__make(e)}function re(t,e){var r=Object.create(Qr);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function ne(){return Xr||(Xr=re(gt()))}function ie(t,e,r,n,i,o){return pt(t.size),t.__iterate(function(t,o,u){i?(i=!1,r=t):r=e.call(n,r,t,o,u)},o),r}function oe(t,e){return e}function ue(t,e){return[e,t]}function se(t){return t&&"function"==typeof t.toJS?t.toJS():t}function ae(t){return function(){return!t.apply(this,arguments)}}function ce(t){return function(){return-t.apply(this,arguments)}}function he(){return i(arguments)}function fe(t,e){return te?-1:0}function pe(t){if(t.size===1/0)return 0;var e=g(t),r=v(t),n=e?1:0;return _e(t.__iterate(r?e?function(t,e){n=31*n+le(K(t),K(e))|0}:function(t,e){n=n+le(K(t),K(e))|0}:e?function(t){n=31*n+K(t)|0}:function(t){n=n+K(t)|0}),n)}function _e(t,e){return e=sr(e,3432918353), -e=sr(e<<15|e>>>-15,461845907),e=sr(e<<13|e>>>-13,5),e=(e+3864292196|0)^t,e=sr(e^e>>>16,2246822507),e=sr(e^e>>>13,3266489909),e=U(e^e>>>16)}function le(t,e){return t^e+2654435769+(t<<6)+(t>>2)|0}function ve(t){if("object"!=typeof console||!console.warn)throw Error(t);console.warn(t)}function ye(t,e,r,n){for(var i=ht(r),o=0;o!==i.length;){if(null==t)return e;if(!t||!t.get)return n&&ve("Invalid keyPath: Value at ["+i.slice(0,o).map(_t)+"] does not have a .get() method: "+t+"\nThis warning will throw in a future version"),e;if((t=t.get(i[o++],je))===je)return e}return t}function de(t){return te(t)&&g(t)}function ge(t,e){var r=Object.create(rn);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function me(){return nn||(nn=ge(Yt()))}function we(t,e,r){var n=Object.create(Object.getPrototypeOf(t));return n._values=e,n.__ownerID=r,n}function Se(t){return t._name||t.constructor.name||"Record"}function ze(t){return x(t._keys.map(function(e){return[e,t.get(e)]}))}function Ie(t,e){try{Object.defineProperty(t,e,{get:function(){return this.get(e)},set:function(t){ft(this.__ownerID,"Cannot set on an immutable record."),this.set(e,t)}})}catch(t){}}function be(t,e){return Oe([],e||Me,t,"",e&&e.length>2?[]:void 0,{"":t})}function Oe(t,e,r,n,i,o){var u=Array.isArray(r)?Ze:qe(r)?Ge:null;if(u){if(~t.indexOf(r))throw new TypeError("Cannot convert circular structure to Immutable");t.push(r),i&&""!==n&&i.push(n);var s=e.call(o,n,u(r).map(function(n,o){return Oe(t,e,n,o,i,r)}),i&&i.slice());return t.pop(),i&&i.pop(),s}return r}function Me(t,e){return v(e)?e.toMap():e.toList()}function qe(t){return t&&(t.constructor===Object||void 0===t.constructor)}var Ee=5,De=1<=n.length){var e=r.next();if(e.done)return e;n[i]=e.value}return S(t,i,n[i++])})},e}(Ze),sr="function"==typeof Math.imul&&Math.imul(4294967295,2)===-2?Math.imul:function(t,e){t|=0,e|=0;var r=65535&t,n=65535&e;return r*n+((t>>>16)*n+r*(e>>>16)<<16>>>0)|0},ar=Object.isExtensible,cr=function(){try{return Object.defineProperty({},"@",{}),!0}catch(t){return!1}}(),hr="function"==typeof WeakMap;hr&&(ir=new WeakMap);var fr=0,pr="__immutablehash__";"function"==typeof Symbol&&(pr=Symbol(pr));var _r=16,lr=255,vr=0,yr={},dr=function(t){function e(t,e){this._iter=t,this._useKeys=e,this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t,e){return this._iter.get(t,e)},e.prototype.has=function(t){return this._iter.has(t)},e.prototype.valueSeq=function(){return this._iter.valueSeq()},e.prototype.reverse=function(){var t=this,e=N(this,!0);return this._useKeys||(e.valueSeq=function(){return t._iter.toSeq().reverse()}),e},e.prototype.map=function(t,e){var r=this,n=J(this,t,e);return this._useKeys||(n.valueSeq=function(){ -return r._iter.toSeq().map(t,e)}),n},e.prototype.__iterate=function(t,e){var r=this;return this._iter.__iterate(function(e,n){return t(e,n,r)},e)},e.prototype.__iterator=function(t,e){return this._iter.__iterator(t,e)},e}(Ge);dr.prototype[Le]=!0;var gr=function(t){function e(t){this._iter=t,this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.includes=function(t){return this._iter.includes(t)},e.prototype.__iterate=function(t,e){var r=this,n=0;return e&&o(this),this._iter.__iterate(function(i){return t(i,e?r.size-++n:n++,r)},e)},e.prototype.__iterator=function(t,e){var r=this,n=this._iter.__iterator(Pe,e),i=0;return e&&o(this),new Xe(function(){var o=n.next();return o.done?o:S(t,e?r.size-++i:i++,o.value,o)})},e}(Ze),mr=function(t){function e(t){this._iter=t,this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.has=function(t){return this._iter.includes(t)},e.prototype.__iterate=function(t,e){var r=this;return this._iter.__iterate(function(e){return t(e,e,r)},e)},e.prototype.__iterator=function(t,e){var r=this._iter.__iterator(Pe,e);return new Xe(function(){var e=r.next();return e.done?e:S(t,e.value,e.value,e)})},e}($e),wr=function(t){function e(t){this._iter=t,this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.entrySeq=function(){return this._iter.toSeq()},e.prototype.__iterate=function(t,e){var r=this;return this._iter.__iterate(function(e){if(e){ot(e);var n=l(e);return t(n?e.get(1):e[1],n?e.get(0):e[0],r)}},e)},e.prototype.__iterator=function(t,e){var r=this._iter.__iterator(Pe,e);return new Xe(function(){for(;;){var e=r.next();if(e.done)return e;var n=e.value;if(n){ot(n);var i=l(n);return S(t,i?n.get(0):n[0],i?n.get(1):n[1],e)}}})},e}(Ge);gr.prototype.cacheResult=dr.prototype.cacheResult=mr.prototype.cacheResult=wr.prototype.cacheResult=at;var Sr=function(t){function e(e){ +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.Immutable={})}(this,function(t){"use strict";function e(t){return t.value=!1,t}function r(t){t&&(t.value=!0)}function n(){}function i(t,e){e=e||0;for(var r=Math.max(0,t.length-e),n=Array(r),i=0;i>>0;if(""+r!==e||4294967295===r)return NaN;e=r}return e<0?o(t)+e:e}function s(){return!0}function a(t,e,r){return(0===t&&!p(t)||void 0!==r&&t<=-r)&&(void 0===e||void 0!==r&&e>=r)}function c(t,e){return f(t,e,0)}function h(t,e){return f(t,e,e)}function f(t,e,r){return void 0===t?r:p(t)?e===1/0?e:0|Math.max(0,e+t):void 0===e||e===t?t:0|Math.min(e,t)}function p(t){return t<0||0===t&&1/t==-(1/0)}function _(t){return l(t)||m(t)}function l(t){return!(!t||!t[Re])}function v(t){return!(!t||!t[Ue])}function y(t){return!(!t||!t[Ke])}function d(t){return v(t)||y(t)}function g(t){return!(!t||!t[Le])}function m(t){return!(!t||!t[Te])}function w(t){return!(!t||"function"!=typeof t.equals||"function"!=typeof t.hashCode)}function z(t,e,r,n){var i=0===t?e:1===t?r:[e,r];return n?n.value=i:n={value:i,done:!1},n}function I(){return{value:void 0,done:!0}}function S(t){return!!M(t)}function b(t){return t&&"function"==typeof t.next}function O(t){var e=M(t);return e&&e.call(t)}function M(t){var e=t&&(He&&t[He]||t[Ye]);if("function"==typeof e)return e}function q(t){return t&&"number"==typeof t.length}function E(t){return!(!t||!t[tr])}function D(){return nr||(nr=new er([]))}function x(t){var e=Array.isArray(t)?new er(t):b(t)?new ur(t):S(t)?new or(t):void 0;if(e)return e.fromEntrySeq();if("object"==typeof t)return new rr(t);throw new TypeError("Expected Array or collection object of [k, v] entries, or keyed object: "+t)}function j(t){var e=A(t);if(e)return e;throw new TypeError("Expected Array or collection object of values: "+t)}function k(t){var e=A(t) +;if(e)return e;if("object"==typeof t)return new rr(t);throw new TypeError("Expected Array or collection object of values, or keyed object: "+t)}function A(t){return q(t)?new er(t):b(t)?new ur(t):S(t)?new or(t):void 0}function R(t,e){if(t===e||t!==t&&e!==e)return!0;if(!t||!e)return!1;if("function"==typeof t.valueOf&&"function"==typeof e.valueOf){if(t=t.valueOf(),e=e.valueOf(),t===e||t!==t&&e!==e)return!0;if(!t||!e)return!1}return!!(w(t)&&w(e)&&t.equals(e))}function U(t){return t>>>1&1073741824|3221225471&t}function K(t){if(t===!1||null===t||void 0===t)return 0;if("function"==typeof t.valueOf&&((t=t.valueOf())===!1||null===t||void 0===t))return 0;if(t===!0)return 1;var e=typeof t;if("number"===e){if(t!==t||t===1/0)return 0;var r=0|t;for(r!==t&&(r^=4294967295*t);t>4294967295;)t/=4294967295,r^=t;return U(r)}if("string"===e)return t.length>_r?L(t):T(t);if("function"==typeof t.hashCode)return U(t.hashCode());if("object"===e)return C(t);if("function"==typeof t.toString)return T(""+t);throw Error("Value type "+e+" cannot be hashed.")}function L(t){var e=yr[t];return void 0===e&&(e=T(t),vr===lr&&(vr=0,yr={}),vr++,yr[t]=e),e}function T(t){for(var e=0,r=0;r0)switch(t.nodeType){case 1:return t.uniqueID;case 9:return t.documentElement&&t.documentElement.uniqueID}}function W(t){var e=st(t);return e._iter=t,e.size=t.size,e.flip=function(){return t},e.reverse=function(){var e=t.reverse.apply(this);return e.flip=function(){return t.reverse()},e},e.has=function(e){return t.includes(e)},e.includes=function(e){return t.has(e)},e.cacheResult=at,e.__iterateUncached=function(e,r){var n=this;return t.__iterate(function(t,r){return e(r,t,n)!==!1},r)},e.__iteratorUncached=function(e,r){if(e===Ve){var n=t.__iterator(e,r);return new Xe(function(){var t=n.next();if(!t.done){var e=t.value[0];t.value[0]=t.value[1],t.value[1]=e}return t})}return t.__iterator(e===Je?Pe:Je,r)},e}function N(t,e,r){var n=st(t);return n.size=t.size,n.has=function(e){return t.has(e)},n.get=function(n,i){var o=t.get(n,je);return o===je?i:e.call(r,o,n,t)},n.__iterateUncached=function(n,i){var o=this;return t.__iterate(function(t,i,u){return n(e.call(r,t,i,u),i,o)!==!1},i)},n.__iteratorUncached=function(n,i){var o=t.__iterator(Ve,i);return new Xe(function(){var i=o.next();if(i.done)return i;var u=i.value,s=u[0];return z(n,s,e.call(r,u[1],s,t),i)})},n}function P(t,e){var r=this,n=st(t);return n._iter=t,n.size=t.size,n.reverse=function(){return t},t.flip&&(n.flip=function(){var e=W(t);return e.reverse=function(){return t.flip()},e}),n.get=function(r,n){return t.get(e?r:-1-r,n)},n.has=function(r){return t.has(e?r:-1-r)},n.includes=function(e){return t.includes(e)},n.cacheResult=at,n.__iterate=function(r,n){var i=this,u=0;return n&&o(t),t.__iterate(function(t,o){return r(t,e?o:n?i.size-++u:u++,i)},!n)},n.__iterator=function(n,i){var u=0;i&&o(t);var s=t.__iterator(Ve,!i);return new Xe(function(){var t=s.next();if(t.done)return t;var o=t.value;return z(n,e?o[0]:i?r.size-++u:u++,o[1],t)})},n}function J(t,e,r,n){var i=st(t);return n&&(i.has=function(n){var i=t.get(n,je);return i!==je&&!!e.call(r,i,n,t)},i.get=function(n,i){var o=t.get(n,je);return o!==je&&e.call(r,o,n,t)?o:i}), +i.__iterateUncached=function(i,o){var u=this,s=0;return t.__iterate(function(t,o,a){if(e.call(r,t,o,a))return s++,i(t,n?o:s-1,u)},o),s},i.__iteratorUncached=function(i,o){var u=t.__iterator(Ve,o),s=0;return new Xe(function(){for(;;){var o=u.next();if(o.done)return o;var a=o.value,c=a[0],h=a[1];if(e.call(r,h,c,t))return z(i,n?c:s++,h,o)}})},i}function V(t,e,r){var n=zr().asMutable();return t.__iterate(function(i,o){n.update(e.call(r,i,o,t),0,function(t){return t+1})}),n.asImmutable()}function H(t,e,r){var n=v(t),i=(g(t)?Br():zr()).asMutable();t.__iterate(function(o,u){i.update(e.call(r,o,u,t),function(t){return t=t||[],t.push(n?[u,o]:o),t})});var o=ut(t);return i.map(function(e){return it(t,o(e))})}function Y(t,e,r,n){var i=t.size;if(a(e,r,i))return t;var o=c(e,i),s=h(r,i);if(o!==o||s!==s)return Y(t.toSeq().cacheResult(),e,r,n);var f,p=s-o;p===p&&(f=p<0?0:p);var _=st(t);return _.size=0===f?f:t.size&&f||void 0,!n&&E(t)&&f>=0&&(_.get=function(e,r){return e=u(this,e),e>=0&&ef)return I();var t=i.next();return n||e===Je||t.done?t:e===Pe?z(e,s-1,void 0,t):z(e,s-1,t.value[1],t)})},_}function Q(t,e,r){var n=st(t);return n.__iterateUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterate(n,i);var u=0;return t.__iterate(function(t,i,s){return e.call(r,t,i,s)&&++u&&n(t,i,o)}),u},n.__iteratorUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterator(n,i);var u=t.__iterator(Ve,i),s=!0;return new Xe(function(){if(!s)return I();var t=u.next();if(t.done)return t;var i=t.value,a=i[0],c=i[1];return e.call(r,c,a,o)?n===Ve?t:z(n,a,c,t):(s=!1,I())})},n} +function X(t,e,r,n){var i=st(t);return i.__iterateUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterate(i,o);var s=!0,a=0;return t.__iterate(function(t,o,c){if(!s||!(s=e.call(r,t,o,c)))return a++,i(t,n?o:a-1,u)}),a},i.__iteratorUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterator(i,o);var s=t.__iterator(Ve,o),a=!0,c=0;return new Xe(function(){var t,o,h;do{if(t=s.next(),t.done)return n||i===Je?t:i===Pe?z(i,c++,void 0,t):z(i,c++,t.value[1],t);var f=t.value;o=f[0],h=f[1],a&&(a=e.call(r,h,o,u))}while(a);return i===Ve?t:z(i,o,h,t)})},i}function F(t,e){var r=v(t),n=[t].concat(e).map(function(t){return l(t)?r&&(t=Be(t)):t=r?x(t):j(Array.isArray(t)?t:[t]),t}).filter(function(t){return 0!==t.size});if(0===n.length)return t;if(1===n.length){var i=n[0];if(i===t||r&&v(i)||y(t)&&y(i))return i}var o=new er(n);return r?o=o.toKeyedSeq():y(t)||(o=o.toSetSeq()),o=o.flatten(!0),o.size=n.reduce(function(t,e){if(void 0!==t){var r=e.size;if(void 0!==r)return t+r}},0),o}function G(t,e,r){var n=st(t);return n.__iterateUncached=function(i,o){function u(t,c){t.__iterate(function(t,o){return(!e||c0}function nt(t,e,r,n){var i=st(t),o=new er(r).map(function(t){return t.size});return i.size=n?o.max():o.min(),i.__iterate=function(t,e){for(var r,n=this,i=this.__iterator(Je,e),o=0;!(r=i.next()).done&&t(r.value,o++,n)!==!1;);return o},i.__iteratorUncached=function(t,i){var o=r.map(function(t){return t=Ce(t),O(i?t.reverse():t)}),u=0,s=!1;return new Xe(function(){var r;return s||(r=o.map(function(t){return t.next()}),s=n?r.every(function(t){return t.done}):r.some(function(t){return t.done})),s?I():z(t,u++,e.apply(null,r.map(function(t){return t.value})))})},i}function it(t,e){return t===e?t:E(t)?e:t.constructor(e)}function ot(t){if(t!==Object(t))throw new TypeError("Expected [K, V] tuple: "+t)}function ut(t){return v(t)?Be:y(t)?We:Ne}function st(t){return Object.create((v(t)?Ge:y(t)?Ze:$e).prototype)}function at(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size,this):Fe.prototype.cacheResult.call(this)}function ct(t,e){return void 0===t&&void 0===e?0:void 0===t?1:void 0===e?-1:t>e?1:t>>r)&xe,s=(0===r?n:n>>>r)&xe;return new Or(e,1<>>=1)u[s]=1&r?e[o++]:void 0;return u[n]=i,new Mr(t,o+1,u)}function Mt(t,e,r){for(var n=[],i=0;i>1&1431655765,t=(858993459&t)+(t>>2&858993459),t=t+(t>>4)&252645135,t+=t>>8,127&(t+=t>>16)}function kt(t,e,r,n){var o=n?t:i(t);return o[e]=r,o}function At(t,e,r,n){var i=t.length+1;if(n&&e+1===i)return t[e]=r,t;for(var o=Array(i),u=0,s=0;so?0:o-r,c=u-r;return c>De&&(c=De),function(){if(i===c)return Cr;var t=e?--c:i++;return n&&n[t]}}function i(t,n,i){var s,a=t&&t.array,c=i>o?0:o-i>>n,h=1+(u-i>>n);return h>De&&(h=De),function(){for(;;){if(s){var t=s();if(t!==Cr)return t;s=null}if(c===h)return Cr;var o=e?--h:c++;s=r(a&&a[o],n-Ee,i+(o<=t.size||r<0)return t.withMutations(function(t){r<0?Pt(t,r).set(0,n):Pt(t,0,r+1).set(r,n)});r+=t._origin;var i=t._tail,o=t._root,s=e(Ae);return r>=Jt(t._capacity)?i=Bt(i,t.__ownerID,0,r,n,s):o=Bt(o,t.__ownerID,t._level,r,n,s),s.value?t.__ownerID?(t._root=o,t._tail=i,t.__hash=void 0,t.__altered=!0,t):Lt(t._origin,t._capacity,t._level,o,i):t}function Bt(t,e,n,i,o,u){var s=i>>>n&xe,a=t&&s0){var h=t&&t.array[s],f=Bt(h,e,n-Ee,i,o,u);return f===h?t:(c=Wt(t,e),c.array[s]=f,c)} +return a&&t.array[s]===o?t:(r(u),c=Wt(t,e),void 0===o&&s===c.array.length-1?c.array.pop():c.array[s]=o,c)}function Wt(t,e){return e&&t&&e===t.ownerID?t:new Lr(t?t.array.slice():[],e)}function Nt(t,e){if(e>=Jt(t._capacity))return t._tail;if(e<1<0;)r=r.array[e>>>n&xe],n-=Ee;return r}}function Pt(t,e,r){void 0!==e&&(e|=0),void 0!==r&&(r|=0);var i=t.__ownerID||new n,o=t._origin,u=t._capacity,s=o+e,a=void 0===r?u:r<0?u+r:o+r;if(s===o&&a===u)return t;if(s>=a)return t.clear();for(var c=t._level,h=t._root,f=0;s+f<0;)h=new Lr(h&&h.array.length?[void 0,h]:[],i),c+=Ee,f+=1<=1<p?new Lr([],i):l;if(l&&_>p&&sEe;d-=Ee){var g=p>>>d&xe;y=y.array[g]=Wt(y.array[g],i)}y.array[p>>>Ee&xe]=l}if(a=_)s-=_,a-=_,c=Ee,h=null,v=v&&v.removeBefore(i,0,s);else if(s>o||_>>c&xe;if(m!==_>>>c&xe)break;m&&(f+=(1<o&&(h=h.removeBefore(i,c,s-f)),h&&_>>Ee<=De&&u.size>=2*o.size?(i=u.filter(function(t,e){return void 0!==t&&s!==e}),n=i.toKeyedSeq().map(function(t){return t[0]}).flip().toMap(),t.__ownerID&&(n.__ownerID=i.__ownerID=t.__ownerID)):(n=o.remove(e),i=s===u.size-1?u.pop():u.set(s,void 0))}else if(a){if(r===u.get(s)[1])return t;n=o,i=u.set(s,[e,r])}else n=o.set(e,u.size),i=u.set(u.size,[e,r]) +;return t.__ownerID?(t.size=n.size,t._map=n,t._list=i,t.__hash=void 0,t):Ht(n,i)}function Xt(t){return!(!t||!t[Pr])}function Ft(t,e,r,n){var i=Object.create(Jr);return i.size=t,i._head=e,i.__ownerID=r,i.__hash=n,i.__altered=!1,i}function Gt(){return Vr||(Vr=Ft(0))}function Zt(t,e){if(t===e)return!0;if(!l(e)||void 0!==t.size&&void 0!==e.size&&t.size!==e.size||void 0!==t.__hash&&void 0!==e.__hash&&t.__hash!==e.__hash||v(t)!==v(e)||y(t)!==y(e)||g(t)!==g(e))return!1;if(0===t.size&&0===e.size)return!0;var r=!d(t);if(g(t)){var n=t.entries();return e.every(function(t,e){var i=n.next().value;return i&&R(i[1],t)&&(r||R(i[0],e))})&&n.next().done}var i=!1;if(void 0===t.size)if(void 0===e.size)"function"==typeof t.cacheResult&&t.cacheResult();else{i=!0;var o=t;t=e,e=o}var u=!0,s=e.__iterate(function(e,n){if(r?!t.has(e):i?!R(e,t.get(n,je)):!R(t.get(n,je),e))return u=!1,!1});return u&&t.size===s}function $t(t,e){var r=function(r){t.prototype[r]=e[r]};return Object.keys(e).forEach(r),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(e).forEach(r),t}function te(t){return _(t)?Ce(t).map(te).toJSON():t}function ee(t){return!(!t||!t[Yr])}function re(t,e){return t.__ownerID?(t.size=e.size,t._map=e,t):e===t._map?t:0===e.size?t.__empty():t.__make(e)}function ne(t,e){var r=Object.create(Qr);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function ie(){return Xr||(Xr=ne(gt()))}function oe(t,e,r,n,i,o){return pt(t.size),t.__iterate(function(t,o,u){i?(i=!1,r=t):r=e.call(n,r,t,o,u)},o),r}function ue(t,e){return e}function se(t,e){return[e,t]}function ae(t){return function(){return!t.apply(this,arguments)}}function ce(t){return function(){return-t.apply(this,arguments)}}function he(){return i(arguments)}function fe(t,e){return te?-1:0}function pe(t){if(t.size===1/0)return 0;var e=g(t),r=v(t),n=e?1:0;return _e(t.__iterate(r?e?function(t,e){n=31*n+le(K(t),K(e))|0}:function(t,e){n=n+le(K(t),K(e))|0}:e?function(t){n=31*n+K(t)|0}:function(t){n=n+K(t)|0}),n)}function _e(t,e){return e=sr(e,3432918353), +e=sr(e<<15|e>>>-15,461845907),e=sr(e<<13|e>>>-13,5),e=(e+3864292196|0)^t,e=sr(e^e>>>16,2246822507),e=sr(e^e>>>13,3266489909),e=U(e^e>>>16)}function le(t,e){return t^e+2654435769+(t<<6)+(t>>2)|0}function ve(t){if("object"!=typeof console||!console.warn)throw Error(t);console.warn(t)}function ye(t,e,r,n){for(var i=ht(r),o=0;o!==i.length;){if(null==t)return e;if(!t||!t.get)return n&&ve("Invalid keyPath: Value at ["+i.slice(0,o).map(_t)+"] does not have a .get() method: "+t+"\nThis warning will throw in a future version"),e;if((t=t.get(i[o++],je))===je)return e}return t}function de(t){return ee(t)&&g(t)}function ge(t,e){var r=Object.create(rn);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function me(){return nn||(nn=ge(Yt()))}function we(t,e,r){var n=Object.create(Object.getPrototypeOf(t));return n._values=e,n.__ownerID=r,n}function ze(t){return t._name||t.constructor.name||"Record"}function Ie(t){return x(t._keys.map(function(e){return[e,t.get(e)]}))}function Se(t,e){try{Object.defineProperty(t,e,{get:function(){return this.get(e)},set:function(t){ft(this.__ownerID,"Cannot set on an immutable record."),this.set(e,t)}})}catch(t){}}function be(t,e){return Oe([],e||Me,t,"",e&&e.length>2?[]:void 0,{"":t})}function Oe(t,e,r,n,i,o){var u=Array.isArray(r)?Ze:qe(r)?Ge:null;if(u){if(~t.indexOf(r))throw new TypeError("Cannot convert circular structure to Immutable");t.push(r),i&&""!==n&&i.push(n);var s=e.call(o,n,u(r).map(function(n,o){return Oe(t,e,n,o,i,r)}),i&&i.slice());return t.pop(),i&&i.pop(),s}return r}function Me(t,e){return v(e)?e.toMap():e.toList()}function qe(t){return t&&(t.constructor===Object||void 0===t.constructor)}var Ee=5,De=1<=n.length){var e=r.next();if(e.done)return e;n[i]=e.value}return z(t,i,n[i++])})},e}(Ze),sr="function"==typeof Math.imul&&Math.imul(4294967295,2)===-2?Math.imul:function(t,e){t|=0,e|=0;var r=65535&t,n=65535&e;return r*n+((t>>>16)*n+r*(e>>>16)<<16>>>0)|0},ar=Object.isExtensible,cr=function(){try{return Object.defineProperty({},"@",{}),!0}catch(t){return!1}}(),hr="function"==typeof WeakMap;hr&&(ir=new WeakMap);var fr=0,pr="__immutablehash__";"function"==typeof Symbol&&(pr=Symbol(pr));var _r=16,lr=255,vr=0,yr={},dr=function(t){function e(t,e){this._iter=t,this._useKeys=e,this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t,e){return this._iter.get(t,e)},e.prototype.has=function(t){return this._iter.has(t)},e.prototype.valueSeq=function(){return this._iter.valueSeq()},e.prototype.reverse=function(){var t=this,e=P(this,!0);return this._useKeys||(e.valueSeq=function(){return t._iter.toSeq().reverse()}),e},e.prototype.map=function(t,e){var r=this,n=N(this,t,e);return this._useKeys||(n.valueSeq=function(){ +return r._iter.toSeq().map(t,e)}),n},e.prototype.__iterate=function(t,e){var r=this;return this._iter.__iterate(function(e,n){return t(e,n,r)},e)},e.prototype.__iterator=function(t,e){return this._iter.__iterator(t,e)},e}(Ge);dr.prototype[Le]=!0;var gr=function(t){function e(t){this._iter=t,this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.includes=function(t){return this._iter.includes(t)},e.prototype.__iterate=function(t,e){var r=this,n=0;return e&&o(this),this._iter.__iterate(function(i){return t(i,e?r.size-++n:n++,r)},e)},e.prototype.__iterator=function(t,e){var r=this,n=this._iter.__iterator(Je,e),i=0;return e&&o(this),new Xe(function(){var o=n.next();return o.done?o:z(t,e?r.size-++i:i++,o.value,o)})},e}(Ze),mr=function(t){function e(t){this._iter=t,this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.has=function(t){return this._iter.includes(t)},e.prototype.__iterate=function(t,e){var r=this;return this._iter.__iterate(function(e){return t(e,e,r)},e)},e.prototype.__iterator=function(t,e){var r=this._iter.__iterator(Je,e);return new Xe(function(){var e=r.next();return e.done?e:z(t,e.value,e.value,e)})},e}($e),wr=function(t){function e(t){this._iter=t,this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.entrySeq=function(){return this._iter.toSeq()},e.prototype.__iterate=function(t,e){var r=this;return this._iter.__iterate(function(e){if(e){ot(e);var n=l(e);return t(n?e.get(1):e[1],n?e.get(0):e[0],r)}},e)},e.prototype.__iterator=function(t,e){var r=this._iter.__iterator(Je,e);return new Xe(function(){for(;;){var e=r.next();if(e.done)return e;var n=e.value;if(n){ot(n);var i=l(n);return z(t,i?n.get(0):n[0],i?n.get(1):n[1],e)}}})},e}(Ge);gr.prototype.cacheResult=dr.prototype.cacheResult=mr.prototype.cacheResult=wr.prototype.cacheResult=at;var zr=function(t){function e(e){ return null===e||void 0===e?gt():lt(e)&&!g(e)?e:gt().withMutations(function(r){var n=t(e);pt(n.size),n.forEach(function(t,e){return r.set(e,t)})})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return gt().withMutations(function(e){for(var r=0;r=t.length)throw Error("Missing value for key: "+t[r]);e.set(t[r],t[r+1])}})},e.prototype.toString=function(){return this.__toString("Map {","}")},e.prototype.get=function(t,e){return this._root?this._root.get(0,void 0,t,e):e},e.prototype.set=function(t,e){return mt(this,t,e)},e.prototype.setIn=function(t,e){return this.updateIn(t,je,function(){return e})},e.prototype.remove=function(t){return mt(this,t,je)},e.prototype.deleteIn=function(t){if(t=[].concat(ht(t)),t.length){var e=t.pop();return this.updateIn(t,function(t){return t&&t.remove(e)})}},e.prototype.deleteAll=function(t){var e=Ce(t);return 0===e.size?this:this.withMutations(function(t){e.forEach(function(e){return t.remove(e)})})},e.prototype.update=function(t,e,r){return 1===arguments.length?t(this):this.updateIn([t],e,r)},e.prototype.updateIn=function(t,e,r){r||(r=e,e=void 0);var n=xt(this,ht(t),0,e,r);return n===je?e:n},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):gt()},e.prototype.merge=function(){return Mt(this,void 0,arguments)},e.prototype.mergeWith=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Mt(this,t,e)},e.prototype.mergeIn=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return this.updateIn(t,gt(),function(t){return"function"==typeof t.merge?t.merge.apply(t,e):e[e.length-1]})},e.prototype.mergeDeep=function(){return Mt(this,Et(qt),arguments)},e.prototype.mergeDeepWith=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Mt(this,Et(t),e)},e.prototype.mergeDeepIn=function(t){ -for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return this.updateIn(t,gt(),function(t){return"function"==typeof t.mergeDeep?t.mergeDeep.apply(t,e):e[e.length-1]})},e.prototype.sort=function(t){return Br(tt(this,t))},e.prototype.sortBy=function(t,e){return Br(tt(this,e,t))},e.prototype.withMutations=function(t){var e=this.asMutable();return t(e),e.wasAltered()?e.__ensureOwner(this.__ownerID):this},e.prototype.asMutable=function(){return this.__ownerID?this:this.__ensureOwner(new n)},e.prototype.asImmutable=function(){return this.__ensureOwner()},e.prototype.wasAltered=function(){return this.__altered},e.prototype.__iterator=function(t,e){return new xr(this,t,e)},e.prototype.__iterate=function(t,e){var r=this,n=0;return this._root&&this._root.iterate(function(e){return n++,t(e[1],e[0],r)},e),n},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?dt(this.size,this._root,t,this.__hash):0===this.size?gt():(this.__ownerID=t,this.__altered=!1,this)},e}(Be);Sr.isMap=lt;var zr="@@__IMMUTABLE_MAP__@@",Ir=Sr.prototype;Ir[zr]=!0,Ir.delete=Ir.remove,Ir.removeIn=Ir.deleteIn,Ir.removeAll=Ir.deleteAll,Ir.concat=Ir.merge,Ir["@@transducer/init"]=Ir.asMutable,Ir["@@transducer/step"]=function(t,e){return t.set(e[0],e[1])},Ir["@@transducer/result"]=function(t){return t.asImmutable()};var br=function(t,e){this.ownerID=t,this.entries=e};br.prototype.get=function(t,e,r,n){for(var i=this.entries,o=0,u=i.length;o=jr)return It(t,h,o,u);var l=t&&t===this.ownerID,v=l?h:i(h);return _?c?f===p-1?v.pop():v[f]=v.pop():v[f]=[o,u]:v.push([o,u]),l?(this.entries=v,this):new br(t,v)}};var Or=function(t,e,r){this.ownerID=t,this.bitmap=e,this.nodes=r};Or.prototype.get=function(t,e,r,n){void 0===e&&(e=K(r));var i=1<<((0===t?e:e>>>t)&xe),o=this.bitmap -;return 0==(o&i)?n:this.nodes[jt(o&i-1)].get(t+Ee,e,r,n)},Or.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=K(n));var s=(0===e?r:r>>>e)&xe,a=1<=kr)return Ot(t,p,c,s,l);if(h&&!l&&2===p.length&&St(p[1^f]))return p[1^f];if(h&&l&&1===p.length&&St(l))return l;var v=t&&t===this.ownerID,y=h?l?c:c^a:c|a,d=h?l?kt(p,f,l,v):Rt(p,f,v):At(p,f,l,v);return v?(this.bitmap=y,this.nodes=d,this):new Or(t,y,d)};var Mr=function(t,e,r){this.ownerID=t,this.count=e,this.nodes=r};Mr.prototype.get=function(t,e,r,n){void 0===e&&(e=K(r));var i=(0===t?e:e>>>t)&xe,o=this.nodes[i];return o?o.get(t+Ee,e,r,n):n},Mr.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=K(n));var s=(0===e?r:r>>>e)&xe,a=i===je,c=this.nodes,h=c[s];if(a&&!h)return this;var f=wt(h,t,e+Ee,r,n,i,o,u);if(f===h)return this;var p=this.count;if(h){if(!f&&--p0&&i=0&&t>>e&xe;if(n>=this.array.length)return new Lr([],t);var i,o=0===n;if(e>0){var u=this.array[n];if((i=u&&u.removeBefore(t,e-Ee,r))===u&&o)return this}if(o&&!i)return this;var s=Wt(this,t);if(!o)for(var a=0;a>>e&xe;if(n>=this.array.length)return this;var i;if(e>0){var o=this.array[n];if((i=o&&o.removeAfter(t,e-Ee,r))===o&&n===this.array.length-1)return this}var u=Wt(this,t);return u.array.splice(n+1),i&&(u.array[n]=i),u};var Tr,Cr={},Br=function(t){function e(t){return null===t||void 0===t?Yt():Vt(t)?t:Yt().withMutations(function(e){var r=Be(t);pt(r.size),r.forEach(function(t,r){return e.set(r,t)})})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("OrderedMap {","}")},e.prototype.get=function(t,e){var r=this._map.get(t);return void 0!==r?this._list.get(r)[1]:e},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._map.clear(),this._list.clear(),this):Yt()},e.prototype.set=function(t,e){return Qt(this,t,e)},e.prototype.remove=function(t){return Qt(this,t,je)},e.prototype.wasAltered=function(){return this._map.wasAltered()||this._list.wasAltered()},e.prototype.__iterate=function(t,e){var r=this;return this._list.__iterate(function(e){return e&&t(e[1],e[0],r)},e)},e.prototype.__iterator=function(t,e){return this._list.fromEntrySeq().__iterator(t,e)},e.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var e=this._map.__ensureOwner(t),r=this._list.__ensureOwner(t);return t?Ht(e,r,t,this.__hash):0===this.size?Yt():(this.__ownerID=t,this._map=e,this._list=r,this)},e}(Sr) -;Br.isOrderedMap=Vt,Br.prototype[Le]=!0,Br.prototype.delete=Br.prototype.remove;var Wr,Jr=function(t){function e(t){return null===t||void 0===t?Gt():Xt(t)?t:Gt().pushAll(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("Stack [","]")},e.prototype.get=function(t,e){var r=this._head;for(t=u(this,t);r&&t--;)r=r.next;return r?r.value:e},e.prototype.peek=function(){return this._head&&this._head.value},e.prototype.push=function(){var t=arguments;if(0===arguments.length)return this;for(var e=this.size+arguments.length,r=this._head,n=arguments.length-1;n>=0;n--)r={value:t[n],next:r};return this.__ownerID?(this.size=e,this._head=r,this.__hash=void 0,this.__altered=!0,this):Ft(e,r)},e.prototype.pushAll=function(e){if(e=t(e),0===e.size)return this;if(0===this.size&&Xt(e))return e;pt(e.size);var r=this.size,n=this._head;return e.__iterate(function(t){r++,n={value:t,next:n}},!0),this.__ownerID?(this.size=r,this._head=n,this.__hash=void 0,this.__altered=!0,this):Ft(r,n)},e.prototype.pop=function(){return this.slice(1)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):Gt()},e.prototype.slice=function(e,r){if(a(e,r,this.size))return this;var n=c(e,this.size);if(h(r,this.size)!==this.size)return t.prototype.slice.call(this,e,r);for(var i=this.size-n,o=this._head;n--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):Ft(i,o)},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Ft(this.size,this._head,t,this.__hash):0===this.size?Gt():(this.__ownerID=t,this.__altered=!1,this)},e.prototype.__iterate=function(t,e){var r=this;if(e)return new er(this.toArray()).__iterate(function(e,n){return t(e,n,r)},e);for(var n=0,i=this._head;i&&t(i.value,n++,r)!==!1;)i=i.next;return n},e.prototype.__iterator=function(t,e){ -if(e)return new er(this.toArray()).__iterator(t,e);var r=0,n=this._head;return new Xe(function(){if(n){var e=n.value;return n=n.next,S(t,r++,e)}return z()})},e}(We);Jr.isStack=Xt;var Nr="@@__IMMUTABLE_STACK__@@",Pr=Jr.prototype;Pr[Nr]=!0,Pr.withMutations=Ir.withMutations,Pr.asMutable=Ir.asMutable,Pr.asImmutable=Ir.asImmutable,Pr.wasAltered=Ir.wasAltered,Pr.shift=Pr.pop,Pr.unshift=Pr.push,Pr.unshiftAll=Pr.pushAll,Pr["@@transducer/init"]=Pr.asMutable,Pr["@@transducer/step"]=function(t,e){return t.unshift(e)},Pr["@@transducer/result"]=Ir["@@transducer/result"];var Vr,Hr=function(t){function e(e){return null===e||void 0===e?ne():te(e)&&!g(e)?e:ne().withMutations(function(r){var n=t(e);pt(n.size),n.forEach(function(t){return r.add(t)})})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(Be(t).keySeq())},e.intersect=function(t){return t=Ce(t).toArray(),t.length?Qr.intersect.apply(e(t.pop()),t):ne()},e.union=function(t){return t=Ce(t).toArray(),t.length?Qr.union.apply(e(t.pop()),t):ne()},e.prototype.toString=function(){return this.__toString("Set {","}")},e.prototype.has=function(t){return this._map.has(t)},e.prototype.add=function(t){return ee(this,this._map.set(t,t))},e.prototype.remove=function(t){return ee(this,this._map.remove(t))},e.prototype.clear=function(){return ee(this,this._map.clear())},e.prototype.union=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return e=e.filter(function(t){return 0!==t.size}),0===e.length?this:0!==this.size||this.__ownerID||1!==e.length?this.withMutations(function(r){for(var n=0;n=0&&e=0&&rthis.size?e:this.find(function(e,r){return r===t},void 0,e)},has:function(t){return(t=u(this,t))>=0&&(void 0!==this.size?this.size===1/0||t0;)e[r]=arguments[r+1];return this.updateIn(t,gt(),function(t){return"function"==typeof t.mergeDeep?t.mergeDeep.apply(t,e):e[e.length-1]})},e.prototype.sort=function(t){return Br(tt(this,t))},e.prototype.sortBy=function(t,e){return Br(tt(this,e,t))},e.prototype.withMutations=function(t){var e=this.asMutable();return t(e),e.wasAltered()?e.__ensureOwner(this.__ownerID):this},e.prototype.asMutable=function(){return this.__ownerID?this:this.__ensureOwner(new n)},e.prototype.asImmutable=function(){return this.__ensureOwner()},e.prototype.wasAltered=function(){return this.__altered},e.prototype.__iterator=function(t,e){return new xr(this,t,e)},e.prototype.__iterate=function(t,e){var r=this,n=0;return this._root&&this._root.iterate(function(e){return n++,t(e[1],e[0],r)},e),n},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?dt(this.size,this._root,t,this.__hash):0===this.size?gt():(this.__ownerID=t,this.__altered=!1,this)},e}(Be);zr.isMap=lt;var Ir="@@__IMMUTABLE_MAP__@@",Sr=zr.prototype;Sr[Ir]=!0,Sr.delete=Sr.remove,Sr.removeIn=Sr.deleteIn,Sr.removeAll=Sr.deleteAll,Sr.concat=Sr.merge,Sr["@@transducer/init"]=Sr.asMutable,Sr["@@transducer/step"]=function(t,e){return t.set(e[0],e[1])},Sr["@@transducer/result"]=function(t){return t.asImmutable()};var br=function(t,e){this.ownerID=t,this.entries=e};br.prototype.get=function(t,e,r,n){for(var i=this.entries,o=0,u=i.length;o=jr)return St(t,h,o,u);var l=t&&t===this.ownerID,v=l?h:i(h);return _?c?f===p-1?v.pop():v[f]=v.pop():v[f]=[o,u]:v.push([o,u]),l?(this.entries=v,this):new br(t,v)}};var Or=function(t,e,r){this.ownerID=t,this.bitmap=e,this.nodes=r};Or.prototype.get=function(t,e,r,n){void 0===e&&(e=K(r));var i=1<<((0===t?e:e>>>t)&xe),o=this.bitmap +;return 0==(o&i)?n:this.nodes[jt(o&i-1)].get(t+Ee,e,r,n)},Or.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=K(n));var s=(0===e?r:r>>>e)&xe,a=1<=kr)return Ot(t,p,c,s,l);if(h&&!l&&2===p.length&&zt(p[1^f]))return p[1^f];if(h&&l&&1===p.length&&zt(l))return l;var v=t&&t===this.ownerID,y=h?l?c:c^a:c|a,d=h?l?kt(p,f,l,v):Rt(p,f,v):At(p,f,l,v);return v?(this.bitmap=y,this.nodes=d,this):new Or(t,y,d)};var Mr=function(t,e,r){this.ownerID=t,this.count=e,this.nodes=r};Mr.prototype.get=function(t,e,r,n){void 0===e&&(e=K(r));var i=(0===t?e:e>>>t)&xe,o=this.nodes[i];return o?o.get(t+Ee,e,r,n):n},Mr.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=K(n));var s=(0===e?r:r>>>e)&xe,a=i===je,c=this.nodes,h=c[s];if(a&&!h)return this;var f=wt(h,t,e+Ee,r,n,i,o,u);if(f===h)return this;var p=this.count;if(h){if(!f&&--p0&&i=0&&t>>e&xe;if(n>=this.array.length)return new Lr([],t);var i,o=0===n;if(e>0){var u=this.array[n];if((i=u&&u.removeBefore(t,e-Ee,r))===u&&o)return this}if(o&&!i)return this;var s=Wt(this,t);if(!o)for(var a=0;a>>e&xe;if(n>=this.array.length)return this;var i;if(e>0){var o=this.array[n];if((i=o&&o.removeAfter(t,e-Ee,r))===o&&n===this.array.length-1)return this}var u=Wt(this,t);return u.array.splice(n+1),i&&(u.array[n]=i),u};var Tr,Cr={},Br=function(t){function e(t){return null===t||void 0===t?Yt():Vt(t)?t:Yt().withMutations(function(e){var r=Be(t);pt(r.size),r.forEach(function(t,r){return e.set(r,t)})})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("OrderedMap {","}")},e.prototype.get=function(t,e){var r=this._map.get(t);return void 0!==r?this._list.get(r)[1]:e},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._map.clear(),this._list.clear(),this):Yt()},e.prototype.set=function(t,e){return Qt(this,t,e)},e.prototype.remove=function(t){return Qt(this,t,je)},e.prototype.wasAltered=function(){return this._map.wasAltered()||this._list.wasAltered()},e.prototype.__iterate=function(t,e){var r=this;return this._list.__iterate(function(e){return e&&t(e[1],e[0],r)},e)},e.prototype.__iterator=function(t,e){return this._list.fromEntrySeq().__iterator(t,e)},e.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var e=this._map.__ensureOwner(t),r=this._list.__ensureOwner(t);return t?Ht(e,r,t,this.__hash):0===this.size?Yt():(this.__ownerID=t,this._map=e,this._list=r,this)},e}(zr) +;Br.isOrderedMap=Vt,Br.prototype[Le]=!0,Br.prototype.delete=Br.prototype.remove;var Wr,Nr=function(t){function e(t){return null===t||void 0===t?Gt():Xt(t)?t:Gt().pushAll(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("Stack [","]")},e.prototype.get=function(t,e){var r=this._head;for(t=u(this,t);r&&t--;)r=r.next;return r?r.value:e},e.prototype.peek=function(){return this._head&&this._head.value},e.prototype.push=function(){var t=arguments;if(0===arguments.length)return this;for(var e=this.size+arguments.length,r=this._head,n=arguments.length-1;n>=0;n--)r={value:t[n],next:r};return this.__ownerID?(this.size=e,this._head=r,this.__hash=void 0,this.__altered=!0,this):Ft(e,r)},e.prototype.pushAll=function(e){if(e=t(e),0===e.size)return this;if(0===this.size&&Xt(e))return e;pt(e.size);var r=this.size,n=this._head;return e.__iterate(function(t){r++,n={value:t,next:n}},!0),this.__ownerID?(this.size=r,this._head=n,this.__hash=void 0,this.__altered=!0,this):Ft(r,n)},e.prototype.pop=function(){return this.slice(1)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):Gt()},e.prototype.slice=function(e,r){if(a(e,r,this.size))return this;var n=c(e,this.size);if(h(r,this.size)!==this.size)return t.prototype.slice.call(this,e,r);for(var i=this.size-n,o=this._head;n--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):Ft(i,o)},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Ft(this.size,this._head,t,this.__hash):0===this.size?Gt():(this.__ownerID=t,this.__altered=!1,this)},e.prototype.__iterate=function(t,e){var r=this;if(e)return new er(this.toArray()).__iterate(function(e,n){return t(e,n,r)},e);for(var n=0,i=this._head;i&&t(i.value,n++,r)!==!1;)i=i.next;return n},e.prototype.__iterator=function(t,e){ +if(e)return new er(this.toArray()).__iterator(t,e);var r=0,n=this._head;return new Xe(function(){if(n){var e=n.value;return n=n.next,z(t,r++,e)}return I()})},e}(We);Nr.isStack=Xt;var Pr="@@__IMMUTABLE_STACK__@@",Jr=Nr.prototype;Jr[Pr]=!0,Jr.withMutations=Sr.withMutations,Jr.asMutable=Sr.asMutable,Jr.asImmutable=Sr.asImmutable,Jr.wasAltered=Sr.wasAltered,Jr.shift=Jr.pop,Jr.unshift=Jr.push,Jr.unshiftAll=Jr.pushAll,Jr["@@transducer/init"]=Jr.asMutable,Jr["@@transducer/step"]=function(t,e){return t.unshift(e)},Jr["@@transducer/result"]=Sr["@@transducer/result"];var Vr,Hr=function(t){function e(e){return null===e||void 0===e?ie():ee(e)&&!g(e)?e:ie().withMutations(function(r){var n=t(e);pt(n.size),n.forEach(function(t){return r.add(t)})})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(Be(t).keySeq())},e.intersect=function(t){return t=Ce(t).toArray(),t.length?Qr.intersect.apply(e(t.pop()),t):ie()},e.union=function(t){return t=Ce(t).toArray(),t.length?Qr.union.apply(e(t.pop()),t):ie()},e.prototype.toString=function(){return this.__toString("Set {","}")},e.prototype.has=function(t){return this._map.has(t)},e.prototype.add=function(t){return re(this,this._map.set(t,t))},e.prototype.remove=function(t){return re(this,this._map.remove(t))},e.prototype.clear=function(){return re(this,this._map.clear())},e.prototype.union=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return e=e.filter(function(t){return 0!==t.size}),0===e.length?this:0!==this.size||this.__ownerID||1!==e.length?this.withMutations(function(r){for(var n=0;n=0&&e=0&&rthis.size?e:this.find(function(e,r){return r===t},void 0,e)},has:function(t){return(t=u(this,t))>=0&&(void 0!==this.size?this.size===1/0||t Date: Mon, 16 Oct 2017 16:16:30 +0000 Subject: [PATCH 063/242] Deploy e35f5fed7d1eb72795b8a87ec34185db26a75591 to NPM branch --- dist/immutable-nonambient.d.ts | 420 +++++++++++++++++++++++- dist/immutable.d.ts | 420 +++++++++++++++++++++++- dist/immutable.es.js | 561 ++++++++++++++++++++------------ dist/immutable.js | 573 +++++++++++++++++++++------------ dist/immutable.js.flow | 109 ++++++- dist/immutable.min.js | 63 ++-- 6 files changed, 1693 insertions(+), 453 deletions(-) diff --git a/dist/immutable-nonambient.d.ts b/dist/immutable-nonambient.d.ts index 31cd68ae1c..0e338800ae 100644 --- a/dist/immutable-nonambient.d.ts +++ b/dist/immutable-nonambient.d.ts @@ -707,6 +707,18 @@ * // List [ 0, 1, 2, List [ 999, 4 ] ] * ``` * + * Plain JavaScript Object or Arrays may be nested within an Immutable.js + * Collection, and setIn() can update those values as well, treating them + * immutably by creating new copies of those values with the changes applied. + * + * + * ```js + * const { List } = require('immutable@4.0.0-rc.7') + * const list = List([ 0, 1, 2, { plain: 'object' }]) + * list.setIn([3, 'plain'], 'value'); + * // List([ 0, 1, 2, { plain: 'value' }]) + * ``` + * * Note: `setIn` can be used in `withMutations`. */ setIn(keyPath: Iterable, value: any): this; @@ -723,6 +735,18 @@ * // List [ 0, 1, 2, List [ 4 ] ] * ``` * + * Plain JavaScript Object or Arrays may be nested within an Immutable.js + * Collection, and removeIn() can update those values as well, treating them + * immutably by creating new copies of those values with the changes applied. + * + * + * ```js + * const { List } = require('immutable@4.0.0-rc.7') + * const list = List([ 0, 1, 2, { plain: 'object' }]) + * list.removeIn([3, 'plain']); + * // List([ 0, 1, 2, {}]) + * ``` + * * Note: `deleteIn` *cannot* be safely used in `withMutations`. * * @alias removeIn @@ -1344,8 +1368,33 @@ * // } * ``` * - * If any key in the path exists but does not have a `.set()` method - * (such as Map and List), an error will be throw. + * Plain JavaScript Object or Arrays may be nested within an Immutable.js + * Collection, and setIn() can update those values as well, treating them + * immutably by creating new copies of those values with the changes applied. + * + * + * ```js + * const { Map } = require('immutable@4.0.0-rc.7') + * const originalMap = Map({ + * subObject: { + * subKey: 'subvalue', + * subSubObject: { + * subSubKey: 'subSubValue' + * } + * } + * }) + * + * originalMap.setIn(['subObject', 'subKey'], 'ha ha!') + * // Map { + * // "subObject": { + * // subKey: "ha ha!", + * // subSubObject: { subSubKey: "subSubValue" } + * // } + * // } + * ``` + * + * If any key in the path exists but cannot be updated (such as a primitive + * like number or a custom Object like Date), an error will be thrown. * * Note: `setIn` can be used in `withMutations`. */ @@ -1420,8 +1469,23 @@ * // Map { "a": Map { "b": Map { "c": 10, "x": 100 } } } * ``` * - * If any key in the path exists but does not have a .set() method (such as - * Map and List), an error will be thrown. + * Plain JavaScript Object or Arrays may be nested within an Immutable.js + * Collection, and updateIn() can update those values as well, treating them + * immutably by creating new copies of those values with the changes applied. + * + * + * ```js + * const map = Map({ a: { b: { c: 10 } } }) + * const newMap = map.updateIn(['a', 'b', 'c'], val => val * 2) + * // Map { "a": { b: { c: 20 } } } + * ``` + * + * If any key in the path exists but cannot be updated (such as a primitive + * like number or a custom Object like Date), an error will be thrown. + * + * Note: `updateIn` can be used in `withMutations`. */ updateIn(keyPath: Iterable, notSetValue: any, updater: (value: any) => any): this; updateIn(keyPath: Iterable, updater: (value: any) => any): this; @@ -2454,6 +2518,44 @@ * export type Point3D = RecordOf; * const some3DPoint: Point3D = makePoint3D({ x: 10, y: 20, z: 30 }); * ``` + * + * + * **Choosing Records vs plain JavaScript objects** + * + * Records ofters a persistently immutable alternative to plain JavaScript + * objects, however they're not required to be used within Immutable.js + * collections. In fact, the deep-access and deep-updating functions + * like `getIn()` and `setIn()` work with plain JavaScript Objects as well. + * + * Deciding to use Records or Objects in your application should be informed + * by the tradeoffs and relative benefits of each: + * + * - *Runtime immutability*: plain JS objects may be carefully treated as + * immutable, however Record instances will *throw* if attempted to be + * mutated directly. Records provide this additional guarantee, however at + * some marginal runtime cost. While JS objects are mutable by nature, the + * use of type-checking tools like [Flow](https://medium.com/@gcanti/immutability-with-flow-faa050a1aef4) + * can help gain confidence in code written to favor immutability. + * + * - *Value equality*: Records use value equality when compared with `is()` + * or `record.equals()`. That is, two Records with the same keys and values + * are equal. Plain objects use *reference equality*. Two objects with the + * same keys and values are not equal since they are different objects. + * This is important to consider when using objects as keys in a `Map` or + * values in a `Set`, which use equality when retrieving values. + * + * - *API methods*: Records have a full featured API, with methods like + * `.getIn()`, and `.equals()`. These can make working with these values + * easier, but comes at the cost of not allowing keys with those names. + * + * - *Default values*: Records provide default values for every key, which + * can be useful when constructing Records with often unchanging values. + * However default values can make using Flow and TypeScript more laborious. + * + * - *Serialization*: Records use a custom internal representation to + * efficiently store and update their values. Converting to and from this + * form isn't free. If converting Records to plain objects is common, + * consider sticking with plain objects to begin with. */ export module Record { @@ -3903,6 +4005,23 @@ /** * Returns the value found by following a path of keys or indices through * nested Collections. + * + * + * ```js + * const { Map, List } = require('immutable@4.0.0-rc.7') + * const deepData = Map({ x: List([ Map({ y: 123 }) ]) }); + * getIn(deepData, ['x', 0, 'y']) // 123 + * ``` + * + * Plain JavaScript Object or Arrays may be nested within an Immutable.js + * Collection, and getIn() can access those values as well: + * + * + * ```js + * const { Map, List } = require('immutable@4.0.0-rc.7') + * const deepData = Map({ x: [ { y: 123 } ] }); + * getIn(deepData, ['x', 0, 'y']) // 123 + * ``` */ getIn(searchKeyPath: Iterable, notSetValue?: any): any; @@ -4709,3 +4828,296 @@ isSuperset(iter: Iterable): boolean; } + /** + * Returns the value within the provided collection associated with the + * provided key, or notSetValue if the key is not defined in the collection. + * + * A functional alternative to `collection.get(key)` which will also work on + * plain Objects and Arrays as an alternative for `collection[key]`. + * + * + * ```js + * const { get } = require('immutable@4.0.0-rc.7') + * get([ 'dog', 'frog', 'cat' ], 2) // 'frog' + * get({ x: 123, y: 456 }, 'x') // 123 + * get({ x: 123, y: 456 }, 'z', 'ifNotSet') // 'ifNotSet' + * ``` + */ + export function get(collection: Collection, key: K): V | undefined; + export function get(collection: Collection, key: K, notSetValue: NSV): V | NSV; + export function get(record: Record, key: K, notSetValue: any): TProps[K]; + export function get(collection: Array, key: number): V | undefined; + export function get(collection: Array, key: number, notSetValue: NSV): V | NSV; + export function get(object: C, key: K, notSetValue: any): C[K]; + export function get(collection: {[key: string]: V}, key: string): V | undefined; + export function get(collection: {[key: string]: V}, key: string, notSetValue: NSV): V | NSV; + + /** + * Returns true if the key is defined in the provided collection. + * + * A functional alternative to `collection.has(key)` which will also work with + * plain Objects and Arrays as an alternative for + * `collection.hasOwnProperty(key)`. + * + * + * ```js + * const { has } = require('immutable@4.0.0-rc.7') + * has([ 'dog', 'frog', 'cat' ], 2) // true + * has([ 'dog', 'frog', 'cat' ], 5) // false + * has({ x: 123, y: 456 }, 'x') // true + * has({ x: 123, y: 456 }, 'z') // false + * ``` + */ + export function has(collection: Object, key: mixed): boolean; + + /** + * Returns a copy of the collection with the value at key removed. + * + * A functional alternative to `collection.remove(key)` which will also work + * with plain Objects and Arrays as an alternative for + * `delete collectionCopy[key]`. + * + * + * ```js + * const { remove } = require('immutable@4.0.0-rc.7') + * const originalArray = [ 'dog', 'frog', 'cat' ] + * remove(originalArray, 1) // [ 'dog', 'cat' ] + * console.log(originalArray) // [ 'dog', 'frog', 'cat' ] + * const originalObject = { x: 123, y: 456 } + * remove(originalObject, 'x') // { y: 456 } + * console.log(originalObject) // { x: 123, y: 456 } + * ``` + */ + export function remove>(collection: C, key: K): C; + export function remove, K extends keyof TProps>(collection: C, key: K): C; + export function remove>(collection: C, key: number): C; + export function remove(collection: C, key: K): C; + export function remove(collection: C, key: K): C; + + /** + * Returns a copy of the collection with the value at key set to the provided + * value. + * + * A functional alternative to `collection.set(key, value)` which will also + * work with plain Objects and Arrays as an alternative for + * `collectionCopy[key] = value`. + * + * + * ```js + * const { set } = require('immutable@4.0.0-rc.7') + * const originalArray = [ 'dog', 'frog', 'cat' ] + * set(originalArray, 1, 'cow') // [ 'dog', 'cow', 'cat' ] + * console.log(originalArray) // [ 'dog', 'frog', 'cat' ] + * const originalObject = { x: 123, y: 456 } + * set(originalObject, 'x', 789) // { x: 789, y: 456 } + * console.log(originalObject) // { x: 123, y: 456 } + * ``` + */ + export function set>(collection: C, key: K, value: V): C; + export function set, K extends keyof TProps>(record: C, key: K, value: TProps[K]): C; + export function set>(collection: C, key: number, value: V): C; + export function set(object: C, key: K, value: C[K]): C; + export function set(collection: C, key: string, value: V): C; + + /** + * Returns a copy of the collection with the value at key set to the result of + * providing the existing value to the updating function. + * + * A functional alternative to `collection.update(key, fn)` which will also + * work with plain Objects and Arrays as an alternative for + * `collectionCopy[key] = fn(collection[key])`. + * + * + * ```js + * const { update } = require('immutable@4.0.0-rc.7') + * const originalArray = [ 'dog', 'frog', 'cat' ] + * update(originalArray, 1, val => val.toUpperCase()) // [ 'dog', 'FROG', 'cat' ] + * console.log(originalArray) // [ 'dog', 'frog', 'cat' ] + * const originalObject = { x: 123, y: 456 } + * set(originalObject, 'x', val => val * 6) // { x: 738, y: 456 } + * console.log(originalObject) // { x: 123, y: 456 } + * ``` + */ + export function update>(collection: C, key: K, updater: (value: V) => V): C; + export function update, NSV>(collection: C, key: K, notSetValue: NSV, updater: (value: V | NSV) => V): C; + export function update, K extends keyof TProps>(record: C, key: K, updater: (value: TProps[K]) => TProps[K]): C; + export function update, K extends keyof TProps, NSV>(record: C, key: K, notSetValue: NSV, updater: (value: TProps[K] | NSV) => TProps[K]): C; + export function update(collection: Array, key: number, updater: (value: V) => V): Array; + export function update(collection: Array, key: number, notSetValue: NSV, updater: (value: V | NSV) => V): C; + export function update(object: C, key: K, updater: (value: C[K]) => C[K]): C; + export function update(object: C, key: K, notSetValue: NSV, updater: (value: C[K] | NSV) => C[K]): C; + export function update(collection: C, key: K, updater: (value: V) => V): {[key: string]: V}; + export function update(collection: C, key: K, notSetValue: NSV, updater: (value: V | NSV) => V): {[key: string]: V}; + + /** + * Returns the value at the provided key path starting at the provided + * collection, or notSetValue if the key path is not defined. + * + * A functional alternative to `collection.getIn(keypath)` which will also + * work with plain Objects and Arrays. + * + * + * ```js + * const { getIn } = require('immutable@4.0.0-rc.7') + * getIn({ x: { y: { z: 123 }}}, ['x', 'y', 'z']) // 123 + * getIn({ x: { y: { z: 123 }}}, ['x', 'q', 'p'], 'ifNotSet') // 'ifNotSet' + * ``` + */ + export function getIn(collection: any, keyPath: Iterable, notSetValue: any): any; + + /** + * Returns true if the key path is defined in the provided collection. + * + * A functional alternative to `collection.hasIn(keypath)` which will also + * work with plain Objects and Arrays. + * + * + * ```js + * const { hasIn } = require('immutable@4.0.0-rc.7') + * hasIn({ x: { y: { z: 123 }}}, ['x', 'y', 'z']) // true + * hasIn({ x: { y: { z: 123 }}}, ['x', 'q', 'p']) // false + * ``` + */ + export function hasIn(collection: any, keyPath: Iterable): boolean; + + /** + * Returns a copy of the collection with the value at the key path removed. + * + * A functional alternative to `collection.removeIn(keypath)` which will also + * work with plain Objects and Arrays. + * + * + * ```js + * const { removeIn } = require('immutable@4.0.0-rc.7') + * const original = { x: { y: { z: 123 }}} + * removeIn(original, ['x', 'y', 'z']) // { x: { y: {}}} + * console.log(original) // { x: { y: { z: 123 }}} + * ``` + */ + export function removeIn(collection: C, keyPath: Iterable): C; + + /** + * Returns a copy of the collection with the value at the key path set to the + * provided value. + * + * A functional alternative to `collection.setIn(keypath)` which will also + * work with plain Objects and Arrays. + * + * + * ```js + * const { setIn } = require('immutable@4.0.0-rc.7') + * const original = { x: { y: { z: 123 }}} + * setIn(original, ['x', 'y', 'z'], 456) // { x: { y: { z: 456 }}} + * console.log(original) // { x: { y: { z: 123 }}} + * ``` + */ + export function setIn(collection: C, keyPath: Iterable, value: any): C; + + /** + * Returns a copy of the collection with the value at key path set to the + * result of providing the existing value to the updating function. + * + * A functional alternative to `collection.updateIn(keypath)` which will also + * work with plain Objects and Arrays. + * + * + * ```js + * const { setIn } = require('immutable@4.0.0-rc.7') + * const original = { x: { y: { z: 123 }}} + * setIn(original, ['x', 'y', 'z'], val => val * 6) // { x: { y: { z: 738 }}} + * console.log(original) // { x: { y: { z: 123 }}} + * ``` + */ + export function updateIn(collection: C, keyPath: Iterable, updater: (value: any) => any): C; + + + /** + * Returns a copy of the collection with the remaining collections merged in. + * + * A functional alternative to `collection.merge()` which will also work with + * plain Objects and Arrays. + * + * + * ```js + * const { merge } = require('immutable@4.0.0-rc.7') + * const original = { x: 123, y: 456 } + * merge(original, { y: 789, z: 'abc' }) // { x: 123, y: 789, z: 'abc' } + * console.log(original) // { x: { y: { z: 123 }}} + * ``` + */ + export function merge( + collection: C, + ...collections: Array | Iterable<[any, any]> | {[key: string]: any}> + ): C; + + /** + * Returns a copy of the collection with the remaining collections merged in, + * calling the `merger` function whenever an existing value is encountered. + * + * A functional alternative to `collection.mergeWith()` which will also work + * with plain Objects and Arrays. + * + * + * ```js + * const { mergeWith } = require('immutable@4.0.0-rc.7') + * const original = { x: 123, y: 456 } + * mergeWith( + * (oldVal, newVal) => oldVal + newVal, + * original, + * { y: 789, z: 'abc' } + * ) // { x: 123, y: 1245, z: 'abc' } + * console.log(original) // { x: { y: { z: 123 }}} + * ``` + */ + export function mergeWith( + merger: (oldVal: any, newVal: any, key: any) => any, + collection: C, + ...collections: Array | Iterable<[any, any]> | {[key: string]: any}> + ): C; + + /** + * Returns a copy of the collection with the remaining collections merged in + * deeply (recursively). + * + * A functional alternative to `collection.mergeDeep()` which will also work + * with plain Objects and Arrays. + * + * + * ```js + * const { merge } = require('immutable@4.0.0-rc.7') + * const original = { x: { y: 123 }} + * merge(original, { x: { z: 456 }}) // { x: { y: 123, z: 456 }} + * console.log(original) // { x: { y: 123 }} + * ``` + */ + export function mergeDeep( + collection: C, + ...collections: Array | Iterable<[any, any]> | {[key: string]: any}> + ): C; + + /** + * Returns a copy of the collection with the remaining collections merged in + * deeply (recursively), calling the `merger` function whenever an existing + * value is encountered. + * + * A functional alternative to `collection.mergeDeepWith()` which will also + * work with plain Objects and Arrays. + * + * + * ```js + * const { merge } = require('immutable@4.0.0-rc.7') + * const original = { x: { y: 123 }} + * mergeDeepWith( + * (oldVal, newVal) => oldVal + newVal, + * original, + * { x: { y: 456 }} + * ) // { x: { y: 579 }} + * console.log(original) // { x: { y: 123 }} + * ``` + */ + export function mergeDeepWith( + merger: (oldVal: any, newVal: any, key: any) => mixed, + collection: C, + ...collections: Array | Iterable<[any, any]> | {[key: string]: any}> + ): C; + diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index ba4f0d8d41..02352deb04 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -707,6 +707,18 @@ declare module Immutable { * // List [ 0, 1, 2, List [ 999, 4 ] ] * ``` * + * Plain JavaScript Object or Arrays may be nested within an Immutable.js + * Collection, and setIn() can update those values as well, treating them + * immutably by creating new copies of those values with the changes applied. + * + * + * ```js + * const { List } = require('immutable@4.0.0-rc.7') + * const list = List([ 0, 1, 2, { plain: 'object' }]) + * list.setIn([3, 'plain'], 'value'); + * // List([ 0, 1, 2, { plain: 'value' }]) + * ``` + * * Note: `setIn` can be used in `withMutations`. */ setIn(keyPath: Iterable, value: any): this; @@ -723,6 +735,18 @@ declare module Immutable { * // List [ 0, 1, 2, List [ 4 ] ] * ``` * + * Plain JavaScript Object or Arrays may be nested within an Immutable.js + * Collection, and removeIn() can update those values as well, treating them + * immutably by creating new copies of those values with the changes applied. + * + * + * ```js + * const { List } = require('immutable@4.0.0-rc.7') + * const list = List([ 0, 1, 2, { plain: 'object' }]) + * list.removeIn([3, 'plain']); + * // List([ 0, 1, 2, {}]) + * ``` + * * Note: `deleteIn` *cannot* be safely used in `withMutations`. * * @alias removeIn @@ -1344,8 +1368,33 @@ declare module Immutable { * // } * ``` * - * If any key in the path exists but does not have a `.set()` method - * (such as Map and List), an error will be throw. + * Plain JavaScript Object or Arrays may be nested within an Immutable.js + * Collection, and setIn() can update those values as well, treating them + * immutably by creating new copies of those values with the changes applied. + * + * + * ```js + * const { Map } = require('immutable@4.0.0-rc.7') + * const originalMap = Map({ + * subObject: { + * subKey: 'subvalue', + * subSubObject: { + * subSubKey: 'subSubValue' + * } + * } + * }) + * + * originalMap.setIn(['subObject', 'subKey'], 'ha ha!') + * // Map { + * // "subObject": { + * // subKey: "ha ha!", + * // subSubObject: { subSubKey: "subSubValue" } + * // } + * // } + * ``` + * + * If any key in the path exists but cannot be updated (such as a primitive + * like number or a custom Object like Date), an error will be thrown. * * Note: `setIn` can be used in `withMutations`. */ @@ -1420,8 +1469,23 @@ declare module Immutable { * // Map { "a": Map { "b": Map { "c": 10, "x": 100 } } } * ``` * - * If any key in the path exists but does not have a .set() method (such as - * Map and List), an error will be thrown. + * Plain JavaScript Object or Arrays may be nested within an Immutable.js + * Collection, and updateIn() can update those values as well, treating them + * immutably by creating new copies of those values with the changes applied. + * + * + * ```js + * const map = Map({ a: { b: { c: 10 } } }) + * const newMap = map.updateIn(['a', 'b', 'c'], val => val * 2) + * // Map { "a": { b: { c: 20 } } } + * ``` + * + * If any key in the path exists but cannot be updated (such as a primitive + * like number or a custom Object like Date), an error will be thrown. + * + * Note: `updateIn` can be used in `withMutations`. */ updateIn(keyPath: Iterable, notSetValue: any, updater: (value: any) => any): this; updateIn(keyPath: Iterable, updater: (value: any) => any): this; @@ -2454,6 +2518,44 @@ declare module Immutable { * export type Point3D = RecordOf; * const some3DPoint: Point3D = makePoint3D({ x: 10, y: 20, z: 30 }); * ``` + * + * + * **Choosing Records vs plain JavaScript objects** + * + * Records ofters a persistently immutable alternative to plain JavaScript + * objects, however they're not required to be used within Immutable.js + * collections. In fact, the deep-access and deep-updating functions + * like `getIn()` and `setIn()` work with plain JavaScript Objects as well. + * + * Deciding to use Records or Objects in your application should be informed + * by the tradeoffs and relative benefits of each: + * + * - *Runtime immutability*: plain JS objects may be carefully treated as + * immutable, however Record instances will *throw* if attempted to be + * mutated directly. Records provide this additional guarantee, however at + * some marginal runtime cost. While JS objects are mutable by nature, the + * use of type-checking tools like [Flow](https://medium.com/@gcanti/immutability-with-flow-faa050a1aef4) + * can help gain confidence in code written to favor immutability. + * + * - *Value equality*: Records use value equality when compared with `is()` + * or `record.equals()`. That is, two Records with the same keys and values + * are equal. Plain objects use *reference equality*. Two objects with the + * same keys and values are not equal since they are different objects. + * This is important to consider when using objects as keys in a `Map` or + * values in a `Set`, which use equality when retrieving values. + * + * - *API methods*: Records have a full featured API, with methods like + * `.getIn()`, and `.equals()`. These can make working with these values + * easier, but comes at the cost of not allowing keys with those names. + * + * - *Default values*: Records provide default values for every key, which + * can be useful when constructing Records with often unchanging values. + * However default values can make using Flow and TypeScript more laborious. + * + * - *Serialization*: Records use a custom internal representation to + * efficiently store and update their values. Converting to and from this + * form isn't free. If converting Records to plain objects is common, + * consider sticking with plain objects to begin with. */ export module Record { @@ -3903,6 +4005,23 @@ declare module Immutable { /** * Returns the value found by following a path of keys or indices through * nested Collections. + * + * + * ```js + * const { Map, List } = require('immutable@4.0.0-rc.7') + * const deepData = Map({ x: List([ Map({ y: 123 }) ]) }); + * getIn(deepData, ['x', 0, 'y']) // 123 + * ``` + * + * Plain JavaScript Object or Arrays may be nested within an Immutable.js + * Collection, and getIn() can access those values as well: + * + * + * ```js + * const { Map, List } = require('immutable@4.0.0-rc.7') + * const deepData = Map({ x: [ { y: 123 } ] }); + * getIn(deepData, ['x', 0, 'y']) // 123 + * ``` */ getIn(searchKeyPath: Iterable, notSetValue?: any): any; @@ -4708,6 +4827,299 @@ declare module Immutable { */ isSuperset(iter: Iterable): boolean; } + + /** + * Returns the value within the provided collection associated with the + * provided key, or notSetValue if the key is not defined in the collection. + * + * A functional alternative to `collection.get(key)` which will also work on + * plain Objects and Arrays as an alternative for `collection[key]`. + * + * + * ```js + * const { get } = require('immutable@4.0.0-rc.7') + * get([ 'dog', 'frog', 'cat' ], 2) // 'frog' + * get({ x: 123, y: 456 }, 'x') // 123 + * get({ x: 123, y: 456 }, 'z', 'ifNotSet') // 'ifNotSet' + * ``` + */ + export function get(collection: Collection, key: K): V | undefined; + export function get(collection: Collection, key: K, notSetValue: NSV): V | NSV; + export function get(record: Record, key: K, notSetValue: any): TProps[K]; + export function get(collection: Array, key: number): V | undefined; + export function get(collection: Array, key: number, notSetValue: NSV): V | NSV; + export function get(object: C, key: K, notSetValue: any): C[K]; + export function get(collection: {[key: string]: V}, key: string): V | undefined; + export function get(collection: {[key: string]: V}, key: string, notSetValue: NSV): V | NSV; + + /** + * Returns true if the key is defined in the provided collection. + * + * A functional alternative to `collection.has(key)` which will also work with + * plain Objects and Arrays as an alternative for + * `collection.hasOwnProperty(key)`. + * + * + * ```js + * const { has } = require('immutable@4.0.0-rc.7') + * has([ 'dog', 'frog', 'cat' ], 2) // true + * has([ 'dog', 'frog', 'cat' ], 5) // false + * has({ x: 123, y: 456 }, 'x') // true + * has({ x: 123, y: 456 }, 'z') // false + * ``` + */ + export function has(collection: Object, key: mixed): boolean; + + /** + * Returns a copy of the collection with the value at key removed. + * + * A functional alternative to `collection.remove(key)` which will also work + * with plain Objects and Arrays as an alternative for + * `delete collectionCopy[key]`. + * + * + * ```js + * const { remove } = require('immutable@4.0.0-rc.7') + * const originalArray = [ 'dog', 'frog', 'cat' ] + * remove(originalArray, 1) // [ 'dog', 'cat' ] + * console.log(originalArray) // [ 'dog', 'frog', 'cat' ] + * const originalObject = { x: 123, y: 456 } + * remove(originalObject, 'x') // { y: 456 } + * console.log(originalObject) // { x: 123, y: 456 } + * ``` + */ + export function remove>(collection: C, key: K): C; + export function remove, K extends keyof TProps>(collection: C, key: K): C; + export function remove>(collection: C, key: number): C; + export function remove(collection: C, key: K): C; + export function remove(collection: C, key: K): C; + + /** + * Returns a copy of the collection with the value at key set to the provided + * value. + * + * A functional alternative to `collection.set(key, value)` which will also + * work with plain Objects and Arrays as an alternative for + * `collectionCopy[key] = value`. + * + * + * ```js + * const { set } = require('immutable@4.0.0-rc.7') + * const originalArray = [ 'dog', 'frog', 'cat' ] + * set(originalArray, 1, 'cow') // [ 'dog', 'cow', 'cat' ] + * console.log(originalArray) // [ 'dog', 'frog', 'cat' ] + * const originalObject = { x: 123, y: 456 } + * set(originalObject, 'x', 789) // { x: 789, y: 456 } + * console.log(originalObject) // { x: 123, y: 456 } + * ``` + */ + export function set>(collection: C, key: K, value: V): C; + export function set, K extends keyof TProps>(record: C, key: K, value: TProps[K]): C; + export function set>(collection: C, key: number, value: V): C; + export function set(object: C, key: K, value: C[K]): C; + export function set(collection: C, key: string, value: V): C; + + /** + * Returns a copy of the collection with the value at key set to the result of + * providing the existing value to the updating function. + * + * A functional alternative to `collection.update(key, fn)` which will also + * work with plain Objects and Arrays as an alternative for + * `collectionCopy[key] = fn(collection[key])`. + * + * + * ```js + * const { update } = require('immutable@4.0.0-rc.7') + * const originalArray = [ 'dog', 'frog', 'cat' ] + * update(originalArray, 1, val => val.toUpperCase()) // [ 'dog', 'FROG', 'cat' ] + * console.log(originalArray) // [ 'dog', 'frog', 'cat' ] + * const originalObject = { x: 123, y: 456 } + * set(originalObject, 'x', val => val * 6) // { x: 738, y: 456 } + * console.log(originalObject) // { x: 123, y: 456 } + * ``` + */ + export function update>(collection: C, key: K, updater: (value: V) => V): C; + export function update, NSV>(collection: C, key: K, notSetValue: NSV, updater: (value: V | NSV) => V): C; + export function update, K extends keyof TProps>(record: C, key: K, updater: (value: TProps[K]) => TProps[K]): C; + export function update, K extends keyof TProps, NSV>(record: C, key: K, notSetValue: NSV, updater: (value: TProps[K] | NSV) => TProps[K]): C; + export function update(collection: Array, key: number, updater: (value: V) => V): Array; + export function update(collection: Array, key: number, notSetValue: NSV, updater: (value: V | NSV) => V): C; + export function update(object: C, key: K, updater: (value: C[K]) => C[K]): C; + export function update(object: C, key: K, notSetValue: NSV, updater: (value: C[K] | NSV) => C[K]): C; + export function update(collection: C, key: K, updater: (value: V) => V): {[key: string]: V}; + export function update(collection: C, key: K, notSetValue: NSV, updater: (value: V | NSV) => V): {[key: string]: V}; + + /** + * Returns the value at the provided key path starting at the provided + * collection, or notSetValue if the key path is not defined. + * + * A functional alternative to `collection.getIn(keypath)` which will also + * work with plain Objects and Arrays. + * + * + * ```js + * const { getIn } = require('immutable@4.0.0-rc.7') + * getIn({ x: { y: { z: 123 }}}, ['x', 'y', 'z']) // 123 + * getIn({ x: { y: { z: 123 }}}, ['x', 'q', 'p'], 'ifNotSet') // 'ifNotSet' + * ``` + */ + export function getIn(collection: any, keyPath: Iterable, notSetValue: any): any; + + /** + * Returns true if the key path is defined in the provided collection. + * + * A functional alternative to `collection.hasIn(keypath)` which will also + * work with plain Objects and Arrays. + * + * + * ```js + * const { hasIn } = require('immutable@4.0.0-rc.7') + * hasIn({ x: { y: { z: 123 }}}, ['x', 'y', 'z']) // true + * hasIn({ x: { y: { z: 123 }}}, ['x', 'q', 'p']) // false + * ``` + */ + export function hasIn(collection: any, keyPath: Iterable): boolean; + + /** + * Returns a copy of the collection with the value at the key path removed. + * + * A functional alternative to `collection.removeIn(keypath)` which will also + * work with plain Objects and Arrays. + * + * + * ```js + * const { removeIn } = require('immutable@4.0.0-rc.7') + * const original = { x: { y: { z: 123 }}} + * removeIn(original, ['x', 'y', 'z']) // { x: { y: {}}} + * console.log(original) // { x: { y: { z: 123 }}} + * ``` + */ + export function removeIn(collection: C, keyPath: Iterable): C; + + /** + * Returns a copy of the collection with the value at the key path set to the + * provided value. + * + * A functional alternative to `collection.setIn(keypath)` which will also + * work with plain Objects and Arrays. + * + * + * ```js + * const { setIn } = require('immutable@4.0.0-rc.7') + * const original = { x: { y: { z: 123 }}} + * setIn(original, ['x', 'y', 'z'], 456) // { x: { y: { z: 456 }}} + * console.log(original) // { x: { y: { z: 123 }}} + * ``` + */ + export function setIn(collection: C, keyPath: Iterable, value: any): C; + + /** + * Returns a copy of the collection with the value at key path set to the + * result of providing the existing value to the updating function. + * + * A functional alternative to `collection.updateIn(keypath)` which will also + * work with plain Objects and Arrays. + * + * + * ```js + * const { setIn } = require('immutable@4.0.0-rc.7') + * const original = { x: { y: { z: 123 }}} + * setIn(original, ['x', 'y', 'z'], val => val * 6) // { x: { y: { z: 738 }}} + * console.log(original) // { x: { y: { z: 123 }}} + * ``` + */ + export function updateIn(collection: C, keyPath: Iterable, updater: (value: any) => any): C; + + + /** + * Returns a copy of the collection with the remaining collections merged in. + * + * A functional alternative to `collection.merge()` which will also work with + * plain Objects and Arrays. + * + * + * ```js + * const { merge } = require('immutable@4.0.0-rc.7') + * const original = { x: 123, y: 456 } + * merge(original, { y: 789, z: 'abc' }) // { x: 123, y: 789, z: 'abc' } + * console.log(original) // { x: { y: { z: 123 }}} + * ``` + */ + export function merge( + collection: C, + ...collections: Array | Iterable<[any, any]> | {[key: string]: any}> + ): C; + + /** + * Returns a copy of the collection with the remaining collections merged in, + * calling the `merger` function whenever an existing value is encountered. + * + * A functional alternative to `collection.mergeWith()` which will also work + * with plain Objects and Arrays. + * + * + * ```js + * const { mergeWith } = require('immutable@4.0.0-rc.7') + * const original = { x: 123, y: 456 } + * mergeWith( + * (oldVal, newVal) => oldVal + newVal, + * original, + * { y: 789, z: 'abc' } + * ) // { x: 123, y: 1245, z: 'abc' } + * console.log(original) // { x: { y: { z: 123 }}} + * ``` + */ + export function mergeWith( + merger: (oldVal: any, newVal: any, key: any) => any, + collection: C, + ...collections: Array | Iterable<[any, any]> | {[key: string]: any}> + ): C; + + /** + * Returns a copy of the collection with the remaining collections merged in + * deeply (recursively). + * + * A functional alternative to `collection.mergeDeep()` which will also work + * with plain Objects and Arrays. + * + * + * ```js + * const { merge } = require('immutable@4.0.0-rc.7') + * const original = { x: { y: 123 }} + * merge(original, { x: { z: 456 }}) // { x: { y: 123, z: 456 }} + * console.log(original) // { x: { y: 123 }} + * ``` + */ + export function mergeDeep( + collection: C, + ...collections: Array | Iterable<[any, any]> | {[key: string]: any}> + ): C; + + /** + * Returns a copy of the collection with the remaining collections merged in + * deeply (recursively), calling the `merger` function whenever an existing + * value is encountered. + * + * A functional alternative to `collection.mergeDeepWith()` which will also + * work with plain Objects and Arrays. + * + * + * ```js + * const { merge } = require('immutable@4.0.0-rc.7') + * const original = { x: { y: 123 }} + * mergeDeepWith( + * (oldVal, newVal) => oldVal + newVal, + * original, + * { x: { y: 456 }} + * ) // { x: { y: 579 }} + * console.log(original) // { x: { y: 123 }} + * ``` + */ + export function mergeDeepWith( + merger: (oldVal: any, newVal: any, key: any) => mixed, + collection: C, + ...collections: Array | Iterable<[any, any]> | {[key: string]: any}> + ): C; } declare module "immutable" { diff --git a/dist/immutable.es.js b/dist/immutable.es.js index fd36b4a817..12f18e840f 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -35,17 +35,6 @@ function SetRef(ref) { // the return of any subsequent call of this function. function OwnerID() {} -// http://jsperf.com/copy-array-inline -function arrCopy(arr, offset) { - offset = offset || 0; - var len = Math.max(0, arr.length - offset); - var newArr = new Array(len); - for (var ii = 0; ii < len; ii++) { - newArr[ii] = arr[ii + offset]; - } - return newArr; -} - function ensureSize(iter) { if (iter.size === undefined) { iter.size = iter.__iterate(returnTrue); @@ -260,6 +249,8 @@ function getIteratorFn(iterable) { } } +var hasOwnProperty = Object.prototype.hasOwnProperty; + function isArrayLike(value) { return value && typeof value.length === 'number'; } @@ -481,7 +472,7 @@ var ObjectSeq = (function (KeyedSeq) { }; ObjectSeq.prototype.has = function has (key) { - return this._object.hasOwnProperty(key); + return hasOwnProperty.call(this._object, key); }; ObjectSeq.prototype.__iterate = function __iterate (fn, reverse) { @@ -766,6 +757,286 @@ function is(valueA, valueB) { ); } +function coerceKeyPath(keyPath) { + if (isArrayLike(keyPath) && typeof keyPath !== 'string') { + return keyPath; + } + if (isOrdered(keyPath)) { + return keyPath.toArray(); + } + throw new TypeError( + 'Invalid keyPath: expected Ordered Collection or Array: ' + keyPath + ); +} + +function isPlainObj(value) { + return ( + value && (value.constructor === Object || value.constructor === undefined) + ); +} + +/** + * Returns true if the value is a potentially-persistent data structure, either + * provided by Immutable.js or a plain Array or Object. + */ +function isDataStructure(value) { + return isImmutable(value) || Array.isArray(value) || isPlainObj(value); +} + +/** + * Converts a value to a string, adding quotes if a string was provided. + */ +function quoteString(value) { + try { + return typeof value === 'string' ? JSON.stringify(value) : String(value); + } catch (_ignoreError) { + return JSON.stringify(value); + } +} + +function has(collection, key) { + return isImmutable(collection) + ? collection.has(key) + : isDataStructure(collection) && hasOwnProperty.call(collection, key); +} + +function get(collection, key, notSetValue) { + return isImmutable(collection) + ? collection.get(key, notSetValue) + : !has(collection, key) + ? notSetValue + : typeof collection.get === 'function' + ? collection.get(key) + : collection[key]; +} + +// http://jsperf.com/copy-array-inline +function arrCopy(arr, offset) { + offset = offset || 0; + var len = Math.max(0, arr.length - offset); + var newArr = new Array(len); + for (var ii = 0; ii < len; ii++) { + newArr[ii] = arr[ii + offset]; + } + return newArr; +} + +function shallowCopy(from) { + if (Array.isArray(from)) { + return arrCopy(from); + } + var to = {}; + for (var key in from) { + if (hasOwnProperty.call(from, key)) { + to[key] = from[key]; + } + } + return to; +} + +function remove(collection, key) { + if (!isDataStructure(collection)) { + throw new TypeError( + 'Cannot update non-data-structure value: ' + collection + ); + } + if (isImmutable(collection)) { + if (!collection.remove) { + throw new TypeError( + 'Cannot update immutable value without .remove() method: ' + collection + ); + } + return collection.remove(key); + } + if (!hasOwnProperty.call(collection, key)) { + return collection; + } + var collectionCopy = shallowCopy(collection); + if (Array.isArray(collectionCopy)) { + collectionCopy.splice(key, 1); + } else { + delete collectionCopy[key]; + } + return collectionCopy; +} + +function set(collection, key, value) { + if (!isDataStructure(collection)) { + throw new TypeError( + 'Cannot update non-data-structure value: ' + collection + ); + } + if (isImmutable(collection)) { + if (!collection.set) { + throw new TypeError( + 'Cannot update immutable value without .set() method: ' + collection + ); + } + return collection.set(key, value); + } + if (hasOwnProperty.call(collection, key) && value === collection[key]) { + return collection; + } + var collectionCopy = shallowCopy(collection); + collectionCopy[key] = value; + return collectionCopy; +} + +function updateIn(collection, keyPath, notSetValue, updater) { + if (!updater) { + updater = notSetValue; + notSetValue = undefined; + } + var updatedValue = updateInDeeply( + isImmutable(collection), + collection, + coerceKeyPath(keyPath), + 0, + notSetValue, + updater + ); + return updatedValue === NOT_SET ? notSetValue : updatedValue; +} + +function updateInDeeply( + inImmutable, + existing, + keyPath, + i, + notSetValue, + updater +) { + var wasNotSet = existing === NOT_SET; + if (i === keyPath.length) { + var existingValue = wasNotSet ? notSetValue : existing; + var newValue = updater(existingValue); + return newValue === existingValue ? existing : newValue; + } + if (!wasNotSet && !isDataStructure(existing)) { + throw new TypeError( + 'Cannot update within non-data-structure value in path [' + + keyPath.slice(0, i).map(quoteString) + + ']: ' + + existing + ); + } + var key = keyPath[i]; + var nextExisting = wasNotSet ? NOT_SET : get(existing, key, NOT_SET); + var nextUpdated = updateInDeeply( + nextExisting === NOT_SET ? inImmutable : isImmutable(nextExisting), + nextExisting, + keyPath, + i + 1, + notSetValue, + updater + ); + return nextUpdated === nextExisting + ? existing + : nextUpdated === NOT_SET + ? remove(existing, key) + : set( + wasNotSet ? (inImmutable ? emptyMap() : {}) : existing, + key, + nextUpdated + ); +} + +function setIn(collection, keyPath, value) { + return updateIn(collection, keyPath, NOT_SET, function () { return value; }); +} + +function update(collection, key, notSetValue, updater) { + return updateIn(collection, [key], notSetValue, updater); +} + +function removeIn(collection, keyPath) { + return updateIn(collection, keyPath, function () { return NOT_SET; }); +} + +function merge(collection) { + var sources = [], len = arguments.length - 1; + while ( len-- > 0 ) sources[ len ] = arguments[ len + 1 ]; + + return mergeWithSources(undefined, collection, sources); +} + +function mergeWith(merger, collection) { + var sources = [], len = arguments.length - 2; + while ( len-- > 0 ) sources[ len ] = arguments[ len + 2 ]; + + return mergeWithSources(merger, collection, sources); +} + +function mergeDeep(collection) { + var sources = [], len = arguments.length - 1; + while ( len-- > 0 ) sources[ len ] = arguments[ len + 1 ]; + + return mergeWithSources(deepMergerWith(alwaysNewValue), collection, sources); +} + +function mergeDeepWith(merger, collection) { + var sources = [], len = arguments.length - 2; + while ( len-- > 0 ) sources[ len ] = arguments[ len + 2 ]; + + return mergeWithSources(deepMergerWith(merger), collection, sources); +} + +function mergeWithSources(merger, collection, sources) { + if (!isDataStructure(collection)) { + throw new TypeError( + 'Cannot merge into non-data-structure value: ' + collection + ); + } + if (isImmutable(collection)) { + return collection.mergeWith + ? collection.mergeWith.apply(collection, [ merger ].concat( sources )) + : collection.concat.apply(collection, sources); + } + var isArray = Array.isArray(collection); + var merged = collection; + var Collection$$1 = isArray ? IndexedCollection : KeyedCollection; + var mergeItem = isArray + ? function (value) { + // Copy on write + if (merged === collection) { + merged = shallowCopy(merged); + } + merged.push(value); + } + : function (value, key) { + var nextVal = + merger && hasOwnProperty.call(merged, key) + ? merger(merged[key], value, key) + : value; + if (!hasOwnProperty.call(merged, key) || nextVal !== merged[key]) { + // Copy on write + if (merged === collection) { + merged = shallowCopy(merged); + } + merged[key] = nextVal; + } + }; + for (var i = 0; i < sources.length; i++) { + Collection$$1(sources[i]).forEach(mergeItem); + } + return merged; +} + +function deepMergerWith(merger) { + function deepMerger(oldValue, newValue, key) { + if (isDataStructure(oldValue) && isDataStructure(newValue)) { + return mergeWithSources(deepMerger, oldValue, [newValue]); + } + var nextValue = merger(oldValue, newValue, key); + return is(oldValue, nextValue) ? oldValue : nextValue; + } + return deepMerger; +} + +function alwaysNewValue(oldValue, newValue) { + return newValue; +} + var imul = typeof Math.imul === 'function' && Math.imul(0xffffffff, 2) === -2 ? Math.imul @@ -1867,18 +2138,6 @@ function defaultComparator(a, b) { return a > b ? 1 : a < b ? -1 : 0; } -function coerceKeyPath(keyPath) { - if (isArrayLike(keyPath) && typeof keyPath !== 'string') { - return keyPath; - } - if (isOrdered(keyPath)) { - return keyPath.toArray(); - } - throw new TypeError( - 'Invalid keyPath: expected Ordered Collection or Array: ' + keyPath - ); -} - function invariant(condition, error) { if (!condition) { throw new Error(error); } } @@ -1890,17 +2149,6 @@ function assertNotInfinite(size) { ); } -/** - * Converts a value to a string, adding quotes if a string was provided. - */ -function quoteString(value) { - try { - return typeof value === 'string' ? JSON.stringify(value) : String(value); - } catch (_ignoreError) { - return JSON.stringify(value); - } -} - var Map = (function (KeyedCollection$$1) { function Map(value) { return value === null || value === undefined @@ -1950,8 +2198,8 @@ var Map = (function (KeyedCollection$$1) { return updateMap(this, k, v); }; - Map.prototype.setIn = function setIn (keyPath, v) { - return this.updateIn(keyPath, NOT_SET, function () { return v; }); + Map.prototype.setIn = function setIn$1 (keyPath, v) { + return setIn(this, keyPath, v); }; Map.prototype.remove = function remove (k) { @@ -1959,11 +2207,7 @@ var Map = (function (KeyedCollection$$1) { }; Map.prototype.deleteIn = function deleteIn (keyPath) { - keyPath = [].concat( coerceKeyPath(keyPath) ); - if (keyPath.length) { - var lastKey = keyPath.pop(); - return this.updateIn(keyPath, function (c) { return c && c.remove(lastKey); }); - } + return removeIn(this, keyPath); }; Map.prototype.deleteAll = function deleteAll (keys) { @@ -1978,25 +2222,14 @@ var Map = (function (KeyedCollection$$1) { }); }; - Map.prototype.update = function update (k, notSetValue, updater) { + Map.prototype.update = function update$1 (key, notSetValue, updater) { return arguments.length === 1 - ? k(this) - : this.updateIn([k], notSetValue, updater); + ? key(this) + : update(this, key, notSetValue, updater); }; - Map.prototype.updateIn = function updateIn (keyPath, notSetValue, updater) { - if (!updater) { - updater = notSetValue; - notSetValue = undefined; - } - var updatedValue = updateInDeepMap( - this, - coerceKeyPath(keyPath), - 0, - notSetValue, - updater - ); - return updatedValue === NOT_SET ? notSetValue : updatedValue; + Map.prototype.updateIn = function updateIn$1 (keyPath, notSetValue, updater) { + return updateIn(this, keyPath, notSetValue, updater); }; Map.prototype.clear = function clear () { @@ -2015,11 +2248,11 @@ var Map = (function (KeyedCollection$$1) { // @pragma Composition - Map.prototype.merge = function merge (/*...iters*/) { + Map.prototype.merge = function merge$$1 (/*...iters*/) { return mergeIntoMapWith(this, undefined, arguments); }; - Map.prototype.mergeWith = function mergeWith (merger) { + Map.prototype.mergeWith = function mergeWith$$1 (merger) { var iters = [], len = arguments.length - 1; while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; @@ -2030,37 +2263,28 @@ var Map = (function (KeyedCollection$$1) { var iters = [], len = arguments.length - 1; while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; - return this.updateIn( - keyPath, - emptyMap(), - function (m) { return typeof m.merge === 'function' - ? m.merge.apply(m, iters) - : iters[iters.length - 1]; } - ); + return updateIn(this, keyPath, emptyMap(), function (m) { return merge.apply(void 0, [ m ].concat( iters )); }); }; - Map.prototype.mergeDeep = function mergeDeep (/*...iters*/) { - return mergeIntoMapWith(this, deepMergerWith(alwaysNewVal), arguments); + Map.prototype.mergeDeep = function mergeDeep$1 () { + var iters = [], len = arguments.length; + while ( len-- ) iters[ len ] = arguments[ len ]; + + return mergeDeep.apply(void 0, [ this ].concat( iters )); }; - Map.prototype.mergeDeepWith = function mergeDeepWith (merger) { + Map.prototype.mergeDeepWith = function mergeDeepWith$1 (merger) { var iters = [], len = arguments.length - 1; while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; - return mergeIntoMapWith(this, deepMergerWith(merger), iters); + return mergeDeepWith.apply(void 0, [ merger, this ].concat( iters )); }; Map.prototype.mergeDeepIn = function mergeDeepIn (keyPath) { var iters = [], len = arguments.length - 1; while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; - return this.updateIn( - keyPath, - emptyMap(), - function (m) { return typeof m.mergeDeep === 'function' - ? m.mergeDeep.apply(m, iters) - : iters[iters.length - 1]; } - ); + return updateIn(this, keyPath, emptyMap(), function (m) { return mergeDeep.apply(void 0, [ m ].concat( iters )); }); }; Map.prototype.sort = function sort (comparator) { @@ -2166,7 +2390,7 @@ ArrayMapNode.prototype.get = function get (shift, keyHash, key, notSetValue) { return notSetValue; }; -ArrayMapNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { +ArrayMapNode.prototype.update = function update$$1 (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { var removed = value === NOT_SET; var entries = this.entries; @@ -2239,7 +2463,7 @@ BitmapIndexedNode.prototype.get = function get (shift, keyHash, key, notSetValue ); }; -BitmapIndexedNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { +BitmapIndexedNode.prototype.update = function update$$1 (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { if (keyHash === undefined) { keyHash = hash(key); } @@ -2291,7 +2515,7 @@ BitmapIndexedNode.prototype.update = function update (ownerID, shift, keyHash, k var newBitmap = exists ? (newNode ? bitmap : bitmap ^ bit) : bitmap | bit; var newNodes = exists ? newNode - ? setIn(nodes, idx, newNode, isEditable) + ? setAt(nodes, idx, newNode, isEditable) : spliceOut(nodes, idx, isEditable) : spliceIn(nodes, idx, newNode, isEditable); @@ -2321,7 +2545,7 @@ HashArrayMapNode.prototype.get = function get (shift, keyHash, key, notSetValue) : notSetValue; }; -HashArrayMapNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { +HashArrayMapNode.prototype.update = function update$$1 (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { if (keyHash === undefined) { keyHash = hash(key); } @@ -2359,7 +2583,7 @@ HashArrayMapNode.prototype.update = function update (ownerID, shift, keyHash, ke } var isEditable = ownerID && ownerID === this.ownerID; - var newNodes = setIn(nodes, idx, newNode, isEditable); + var newNodes = setAt(nodes, idx, newNode, isEditable); if (isEditable) { this.count = newCount; @@ -2386,7 +2610,7 @@ HashCollisionNode.prototype.get = function get (shift, keyHash, key, notSetValue return notSetValue; }; -HashCollisionNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { +HashCollisionNode.prototype.update = function update$$1 (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { if (keyHash === undefined) { keyHash = hash(key); } @@ -2456,7 +2680,7 @@ ValueNode.prototype.get = function get (shift, keyHash, key, notSetValue) { return is(key, this.entry[0]) ? this.entry[1] : notSetValue; }; -ValueNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { +ValueNode.prototype.update = function update$$1 (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { var removed = value === NOT_SET; var keyMatch = is(key, this.entry[0]); if (keyMatch ? value === this.entry[1] : removed) { @@ -2720,35 +2944,14 @@ function expandNodes(ownerID, nodes, bitmap, including, node) { return new HashArrayMapNode(ownerID, count + 1, expandedNodes); } -function mergeIntoMapWith(map, merger, collections) { +function mergeIntoMapWith(collection, merger, collections) { var iters = []; for (var ii = 0; ii < collections.length; ii++) { - iters.push(KeyedCollection(collections[ii])); - } - return mergeIntoCollectionWith(map, merger, iters); -} - -function alwaysNewVal(oldVal, newVal) { - return newVal; -} - -function deepMergerWith(merger) { - return function(oldVal, newVal, key) { - if (oldVal && newVal && typeof newVal === 'object') { - if (oldVal.mergeDeepWith) { - return oldVal.mergeDeepWith(merger, newVal); - } - if (oldVal.merge) { - return oldVal.merge(newVal); - } + var collection$1 = KeyedCollection(collections[ii]); + if (collection$1.size !== 0) { + iters.push(collection$1); } - var nextValue = merger(oldVal, newVal, key); - return is(oldVal, nextValue) ? oldVal : nextValue; - }; -} - -function mergeIntoCollectionWith(collection, merger, iters) { - iters = iters.filter(function (x) { return x.size !== 0; }); + } if (iters.length === 0) { return collection; } @@ -2758,7 +2961,8 @@ function mergeIntoCollectionWith(collection, merger, iters) { return collection.withMutations(function (collection) { var mergeIntoCollection = merger ? function (value, key) { - collection.update( + update( + collection, key, NOT_SET, function (oldVal) { return (oldVal === NOT_SET ? value : merger(oldVal, value, key)); } @@ -2773,37 +2977,6 @@ function mergeIntoCollectionWith(collection, merger, iters) { }); } -function updateInDeepMap(existing, keyPath, i, notSetValue, updater) { - var isNotSet = existing === NOT_SET; - if (i === keyPath.length) { - var existingValue = isNotSet ? notSetValue : existing; - var newValue = updater(existingValue); - return newValue === existingValue ? existing : newValue; - } - if (!(isNotSet || (existing && existing.set))) { - throw new TypeError( - 'Invalid keyPath: Value at [' + - keyPath.slice(0, i).map(quoteString) + - '] does not have a .set() method and cannot be updated: ' + - existing - ); - } - var key = keyPath[i]; - var nextExisting = isNotSet ? NOT_SET : existing.get(key, NOT_SET); - var nextUpdated = updateInDeepMap( - nextExisting, - keyPath, - i + 1, - notSetValue, - updater - ); - return nextUpdated === nextExisting - ? existing - : nextUpdated === NOT_SET - ? existing.remove(key) - : (isNotSet ? emptyMap() : existing).set(key, nextUpdated); -} - function popCount(x) { x -= (x >> 1) & 0x55555555; x = (x & 0x33333333) + ((x >> 2) & 0x33333333); @@ -2813,7 +2986,7 @@ function popCount(x) { return x & 0x7f; } -function setIn(array, idx, val, canEdit) { +function setAt(array, idx, val, canEdit) { var newArray = canEdit ? array : arrCopy(array); newArray[idx] = val; return newArray; @@ -3893,6 +4066,22 @@ function emptyStack() { return EMPTY_STACK || (EMPTY_STACK = makeStack(0)); } +function getIn(collection, searchKeyPath, notSetValue) { + var keyPath = coerceKeyPath(searchKeyPath); + var i = 0; + while (i !== keyPath.length) { + collection = get(collection, keyPath[i++], NOT_SET); + if (collection === NOT_SET) { + return notSetValue; + } + } + return collection; +} + +function hasIn(collection, keyPath) { + return getIn(collection, keyPath, NOT_SET) !== NOT_SET; +} + function deepEqual(a, b) { if (a === b) { return true; @@ -3971,8 +4160,8 @@ function mixin(ctor, methods) { } function toJS(value) { - return isImmutable(value) - ? Collection(value) + return isDataStructure(value) + ? Seq(value) .map(toJS) .toJSON() : value; @@ -4579,13 +4768,6 @@ mixin(Collection, { .map(entryMapper) .toIndexedSeq(); entriesSequence.fromEntrySeq = function () { return collection.toSeq(); }; - - // Entries are plain Array, which do not define toJS, so it must - // manually converts keys and values before conversion. - entriesSequence.toJS = function() { - return this.map(function (entry) { return [toJS(entry[0]), toJS(entry[1])]; }).toJSON(); - }; - return entriesSequence; }, @@ -4648,7 +4830,7 @@ mixin(Collection, { }, getIn: function getIn$1(searchKeyPath, notSetValue) { - return getIn(this, notSetValue, searchKeyPath, true /* report bad path */); + return getIn(this, searchKeyPath, notSetValue); }, groupBy: function groupBy(grouper, context) { @@ -4659,11 +4841,8 @@ mixin(Collection, { return this.get(searchKey, NOT_SET) !== NOT_SET; }, - hasIn: function hasIn(searchKeyPath) { - return ( - getIn(this, NOT_SET, searchKeyPath, false /* report bad path */) !== - NOT_SET - ); + hasIn: function hasIn$1(searchKeyPath) { + return hasIn(this, searchKeyPath); }, isSubset: function isSubset(iter) { @@ -5078,44 +5257,6 @@ function hashMerge(a, b) { return (a ^ (b + 0x9e3779b9 + (a << 6) + (a >> 2))) | 0; // int } -function warn(message) { - /* eslint-disable no-console */ - if (typeof console === 'object' && console.warn) { - console.warn(message); - } else { - throw new Error(message); - } - /* eslint-enable no-console */ -} - -function getIn(value, notSetValue, searchKeyPath, reportBadKeyPath) { - var keyPath = coerceKeyPath(searchKeyPath); - var i = 0; - while (i !== keyPath.length) { - // Intermediate null/undefined value along path - if (value == null) { - return notSetValue; - } - if (!value || !value.get) { - if (reportBadKeyPath) { - warn( - 'Invalid keyPath: Value at [' + - keyPath.slice(0, i).map(quoteString) + - '] does not have a .get() method: ' + - value + - '\nThis warning will throw in a future version' - ); - } - return notSetValue; - } - value = value.get(keyPath[i++], NOT_SET); - if (value === NOT_SET) { - return notSetValue; - } - } - return value; -} - var OrderedSet = (function (Set$$1) { function OrderedSet(value) { return value === null || value === undefined @@ -5529,14 +5670,9 @@ function defaultConverter(k, v) { return isKeyed(v) ? v.toMap() : v.toList(); } -function isPlainObj(value) { - return ( - value && (value.constructor === Object || value.constructor === undefined) - ); -} - var version = "4.0.0-rc.7"; +// Functional read/write API var Immutable = { version: version, @@ -5566,11 +5702,26 @@ var Immutable = { isIndexed: isIndexed, isAssociative: isAssociative, isOrdered: isOrdered, - isValueObject: isValueObject + isValueObject: isValueObject, + + get: get, + getIn: getIn, + has: has, + hasIn: hasIn, + merge: merge, + mergeDeep: mergeDeep, + mergeWith: mergeWith, + mergeDeepWith: mergeDeepWith, + remove: remove, + removeIn: removeIn, + set: set, + setIn: setIn, + update: update, + updateIn: updateIn }; // Note: Iterable is deprecated var Iterable = Collection; -export { version, Collection, Iterable, Seq, Map, OrderedMap, List, Stack, Set, OrderedSet, Record, Range, Repeat, is, fromJS, hash, isImmutable, isCollection, isKeyed, isIndexed, isAssociative, isOrdered, isValueObject }; +export { version, Collection, Iterable, Seq, Map, OrderedMap, List, Stack, Set, OrderedSet, Record, Range, Repeat, is, fromJS, hash, isImmutable, isCollection, isKeyed, isIndexed, isAssociative, isOrdered, isValueObject, get, getIn, has, hasIn, merge, mergeDeep, mergeWith, mergeDeepWith, remove, removeIn, set, setIn, update, updateIn }; export default Immutable; diff --git a/dist/immutable.js b/dist/immutable.js index fb3078feca..f142d27ec6 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -41,17 +41,6 @@ function SetRef(ref) { // the return of any subsequent call of this function. function OwnerID() {} -// http://jsperf.com/copy-array-inline -function arrCopy(arr, offset) { - offset = offset || 0; - var len = Math.max(0, arr.length - offset); - var newArr = new Array(len); - for (var ii = 0; ii < len; ii++) { - newArr[ii] = arr[ii + offset]; - } - return newArr; -} - function ensureSize(iter) { if (iter.size === undefined) { iter.size = iter.__iterate(returnTrue); @@ -266,6 +255,8 @@ function getIteratorFn(iterable) { } } +var hasOwnProperty = Object.prototype.hasOwnProperty; + function isArrayLike(value) { return value && typeof value.length === 'number'; } @@ -487,7 +478,7 @@ var ObjectSeq = (function (KeyedSeq) { }; ObjectSeq.prototype.has = function has (key) { - return this._object.hasOwnProperty(key); + return hasOwnProperty.call(this._object, key); }; ObjectSeq.prototype.__iterate = function __iterate (fn, reverse) { @@ -772,6 +763,286 @@ function is(valueA, valueB) { ); } +function coerceKeyPath(keyPath) { + if (isArrayLike(keyPath) && typeof keyPath !== 'string') { + return keyPath; + } + if (isOrdered(keyPath)) { + return keyPath.toArray(); + } + throw new TypeError( + 'Invalid keyPath: expected Ordered Collection or Array: ' + keyPath + ); +} + +function isPlainObj(value) { + return ( + value && (value.constructor === Object || value.constructor === undefined) + ); +} + +/** + * Returns true if the value is a potentially-persistent data structure, either + * provided by Immutable.js or a plain Array or Object. + */ +function isDataStructure(value) { + return isImmutable(value) || Array.isArray(value) || isPlainObj(value); +} + +/** + * Converts a value to a string, adding quotes if a string was provided. + */ +function quoteString(value) { + try { + return typeof value === 'string' ? JSON.stringify(value) : String(value); + } catch (_ignoreError) { + return JSON.stringify(value); + } +} + +function has(collection, key) { + return isImmutable(collection) + ? collection.has(key) + : isDataStructure(collection) && hasOwnProperty.call(collection, key); +} + +function get(collection, key, notSetValue) { + return isImmutable(collection) + ? collection.get(key, notSetValue) + : !has(collection, key) + ? notSetValue + : typeof collection.get === 'function' + ? collection.get(key) + : collection[key]; +} + +// http://jsperf.com/copy-array-inline +function arrCopy(arr, offset) { + offset = offset || 0; + var len = Math.max(0, arr.length - offset); + var newArr = new Array(len); + for (var ii = 0; ii < len; ii++) { + newArr[ii] = arr[ii + offset]; + } + return newArr; +} + +function shallowCopy(from) { + if (Array.isArray(from)) { + return arrCopy(from); + } + var to = {}; + for (var key in from) { + if (hasOwnProperty.call(from, key)) { + to[key] = from[key]; + } + } + return to; +} + +function remove(collection, key) { + if (!isDataStructure(collection)) { + throw new TypeError( + 'Cannot update non-data-structure value: ' + collection + ); + } + if (isImmutable(collection)) { + if (!collection.remove) { + throw new TypeError( + 'Cannot update immutable value without .remove() method: ' + collection + ); + } + return collection.remove(key); + } + if (!hasOwnProperty.call(collection, key)) { + return collection; + } + var collectionCopy = shallowCopy(collection); + if (Array.isArray(collectionCopy)) { + collectionCopy.splice(key, 1); + } else { + delete collectionCopy[key]; + } + return collectionCopy; +} + +function set(collection, key, value) { + if (!isDataStructure(collection)) { + throw new TypeError( + 'Cannot update non-data-structure value: ' + collection + ); + } + if (isImmutable(collection)) { + if (!collection.set) { + throw new TypeError( + 'Cannot update immutable value without .set() method: ' + collection + ); + } + return collection.set(key, value); + } + if (hasOwnProperty.call(collection, key) && value === collection[key]) { + return collection; + } + var collectionCopy = shallowCopy(collection); + collectionCopy[key] = value; + return collectionCopy; +} + +function updateIn(collection, keyPath, notSetValue, updater) { + if (!updater) { + updater = notSetValue; + notSetValue = undefined; + } + var updatedValue = updateInDeeply( + isImmutable(collection), + collection, + coerceKeyPath(keyPath), + 0, + notSetValue, + updater + ); + return updatedValue === NOT_SET ? notSetValue : updatedValue; +} + +function updateInDeeply( + inImmutable, + existing, + keyPath, + i, + notSetValue, + updater +) { + var wasNotSet = existing === NOT_SET; + if (i === keyPath.length) { + var existingValue = wasNotSet ? notSetValue : existing; + var newValue = updater(existingValue); + return newValue === existingValue ? existing : newValue; + } + if (!wasNotSet && !isDataStructure(existing)) { + throw new TypeError( + 'Cannot update within non-data-structure value in path [' + + keyPath.slice(0, i).map(quoteString) + + ']: ' + + existing + ); + } + var key = keyPath[i]; + var nextExisting = wasNotSet ? NOT_SET : get(existing, key, NOT_SET); + var nextUpdated = updateInDeeply( + nextExisting === NOT_SET ? inImmutable : isImmutable(nextExisting), + nextExisting, + keyPath, + i + 1, + notSetValue, + updater + ); + return nextUpdated === nextExisting + ? existing + : nextUpdated === NOT_SET + ? remove(existing, key) + : set( + wasNotSet ? (inImmutable ? emptyMap() : {}) : existing, + key, + nextUpdated + ); +} + +function setIn(collection, keyPath, value) { + return updateIn(collection, keyPath, NOT_SET, function () { return value; }); +} + +function update(collection, key, notSetValue, updater) { + return updateIn(collection, [key], notSetValue, updater); +} + +function removeIn(collection, keyPath) { + return updateIn(collection, keyPath, function () { return NOT_SET; }); +} + +function merge(collection) { + var sources = [], len = arguments.length - 1; + while ( len-- > 0 ) sources[ len ] = arguments[ len + 1 ]; + + return mergeWithSources(undefined, collection, sources); +} + +function mergeWith(merger, collection) { + var sources = [], len = arguments.length - 2; + while ( len-- > 0 ) sources[ len ] = arguments[ len + 2 ]; + + return mergeWithSources(merger, collection, sources); +} + +function mergeDeep(collection) { + var sources = [], len = arguments.length - 1; + while ( len-- > 0 ) sources[ len ] = arguments[ len + 1 ]; + + return mergeWithSources(deepMergerWith(alwaysNewValue), collection, sources); +} + +function mergeDeepWith(merger, collection) { + var sources = [], len = arguments.length - 2; + while ( len-- > 0 ) sources[ len ] = arguments[ len + 2 ]; + + return mergeWithSources(deepMergerWith(merger), collection, sources); +} + +function mergeWithSources(merger, collection, sources) { + if (!isDataStructure(collection)) { + throw new TypeError( + 'Cannot merge into non-data-structure value: ' + collection + ); + } + if (isImmutable(collection)) { + return collection.mergeWith + ? collection.mergeWith.apply(collection, [ merger ].concat( sources )) + : collection.concat.apply(collection, sources); + } + var isArray = Array.isArray(collection); + var merged = collection; + var Collection$$1 = isArray ? IndexedCollection : KeyedCollection; + var mergeItem = isArray + ? function (value) { + // Copy on write + if (merged === collection) { + merged = shallowCopy(merged); + } + merged.push(value); + } + : function (value, key) { + var nextVal = + merger && hasOwnProperty.call(merged, key) + ? merger(merged[key], value, key) + : value; + if (!hasOwnProperty.call(merged, key) || nextVal !== merged[key]) { + // Copy on write + if (merged === collection) { + merged = shallowCopy(merged); + } + merged[key] = nextVal; + } + }; + for (var i = 0; i < sources.length; i++) { + Collection$$1(sources[i]).forEach(mergeItem); + } + return merged; +} + +function deepMergerWith(merger) { + function deepMerger(oldValue, newValue, key) { + if (isDataStructure(oldValue) && isDataStructure(newValue)) { + return mergeWithSources(deepMerger, oldValue, [newValue]); + } + var nextValue = merger(oldValue, newValue, key); + return is(oldValue, nextValue) ? oldValue : nextValue; + } + return deepMerger; +} + +function alwaysNewValue(oldValue, newValue) { + return newValue; +} + var imul = typeof Math.imul === 'function' && Math.imul(0xffffffff, 2) === -2 ? Math.imul @@ -1873,18 +2144,6 @@ function defaultComparator(a, b) { return a > b ? 1 : a < b ? -1 : 0; } -function coerceKeyPath(keyPath) { - if (isArrayLike(keyPath) && typeof keyPath !== 'string') { - return keyPath; - } - if (isOrdered(keyPath)) { - return keyPath.toArray(); - } - throw new TypeError( - 'Invalid keyPath: expected Ordered Collection or Array: ' + keyPath - ); -} - function invariant(condition, error) { if (!condition) { throw new Error(error); } } @@ -1896,17 +2155,6 @@ function assertNotInfinite(size) { ); } -/** - * Converts a value to a string, adding quotes if a string was provided. - */ -function quoteString(value) { - try { - return typeof value === 'string' ? JSON.stringify(value) : String(value); - } catch (_ignoreError) { - return JSON.stringify(value); - } -} - var Map = (function (KeyedCollection$$1) { function Map(value) { return value === null || value === undefined @@ -1956,8 +2204,8 @@ var Map = (function (KeyedCollection$$1) { return updateMap(this, k, v); }; - Map.prototype.setIn = function setIn (keyPath, v) { - return this.updateIn(keyPath, NOT_SET, function () { return v; }); + Map.prototype.setIn = function setIn$1 (keyPath, v) { + return setIn(this, keyPath, v); }; Map.prototype.remove = function remove (k) { @@ -1965,11 +2213,7 @@ var Map = (function (KeyedCollection$$1) { }; Map.prototype.deleteIn = function deleteIn (keyPath) { - keyPath = [].concat( coerceKeyPath(keyPath) ); - if (keyPath.length) { - var lastKey = keyPath.pop(); - return this.updateIn(keyPath, function (c) { return c && c.remove(lastKey); }); - } + return removeIn(this, keyPath); }; Map.prototype.deleteAll = function deleteAll (keys) { @@ -1984,25 +2228,14 @@ var Map = (function (KeyedCollection$$1) { }); }; - Map.prototype.update = function update (k, notSetValue, updater) { + Map.prototype.update = function update$1 (key, notSetValue, updater) { return arguments.length === 1 - ? k(this) - : this.updateIn([k], notSetValue, updater); + ? key(this) + : update(this, key, notSetValue, updater); }; - Map.prototype.updateIn = function updateIn (keyPath, notSetValue, updater) { - if (!updater) { - updater = notSetValue; - notSetValue = undefined; - } - var updatedValue = updateInDeepMap( - this, - coerceKeyPath(keyPath), - 0, - notSetValue, - updater - ); - return updatedValue === NOT_SET ? notSetValue : updatedValue; + Map.prototype.updateIn = function updateIn$1 (keyPath, notSetValue, updater) { + return updateIn(this, keyPath, notSetValue, updater); }; Map.prototype.clear = function clear () { @@ -2021,11 +2254,11 @@ var Map = (function (KeyedCollection$$1) { // @pragma Composition - Map.prototype.merge = function merge (/*...iters*/) { + Map.prototype.merge = function merge$$1 (/*...iters*/) { return mergeIntoMapWith(this, undefined, arguments); }; - Map.prototype.mergeWith = function mergeWith (merger) { + Map.prototype.mergeWith = function mergeWith$$1 (merger) { var iters = [], len = arguments.length - 1; while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; @@ -2036,37 +2269,28 @@ var Map = (function (KeyedCollection$$1) { var iters = [], len = arguments.length - 1; while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; - return this.updateIn( - keyPath, - emptyMap(), - function (m) { return typeof m.merge === 'function' - ? m.merge.apply(m, iters) - : iters[iters.length - 1]; } - ); + return updateIn(this, keyPath, emptyMap(), function (m) { return merge.apply(void 0, [ m ].concat( iters )); }); }; - Map.prototype.mergeDeep = function mergeDeep (/*...iters*/) { - return mergeIntoMapWith(this, deepMergerWith(alwaysNewVal), arguments); + Map.prototype.mergeDeep = function mergeDeep$1 () { + var iters = [], len = arguments.length; + while ( len-- ) iters[ len ] = arguments[ len ]; + + return mergeDeep.apply(void 0, [ this ].concat( iters )); }; - Map.prototype.mergeDeepWith = function mergeDeepWith (merger) { + Map.prototype.mergeDeepWith = function mergeDeepWith$1 (merger) { var iters = [], len = arguments.length - 1; while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; - return mergeIntoMapWith(this, deepMergerWith(merger), iters); + return mergeDeepWith.apply(void 0, [ merger, this ].concat( iters )); }; Map.prototype.mergeDeepIn = function mergeDeepIn (keyPath) { var iters = [], len = arguments.length - 1; while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; - return this.updateIn( - keyPath, - emptyMap(), - function (m) { return typeof m.mergeDeep === 'function' - ? m.mergeDeep.apply(m, iters) - : iters[iters.length - 1]; } - ); + return updateIn(this, keyPath, emptyMap(), function (m) { return mergeDeep.apply(void 0, [ m ].concat( iters )); }); }; Map.prototype.sort = function sort (comparator) { @@ -2172,7 +2396,7 @@ ArrayMapNode.prototype.get = function get (shift, keyHash, key, notSetValue) { return notSetValue; }; -ArrayMapNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { +ArrayMapNode.prototype.update = function update$$1 (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { var removed = value === NOT_SET; var entries = this.entries; @@ -2245,7 +2469,7 @@ BitmapIndexedNode.prototype.get = function get (shift, keyHash, key, notSetValue ); }; -BitmapIndexedNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { +BitmapIndexedNode.prototype.update = function update$$1 (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { if (keyHash === undefined) { keyHash = hash(key); } @@ -2297,7 +2521,7 @@ BitmapIndexedNode.prototype.update = function update (ownerID, shift, keyHash, k var newBitmap = exists ? (newNode ? bitmap : bitmap ^ bit) : bitmap | bit; var newNodes = exists ? newNode - ? setIn(nodes, idx, newNode, isEditable) + ? setAt(nodes, idx, newNode, isEditable) : spliceOut(nodes, idx, isEditable) : spliceIn(nodes, idx, newNode, isEditable); @@ -2327,7 +2551,7 @@ HashArrayMapNode.prototype.get = function get (shift, keyHash, key, notSetValue) : notSetValue; }; -HashArrayMapNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { +HashArrayMapNode.prototype.update = function update$$1 (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { if (keyHash === undefined) { keyHash = hash(key); } @@ -2365,7 +2589,7 @@ HashArrayMapNode.prototype.update = function update (ownerID, shift, keyHash, ke } var isEditable = ownerID && ownerID === this.ownerID; - var newNodes = setIn(nodes, idx, newNode, isEditable); + var newNodes = setAt(nodes, idx, newNode, isEditable); if (isEditable) { this.count = newCount; @@ -2392,7 +2616,7 @@ HashCollisionNode.prototype.get = function get (shift, keyHash, key, notSetValue return notSetValue; }; -HashCollisionNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { +HashCollisionNode.prototype.update = function update$$1 (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { if (keyHash === undefined) { keyHash = hash(key); } @@ -2462,7 +2686,7 @@ ValueNode.prototype.get = function get (shift, keyHash, key, notSetValue) { return is(key, this.entry[0]) ? this.entry[1] : notSetValue; }; -ValueNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { +ValueNode.prototype.update = function update$$1 (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { var removed = value === NOT_SET; var keyMatch = is(key, this.entry[0]); if (keyMatch ? value === this.entry[1] : removed) { @@ -2726,35 +2950,14 @@ function expandNodes(ownerID, nodes, bitmap, including, node) { return new HashArrayMapNode(ownerID, count + 1, expandedNodes); } -function mergeIntoMapWith(map, merger, collections) { +function mergeIntoMapWith(collection, merger, collections) { var iters = []; for (var ii = 0; ii < collections.length; ii++) { - iters.push(KeyedCollection(collections[ii])); - } - return mergeIntoCollectionWith(map, merger, iters); -} - -function alwaysNewVal(oldVal, newVal) { - return newVal; -} - -function deepMergerWith(merger) { - return function(oldVal, newVal, key) { - if (oldVal && newVal && typeof newVal === 'object') { - if (oldVal.mergeDeepWith) { - return oldVal.mergeDeepWith(merger, newVal); - } - if (oldVal.merge) { - return oldVal.merge(newVal); - } + var collection$1 = KeyedCollection(collections[ii]); + if (collection$1.size !== 0) { + iters.push(collection$1); } - var nextValue = merger(oldVal, newVal, key); - return is(oldVal, nextValue) ? oldVal : nextValue; - }; -} - -function mergeIntoCollectionWith(collection, merger, iters) { - iters = iters.filter(function (x) { return x.size !== 0; }); + } if (iters.length === 0) { return collection; } @@ -2764,7 +2967,8 @@ function mergeIntoCollectionWith(collection, merger, iters) { return collection.withMutations(function (collection) { var mergeIntoCollection = merger ? function (value, key) { - collection.update( + update( + collection, key, NOT_SET, function (oldVal) { return (oldVal === NOT_SET ? value : merger(oldVal, value, key)); } @@ -2779,37 +2983,6 @@ function mergeIntoCollectionWith(collection, merger, iters) { }); } -function updateInDeepMap(existing, keyPath, i, notSetValue, updater) { - var isNotSet = existing === NOT_SET; - if (i === keyPath.length) { - var existingValue = isNotSet ? notSetValue : existing; - var newValue = updater(existingValue); - return newValue === existingValue ? existing : newValue; - } - if (!(isNotSet || (existing && existing.set))) { - throw new TypeError( - 'Invalid keyPath: Value at [' + - keyPath.slice(0, i).map(quoteString) + - '] does not have a .set() method and cannot be updated: ' + - existing - ); - } - var key = keyPath[i]; - var nextExisting = isNotSet ? NOT_SET : existing.get(key, NOT_SET); - var nextUpdated = updateInDeepMap( - nextExisting, - keyPath, - i + 1, - notSetValue, - updater - ); - return nextUpdated === nextExisting - ? existing - : nextUpdated === NOT_SET - ? existing.remove(key) - : (isNotSet ? emptyMap() : existing).set(key, nextUpdated); -} - function popCount(x) { x -= (x >> 1) & 0x55555555; x = (x & 0x33333333) + ((x >> 2) & 0x33333333); @@ -2819,7 +2992,7 @@ function popCount(x) { return x & 0x7f; } -function setIn(array, idx, val, canEdit) { +function setAt(array, idx, val, canEdit) { var newArray = canEdit ? array : arrCopy(array); newArray[idx] = val; return newArray; @@ -3899,6 +4072,22 @@ function emptyStack() { return EMPTY_STACK || (EMPTY_STACK = makeStack(0)); } +function getIn(collection, searchKeyPath, notSetValue) { + var keyPath = coerceKeyPath(searchKeyPath); + var i = 0; + while (i !== keyPath.length) { + collection = get(collection, keyPath[i++], NOT_SET); + if (collection === NOT_SET) { + return notSetValue; + } + } + return collection; +} + +function hasIn(collection, keyPath) { + return getIn(collection, keyPath, NOT_SET) !== NOT_SET; +} + function deepEqual(a, b) { if (a === b) { return true; @@ -3977,8 +4166,8 @@ function mixin(ctor, methods) { } function toJS(value) { - return isImmutable(value) - ? Collection(value) + return isDataStructure(value) + ? Seq(value) .map(toJS) .toJSON() : value; @@ -4585,13 +4774,6 @@ mixin(Collection, { .map(entryMapper) .toIndexedSeq(); entriesSequence.fromEntrySeq = function () { return collection.toSeq(); }; - - // Entries are plain Array, which do not define toJS, so it must - // manually converts keys and values before conversion. - entriesSequence.toJS = function() { - return this.map(function (entry) { return [toJS(entry[0]), toJS(entry[1])]; }).toJSON(); - }; - return entriesSequence; }, @@ -4654,7 +4836,7 @@ mixin(Collection, { }, getIn: function getIn$1(searchKeyPath, notSetValue) { - return getIn(this, notSetValue, searchKeyPath, true /* report bad path */); + return getIn(this, searchKeyPath, notSetValue); }, groupBy: function groupBy(grouper, context) { @@ -4665,11 +4847,8 @@ mixin(Collection, { return this.get(searchKey, NOT_SET) !== NOT_SET; }, - hasIn: function hasIn(searchKeyPath) { - return ( - getIn(this, NOT_SET, searchKeyPath, false /* report bad path */) !== - NOT_SET - ); + hasIn: function hasIn$1(searchKeyPath) { + return hasIn(this, searchKeyPath); }, isSubset: function isSubset(iter) { @@ -5084,44 +5263,6 @@ function hashMerge(a, b) { return (a ^ (b + 0x9e3779b9 + (a << 6) + (a >> 2))) | 0; // int } -function warn(message) { - /* eslint-disable no-console */ - if (typeof console === 'object' && console.warn) { - console.warn(message); - } else { - throw new Error(message); - } - /* eslint-enable no-console */ -} - -function getIn(value, notSetValue, searchKeyPath, reportBadKeyPath) { - var keyPath = coerceKeyPath(searchKeyPath); - var i = 0; - while (i !== keyPath.length) { - // Intermediate null/undefined value along path - if (value == null) { - return notSetValue; - } - if (!value || !value.get) { - if (reportBadKeyPath) { - warn( - 'Invalid keyPath: Value at [' + - keyPath.slice(0, i).map(quoteString) + - '] does not have a .get() method: ' + - value + - '\nThis warning will throw in a future version' - ); - } - return notSetValue; - } - value = value.get(keyPath[i++], NOT_SET); - if (value === NOT_SET) { - return notSetValue; - } - } - return value; -} - var OrderedSet = (function (Set$$1) { function OrderedSet(value) { return value === null || value === undefined @@ -5535,14 +5676,9 @@ function defaultConverter(k, v) { return isKeyed(v) ? v.toMap() : v.toList(); } -function isPlainObj(value) { - return ( - value && (value.constructor === Object || value.constructor === undefined) - ); -} - var version = "4.0.0-rc.7"; +// Functional read/write API var Immutable = { version: version, @@ -5572,7 +5708,22 @@ var Immutable = { isIndexed: isIndexed, isAssociative: isAssociative, isOrdered: isOrdered, - isValueObject: isValueObject + isValueObject: isValueObject, + + get: get, + getIn: getIn, + has: has, + hasIn: hasIn, + merge: merge, + mergeDeep: mergeDeep, + mergeWith: mergeWith, + mergeDeepWith: mergeDeepWith, + remove: remove, + removeIn: removeIn, + set: set, + setIn: setIn, + update: update, + updateIn: updateIn }; // Note: Iterable is deprecated @@ -5602,6 +5753,20 @@ exports.isIndexed = isIndexed; exports.isAssociative = isAssociative; exports.isOrdered = isOrdered; exports.isValueObject = isValueObject; +exports.get = get; +exports.getIn = getIn; +exports.has = has; +exports.hasIn = hasIn; +exports.merge = merge; +exports.mergeDeep = mergeDeep; +exports.mergeWith = mergeWith; +exports.mergeDeepWith = mergeDeepWith; +exports.remove = remove; +exports.removeIn = removeIn; +exports.set = set; +exports.setIn = setIn; +exports.update = update; +exports.updateIn = updateIn; Object.defineProperty(exports, '__esModule', { value: true }); diff --git a/dist/immutable.js.flow b/dist/immutable.js.flow index 0ed51e91b0..49956190f9 100644 --- a/dist/immutable.js.flow +++ b/dist/immutable.js.flow @@ -33,16 +33,18 @@ type PlainObjInput = {[key: K]: V, __proto__: null}; // Helper types to extract the "keys" and "values" use by the *In() methods. -// Exported for experimental use only, may change. -export type $KeyOf = $Call< +type $KeyOf = $Call< & ((?_Collection) => K) - & ((?RecordInstance) => $Keys), + & ((?$ReadOnlyArray) => number) + & ((?RecordInstance | T) => $Keys), C >; -export type $ValOf> = $Call< +type $ValOf> = $Call< & ((?_Collection) => V) - & (>(?RecordInstance, K) => $ElementType), + & ((?$ReadOnlyArray) => T) + & (>(?RecordInstance | T, K) => $ElementType) + & ((?{[any]: V}) => V), C, K >; @@ -1484,6 +1486,70 @@ declare function fromJS( declare function is(first: mixed, second: mixed): boolean; declare function hash(value: mixed): number; +declare function get>(collection: C, key: K, notSetValue: mixed): $ValOf; +declare function get, NSV>(collection: C, key: K, notSetValue: NSV): $ValOf | NSV; + +declare function has(collection: Object, key: mixed): boolean; +declare function remove(collection: C, key: $KeyOf): C; +declare function set, V: $ValOf>(collection: C, key: K, value: V): C; +declare function update, V: $ValOf, NSV>(collection: C, key: K, notSetValue: NSV, updater: ($ValOf | NSV) => V): C; +declare function update, V: $ValOf>(collection: C, key: K, updater: ($ValOf) => V): C; + +declare function getIn(collection: C, keyPath: [], notSetValue?: mixed): C; +declare function getIn, NSV>(collection: C, keyPath: [K], notSetValue: NSV): $ValOf | NSV; +declare function getIn, K2: $KeyOf<$ValOf>, NSV>(collection: C, keyPath: [K, K2], notSetValue: NSV): $ValOf<$ValOf, K2> | NSV; +declare function getIn, K2: $KeyOf<$ValOf>, K3: $KeyOf<$ValOf<$ValOf, K2>>, NSV>(collection: C, keyPath: [K, K2, K3], notSetValue: NSV): $ValOf<$ValOf<$ValOf, K2>, K3> | NSV; +declare function getIn, K2: $KeyOf<$ValOf>, K3: $KeyOf<$ValOf<$ValOf, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>>, NSV>(collection: C, keyPath: [K, K2, K3, K4], notSetValue: NSV): $ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4> | NSV; +declare function getIn, K2: $KeyOf<$ValOf>, K3: $KeyOf<$ValOf<$ValOf, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>>, K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>>, NSV>(collection: C, keyPath: [K, K2, K3, K4, K5], notSetValue: NSV): $ValOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>, K5> | NSV; + +declare function hasIn(collection: Object, keyPath: Iterable): boolean; + +declare function removeIn(collection: C, keyPath: []): void; +declare function removeIn>(collection: C, keyPath: [K]): C; +declare function removeIn, K2: $KeyOf<$ValOf>>(collection: C, keyPath: [K, K2]): C; +declare function removeIn, K2: $KeyOf<$ValOf>, K3: $KeyOf<$ValOf<$ValOf, K2>>>(collection: C, keyPath: [K, K2, K3]): C; +declare function removeIn, K2: $KeyOf<$ValOf>, K3: $KeyOf<$ValOf<$ValOf, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>>>(collection: C, keyPath: [K, K2, K3, K4]): C; +declare function removeIn, K2: $KeyOf<$ValOf>, K3: $KeyOf<$ValOf<$ValOf, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>>, K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>>>(collection: C, keyPath: [K, K2, K3, K4, K5]): C; + +declare function setIn(collection: Object, keyPath: [], value: S): S; +declare function setIn, S: $ValOf>(collection: C, keyPath: [K], value: S): C; +declare function setIn, K2: $KeyOf<$ValOf>, S: $ValOf<$ValOf, K2>>(collection: C, keyPath: [K, K2], value: S): C; +declare function setIn, K2: $KeyOf<$ValOf>, K3: $KeyOf<$ValOf<$ValOf, K2>>, S: $ValOf<$ValOf<$ValOf, K2>, K3>>(collection: C, keyPath: [K, K2, K3], value: S): C; +declare function setIn, K2: $KeyOf<$ValOf>, K3: $KeyOf<$ValOf<$ValOf, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>>, S: $ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>>(collection: C, keyPath: [K, K2, K3, K4], value: S): C; +declare function setIn, K2: $KeyOf<$ValOf>, K3: $KeyOf<$ValOf<$ValOf, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>>, K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>>, S: $ValOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>, K5>>(collection: C, keyPath: [K, K2, K3, K4, K5], value: S): C; + +declare function updateIn(collection: C, keyPath: [], notSetValue: mixed, updater: (value: C) => S): S; +declare function updateIn(collection: C, keyPath: [], updater: (value: C) => S): S; +declare function updateIn, S: $ValOf, NSV>(collection: C, keyPath: [K], notSetValue: NSV, updater: (value: $ValOf | NSV) => S): C; +declare function updateIn, S: $ValOf>(collection: C, keyPath: [K], updater: (value: $ValOf) => S): C; +declare function updateIn, K2: $KeyOf<$ValOf>, S: $ValOf<$ValOf, K2>, NSV>(collection: C, keyPath: [K, K2], notSetValue: NSV, updater: (value: $ValOf<$ValOf, K2> | NSV) => S): C; +declare function updateIn, K2: $KeyOf<$ValOf>, S: $ValOf<$ValOf, K2>>(collection: C, keyPath: [K, K2], updater: (value: $ValOf<$ValOf, K2>) => S): C; +declare function updateIn, K2: $KeyOf<$ValOf>, K3: $KeyOf<$ValOf<$ValOf, K2>>, S: $ValOf<$ValOf<$ValOf, K2>, K3>, NSV>(collection: C, keyPath: [K, K2, K3], notSetValue: NSV, updater: (value: $ValOf<$ValOf<$ValOf, K2>, K3> | NSV) => S): C; +declare function updateIn, K2: $KeyOf<$ValOf>, K3: $KeyOf<$ValOf<$ValOf, K2>>, S: $ValOf<$ValOf<$ValOf, K2>, K3>>(collection: C, keyPath: [K, K2, K3], updater: (value: $ValOf<$ValOf<$ValOf, K2>, K3>) => S): C; +declare function updateIn, K2: $KeyOf<$ValOf>, K3: $KeyOf<$ValOf<$ValOf, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>>, S: $ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>, NSV>(collection: C, keyPath: [K, K2, K3, K4], notSetValue: NSV, updater: (value: $ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4> | NSV) => S): C; +declare function updateIn, K2: $KeyOf<$ValOf>, K3: $KeyOf<$ValOf<$ValOf, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>>, S: $ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>>(collection: C, keyPath: [K, K2, K3, K4], updater: (value: $ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>) => S): C; +declare function updateIn, K2: $KeyOf<$ValOf>, K3: $KeyOf<$ValOf<$ValOf, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>>, K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>>, S: $ValOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>, K5>, NSV>(collection: C, keyPath: [K, K2, K3, K4, K5], notSetValue: NSV, updater: (value: $ValOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>, K5> | NSV) => S): C; +declare function updateIn, K2: $KeyOf<$ValOf>, K3: $KeyOf<$ValOf<$ValOf, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>>, K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>>, S: $ValOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>, K5>>(collection: C, keyPath: [K, K2, K3, K4, K5], updater: (value: $ValOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>, K5>) => S): C; + +declare function merge( + collection: C, + ...collections: Array> | Iterable<[$KeyOf, $ValOf]> | PlainObjInput<$KeyOf, $ValOf>> +): C; +declare function mergeWith( + merger: (oldVal: $ValOf, newVal: $ValOf, key: $KeyOf) => $ValOf, + collection: C, + ...collections: Array> | Iterable<[$KeyOf, $ValOf]> | PlainObjInput<$KeyOf, $ValOf>> +): C; +declare function mergeDeep( + collection: C, + ...collections: Array> | Iterable<[$KeyOf, $ValOf]> | PlainObjInput<$KeyOf, $ValOf>> +): C; +declare function mergeDeepWith( + merger: (oldVal: any, newVal: any, key: any) => mixed, + collection: C, + ...collections: Array> | Iterable<[$KeyOf, $ValOf]> | PlainObjInput<$KeyOf, $ValOf>> +): C; + export { Collection, Seq, @@ -1510,6 +1576,21 @@ export { isOrdered, isRecord, isValueObject, + + get, + has, + remove, + set, + update, + getIn, + hasIn, + removeIn, + setIn, + updateIn, + merge, + mergeWith, + mergeDeep, + mergeDeepWith, } export default { @@ -1538,6 +1619,21 @@ export default { isOrdered, isRecord, isValueObject, + + get, + has, + remove, + set, + update, + getIn, + hasIn, + removeIn, + setIn, + updateIn, + merge, + mergeWith, + mergeDeep, + mergeDeepWith, } export type { @@ -1550,4 +1646,7 @@ export type { RecordFactory, RecordOf, ValueObject, + + $KeyOf, + $ValOf, } diff --git a/dist/immutable.min.js b/dist/immutable.min.js index d91ec06c39..e9e5d84493 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -4,34 +4,35 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.Immutable={})}(this,function(t){"use strict";function e(t){return t.value=!1,t}function r(t){t&&(t.value=!0)}function n(){}function i(t,e){e=e||0;for(var r=Math.max(0,t.length-e),n=Array(r),i=0;i>>0;if(""+r!==e||4294967295===r)return NaN;e=r}return e<0?o(t)+e:e}function s(){return!0}function a(t,e,r){return(0===t&&!p(t)||void 0!==r&&t<=-r)&&(void 0===e||void 0!==r&&e>=r)}function c(t,e){return f(t,e,0)}function h(t,e){return f(t,e,e)}function f(t,e,r){return void 0===t?r:p(t)?e===1/0?e:0|Math.max(0,e+t):void 0===e||e===t?t:0|Math.min(e,t)}function p(t){return t<0||0===t&&1/t==-(1/0)}function _(t){return l(t)||m(t)}function l(t){return!(!t||!t[Re])}function v(t){return!(!t||!t[Ue])}function y(t){return!(!t||!t[Ke])}function d(t){return v(t)||y(t)}function g(t){return!(!t||!t[Le])}function m(t){return!(!t||!t[Te])}function w(t){return!(!t||"function"!=typeof t.equals||"function"!=typeof t.hashCode)}function z(t,e,r,n){var i=0===t?e:1===t?r:[e,r];return n?n.value=i:n={value:i,done:!1},n}function I(){return{value:void 0,done:!0}}function S(t){return!!M(t)}function b(t){return t&&"function"==typeof t.next}function O(t){var e=M(t);return e&&e.call(t)}function M(t){var e=t&&(He&&t[He]||t[Ye]);if("function"==typeof e)return e}function q(t){return t&&"number"==typeof t.length}function E(t){return!(!t||!t[tr])}function D(){return nr||(nr=new er([]))}function x(t){var e=Array.isArray(t)?new er(t):b(t)?new ur(t):S(t)?new or(t):void 0;if(e)return e.fromEntrySeq();if("object"==typeof t)return new rr(t);throw new TypeError("Expected Array or collection object of [k, v] entries, or keyed object: "+t)}function j(t){var e=A(t);if(e)return e;throw new TypeError("Expected Array or collection object of values: "+t)}function k(t){var e=A(t) -;if(e)return e;if("object"==typeof t)return new rr(t);throw new TypeError("Expected Array or collection object of values, or keyed object: "+t)}function A(t){return q(t)?new er(t):b(t)?new ur(t):S(t)?new or(t):void 0}function R(t,e){if(t===e||t!==t&&e!==e)return!0;if(!t||!e)return!1;if("function"==typeof t.valueOf&&"function"==typeof e.valueOf){if(t=t.valueOf(),e=e.valueOf(),t===e||t!==t&&e!==e)return!0;if(!t||!e)return!1}return!!(w(t)&&w(e)&&t.equals(e))}function U(t){return t>>>1&1073741824|3221225471&t}function K(t){if(t===!1||null===t||void 0===t)return 0;if("function"==typeof t.valueOf&&((t=t.valueOf())===!1||null===t||void 0===t))return 0;if(t===!0)return 1;var e=typeof t;if("number"===e){if(t!==t||t===1/0)return 0;var r=0|t;for(r!==t&&(r^=4294967295*t);t>4294967295;)t/=4294967295,r^=t;return U(r)}if("string"===e)return t.length>_r?L(t):T(t);if("function"==typeof t.hashCode)return U(t.hashCode());if("object"===e)return C(t);if("function"==typeof t.toString)return T(""+t);throw Error("Value type "+e+" cannot be hashed.")}function L(t){var e=yr[t];return void 0===e&&(e=T(t),vr===lr&&(vr=0,yr={}),vr++,yr[t]=e),e}function T(t){for(var e=0,r=0;r0)switch(t.nodeType){case 1:return t.uniqueID;case 9:return t.documentElement&&t.documentElement.uniqueID}}function W(t){var e=st(t);return e._iter=t,e.size=t.size,e.flip=function(){return t},e.reverse=function(){var e=t.reverse.apply(this);return e.flip=function(){return t.reverse()},e},e.has=function(e){return t.includes(e)},e.includes=function(e){return t.has(e)},e.cacheResult=at,e.__iterateUncached=function(e,r){var n=this;return t.__iterate(function(t,r){return e(r,t,n)!==!1},r)},e.__iteratorUncached=function(e,r){if(e===Ve){var n=t.__iterator(e,r);return new Xe(function(){var t=n.next();if(!t.done){var e=t.value[0];t.value[0]=t.value[1],t.value[1]=e}return t})}return t.__iterator(e===Je?Pe:Je,r)},e}function N(t,e,r){var n=st(t);return n.size=t.size,n.has=function(e){return t.has(e)},n.get=function(n,i){var o=t.get(n,je);return o===je?i:e.call(r,o,n,t)},n.__iterateUncached=function(n,i){var o=this;return t.__iterate(function(t,i,u){return n(e.call(r,t,i,u),i,o)!==!1},i)},n.__iteratorUncached=function(n,i){var o=t.__iterator(Ve,i);return new Xe(function(){var i=o.next();if(i.done)return i;var u=i.value,s=u[0];return z(n,s,e.call(r,u[1],s,t),i)})},n}function P(t,e){var r=this,n=st(t);return n._iter=t,n.size=t.size,n.reverse=function(){return t},t.flip&&(n.flip=function(){var e=W(t);return e.reverse=function(){return t.flip()},e}),n.get=function(r,n){return t.get(e?r:-1-r,n)},n.has=function(r){return t.has(e?r:-1-r)},n.includes=function(e){return t.includes(e)},n.cacheResult=at,n.__iterate=function(r,n){var i=this,u=0;return n&&o(t),t.__iterate(function(t,o){return r(t,e?o:n?i.size-++u:u++,i)},!n)},n.__iterator=function(n,i){var u=0;i&&o(t);var s=t.__iterator(Ve,!i);return new Xe(function(){var t=s.next();if(t.done)return t;var o=t.value;return z(n,e?o[0]:i?r.size-++u:u++,o[1],t)})},n}function J(t,e,r,n){var i=st(t);return n&&(i.has=function(n){var i=t.get(n,je);return i!==je&&!!e.call(r,i,n,t)},i.get=function(n,i){var o=t.get(n,je);return o!==je&&e.call(r,o,n,t)?o:i}), -i.__iterateUncached=function(i,o){var u=this,s=0;return t.__iterate(function(t,o,a){if(e.call(r,t,o,a))return s++,i(t,n?o:s-1,u)},o),s},i.__iteratorUncached=function(i,o){var u=t.__iterator(Ve,o),s=0;return new Xe(function(){for(;;){var o=u.next();if(o.done)return o;var a=o.value,c=a[0],h=a[1];if(e.call(r,h,c,t))return z(i,n?c:s++,h,o)}})},i}function V(t,e,r){var n=zr().asMutable();return t.__iterate(function(i,o){n.update(e.call(r,i,o,t),0,function(t){return t+1})}),n.asImmutable()}function H(t,e,r){var n=v(t),i=(g(t)?Br():zr()).asMutable();t.__iterate(function(o,u){i.update(e.call(r,o,u,t),function(t){return t=t||[],t.push(n?[u,o]:o),t})});var o=ut(t);return i.map(function(e){return it(t,o(e))})}function Y(t,e,r,n){var i=t.size;if(a(e,r,i))return t;var o=c(e,i),s=h(r,i);if(o!==o||s!==s)return Y(t.toSeq().cacheResult(),e,r,n);var f,p=s-o;p===p&&(f=p<0?0:p);var _=st(t);return _.size=0===f?f:t.size&&f||void 0,!n&&E(t)&&f>=0&&(_.get=function(e,r){return e=u(this,e),e>=0&&ef)return I();var t=i.next();return n||e===Je||t.done?t:e===Pe?z(e,s-1,void 0,t):z(e,s-1,t.value[1],t)})},_}function Q(t,e,r){var n=st(t);return n.__iterateUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterate(n,i);var u=0;return t.__iterate(function(t,i,s){return e.call(r,t,i,s)&&++u&&n(t,i,o)}),u},n.__iteratorUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterator(n,i);var u=t.__iterator(Ve,i),s=!0;return new Xe(function(){if(!s)return I();var t=u.next();if(t.done)return t;var i=t.value,a=i[0],c=i[1];return e.call(r,c,a,o)?n===Ve?t:z(n,a,c,t):(s=!1,I())})},n} -function X(t,e,r,n){var i=st(t);return i.__iterateUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterate(i,o);var s=!0,a=0;return t.__iterate(function(t,o,c){if(!s||!(s=e.call(r,t,o,c)))return a++,i(t,n?o:a-1,u)}),a},i.__iteratorUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterator(i,o);var s=t.__iterator(Ve,o),a=!0,c=0;return new Xe(function(){var t,o,h;do{if(t=s.next(),t.done)return n||i===Je?t:i===Pe?z(i,c++,void 0,t):z(i,c++,t.value[1],t);var f=t.value;o=f[0],h=f[1],a&&(a=e.call(r,h,o,u))}while(a);return i===Ve?t:z(i,o,h,t)})},i}function F(t,e){var r=v(t),n=[t].concat(e).map(function(t){return l(t)?r&&(t=Be(t)):t=r?x(t):j(Array.isArray(t)?t:[t]),t}).filter(function(t){return 0!==t.size});if(0===n.length)return t;if(1===n.length){var i=n[0];if(i===t||r&&v(i)||y(t)&&y(i))return i}var o=new er(n);return r?o=o.toKeyedSeq():y(t)||(o=o.toSetSeq()),o=o.flatten(!0),o.size=n.reduce(function(t,e){if(void 0!==t){var r=e.size;if(void 0!==r)return t+r}},0),o}function G(t,e,r){var n=st(t);return n.__iterateUncached=function(i,o){function u(t,c){t.__iterate(function(t,o){return(!e||c0}function nt(t,e,r,n){var i=st(t),o=new er(r).map(function(t){return t.size});return i.size=n?o.max():o.min(),i.__iterate=function(t,e){for(var r,n=this,i=this.__iterator(Je,e),o=0;!(r=i.next()).done&&t(r.value,o++,n)!==!1;);return o},i.__iteratorUncached=function(t,i){var o=r.map(function(t){return t=Ce(t),O(i?t.reverse():t)}),u=0,s=!1;return new Xe(function(){var r;return s||(r=o.map(function(t){return t.next()}),s=n?r.every(function(t){return t.done}):r.some(function(t){return t.done})),s?I():z(t,u++,e.apply(null,r.map(function(t){return t.value})))})},i}function it(t,e){return t===e?t:E(t)?e:t.constructor(e)}function ot(t){if(t!==Object(t))throw new TypeError("Expected [K, V] tuple: "+t)}function ut(t){return v(t)?Be:y(t)?We:Ne}function st(t){return Object.create((v(t)?Ge:y(t)?Ze:$e).prototype)}function at(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size,this):Fe.prototype.cacheResult.call(this)}function ct(t,e){return void 0===t&&void 0===e?0:void 0===t?1:void 0===e?-1:t>e?1:t>>r)&xe,s=(0===r?n:n>>>r)&xe;return new Or(e,1<>>=1)u[s]=1&r?e[o++]:void 0;return u[n]=i,new Mr(t,o+1,u)}function Mt(t,e,r){for(var n=[],i=0;i>1&1431655765,t=(858993459&t)+(t>>2&858993459),t=t+(t>>4)&252645135,t+=t>>8,127&(t+=t>>16)}function kt(t,e,r,n){var o=n?t:i(t);return o[e]=r,o}function At(t,e,r,n){var i=t.length+1;if(n&&e+1===i)return t[e]=r,t;for(var o=Array(i),u=0,s=0;so?0:o-r,c=u-r;return c>De&&(c=De),function(){if(i===c)return Cr;var t=e?--c:i++;return n&&n[t]}}function i(t,n,i){var s,a=t&&t.array,c=i>o?0:o-i>>n,h=1+(u-i>>n);return h>De&&(h=De),function(){for(;;){if(s){var t=s();if(t!==Cr)return t;s=null}if(c===h)return Cr;var o=e?--h:c++;s=r(a&&a[o],n-Ee,i+(o<=t.size||r<0)return t.withMutations(function(t){r<0?Pt(t,r).set(0,n):Pt(t,0,r+1).set(r,n)});r+=t._origin;var i=t._tail,o=t._root,s=e(Ae);return r>=Jt(t._capacity)?i=Bt(i,t.__ownerID,0,r,n,s):o=Bt(o,t.__ownerID,t._level,r,n,s),s.value?t.__ownerID?(t._root=o,t._tail=i,t.__hash=void 0,t.__altered=!0,t):Lt(t._origin,t._capacity,t._level,o,i):t}function Bt(t,e,n,i,o,u){var s=i>>>n&xe,a=t&&s0){var h=t&&t.array[s],f=Bt(h,e,n-Ee,i,o,u);return f===h?t:(c=Wt(t,e),c.array[s]=f,c)} -return a&&t.array[s]===o?t:(r(u),c=Wt(t,e),void 0===o&&s===c.array.length-1?c.array.pop():c.array[s]=o,c)}function Wt(t,e){return e&&t&&e===t.ownerID?t:new Lr(t?t.array.slice():[],e)}function Nt(t,e){if(e>=Jt(t._capacity))return t._tail;if(e<1<0;)r=r.array[e>>>n&xe],n-=Ee;return r}}function Pt(t,e,r){void 0!==e&&(e|=0),void 0!==r&&(r|=0);var i=t.__ownerID||new n,o=t._origin,u=t._capacity,s=o+e,a=void 0===r?u:r<0?u+r:o+r;if(s===o&&a===u)return t;if(s>=a)return t.clear();for(var c=t._level,h=t._root,f=0;s+f<0;)h=new Lr(h&&h.array.length?[void 0,h]:[],i),c+=Ee,f+=1<=1<p?new Lr([],i):l;if(l&&_>p&&sEe;d-=Ee){var g=p>>>d&xe;y=y.array[g]=Wt(y.array[g],i)}y.array[p>>>Ee&xe]=l}if(a=_)s-=_,a-=_,c=Ee,h=null,v=v&&v.removeBefore(i,0,s);else if(s>o||_>>c&xe;if(m!==_>>>c&xe)break;m&&(f+=(1<o&&(h=h.removeBefore(i,c,s-f)),h&&_>>Ee<=De&&u.size>=2*o.size?(i=u.filter(function(t,e){return void 0!==t&&s!==e}),n=i.toKeyedSeq().map(function(t){return t[0]}).flip().toMap(),t.__ownerID&&(n.__ownerID=i.__ownerID=t.__ownerID)):(n=o.remove(e),i=s===u.size-1?u.pop():u.set(s,void 0))}else if(a){if(r===u.get(s)[1])return t;n=o,i=u.set(s,[e,r])}else n=o.set(e,u.size),i=u.set(u.size,[e,r]) -;return t.__ownerID?(t.size=n.size,t._map=n,t._list=i,t.__hash=void 0,t):Ht(n,i)}function Xt(t){return!(!t||!t[Pr])}function Ft(t,e,r,n){var i=Object.create(Jr);return i.size=t,i._head=e,i.__ownerID=r,i.__hash=n,i.__altered=!1,i}function Gt(){return Vr||(Vr=Ft(0))}function Zt(t,e){if(t===e)return!0;if(!l(e)||void 0!==t.size&&void 0!==e.size&&t.size!==e.size||void 0!==t.__hash&&void 0!==e.__hash&&t.__hash!==e.__hash||v(t)!==v(e)||y(t)!==y(e)||g(t)!==g(e))return!1;if(0===t.size&&0===e.size)return!0;var r=!d(t);if(g(t)){var n=t.entries();return e.every(function(t,e){var i=n.next().value;return i&&R(i[1],t)&&(r||R(i[0],e))})&&n.next().done}var i=!1;if(void 0===t.size)if(void 0===e.size)"function"==typeof t.cacheResult&&t.cacheResult();else{i=!0;var o=t;t=e,e=o}var u=!0,s=e.__iterate(function(e,n){if(r?!t.has(e):i?!R(e,t.get(n,je)):!R(t.get(n,je),e))return u=!1,!1});return u&&t.size===s}function $t(t,e){var r=function(r){t.prototype[r]=e[r]};return Object.keys(e).forEach(r),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(e).forEach(r),t}function te(t){return _(t)?Ce(t).map(te).toJSON():t}function ee(t){return!(!t||!t[Yr])}function re(t,e){return t.__ownerID?(t.size=e.size,t._map=e,t):e===t._map?t:0===e.size?t.__empty():t.__make(e)}function ne(t,e){var r=Object.create(Qr);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function ie(){return Xr||(Xr=ne(gt()))}function oe(t,e,r,n,i,o){return pt(t.size),t.__iterate(function(t,o,u){i?(i=!1,r=t):r=e.call(n,r,t,o,u)},o),r}function ue(t,e){return e}function se(t,e){return[e,t]}function ae(t){return function(){return!t.apply(this,arguments)}}function ce(t){return function(){return-t.apply(this,arguments)}}function he(){return i(arguments)}function fe(t,e){return te?-1:0}function pe(t){if(t.size===1/0)return 0;var e=g(t),r=v(t),n=e?1:0;return _e(t.__iterate(r?e?function(t,e){n=31*n+le(K(t),K(e))|0}:function(t,e){n=n+le(K(t),K(e))|0}:e?function(t){n=31*n+K(t)|0}:function(t){n=n+K(t)|0}),n)}function _e(t,e){return e=sr(e,3432918353), -e=sr(e<<15|e>>>-15,461845907),e=sr(e<<13|e>>>-13,5),e=(e+3864292196|0)^t,e=sr(e^e>>>16,2246822507),e=sr(e^e>>>13,3266489909),e=U(e^e>>>16)}function le(t,e){return t^e+2654435769+(t<<6)+(t>>2)|0}function ve(t){if("object"!=typeof console||!console.warn)throw Error(t);console.warn(t)}function ye(t,e,r,n){for(var i=ht(r),o=0;o!==i.length;){if(null==t)return e;if(!t||!t.get)return n&&ve("Invalid keyPath: Value at ["+i.slice(0,o).map(_t)+"] does not have a .get() method: "+t+"\nThis warning will throw in a future version"),e;if((t=t.get(i[o++],je))===je)return e}return t}function de(t){return ee(t)&&g(t)}function ge(t,e){var r=Object.create(rn);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function me(){return nn||(nn=ge(Yt()))}function we(t,e,r){var n=Object.create(Object.getPrototypeOf(t));return n._values=e,n.__ownerID=r,n}function ze(t){return t._name||t.constructor.name||"Record"}function Ie(t){return x(t._keys.map(function(e){return[e,t.get(e)]}))}function Se(t,e){try{Object.defineProperty(t,e,{get:function(){return this.get(e)},set:function(t){ft(this.__ownerID,"Cannot set on an immutable record."),this.set(e,t)}})}catch(t){}}function be(t,e){return Oe([],e||Me,t,"",e&&e.length>2?[]:void 0,{"":t})}function Oe(t,e,r,n,i,o){var u=Array.isArray(r)?Ze:qe(r)?Ge:null;if(u){if(~t.indexOf(r))throw new TypeError("Cannot convert circular structure to Immutable");t.push(r),i&&""!==n&&i.push(n);var s=e.call(o,n,u(r).map(function(n,o){return Oe(t,e,n,o,i,r)}),i&&i.slice());return t.pop(),i&&i.pop(),s}return r}function Me(t,e){return v(e)?e.toMap():e.toList()}function qe(t){return t&&(t.constructor===Object||void 0===t.constructor)}var Ee=5,De=1<=n.length){var e=r.next();if(e.done)return e;n[i]=e.value}return z(t,i,n[i++])})},e}(Ze),sr="function"==typeof Math.imul&&Math.imul(4294967295,2)===-2?Math.imul:function(t,e){t|=0,e|=0;var r=65535&t,n=65535&e;return r*n+((t>>>16)*n+r*(e>>>16)<<16>>>0)|0},ar=Object.isExtensible,cr=function(){try{return Object.defineProperty({},"@",{}),!0}catch(t){return!1}}(),hr="function"==typeof WeakMap;hr&&(ir=new WeakMap);var fr=0,pr="__immutablehash__";"function"==typeof Symbol&&(pr=Symbol(pr));var _r=16,lr=255,vr=0,yr={},dr=function(t){function e(t,e){this._iter=t,this._useKeys=e,this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t,e){return this._iter.get(t,e)},e.prototype.has=function(t){return this._iter.has(t)},e.prototype.valueSeq=function(){return this._iter.valueSeq()},e.prototype.reverse=function(){var t=this,e=P(this,!0);return this._useKeys||(e.valueSeq=function(){return t._iter.toSeq().reverse()}),e},e.prototype.map=function(t,e){var r=this,n=N(this,t,e);return this._useKeys||(n.valueSeq=function(){ -return r._iter.toSeq().map(t,e)}),n},e.prototype.__iterate=function(t,e){var r=this;return this._iter.__iterate(function(e,n){return t(e,n,r)},e)},e.prototype.__iterator=function(t,e){return this._iter.__iterator(t,e)},e}(Ge);dr.prototype[Le]=!0;var gr=function(t){function e(t){this._iter=t,this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.includes=function(t){return this._iter.includes(t)},e.prototype.__iterate=function(t,e){var r=this,n=0;return e&&o(this),this._iter.__iterate(function(i){return t(i,e?r.size-++n:n++,r)},e)},e.prototype.__iterator=function(t,e){var r=this,n=this._iter.__iterator(Je,e),i=0;return e&&o(this),new Xe(function(){var o=n.next();return o.done?o:z(t,e?r.size-++i:i++,o.value,o)})},e}(Ze),mr=function(t){function e(t){this._iter=t,this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.has=function(t){return this._iter.includes(t)},e.prototype.__iterate=function(t,e){var r=this;return this._iter.__iterate(function(e){return t(e,e,r)},e)},e.prototype.__iterator=function(t,e){var r=this._iter.__iterator(Je,e);return new Xe(function(){var e=r.next();return e.done?e:z(t,e.value,e.value,e)})},e}($e),wr=function(t){function e(t){this._iter=t,this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.entrySeq=function(){return this._iter.toSeq()},e.prototype.__iterate=function(t,e){var r=this;return this._iter.__iterate(function(e){if(e){ot(e);var n=l(e);return t(n?e.get(1):e[1],n?e.get(0):e[0],r)}},e)},e.prototype.__iterator=function(t,e){var r=this._iter.__iterator(Je,e);return new Xe(function(){for(;;){var e=r.next();if(e.done)return e;var n=e.value;if(n){ot(n);var i=l(n);return z(t,i?n.get(0):n[0],i?n.get(1):n[1],e)}}})},e}(Ge);gr.prototype.cacheResult=dr.prototype.cacheResult=mr.prototype.cacheResult=wr.prototype.cacheResult=at;var zr=function(t){function e(e){ -return null===e||void 0===e?gt():lt(e)&&!g(e)?e:gt().withMutations(function(r){var n=t(e);pt(n.size),n.forEach(function(t,e){return r.set(e,t)})})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return gt().withMutations(function(e){for(var r=0;r=t.length)throw Error("Missing value for key: "+t[r]);e.set(t[r],t[r+1])}})},e.prototype.toString=function(){return this.__toString("Map {","}")},e.prototype.get=function(t,e){return this._root?this._root.get(0,void 0,t,e):e},e.prototype.set=function(t,e){return mt(this,t,e)},e.prototype.setIn=function(t,e){return this.updateIn(t,je,function(){return e})},e.prototype.remove=function(t){return mt(this,t,je)},e.prototype.deleteIn=function(t){if(t=[].concat(ht(t)),t.length){var e=t.pop();return this.updateIn(t,function(t){return t&&t.remove(e)})}},e.prototype.deleteAll=function(t){var e=Ce(t);return 0===e.size?this:this.withMutations(function(t){e.forEach(function(e){return t.remove(e)})})},e.prototype.update=function(t,e,r){return 1===arguments.length?t(this):this.updateIn([t],e,r)},e.prototype.updateIn=function(t,e,r){r||(r=e,e=void 0);var n=xt(this,ht(t),0,e,r);return n===je?e:n},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):gt()},e.prototype.merge=function(){return Mt(this,void 0,arguments)},e.prototype.mergeWith=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Mt(this,t,e)},e.prototype.mergeIn=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return this.updateIn(t,gt(),function(t){return"function"==typeof t.merge?t.merge.apply(t,e):e[e.length-1]})},e.prototype.mergeDeep=function(){return Mt(this,Et(qt),arguments)},e.prototype.mergeDeepWith=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Mt(this,Et(t),e)},e.prototype.mergeDeepIn=function(t){ -for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return this.updateIn(t,gt(),function(t){return"function"==typeof t.mergeDeep?t.mergeDeep.apply(t,e):e[e.length-1]})},e.prototype.sort=function(t){return Br(tt(this,t))},e.prototype.sortBy=function(t,e){return Br(tt(this,e,t))},e.prototype.withMutations=function(t){var e=this.asMutable();return t(e),e.wasAltered()?e.__ensureOwner(this.__ownerID):this},e.prototype.asMutable=function(){return this.__ownerID?this:this.__ensureOwner(new n)},e.prototype.asImmutable=function(){return this.__ensureOwner()},e.prototype.wasAltered=function(){return this.__altered},e.prototype.__iterator=function(t,e){return new xr(this,t,e)},e.prototype.__iterate=function(t,e){var r=this,n=0;return this._root&&this._root.iterate(function(e){return n++,t(e[1],e[0],r)},e),n},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?dt(this.size,this._root,t,this.__hash):0===this.size?gt():(this.__ownerID=t,this.__altered=!1,this)},e}(Be);zr.isMap=lt;var Ir="@@__IMMUTABLE_MAP__@@",Sr=zr.prototype;Sr[Ir]=!0,Sr.delete=Sr.remove,Sr.removeIn=Sr.deleteIn,Sr.removeAll=Sr.deleteAll,Sr.concat=Sr.merge,Sr["@@transducer/init"]=Sr.asMutable,Sr["@@transducer/step"]=function(t,e){return t.set(e[0],e[1])},Sr["@@transducer/result"]=function(t){return t.asImmutable()};var br=function(t,e){this.ownerID=t,this.entries=e};br.prototype.get=function(t,e,r,n){for(var i=this.entries,o=0,u=i.length;o=jr)return St(t,h,o,u);var l=t&&t===this.ownerID,v=l?h:i(h);return _?c?f===p-1?v.pop():v[f]=v.pop():v[f]=[o,u]:v.push([o,u]),l?(this.entries=v,this):new br(t,v)}};var Or=function(t,e,r){this.ownerID=t,this.bitmap=e,this.nodes=r};Or.prototype.get=function(t,e,r,n){void 0===e&&(e=K(r));var i=1<<((0===t?e:e>>>t)&xe),o=this.bitmap -;return 0==(o&i)?n:this.nodes[jt(o&i-1)].get(t+Ee,e,r,n)},Or.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=K(n));var s=(0===e?r:r>>>e)&xe,a=1<=kr)return Ot(t,p,c,s,l);if(h&&!l&&2===p.length&&zt(p[1^f]))return p[1^f];if(h&&l&&1===p.length&&zt(l))return l;var v=t&&t===this.ownerID,y=h?l?c:c^a:c|a,d=h?l?kt(p,f,l,v):Rt(p,f,v):At(p,f,l,v);return v?(this.bitmap=y,this.nodes=d,this):new Or(t,y,d)};var Mr=function(t,e,r){this.ownerID=t,this.count=e,this.nodes=r};Mr.prototype.get=function(t,e,r,n){void 0===e&&(e=K(r));var i=(0===t?e:e>>>t)&xe,o=this.nodes[i];return o?o.get(t+Ee,e,r,n):n},Mr.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=K(n));var s=(0===e?r:r>>>e)&xe,a=i===je,c=this.nodes,h=c[s];if(a&&!h)return this;var f=wt(h,t,e+Ee,r,n,i,o,u);if(f===h)return this;var p=this.count;if(h){if(!f&&--p0&&i=0&&t>>e&xe;if(n>=this.array.length)return new Lr([],t);var i,o=0===n;if(e>0){var u=this.array[n];if((i=u&&u.removeBefore(t,e-Ee,r))===u&&o)return this}if(o&&!i)return this;var s=Wt(this,t);if(!o)for(var a=0;a>>e&xe;if(n>=this.array.length)return this;var i;if(e>0){var o=this.array[n];if((i=o&&o.removeAfter(t,e-Ee,r))===o&&n===this.array.length-1)return this}var u=Wt(this,t);return u.array.splice(n+1),i&&(u.array[n]=i),u};var Tr,Cr={},Br=function(t){function e(t){return null===t||void 0===t?Yt():Vt(t)?t:Yt().withMutations(function(e){var r=Be(t);pt(r.size),r.forEach(function(t,r){return e.set(r,t)})})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("OrderedMap {","}")},e.prototype.get=function(t,e){var r=this._map.get(t);return void 0!==r?this._list.get(r)[1]:e},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._map.clear(),this._list.clear(),this):Yt()},e.prototype.set=function(t,e){return Qt(this,t,e)},e.prototype.remove=function(t){return Qt(this,t,je)},e.prototype.wasAltered=function(){return this._map.wasAltered()||this._list.wasAltered()},e.prototype.__iterate=function(t,e){var r=this;return this._list.__iterate(function(e){return e&&t(e[1],e[0],r)},e)},e.prototype.__iterator=function(t,e){return this._list.fromEntrySeq().__iterator(t,e)},e.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var e=this._map.__ensureOwner(t),r=this._list.__ensureOwner(t);return t?Ht(e,r,t,this.__hash):0===this.size?Yt():(this.__ownerID=t,this._map=e,this._list=r,this)},e}(zr) -;Br.isOrderedMap=Vt,Br.prototype[Le]=!0,Br.prototype.delete=Br.prototype.remove;var Wr,Nr=function(t){function e(t){return null===t||void 0===t?Gt():Xt(t)?t:Gt().pushAll(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("Stack [","]")},e.prototype.get=function(t,e){var r=this._head;for(t=u(this,t);r&&t--;)r=r.next;return r?r.value:e},e.prototype.peek=function(){return this._head&&this._head.value},e.prototype.push=function(){var t=arguments;if(0===arguments.length)return this;for(var e=this.size+arguments.length,r=this._head,n=arguments.length-1;n>=0;n--)r={value:t[n],next:r};return this.__ownerID?(this.size=e,this._head=r,this.__hash=void 0,this.__altered=!0,this):Ft(e,r)},e.prototype.pushAll=function(e){if(e=t(e),0===e.size)return this;if(0===this.size&&Xt(e))return e;pt(e.size);var r=this.size,n=this._head;return e.__iterate(function(t){r++,n={value:t,next:n}},!0),this.__ownerID?(this.size=r,this._head=n,this.__hash=void 0,this.__altered=!0,this):Ft(r,n)},e.prototype.pop=function(){return this.slice(1)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):Gt()},e.prototype.slice=function(e,r){if(a(e,r,this.size))return this;var n=c(e,this.size);if(h(r,this.size)!==this.size)return t.prototype.slice.call(this,e,r);for(var i=this.size-n,o=this._head;n--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):Ft(i,o)},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Ft(this.size,this._head,t,this.__hash):0===this.size?Gt():(this.__ownerID=t,this.__altered=!1,this)},e.prototype.__iterate=function(t,e){var r=this;if(e)return new er(this.toArray()).__iterate(function(e,n){return t(e,n,r)},e);for(var n=0,i=this._head;i&&t(i.value,n++,r)!==!1;)i=i.next;return n},e.prototype.__iterator=function(t,e){ -if(e)return new er(this.toArray()).__iterator(t,e);var r=0,n=this._head;return new Xe(function(){if(n){var e=n.value;return n=n.next,z(t,r++,e)}return I()})},e}(We);Nr.isStack=Xt;var Pr="@@__IMMUTABLE_STACK__@@",Jr=Nr.prototype;Jr[Pr]=!0,Jr.withMutations=Sr.withMutations,Jr.asMutable=Sr.asMutable,Jr.asImmutable=Sr.asImmutable,Jr.wasAltered=Sr.wasAltered,Jr.shift=Jr.pop,Jr.unshift=Jr.push,Jr.unshiftAll=Jr.pushAll,Jr["@@transducer/init"]=Jr.asMutable,Jr["@@transducer/step"]=function(t,e){return t.unshift(e)},Jr["@@transducer/result"]=Sr["@@transducer/result"];var Vr,Hr=function(t){function e(e){return null===e||void 0===e?ie():ee(e)&&!g(e)?e:ie().withMutations(function(r){var n=t(e);pt(n.size),n.forEach(function(t){return r.add(t)})})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(Be(t).keySeq())},e.intersect=function(t){return t=Ce(t).toArray(),t.length?Qr.intersect.apply(e(t.pop()),t):ie()},e.union=function(t){return t=Ce(t).toArray(),t.length?Qr.union.apply(e(t.pop()),t):ie()},e.prototype.toString=function(){return this.__toString("Set {","}")},e.prototype.has=function(t){return this._map.has(t)},e.prototype.add=function(t){return re(this,this._map.set(t,t))},e.prototype.remove=function(t){return re(this,this._map.remove(t))},e.prototype.clear=function(){return re(this,this._map.clear())},e.prototype.union=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return e=e.filter(function(t){return 0!==t.size}),0===e.length?this:0!==this.size||this.__ownerID||1!==e.length?this.withMutations(function(r){for(var n=0;n=0&&e=0&&rthis.size?e:this.find(function(e,r){return r===t},void 0,e)},has:function(t){return(t=u(this,t))>=0&&(void 0!==this.size?this.size===1/0||t>>0;if(""+r!==e||4294967295===r)return NaN;e=r}return e<0?i(t)+e:e}function u(){return!0}function s(t,e,r){return(0===t&&!f(t)||void 0!==r&&t<=-r)&&(void 0===e||void 0!==r&&e>=r)}function a(t,e){return h(t,e,0)}function c(t,e){return h(t,e,e)}function h(t,e,r){return void 0===t?r:f(t)?e===1/0?e:0|Math.max(0,e+t):void 0===e||e===t?t:0|Math.min(e,t)}function f(t){return t<0||0===t&&1/t==-(1/0)}function p(t){return _(t)||g(t)}function _(t){return!(!t||!t[Qe])}function l(t){return!(!t||!t[Xe])}function v(t){return!(!t||!t[Fe])}function y(t){return l(t)||v(t)}function d(t){return!(!t||!t[Ge])}function g(t){return!(!t||!t[Ze])}function m(t){return!(!t||"function"!=typeof t.equals||"function"!=typeof t.hashCode)}function w(t,e,r,n){var i=0===t?e:1===t?r:[e,r];return n?n.value=i:n={value:i,done:!1},n}function I(){return{value:void 0,done:!0}}function z(t){return!!O(t)}function S(t){return t&&"function"==typeof t.next}function b(t){var e=O(t);return e&&e.call(t)}function O(t){var e=t&&(ur&&t[ur]||t[sr]);if("function"==typeof e)return e}function M(t){return t&&"number"==typeof t.length}function E(t){return!(!t||!t[vr])}function q(){return gr||(gr=new yr([]))}function D(t){var e=Array.isArray(t)?new yr(t):S(t)?new Ir(t):z(t)?new wr(t):void 0;if(e)return e.fromEntrySeq();if("object"==typeof t)return new dr(t);throw new TypeError("Expected Array or collection object of [k, v] entries, or keyed object: "+t)}function A(t){var e=j(t);if(e)return e;throw new TypeError("Expected Array or collection object of values: "+t)}function x(t){var e=j(t);if(e)return e;if("object"==typeof t)return new dr(t) +;throw new TypeError("Expected Array or collection object of values, or keyed object: "+t)}function j(t){return M(t)?new yr(t):S(t)?new Ir(t):z(t)?new wr(t):void 0}function k(t,e){if(t===e||t!==t&&e!==e)return!0;if(!t||!e)return!1;if("function"==typeof t.valueOf&&"function"==typeof e.valueOf){if(t=t.valueOf(),e=e.valueOf(),t===e||t!==t&&e!==e)return!0;if(!t||!e)return!1}return!!(m(t)&&m(e)&&t.equals(e))}function R(t){if(M(t)&&"string"!=typeof t)return t;if(d(t))return t.toArray();throw new TypeError("Invalid keyPath: expected Ordered Collection or Array: "+t)}function U(t){return t&&(t.constructor===Object||void 0===t.constructor)}function K(t){return p(t)||Array.isArray(t)||U(t)}function T(t){try{return"string"==typeof t?JSON.stringify(t):t+""}catch(e){return JSON.stringify(t)}}function C(t,e){return p(t)?t.has(e):K(t)&&hr.call(t,e)}function L(t,e,r){return p(t)?t.get(e,r):C(t,e)?"function"==typeof t.get?t.get(e):t[e]:r}function B(t,e){e=e||0;for(var r=Math.max(0,t.length-e),n=Array(r),i=0;i0;)e[r]=arguments[r+1];return $(void 0,t,e)}function F(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];return $(t,e,r)}function G(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return $(tt(et),t,e)}function Z(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];return $(tt(t),e,r)}function $(t,e,r){if(!K(e))throw new TypeError("Cannot merge into non-data-structure value: "+e);if(p(e))return e.mergeWith?e.mergeWith.apply(e,[t].concat(r)):e.concat.apply(e,r);for(var n=Array.isArray(e),i=e,o=n?er:tr,u=n?function(t){i===e&&(i=W(i)),i.push(t)}:function(r,n){var o=t&&hr.call(i,n)?t(i[n],r,n):r;hr.call(i,n)&&o===i[n]||(i===e&&(i=W(i)),i[n]=o)},s=0;s>>1&1073741824|3221225471&t}function nt(t){if(t===!1||null===t||void 0===t)return 0;if("function"==typeof t.valueOf&&((t=t.valueOf())===!1||null===t||void 0===t))return 0;if(t===!0)return 1;var e=typeof t;if("number"===e){if(t!==t||t===1/0)return 0;var r=0|t;for(r!==t&&(r^=4294967295*t);t>4294967295;)t/=4294967295,r^=t;return rt(r)}if("string"===e)return t.length>qr?it(t):ot(t);if("function"==typeof t.hashCode)return rt(t.hashCode());if("object"===e)return ut(t);if("function"==typeof t.toString)return ot(""+t);throw Error("Value type "+e+" cannot be hashed.")}function it(t){var e=xr[t];return void 0===e&&(e=ot(t),Ar===Dr&&(Ar=0,xr={}),Ar++,xr[t]=e),e}function ot(t){for(var e=0,r=0;r0)switch(t.nodeType){case 1:return t.uniqueID;case 9:return t.documentElement&&t.documentElement.uniqueID}}function at(t){var e=qt(t);return e._iter=t,e.size=t.size,e.flip=function(){return t},e.reverse=function(){var e=t.reverse.apply(this);return e.flip=function(){return t.reverse()},e},e.has=function(e){return t.includes(e)},e.includes=function(e){return t.has(e)},e.cacheResult=Dt,e.__iterateUncached=function(e,r){var n=this;return t.__iterate(function(t,r){return e(r,t,n)!==!1},r)},e.__iteratorUncached=function(e,r){if(e===or){var n=t.__iterator(e,r);return new cr(function(){var t=n.next();if(!t.done){var e=t.value[0];t.value[0]=t.value[1],t.value[1]=e}return t})}return t.__iterator(e===ir?nr:ir,r)},e}function ct(t,e,r){var n=qt(t);return n.size=t.size,n.has=function(e){return t.has(e)},n.get=function(n,i){var o=t.get(n,He);return o===He?i:e.call(r,o,n,t)},n.__iterateUncached=function(n,i){var o=this;return t.__iterate(function(t,i,u){return n(e.call(r,t,i,u),i,o)!==!1},i)},n.__iteratorUncached=function(n,i){var o=t.__iterator(or,i);return new cr(function(){var i=o.next();if(i.done)return i;var u=i.value,s=u[0];return w(n,s,e.call(r,u[1],s,t),i)})},n}function ht(t,e){var r=this,n=qt(t);return n._iter=t,n.size=t.size,n.reverse=function(){return t},t.flip&&(n.flip=function(){ +var e=at(t);return e.reverse=function(){return t.flip()},e}),n.get=function(r,n){return t.get(e?r:-1-r,n)},n.has=function(r){return t.has(e?r:-1-r)},n.includes=function(e){return t.includes(e)},n.cacheResult=Dt,n.__iterate=function(r,n){var o=this,u=0;return n&&i(t),t.__iterate(function(t,i){return r(t,e?i:n?o.size-++u:u++,o)},!n)},n.__iterator=function(n,o){var u=0;o&&i(t);var s=t.__iterator(or,!o);return new cr(function(){var t=s.next();if(t.done)return t;var i=t.value;return w(n,e?i[0]:o?r.size-++u:u++,i[1],t)})},n}function ft(t,e,r,n){var i=qt(t);return n&&(i.has=function(n){var i=t.get(n,He);return i!==He&&!!e.call(r,i,n,t)},i.get=function(n,i){var o=t.get(n,He);return o!==He&&e.call(r,o,n,t)?o:i}),i.__iterateUncached=function(i,o){var u=this,s=0;return t.__iterate(function(t,o,a){if(e.call(r,t,o,a))return s++,i(t,n?o:s-1,u)},o),s},i.__iteratorUncached=function(i,o){var u=t.__iterator(or,o),s=0;return new cr(function(){for(;;){var o=u.next();if(o.done)return o;var a=o.value,c=a[0],h=a[1];if(e.call(r,h,c,t))return w(i,n?c:s++,h,o)}})},i}function pt(t,e,r){var n=Kr().asMutable();return t.__iterate(function(i,o){n.update(e.call(r,i,o,t),0,function(t){return t+1})}),n.asImmutable()}function _t(t,e,r){var n=l(t),i=(d(t)?en():Kr()).asMutable();t.__iterate(function(o,u){i.update(e.call(r,o,u,t),function(t){return t=t||[],t.push(n?[u,o]:o),t})});var o=Et(t);return i.map(function(e){return Ot(t,o(e))})}function lt(t,e,r,n){var i=t.size;if(s(e,r,i))return t;var u=a(e,i),h=c(r,i);if(u!==u||h!==h)return lt(t.toSeq().cacheResult(),e,r,n);var f,p=h-u;p===p&&(f=p<0?0:p);var _=qt(t);return _.size=0===f?f:t.size&&f||void 0,!n&&E(t)&&f>=0&&(_.get=function(e,r){return e=o(this,e),e>=0&&ef)return I();var t=i.next();return n||e===ir||t.done?t:e===nr?w(e,s-1,void 0,t):w(e,s-1,t.value[1],t)})},_}function vt(t,e,r){var n=qt(t);return n.__iterateUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterate(n,i);var u=0;return t.__iterate(function(t,i,s){return e.call(r,t,i,s)&&++u&&n(t,i,o)}),u},n.__iteratorUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterator(n,i);var u=t.__iterator(or,i),s=!0;return new cr(function(){if(!s)return I();var t=u.next();if(t.done)return t;var i=t.value,a=i[0],c=i[1];return e.call(r,c,a,o)?n===or?t:w(n,a,c,t):(s=!1,I())})},n}function yt(t,e,r,n){var i=qt(t);return i.__iterateUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterate(i,o);var s=!0,a=0;return t.__iterate(function(t,o,c){if(!s||!(s=e.call(r,t,o,c)))return a++,i(t,n?o:a-1,u)}),a},i.__iteratorUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterator(i,o);var s=t.__iterator(or,o),a=!0,c=0;return new cr(function(){var t,o,h;do{if(t=s.next(),t.done)return n||i===ir?t:i===nr?w(i,c++,void 0,t):w(i,c++,t.value[1],t);var f=t.value;o=f[0],h=f[1],a&&(a=e.call(r,h,o,u))}while(a);return i===or?t:w(i,o,h,t)})},i}function dt(t,e){var r=l(t),n=[t].concat(e).map(function(t){return _(t)?r&&(t=tr(t)):t=r?D(t):A(Array.isArray(t)?t:[t]),t}).filter(function(t){return 0!==t.size});if(0===n.length)return t;if(1===n.length){var i=n[0];if(i===t||r&&l(i)||v(t)&&v(i))return i}var o=new yr(n);return r?o=o.toKeyedSeq():v(t)||(o=o.toSetSeq()),o=o.flatten(!0),o.size=n.reduce(function(t,e){if(void 0!==t){var r=e.size;if(void 0!==r)return t+r}},0),o}function gt(t,e,r){var n=qt(t);return n.__iterateUncached=function(i,o){function u(t,c){t.__iterate(function(t,o){return(!e||c0}function bt(t,e,r,n){var i=qt(t),o=new yr(r).map(function(t){return t.size});return i.size=n?o.max():o.min(),i.__iterate=function(t,e){for(var r,n=this,i=this.__iterator(ir,e),o=0;!(r=i.next()).done&&t(r.value,o++,n)!==!1;);return o},i.__iteratorUncached=function(t,i){var o=r.map(function(t){return t=$e(t),b(i?t.reverse():t)}),u=0,s=!1;return new cr(function(){var r;return s||(r=o.map(function(t){return t.next()}),s=n?r.every(function(t){return t.done}):r.some(function(t){return t.done})),s?I():w(t,u++,e.apply(null,r.map(function(t){return t.value})))})},i}function Ot(t,e){return t===e?t:E(t)?e:t.constructor(e)}function Mt(t){if(t!==Object(t))throw new TypeError("Expected [K, V] tuple: "+t)}function Et(t){ +return l(t)?tr:v(t)?er:rr}function qt(t){return Object.create((l(t)?pr:v(t)?_r:lr).prototype)}function Dt(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size,this):fr.prototype.cacheResult.call(this)}function At(t,e){return void 0===t&&void 0===e?0:void 0===t?1:void 0===e?-1:t>e?1:t>>r)&Je,s=(0===r?n:n>>>r)&Je;return new Br(e,1<>>=1)u[s]=1&r?e[o++]:void 0;return u[n]=i,new Wr(t,o+1,u)}function Ht(t,e,r){for(var n=[],i=0;i>1&1431655765,t=(858993459&t)+(t>>2&858993459),t=t+(t>>4)&252645135,t+=t>>8,127&(t+=t>>16)}function Yt(t,e,r,n){var i=n?t:B(t);return i[e]=r,i}function Qt(t,e,r,n){var i=t.length+1;if(n&&e+1===i)return t[e]=r,t;for(var o=Array(i),u=0,s=0;so?0:o-r,c=u-r;return c>Pe&&(c=Pe),function(){if(i===c)return tn;var t=e?--c:i++;return n&&n[t]}}function i(t,n,i){var s,a=t&&t.array,c=i>o?0:o-i>>n,h=1+(u-i>>n);return h>Pe&&(h=Pe),function(){for(;;){if(s){var t=s();if(t!==tn)return t;s=null}if(c===h)return tn;var o=e?--h:c++;s=r(a&&a[o],n-Ne,i+(o<=t.size||r<0)return t.withMutations(function(t){r<0?ie(t,r).set(0,n):ie(t,0,r+1).set(r,n)});r+=t._origin;var i=t._tail,u=t._root,s=e(Ye);return r>=oe(t._capacity)?i=ee(i,t.__ownerID,0,r,n,s):u=ee(u,t.__ownerID,t._level,r,n,s),s.value?t.__ownerID?(t._root=u,t._tail=i,t.__hash=void 0,t.__altered=!0,t):Zt(t._origin,t._capacity,t._level,u,i):t}function ee(t,e,n,i,o,u){var s=i>>>n&Je,a=t&&s0){var h=t&&t.array[s],f=ee(h,e,n-Ne,i,o,u);return f===h?t:(c=re(t,e),c.array[s]=f,c)}return a&&t.array[s]===o?t:(r(u),c=re(t,e),void 0===o&&s===c.array.length-1?c.array.pop():c.array[s]=o,c)}function re(t,e){ +return e&&t&&e===t.ownerID?t:new Zr(t?t.array.slice():[],e)}function ne(t,e){if(e>=oe(t._capacity))return t._tail;if(e<1<0;)r=r.array[e>>>n&Je],n-=Ne;return r}}function ie(t,e,r){void 0!==e&&(e|=0),void 0!==r&&(r|=0);var i=t.__ownerID||new n,o=t._origin,u=t._capacity,s=o+e,a=void 0===r?u:r<0?u+r:o+r;if(s===o&&a===u)return t;if(s>=a)return t.clear();for(var c=t._level,h=t._root,f=0;s+f<0;)h=new Zr(h&&h.array.length?[void 0,h]:[],i),c+=Ne,f+=1<=1<p?new Zr([],i):l;if(l&&_>p&&sNe;d-=Ne){var g=p>>>d&Je;y=y.array[g]=re(y.array[g],i)}y.array[p>>>Ne&Je]=l}if(a=_)s-=_,a-=_,c=Ne,h=null,v=v&&v.removeBefore(i,0,s);else if(s>o||_>>c&Je;if(m!==_>>>c&Je)break;m&&(f+=(1<o&&(h=h.removeBefore(i,c,s-f)),h&&_>>Ne<=Pe&&u.size>=2*o.size?(i=u.filter(function(t,e){return void 0!==t&&s!==e}),n=i.toKeyedSeq().map(function(t){return t[0]}).flip().toMap(),t.__ownerID&&(n.__ownerID=i.__ownerID=t.__ownerID)):(n=o.remove(e),i=s===u.size-1?u.pop():u.set(s,void 0))}else if(a){if(r===u.get(s)[1])return t;n=o,i=u.set(s,[e,r])}else n=o.set(e,u.size),i=u.set(u.size,[e,r]);return t.__ownerID?(t.size=n.size,t._map=n,t._list=i,t.__hash=void 0,t):se(n,i)}function he(t){return!(!t||!t[on])}function fe(t,e,r,n){ +var i=Object.create(un);return i.size=t,i._head=e,i.__ownerID=r,i.__hash=n,i.__altered=!1,i}function pe(){return sn||(sn=fe(0))}function _e(t,e,r){for(var n=R(e),i=0;i!==n.length;)if((t=L(t,n[i++],He))===He)return r;return t}function le(t,e){return _e(t,e,He)!==He}function ve(t,e){if(t===e)return!0;if(!_(e)||void 0!==t.size&&void 0!==e.size&&t.size!==e.size||void 0!==t.__hash&&void 0!==e.__hash&&t.__hash!==e.__hash||l(t)!==l(e)||v(t)!==v(e)||d(t)!==d(e))return!1;if(0===t.size&&0===e.size)return!0;var r=!y(t);if(d(t)){var n=t.entries();return e.every(function(t,e){var i=n.next().value;return i&&k(i[1],t)&&(r||k(i[0],e))})&&n.next().done}var i=!1;if(void 0===t.size)if(void 0===e.size)"function"==typeof t.cacheResult&&t.cacheResult();else{i=!0;var o=t;t=e,e=o}var u=!0,s=e.__iterate(function(e,n){if(r?!t.has(e):i?!k(e,t.get(n,He)):!k(t.get(n,He),e))return u=!1,!1});return u&&t.size===s}function ye(t,e){var r=function(r){t.prototype[r]=e[r]};return Object.keys(e).forEach(r),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(e).forEach(r),t}function de(t){return K(t)?fr(t).map(de).toJSON():t}function ge(t){return!(!t||!t[cn])}function me(t,e){return t.__ownerID?(t.size=e.size,t._map=e,t):e===t._map?t:0===e.size?t.__empty():t.__make(e)}function we(t,e){var r=Object.create(hn);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function Ie(){return fn||(fn=we(Tt()))}function ze(t,e,r,n,i,o){return jt(t.size),t.__iterate(function(t,o,u){i?(i=!1,r=t):r=e.call(n,r,t,o,u)},o),r}function Se(t,e){return e}function be(t,e){return[e,t]}function Oe(t){return function(){return!t.apply(this,arguments)}}function Me(t){return function(){return-t.apply(this,arguments)}}function Ee(){return B(arguments)}function qe(t,e){return te?-1:0}function De(t){if(t.size===1/0)return 0;var e=d(t),r=l(t),n=e?1:0;return Ae(t.__iterate(r?e?function(t,e){n=31*n+xe(nt(t),nt(e))|0}:function(t,e){n=n+xe(nt(t),nt(e))|0}:e?function(t){n=31*n+nt(t)|0}:function(t){n=n+nt(t)|0}),n)}function Ae(t,e){return e=zr(e,3432918353), +e=zr(e<<15|e>>>-15,461845907),e=zr(e<<13|e>>>-13,5),e=(e+3864292196|0)^t,e=zr(e^e>>>16,2246822507),e=zr(e^e>>>13,3266489909),e=rt(e^e>>>16)}function xe(t,e){return t^e+2654435769+(t<<6)+(t>>2)|0}function je(t){return ge(t)&&d(t)}function ke(t,e){var r=Object.create(gn);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function Re(){return mn||(mn=ke(ae()))}function Ue(t,e,r){var n=Object.create(Object.getPrototypeOf(t));return n._values=e,n.__ownerID=r,n}function Ke(t){return t._name||t.constructor.name||"Record"}function Te(t){return D(t._keys.map(function(e){return[e,t.get(e)]}))}function Ce(t,e){try{Object.defineProperty(t,e,{get:function(){return this.get(e)},set:function(t){xt(this.__ownerID,"Cannot set on an immutable record."),this.set(e,t)}})}catch(t){}}function Le(t,e){return Be([],e||We,t,"",e&&e.length>2?[]:void 0,{"":t})}function Be(t,e,r,n,i,o){var u=Array.isArray(r)?_r:U(r)?pr:null;if(u){if(~t.indexOf(r))throw new TypeError("Cannot convert circular structure to Immutable");t.push(r),i&&""!==n&&i.push(n);var s=e.call(o,n,u(r).map(function(n,o){return Be(t,e,n,o,i,r)}),i&&i.slice());return t.pop(),i&&i.pop(),s}return r}function We(t,e){return l(e)?e.toMap():e.toList()}var Ne=5,Pe=1<=n.length){var e=r.next();if(e.done)return e;n[i]=e.value}return w(t,i,n[i++])})},e}(_r),zr="function"==typeof Math.imul&&Math.imul(4294967295,2)===-2?Math.imul:function(t,e){t|=0,e|=0;var r=65535&t,n=65535&e;return r*n+((t>>>16)*n+r*(e>>>16)<<16>>>0)|0},Sr=Object.isExtensible,br=function(){try{return Object.defineProperty({},"@",{}),!0}catch(t){return!1}}(),Or="function"==typeof WeakMap;Or&&(mr=new WeakMap);var Mr=0,Er="__immutablehash__";"function"==typeof Symbol&&(Er=Symbol(Er));var qr=16,Dr=255,Ar=0,xr={},jr=function(t){function e(t,e){this._iter=t,this._useKeys=e,this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t,e){return this._iter.get(t,e)},e.prototype.has=function(t){return this._iter.has(t)},e.prototype.valueSeq=function(){return this._iter.valueSeq()},e.prototype.reverse=function(){var t=this,e=ht(this,!0);return this._useKeys||(e.valueSeq=function(){return t._iter.toSeq().reverse()}),e},e.prototype.map=function(t,e){var r=this,n=ct(this,t,e);return this._useKeys||(n.valueSeq=function(){return r._iter.toSeq().map(t,e)}),n},e.prototype.__iterate=function(t,e){var r=this;return this._iter.__iterate(function(e,n){return t(e,n,r)},e)},e.prototype.__iterator=function(t,e){return this._iter.__iterator(t,e)},e}(pr);jr.prototype[Ge]=!0;var kr=function(t){function e(t){this._iter=t,this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e, +e.prototype.includes=function(t){return this._iter.includes(t)},e.prototype.__iterate=function(t,e){var r=this,n=0;return e&&i(this),this._iter.__iterate(function(i){return t(i,e?r.size-++n:n++,r)},e)},e.prototype.__iterator=function(t,e){var r=this,n=this._iter.__iterator(ir,e),o=0;return e&&i(this),new cr(function(){var i=n.next();return i.done?i:w(t,e?r.size-++o:o++,i.value,i)})},e}(_r),Rr=function(t){function e(t){this._iter=t,this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.has=function(t){return this._iter.includes(t)},e.prototype.__iterate=function(t,e){var r=this;return this._iter.__iterate(function(e){return t(e,e,r)},e)},e.prototype.__iterator=function(t,e){var r=this._iter.__iterator(ir,e);return new cr(function(){var e=r.next();return e.done?e:w(t,e.value,e.value,e)})},e}(lr),Ur=function(t){function e(t){this._iter=t,this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.entrySeq=function(){return this._iter.toSeq()},e.prototype.__iterate=function(t,e){var r=this;return this._iter.__iterate(function(e){if(e){Mt(e);var n=_(e);return t(n?e.get(1):e[1],n?e.get(0):e[0],r)}},e)},e.prototype.__iterator=function(t,e){var r=this._iter.__iterator(ir,e);return new cr(function(){for(;;){var e=r.next();if(e.done)return e;var n=e.value;if(n){Mt(n);var i=_(n);return w(t,i?n.get(0):n[0],i?n.get(1):n[1],e)}}})},e}(pr);kr.prototype.cacheResult=jr.prototype.cacheResult=Rr.prototype.cacheResult=Ur.prototype.cacheResult=Dt;var Kr=function(t){function e(e){return null===e||void 0===e?Tt():kt(e)&&!d(e)?e:Tt().withMutations(function(r){var n=t(e);jt(n.size),n.forEach(function(t,e){return r.set(e,t)})})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return Tt().withMutations(function(e){for(var r=0;r=t.length)throw Error("Missing value for key: "+t[r]);e.set(t[r],t[r+1])}})},e.prototype.toString=function(){return this.__toString("Map {","}")},e.prototype.get=function(t,e){return this._root?this._root.get(0,void 0,t,e):e},e.prototype.set=function(t,e){return Ct(this,t,e)},e.prototype.setIn=function(t,e){return V(this,t,e)},e.prototype.remove=function(t){return Ct(this,t,He)},e.prototype.deleteIn=function(t){return Q(this,t)},e.prototype.deleteAll=function(t){var e=$e(t);return 0===e.size?this:this.withMutations(function(t){e.forEach(function(e){return t.remove(e)})})},e.prototype.update=function(t,e,r){return 1===arguments.length?t(this):Y(this,t,e,r)},e.prototype.updateIn=function(t,e,r){return J(this,t,e,r)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):Tt()},e.prototype.merge=function(){return Ht(this,void 0,arguments)},e.prototype.mergeWith=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Ht(this,t,e)},e.prototype.mergeIn=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return J(this,t,Tt(),function(t){return X.apply(void 0,[t].concat(e))})},e.prototype.mergeDeep=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return G.apply(void 0,[this].concat(t))},e.prototype.mergeDeepWith=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Z.apply(void 0,[t,this].concat(e))},e.prototype.mergeDeepIn=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return J(this,t,Tt(),function(t){return G.apply(void 0,[t].concat(e))})},e.prototype.sort=function(t){return en(It(this,t))},e.prototype.sortBy=function(t,e){return en(It(this,e,t))},e.prototype.withMutations=function(t){var e=this.asMutable();return t(e),e.wasAltered()?e.__ensureOwner(this.__ownerID):this},e.prototype.asMutable=function(){return this.__ownerID?this:this.__ensureOwner(new n)},e.prototype.asImmutable=function(){ +return this.__ensureOwner()},e.prototype.wasAltered=function(){return this.__altered},e.prototype.__iterator=function(t,e){return new Hr(this,t,e)},e.prototype.__iterate=function(t,e){var r=this,n=0;return this._root&&this._root.iterate(function(e){return n++,t(e[1],e[0],r)},e),n},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Kt(this.size,this._root,t,this.__hash):0===this.size?Tt():(this.__ownerID=t,this.__altered=!1,this)},e}(tr);Kr.isMap=kt;var Tr="@@__IMMUTABLE_MAP__@@",Cr=Kr.prototype;Cr[Tr]=!0,Cr.delete=Cr.remove,Cr.removeIn=Cr.deleteIn,Cr.removeAll=Cr.deleteAll,Cr.concat=Cr.merge,Cr["@@transducer/init"]=Cr.asMutable,Cr["@@transducer/step"]=function(t,e){return t.set(e[0],e[1])},Cr["@@transducer/result"]=function(t){return t.asImmutable()};var Lr=function(t,e){this.ownerID=t,this.entries=e};Lr.prototype.get=function(t,e,r,n){for(var i=this.entries,o=0,u=i.length;o=Vr)return Nt(t,c,i,o);var _=t&&t===this.ownerID,l=_?c:B(c);return p?a?h===f-1?l.pop():l[h]=l.pop():l[h]=[i,o]:l.push([i,o]),_?(this.entries=l,this):new Lr(t,l)}};var Br=function(t,e,r){this.ownerID=t,this.bitmap=e,this.nodes=r};Br.prototype.get=function(t,e,r,n){void 0===e&&(e=nt(r));var i=1<<((0===t?e:e>>>t)&Je),o=this.bitmap;return 0==(o&i)?n:this.nodes[Vt(o&i-1)].get(t+Ne,e,r,n)},Br.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=nt(n));var s=(0===e?r:r>>>e)&Je,a=1<=Yr)return Jt(t,p,c,s,l);if(h&&!l&&2===p.length&&Bt(p[1^f]))return p[1^f];if(h&&l&&1===p.length&&Bt(l))return l;var v=t&&t===this.ownerID,y=h?l?c:c^a:c|a,d=h?l?Yt(p,f,l,v):Xt(p,f,v):Qt(p,f,l,v);return v?(this.bitmap=y,this.nodes=d, +this):new Br(t,y,d)};var Wr=function(t,e,r){this.ownerID=t,this.count=e,this.nodes=r};Wr.prototype.get=function(t,e,r,n){void 0===e&&(e=nt(r));var i=(0===t?e:e>>>t)&Je,o=this.nodes[i];return o?o.get(t+Ne,e,r,n):n},Wr.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=nt(n));var s=(0===e?r:r>>>e)&Je,a=i===He,c=this.nodes,h=c[s];if(a&&!h)return this;var f=Lt(h,t,e+Ne,r,n,i,o,u);if(f===h)return this;var p=this.count;if(h){if(!f&&--p0&&i=0&&t>>e&Je;if(n>=this.array.length)return new Zr([],t);var i,o=0===n;if(e>0){var u=this.array[n];if((i=u&&u.removeBefore(t,e-Ne,r))===u&&o)return this}if(o&&!i)return this;var s=re(this,t);if(!o)for(var a=0;a>>e&Je;if(n>=this.array.length)return this;var i;if(e>0){ +var o=this.array[n];if((i=o&&o.removeAfter(t,e-Ne,r))===o&&n===this.array.length-1)return this}var u=re(this,t);return u.array.splice(n+1),i&&(u.array[n]=i),u};var $r,tn={},en=function(t){function e(t){return null===t||void 0===t?ae():ue(t)?t:ae().withMutations(function(e){var r=tr(t);jt(r.size),r.forEach(function(t,r){return e.set(r,t)})})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("OrderedMap {","}")},e.prototype.get=function(t,e){var r=this._map.get(t);return void 0!==r?this._list.get(r)[1]:e},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._map.clear(),this._list.clear(),this):ae()},e.prototype.set=function(t,e){return ce(this,t,e)},e.prototype.remove=function(t){return ce(this,t,He)},e.prototype.wasAltered=function(){return this._map.wasAltered()||this._list.wasAltered()},e.prototype.__iterate=function(t,e){var r=this;return this._list.__iterate(function(e){return e&&t(e[1],e[0],r)},e)},e.prototype.__iterator=function(t,e){return this._list.fromEntrySeq().__iterator(t,e)},e.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var e=this._map.__ensureOwner(t),r=this._list.__ensureOwner(t);return t?se(e,r,t,this.__hash):0===this.size?ae():(this.__ownerID=t,this._map=e,this._list=r,this)},e}(Kr);en.isOrderedMap=ue,en.prototype[Ge]=!0,en.prototype.delete=en.prototype.remove;var rn,nn=function(t){function e(t){return null===t||void 0===t?pe():he(t)?t:pe().pushAll(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("Stack [","]")},e.prototype.get=function(t,e){var r=this._head;for(t=o(this,t);r&&t--;)r=r.next;return r?r.value:e},e.prototype.peek=function(){return this._head&&this._head.value},e.prototype.push=function(){var t=arguments;if(0===arguments.length)return this +;for(var e=this.size+arguments.length,r=this._head,n=arguments.length-1;n>=0;n--)r={value:t[n],next:r};return this.__ownerID?(this.size=e,this._head=r,this.__hash=void 0,this.__altered=!0,this):fe(e,r)},e.prototype.pushAll=function(e){if(e=t(e),0===e.size)return this;if(0===this.size&&he(e))return e;jt(e.size);var r=this.size,n=this._head;return e.__iterate(function(t){r++,n={value:t,next:n}},!0),this.__ownerID?(this.size=r,this._head=n,this.__hash=void 0,this.__altered=!0,this):fe(r,n)},e.prototype.pop=function(){return this.slice(1)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):pe()},e.prototype.slice=function(e,r){if(s(e,r,this.size))return this;var n=a(e,this.size);if(c(r,this.size)!==this.size)return t.prototype.slice.call(this,e,r);for(var i=this.size-n,o=this._head;n--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):fe(i,o)},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?fe(this.size,this._head,t,this.__hash):0===this.size?pe():(this.__ownerID=t,this.__altered=!1,this)},e.prototype.__iterate=function(t,e){var r=this;if(e)return new yr(this.toArray()).__iterate(function(e,n){return t(e,n,r)},e);for(var n=0,i=this._head;i&&t(i.value,n++,r)!==!1;)i=i.next;return n},e.prototype.__iterator=function(t,e){if(e)return new yr(this.toArray()).__iterator(t,e);var r=0,n=this._head;return new cr(function(){if(n){var e=n.value;return n=n.next,w(t,r++,e)}return I()})},e}(er);nn.isStack=he;var on="@@__IMMUTABLE_STACK__@@",un=nn.prototype;un[on]=!0,un.withMutations=Cr.withMutations,un.asMutable=Cr.asMutable,un.asImmutable=Cr.asImmutable,un.wasAltered=Cr.wasAltered,un.shift=un.pop,un.unshift=un.push,un.unshiftAll=un.pushAll,un["@@transducer/init"]=un.asMutable,un["@@transducer/step"]=function(t,e){return t.unshift(e)},un["@@transducer/result"]=Cr["@@transducer/result"];var sn,an=function(t){function e(e){ +return null===e||void 0===e?Ie():ge(e)&&!d(e)?e:Ie().withMutations(function(r){var n=t(e);jt(n.size),n.forEach(function(t){return r.add(t)})})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(tr(t).keySeq())},e.intersect=function(t){return t=$e(t).toArray(),t.length?hn.intersect.apply(e(t.pop()),t):Ie()},e.union=function(t){return t=$e(t).toArray(),t.length?hn.union.apply(e(t.pop()),t):Ie()},e.prototype.toString=function(){return this.__toString("Set {","}")},e.prototype.has=function(t){return this._map.has(t)},e.prototype.add=function(t){return me(this,this._map.set(t,t))},e.prototype.remove=function(t){return me(this,this._map.remove(t))},e.prototype.clear=function(){return me(this,this._map.clear())},e.prototype.union=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return e=e.filter(function(t){return 0!==t.size}),0===e.length?this:0!==this.size||this.__ownerID||1!==e.length?this.withMutations(function(r){for(var n=0;n=0&&e=0&&rthis.size?e:this.find(function(e,r){return r===t},void 0,e)},has:function(t){return(t=o(this,t))>=0&&(void 0!==this.size?this.size===1/0||t Date: Mon, 16 Oct 2017 20:02:26 +0000 Subject: [PATCH 064/242] Deploy ce9df42231c6897df32d9cc8427cc20d5fb6bb1f to NPM branch --- dist/immutable.es.js | 1397 ++++++++++++++++++++-------------------- dist/immutable.js | 1411 +++++++++++++++++++++-------------------- dist/immutable.min.js | 64 +- 3 files changed, 1465 insertions(+), 1407 deletions(-) diff --git a/dist/immutable.es.js b/dist/immutable.es.js index 12f18e840f..d2ad2b79d3 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -757,400 +757,120 @@ function is(valueA, valueB) { ); } -function coerceKeyPath(keyPath) { - if (isArrayLike(keyPath) && typeof keyPath !== 'string') { - return keyPath; - } - if (isOrdered(keyPath)) { - return keyPath.toArray(); - } - throw new TypeError( - 'Invalid keyPath: expected Ordered Collection or Array: ' + keyPath - ); -} - -function isPlainObj(value) { - return ( - value && (value.constructor === Object || value.constructor === undefined) - ); -} +var imul = + typeof Math.imul === 'function' && Math.imul(0xffffffff, 2) === -2 + ? Math.imul + : function imul(a, b) { + a |= 0; // int + b |= 0; // int + var c = a & 0xffff; + var d = b & 0xffff; + // Shift by 0 fixes the sign on the high part. + return (c * d + ((((a >>> 16) * d + c * (b >>> 16)) << 16) >>> 0)) | 0; // int + }; -/** - * Returns true if the value is a potentially-persistent data structure, either - * provided by Immutable.js or a plain Array or Object. - */ -function isDataStructure(value) { - return isImmutable(value) || Array.isArray(value) || isPlainObj(value); +// v8 has an optimization for storing 31-bit signed numbers. +// Values which have either 00 or 11 as the high order bits qualify. +// This function drops the highest order bit in a signed number, maintaining +// the sign bit. +function smi(i32) { + return ((i32 >>> 1) & 0x40000000) | (i32 & 0xbfffffff); } -/** - * Converts a value to a string, adding quotes if a string was provided. - */ -function quoteString(value) { - try { - return typeof value === 'string' ? JSON.stringify(value) : String(value); - } catch (_ignoreError) { - return JSON.stringify(value); +function hash(o) { + if (o === false || o === null || o === undefined) { + return 0; } -} - -function has(collection, key) { - return isImmutable(collection) - ? collection.has(key) - : isDataStructure(collection) && hasOwnProperty.call(collection, key); -} - -function get(collection, key, notSetValue) { - return isImmutable(collection) - ? collection.get(key, notSetValue) - : !has(collection, key) - ? notSetValue - : typeof collection.get === 'function' - ? collection.get(key) - : collection[key]; -} - -// http://jsperf.com/copy-array-inline -function arrCopy(arr, offset) { - offset = offset || 0; - var len = Math.max(0, arr.length - offset); - var newArr = new Array(len); - for (var ii = 0; ii < len; ii++) { - newArr[ii] = arr[ii + offset]; + if (typeof o.valueOf === 'function') { + o = o.valueOf(); + if (o === false || o === null || o === undefined) { + return 0; + } } - return newArr; -} - -function shallowCopy(from) { - if (Array.isArray(from)) { - return arrCopy(from); + if (o === true) { + return 1; } - var to = {}; - for (var key in from) { - if (hasOwnProperty.call(from, key)) { - to[key] = from[key]; + var type = typeof o; + if (type === 'number') { + if (o !== o || o === Infinity) { + return 0; + } + var h = o | 0; + if (h !== o) { + h ^= o * 0xffffffff; + } + while (o > 0xffffffff) { + o /= 0xffffffff; + h ^= o; } + return smi(h); } - return to; -} - -function remove(collection, key) { - if (!isDataStructure(collection)) { - throw new TypeError( - 'Cannot update non-data-structure value: ' + collection - ); + if (type === 'string') { + return o.length > STRING_HASH_CACHE_MIN_STRLEN + ? cachedHashString(o) + : hashString(o); } - if (isImmutable(collection)) { - if (!collection.remove) { - throw new TypeError( - 'Cannot update immutable value without .remove() method: ' + collection - ); - } - return collection.remove(key); + if (typeof o.hashCode === 'function') { + // Drop any high bits from accidentally long hash codes. + return smi(o.hashCode()); } - if (!hasOwnProperty.call(collection, key)) { - return collection; + if (type === 'object') { + return hashJSObj(o); } - var collectionCopy = shallowCopy(collection); - if (Array.isArray(collectionCopy)) { - collectionCopy.splice(key, 1); - } else { - delete collectionCopy[key]; + if (typeof o.toString === 'function') { + return hashString(o.toString()); } - return collectionCopy; + throw new Error('Value type ' + type + ' cannot be hashed.'); } -function set(collection, key, value) { - if (!isDataStructure(collection)) { - throw new TypeError( - 'Cannot update non-data-structure value: ' + collection - ); - } - if (isImmutable(collection)) { - if (!collection.set) { - throw new TypeError( - 'Cannot update immutable value without .set() method: ' + collection - ); +function cachedHashString(string) { + var hashed = stringHashCache[string]; + if (hashed === undefined) { + hashed = hashString(string); + if (STRING_HASH_CACHE_SIZE === STRING_HASH_CACHE_MAX_SIZE) { + STRING_HASH_CACHE_SIZE = 0; + stringHashCache = {}; } - return collection.set(key, value); - } - if (hasOwnProperty.call(collection, key) && value === collection[key]) { - return collection; + STRING_HASH_CACHE_SIZE++; + stringHashCache[string] = hashed; } - var collectionCopy = shallowCopy(collection); - collectionCopy[key] = value; - return collectionCopy; + return hashed; } -function updateIn(collection, keyPath, notSetValue, updater) { - if (!updater) { - updater = notSetValue; - notSetValue = undefined; +// http://jsperf.com/hashing-strings +function hashString(string) { + // This is the hash from JVM + // The hash code for a string is computed as + // s[0] * 31 ^ (n - 1) + s[1] * 31 ^ (n - 2) + ... + s[n - 1], + // where s[i] is the ith character of the string and n is the length of + // the string. We "mod" the result to make it between 0 (inclusive) and 2^31 + // (exclusive) by dropping high bits. + var hashed = 0; + for (var ii = 0; ii < string.length; ii++) { + hashed = (31 * hashed + string.charCodeAt(ii)) | 0; } - var updatedValue = updateInDeeply( - isImmutable(collection), - collection, - coerceKeyPath(keyPath), - 0, - notSetValue, - updater - ); - return updatedValue === NOT_SET ? notSetValue : updatedValue; + return smi(hashed); } -function updateInDeeply( - inImmutable, - existing, - keyPath, - i, - notSetValue, - updater -) { - var wasNotSet = existing === NOT_SET; - if (i === keyPath.length) { - var existingValue = wasNotSet ? notSetValue : existing; - var newValue = updater(existingValue); - return newValue === existingValue ? existing : newValue; - } - if (!wasNotSet && !isDataStructure(existing)) { - throw new TypeError( - 'Cannot update within non-data-structure value in path [' + - keyPath.slice(0, i).map(quoteString) + - ']: ' + - existing - ); +function hashJSObj(obj) { + var hashed; + if (usingWeakMap) { + hashed = weakMap.get(obj); + if (hashed !== undefined) { + return hashed; + } } - var key = keyPath[i]; - var nextExisting = wasNotSet ? NOT_SET : get(existing, key, NOT_SET); - var nextUpdated = updateInDeeply( - nextExisting === NOT_SET ? inImmutable : isImmutable(nextExisting), - nextExisting, - keyPath, - i + 1, - notSetValue, - updater - ); - return nextUpdated === nextExisting - ? existing - : nextUpdated === NOT_SET - ? remove(existing, key) - : set( - wasNotSet ? (inImmutable ? emptyMap() : {}) : existing, - key, - nextUpdated - ); -} -function setIn(collection, keyPath, value) { - return updateIn(collection, keyPath, NOT_SET, function () { return value; }); -} + hashed = obj[UID_HASH_KEY]; + if (hashed !== undefined) { + return hashed; + } -function update(collection, key, notSetValue, updater) { - return updateIn(collection, [key], notSetValue, updater); -} - -function removeIn(collection, keyPath) { - return updateIn(collection, keyPath, function () { return NOT_SET; }); -} - -function merge(collection) { - var sources = [], len = arguments.length - 1; - while ( len-- > 0 ) sources[ len ] = arguments[ len + 1 ]; - - return mergeWithSources(undefined, collection, sources); -} - -function mergeWith(merger, collection) { - var sources = [], len = arguments.length - 2; - while ( len-- > 0 ) sources[ len ] = arguments[ len + 2 ]; - - return mergeWithSources(merger, collection, sources); -} - -function mergeDeep(collection) { - var sources = [], len = arguments.length - 1; - while ( len-- > 0 ) sources[ len ] = arguments[ len + 1 ]; - - return mergeWithSources(deepMergerWith(alwaysNewValue), collection, sources); -} - -function mergeDeepWith(merger, collection) { - var sources = [], len = arguments.length - 2; - while ( len-- > 0 ) sources[ len ] = arguments[ len + 2 ]; - - return mergeWithSources(deepMergerWith(merger), collection, sources); -} - -function mergeWithSources(merger, collection, sources) { - if (!isDataStructure(collection)) { - throw new TypeError( - 'Cannot merge into non-data-structure value: ' + collection - ); - } - if (isImmutable(collection)) { - return collection.mergeWith - ? collection.mergeWith.apply(collection, [ merger ].concat( sources )) - : collection.concat.apply(collection, sources); - } - var isArray = Array.isArray(collection); - var merged = collection; - var Collection$$1 = isArray ? IndexedCollection : KeyedCollection; - var mergeItem = isArray - ? function (value) { - // Copy on write - if (merged === collection) { - merged = shallowCopy(merged); - } - merged.push(value); - } - : function (value, key) { - var nextVal = - merger && hasOwnProperty.call(merged, key) - ? merger(merged[key], value, key) - : value; - if (!hasOwnProperty.call(merged, key) || nextVal !== merged[key]) { - // Copy on write - if (merged === collection) { - merged = shallowCopy(merged); - } - merged[key] = nextVal; - } - }; - for (var i = 0; i < sources.length; i++) { - Collection$$1(sources[i]).forEach(mergeItem); - } - return merged; -} - -function deepMergerWith(merger) { - function deepMerger(oldValue, newValue, key) { - if (isDataStructure(oldValue) && isDataStructure(newValue)) { - return mergeWithSources(deepMerger, oldValue, [newValue]); - } - var nextValue = merger(oldValue, newValue, key); - return is(oldValue, nextValue) ? oldValue : nextValue; - } - return deepMerger; -} - -function alwaysNewValue(oldValue, newValue) { - return newValue; -} - -var imul = - typeof Math.imul === 'function' && Math.imul(0xffffffff, 2) === -2 - ? Math.imul - : function imul(a, b) { - a |= 0; // int - b |= 0; // int - var c = a & 0xffff; - var d = b & 0xffff; - // Shift by 0 fixes the sign on the high part. - return (c * d + ((((a >>> 16) * d + c * (b >>> 16)) << 16) >>> 0)) | 0; // int - }; - -// v8 has an optimization for storing 31-bit signed numbers. -// Values which have either 00 or 11 as the high order bits qualify. -// This function drops the highest order bit in a signed number, maintaining -// the sign bit. -function smi(i32) { - return ((i32 >>> 1) & 0x40000000) | (i32 & 0xbfffffff); -} - -function hash(o) { - if (o === false || o === null || o === undefined) { - return 0; - } - if (typeof o.valueOf === 'function') { - o = o.valueOf(); - if (o === false || o === null || o === undefined) { - return 0; - } - } - if (o === true) { - return 1; - } - var type = typeof o; - if (type === 'number') { - if (o !== o || o === Infinity) { - return 0; - } - var h = o | 0; - if (h !== o) { - h ^= o * 0xffffffff; - } - while (o > 0xffffffff) { - o /= 0xffffffff; - h ^= o; - } - return smi(h); - } - if (type === 'string') { - return o.length > STRING_HASH_CACHE_MIN_STRLEN - ? cachedHashString(o) - : hashString(o); - } - if (typeof o.hashCode === 'function') { - // Drop any high bits from accidentally long hash codes. - return smi(o.hashCode()); - } - if (type === 'object') { - return hashJSObj(o); - } - if (typeof o.toString === 'function') { - return hashString(o.toString()); - } - throw new Error('Value type ' + type + ' cannot be hashed.'); -} - -function cachedHashString(string) { - var hashed = stringHashCache[string]; - if (hashed === undefined) { - hashed = hashString(string); - if (STRING_HASH_CACHE_SIZE === STRING_HASH_CACHE_MAX_SIZE) { - STRING_HASH_CACHE_SIZE = 0; - stringHashCache = {}; - } - STRING_HASH_CACHE_SIZE++; - stringHashCache[string] = hashed; - } - return hashed; -} - -// http://jsperf.com/hashing-strings -function hashString(string) { - // This is the hash from JVM - // The hash code for a string is computed as - // s[0] * 31 ^ (n - 1) + s[1] * 31 ^ (n - 2) + ... + s[n - 1], - // where s[i] is the ith character of the string and n is the length of - // the string. We "mod" the result to make it between 0 (inclusive) and 2^31 - // (exclusive) by dropping high bits. - var hashed = 0; - for (var ii = 0; ii < string.length; ii++) { - hashed = (31 * hashed + string.charCodeAt(ii)) | 0; - } - return smi(hashed); -} - -function hashJSObj(obj) { - var hashed; - if (usingWeakMap) { - hashed = weakMap.get(obj); - if (hashed !== undefined) { - return hashed; - } - } - - hashed = obj[UID_HASH_KEY]; - if (hashed !== undefined) { - return hashed; - } - - if (!canDefineProperty) { - hashed = obj.propertyIsEnumerable && obj.propertyIsEnumerable[UID_HASH_KEY]; - if (hashed !== undefined) { - return hashed; - } + if (!canDefineProperty) { + hashed = obj.propertyIsEnumerable && obj.propertyIsEnumerable[UID_HASH_KEY]; + if (hashed !== undefined) { + return hashed; + } hashed = getIENodeHash(obj); if (hashed !== undefined) { @@ -1999,154 +1719,545 @@ function sortFactory(collection, comparator, mapper) { : function (v, i) { entries[i] = v[1]; } - ); - return isKeyedCollection - ? KeyedSeq(entries) - : isIndexed(collection) ? IndexedSeq(entries) : SetSeq(entries); + ); + return isKeyedCollection + ? KeyedSeq(entries) + : isIndexed(collection) ? IndexedSeq(entries) : SetSeq(entries); +} + +function maxFactory(collection, comparator, mapper) { + if (!comparator) { + comparator = defaultComparator; + } + if (mapper) { + var entry = collection + .toSeq() + .map(function (v, k) { return [v, mapper(v, k, collection)]; }) + .reduce(function (a, b) { return (maxCompare(comparator, a[1], b[1]) ? b : a); }); + return entry && entry[0]; + } + return collection.reduce(function (a, b) { return (maxCompare(comparator, a, b) ? b : a); }); +} + +function maxCompare(comparator, a, b) { + var comp = comparator(b, a); + // b is considered the new max if the comparator declares them equal, but + // they are not equal and b is in fact a nullish value. + return ( + (comp === 0 && b !== a && (b === undefined || b === null || b !== b)) || + comp > 0 + ); +} + +function zipWithFactory(keyIter, zipper, iters, zipAll) { + var zipSequence = makeSequence(keyIter); + var sizes = new ArraySeq(iters).map(function (i) { return i.size; }); + zipSequence.size = zipAll ? sizes.max() : sizes.min(); + // Note: this a generic base implementation of __iterate in terms of + // __iterator which may be more generically useful in the future. + zipSequence.__iterate = function(fn, reverse) { + var this$1 = this; + + /* generic: + var iterator = this.__iterator(ITERATE_ENTRIES, reverse); + var step; + var iterations = 0; + while (!(step = iterator.next()).done) { + iterations++; + if (fn(step.value[1], step.value[0], this) === false) { + break; + } + } + return iterations; + */ + // indexed: + var iterator = this.__iterator(ITERATE_VALUES, reverse); + var step; + var iterations = 0; + while (!(step = iterator.next()).done) { + if (fn(step.value, iterations++, this$1) === false) { + break; + } + } + return iterations; + }; + zipSequence.__iteratorUncached = function(type, reverse) { + var iterators = iters.map( + function (i) { return ((i = Collection(i)), getIterator(reverse ? i.reverse() : i)); } + ); + var iterations = 0; + var isDone = false; + return new Iterator(function () { + var steps; + if (!isDone) { + steps = iterators.map(function (i) { return i.next(); }); + isDone = zipAll ? steps.every(function (s) { return s.done; }) : steps.some(function (s) { return s.done; }); + } + if (isDone) { + return iteratorDone(); + } + return iteratorValue( + type, + iterations++, + zipper.apply(null, steps.map(function (s) { return s.value; })) + ); + }); + }; + return zipSequence; +} + +// #pragma Helper Functions + +function reify(iter, seq) { + return iter === seq ? iter : isSeq(iter) ? seq : iter.constructor(seq); +} + +function validateEntry(entry) { + if (entry !== Object(entry)) { + throw new TypeError('Expected [K, V] tuple: ' + entry); + } +} + +function collectionClass(collection) { + return isKeyed(collection) + ? KeyedCollection + : isIndexed(collection) ? IndexedCollection : SetCollection; +} + +function makeSequence(collection) { + return Object.create( + (isKeyed(collection) + ? KeyedSeq + : isIndexed(collection) ? IndexedSeq : SetSeq + ).prototype + ); +} + +function cacheResultThrough() { + if (this._iter.cacheResult) { + this._iter.cacheResult(); + this.size = this._iter.size; + return this; + } + return Seq.prototype.cacheResult.call(this); +} + +function defaultComparator(a, b) { + if (a === undefined && b === undefined) { + return 0; + } + + if (a === undefined) { + return 1; + } + + if (b === undefined) { + return -1; + } + + return a > b ? 1 : a < b ? -1 : 0; +} + +// http://jsperf.com/copy-array-inline +function arrCopy(arr, offset) { + offset = offset || 0; + var len = Math.max(0, arr.length - offset); + var newArr = new Array(len); + for (var ii = 0; ii < len; ii++) { + newArr[ii] = arr[ii + offset]; + } + return newArr; +} + +function invariant(condition, error) { + if (!condition) { throw new Error(error); } +} + +function assertNotInfinite(size) { + invariant( + size !== Infinity, + 'Cannot perform this action with an infinite size.' + ); +} + +function coerceKeyPath(keyPath) { + if (isArrayLike(keyPath) && typeof keyPath !== 'string') { + return keyPath; + } + if (isOrdered(keyPath)) { + return keyPath.toArray(); + } + throw new TypeError( + 'Invalid keyPath: expected Ordered Collection or Array: ' + keyPath + ); +} + +function isPlainObj(value) { + return ( + value && (value.constructor === Object || value.constructor === undefined) + ); +} + +/** + * Returns true if the value is a potentially-persistent data structure, either + * provided by Immutable.js or a plain Array or Object. + */ +function isDataStructure(value) { + return isImmutable(value) || Array.isArray(value) || isPlainObj(value); +} + +/** + * Converts a value to a string, adding quotes if a string was provided. + */ +function quoteString(value) { + try { + return typeof value === 'string' ? JSON.stringify(value) : String(value); + } catch (_ignoreError) { + return JSON.stringify(value); + } +} + +function has(collection, key) { + return isImmutable(collection) + ? collection.has(key) + : isDataStructure(collection) && hasOwnProperty.call(collection, key); +} + +function get(collection, key, notSetValue) { + return isImmutable(collection) + ? collection.get(key, notSetValue) + : !has(collection, key) + ? notSetValue + : typeof collection.get === 'function' + ? collection.get(key) + : collection[key]; +} + +function shallowCopy(from) { + if (Array.isArray(from)) { + return arrCopy(from); + } + var to = {}; + for (var key in from) { + if (hasOwnProperty.call(from, key)) { + to[key] = from[key]; + } + } + return to; +} + +function remove(collection, key) { + if (!isDataStructure(collection)) { + throw new TypeError( + 'Cannot update non-data-structure value: ' + collection + ); + } + if (isImmutable(collection)) { + if (!collection.remove) { + throw new TypeError( + 'Cannot update immutable value without .remove() method: ' + collection + ); + } + return collection.remove(key); + } + if (!hasOwnProperty.call(collection, key)) { + return collection; + } + var collectionCopy = shallowCopy(collection); + if (Array.isArray(collectionCopy)) { + collectionCopy.splice(key, 1); + } else { + delete collectionCopy[key]; + } + return collectionCopy; +} + +function set(collection, key, value) { + if (!isDataStructure(collection)) { + throw new TypeError( + 'Cannot update non-data-structure value: ' + collection + ); + } + if (isImmutable(collection)) { + if (!collection.set) { + throw new TypeError( + 'Cannot update immutable value without .set() method: ' + collection + ); + } + return collection.set(key, value); + } + if (hasOwnProperty.call(collection, key) && value === collection[key]) { + return collection; + } + var collectionCopy = shallowCopy(collection); + collectionCopy[key] = value; + return collectionCopy; +} + +function updateIn(collection, keyPath, notSetValue, updater) { + if (!updater) { + updater = notSetValue; + notSetValue = undefined; + } + var updatedValue = updateInDeeply( + isImmutable(collection), + collection, + coerceKeyPath(keyPath), + 0, + notSetValue, + updater + ); + return updatedValue === NOT_SET ? notSetValue : updatedValue; +} + +function updateInDeeply( + inImmutable, + existing, + keyPath, + i, + notSetValue, + updater +) { + var wasNotSet = existing === NOT_SET; + if (i === keyPath.length) { + var existingValue = wasNotSet ? notSetValue : existing; + var newValue = updater(existingValue); + return newValue === existingValue ? existing : newValue; + } + if (!wasNotSet && !isDataStructure(existing)) { + throw new TypeError( + 'Cannot update within non-data-structure value in path [' + + keyPath.slice(0, i).map(quoteString) + + ']: ' + + existing + ); + } + var key = keyPath[i]; + var nextExisting = wasNotSet ? NOT_SET : get(existing, key, NOT_SET); + var nextUpdated = updateInDeeply( + nextExisting === NOT_SET ? inImmutable : isImmutable(nextExisting), + nextExisting, + keyPath, + i + 1, + notSetValue, + updater + ); + return nextUpdated === nextExisting + ? existing + : nextUpdated === NOT_SET + ? remove(existing, key) + : set( + wasNotSet ? (inImmutable ? emptyMap() : {}) : existing, + key, + nextUpdated + ); +} + +function setIn$1(collection, keyPath, value) { + return updateIn(collection, keyPath, NOT_SET, function () { return value; }); +} + +function setIn$$1(keyPath, v) { + return setIn$1(this, keyPath, v); +} + +function removeIn(collection, keyPath) { + return updateIn(collection, keyPath, function () { return NOT_SET; }); +} + +function deleteIn(keyPath) { + return removeIn(this, keyPath); +} + +function update$1(collection, key, notSetValue, updater) { + return updateIn(collection, [key], notSetValue, updater); +} + +function update$$1(key, notSetValue, updater) { + return arguments.length === 1 + ? key(this) + : update$1(this, key, notSetValue, updater); +} + +function updateIn$1(keyPath, notSetValue, updater) { + return updateIn(this, keyPath, notSetValue, updater); +} + +function merge() { + var iters = [], len = arguments.length; + while ( len-- ) iters[ len ] = arguments[ len ]; + + return mergeIntoKeyedWith(this, undefined, iters); +} + +function mergeWith(merger) { + var iters = [], len = arguments.length - 1; + while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; + + return mergeIntoKeyedWith(this, merger, iters); +} + +function mergeIntoKeyedWith(collection, merger, collections) { + var iters = []; + for (var ii = 0; ii < collections.length; ii++) { + var collection$1 = KeyedCollection(collections[ii]); + if (collection$1.size !== 0) { + iters.push(collection$1); + } + } + if (iters.length === 0) { + return collection; + } + if (collection.size === 0 && !collection.__ownerID && iters.length === 1) { + return collection.constructor(iters[0]); + } + return collection.withMutations(function (collection) { + var mergeIntoCollection = merger + ? function (value, key) { + update$1( + collection, + key, + NOT_SET, + function (oldVal) { return (oldVal === NOT_SET ? value : merger(oldVal, value, key)); } + ); + } + : function (value, key) { + collection.set(key, value); + }; + for (var ii = 0; ii < iters.length; ii++) { + iters[ii].forEach(mergeIntoCollection); + } + }); +} + +function merge$1(collection) { + var sources = [], len = arguments.length - 1; + while ( len-- > 0 ) sources[ len ] = arguments[ len + 1 ]; + + return mergeWithSources(undefined, collection, sources); +} + +function mergeWith$1(merger, collection) { + var sources = [], len = arguments.length - 2; + while ( len-- > 0 ) sources[ len ] = arguments[ len + 2 ]; + + return mergeWithSources(merger, collection, sources); +} + +function mergeDeep$1(collection) { + var sources = [], len = arguments.length - 1; + while ( len-- > 0 ) sources[ len ] = arguments[ len + 1 ]; + + return mergeWithSources(deepMergerWith(alwaysNewValue), collection, sources); +} + +function mergeDeepWith$1(merger, collection) { + var sources = [], len = arguments.length - 2; + while ( len-- > 0 ) sources[ len ] = arguments[ len + 2 ]; + + return mergeWithSources(deepMergerWith(merger), collection, sources); +} + +function mergeWithSources(merger, collection, sources) { + if (!isDataStructure(collection)) { + throw new TypeError( + 'Cannot merge into non-data-structure value: ' + collection + ); + } + if (isImmutable(collection)) { + return collection.mergeWith + ? collection.mergeWith.apply(collection, [ merger ].concat( sources )) + : collection.concat.apply(collection, sources); + } + var isArray = Array.isArray(collection); + var merged = collection; + var Collection$$1 = isArray ? IndexedCollection : KeyedCollection; + var mergeItem = isArray + ? function (value) { + // Copy on write + if (merged === collection) { + merged = shallowCopy(merged); + } + merged.push(value); + } + : function (value, key) { + var nextVal = + merger && hasOwnProperty.call(merged, key) + ? merger(merged[key], value, key) + : value; + if (!hasOwnProperty.call(merged, key) || nextVal !== merged[key]) { + // Copy on write + if (merged === collection) { + merged = shallowCopy(merged); + } + merged[key] = nextVal; + } + }; + for (var i = 0; i < sources.length; i++) { + Collection$$1(sources[i]).forEach(mergeItem); + } + return merged; } -function maxFactory(collection, comparator, mapper) { - if (!comparator) { - comparator = defaultComparator; - } - if (mapper) { - var entry = collection - .toSeq() - .map(function (v, k) { return [v, mapper(v, k, collection)]; }) - .reduce(function (a, b) { return (maxCompare(comparator, a[1], b[1]) ? b : a); }); - return entry && entry[0]; +function deepMergerWith(merger) { + function deepMerger(oldValue, newValue, key) { + if (isDataStructure(oldValue) && isDataStructure(newValue)) { + return mergeWithSources(deepMerger, oldValue, [newValue]); + } + var nextValue = merger(oldValue, newValue, key); + return is(oldValue, nextValue) ? oldValue : nextValue; } - return collection.reduce(function (a, b) { return (maxCompare(comparator, a, b) ? b : a); }); + return deepMerger; } -function maxCompare(comparator, a, b) { - var comp = comparator(b, a); - // b is considered the new max if the comparator declares them equal, but - // they are not equal and b is in fact a nullish value. - return ( - (comp === 0 && b !== a && (b === undefined || b === null || b !== b)) || - comp > 0 - ); +function alwaysNewValue(oldValue, newValue) { + return newValue; } -function zipWithFactory(keyIter, zipper, iters, zipAll) { - var zipSequence = makeSequence(keyIter); - var sizes = new ArraySeq(iters).map(function (i) { return i.size; }); - zipSequence.size = zipAll ? sizes.max() : sizes.min(); - // Note: this a generic base implementation of __iterate in terms of - // __iterator which may be more generically useful in the future. - zipSequence.__iterate = function(fn, reverse) { - var this$1 = this; +function mergeDeep$$1() { + var iters = [], len = arguments.length; + while ( len-- ) iters[ len ] = arguments[ len ]; - /* generic: - var iterator = this.__iterator(ITERATE_ENTRIES, reverse); - var step; - var iterations = 0; - while (!(step = iterator.next()).done) { - iterations++; - if (fn(step.value[1], step.value[0], this) === false) { - break; - } - } - return iterations; - */ - // indexed: - var iterator = this.__iterator(ITERATE_VALUES, reverse); - var step; - var iterations = 0; - while (!(step = iterator.next()).done) { - if (fn(step.value, iterations++, this$1) === false) { - break; - } - } - return iterations; - }; - zipSequence.__iteratorUncached = function(type, reverse) { - var iterators = iters.map( - function (i) { return ((i = Collection(i)), getIterator(reverse ? i.reverse() : i)); } - ); - var iterations = 0; - var isDone = false; - return new Iterator(function () { - var steps; - if (!isDone) { - steps = iterators.map(function (i) { return i.next(); }); - isDone = zipAll ? steps.every(function (s) { return s.done; }) : steps.some(function (s) { return s.done; }); - } - if (isDone) { - return iteratorDone(); - } - return iteratorValue( - type, - iterations++, - zipper.apply(null, steps.map(function (s) { return s.value; })) - ); - }); - }; - return zipSequence; + return mergeDeep$1.apply(void 0, [ this ].concat( iters )); } -// #pragma Helper Functions +function mergeDeepWith$$1(merger) { + var iters = [], len = arguments.length - 1; + while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; -function reify(iter, seq) { - return iter === seq ? iter : isSeq(iter) ? seq : iter.constructor(seq); + return mergeDeepWith$1.apply(void 0, [ merger, this ].concat( iters )); } -function validateEntry(entry) { - if (entry !== Object(entry)) { - throw new TypeError('Expected [K, V] tuple: ' + entry); - } -} +function mergeIn(keyPath) { + var iters = [], len = arguments.length - 1; + while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; -function collectionClass(collection) { - return isKeyed(collection) - ? KeyedCollection - : isIndexed(collection) ? IndexedCollection : SetCollection; + return updateIn(this, keyPath, emptyMap(), function (m) { return merge$1.apply(void 0, [ m ].concat( iters )); }); } -function makeSequence(collection) { - return Object.create( - (isKeyed(collection) - ? KeyedSeq - : isIndexed(collection) ? IndexedSeq : SetSeq - ).prototype - ); -} +function mergeDeepIn(keyPath) { + var iters = [], len = arguments.length - 1; + while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; -function cacheResultThrough() { - if (this._iter.cacheResult) { - this._iter.cacheResult(); - this.size = this._iter.size; - return this; - } - return Seq.prototype.cacheResult.call(this); + return updateIn(this, keyPath, emptyMap(), function (m) { return mergeDeep$1.apply(void 0, [ m ].concat( iters )); }); } -function defaultComparator(a, b) { - if (a === undefined && b === undefined) { - return 0; - } - - if (a === undefined) { - return 1; - } - - if (b === undefined) { - return -1; - } +function withMutations(fn) { + var mutable = this.asMutable(); + fn(mutable); + return mutable.wasAltered() ? mutable.__ensureOwner(this.__ownerID) : this; +} - return a > b ? 1 : a < b ? -1 : 0; +function asMutable() { + return this.__ownerID ? this : this.__ensureOwner(new OwnerID()); } -function invariant(condition, error) { - if (!condition) { throw new Error(error); } +function asImmutable() { + return this.__ensureOwner(); } -function assertNotInfinite(size) { - invariant( - size !== Infinity, - 'Cannot perform this action with an infinite size.' - ); +function wasAltered() { + return this.__altered; } var Map = (function (KeyedCollection$$1) { @@ -2198,18 +2309,10 @@ var Map = (function (KeyedCollection$$1) { return updateMap(this, k, v); }; - Map.prototype.setIn = function setIn$1 (keyPath, v) { - return setIn(this, keyPath, v); - }; - Map.prototype.remove = function remove (k) { return updateMap(this, k, NOT_SET); }; - Map.prototype.deleteIn = function deleteIn (keyPath) { - return removeIn(this, keyPath); - }; - Map.prototype.deleteAll = function deleteAll (keys) { var collection = Collection(keys); @@ -2222,16 +2325,6 @@ var Map = (function (KeyedCollection$$1) { }); }; - Map.prototype.update = function update$1 (key, notSetValue, updater) { - return arguments.length === 1 - ? key(this) - : update(this, key, notSetValue, updater); - }; - - Map.prototype.updateIn = function updateIn$1 (keyPath, notSetValue, updater) { - return updateIn(this, keyPath, notSetValue, updater); - }; - Map.prototype.clear = function clear () { if (this.size === 0) { return this; @@ -2248,45 +2341,6 @@ var Map = (function (KeyedCollection$$1) { // @pragma Composition - Map.prototype.merge = function merge$$1 (/*...iters*/) { - return mergeIntoMapWith(this, undefined, arguments); - }; - - Map.prototype.mergeWith = function mergeWith$$1 (merger) { - var iters = [], len = arguments.length - 1; - while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; - - return mergeIntoMapWith(this, merger, iters); - }; - - Map.prototype.mergeIn = function mergeIn (keyPath) { - var iters = [], len = arguments.length - 1; - while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; - - return updateIn(this, keyPath, emptyMap(), function (m) { return merge.apply(void 0, [ m ].concat( iters )); }); - }; - - Map.prototype.mergeDeep = function mergeDeep$1 () { - var iters = [], len = arguments.length; - while ( len-- ) iters[ len ] = arguments[ len ]; - - return mergeDeep.apply(void 0, [ this ].concat( iters )); - }; - - Map.prototype.mergeDeepWith = function mergeDeepWith$1 (merger) { - var iters = [], len = arguments.length - 1; - while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; - - return mergeDeepWith.apply(void 0, [ merger, this ].concat( iters )); - }; - - Map.prototype.mergeDeepIn = function mergeDeepIn (keyPath) { - var iters = [], len = arguments.length - 1; - while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; - - return updateIn(this, keyPath, emptyMap(), function (m) { return mergeDeep.apply(void 0, [ m ].concat( iters )); }); - }; - Map.prototype.sort = function sort (comparator) { // Late binding return OrderedMap(sortFactory(this, comparator)); @@ -2299,24 +2353,6 @@ var Map = (function (KeyedCollection$$1) { // @pragma Mutability - Map.prototype.withMutations = function withMutations (fn) { - var mutable = this.asMutable(); - fn(mutable); - return mutable.wasAltered() ? mutable.__ensureOwner(this.__ownerID) : this; - }; - - Map.prototype.asMutable = function asMutable () { - return this.__ownerID ? this : this.__ensureOwner(new OwnerID()); - }; - - Map.prototype.asImmutable = function asImmutable () { - return this.__ensureOwner(); - }; - - Map.prototype.wasAltered = function wasAltered () { - return this.__altered; - }; - Map.prototype.__iterator = function __iterator (type, reverse) { return new MapIterator(this, type, reverse); }; @@ -2362,10 +2398,22 @@ var IS_MAP_SENTINEL = '@@__IMMUTABLE_MAP__@@'; var MapPrototype = Map.prototype; MapPrototype[IS_MAP_SENTINEL] = true; MapPrototype[DELETE] = MapPrototype.remove; -MapPrototype.removeIn = MapPrototype.deleteIn; MapPrototype.removeAll = MapPrototype.deleteAll; MapPrototype.concat = MapPrototype.merge; -MapPrototype['@@transducer/init'] = MapPrototype.asMutable; +MapPrototype.setIn = setIn$$1; +MapPrototype.removeIn = MapPrototype.deleteIn = deleteIn; +MapPrototype.update = update$$1; +MapPrototype.updateIn = updateIn$1; +MapPrototype.merge = merge; +MapPrototype.mergeWith = mergeWith; +MapPrototype.mergeDeep = mergeDeep$$1; +MapPrototype.mergeDeepWith = mergeDeepWith$$1; +MapPrototype.mergeIn = mergeIn; +MapPrototype.mergeDeepIn = mergeDeepIn; +MapPrototype.withMutations = withMutations; +MapPrototype.wasAltered = wasAltered; +MapPrototype.asImmutable = asImmutable; +MapPrototype['@@transducer/init'] = MapPrototype.asMutable = asMutable; MapPrototype['@@transducer/step'] = function(result, arr) { return result.set(arr[0], arr[1]); }; @@ -2944,39 +2992,6 @@ function expandNodes(ownerID, nodes, bitmap, including, node) { return new HashArrayMapNode(ownerID, count + 1, expandedNodes); } -function mergeIntoMapWith(collection, merger, collections) { - var iters = []; - for (var ii = 0; ii < collections.length; ii++) { - var collection$1 = KeyedCollection(collections[ii]); - if (collection$1.size !== 0) { - iters.push(collection$1); - } - } - if (iters.length === 0) { - return collection; - } - if (collection.size === 0 && !collection.__ownerID && iters.length === 1) { - return collection.constructor(iters[0]); - } - return collection.withMutations(function (collection) { - var mergeIntoCollection = merger - ? function (value, key) { - update( - collection, - key, - NOT_SET, - function (oldVal) { return (oldVal === NOT_SET ? value : merger(oldVal, value, key)); } - ); - } - : function (value, key) { - collection.set(key, value); - }; - for (var ii = 0; ii < iters.length; ii++) { - iters[ii].forEach(mergeIntoCollection); - } - }); -} - function popCount(x) { x -= (x >> 1) & 0x55555555; x = (x & 0x33333333) + ((x >> 2) & 0x33333333); @@ -3251,21 +3266,22 @@ var ListPrototype = List.prototype; ListPrototype[IS_LIST_SENTINEL] = true; ListPrototype[DELETE] = ListPrototype.remove; ListPrototype.merge = ListPrototype.concat; -ListPrototype.setIn = MapPrototype.setIn; -ListPrototype.deleteIn = ListPrototype.removeIn = MapPrototype.removeIn; -ListPrototype.update = MapPrototype.update; -ListPrototype.updateIn = MapPrototype.updateIn; -ListPrototype.mergeIn = MapPrototype.mergeIn; -ListPrototype.mergeDeepIn = MapPrototype.mergeDeepIn; -ListPrototype.withMutations = MapPrototype.withMutations; -ListPrototype.asMutable = MapPrototype.asMutable; -ListPrototype.asImmutable = MapPrototype.asImmutable; -ListPrototype.wasAltered = MapPrototype.wasAltered; -ListPrototype['@@transducer/init'] = ListPrototype.asMutable; +ListPrototype.setIn = setIn$$1; +ListPrototype.deleteIn = ListPrototype.removeIn = deleteIn; +ListPrototype.update = update$$1; +ListPrototype.updateIn = updateIn$1; +ListPrototype.mergeIn = mergeIn; +ListPrototype.mergeDeepIn = mergeDeepIn; +ListPrototype.withMutations = withMutations; +ListPrototype.wasAltered = wasAltered; +ListPrototype.asImmutable = asImmutable; +ListPrototype['@@transducer/init'] = ListPrototype.asMutable = asMutable; ListPrototype['@@transducer/step'] = function(result, arr) { return result.push(arr); }; -ListPrototype['@@transducer/result'] = MapPrototype['@@transducer/result']; +ListPrototype['@@transducer/result'] = function(obj) { + return obj.asImmutable(); +}; var VNode = function VNode(array, ownerID) { this.array = array; @@ -4038,18 +4054,19 @@ var IS_STACK_SENTINEL = '@@__IMMUTABLE_STACK__@@'; var StackPrototype = Stack.prototype; StackPrototype[IS_STACK_SENTINEL] = true; -StackPrototype.withMutations = MapPrototype.withMutations; -StackPrototype.asMutable = MapPrototype.asMutable; -StackPrototype.asImmutable = MapPrototype.asImmutable; -StackPrototype.wasAltered = MapPrototype.wasAltered; StackPrototype.shift = StackPrototype.pop; StackPrototype.unshift = StackPrototype.push; StackPrototype.unshiftAll = StackPrototype.pushAll; -StackPrototype['@@transducer/init'] = StackPrototype.asMutable; +StackPrototype.withMutations = withMutations; +StackPrototype.wasAltered = wasAltered; +StackPrototype.asImmutable = asImmutable; +StackPrototype['@@transducer/init'] = StackPrototype.asMutable = asMutable; StackPrototype['@@transducer/step'] = function(result, arr) { return result.unshift(arr); }; -StackPrototype['@@transducer/result'] = MapPrototype['@@transducer/result']; +StackPrototype['@@transducer/result'] = function(obj) { + return obj.asImmutable(); +}; function makeStack(size, head, ownerID, hash) { var map = Object.create(StackPrototype); @@ -4066,22 +4083,6 @@ function emptyStack() { return EMPTY_STACK || (EMPTY_STACK = makeStack(0)); } -function getIn(collection, searchKeyPath, notSetValue) { - var keyPath = coerceKeyPath(searchKeyPath); - var i = 0; - while (i !== keyPath.length) { - collection = get(collection, keyPath[i++], NOT_SET); - if (collection === NOT_SET) { - return notSetValue; - } - } - return collection; -} - -function hasIn(collection, keyPath) { - return getIn(collection, keyPath, NOT_SET) !== NOT_SET; -} - function deepEqual(a, b) { if (a === b) { return true; @@ -4347,14 +4348,15 @@ var SetPrototype = Set.prototype; SetPrototype[IS_SET_SENTINEL] = true; SetPrototype[DELETE] = SetPrototype.remove; SetPrototype.merge = SetPrototype.concat = SetPrototype.union; -SetPrototype.withMutations = MapPrototype.withMutations; -SetPrototype.asMutable = MapPrototype.asMutable; -SetPrototype.asImmutable = MapPrototype.asImmutable; -SetPrototype['@@transducer/init'] = SetPrototype.asMutable; +SetPrototype.withMutations = withMutations; +SetPrototype.asImmutable = asImmutable; +SetPrototype['@@transducer/init'] = SetPrototype.asMutable = asMutable; SetPrototype['@@transducer/step'] = function(result, arr) { return result.add(arr); }; -SetPrototype['@@transducer/result'] = MapPrototype['@@transducer/result']; +SetPrototype['@@transducer/result'] = function(obj) { + return obj.asImmutable(); +}; SetPrototype.__empty = emptySet; SetPrototype.__make = makeSet; @@ -4522,6 +4524,39 @@ var Range = (function (IndexedSeq$$1) { var EMPTY_RANGE; +function getIn$1(collection, searchKeyPath, notSetValue) { + var keyPath = coerceKeyPath(searchKeyPath); + var i = 0; + while (i !== keyPath.length) { + collection = get(collection, keyPath[i++], NOT_SET); + if (collection === NOT_SET) { + return notSetValue; + } + } + return collection; +} + +function getIn$$1(searchKeyPath, notSetValue) { + return getIn$1(this, searchKeyPath, notSetValue); +} + +function hasIn$1(collection, keyPath) { + return getIn$1(collection, keyPath, NOT_SET) !== NOT_SET; +} + +function hasIn$$1(searchKeyPath) { + return hasIn$1(this, searchKeyPath); +} + +function toObject() { + assertNotInfinite(this.size); + var object = {}; + this.__iterate(function (v, k) { + object[k] = v; + }); + return object; +} + // Note: all of these methods are deprecated. Collection.isIterable = isCollection; Collection.isKeyed = isKeyed; @@ -4563,14 +4598,7 @@ mixin(Collection, { return Map(this.toKeyedSeq()); }, - toObject: function toObject() { - assertNotInfinite(this.size); - var object = {}; - this.__iterate(function (v, k) { - object[k] = v; - }); - return object; - }, + toObject: toObject, toOrderedMap: function toOrderedMap() { // Use Late Binding here to solve the circular dependency. @@ -4829,9 +4857,7 @@ mixin(Collection, { return this.find(function (_, key) { return is(key, searchKey); }, undefined, notSetValue); }, - getIn: function getIn$1(searchKeyPath, notSetValue) { - return getIn(this, searchKeyPath, notSetValue); - }, + getIn: getIn$$1, groupBy: function groupBy(grouper, context) { return groupByFactory(this, grouper, context); @@ -4841,9 +4867,7 @@ mixin(Collection, { return this.get(searchKey, NOT_SET) !== NOT_SET; }, - hasIn: function hasIn$1(searchKeyPath) { - return hasIn(this, searchKeyPath); - }, + hasIn: hasIn$$1, isSubset: function isSubset(iter) { iter = typeof iter.includes === 'function' ? iter : Collection(iter); @@ -5007,7 +5031,7 @@ mixin(KeyedCollection, { var KeyedCollectionPrototype = KeyedCollection.prototype; KeyedCollectionPrototype[IS_KEYED_SENTINEL] = true; KeyedCollectionPrototype[ITERATOR_SYMBOL] = CollectionPrototype.entries; -KeyedCollectionPrototype.toJSON = CollectionPrototype.toObject; +KeyedCollectionPrototype.toJSON = toObject; KeyedCollectionPrototype.__toStringMapper = function (v, k) { return quoteString(k) + ': ' + quoteString(v); }; mixin(IndexedCollection, { @@ -5451,6 +5475,10 @@ Record.prototype.toJS = function toJS$1 () { return toJS(this); }; +Record.prototype.entries = function entries () { + return this.__iterator(ITERATE_ENTRIES); +}; + Record.prototype.__iterator = function __iterator (type, reverse) { return recordSeq(this).__iterator(type, reverse); }; @@ -5477,26 +5505,27 @@ Record.getDescriptiveName = recordName; var RecordPrototype = Record.prototype; RecordPrototype[IS_RECORD_SENTINEL] = true; RecordPrototype[DELETE] = RecordPrototype.remove; -RecordPrototype.deleteIn = RecordPrototype.removeIn = MapPrototype.removeIn; -RecordPrototype.getIn = CollectionPrototype.getIn; +RecordPrototype.deleteIn = RecordPrototype.removeIn = deleteIn; +RecordPrototype.getIn = getIn$$1; RecordPrototype.hasIn = CollectionPrototype.hasIn; -RecordPrototype.merge = MapPrototype.merge; -RecordPrototype.mergeWith = MapPrototype.mergeWith; -RecordPrototype.mergeIn = MapPrototype.mergeIn; -RecordPrototype.mergeDeep = MapPrototype.mergeDeep; -RecordPrototype.mergeDeepWith = MapPrototype.mergeDeepWith; -RecordPrototype.mergeDeepIn = MapPrototype.mergeDeepIn; -RecordPrototype.setIn = MapPrototype.setIn; -RecordPrototype.update = MapPrototype.update; -RecordPrototype.updateIn = MapPrototype.updateIn; -RecordPrototype.withMutations = MapPrototype.withMutations; -RecordPrototype.asMutable = MapPrototype.asMutable; -RecordPrototype.asImmutable = MapPrototype.asImmutable; -RecordPrototype[ITERATOR_SYMBOL] = CollectionPrototype.entries; +RecordPrototype.merge = merge; +RecordPrototype.mergeWith = mergeWith; +RecordPrototype.mergeIn = mergeIn; +RecordPrototype.mergeDeep = mergeDeep$$1; +RecordPrototype.mergeDeepWith = mergeDeepWith$$1; +RecordPrototype.mergeDeepIn = mergeDeepIn; +RecordPrototype.setIn = setIn$$1; +RecordPrototype.update = update$$1; +RecordPrototype.updateIn = updateIn$1; +RecordPrototype.withMutations = withMutations; +RecordPrototype.asMutable = asMutable; +RecordPrototype.asImmutable = asImmutable; +RecordPrototype[ITERATOR_SYMBOL] = RecordPrototype.entries; RecordPrototype.toJSON = RecordPrototype.toObject = CollectionPrototype.toObject; -RecordPrototype.inspect = RecordPrototype.toSource = - CollectionPrototype.toSource; +RecordPrototype.inspect = RecordPrototype.toSource = function() { + return this.toString(); +}; function makeRecord(likeRecord, values, ownerID) { var record = Object.create(Object.getPrototypeOf(likeRecord)); @@ -5705,23 +5734,23 @@ var Immutable = { isValueObject: isValueObject, get: get, - getIn: getIn, + getIn: getIn$1, has: has, - hasIn: hasIn, - merge: merge, - mergeDeep: mergeDeep, - mergeWith: mergeWith, - mergeDeepWith: mergeDeepWith, + hasIn: hasIn$1, + merge: merge$1, + mergeDeep: mergeDeep$1, + mergeWith: mergeWith$1, + mergeDeepWith: mergeDeepWith$1, remove: remove, removeIn: removeIn, set: set, - setIn: setIn, - update: update, + setIn: setIn$1, + update: update$1, updateIn: updateIn }; // Note: Iterable is deprecated var Iterable = Collection; -export { version, Collection, Iterable, Seq, Map, OrderedMap, List, Stack, Set, OrderedSet, Record, Range, Repeat, is, fromJS, hash, isImmutable, isCollection, isKeyed, isIndexed, isAssociative, isOrdered, isValueObject, get, getIn, has, hasIn, merge, mergeDeep, mergeWith, mergeDeepWith, remove, removeIn, set, setIn, update, updateIn }; +export { version, Collection, Iterable, Seq, Map, OrderedMap, List, Stack, Set, OrderedSet, Record, Range, Repeat, is, fromJS, hash, isImmutable, isCollection, isKeyed, isIndexed, isAssociative, isOrdered, isValueObject, get, getIn$1 as getIn, has, hasIn$1 as hasIn, merge$1 as merge, mergeDeep$1 as mergeDeep, mergeWith$1 as mergeWith, mergeDeepWith$1 as mergeDeepWith, remove, removeIn, set, setIn$1 as setIn, update$1 as update, updateIn }; export default Immutable; diff --git a/dist/immutable.js b/dist/immutable.js index f142d27ec6..8a4492c25a 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -763,400 +763,120 @@ function is(valueA, valueB) { ); } -function coerceKeyPath(keyPath) { - if (isArrayLike(keyPath) && typeof keyPath !== 'string') { - return keyPath; - } - if (isOrdered(keyPath)) { - return keyPath.toArray(); - } - throw new TypeError( - 'Invalid keyPath: expected Ordered Collection or Array: ' + keyPath - ); -} - -function isPlainObj(value) { - return ( - value && (value.constructor === Object || value.constructor === undefined) - ); -} +var imul = + typeof Math.imul === 'function' && Math.imul(0xffffffff, 2) === -2 + ? Math.imul + : function imul(a, b) { + a |= 0; // int + b |= 0; // int + var c = a & 0xffff; + var d = b & 0xffff; + // Shift by 0 fixes the sign on the high part. + return (c * d + ((((a >>> 16) * d + c * (b >>> 16)) << 16) >>> 0)) | 0; // int + }; -/** - * Returns true if the value is a potentially-persistent data structure, either - * provided by Immutable.js or a plain Array or Object. - */ -function isDataStructure(value) { - return isImmutable(value) || Array.isArray(value) || isPlainObj(value); +// v8 has an optimization for storing 31-bit signed numbers. +// Values which have either 00 or 11 as the high order bits qualify. +// This function drops the highest order bit in a signed number, maintaining +// the sign bit. +function smi(i32) { + return ((i32 >>> 1) & 0x40000000) | (i32 & 0xbfffffff); } -/** - * Converts a value to a string, adding quotes if a string was provided. - */ -function quoteString(value) { - try { - return typeof value === 'string' ? JSON.stringify(value) : String(value); - } catch (_ignoreError) { - return JSON.stringify(value); +function hash(o) { + if (o === false || o === null || o === undefined) { + return 0; } -} - -function has(collection, key) { - return isImmutable(collection) - ? collection.has(key) - : isDataStructure(collection) && hasOwnProperty.call(collection, key); -} - -function get(collection, key, notSetValue) { - return isImmutable(collection) - ? collection.get(key, notSetValue) - : !has(collection, key) - ? notSetValue - : typeof collection.get === 'function' - ? collection.get(key) - : collection[key]; -} - -// http://jsperf.com/copy-array-inline -function arrCopy(arr, offset) { - offset = offset || 0; - var len = Math.max(0, arr.length - offset); - var newArr = new Array(len); - for (var ii = 0; ii < len; ii++) { - newArr[ii] = arr[ii + offset]; + if (typeof o.valueOf === 'function') { + o = o.valueOf(); + if (o === false || o === null || o === undefined) { + return 0; + } } - return newArr; -} - -function shallowCopy(from) { - if (Array.isArray(from)) { - return arrCopy(from); + if (o === true) { + return 1; } - var to = {}; - for (var key in from) { - if (hasOwnProperty.call(from, key)) { - to[key] = from[key]; + var type = typeof o; + if (type === 'number') { + if (o !== o || o === Infinity) { + return 0; + } + var h = o | 0; + if (h !== o) { + h ^= o * 0xffffffff; + } + while (o > 0xffffffff) { + o /= 0xffffffff; + h ^= o; } + return smi(h); } - return to; -} - -function remove(collection, key) { - if (!isDataStructure(collection)) { - throw new TypeError( - 'Cannot update non-data-structure value: ' + collection - ); + if (type === 'string') { + return o.length > STRING_HASH_CACHE_MIN_STRLEN + ? cachedHashString(o) + : hashString(o); } - if (isImmutable(collection)) { - if (!collection.remove) { - throw new TypeError( - 'Cannot update immutable value without .remove() method: ' + collection - ); - } - return collection.remove(key); + if (typeof o.hashCode === 'function') { + // Drop any high bits from accidentally long hash codes. + return smi(o.hashCode()); } - if (!hasOwnProperty.call(collection, key)) { - return collection; + if (type === 'object') { + return hashJSObj(o); } - var collectionCopy = shallowCopy(collection); - if (Array.isArray(collectionCopy)) { - collectionCopy.splice(key, 1); - } else { - delete collectionCopy[key]; + if (typeof o.toString === 'function') { + return hashString(o.toString()); } - return collectionCopy; + throw new Error('Value type ' + type + ' cannot be hashed.'); } -function set(collection, key, value) { - if (!isDataStructure(collection)) { - throw new TypeError( - 'Cannot update non-data-structure value: ' + collection - ); - } - if (isImmutable(collection)) { - if (!collection.set) { - throw new TypeError( - 'Cannot update immutable value without .set() method: ' + collection - ); +function cachedHashString(string) { + var hashed = stringHashCache[string]; + if (hashed === undefined) { + hashed = hashString(string); + if (STRING_HASH_CACHE_SIZE === STRING_HASH_CACHE_MAX_SIZE) { + STRING_HASH_CACHE_SIZE = 0; + stringHashCache = {}; } - return collection.set(key, value); - } - if (hasOwnProperty.call(collection, key) && value === collection[key]) { - return collection; + STRING_HASH_CACHE_SIZE++; + stringHashCache[string] = hashed; } - var collectionCopy = shallowCopy(collection); - collectionCopy[key] = value; - return collectionCopy; + return hashed; } -function updateIn(collection, keyPath, notSetValue, updater) { - if (!updater) { - updater = notSetValue; - notSetValue = undefined; +// http://jsperf.com/hashing-strings +function hashString(string) { + // This is the hash from JVM + // The hash code for a string is computed as + // s[0] * 31 ^ (n - 1) + s[1] * 31 ^ (n - 2) + ... + s[n - 1], + // where s[i] is the ith character of the string and n is the length of + // the string. We "mod" the result to make it between 0 (inclusive) and 2^31 + // (exclusive) by dropping high bits. + var hashed = 0; + for (var ii = 0; ii < string.length; ii++) { + hashed = (31 * hashed + string.charCodeAt(ii)) | 0; } - var updatedValue = updateInDeeply( - isImmutable(collection), - collection, - coerceKeyPath(keyPath), - 0, - notSetValue, - updater - ); - return updatedValue === NOT_SET ? notSetValue : updatedValue; + return smi(hashed); } -function updateInDeeply( - inImmutable, - existing, - keyPath, - i, - notSetValue, - updater -) { - var wasNotSet = existing === NOT_SET; - if (i === keyPath.length) { - var existingValue = wasNotSet ? notSetValue : existing; - var newValue = updater(existingValue); - return newValue === existingValue ? existing : newValue; - } - if (!wasNotSet && !isDataStructure(existing)) { - throw new TypeError( - 'Cannot update within non-data-structure value in path [' + - keyPath.slice(0, i).map(quoteString) + - ']: ' + - existing - ); +function hashJSObj(obj) { + var hashed; + if (usingWeakMap) { + hashed = weakMap.get(obj); + if (hashed !== undefined) { + return hashed; + } } - var key = keyPath[i]; - var nextExisting = wasNotSet ? NOT_SET : get(existing, key, NOT_SET); - var nextUpdated = updateInDeeply( - nextExisting === NOT_SET ? inImmutable : isImmutable(nextExisting), - nextExisting, - keyPath, - i + 1, - notSetValue, - updater - ); - return nextUpdated === nextExisting - ? existing - : nextUpdated === NOT_SET - ? remove(existing, key) - : set( - wasNotSet ? (inImmutable ? emptyMap() : {}) : existing, - key, - nextUpdated - ); -} -function setIn(collection, keyPath, value) { - return updateIn(collection, keyPath, NOT_SET, function () { return value; }); -} + hashed = obj[UID_HASH_KEY]; + if (hashed !== undefined) { + return hashed; + } -function update(collection, key, notSetValue, updater) { - return updateIn(collection, [key], notSetValue, updater); -} - -function removeIn(collection, keyPath) { - return updateIn(collection, keyPath, function () { return NOT_SET; }); -} - -function merge(collection) { - var sources = [], len = arguments.length - 1; - while ( len-- > 0 ) sources[ len ] = arguments[ len + 1 ]; - - return mergeWithSources(undefined, collection, sources); -} - -function mergeWith(merger, collection) { - var sources = [], len = arguments.length - 2; - while ( len-- > 0 ) sources[ len ] = arguments[ len + 2 ]; - - return mergeWithSources(merger, collection, sources); -} - -function mergeDeep(collection) { - var sources = [], len = arguments.length - 1; - while ( len-- > 0 ) sources[ len ] = arguments[ len + 1 ]; - - return mergeWithSources(deepMergerWith(alwaysNewValue), collection, sources); -} - -function mergeDeepWith(merger, collection) { - var sources = [], len = arguments.length - 2; - while ( len-- > 0 ) sources[ len ] = arguments[ len + 2 ]; - - return mergeWithSources(deepMergerWith(merger), collection, sources); -} - -function mergeWithSources(merger, collection, sources) { - if (!isDataStructure(collection)) { - throw new TypeError( - 'Cannot merge into non-data-structure value: ' + collection - ); - } - if (isImmutable(collection)) { - return collection.mergeWith - ? collection.mergeWith.apply(collection, [ merger ].concat( sources )) - : collection.concat.apply(collection, sources); - } - var isArray = Array.isArray(collection); - var merged = collection; - var Collection$$1 = isArray ? IndexedCollection : KeyedCollection; - var mergeItem = isArray - ? function (value) { - // Copy on write - if (merged === collection) { - merged = shallowCopy(merged); - } - merged.push(value); - } - : function (value, key) { - var nextVal = - merger && hasOwnProperty.call(merged, key) - ? merger(merged[key], value, key) - : value; - if (!hasOwnProperty.call(merged, key) || nextVal !== merged[key]) { - // Copy on write - if (merged === collection) { - merged = shallowCopy(merged); - } - merged[key] = nextVal; - } - }; - for (var i = 0; i < sources.length; i++) { - Collection$$1(sources[i]).forEach(mergeItem); - } - return merged; -} - -function deepMergerWith(merger) { - function deepMerger(oldValue, newValue, key) { - if (isDataStructure(oldValue) && isDataStructure(newValue)) { - return mergeWithSources(deepMerger, oldValue, [newValue]); - } - var nextValue = merger(oldValue, newValue, key); - return is(oldValue, nextValue) ? oldValue : nextValue; - } - return deepMerger; -} - -function alwaysNewValue(oldValue, newValue) { - return newValue; -} - -var imul = - typeof Math.imul === 'function' && Math.imul(0xffffffff, 2) === -2 - ? Math.imul - : function imul(a, b) { - a |= 0; // int - b |= 0; // int - var c = a & 0xffff; - var d = b & 0xffff; - // Shift by 0 fixes the sign on the high part. - return (c * d + ((((a >>> 16) * d + c * (b >>> 16)) << 16) >>> 0)) | 0; // int - }; - -// v8 has an optimization for storing 31-bit signed numbers. -// Values which have either 00 or 11 as the high order bits qualify. -// This function drops the highest order bit in a signed number, maintaining -// the sign bit. -function smi(i32) { - return ((i32 >>> 1) & 0x40000000) | (i32 & 0xbfffffff); -} - -function hash(o) { - if (o === false || o === null || o === undefined) { - return 0; - } - if (typeof o.valueOf === 'function') { - o = o.valueOf(); - if (o === false || o === null || o === undefined) { - return 0; - } - } - if (o === true) { - return 1; - } - var type = typeof o; - if (type === 'number') { - if (o !== o || o === Infinity) { - return 0; - } - var h = o | 0; - if (h !== o) { - h ^= o * 0xffffffff; - } - while (o > 0xffffffff) { - o /= 0xffffffff; - h ^= o; - } - return smi(h); - } - if (type === 'string') { - return o.length > STRING_HASH_CACHE_MIN_STRLEN - ? cachedHashString(o) - : hashString(o); - } - if (typeof o.hashCode === 'function') { - // Drop any high bits from accidentally long hash codes. - return smi(o.hashCode()); - } - if (type === 'object') { - return hashJSObj(o); - } - if (typeof o.toString === 'function') { - return hashString(o.toString()); - } - throw new Error('Value type ' + type + ' cannot be hashed.'); -} - -function cachedHashString(string) { - var hashed = stringHashCache[string]; - if (hashed === undefined) { - hashed = hashString(string); - if (STRING_HASH_CACHE_SIZE === STRING_HASH_CACHE_MAX_SIZE) { - STRING_HASH_CACHE_SIZE = 0; - stringHashCache = {}; - } - STRING_HASH_CACHE_SIZE++; - stringHashCache[string] = hashed; - } - return hashed; -} - -// http://jsperf.com/hashing-strings -function hashString(string) { - // This is the hash from JVM - // The hash code for a string is computed as - // s[0] * 31 ^ (n - 1) + s[1] * 31 ^ (n - 2) + ... + s[n - 1], - // where s[i] is the ith character of the string and n is the length of - // the string. We "mod" the result to make it between 0 (inclusive) and 2^31 - // (exclusive) by dropping high bits. - var hashed = 0; - for (var ii = 0; ii < string.length; ii++) { - hashed = (31 * hashed + string.charCodeAt(ii)) | 0; - } - return smi(hashed); -} - -function hashJSObj(obj) { - var hashed; - if (usingWeakMap) { - hashed = weakMap.get(obj); - if (hashed !== undefined) { - return hashed; - } - } - - hashed = obj[UID_HASH_KEY]; - if (hashed !== undefined) { - return hashed; - } - - if (!canDefineProperty) { - hashed = obj.propertyIsEnumerable && obj.propertyIsEnumerable[UID_HASH_KEY]; - if (hashed !== undefined) { - return hashed; - } + if (!canDefineProperty) { + hashed = obj.propertyIsEnumerable && obj.propertyIsEnumerable[UID_HASH_KEY]; + if (hashed !== undefined) { + return hashed; + } hashed = getIENodeHash(obj); if (hashed !== undefined) { @@ -2005,154 +1725,545 @@ function sortFactory(collection, comparator, mapper) { : function (v, i) { entries[i] = v[1]; } - ); - return isKeyedCollection - ? KeyedSeq(entries) - : isIndexed(collection) ? IndexedSeq(entries) : SetSeq(entries); + ); + return isKeyedCollection + ? KeyedSeq(entries) + : isIndexed(collection) ? IndexedSeq(entries) : SetSeq(entries); +} + +function maxFactory(collection, comparator, mapper) { + if (!comparator) { + comparator = defaultComparator; + } + if (mapper) { + var entry = collection + .toSeq() + .map(function (v, k) { return [v, mapper(v, k, collection)]; }) + .reduce(function (a, b) { return (maxCompare(comparator, a[1], b[1]) ? b : a); }); + return entry && entry[0]; + } + return collection.reduce(function (a, b) { return (maxCompare(comparator, a, b) ? b : a); }); +} + +function maxCompare(comparator, a, b) { + var comp = comparator(b, a); + // b is considered the new max if the comparator declares them equal, but + // they are not equal and b is in fact a nullish value. + return ( + (comp === 0 && b !== a && (b === undefined || b === null || b !== b)) || + comp > 0 + ); +} + +function zipWithFactory(keyIter, zipper, iters, zipAll) { + var zipSequence = makeSequence(keyIter); + var sizes = new ArraySeq(iters).map(function (i) { return i.size; }); + zipSequence.size = zipAll ? sizes.max() : sizes.min(); + // Note: this a generic base implementation of __iterate in terms of + // __iterator which may be more generically useful in the future. + zipSequence.__iterate = function(fn, reverse) { + var this$1 = this; + + /* generic: + var iterator = this.__iterator(ITERATE_ENTRIES, reverse); + var step; + var iterations = 0; + while (!(step = iterator.next()).done) { + iterations++; + if (fn(step.value[1], step.value[0], this) === false) { + break; + } + } + return iterations; + */ + // indexed: + var iterator = this.__iterator(ITERATE_VALUES, reverse); + var step; + var iterations = 0; + while (!(step = iterator.next()).done) { + if (fn(step.value, iterations++, this$1) === false) { + break; + } + } + return iterations; + }; + zipSequence.__iteratorUncached = function(type, reverse) { + var iterators = iters.map( + function (i) { return ((i = Collection(i)), getIterator(reverse ? i.reverse() : i)); } + ); + var iterations = 0; + var isDone = false; + return new Iterator(function () { + var steps; + if (!isDone) { + steps = iterators.map(function (i) { return i.next(); }); + isDone = zipAll ? steps.every(function (s) { return s.done; }) : steps.some(function (s) { return s.done; }); + } + if (isDone) { + return iteratorDone(); + } + return iteratorValue( + type, + iterations++, + zipper.apply(null, steps.map(function (s) { return s.value; })) + ); + }); + }; + return zipSequence; +} + +// #pragma Helper Functions + +function reify(iter, seq) { + return iter === seq ? iter : isSeq(iter) ? seq : iter.constructor(seq); +} + +function validateEntry(entry) { + if (entry !== Object(entry)) { + throw new TypeError('Expected [K, V] tuple: ' + entry); + } +} + +function collectionClass(collection) { + return isKeyed(collection) + ? KeyedCollection + : isIndexed(collection) ? IndexedCollection : SetCollection; +} + +function makeSequence(collection) { + return Object.create( + (isKeyed(collection) + ? KeyedSeq + : isIndexed(collection) ? IndexedSeq : SetSeq + ).prototype + ); +} + +function cacheResultThrough() { + if (this._iter.cacheResult) { + this._iter.cacheResult(); + this.size = this._iter.size; + return this; + } + return Seq.prototype.cacheResult.call(this); +} + +function defaultComparator(a, b) { + if (a === undefined && b === undefined) { + return 0; + } + + if (a === undefined) { + return 1; + } + + if (b === undefined) { + return -1; + } + + return a > b ? 1 : a < b ? -1 : 0; +} + +// http://jsperf.com/copy-array-inline +function arrCopy(arr, offset) { + offset = offset || 0; + var len = Math.max(0, arr.length - offset); + var newArr = new Array(len); + for (var ii = 0; ii < len; ii++) { + newArr[ii] = arr[ii + offset]; + } + return newArr; +} + +function invariant(condition, error) { + if (!condition) { throw new Error(error); } +} + +function assertNotInfinite(size) { + invariant( + size !== Infinity, + 'Cannot perform this action with an infinite size.' + ); +} + +function coerceKeyPath(keyPath) { + if (isArrayLike(keyPath) && typeof keyPath !== 'string') { + return keyPath; + } + if (isOrdered(keyPath)) { + return keyPath.toArray(); + } + throw new TypeError( + 'Invalid keyPath: expected Ordered Collection or Array: ' + keyPath + ); +} + +function isPlainObj(value) { + return ( + value && (value.constructor === Object || value.constructor === undefined) + ); +} + +/** + * Returns true if the value is a potentially-persistent data structure, either + * provided by Immutable.js or a plain Array or Object. + */ +function isDataStructure(value) { + return isImmutable(value) || Array.isArray(value) || isPlainObj(value); +} + +/** + * Converts a value to a string, adding quotes if a string was provided. + */ +function quoteString(value) { + try { + return typeof value === 'string' ? JSON.stringify(value) : String(value); + } catch (_ignoreError) { + return JSON.stringify(value); + } +} + +function has(collection, key) { + return isImmutable(collection) + ? collection.has(key) + : isDataStructure(collection) && hasOwnProperty.call(collection, key); +} + +function get(collection, key, notSetValue) { + return isImmutable(collection) + ? collection.get(key, notSetValue) + : !has(collection, key) + ? notSetValue + : typeof collection.get === 'function' + ? collection.get(key) + : collection[key]; +} + +function shallowCopy(from) { + if (Array.isArray(from)) { + return arrCopy(from); + } + var to = {}; + for (var key in from) { + if (hasOwnProperty.call(from, key)) { + to[key] = from[key]; + } + } + return to; +} + +function remove(collection, key) { + if (!isDataStructure(collection)) { + throw new TypeError( + 'Cannot update non-data-structure value: ' + collection + ); + } + if (isImmutable(collection)) { + if (!collection.remove) { + throw new TypeError( + 'Cannot update immutable value without .remove() method: ' + collection + ); + } + return collection.remove(key); + } + if (!hasOwnProperty.call(collection, key)) { + return collection; + } + var collectionCopy = shallowCopy(collection); + if (Array.isArray(collectionCopy)) { + collectionCopy.splice(key, 1); + } else { + delete collectionCopy[key]; + } + return collectionCopy; +} + +function set(collection, key, value) { + if (!isDataStructure(collection)) { + throw new TypeError( + 'Cannot update non-data-structure value: ' + collection + ); + } + if (isImmutable(collection)) { + if (!collection.set) { + throw new TypeError( + 'Cannot update immutable value without .set() method: ' + collection + ); + } + return collection.set(key, value); + } + if (hasOwnProperty.call(collection, key) && value === collection[key]) { + return collection; + } + var collectionCopy = shallowCopy(collection); + collectionCopy[key] = value; + return collectionCopy; +} + +function updateIn(collection, keyPath, notSetValue, updater) { + if (!updater) { + updater = notSetValue; + notSetValue = undefined; + } + var updatedValue = updateInDeeply( + isImmutable(collection), + collection, + coerceKeyPath(keyPath), + 0, + notSetValue, + updater + ); + return updatedValue === NOT_SET ? notSetValue : updatedValue; +} + +function updateInDeeply( + inImmutable, + existing, + keyPath, + i, + notSetValue, + updater +) { + var wasNotSet = existing === NOT_SET; + if (i === keyPath.length) { + var existingValue = wasNotSet ? notSetValue : existing; + var newValue = updater(existingValue); + return newValue === existingValue ? existing : newValue; + } + if (!wasNotSet && !isDataStructure(existing)) { + throw new TypeError( + 'Cannot update within non-data-structure value in path [' + + keyPath.slice(0, i).map(quoteString) + + ']: ' + + existing + ); + } + var key = keyPath[i]; + var nextExisting = wasNotSet ? NOT_SET : get(existing, key, NOT_SET); + var nextUpdated = updateInDeeply( + nextExisting === NOT_SET ? inImmutable : isImmutable(nextExisting), + nextExisting, + keyPath, + i + 1, + notSetValue, + updater + ); + return nextUpdated === nextExisting + ? existing + : nextUpdated === NOT_SET + ? remove(existing, key) + : set( + wasNotSet ? (inImmutable ? emptyMap() : {}) : existing, + key, + nextUpdated + ); +} + +function setIn$1(collection, keyPath, value) { + return updateIn(collection, keyPath, NOT_SET, function () { return value; }); +} + +function setIn$$1(keyPath, v) { + return setIn$1(this, keyPath, v); +} + +function removeIn(collection, keyPath) { + return updateIn(collection, keyPath, function () { return NOT_SET; }); +} + +function deleteIn(keyPath) { + return removeIn(this, keyPath); +} + +function update$1(collection, key, notSetValue, updater) { + return updateIn(collection, [key], notSetValue, updater); +} + +function update$$1(key, notSetValue, updater) { + return arguments.length === 1 + ? key(this) + : update$1(this, key, notSetValue, updater); +} + +function updateIn$1(keyPath, notSetValue, updater) { + return updateIn(this, keyPath, notSetValue, updater); +} + +function merge() { + var iters = [], len = arguments.length; + while ( len-- ) iters[ len ] = arguments[ len ]; + + return mergeIntoKeyedWith(this, undefined, iters); +} + +function mergeWith(merger) { + var iters = [], len = arguments.length - 1; + while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; + + return mergeIntoKeyedWith(this, merger, iters); +} + +function mergeIntoKeyedWith(collection, merger, collections) { + var iters = []; + for (var ii = 0; ii < collections.length; ii++) { + var collection$1 = KeyedCollection(collections[ii]); + if (collection$1.size !== 0) { + iters.push(collection$1); + } + } + if (iters.length === 0) { + return collection; + } + if (collection.size === 0 && !collection.__ownerID && iters.length === 1) { + return collection.constructor(iters[0]); + } + return collection.withMutations(function (collection) { + var mergeIntoCollection = merger + ? function (value, key) { + update$1( + collection, + key, + NOT_SET, + function (oldVal) { return (oldVal === NOT_SET ? value : merger(oldVal, value, key)); } + ); + } + : function (value, key) { + collection.set(key, value); + }; + for (var ii = 0; ii < iters.length; ii++) { + iters[ii].forEach(mergeIntoCollection); + } + }); +} + +function merge$1(collection) { + var sources = [], len = arguments.length - 1; + while ( len-- > 0 ) sources[ len ] = arguments[ len + 1 ]; + + return mergeWithSources(undefined, collection, sources); +} + +function mergeWith$1(merger, collection) { + var sources = [], len = arguments.length - 2; + while ( len-- > 0 ) sources[ len ] = arguments[ len + 2 ]; + + return mergeWithSources(merger, collection, sources); +} + +function mergeDeep$1(collection) { + var sources = [], len = arguments.length - 1; + while ( len-- > 0 ) sources[ len ] = arguments[ len + 1 ]; + + return mergeWithSources(deepMergerWith(alwaysNewValue), collection, sources); +} + +function mergeDeepWith$1(merger, collection) { + var sources = [], len = arguments.length - 2; + while ( len-- > 0 ) sources[ len ] = arguments[ len + 2 ]; + + return mergeWithSources(deepMergerWith(merger), collection, sources); +} + +function mergeWithSources(merger, collection, sources) { + if (!isDataStructure(collection)) { + throw new TypeError( + 'Cannot merge into non-data-structure value: ' + collection + ); + } + if (isImmutable(collection)) { + return collection.mergeWith + ? collection.mergeWith.apply(collection, [ merger ].concat( sources )) + : collection.concat.apply(collection, sources); + } + var isArray = Array.isArray(collection); + var merged = collection; + var Collection$$1 = isArray ? IndexedCollection : KeyedCollection; + var mergeItem = isArray + ? function (value) { + // Copy on write + if (merged === collection) { + merged = shallowCopy(merged); + } + merged.push(value); + } + : function (value, key) { + var nextVal = + merger && hasOwnProperty.call(merged, key) + ? merger(merged[key], value, key) + : value; + if (!hasOwnProperty.call(merged, key) || nextVal !== merged[key]) { + // Copy on write + if (merged === collection) { + merged = shallowCopy(merged); + } + merged[key] = nextVal; + } + }; + for (var i = 0; i < sources.length; i++) { + Collection$$1(sources[i]).forEach(mergeItem); + } + return merged; } -function maxFactory(collection, comparator, mapper) { - if (!comparator) { - comparator = defaultComparator; - } - if (mapper) { - var entry = collection - .toSeq() - .map(function (v, k) { return [v, mapper(v, k, collection)]; }) - .reduce(function (a, b) { return (maxCompare(comparator, a[1], b[1]) ? b : a); }); - return entry && entry[0]; +function deepMergerWith(merger) { + function deepMerger(oldValue, newValue, key) { + if (isDataStructure(oldValue) && isDataStructure(newValue)) { + return mergeWithSources(deepMerger, oldValue, [newValue]); + } + var nextValue = merger(oldValue, newValue, key); + return is(oldValue, nextValue) ? oldValue : nextValue; } - return collection.reduce(function (a, b) { return (maxCompare(comparator, a, b) ? b : a); }); + return deepMerger; } -function maxCompare(comparator, a, b) { - var comp = comparator(b, a); - // b is considered the new max if the comparator declares them equal, but - // they are not equal and b is in fact a nullish value. - return ( - (comp === 0 && b !== a && (b === undefined || b === null || b !== b)) || - comp > 0 - ); +function alwaysNewValue(oldValue, newValue) { + return newValue; } -function zipWithFactory(keyIter, zipper, iters, zipAll) { - var zipSequence = makeSequence(keyIter); - var sizes = new ArraySeq(iters).map(function (i) { return i.size; }); - zipSequence.size = zipAll ? sizes.max() : sizes.min(); - // Note: this a generic base implementation of __iterate in terms of - // __iterator which may be more generically useful in the future. - zipSequence.__iterate = function(fn, reverse) { - var this$1 = this; +function mergeDeep$$1() { + var iters = [], len = arguments.length; + while ( len-- ) iters[ len ] = arguments[ len ]; - /* generic: - var iterator = this.__iterator(ITERATE_ENTRIES, reverse); - var step; - var iterations = 0; - while (!(step = iterator.next()).done) { - iterations++; - if (fn(step.value[1], step.value[0], this) === false) { - break; - } - } - return iterations; - */ - // indexed: - var iterator = this.__iterator(ITERATE_VALUES, reverse); - var step; - var iterations = 0; - while (!(step = iterator.next()).done) { - if (fn(step.value, iterations++, this$1) === false) { - break; - } - } - return iterations; - }; - zipSequence.__iteratorUncached = function(type, reverse) { - var iterators = iters.map( - function (i) { return ((i = Collection(i)), getIterator(reverse ? i.reverse() : i)); } - ); - var iterations = 0; - var isDone = false; - return new Iterator(function () { - var steps; - if (!isDone) { - steps = iterators.map(function (i) { return i.next(); }); - isDone = zipAll ? steps.every(function (s) { return s.done; }) : steps.some(function (s) { return s.done; }); - } - if (isDone) { - return iteratorDone(); - } - return iteratorValue( - type, - iterations++, - zipper.apply(null, steps.map(function (s) { return s.value; })) - ); - }); - }; - return zipSequence; + return mergeDeep$1.apply(void 0, [ this ].concat( iters )); } -// #pragma Helper Functions +function mergeDeepWith$$1(merger) { + var iters = [], len = arguments.length - 1; + while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; -function reify(iter, seq) { - return iter === seq ? iter : isSeq(iter) ? seq : iter.constructor(seq); + return mergeDeepWith$1.apply(void 0, [ merger, this ].concat( iters )); } -function validateEntry(entry) { - if (entry !== Object(entry)) { - throw new TypeError('Expected [K, V] tuple: ' + entry); - } -} +function mergeIn(keyPath) { + var iters = [], len = arguments.length - 1; + while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; -function collectionClass(collection) { - return isKeyed(collection) - ? KeyedCollection - : isIndexed(collection) ? IndexedCollection : SetCollection; + return updateIn(this, keyPath, emptyMap(), function (m) { return merge$1.apply(void 0, [ m ].concat( iters )); }); } -function makeSequence(collection) { - return Object.create( - (isKeyed(collection) - ? KeyedSeq - : isIndexed(collection) ? IndexedSeq : SetSeq - ).prototype - ); -} +function mergeDeepIn(keyPath) { + var iters = [], len = arguments.length - 1; + while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; -function cacheResultThrough() { - if (this._iter.cacheResult) { - this._iter.cacheResult(); - this.size = this._iter.size; - return this; - } - return Seq.prototype.cacheResult.call(this); + return updateIn(this, keyPath, emptyMap(), function (m) { return mergeDeep$1.apply(void 0, [ m ].concat( iters )); }); } -function defaultComparator(a, b) { - if (a === undefined && b === undefined) { - return 0; - } - - if (a === undefined) { - return 1; - } - - if (b === undefined) { - return -1; - } +function withMutations(fn) { + var mutable = this.asMutable(); + fn(mutable); + return mutable.wasAltered() ? mutable.__ensureOwner(this.__ownerID) : this; +} - return a > b ? 1 : a < b ? -1 : 0; +function asMutable() { + return this.__ownerID ? this : this.__ensureOwner(new OwnerID()); } -function invariant(condition, error) { - if (!condition) { throw new Error(error); } +function asImmutable() { + return this.__ensureOwner(); } -function assertNotInfinite(size) { - invariant( - size !== Infinity, - 'Cannot perform this action with an infinite size.' - ); +function wasAltered() { + return this.__altered; } var Map = (function (KeyedCollection$$1) { @@ -2204,18 +2315,10 @@ var Map = (function (KeyedCollection$$1) { return updateMap(this, k, v); }; - Map.prototype.setIn = function setIn$1 (keyPath, v) { - return setIn(this, keyPath, v); - }; - Map.prototype.remove = function remove (k) { return updateMap(this, k, NOT_SET); }; - Map.prototype.deleteIn = function deleteIn (keyPath) { - return removeIn(this, keyPath); - }; - Map.prototype.deleteAll = function deleteAll (keys) { var collection = Collection(keys); @@ -2228,16 +2331,6 @@ var Map = (function (KeyedCollection$$1) { }); }; - Map.prototype.update = function update$1 (key, notSetValue, updater) { - return arguments.length === 1 - ? key(this) - : update(this, key, notSetValue, updater); - }; - - Map.prototype.updateIn = function updateIn$1 (keyPath, notSetValue, updater) { - return updateIn(this, keyPath, notSetValue, updater); - }; - Map.prototype.clear = function clear () { if (this.size === 0) { return this; @@ -2254,45 +2347,6 @@ var Map = (function (KeyedCollection$$1) { // @pragma Composition - Map.prototype.merge = function merge$$1 (/*...iters*/) { - return mergeIntoMapWith(this, undefined, arguments); - }; - - Map.prototype.mergeWith = function mergeWith$$1 (merger) { - var iters = [], len = arguments.length - 1; - while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; - - return mergeIntoMapWith(this, merger, iters); - }; - - Map.prototype.mergeIn = function mergeIn (keyPath) { - var iters = [], len = arguments.length - 1; - while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; - - return updateIn(this, keyPath, emptyMap(), function (m) { return merge.apply(void 0, [ m ].concat( iters )); }); - }; - - Map.prototype.mergeDeep = function mergeDeep$1 () { - var iters = [], len = arguments.length; - while ( len-- ) iters[ len ] = arguments[ len ]; - - return mergeDeep.apply(void 0, [ this ].concat( iters )); - }; - - Map.prototype.mergeDeepWith = function mergeDeepWith$1 (merger) { - var iters = [], len = arguments.length - 1; - while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; - - return mergeDeepWith.apply(void 0, [ merger, this ].concat( iters )); - }; - - Map.prototype.mergeDeepIn = function mergeDeepIn (keyPath) { - var iters = [], len = arguments.length - 1; - while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; - - return updateIn(this, keyPath, emptyMap(), function (m) { return mergeDeep.apply(void 0, [ m ].concat( iters )); }); - }; - Map.prototype.sort = function sort (comparator) { // Late binding return OrderedMap(sortFactory(this, comparator)); @@ -2305,24 +2359,6 @@ var Map = (function (KeyedCollection$$1) { // @pragma Mutability - Map.prototype.withMutations = function withMutations (fn) { - var mutable = this.asMutable(); - fn(mutable); - return mutable.wasAltered() ? mutable.__ensureOwner(this.__ownerID) : this; - }; - - Map.prototype.asMutable = function asMutable () { - return this.__ownerID ? this : this.__ensureOwner(new OwnerID()); - }; - - Map.prototype.asImmutable = function asImmutable () { - return this.__ensureOwner(); - }; - - Map.prototype.wasAltered = function wasAltered () { - return this.__altered; - }; - Map.prototype.__iterator = function __iterator (type, reverse) { return new MapIterator(this, type, reverse); }; @@ -2368,10 +2404,22 @@ var IS_MAP_SENTINEL = '@@__IMMUTABLE_MAP__@@'; var MapPrototype = Map.prototype; MapPrototype[IS_MAP_SENTINEL] = true; MapPrototype[DELETE] = MapPrototype.remove; -MapPrototype.removeIn = MapPrototype.deleteIn; MapPrototype.removeAll = MapPrototype.deleteAll; MapPrototype.concat = MapPrototype.merge; -MapPrototype['@@transducer/init'] = MapPrototype.asMutable; +MapPrototype.setIn = setIn$$1; +MapPrototype.removeIn = MapPrototype.deleteIn = deleteIn; +MapPrototype.update = update$$1; +MapPrototype.updateIn = updateIn$1; +MapPrototype.merge = merge; +MapPrototype.mergeWith = mergeWith; +MapPrototype.mergeDeep = mergeDeep$$1; +MapPrototype.mergeDeepWith = mergeDeepWith$$1; +MapPrototype.mergeIn = mergeIn; +MapPrototype.mergeDeepIn = mergeDeepIn; +MapPrototype.withMutations = withMutations; +MapPrototype.wasAltered = wasAltered; +MapPrototype.asImmutable = asImmutable; +MapPrototype['@@transducer/init'] = MapPrototype.asMutable = asMutable; MapPrototype['@@transducer/step'] = function(result, arr) { return result.set(arr[0], arr[1]); }; @@ -2950,39 +2998,6 @@ function expandNodes(ownerID, nodes, bitmap, including, node) { return new HashArrayMapNode(ownerID, count + 1, expandedNodes); } -function mergeIntoMapWith(collection, merger, collections) { - var iters = []; - for (var ii = 0; ii < collections.length; ii++) { - var collection$1 = KeyedCollection(collections[ii]); - if (collection$1.size !== 0) { - iters.push(collection$1); - } - } - if (iters.length === 0) { - return collection; - } - if (collection.size === 0 && !collection.__ownerID && iters.length === 1) { - return collection.constructor(iters[0]); - } - return collection.withMutations(function (collection) { - var mergeIntoCollection = merger - ? function (value, key) { - update( - collection, - key, - NOT_SET, - function (oldVal) { return (oldVal === NOT_SET ? value : merger(oldVal, value, key)); } - ); - } - : function (value, key) { - collection.set(key, value); - }; - for (var ii = 0; ii < iters.length; ii++) { - iters[ii].forEach(mergeIntoCollection); - } - }); -} - function popCount(x) { x -= (x >> 1) & 0x55555555; x = (x & 0x33333333) + ((x >> 2) & 0x33333333); @@ -3257,21 +3272,22 @@ var ListPrototype = List.prototype; ListPrototype[IS_LIST_SENTINEL] = true; ListPrototype[DELETE] = ListPrototype.remove; ListPrototype.merge = ListPrototype.concat; -ListPrototype.setIn = MapPrototype.setIn; -ListPrototype.deleteIn = ListPrototype.removeIn = MapPrototype.removeIn; -ListPrototype.update = MapPrototype.update; -ListPrototype.updateIn = MapPrototype.updateIn; -ListPrototype.mergeIn = MapPrototype.mergeIn; -ListPrototype.mergeDeepIn = MapPrototype.mergeDeepIn; -ListPrototype.withMutations = MapPrototype.withMutations; -ListPrototype.asMutable = MapPrototype.asMutable; -ListPrototype.asImmutable = MapPrototype.asImmutable; -ListPrototype.wasAltered = MapPrototype.wasAltered; -ListPrototype['@@transducer/init'] = ListPrototype.asMutable; +ListPrototype.setIn = setIn$$1; +ListPrototype.deleteIn = ListPrototype.removeIn = deleteIn; +ListPrototype.update = update$$1; +ListPrototype.updateIn = updateIn$1; +ListPrototype.mergeIn = mergeIn; +ListPrototype.mergeDeepIn = mergeDeepIn; +ListPrototype.withMutations = withMutations; +ListPrototype.wasAltered = wasAltered; +ListPrototype.asImmutable = asImmutable; +ListPrototype['@@transducer/init'] = ListPrototype.asMutable = asMutable; ListPrototype['@@transducer/step'] = function(result, arr) { return result.push(arr); }; -ListPrototype['@@transducer/result'] = MapPrototype['@@transducer/result']; +ListPrototype['@@transducer/result'] = function(obj) { + return obj.asImmutable(); +}; var VNode = function VNode(array, ownerID) { this.array = array; @@ -4044,18 +4060,19 @@ var IS_STACK_SENTINEL = '@@__IMMUTABLE_STACK__@@'; var StackPrototype = Stack.prototype; StackPrototype[IS_STACK_SENTINEL] = true; -StackPrototype.withMutations = MapPrototype.withMutations; -StackPrototype.asMutable = MapPrototype.asMutable; -StackPrototype.asImmutable = MapPrototype.asImmutable; -StackPrototype.wasAltered = MapPrototype.wasAltered; StackPrototype.shift = StackPrototype.pop; StackPrototype.unshift = StackPrototype.push; StackPrototype.unshiftAll = StackPrototype.pushAll; -StackPrototype['@@transducer/init'] = StackPrototype.asMutable; +StackPrototype.withMutations = withMutations; +StackPrototype.wasAltered = wasAltered; +StackPrototype.asImmutable = asImmutable; +StackPrototype['@@transducer/init'] = StackPrototype.asMutable = asMutable; StackPrototype['@@transducer/step'] = function(result, arr) { return result.unshift(arr); }; -StackPrototype['@@transducer/result'] = MapPrototype['@@transducer/result']; +StackPrototype['@@transducer/result'] = function(obj) { + return obj.asImmutable(); +}; function makeStack(size, head, ownerID, hash) { var map = Object.create(StackPrototype); @@ -4072,22 +4089,6 @@ function emptyStack() { return EMPTY_STACK || (EMPTY_STACK = makeStack(0)); } -function getIn(collection, searchKeyPath, notSetValue) { - var keyPath = coerceKeyPath(searchKeyPath); - var i = 0; - while (i !== keyPath.length) { - collection = get(collection, keyPath[i++], NOT_SET); - if (collection === NOT_SET) { - return notSetValue; - } - } - return collection; -} - -function hasIn(collection, keyPath) { - return getIn(collection, keyPath, NOT_SET) !== NOT_SET; -} - function deepEqual(a, b) { if (a === b) { return true; @@ -4353,14 +4354,15 @@ var SetPrototype = Set.prototype; SetPrototype[IS_SET_SENTINEL] = true; SetPrototype[DELETE] = SetPrototype.remove; SetPrototype.merge = SetPrototype.concat = SetPrototype.union; -SetPrototype.withMutations = MapPrototype.withMutations; -SetPrototype.asMutable = MapPrototype.asMutable; -SetPrototype.asImmutable = MapPrototype.asImmutable; -SetPrototype['@@transducer/init'] = SetPrototype.asMutable; +SetPrototype.withMutations = withMutations; +SetPrototype.asImmutable = asImmutable; +SetPrototype['@@transducer/init'] = SetPrototype.asMutable = asMutable; SetPrototype['@@transducer/step'] = function(result, arr) { return result.add(arr); }; -SetPrototype['@@transducer/result'] = MapPrototype['@@transducer/result']; +SetPrototype['@@transducer/result'] = function(obj) { + return obj.asImmutable(); +}; SetPrototype.__empty = emptySet; SetPrototype.__make = makeSet; @@ -4528,6 +4530,39 @@ var Range = (function (IndexedSeq$$1) { var EMPTY_RANGE; +function getIn$1(collection, searchKeyPath, notSetValue) { + var keyPath = coerceKeyPath(searchKeyPath); + var i = 0; + while (i !== keyPath.length) { + collection = get(collection, keyPath[i++], NOT_SET); + if (collection === NOT_SET) { + return notSetValue; + } + } + return collection; +} + +function getIn$$1(searchKeyPath, notSetValue) { + return getIn$1(this, searchKeyPath, notSetValue); +} + +function hasIn$1(collection, keyPath) { + return getIn$1(collection, keyPath, NOT_SET) !== NOT_SET; +} + +function hasIn$$1(searchKeyPath) { + return hasIn$1(this, searchKeyPath); +} + +function toObject() { + assertNotInfinite(this.size); + var object = {}; + this.__iterate(function (v, k) { + object[k] = v; + }); + return object; +} + // Note: all of these methods are deprecated. Collection.isIterable = isCollection; Collection.isKeyed = isKeyed; @@ -4569,14 +4604,7 @@ mixin(Collection, { return Map(this.toKeyedSeq()); }, - toObject: function toObject() { - assertNotInfinite(this.size); - var object = {}; - this.__iterate(function (v, k) { - object[k] = v; - }); - return object; - }, + toObject: toObject, toOrderedMap: function toOrderedMap() { // Use Late Binding here to solve the circular dependency. @@ -4835,9 +4863,7 @@ mixin(Collection, { return this.find(function (_, key) { return is(key, searchKey); }, undefined, notSetValue); }, - getIn: function getIn$1(searchKeyPath, notSetValue) { - return getIn(this, searchKeyPath, notSetValue); - }, + getIn: getIn$$1, groupBy: function groupBy(grouper, context) { return groupByFactory(this, grouper, context); @@ -4847,9 +4873,7 @@ mixin(Collection, { return this.get(searchKey, NOT_SET) !== NOT_SET; }, - hasIn: function hasIn$1(searchKeyPath) { - return hasIn(this, searchKeyPath); - }, + hasIn: hasIn$$1, isSubset: function isSubset(iter) { iter = typeof iter.includes === 'function' ? iter : Collection(iter); @@ -5013,7 +5037,7 @@ mixin(KeyedCollection, { var KeyedCollectionPrototype = KeyedCollection.prototype; KeyedCollectionPrototype[IS_KEYED_SENTINEL] = true; KeyedCollectionPrototype[ITERATOR_SYMBOL] = CollectionPrototype.entries; -KeyedCollectionPrototype.toJSON = CollectionPrototype.toObject; +KeyedCollectionPrototype.toJSON = toObject; KeyedCollectionPrototype.__toStringMapper = function (v, k) { return quoteString(k) + ': ' + quoteString(v); }; mixin(IndexedCollection, { @@ -5457,6 +5481,10 @@ Record.prototype.toJS = function toJS$1 () { return toJS(this); }; +Record.prototype.entries = function entries () { + return this.__iterator(ITERATE_ENTRIES); +}; + Record.prototype.__iterator = function __iterator (type, reverse) { return recordSeq(this).__iterator(type, reverse); }; @@ -5483,26 +5511,27 @@ Record.getDescriptiveName = recordName; var RecordPrototype = Record.prototype; RecordPrototype[IS_RECORD_SENTINEL] = true; RecordPrototype[DELETE] = RecordPrototype.remove; -RecordPrototype.deleteIn = RecordPrototype.removeIn = MapPrototype.removeIn; -RecordPrototype.getIn = CollectionPrototype.getIn; +RecordPrototype.deleteIn = RecordPrototype.removeIn = deleteIn; +RecordPrototype.getIn = getIn$$1; RecordPrototype.hasIn = CollectionPrototype.hasIn; -RecordPrototype.merge = MapPrototype.merge; -RecordPrototype.mergeWith = MapPrototype.mergeWith; -RecordPrototype.mergeIn = MapPrototype.mergeIn; -RecordPrototype.mergeDeep = MapPrototype.mergeDeep; -RecordPrototype.mergeDeepWith = MapPrototype.mergeDeepWith; -RecordPrototype.mergeDeepIn = MapPrototype.mergeDeepIn; -RecordPrototype.setIn = MapPrototype.setIn; -RecordPrototype.update = MapPrototype.update; -RecordPrototype.updateIn = MapPrototype.updateIn; -RecordPrototype.withMutations = MapPrototype.withMutations; -RecordPrototype.asMutable = MapPrototype.asMutable; -RecordPrototype.asImmutable = MapPrototype.asImmutable; -RecordPrototype[ITERATOR_SYMBOL] = CollectionPrototype.entries; +RecordPrototype.merge = merge; +RecordPrototype.mergeWith = mergeWith; +RecordPrototype.mergeIn = mergeIn; +RecordPrototype.mergeDeep = mergeDeep$$1; +RecordPrototype.mergeDeepWith = mergeDeepWith$$1; +RecordPrototype.mergeDeepIn = mergeDeepIn; +RecordPrototype.setIn = setIn$$1; +RecordPrototype.update = update$$1; +RecordPrototype.updateIn = updateIn$1; +RecordPrototype.withMutations = withMutations; +RecordPrototype.asMutable = asMutable; +RecordPrototype.asImmutable = asImmutable; +RecordPrototype[ITERATOR_SYMBOL] = RecordPrototype.entries; RecordPrototype.toJSON = RecordPrototype.toObject = CollectionPrototype.toObject; -RecordPrototype.inspect = RecordPrototype.toSource = - CollectionPrototype.toSource; +RecordPrototype.inspect = RecordPrototype.toSource = function() { + return this.toString(); +}; function makeRecord(likeRecord, values, ownerID) { var record = Object.create(Object.getPrototypeOf(likeRecord)); @@ -5711,18 +5740,18 @@ var Immutable = { isValueObject: isValueObject, get: get, - getIn: getIn, + getIn: getIn$1, has: has, - hasIn: hasIn, - merge: merge, - mergeDeep: mergeDeep, - mergeWith: mergeWith, - mergeDeepWith: mergeDeepWith, + hasIn: hasIn$1, + merge: merge$1, + mergeDeep: mergeDeep$1, + mergeWith: mergeWith$1, + mergeDeepWith: mergeDeepWith$1, remove: remove, removeIn: removeIn, set: set, - setIn: setIn, - update: update, + setIn: setIn$1, + update: update$1, updateIn: updateIn }; @@ -5754,18 +5783,18 @@ exports.isAssociative = isAssociative; exports.isOrdered = isOrdered; exports.isValueObject = isValueObject; exports.get = get; -exports.getIn = getIn; +exports.getIn = getIn$1; exports.has = has; -exports.hasIn = hasIn; -exports.merge = merge; -exports.mergeDeep = mergeDeep; -exports.mergeWith = mergeWith; -exports.mergeDeepWith = mergeDeepWith; +exports.hasIn = hasIn$1; +exports.merge = merge$1; +exports.mergeDeep = mergeDeep$1; +exports.mergeWith = mergeWith$1; +exports.mergeDeepWith = mergeDeepWith$1; exports.remove = remove; exports.removeIn = removeIn; exports.set = set; -exports.setIn = setIn; -exports.update = update; +exports.setIn = setIn$1; +exports.update = update$1; exports.updateIn = updateIn; Object.defineProperty(exports, '__esModule', { value: true }); diff --git a/dist/immutable.min.js b/dist/immutable.min.js index e9e5d84493..43df1032f3 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -4,35 +4,35 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.Immutable={})}(this,function(t){"use strict";function e(t){return t.value=!1,t}function r(t){t&&(t.value=!0)}function n(){}function i(t){return void 0===t.size&&(t.size=t.__iterate(u)),t.size}function o(t,e){if("number"!=typeof e){var r=e>>>0;if(""+r!==e||4294967295===r)return NaN;e=r}return e<0?i(t)+e:e}function u(){return!0}function s(t,e,r){return(0===t&&!f(t)||void 0!==r&&t<=-r)&&(void 0===e||void 0!==r&&e>=r)}function a(t,e){return h(t,e,0)}function c(t,e){return h(t,e,e)}function h(t,e,r){return void 0===t?r:f(t)?e===1/0?e:0|Math.max(0,e+t):void 0===e||e===t?t:0|Math.min(e,t)}function f(t){return t<0||0===t&&1/t==-(1/0)}function p(t){return _(t)||g(t)}function _(t){return!(!t||!t[Qe])}function l(t){return!(!t||!t[Xe])}function v(t){return!(!t||!t[Fe])}function y(t){return l(t)||v(t)}function d(t){return!(!t||!t[Ge])}function g(t){return!(!t||!t[Ze])}function m(t){return!(!t||"function"!=typeof t.equals||"function"!=typeof t.hashCode)}function w(t,e,r,n){var i=0===t?e:1===t?r:[e,r];return n?n.value=i:n={value:i,done:!1},n}function I(){return{value:void 0,done:!0}}function z(t){return!!O(t)}function S(t){return t&&"function"==typeof t.next}function b(t){var e=O(t);return e&&e.call(t)}function O(t){var e=t&&(ur&&t[ur]||t[sr]);if("function"==typeof e)return e}function M(t){return t&&"number"==typeof t.length}function E(t){return!(!t||!t[vr])}function q(){return gr||(gr=new yr([]))}function D(t){var e=Array.isArray(t)?new yr(t):S(t)?new Ir(t):z(t)?new wr(t):void 0;if(e)return e.fromEntrySeq();if("object"==typeof t)return new dr(t);throw new TypeError("Expected Array or collection object of [k, v] entries, or keyed object: "+t)}function A(t){var e=j(t);if(e)return e;throw new TypeError("Expected Array or collection object of values: "+t)}function x(t){var e=j(t);if(e)return e;if("object"==typeof t)return new dr(t) -;throw new TypeError("Expected Array or collection object of values, or keyed object: "+t)}function j(t){return M(t)?new yr(t):S(t)?new Ir(t):z(t)?new wr(t):void 0}function k(t,e){if(t===e||t!==t&&e!==e)return!0;if(!t||!e)return!1;if("function"==typeof t.valueOf&&"function"==typeof e.valueOf){if(t=t.valueOf(),e=e.valueOf(),t===e||t!==t&&e!==e)return!0;if(!t||!e)return!1}return!!(m(t)&&m(e)&&t.equals(e))}function R(t){if(M(t)&&"string"!=typeof t)return t;if(d(t))return t.toArray();throw new TypeError("Invalid keyPath: expected Ordered Collection or Array: "+t)}function U(t){return t&&(t.constructor===Object||void 0===t.constructor)}function K(t){return p(t)||Array.isArray(t)||U(t)}function T(t){try{return"string"==typeof t?JSON.stringify(t):t+""}catch(e){return JSON.stringify(t)}}function C(t,e){return p(t)?t.has(e):K(t)&&hr.call(t,e)}function L(t,e,r){return p(t)?t.get(e,r):C(t,e)?"function"==typeof t.get?t.get(e):t[e]:r}function B(t,e){e=e||0;for(var r=Math.max(0,t.length-e),n=Array(r),i=0;i0;)e[r]=arguments[r+1];return $(void 0,t,e)}function F(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];return $(t,e,r)}function G(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return $(tt(et),t,e)}function Z(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];return $(tt(t),e,r)}function $(t,e,r){if(!K(e))throw new TypeError("Cannot merge into non-data-structure value: "+e);if(p(e))return e.mergeWith?e.mergeWith.apply(e,[t].concat(r)):e.concat.apply(e,r);for(var n=Array.isArray(e),i=e,o=n?er:tr,u=n?function(t){i===e&&(i=W(i)),i.push(t)}:function(r,n){var o=t&&hr.call(i,n)?t(i[n],r,n):r;hr.call(i,n)&&o===i[n]||(i===e&&(i=W(i)),i[n]=o)},s=0;s>>1&1073741824|3221225471&t}function nt(t){if(t===!1||null===t||void 0===t)return 0;if("function"==typeof t.valueOf&&((t=t.valueOf())===!1||null===t||void 0===t))return 0;if(t===!0)return 1;var e=typeof t;if("number"===e){if(t!==t||t===1/0)return 0;var r=0|t;for(r!==t&&(r^=4294967295*t);t>4294967295;)t/=4294967295,r^=t;return rt(r)}if("string"===e)return t.length>qr?it(t):ot(t);if("function"==typeof t.hashCode)return rt(t.hashCode());if("object"===e)return ut(t);if("function"==typeof t.toString)return ot(""+t);throw Error("Value type "+e+" cannot be hashed.")}function it(t){var e=xr[t];return void 0===e&&(e=ot(t),Ar===Dr&&(Ar=0,xr={}),Ar++,xr[t]=e),e}function ot(t){for(var e=0,r=0;r0)switch(t.nodeType){case 1:return t.uniqueID;case 9:return t.documentElement&&t.documentElement.uniqueID}}function at(t){var e=qt(t);return e._iter=t,e.size=t.size,e.flip=function(){return t},e.reverse=function(){var e=t.reverse.apply(this);return e.flip=function(){return t.reverse()},e},e.has=function(e){return t.includes(e)},e.includes=function(e){return t.has(e)},e.cacheResult=Dt,e.__iterateUncached=function(e,r){var n=this;return t.__iterate(function(t,r){return e(r,t,n)!==!1},r)},e.__iteratorUncached=function(e,r){if(e===or){var n=t.__iterator(e,r);return new cr(function(){var t=n.next();if(!t.done){var e=t.value[0];t.value[0]=t.value[1],t.value[1]=e}return t})}return t.__iterator(e===ir?nr:ir,r)},e}function ct(t,e,r){var n=qt(t);return n.size=t.size,n.has=function(e){return t.has(e)},n.get=function(n,i){var o=t.get(n,He);return o===He?i:e.call(r,o,n,t)},n.__iterateUncached=function(n,i){var o=this;return t.__iterate(function(t,i,u){return n(e.call(r,t,i,u),i,o)!==!1},i)},n.__iteratorUncached=function(n,i){var o=t.__iterator(or,i);return new cr(function(){var i=o.next();if(i.done)return i;var u=i.value,s=u[0];return w(n,s,e.call(r,u[1],s,t),i)})},n}function ht(t,e){var r=this,n=qt(t);return n._iter=t,n.size=t.size,n.reverse=function(){return t},t.flip&&(n.flip=function(){ -var e=at(t);return e.reverse=function(){return t.flip()},e}),n.get=function(r,n){return t.get(e?r:-1-r,n)},n.has=function(r){return t.has(e?r:-1-r)},n.includes=function(e){return t.includes(e)},n.cacheResult=Dt,n.__iterate=function(r,n){var o=this,u=0;return n&&i(t),t.__iterate(function(t,i){return r(t,e?i:n?o.size-++u:u++,o)},!n)},n.__iterator=function(n,o){var u=0;o&&i(t);var s=t.__iterator(or,!o);return new cr(function(){var t=s.next();if(t.done)return t;var i=t.value;return w(n,e?i[0]:o?r.size-++u:u++,i[1],t)})},n}function ft(t,e,r,n){var i=qt(t);return n&&(i.has=function(n){var i=t.get(n,He);return i!==He&&!!e.call(r,i,n,t)},i.get=function(n,i){var o=t.get(n,He);return o!==He&&e.call(r,o,n,t)?o:i}),i.__iterateUncached=function(i,o){var u=this,s=0;return t.__iterate(function(t,o,a){if(e.call(r,t,o,a))return s++,i(t,n?o:s-1,u)},o),s},i.__iteratorUncached=function(i,o){var u=t.__iterator(or,o),s=0;return new cr(function(){for(;;){var o=u.next();if(o.done)return o;var a=o.value,c=a[0],h=a[1];if(e.call(r,h,c,t))return w(i,n?c:s++,h,o)}})},i}function pt(t,e,r){var n=Kr().asMutable();return t.__iterate(function(i,o){n.update(e.call(r,i,o,t),0,function(t){return t+1})}),n.asImmutable()}function _t(t,e,r){var n=l(t),i=(d(t)?en():Kr()).asMutable();t.__iterate(function(o,u){i.update(e.call(r,o,u,t),function(t){return t=t||[],t.push(n?[u,o]:o),t})});var o=Et(t);return i.map(function(e){return Ot(t,o(e))})}function lt(t,e,r,n){var i=t.size;if(s(e,r,i))return t;var u=a(e,i),h=c(r,i);if(u!==u||h!==h)return lt(t.toSeq().cacheResult(),e,r,n);var f,p=h-u;p===p&&(f=p<0?0:p);var _=qt(t);return _.size=0===f?f:t.size&&f||void 0,!n&&E(t)&&f>=0&&(_.get=function(e,r){return e=o(this,e),e>=0&&ef)return I();var t=i.next();return n||e===ir||t.done?t:e===nr?w(e,s-1,void 0,t):w(e,s-1,t.value[1],t)})},_}function vt(t,e,r){var n=qt(t);return n.__iterateUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterate(n,i);var u=0;return t.__iterate(function(t,i,s){return e.call(r,t,i,s)&&++u&&n(t,i,o)}),u},n.__iteratorUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterator(n,i);var u=t.__iterator(or,i),s=!0;return new cr(function(){if(!s)return I();var t=u.next();if(t.done)return t;var i=t.value,a=i[0],c=i[1];return e.call(r,c,a,o)?n===or?t:w(n,a,c,t):(s=!1,I())})},n}function yt(t,e,r,n){var i=qt(t);return i.__iterateUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterate(i,o);var s=!0,a=0;return t.__iterate(function(t,o,c){if(!s||!(s=e.call(r,t,o,c)))return a++,i(t,n?o:a-1,u)}),a},i.__iteratorUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterator(i,o);var s=t.__iterator(or,o),a=!0,c=0;return new cr(function(){var t,o,h;do{if(t=s.next(),t.done)return n||i===ir?t:i===nr?w(i,c++,void 0,t):w(i,c++,t.value[1],t);var f=t.value;o=f[0],h=f[1],a&&(a=e.call(r,h,o,u))}while(a);return i===or?t:w(i,o,h,t)})},i}function dt(t,e){var r=l(t),n=[t].concat(e).map(function(t){return _(t)?r&&(t=tr(t)):t=r?D(t):A(Array.isArray(t)?t:[t]),t}).filter(function(t){return 0!==t.size});if(0===n.length)return t;if(1===n.length){var i=n[0];if(i===t||r&&l(i)||v(t)&&v(i))return i}var o=new yr(n);return r?o=o.toKeyedSeq():v(t)||(o=o.toSetSeq()),o=o.flatten(!0),o.size=n.reduce(function(t,e){if(void 0!==t){var r=e.size;if(void 0!==r)return t+r}},0),o}function gt(t,e,r){var n=qt(t);return n.__iterateUncached=function(i,o){function u(t,c){t.__iterate(function(t,o){return(!e||c0}function bt(t,e,r,n){var i=qt(t),o=new yr(r).map(function(t){return t.size});return i.size=n?o.max():o.min(),i.__iterate=function(t,e){for(var r,n=this,i=this.__iterator(ir,e),o=0;!(r=i.next()).done&&t(r.value,o++,n)!==!1;);return o},i.__iteratorUncached=function(t,i){var o=r.map(function(t){return t=$e(t),b(i?t.reverse():t)}),u=0,s=!1;return new cr(function(){var r;return s||(r=o.map(function(t){return t.next()}),s=n?r.every(function(t){return t.done}):r.some(function(t){return t.done})),s?I():w(t,u++,e.apply(null,r.map(function(t){return t.value})))})},i}function Ot(t,e){return t===e?t:E(t)?e:t.constructor(e)}function Mt(t){if(t!==Object(t))throw new TypeError("Expected [K, V] tuple: "+t)}function Et(t){ -return l(t)?tr:v(t)?er:rr}function qt(t){return Object.create((l(t)?pr:v(t)?_r:lr).prototype)}function Dt(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size,this):fr.prototype.cacheResult.call(this)}function At(t,e){return void 0===t&&void 0===e?0:void 0===t?1:void 0===e?-1:t>e?1:t>>r)&Je,s=(0===r?n:n>>>r)&Je;return new Br(e,1<>>=1)u[s]=1&r?e[o++]:void 0;return u[n]=i,new Wr(t,o+1,u)}function Ht(t,e,r){for(var n=[],i=0;i>1&1431655765,t=(858993459&t)+(t>>2&858993459),t=t+(t>>4)&252645135,t+=t>>8,127&(t+=t>>16)}function Yt(t,e,r,n){var i=n?t:B(t);return i[e]=r,i}function Qt(t,e,r,n){var i=t.length+1;if(n&&e+1===i)return t[e]=r,t;for(var o=Array(i),u=0,s=0;so?0:o-r,c=u-r;return c>Pe&&(c=Pe),function(){if(i===c)return tn;var t=e?--c:i++;return n&&n[t]}}function i(t,n,i){var s,a=t&&t.array,c=i>o?0:o-i>>n,h=1+(u-i>>n);return h>Pe&&(h=Pe),function(){for(;;){if(s){var t=s();if(t!==tn)return t;s=null}if(c===h)return tn;var o=e?--h:c++;s=r(a&&a[o],n-Ne,i+(o<=t.size||r<0)return t.withMutations(function(t){r<0?ie(t,r).set(0,n):ie(t,0,r+1).set(r,n)});r+=t._origin;var i=t._tail,u=t._root,s=e(Ye);return r>=oe(t._capacity)?i=ee(i,t.__ownerID,0,r,n,s):u=ee(u,t.__ownerID,t._level,r,n,s),s.value?t.__ownerID?(t._root=u,t._tail=i,t.__hash=void 0,t.__altered=!0,t):Zt(t._origin,t._capacity,t._level,u,i):t}function ee(t,e,n,i,o,u){var s=i>>>n&Je,a=t&&s0){var h=t&&t.array[s],f=ee(h,e,n-Ne,i,o,u);return f===h?t:(c=re(t,e),c.array[s]=f,c)}return a&&t.array[s]===o?t:(r(u),c=re(t,e),void 0===o&&s===c.array.length-1?c.array.pop():c.array[s]=o,c)}function re(t,e){ -return e&&t&&e===t.ownerID?t:new Zr(t?t.array.slice():[],e)}function ne(t,e){if(e>=oe(t._capacity))return t._tail;if(e<1<0;)r=r.array[e>>>n&Je],n-=Ne;return r}}function ie(t,e,r){void 0!==e&&(e|=0),void 0!==r&&(r|=0);var i=t.__ownerID||new n,o=t._origin,u=t._capacity,s=o+e,a=void 0===r?u:r<0?u+r:o+r;if(s===o&&a===u)return t;if(s>=a)return t.clear();for(var c=t._level,h=t._root,f=0;s+f<0;)h=new Zr(h&&h.array.length?[void 0,h]:[],i),c+=Ne,f+=1<=1<p?new Zr([],i):l;if(l&&_>p&&sNe;d-=Ne){var g=p>>>d&Je;y=y.array[g]=re(y.array[g],i)}y.array[p>>>Ne&Je]=l}if(a=_)s-=_,a-=_,c=Ne,h=null,v=v&&v.removeBefore(i,0,s);else if(s>o||_>>c&Je;if(m!==_>>>c&Je)break;m&&(f+=(1<o&&(h=h.removeBefore(i,c,s-f)),h&&_>>Ne<=Pe&&u.size>=2*o.size?(i=u.filter(function(t,e){return void 0!==t&&s!==e}),n=i.toKeyedSeq().map(function(t){return t[0]}).flip().toMap(),t.__ownerID&&(n.__ownerID=i.__ownerID=t.__ownerID)):(n=o.remove(e),i=s===u.size-1?u.pop():u.set(s,void 0))}else if(a){if(r===u.get(s)[1])return t;n=o,i=u.set(s,[e,r])}else n=o.set(e,u.size),i=u.set(u.size,[e,r]);return t.__ownerID?(t.size=n.size,t._map=n,t._list=i,t.__hash=void 0,t):se(n,i)}function he(t){return!(!t||!t[on])}function fe(t,e,r,n){ -var i=Object.create(un);return i.size=t,i._head=e,i.__ownerID=r,i.__hash=n,i.__altered=!1,i}function pe(){return sn||(sn=fe(0))}function _e(t,e,r){for(var n=R(e),i=0;i!==n.length;)if((t=L(t,n[i++],He))===He)return r;return t}function le(t,e){return _e(t,e,He)!==He}function ve(t,e){if(t===e)return!0;if(!_(e)||void 0!==t.size&&void 0!==e.size&&t.size!==e.size||void 0!==t.__hash&&void 0!==e.__hash&&t.__hash!==e.__hash||l(t)!==l(e)||v(t)!==v(e)||d(t)!==d(e))return!1;if(0===t.size&&0===e.size)return!0;var r=!y(t);if(d(t)){var n=t.entries();return e.every(function(t,e){var i=n.next().value;return i&&k(i[1],t)&&(r||k(i[0],e))})&&n.next().done}var i=!1;if(void 0===t.size)if(void 0===e.size)"function"==typeof t.cacheResult&&t.cacheResult();else{i=!0;var o=t;t=e,e=o}var u=!0,s=e.__iterate(function(e,n){if(r?!t.has(e):i?!k(e,t.get(n,He)):!k(t.get(n,He),e))return u=!1,!1});return u&&t.size===s}function ye(t,e){var r=function(r){t.prototype[r]=e[r]};return Object.keys(e).forEach(r),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(e).forEach(r),t}function de(t){return K(t)?fr(t).map(de).toJSON():t}function ge(t){return!(!t||!t[cn])}function me(t,e){return t.__ownerID?(t.size=e.size,t._map=e,t):e===t._map?t:0===e.size?t.__empty():t.__make(e)}function we(t,e){var r=Object.create(hn);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function Ie(){return fn||(fn=we(Tt()))}function ze(t,e,r,n,i,o){return jt(t.size),t.__iterate(function(t,o,u){i?(i=!1,r=t):r=e.call(n,r,t,o,u)},o),r}function Se(t,e){return e}function be(t,e){return[e,t]}function Oe(t){return function(){return!t.apply(this,arguments)}}function Me(t){return function(){return-t.apply(this,arguments)}}function Ee(){return B(arguments)}function qe(t,e){return te?-1:0}function De(t){if(t.size===1/0)return 0;var e=d(t),r=l(t),n=e?1:0;return Ae(t.__iterate(r?e?function(t,e){n=31*n+xe(nt(t),nt(e))|0}:function(t,e){n=n+xe(nt(t),nt(e))|0}:e?function(t){n=31*n+nt(t)|0}:function(t){n=n+nt(t)|0}),n)}function Ae(t,e){return e=zr(e,3432918353), -e=zr(e<<15|e>>>-15,461845907),e=zr(e<<13|e>>>-13,5),e=(e+3864292196|0)^t,e=zr(e^e>>>16,2246822507),e=zr(e^e>>>13,3266489909),e=rt(e^e>>>16)}function xe(t,e){return t^e+2654435769+(t<<6)+(t>>2)|0}function je(t){return ge(t)&&d(t)}function ke(t,e){var r=Object.create(gn);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function Re(){return mn||(mn=ke(ae()))}function Ue(t,e,r){var n=Object.create(Object.getPrototypeOf(t));return n._values=e,n.__ownerID=r,n}function Ke(t){return t._name||t.constructor.name||"Record"}function Te(t){return D(t._keys.map(function(e){return[e,t.get(e)]}))}function Ce(t,e){try{Object.defineProperty(t,e,{get:function(){return this.get(e)},set:function(t){xt(this.__ownerID,"Cannot set on an immutable record."),this.set(e,t)}})}catch(t){}}function Le(t,e){return Be([],e||We,t,"",e&&e.length>2?[]:void 0,{"":t})}function Be(t,e,r,n,i,o){var u=Array.isArray(r)?_r:U(r)?pr:null;if(u){if(~t.indexOf(r))throw new TypeError("Cannot convert circular structure to Immutable");t.push(r),i&&""!==n&&i.push(n);var s=e.call(o,n,u(r).map(function(n,o){return Be(t,e,n,o,i,r)}),i&&i.slice());return t.pop(),i&&i.pop(),s}return r}function We(t,e){return l(e)?e.toMap():e.toList()}var Ne=5,Pe=1<=n.length){var e=r.next();if(e.done)return e;n[i]=e.value}return w(t,i,n[i++])})},e}(_r),zr="function"==typeof Math.imul&&Math.imul(4294967295,2)===-2?Math.imul:function(t,e){t|=0,e|=0;var r=65535&t,n=65535&e;return r*n+((t>>>16)*n+r*(e>>>16)<<16>>>0)|0},Sr=Object.isExtensible,br=function(){try{return Object.defineProperty({},"@",{}),!0}catch(t){return!1}}(),Or="function"==typeof WeakMap;Or&&(mr=new WeakMap);var Mr=0,Er="__immutablehash__";"function"==typeof Symbol&&(Er=Symbol(Er));var qr=16,Dr=255,Ar=0,xr={},jr=function(t){function e(t,e){this._iter=t,this._useKeys=e,this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t,e){return this._iter.get(t,e)},e.prototype.has=function(t){return this._iter.has(t)},e.prototype.valueSeq=function(){return this._iter.valueSeq()},e.prototype.reverse=function(){var t=this,e=ht(this,!0);return this._useKeys||(e.valueSeq=function(){return t._iter.toSeq().reverse()}),e},e.prototype.map=function(t,e){var r=this,n=ct(this,t,e);return this._useKeys||(n.valueSeq=function(){return r._iter.toSeq().map(t,e)}),n},e.prototype.__iterate=function(t,e){var r=this;return this._iter.__iterate(function(e,n){return t(e,n,r)},e)},e.prototype.__iterator=function(t,e){return this._iter.__iterator(t,e)},e}(pr);jr.prototype[Ge]=!0;var kr=function(t){function e(t){this._iter=t,this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e, -e.prototype.includes=function(t){return this._iter.includes(t)},e.prototype.__iterate=function(t,e){var r=this,n=0;return e&&i(this),this._iter.__iterate(function(i){return t(i,e?r.size-++n:n++,r)},e)},e.prototype.__iterator=function(t,e){var r=this,n=this._iter.__iterator(ir,e),o=0;return e&&i(this),new cr(function(){var i=n.next();return i.done?i:w(t,e?r.size-++o:o++,i.value,i)})},e}(_r),Rr=function(t){function e(t){this._iter=t,this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.has=function(t){return this._iter.includes(t)},e.prototype.__iterate=function(t,e){var r=this;return this._iter.__iterate(function(e){return t(e,e,r)},e)},e.prototype.__iterator=function(t,e){var r=this._iter.__iterator(ir,e);return new cr(function(){var e=r.next();return e.done?e:w(t,e.value,e.value,e)})},e}(lr),Ur=function(t){function e(t){this._iter=t,this.size=t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.entrySeq=function(){return this._iter.toSeq()},e.prototype.__iterate=function(t,e){var r=this;return this._iter.__iterate(function(e){if(e){Mt(e);var n=_(e);return t(n?e.get(1):e[1],n?e.get(0):e[0],r)}},e)},e.prototype.__iterator=function(t,e){var r=this._iter.__iterator(ir,e);return new cr(function(){for(;;){var e=r.next();if(e.done)return e;var n=e.value;if(n){Mt(n);var i=_(n);return w(t,i?n.get(0):n[0],i?n.get(1):n[1],e)}}})},e}(pr);kr.prototype.cacheResult=jr.prototype.cacheResult=Rr.prototype.cacheResult=Ur.prototype.cacheResult=Dt;var Kr=function(t){function e(e){return null===e||void 0===e?Tt():kt(e)&&!d(e)?e:Tt().withMutations(function(r){var n=t(e);jt(n.size),n.forEach(function(t,e){return r.set(e,t)})})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return Tt().withMutations(function(e){for(var r=0;r=t.length)throw Error("Missing value for key: "+t[r]);e.set(t[r],t[r+1])}})},e.prototype.toString=function(){return this.__toString("Map {","}")},e.prototype.get=function(t,e){return this._root?this._root.get(0,void 0,t,e):e},e.prototype.set=function(t,e){return Ct(this,t,e)},e.prototype.setIn=function(t,e){return V(this,t,e)},e.prototype.remove=function(t){return Ct(this,t,He)},e.prototype.deleteIn=function(t){return Q(this,t)},e.prototype.deleteAll=function(t){var e=$e(t);return 0===e.size?this:this.withMutations(function(t){e.forEach(function(e){return t.remove(e)})})},e.prototype.update=function(t,e,r){return 1===arguments.length?t(this):Y(this,t,e,r)},e.prototype.updateIn=function(t,e,r){return J(this,t,e,r)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):Tt()},e.prototype.merge=function(){return Ht(this,void 0,arguments)},e.prototype.mergeWith=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Ht(this,t,e)},e.prototype.mergeIn=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return J(this,t,Tt(),function(t){return X.apply(void 0,[t].concat(e))})},e.prototype.mergeDeep=function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return G.apply(void 0,[this].concat(t))},e.prototype.mergeDeepWith=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Z.apply(void 0,[t,this].concat(e))},e.prototype.mergeDeepIn=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return J(this,t,Tt(),function(t){return G.apply(void 0,[t].concat(e))})},e.prototype.sort=function(t){return en(It(this,t))},e.prototype.sortBy=function(t,e){return en(It(this,e,t))},e.prototype.withMutations=function(t){var e=this.asMutable();return t(e),e.wasAltered()?e.__ensureOwner(this.__ownerID):this},e.prototype.asMutable=function(){return this.__ownerID?this:this.__ensureOwner(new n)},e.prototype.asImmutable=function(){ -return this.__ensureOwner()},e.prototype.wasAltered=function(){return this.__altered},e.prototype.__iterator=function(t,e){return new Hr(this,t,e)},e.prototype.__iterate=function(t,e){var r=this,n=0;return this._root&&this._root.iterate(function(e){return n++,t(e[1],e[0],r)},e),n},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Kt(this.size,this._root,t,this.__hash):0===this.size?Tt():(this.__ownerID=t,this.__altered=!1,this)},e}(tr);Kr.isMap=kt;var Tr="@@__IMMUTABLE_MAP__@@",Cr=Kr.prototype;Cr[Tr]=!0,Cr.delete=Cr.remove,Cr.removeIn=Cr.deleteIn,Cr.removeAll=Cr.deleteAll,Cr.concat=Cr.merge,Cr["@@transducer/init"]=Cr.asMutable,Cr["@@transducer/step"]=function(t,e){return t.set(e[0],e[1])},Cr["@@transducer/result"]=function(t){return t.asImmutable()};var Lr=function(t,e){this.ownerID=t,this.entries=e};Lr.prototype.get=function(t,e,r,n){for(var i=this.entries,o=0,u=i.length;o=Vr)return Nt(t,c,i,o);var _=t&&t===this.ownerID,l=_?c:B(c);return p?a?h===f-1?l.pop():l[h]=l.pop():l[h]=[i,o]:l.push([i,o]),_?(this.entries=l,this):new Lr(t,l)}};var Br=function(t,e,r){this.ownerID=t,this.bitmap=e,this.nodes=r};Br.prototype.get=function(t,e,r,n){void 0===e&&(e=nt(r));var i=1<<((0===t?e:e>>>t)&Je),o=this.bitmap;return 0==(o&i)?n:this.nodes[Vt(o&i-1)].get(t+Ne,e,r,n)},Br.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=nt(n));var s=(0===e?r:r>>>e)&Je,a=1<=Yr)return Jt(t,p,c,s,l);if(h&&!l&&2===p.length&&Bt(p[1^f]))return p[1^f];if(h&&l&&1===p.length&&Bt(l))return l;var v=t&&t===this.ownerID,y=h?l?c:c^a:c|a,d=h?l?Yt(p,f,l,v):Xt(p,f,v):Qt(p,f,l,v);return v?(this.bitmap=y,this.nodes=d, -this):new Br(t,y,d)};var Wr=function(t,e,r){this.ownerID=t,this.count=e,this.nodes=r};Wr.prototype.get=function(t,e,r,n){void 0===e&&(e=nt(r));var i=(0===t?e:e>>>t)&Je,o=this.nodes[i];return o?o.get(t+Ne,e,r,n):n},Wr.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=nt(n));var s=(0===e?r:r>>>e)&Je,a=i===He,c=this.nodes,h=c[s];if(a&&!h)return this;var f=Lt(h,t,e+Ne,r,n,i,o,u);if(f===h)return this;var p=this.count;if(h){if(!f&&--p0&&i=0&&t>>e&Je;if(n>=this.array.length)return new Zr([],t);var i,o=0===n;if(e>0){var u=this.array[n];if((i=u&&u.removeBefore(t,e-Ne,r))===u&&o)return this}if(o&&!i)return this;var s=re(this,t);if(!o)for(var a=0;a>>e&Je;if(n>=this.array.length)return this;var i;if(e>0){ -var o=this.array[n];if((i=o&&o.removeAfter(t,e-Ne,r))===o&&n===this.array.length-1)return this}var u=re(this,t);return u.array.splice(n+1),i&&(u.array[n]=i),u};var $r,tn={},en=function(t){function e(t){return null===t||void 0===t?ae():ue(t)?t:ae().withMutations(function(e){var r=tr(t);jt(r.size),r.forEach(function(t,r){return e.set(r,t)})})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("OrderedMap {","}")},e.prototype.get=function(t,e){var r=this._map.get(t);return void 0!==r?this._list.get(r)[1]:e},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._map.clear(),this._list.clear(),this):ae()},e.prototype.set=function(t,e){return ce(this,t,e)},e.prototype.remove=function(t){return ce(this,t,He)},e.prototype.wasAltered=function(){return this._map.wasAltered()||this._list.wasAltered()},e.prototype.__iterate=function(t,e){var r=this;return this._list.__iterate(function(e){return e&&t(e[1],e[0],r)},e)},e.prototype.__iterator=function(t,e){return this._list.fromEntrySeq().__iterator(t,e)},e.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var e=this._map.__ensureOwner(t),r=this._list.__ensureOwner(t);return t?se(e,r,t,this.__hash):0===this.size?ae():(this.__ownerID=t,this._map=e,this._list=r,this)},e}(Kr);en.isOrderedMap=ue,en.prototype[Ge]=!0,en.prototype.delete=en.prototype.remove;var rn,nn=function(t){function e(t){return null===t||void 0===t?pe():he(t)?t:pe().pushAll(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("Stack [","]")},e.prototype.get=function(t,e){var r=this._head;for(t=o(this,t);r&&t--;)r=r.next;return r?r.value:e},e.prototype.peek=function(){return this._head&&this._head.value},e.prototype.push=function(){var t=arguments;if(0===arguments.length)return this -;for(var e=this.size+arguments.length,r=this._head,n=arguments.length-1;n>=0;n--)r={value:t[n],next:r};return this.__ownerID?(this.size=e,this._head=r,this.__hash=void 0,this.__altered=!0,this):fe(e,r)},e.prototype.pushAll=function(e){if(e=t(e),0===e.size)return this;if(0===this.size&&he(e))return e;jt(e.size);var r=this.size,n=this._head;return e.__iterate(function(t){r++,n={value:t,next:n}},!0),this.__ownerID?(this.size=r,this._head=n,this.__hash=void 0,this.__altered=!0,this):fe(r,n)},e.prototype.pop=function(){return this.slice(1)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):pe()},e.prototype.slice=function(e,r){if(s(e,r,this.size))return this;var n=a(e,this.size);if(c(r,this.size)!==this.size)return t.prototype.slice.call(this,e,r);for(var i=this.size-n,o=this._head;n--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):fe(i,o)},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?fe(this.size,this._head,t,this.__hash):0===this.size?pe():(this.__ownerID=t,this.__altered=!1,this)},e.prototype.__iterate=function(t,e){var r=this;if(e)return new yr(this.toArray()).__iterate(function(e,n){return t(e,n,r)},e);for(var n=0,i=this._head;i&&t(i.value,n++,r)!==!1;)i=i.next;return n},e.prototype.__iterator=function(t,e){if(e)return new yr(this.toArray()).__iterator(t,e);var r=0,n=this._head;return new cr(function(){if(n){var e=n.value;return n=n.next,w(t,r++,e)}return I()})},e}(er);nn.isStack=he;var on="@@__IMMUTABLE_STACK__@@",un=nn.prototype;un[on]=!0,un.withMutations=Cr.withMutations,un.asMutable=Cr.asMutable,un.asImmutable=Cr.asImmutable,un.wasAltered=Cr.wasAltered,un.shift=un.pop,un.unshift=un.push,un.unshiftAll=un.pushAll,un["@@transducer/init"]=un.asMutable,un["@@transducer/step"]=function(t,e){return t.unshift(e)},un["@@transducer/result"]=Cr["@@transducer/result"];var sn,an=function(t){function e(e){ -return null===e||void 0===e?Ie():ge(e)&&!d(e)?e:Ie().withMutations(function(r){var n=t(e);jt(n.size),n.forEach(function(t){return r.add(t)})})}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(tr(t).keySeq())},e.intersect=function(t){return t=$e(t).toArray(),t.length?hn.intersect.apply(e(t.pop()),t):Ie()},e.union=function(t){return t=$e(t).toArray(),t.length?hn.union.apply(e(t.pop()),t):Ie()},e.prototype.toString=function(){return this.__toString("Set {","}")},e.prototype.has=function(t){return this._map.has(t)},e.prototype.add=function(t){return me(this,this._map.set(t,t))},e.prototype.remove=function(t){return me(this,this._map.remove(t))},e.prototype.clear=function(){return me(this,this._map.clear())},e.prototype.union=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return e=e.filter(function(t){return 0!==t.size}),0===e.length?this:0!==this.size||this.__ownerID||1!==e.length?this.withMutations(function(r){for(var n=0;n=0&&e=0&&rthis.size?e:this.find(function(e,r){return r===t},void 0,e)},has:function(t){return(t=o(this,t))>=0&&(void 0!==this.size?this.size===1/0||t>>0;if(""+e!==r||4294967295===e)return NaN;r=e}return r<0?i(t)+r:r}function u(){return!0}function s(t,r,e){return(0===t&&!h(t)||void 0!==e&&t<=-e)&&(void 0===r||void 0!==e&&r>=e)}function a(t,r){return f(t,r,0)}function c(t,r){return f(t,r,r)}function f(t,r,e){return void 0===t?e:h(t)?r===1/0?r:0|Math.max(0,r+t):void 0===r||r===t?t:0|Math.min(r,t)}function h(t){return t<0||0===t&&1/t==-(1/0)}function p(t){return _(t)||g(t)}function _(t){return!(!t||!t[he])}function l(t){return!(!t||!t[pe])}function v(t){return!(!t||!t[_e])}function y(t){return l(t)||v(t)}function d(t){return!(!t||!t[le])}function g(t){return!(!t||!t[ve])}function m(t){return!(!t||"function"!=typeof t.equals||"function"!=typeof t.hashCode)}function w(t,r,e,n){var i=0===t?r:1===t?e:[r,e];return n?n.value=i:n={value:i,done:!1},n}function z(){return{value:void 0,done:!0}}function S(t){return!!O(t)}function I(t){return t&&"function"==typeof t.next}function b(t){var r=O(t);return r&&r.call(t)}function O(t){var r=t&&(Ie&&t[Ie]||t[be]);if("function"==typeof r)return r}function E(t){return t&&"number"==typeof t.length}function q(t){return!(!t||!t[je])}function M(){return Ue||(Ue=new ke([]))}function D(t){var r=Array.isArray(t)?new ke(t):I(t)?new Ce(t):S(t)?new Te(t):void 0;if(r)return r.fromEntrySeq();if("object"==typeof t)return new Re(t);throw new TypeError("Expected Array or collection object of [k, v] entries, or keyed object: "+t)}function x(t){var r=j(t);if(r)return r;throw new TypeError("Expected Array or collection object of values: "+t)}function A(t){var r=j(t);if(r)return r;if("object"==typeof t)return new Re(t) +;throw new TypeError("Expected Array or collection object of values, or keyed object: "+t)}function j(t){return E(t)?new ke(t):I(t)?new Ce(t):S(t)?new Te(t):void 0}function k(t,r){if(t===r||t!==t&&r!==r)return!0;if(!t||!r)return!1;if("function"==typeof t.valueOf&&"function"==typeof r.valueOf){if(t=t.valueOf(),r=r.valueOf(),t===r||t!==t&&r!==r)return!0;if(!t||!r)return!1}return!!(m(t)&&m(r)&&t.equals(r))}function R(t){return t>>>1&1073741824|3221225471&t}function U(t){if(t===!1||null===t||void 0===t)return 0;if("function"==typeof t.valueOf&&((t=t.valueOf())===!1||null===t||void 0===t))return 0;if(t===!0)return 1;var r=typeof t;if("number"===r){if(t!==t||t===1/0)return 0;var e=0|t;for(e!==t&&(e^=4294967295*t);t>4294967295;)t/=4294967295,e^=t;return R(e)}if("string"===r)return t.length>He?K(t):T(t);if("function"==typeof t.hashCode)return R(t.hashCode());if("object"===r)return C(t);if("function"==typeof t.toString)return T(""+t);throw Error("Value type "+r+" cannot be hashed.")}function K(t){var r=Qe[t];return void 0===r&&(r=T(t),Ye===Ve&&(Ye=0,Qe={}),Ye++,Qe[t]=r),r}function T(t){for(var r=0,e=0;e0)switch(t.nodeType){case 1:return t.uniqueID;case 9: +return t.documentElement&&t.documentElement.uniqueID}}function B(t){var r=ut(t);return r._iter=t,r.size=t.size,r.flip=function(){return t},r.reverse=function(){var r=t.reverse.apply(this);return r.flip=function(){return t.reverse()},r},r.has=function(r){return t.includes(r)},r.includes=function(r){return t.has(r)},r.cacheResult=st,r.__iterateUncached=function(r,e){var n=this;return t.__iterate(function(t,e){return r(e,t,n)!==!1},e)},r.__iteratorUncached=function(r,e){if(r===Se){var n=t.__iterator(r,e);return new Ee(function(){var t=n.next();if(!t.done){var r=t.value[0];t.value[0]=t.value[1],t.value[1]=r}return t})}return t.__iterator(r===ze?we:ze,e)},r}function W(t,r,e){var n=ut(t);return n.size=t.size,n.has=function(r){return t.has(r)},n.get=function(n,i){var o=t.get(n,ae);return o===ae?i:r.call(e,o,n,t)},n.__iterateUncached=function(n,i){var o=this;return t.__iterate(function(t,i,u){return n(r.call(e,t,i,u),i,o)!==!1},i)},n.__iteratorUncached=function(n,i){var o=t.__iterator(Se,i);return new Ee(function(){var i=o.next();if(i.done)return i;var u=i.value,s=u[0];return w(n,s,r.call(e,u[1],s,t),i)})},n}function N(t,r){var e=this,n=ut(t);return n._iter=t,n.size=t.size,n.reverse=function(){return t},t.flip&&(n.flip=function(){var r=B(t);return r.reverse=function(){return t.flip()},r}),n.get=function(e,n){return t.get(r?e:-1-e,n)},n.has=function(e){return t.has(r?e:-1-e)},n.includes=function(r){return t.includes(r)},n.cacheResult=st,n.__iterate=function(e,n){var o=this,u=0;return n&&i(t),t.__iterate(function(t,i){return e(t,r?i:n?o.size-++u:u++,o)},!n)},n.__iterator=function(n,o){var u=0;o&&i(t);var s=t.__iterator(Se,!o);return new Ee(function(){var t=s.next();if(t.done)return t;var i=t.value;return w(n,r?i[0]:o?e.size-++u:u++,i[1],t)})},n}function P(t,r,e,n){var i=ut(t);return n&&(i.has=function(n){var i=t.get(n,ae);return i!==ae&&!!r.call(e,i,n,t)},i.get=function(n,i){var o=t.get(n,ae);return o!==ae&&r.call(e,o,n,t)?o:i}),i.__iterateUncached=function(i,o){var u=this,s=0;return t.__iterate(function(t,o,a){ +if(r.call(e,t,o,a))return s++,i(t,n?o:s-1,u)},o),s},i.__iteratorUncached=function(i,o){var u=t.__iterator(Se,o),s=0;return new Ee(function(){for(;;){var o=u.next();if(o.done)return o;var a=o.value,c=a[0],f=a[1];if(r.call(e,f,c,t))return w(i,n?c:s++,f,o)}})},i}function J(t,r,e){var n=$e().asMutable();return t.__iterate(function(i,o){n.update(r.call(e,i,o,t),0,function(t){return t+1})}),n.asImmutable()}function H(t,r,e){var n=l(t),i=(d(t)?mn():$e()).asMutable();t.__iterate(function(o,u){i.update(r.call(e,o,u,t),function(t){return t=t||[],t.push(n?[u,o]:o),t})});var o=ot(t);return i.map(function(r){return nt(t,o(r))})}function V(t,r,e,n){var i=t.size;if(s(r,e,i))return t;var u=a(r,i),f=c(e,i);if(u!==u||f!==f)return V(t.toSeq().cacheResult(),r,e,n);var h,p=f-u;p===p&&(h=p<0?0:p);var _=ut(t);return _.size=0===h?h:t.size&&h||void 0,!n&&q(t)&&h>=0&&(_.get=function(r,e){return r=o(this,r),r>=0&&rh)return z();var t=i.next();return n||r===ze||t.done?t:r===we?w(r,s-1,void 0,t):w(r,s-1,t.value[1],t)})},_}function Y(t,r,e){var n=ut(t);return n.__iterateUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterate(n,i);var u=0;return t.__iterate(function(t,i,s){return r.call(e,t,i,s)&&++u&&n(t,i,o)}),u},n.__iteratorUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterator(n,i);var u=t.__iterator(Se,i),s=!0;return new Ee(function(){if(!s)return z();var t=u.next();if(t.done)return t;var i=t.value,a=i[0],c=i[1];return r.call(e,c,a,o)?n===Se?t:w(n,a,c,t):(s=!1,z())})},n}function Q(t,r,e,n){var i=ut(t);return i.__iterateUncached=function(i,o){var u=this +;if(o)return this.cacheResult().__iterate(i,o);var s=!0,a=0;return t.__iterate(function(t,o,c){if(!s||!(s=r.call(e,t,o,c)))return a++,i(t,n?o:a-1,u)}),a},i.__iteratorUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterator(i,o);var s=t.__iterator(Se,o),a=!0,c=0;return new Ee(function(){var t,o,f;do{if(t=s.next(),t.done)return n||i===ze?t:i===we?w(i,c++,void 0,t):w(i,c++,t.value[1],t);var h=t.value;o=h[0],f=h[1],a&&(a=r.call(e,f,o,u))}while(a);return i===Se?t:w(i,o,f,t)})},i}function X(t,r){var e=l(t),n=[t].concat(r).map(function(t){return _(t)?e&&(t=de(t)):t=e?D(t):x(Array.isArray(t)?t:[t]),t}).filter(function(t){return 0!==t.size});if(0===n.length)return t;if(1===n.length){var i=n[0];if(i===t||e&&l(i)||v(t)&&v(i))return i}var o=new ke(n);return e?o=o.toKeyedSeq():v(t)||(o=o.toSetSeq()),o=o.flatten(!0),o.size=n.reduce(function(t,r){if(void 0!==t){var e=r.size;if(void 0!==e)return t+e}},0),o}function F(t,r,e){var n=ut(t);return n.__iterateUncached=function(i,o){function u(t,c){t.__iterate(function(t,o){return(!r||c0}function et(t,r,e,n){var i=ut(t),o=new ke(e).map(function(t){return t.size});return i.size=n?o.max():o.min(),i.__iterate=function(t,r){for(var e,n=this,i=this.__iterator(ze,r),o=0;!(e=i.next()).done&&t(e.value,o++,n)!==!1;);return o},i.__iteratorUncached=function(t,i){var o=e.map(function(t){return t=ye(t),b(i?t.reverse():t)}),u=0,s=!1;return new Ee(function(){var e;return s||(e=o.map(function(t){return t.next()}),s=n?e.every(function(t){return t.done}):e.some(function(t){return t.done})),s?z():w(t,u++,r.apply(null,e.map(function(t){return t.value})))})},i}function nt(t,r){return t===r?t:q(t)?r:t.constructor(r)}function it(t){if(t!==Object(t))throw new TypeError("Expected [K, V] tuple: "+t)}function ot(t){return l(t)?de:v(t)?ge:me}function ut(t){return Object.create((l(t)?De:v(t)?xe:Ae).prototype)}function st(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size,this):Me.prototype.cacheResult.call(this)}function at(t,r){return void 0===t&&void 0===r?0:void 0===t?1:void 0===r?-1:t>r?1:t0;)r[e]=arguments[e+1];return jt(this,t,r)}function jt(t,r,e){for(var n=[],i=0;i0;)r[e]=arguments[e+1];return Tt(void 0,t,r)}function Rt(t,r){for(var e=[],n=arguments.length-2;n-- >0;)e[n]=arguments[n+2];return Tt(t,r,e)}function Ut(t){for(var r=[],e=arguments.length-1;e-- >0;)r[e]=arguments[e+1];return Tt(Ct(Lt),t,r)}function Kt(t,r){for(var e=[],n=arguments.length-2;n-- >0;)e[n]=arguments[n+2];return Tt(Ct(t),r,e)}function Tt(t,r,e){if(!lt(r))throw new TypeError("Cannot merge into non-data-structure value: "+r);if(p(r))return r.mergeWith?r.mergeWith.apply(r,[t].concat(e)):r.concat.apply(r,e);for(var n=Array.isArray(r),i=r,o=n?ge:de,u=n?function(t){i===r&&(i=gt(i)),i.push(t)}:function(e,n){var o=t&&qe.call(i,n)?t(i[n],e,n):e;qe.call(i,n)&&o===i[n]||(i===r&&(i=gt(i)),i[n]=o)},s=0;s0;)r[e]=arguments[e+1];return Kt.apply(void 0,[t,this].concat(r))}function Nt(t){for(var r=[],e=arguments.length-1;e-- >0;)r[e]=arguments[e+1];return zt(this,t,Zt(),function(t){return kt.apply(void 0,[t].concat(r))})}function Pt(t){for(var r=[],e=arguments.length-1;e-- >0;)r[e]=arguments[e+1];return zt(this,t,Zt(),function(t){return Ut.apply(void 0,[t].concat(r))})}function Jt(t){var r=this.asMutable();return t(r),r.wasAltered()?r.__ensureOwner(this.__ownerID):this}function Ht(){return this.__ownerID?this:this.__ensureOwner(new n)}function Vt(){return this.__ensureOwner()}function Yt(){return this.__altered}function Qt(t){return!(!t||!t[tn])}function Xt(t,r){return w(t,r[0],r[1])} +function Ft(t,r){return{node:t,index:0,__prev:r}}function Gt(t,r,e,n){var i=Object.create(rn);return i.size=t,i._root=r,i.__ownerID=e,i.__hash=n,i.__altered=!1,i}function Zt(){return an||(an=Gt(0))}function $t(t,e,n){var i,o;if(t._root){var u=r(ce),s=r(fe);if(i=tr(t._root,t.__ownerID,0,void 0,e,n,u,s),!s.value)return t;o=t.size+(u.value?n===ae?-1:1:0)}else{if(n===ae)return t;o=1,i=new en(t.__ownerID,[[e,n]])}return t.__ownerID?(t.size=o,t._root=i,t.__hash=void 0,t.__altered=!0,t):i?Gt(o,i):Zt()}function tr(t,r,n,i,o,u,s,a){return t?t.update(r,n,i,o,u,s,a):u===ae?t:(e(a),e(s),new sn(r,i,[o,u]))}function rr(t){return t.constructor===sn||t.constructor===un}function er(t,r,e,n,i){if(t.keyHash===n)return new un(r,n,[t.entry,i]);var o,u=(0===e?t.keyHash:t.keyHash>>>e)&se,s=(0===e?n:n>>>e)&se;return new nn(r,1<>>=1)u[s]=1&e?r[o++]:void 0;return u[n]=i,new on(t,o+1,u)}function ur(t){return t-=t>>1&1431655765,t=(858993459&t)+(t>>2&858993459),t=t+(t>>4)&252645135,t+=t>>8,127&(t+=t>>16)}function sr(t,r,e,n){var i=n?t:ct(t);return i[r]=e,i}function ar(t,r,e,n){var i=t.length+1;if(n&&r+1===i)return t[r]=e,t;for(var o=Array(i),u=0,s=0;so?0:o-e,c=u-e;return c>ue&&(c=ue),function(){if(i===c)return gn;var t=r?--c:i++;return n&&n[t]}}function i(t,n,i){ +var s,a=t&&t.array,c=i>o?0:o-i>>n,f=1+(u-i>>n);return f>ue&&(f=ue),function(){for(;;){if(s){var t=s();if(t!==gn)return t;s=null}if(c===f)return gn;var o=r?--f:c++;s=e(a&&a[o],n-oe,i+(o<=t.size||e<0)return t.withMutations(function(t){e<0?gr(t,e).set(0,n):gr(t,0,e+1).set(e,n)});e+=t._origin;var i=t._tail,u=t._root,s=r(fe);return e>=mr(t._capacity)?i=vr(i,t.__ownerID,0,e,n,s):u=vr(u,t.__ownerID,t._level,e,n,s),s.value?t.__ownerID?(t._root=u,t._tail=i,t.__hash=void 0,t.__altered=!0,t):pr(t._origin,t._capacity,t._level,u,i):t}function vr(t,r,n,i,o,u){var s=i>>>n&se,a=t&&s0){var f=t&&t.array[s],h=vr(f,r,n-oe,i,o,u);return h===f?t:(c=yr(t,r),c.array[s]=h,c)}return a&&t.array[s]===o?t:(e(u),c=yr(t,r),void 0===o&&s===c.array.length-1?c.array.pop():c.array[s]=o,c)}function yr(t,r){return r&&t&&r===t.ownerID?t:new yn(t?t.array.slice():[],r)}function dr(t,r){if(r>=mr(t._capacity))return t._tail;if(r<1<0;)e=e.array[r>>>n&se],n-=oe;return e}}function gr(t,r,e){void 0!==r&&(r|=0),void 0!==e&&(e|=0);var i=t.__ownerID||new n,o=t._origin,u=t._capacity,s=o+r,a=void 0===e?u:e<0?u+e:o+e;if(s===o&&a===u)return t;if(s>=a)return t.clear();for(var c=t._level,f=t._root,h=0;s+h<0;)f=new yn(f&&f.array.length?[void 0,f]:[],i),c+=oe,h+=1<=1<p?new yn([],i):l;if(l&&_>p&&soe;d-=oe){var g=p>>>d&se;y=y.array[g]=yr(y.array[g],i)}y.array[p>>>oe&se]=l}if(a=_)s-=_,a-=_,c=oe,f=null, +v=v&&v.removeBefore(i,0,s);else if(s>o||_>>c&se;if(m!==_>>>c&se)break;m&&(h+=(1<o&&(f=f.removeBefore(i,c,s-h)),f&&_>>oe<=ue&&u.size>=2*o.size?(i=u.filter(function(t,r){return void 0!==t&&s!==r}),n=i.toKeyedSeq().map(function(t){return t[0]}).flip().toMap(),t.__ownerID&&(n.__ownerID=i.__ownerID=t.__ownerID)):(n=o.remove(r),i=s===u.size-1?u.pop():u.set(s,void 0))}else if(a){if(e===u.get(s)[1])return t;n=o,i=u.set(s,[r,e])}else n=o.set(r,u.size),i=u.set(u.size,[r,e]);return t.__ownerID?(t.size=n.size,t._map=n,t._list=i,t.__hash=void 0,t):zr(n,i)}function br(t){return!(!t||!t[Sn])}function Or(t,r,e,n){var i=Object.create(In);return i.size=t,i._head=r,i.__ownerID=e,i.__hash=n,i.__altered=!1,i}function Er(){return bn||(bn=Or(0))}function qr(t,r){if(t===r)return!0;if(!_(r)||void 0!==t.size&&void 0!==r.size&&t.size!==r.size||void 0!==t.__hash&&void 0!==r.__hash&&t.__hash!==r.__hash||l(t)!==l(r)||v(t)!==v(r)||d(t)!==d(r))return!1;if(0===t.size&&0===r.size)return!0;var e=!y(t);if(d(t)){var n=t.entries();return r.every(function(t,r){var i=n.next().value;return i&&k(i[1],t)&&(e||k(i[0],r))})&&n.next().done}var i=!1;if(void 0===t.size)if(void 0===r.size)"function"==typeof t.cacheResult&&t.cacheResult();else{i=!0;var o=t;t=r,r=o}var u=!0,s=r.__iterate(function(r,n){if(e?!t.has(r):i?!k(r,t.get(n,ae)):!k(t.get(n,ae),r))return u=!1,!1});return u&&t.size===s}function Mr(t,r){var e=function(e){t.prototype[e]=r[e]};return Object.keys(r).forEach(e), +Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(r).forEach(e),t}function Dr(t){return lt(t)?Me(t).map(Dr).toJSON():t}function xr(t){return!(!t||!t[En])}function Ar(t,r){return t.__ownerID?(t.size=r.size,t._map=r,t):r===t._map?t:0===r.size?t.__empty():t.__make(r)}function jr(t,r){var e=Object.create(qn);return e.size=t?t.size:0,e._map=t,e.__ownerID=r,e}function kr(){return Mn||(Mn=jr(Zt()))}function Rr(t,r,e){for(var n=pt(r),i=0;i!==n.length;)if((t=dt(t,n[i++],ae))===ae)return e;return t}function Ur(t,r){return Rr(this,t,r)}function Kr(t,r){return Rr(t,r,ae)!==ae}function Tr(t){return Kr(this,t)}function Cr(){ht(this.size);var t={};return this.__iterate(function(r,e){t[e]=r}),t}function Lr(t,r,e,n,i,o){return ht(t.size),t.__iterate(function(t,o,u){i?(i=!1,e=t):e=r.call(n,e,t,o,u)},o),e}function Br(t,r){return r}function Wr(t,r){return[r,t]}function Nr(t){return function(){return!t.apply(this,arguments)}}function Pr(t){return function(){return-t.apply(this,arguments)}}function Jr(){return ct(arguments)}function Hr(t,r){return tr?-1:0}function Vr(t){if(t.size===1/0)return 0;var r=d(t),e=l(t),n=r?1:0;return Yr(t.__iterate(e?r?function(t,r){n=31*n+Qr(U(t),U(r))|0}:function(t,r){n=n+Qr(U(t),U(r))|0}:r?function(t){n=31*n+U(t)|0}:function(t){n=n+U(t)|0}),n)}function Yr(t,r){return r=Le(r,3432918353),r=Le(r<<15|r>>>-15,461845907),r=Le(r<<13|r>>>-13,5),r=(r+3864292196|0)^t,r=Le(r^r>>>16,2246822507),r=Le(r^r>>>13,3266489909),r=R(r^r>>>16)}function Qr(t,r){return t^r+2654435769+(t<<6)+(t>>2)|0}function Xr(t){return xr(t)&&d(t)}function Fr(t,r){var e=Object.create(Un);return e.size=t?t.size:0,e._map=t,e.__ownerID=r,e}function Gr(){return Kn||(Kn=Fr(Sr()))}function Zr(t,r,e){var n=Object.create(Object.getPrototypeOf(t));return n._values=r,n.__ownerID=e,n}function $r(t){return t._name||t.constructor.name||"Record"}function te(t){return D(t._keys.map(function(r){return[r,t.get(r)]}))}function re(t,r){try{Object.defineProperty(t,r,{get:function(){return this.get(r)},set:function(t){ +ft(this.__ownerID,"Cannot set on an immutable record."),this.set(r,t)}})}catch(t){}}function ee(t,r){return ne([],r||ie,t,"",r&&r.length>2?[]:void 0,{"":t})}function ne(t,r,e,n,i,o){var u=Array.isArray(e)?xe:_t(e)?De:null;if(u){if(~t.indexOf(e))throw new TypeError("Cannot convert circular structure to Immutable");t.push(e),i&&""!==n&&i.push(n);var s=r.call(o,n,u(e).map(function(n,o){return ne(t,r,n,o,i,e)}),i&&i.slice());return t.pop(),i&&i.pop(),s}return e}function ie(t,r){return l(r)?r.toMap():r.toList()}var oe=5,ue=1<=n.length){var r=e.next();if(r.done)return r;n[i]=r.value}return w(t,i,n[i++])})},r}(xe),Le="function"==typeof Math.imul&&Math.imul(4294967295,2)===-2?Math.imul:function(t,r){t|=0,r|=0 +;var e=65535&t,n=65535&r;return e*n+((t>>>16)*n+e*(r>>>16)<<16>>>0)|0},Be=Object.isExtensible,We=function(){try{return Object.defineProperty({},"@",{}),!0}catch(t){return!1}}(),Ne="function"==typeof WeakMap;Ne&&(Ke=new WeakMap);var Pe=0,Je="__immutablehash__";"function"==typeof Symbol&&(Je=Symbol(Je));var He=16,Ve=255,Ye=0,Qe={},Xe=function(t){function r(t,r){this._iter=t,this._useKeys=r,this.size=t.size}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.prototype.get=function(t,r){return this._iter.get(t,r)},r.prototype.has=function(t){return this._iter.has(t)},r.prototype.valueSeq=function(){return this._iter.valueSeq()},r.prototype.reverse=function(){var t=this,r=N(this,!0);return this._useKeys||(r.valueSeq=function(){return t._iter.toSeq().reverse()}),r},r.prototype.map=function(t,r){var e=this,n=W(this,t,r);return this._useKeys||(n.valueSeq=function(){return e._iter.toSeq().map(t,r)}),n},r.prototype.__iterate=function(t,r){var e=this;return this._iter.__iterate(function(r,n){return t(r,n,e)},r)},r.prototype.__iterator=function(t,r){return this._iter.__iterator(t,r)},r}(De);Xe.prototype[le]=!0;var Fe=function(t){function r(t){this._iter=t,this.size=t.size}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.prototype.includes=function(t){return this._iter.includes(t)},r.prototype.__iterate=function(t,r){var e=this,n=0;return r&&i(this),this._iter.__iterate(function(i){return t(i,r?e.size-++n:n++,e)},r)},r.prototype.__iterator=function(t,r){var e=this,n=this._iter.__iterator(ze,r),o=0;return r&&i(this),new Ee(function(){var i=n.next();return i.done?i:w(t,r?e.size-++o:o++,i.value,i)})},r}(xe),Ge=function(t){function r(t){this._iter=t,this.size=t.size}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.prototype.has=function(t){return this._iter.includes(t)},r.prototype.__iterate=function(t,r){var e=this;return this._iter.__iterate(function(r){return t(r,r,e)},r)}, +r.prototype.__iterator=function(t,r){var e=this._iter.__iterator(ze,r);return new Ee(function(){var r=e.next();return r.done?r:w(t,r.value,r.value,r)})},r}(Ae),Ze=function(t){function r(t){this._iter=t,this.size=t.size}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.prototype.entrySeq=function(){return this._iter.toSeq()},r.prototype.__iterate=function(t,r){var e=this;return this._iter.__iterate(function(r){if(r){it(r);var n=_(r);return t(n?r.get(1):r[1],n?r.get(0):r[0],e)}},r)},r.prototype.__iterator=function(t,r){var e=this._iter.__iterator(ze,r);return new Ee(function(){for(;;){var r=e.next();if(r.done)return r;var n=r.value;if(n){it(n);var i=_(n);return w(t,i?n.get(0):n[0],i?n.get(1):n[1],r)}}})},r}(De);Fe.prototype.cacheResult=Xe.prototype.cacheResult=Ge.prototype.cacheResult=Ze.prototype.cacheResult=st;var $e=function(t){function r(r){return null===r||void 0===r?Zt():Qt(r)&&!d(r)?r:Zt().withMutations(function(e){var n=t(r);ht(n.size),n.forEach(function(t,r){return e.set(r,t)})})}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.of=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return Zt().withMutations(function(r){for(var e=0;e=t.length)throw Error("Missing value for key: "+t[e]);r.set(t[e],t[e+1])}})},r.prototype.toString=function(){return this.__toString("Map {","}")},r.prototype.get=function(t,r){return this._root?this._root.get(0,void 0,t,r):r},r.prototype.set=function(t,r){return $t(this,t,r)},r.prototype.remove=function(t){return $t(this,t,ae)},r.prototype.deleteAll=function(t){var r=ye(t);return 0===r.size?this:this.withMutations(function(t){r.forEach(function(r){return t.remove(r)})})},r.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):Zt()},r.prototype.sort=function(t){return mn($(this,t))},r.prototype.sortBy=function(t,r){return mn($(this,r,t))}, +r.prototype.__iterator=function(t,r){return new cn(this,t,r)},r.prototype.__iterate=function(t,r){var e=this,n=0;return this._root&&this._root.iterate(function(r){return n++,t(r[1],r[0],e)},r),n},r.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Gt(this.size,this._root,t,this.__hash):0===this.size?Zt():(this.__ownerID=t,this.__altered=!1,this)},r}(de);$e.isMap=Qt;var tn="@@__IMMUTABLE_MAP__@@",rn=$e.prototype;rn[tn]=!0,rn.delete=rn.remove,rn.removeAll=rn.deleteAll,rn.concat=rn.merge,rn.setIn=bt,rn.removeIn=rn.deleteIn=Et,rn.update=Mt,rn.updateIn=Dt,rn.merge=xt,rn.mergeWith=At,rn.mergeDeep=Bt,rn.mergeDeepWith=Wt,rn.mergeIn=Nt,rn.mergeDeepIn=Pt,rn.withMutations=Jt,rn.wasAltered=Yt,rn.asImmutable=Vt,rn["@@transducer/init"]=rn.asMutable=Ht,rn["@@transducer/step"]=function(t,r){return t.set(r[0],r[1])},rn["@@transducer/result"]=function(t){return t.asImmutable()};var en=function(t,r){this.ownerID=t,this.entries=r};en.prototype.get=function(t,r,e,n){for(var i=this.entries,o=0,u=i.length;o=fn)return nr(t,c,i,o);var _=t&&t===this.ownerID,l=_?c:ct(c);return p?a?f===h-1?l.pop():l[f]=l.pop():l[f]=[i,o]:l.push([i,o]),_?(this.entries=l,this):new en(t,l)}};var nn=function(t,r,e){this.ownerID=t,this.bitmap=r,this.nodes=e};nn.prototype.get=function(t,r,e,n){void 0===r&&(r=U(e));var i=1<<((0===t?r:r>>>t)&se),o=this.bitmap;return 0==(o&i)?n:this.nodes[ur(o&i-1)].get(t+oe,r,e,n)},nn.prototype.update=function(t,r,e,n,i,o,u){void 0===e&&(e=U(n));var s=(0===r?e:e>>>r)&se,a=1<=hn)return or(t,p,c,s,l);if(f&&!l&&2===p.length&&rr(p[1^h]))return p[1^h];if(f&&l&&1===p.length&&rr(l))return l +;var v=t&&t===this.ownerID,y=f?l?c:c^a:c|a,d=f?l?sr(p,h,l,v):cr(p,h,v):ar(p,h,l,v);return v?(this.bitmap=y,this.nodes=d,this):new nn(t,y,d)};var on=function(t,r,e){this.ownerID=t,this.count=r,this.nodes=e};on.prototype.get=function(t,r,e,n){void 0===r&&(r=U(e));var i=(0===t?r:r>>>t)&se,o=this.nodes[i];return o?o.get(t+oe,r,e,n):n},on.prototype.update=function(t,r,e,n,i,o,u){void 0===e&&(e=U(n));var s=(0===r?e:e>>>r)&se,a=i===ae,c=this.nodes,f=c[s];if(a&&!f)return this;var h=tr(f,t,r+oe,e,n,i,o,u);if(h===f)return this;var p=this.count;if(f){if(!h&&--p0&&i=0&&t>>r&se;if(n>=this.array.length)return new yn([],t);var i,o=0===n;if(r>0){var u=this.array[n];if((i=u&&u.removeBefore(t,r-oe,e))===u&&o)return this}if(o&&!i)return this;var s=yr(this,t);if(!o)for(var a=0;a>>r&se +;if(n>=this.array.length)return this;var i;if(r>0){var o=this.array[n];if((i=o&&o.removeAfter(t,r-oe,e))===o&&n===this.array.length-1)return this}var u=yr(this,t);return u.array.splice(n+1),i&&(u.array[n]=i),u};var dn,gn={},mn=function(t){function r(t){return null===t||void 0===t?Sr():wr(t)?t:Sr().withMutations(function(r){var e=de(t);ht(e.size),e.forEach(function(t,e){return r.set(e,t)})})}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.of=function(){return this(arguments)},r.prototype.toString=function(){return this.__toString("OrderedMap {","}")},r.prototype.get=function(t,r){var e=this._map.get(t);return void 0!==e?this._list.get(e)[1]:r},r.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._map.clear(),this._list.clear(),this):Sr()},r.prototype.set=function(t,r){return Ir(this,t,r)},r.prototype.remove=function(t){return Ir(this,t,ae)},r.prototype.wasAltered=function(){return this._map.wasAltered()||this._list.wasAltered()},r.prototype.__iterate=function(t,r){var e=this;return this._list.__iterate(function(r){return r&&t(r[1],r[0],e)},r)},r.prototype.__iterator=function(t,r){return this._list.fromEntrySeq().__iterator(t,r)},r.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var r=this._map.__ensureOwner(t),e=this._list.__ensureOwner(t);return t?zr(r,e,t,this.__hash):0===this.size?Sr():(this.__ownerID=t,this._map=r,this._list=e,this)},r}($e);mn.isOrderedMap=wr,mn.prototype[le]=!0,mn.prototype.delete=mn.prototype.remove;var wn,zn=function(t){function r(t){return null===t||void 0===t?Er():br(t)?t:Er().pushAll(t)}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.of=function(){return this(arguments)},r.prototype.toString=function(){return this.__toString("Stack [","]")},r.prototype.get=function(t,r){var e=this._head;for(t=o(this,t);e&&t--;)e=e.next;return e?e.value:r},r.prototype.peek=function(){return this._head&&this._head.value},r.prototype.push=function(){ +var t=arguments;if(0===arguments.length)return this;for(var r=this.size+arguments.length,e=this._head,n=arguments.length-1;n>=0;n--)e={value:t[n],next:e};return this.__ownerID?(this.size=r,this._head=e,this.__hash=void 0,this.__altered=!0,this):Or(r,e)},r.prototype.pushAll=function(r){if(r=t(r),0===r.size)return this;if(0===this.size&&br(r))return r;ht(r.size);var e=this.size,n=this._head;return r.__iterate(function(t){e++,n={value:t,next:n}},!0),this.__ownerID?(this.size=e,this._head=n,this.__hash=void 0,this.__altered=!0,this):Or(e,n)},r.prototype.pop=function(){return this.slice(1)},r.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):Er()},r.prototype.slice=function(r,e){if(s(r,e,this.size))return this;var n=a(r,this.size);if(c(e,this.size)!==this.size)return t.prototype.slice.call(this,r,e);for(var i=this.size-n,o=this._head;n--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):Or(i,o)},r.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Or(this.size,this._head,t,this.__hash):0===this.size?Er():(this.__ownerID=t,this.__altered=!1,this)},r.prototype.__iterate=function(t,r){var e=this;if(r)return new ke(this.toArray()).__iterate(function(r,n){return t(r,n,e)},r);for(var n=0,i=this._head;i&&t(i.value,n++,e)!==!1;)i=i.next;return n},r.prototype.__iterator=function(t,r){if(r)return new ke(this.toArray()).__iterator(t,r);var e=0,n=this._head;return new Ee(function(){if(n){var r=n.value;return n=n.next,w(t,e++,r)}return z()})},r}(ge);zn.isStack=br;var Sn="@@__IMMUTABLE_STACK__@@",In=zn.prototype;In[Sn]=!0,In.shift=In.pop,In.unshift=In.push,In.unshiftAll=In.pushAll,In.withMutations=Jt,In.wasAltered=Yt,In.asImmutable=Vt,In["@@transducer/init"]=In.asMutable=Ht,In["@@transducer/step"]=function(t,r){return t.unshift(r)},In["@@transducer/result"]=function(t){return t.asImmutable()};var bn,On=function(t){function r(r){ +return null===r||void 0===r?kr():xr(r)&&!d(r)?r:kr().withMutations(function(e){var n=t(r);ht(n.size),n.forEach(function(t){return e.add(t)})})}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.of=function(){return this(arguments)},r.fromKeys=function(t){return this(de(t).keySeq())},r.intersect=function(t){return t=ye(t).toArray(),t.length?qn.intersect.apply(r(t.pop()),t):kr()},r.union=function(t){return t=ye(t).toArray(),t.length?qn.union.apply(r(t.pop()),t):kr()},r.prototype.toString=function(){return this.__toString("Set {","}")},r.prototype.has=function(t){return this._map.has(t)},r.prototype.add=function(t){return Ar(this,this._map.set(t,t))},r.prototype.remove=function(t){return Ar(this,this._map.remove(t))},r.prototype.clear=function(){return Ar(this,this._map.clear())},r.prototype.union=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];return r=r.filter(function(t){return 0!==t.size}),0===r.length?this:0!==this.size||this.__ownerID||1!==r.length?this.withMutations(function(e){for(var n=0;n=0&&r=0&&ethis.size?r:this.find(function(r,e){return e===t},void 0,r)},has:function(t){return(t=o(this,t))>=0&&(void 0!==this.size?this.size===1/0||t Date: Tue, 17 Oct 2017 00:29:15 +0000 Subject: [PATCH 065/242] Deploy 732a1590bea87b86c0d7282c549008cea3a472f5 to NPM branch --- dist/immutable.es.js | 60 +++++++++++++++++++++---------------------- dist/immutable.js | 60 +++++++++++++++++++++---------------------- dist/immutable.min.js | 52 ++++++++++++++++++------------------- 3 files changed, 84 insertions(+), 88 deletions(-) diff --git a/dist/immutable.es.js b/dist/immutable.es.js index d2ad2b79d3..b0d2534ee4 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -2087,17 +2087,17 @@ function merge() { var iters = [], len = arguments.length; while ( len-- ) iters[ len ] = arguments[ len ]; - return mergeIntoKeyedWith(this, undefined, iters); + return mergeIntoKeyedWith(this, iters); } function mergeWith(merger) { var iters = [], len = arguments.length - 1; while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; - return mergeIntoKeyedWith(this, merger, iters); + return mergeIntoKeyedWith(this, iters, merger); } -function mergeIntoKeyedWith(collection, merger, collections) { +function mergeIntoKeyedWith(collection, collections, merger) { var iters = []; for (var ii = 0; ii < collections.length; ii++) { var collection$1 = KeyedCollection(collections[ii]); @@ -2134,31 +2134,35 @@ function merge$1(collection) { var sources = [], len = arguments.length - 1; while ( len-- > 0 ) sources[ len ] = arguments[ len + 1 ]; - return mergeWithSources(undefined, collection, sources); + return mergeWithSources(collection, sources); } function mergeWith$1(merger, collection) { var sources = [], len = arguments.length - 2; while ( len-- > 0 ) sources[ len ] = arguments[ len + 2 ]; - return mergeWithSources(merger, collection, sources); + return mergeWithSources(collection, sources, merger); } function mergeDeep$1(collection) { var sources = [], len = arguments.length - 1; while ( len-- > 0 ) sources[ len ] = arguments[ len + 1 ]; - return mergeWithSources(deepMergerWith(alwaysNewValue), collection, sources); + return mergeDeepWithSources(collection, sources); } function mergeDeepWith$1(merger, collection) { var sources = [], len = arguments.length - 2; while ( len-- > 0 ) sources[ len ] = arguments[ len + 2 ]; - return mergeWithSources(deepMergerWith(merger), collection, sources); + return mergeDeepWithSources(collection, sources, merger); } -function mergeWithSources(merger, collection, sources) { +function mergeDeepWithSources(collection, sources, merger) { + return mergeWithSources(collection, sources, deepMergerWith(merger)); +} + +function mergeWithSources(collection, sources, merger) { if (!isDataStructure(collection)) { throw new TypeError( 'Cannot merge into non-data-structure value: ' + collection @@ -2181,11 +2185,10 @@ function mergeWithSources(merger, collection, sources) { merged.push(value); } : function (value, key) { + var hasVal = hasOwnProperty.call(merged, key); var nextVal = - merger && hasOwnProperty.call(merged, key) - ? merger(merged[key], value, key) - : value; - if (!hasOwnProperty.call(merged, key) || nextVal !== merged[key]) { + hasVal && merger ? merger(merged[key], value, key) : value; + if (!hasVal || nextVal !== merged[key]) { // Copy on write if (merged === collection) { merged = shallowCopy(merged); @@ -2201,45 +2204,40 @@ function mergeWithSources(merger, collection, sources) { function deepMergerWith(merger) { function deepMerger(oldValue, newValue, key) { - if (isDataStructure(oldValue) && isDataStructure(newValue)) { - return mergeWithSources(deepMerger, oldValue, [newValue]); - } - var nextValue = merger(oldValue, newValue, key); - return is(oldValue, nextValue) ? oldValue : nextValue; + return isDataStructure(oldValue) && isDataStructure(newValue) + ? mergeWithSources(oldValue, [newValue], deepMerger) + : merger ? merger(oldValue, newValue, key) : newValue; } return deepMerger; } -function alwaysNewValue(oldValue, newValue) { - return newValue; -} - -function mergeDeep$$1() { +function mergeDeep() { var iters = [], len = arguments.length; while ( len-- ) iters[ len ] = arguments[ len ]; - return mergeDeep$1.apply(void 0, [ this ].concat( iters )); + return mergeDeepWithSources(this, iters); } -function mergeDeepWith$$1(merger) { +function mergeDeepWith(merger) { var iters = [], len = arguments.length - 1; while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; - return mergeDeepWith$1.apply(void 0, [ merger, this ].concat( iters )); + return mergeDeepWithSources(this, iters, merger); } function mergeIn(keyPath) { var iters = [], len = arguments.length - 1; while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; - return updateIn(this, keyPath, emptyMap(), function (m) { return merge$1.apply(void 0, [ m ].concat( iters )); }); + return updateIn(this, keyPath, emptyMap(), function (m) { return mergeWithSources(m, iters); }); } function mergeDeepIn(keyPath) { var iters = [], len = arguments.length - 1; while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; - return updateIn(this, keyPath, emptyMap(), function (m) { return mergeDeep$1.apply(void 0, [ m ].concat( iters )); }); + return updateIn(this, keyPath, emptyMap(), function (m) { return mergeDeepWithSources(m, iters); } + ); } function withMutations(fn) { @@ -2406,8 +2404,8 @@ MapPrototype.update = update$$1; MapPrototype.updateIn = updateIn$1; MapPrototype.merge = merge; MapPrototype.mergeWith = mergeWith; -MapPrototype.mergeDeep = mergeDeep$$1; -MapPrototype.mergeDeepWith = mergeDeepWith$$1; +MapPrototype.mergeDeep = mergeDeep; +MapPrototype.mergeDeepWith = mergeDeepWith; MapPrototype.mergeIn = mergeIn; MapPrototype.mergeDeepIn = mergeDeepIn; MapPrototype.withMutations = withMutations; @@ -5511,8 +5509,8 @@ RecordPrototype.hasIn = CollectionPrototype.hasIn; RecordPrototype.merge = merge; RecordPrototype.mergeWith = mergeWith; RecordPrototype.mergeIn = mergeIn; -RecordPrototype.mergeDeep = mergeDeep$$1; -RecordPrototype.mergeDeepWith = mergeDeepWith$$1; +RecordPrototype.mergeDeep = mergeDeep; +RecordPrototype.mergeDeepWith = mergeDeepWith; RecordPrototype.mergeDeepIn = mergeDeepIn; RecordPrototype.setIn = setIn$$1; RecordPrototype.update = update$$1; diff --git a/dist/immutable.js b/dist/immutable.js index 8a4492c25a..f3d0d12303 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -2093,17 +2093,17 @@ function merge() { var iters = [], len = arguments.length; while ( len-- ) iters[ len ] = arguments[ len ]; - return mergeIntoKeyedWith(this, undefined, iters); + return mergeIntoKeyedWith(this, iters); } function mergeWith(merger) { var iters = [], len = arguments.length - 1; while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; - return mergeIntoKeyedWith(this, merger, iters); + return mergeIntoKeyedWith(this, iters, merger); } -function mergeIntoKeyedWith(collection, merger, collections) { +function mergeIntoKeyedWith(collection, collections, merger) { var iters = []; for (var ii = 0; ii < collections.length; ii++) { var collection$1 = KeyedCollection(collections[ii]); @@ -2140,31 +2140,35 @@ function merge$1(collection) { var sources = [], len = arguments.length - 1; while ( len-- > 0 ) sources[ len ] = arguments[ len + 1 ]; - return mergeWithSources(undefined, collection, sources); + return mergeWithSources(collection, sources); } function mergeWith$1(merger, collection) { var sources = [], len = arguments.length - 2; while ( len-- > 0 ) sources[ len ] = arguments[ len + 2 ]; - return mergeWithSources(merger, collection, sources); + return mergeWithSources(collection, sources, merger); } function mergeDeep$1(collection) { var sources = [], len = arguments.length - 1; while ( len-- > 0 ) sources[ len ] = arguments[ len + 1 ]; - return mergeWithSources(deepMergerWith(alwaysNewValue), collection, sources); + return mergeDeepWithSources(collection, sources); } function mergeDeepWith$1(merger, collection) { var sources = [], len = arguments.length - 2; while ( len-- > 0 ) sources[ len ] = arguments[ len + 2 ]; - return mergeWithSources(deepMergerWith(merger), collection, sources); + return mergeDeepWithSources(collection, sources, merger); } -function mergeWithSources(merger, collection, sources) { +function mergeDeepWithSources(collection, sources, merger) { + return mergeWithSources(collection, sources, deepMergerWith(merger)); +} + +function mergeWithSources(collection, sources, merger) { if (!isDataStructure(collection)) { throw new TypeError( 'Cannot merge into non-data-structure value: ' + collection @@ -2187,11 +2191,10 @@ function mergeWithSources(merger, collection, sources) { merged.push(value); } : function (value, key) { + var hasVal = hasOwnProperty.call(merged, key); var nextVal = - merger && hasOwnProperty.call(merged, key) - ? merger(merged[key], value, key) - : value; - if (!hasOwnProperty.call(merged, key) || nextVal !== merged[key]) { + hasVal && merger ? merger(merged[key], value, key) : value; + if (!hasVal || nextVal !== merged[key]) { // Copy on write if (merged === collection) { merged = shallowCopy(merged); @@ -2207,45 +2210,40 @@ function mergeWithSources(merger, collection, sources) { function deepMergerWith(merger) { function deepMerger(oldValue, newValue, key) { - if (isDataStructure(oldValue) && isDataStructure(newValue)) { - return mergeWithSources(deepMerger, oldValue, [newValue]); - } - var nextValue = merger(oldValue, newValue, key); - return is(oldValue, nextValue) ? oldValue : nextValue; + return isDataStructure(oldValue) && isDataStructure(newValue) + ? mergeWithSources(oldValue, [newValue], deepMerger) + : merger ? merger(oldValue, newValue, key) : newValue; } return deepMerger; } -function alwaysNewValue(oldValue, newValue) { - return newValue; -} - -function mergeDeep$$1() { +function mergeDeep() { var iters = [], len = arguments.length; while ( len-- ) iters[ len ] = arguments[ len ]; - return mergeDeep$1.apply(void 0, [ this ].concat( iters )); + return mergeDeepWithSources(this, iters); } -function mergeDeepWith$$1(merger) { +function mergeDeepWith(merger) { var iters = [], len = arguments.length - 1; while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; - return mergeDeepWith$1.apply(void 0, [ merger, this ].concat( iters )); + return mergeDeepWithSources(this, iters, merger); } function mergeIn(keyPath) { var iters = [], len = arguments.length - 1; while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; - return updateIn(this, keyPath, emptyMap(), function (m) { return merge$1.apply(void 0, [ m ].concat( iters )); }); + return updateIn(this, keyPath, emptyMap(), function (m) { return mergeWithSources(m, iters); }); } function mergeDeepIn(keyPath) { var iters = [], len = arguments.length - 1; while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; - return updateIn(this, keyPath, emptyMap(), function (m) { return mergeDeep$1.apply(void 0, [ m ].concat( iters )); }); + return updateIn(this, keyPath, emptyMap(), function (m) { return mergeDeepWithSources(m, iters); } + ); } function withMutations(fn) { @@ -2412,8 +2410,8 @@ MapPrototype.update = update$$1; MapPrototype.updateIn = updateIn$1; MapPrototype.merge = merge; MapPrototype.mergeWith = mergeWith; -MapPrototype.mergeDeep = mergeDeep$$1; -MapPrototype.mergeDeepWith = mergeDeepWith$$1; +MapPrototype.mergeDeep = mergeDeep; +MapPrototype.mergeDeepWith = mergeDeepWith; MapPrototype.mergeIn = mergeIn; MapPrototype.mergeDeepIn = mergeDeepIn; MapPrototype.withMutations = withMutations; @@ -5517,8 +5515,8 @@ RecordPrototype.hasIn = CollectionPrototype.hasIn; RecordPrototype.merge = merge; RecordPrototype.mergeWith = mergeWith; RecordPrototype.mergeIn = mergeIn; -RecordPrototype.mergeDeep = mergeDeep$$1; -RecordPrototype.mergeDeepWith = mergeDeepWith$$1; +RecordPrototype.mergeDeep = mergeDeep; +RecordPrototype.mergeDeepWith = mergeDeepWith; RecordPrototype.mergeDeepIn = mergeDeepIn; RecordPrototype.setIn = setIn$$1; RecordPrototype.update = update$$1; diff --git a/dist/immutable.min.js b/dist/immutable.min.js index 43df1032f3..dbc4d7586a 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -10,29 +10,29 @@ return t.documentElement&&t.documentElement.uniqueID}}function B(t){var r=ut(t); if(r.call(e,t,o,a))return s++,i(t,n?o:s-1,u)},o),s},i.__iteratorUncached=function(i,o){var u=t.__iterator(Se,o),s=0;return new Ee(function(){for(;;){var o=u.next();if(o.done)return o;var a=o.value,c=a[0],f=a[1];if(r.call(e,f,c,t))return w(i,n?c:s++,f,o)}})},i}function J(t,r,e){var n=$e().asMutable();return t.__iterate(function(i,o){n.update(r.call(e,i,o,t),0,function(t){return t+1})}),n.asImmutable()}function H(t,r,e){var n=l(t),i=(d(t)?mn():$e()).asMutable();t.__iterate(function(o,u){i.update(r.call(e,o,u,t),function(t){return t=t||[],t.push(n?[u,o]:o),t})});var o=ot(t);return i.map(function(r){return nt(t,o(r))})}function V(t,r,e,n){var i=t.size;if(s(r,e,i))return t;var u=a(r,i),f=c(e,i);if(u!==u||f!==f)return V(t.toSeq().cacheResult(),r,e,n);var h,p=f-u;p===p&&(h=p<0?0:p);var _=ut(t);return _.size=0===h?h:t.size&&h||void 0,!n&&q(t)&&h>=0&&(_.get=function(r,e){return r=o(this,r),r>=0&&rh)return z();var t=i.next();return n||r===ze||t.done?t:r===we?w(r,s-1,void 0,t):w(r,s-1,t.value[1],t)})},_}function Y(t,r,e){var n=ut(t);return n.__iterateUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterate(n,i);var u=0;return t.__iterate(function(t,i,s){return r.call(e,t,i,s)&&++u&&n(t,i,o)}),u},n.__iteratorUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterator(n,i);var u=t.__iterator(Se,i),s=!0;return new Ee(function(){if(!s)return z();var t=u.next();if(t.done)return t;var i=t.value,a=i[0],c=i[1];return r.call(e,c,a,o)?n===Se?t:w(n,a,c,t):(s=!1,z())})},n}function Q(t,r,e,n){var i=ut(t);return i.__iterateUncached=function(i,o){var u=this ;if(o)return this.cacheResult().__iterate(i,o);var s=!0,a=0;return t.__iterate(function(t,o,c){if(!s||!(s=r.call(e,t,o,c)))return a++,i(t,n?o:a-1,u)}),a},i.__iteratorUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterator(i,o);var s=t.__iterator(Se,o),a=!0,c=0;return new Ee(function(){var t,o,f;do{if(t=s.next(),t.done)return n||i===ze?t:i===we?w(i,c++,void 0,t):w(i,c++,t.value[1],t);var h=t.value;o=h[0],f=h[1],a&&(a=r.call(e,f,o,u))}while(a);return i===Se?t:w(i,o,f,t)})},i}function X(t,r){var e=l(t),n=[t].concat(r).map(function(t){return _(t)?e&&(t=de(t)):t=e?D(t):x(Array.isArray(t)?t:[t]),t}).filter(function(t){return 0!==t.size});if(0===n.length)return t;if(1===n.length){var i=n[0];if(i===t||e&&l(i)||v(t)&&v(i))return i}var o=new ke(n);return e?o=o.toKeyedSeq():v(t)||(o=o.toSetSeq()),o=o.flatten(!0),o.size=n.reduce(function(t,r){if(void 0!==t){var e=r.size;if(void 0!==e)return t+e}},0),o}function F(t,r,e){var n=ut(t);return n.__iterateUncached=function(i,o){function u(t,c){t.__iterate(function(t,o){return(!r||c0}function et(t,r,e,n){var i=ut(t),o=new ke(e).map(function(t){return t.size});return i.size=n?o.max():o.min(),i.__iterate=function(t,r){for(var e,n=this,i=this.__iterator(ze,r),o=0;!(e=i.next()).done&&t(e.value,o++,n)!==!1;);return o},i.__iteratorUncached=function(t,i){var o=e.map(function(t){return t=ye(t),b(i?t.reverse():t)}),u=0,s=!1;return new Ee(function(){var e;return s||(e=o.map(function(t){return t.next()}),s=n?e.every(function(t){return t.done}):e.some(function(t){return t.done})),s?z():w(t,u++,r.apply(null,e.map(function(t){return t.value})))})},i}function nt(t,r){return t===r?t:q(t)?r:t.constructor(r)}function it(t){if(t!==Object(t))throw new TypeError("Expected [K, V] tuple: "+t)}function ot(t){return l(t)?de:v(t)?ge:me}function ut(t){return Object.create((l(t)?De:v(t)?xe:Ae).prototype)}function st(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size,this):Me.prototype.cacheResult.call(this)}function at(t,r){return void 0===t&&void 0===r?0:void 0===t?1:void 0===r?-1:t>r?1:t0;)r[e]=arguments[e+1];return jt(this,t,r)}function jt(t,r,e){for(var n=[],i=0;i0;)r[e]=arguments[e+1];return Tt(void 0,t,r)}function Rt(t,r){for(var e=[],n=arguments.length-2;n-- >0;)e[n]=arguments[n+2];return Tt(t,r,e)}function Ut(t){for(var r=[],e=arguments.length-1;e-- >0;)r[e]=arguments[e+1];return Tt(Ct(Lt),t,r)}function Kt(t,r){for(var e=[],n=arguments.length-2;n-- >0;)e[n]=arguments[n+2];return Tt(Ct(t),r,e)}function Tt(t,r,e){if(!lt(r))throw new TypeError("Cannot merge into non-data-structure value: "+r);if(p(r))return r.mergeWith?r.mergeWith.apply(r,[t].concat(e)):r.concat.apply(r,e);for(var n=Array.isArray(r),i=r,o=n?ge:de,u=n?function(t){i===r&&(i=gt(i)),i.push(t)}:function(e,n){var o=t&&qe.call(i,n)?t(i[n],e,n):e;qe.call(i,n)&&o===i[n]||(i===r&&(i=gt(i)),i[n]=o)},s=0;s0;)r[e]=arguments[e+1];return Kt.apply(void 0,[t,this].concat(r))}function Nt(t){for(var r=[],e=arguments.length-1;e-- >0;)r[e]=arguments[e+1];return zt(this,t,Zt(),function(t){return kt.apply(void 0,[t].concat(r))})}function Pt(t){for(var r=[],e=arguments.length-1;e-- >0;)r[e]=arguments[e+1];return zt(this,t,Zt(),function(t){return Ut.apply(void 0,[t].concat(r))})}function Jt(t){var r=this.asMutable();return t(r),r.wasAltered()?r.__ensureOwner(this.__ownerID):this}function Ht(){return this.__ownerID?this:this.__ensureOwner(new n)}function Vt(){return this.__ensureOwner()}function Yt(){return this.__altered}function Qt(t){return!(!t||!t[tn])}function Xt(t,r){return w(t,r[0],r[1])} -function Ft(t,r){return{node:t,index:0,__prev:r}}function Gt(t,r,e,n){var i=Object.create(rn);return i.size=t,i._root=r,i.__ownerID=e,i.__hash=n,i.__altered=!1,i}function Zt(){return an||(an=Gt(0))}function $t(t,e,n){var i,o;if(t._root){var u=r(ce),s=r(fe);if(i=tr(t._root,t.__ownerID,0,void 0,e,n,u,s),!s.value)return t;o=t.size+(u.value?n===ae?-1:1:0)}else{if(n===ae)return t;o=1,i=new en(t.__ownerID,[[e,n]])}return t.__ownerID?(t.size=o,t._root=i,t.__hash=void 0,t.__altered=!0,t):i?Gt(o,i):Zt()}function tr(t,r,n,i,o,u,s,a){return t?t.update(r,n,i,o,u,s,a):u===ae?t:(e(a),e(s),new sn(r,i,[o,u]))}function rr(t){return t.constructor===sn||t.constructor===un}function er(t,r,e,n,i){if(t.keyHash===n)return new un(r,n,[t.entry,i]);var o,u=(0===e?t.keyHash:t.keyHash>>>e)&se,s=(0===e?n:n>>>e)&se;return new nn(r,1<>>=1)u[s]=1&e?r[o++]:void 0;return u[n]=i,new on(t,o+1,u)}function ur(t){return t-=t>>1&1431655765,t=(858993459&t)+(t>>2&858993459),t=t+(t>>4)&252645135,t+=t>>8,127&(t+=t>>16)}function sr(t,r,e,n){var i=n?t:ct(t);return i[r]=e,i}function ar(t,r,e,n){var i=t.length+1;if(n&&r+1===i)return t[r]=e,t;for(var o=Array(i),u=0,s=0;so?0:o-e,c=u-e;return c>ue&&(c=ue),function(){if(i===c)return gn;var t=r?--c:i++;return n&&n[t]}}function i(t,n,i){ -var s,a=t&&t.array,c=i>o?0:o-i>>n,f=1+(u-i>>n);return f>ue&&(f=ue),function(){for(;;){if(s){var t=s();if(t!==gn)return t;s=null}if(c===f)return gn;var o=r?--f:c++;s=e(a&&a[o],n-oe,i+(o<=t.size||e<0)return t.withMutations(function(t){e<0?gr(t,e).set(0,n):gr(t,0,e+1).set(e,n)});e+=t._origin;var i=t._tail,u=t._root,s=r(fe);return e>=mr(t._capacity)?i=vr(i,t.__ownerID,0,e,n,s):u=vr(u,t.__ownerID,t._level,e,n,s),s.value?t.__ownerID?(t._root=u,t._tail=i,t.__hash=void 0,t.__altered=!0,t):pr(t._origin,t._capacity,t._level,u,i):t}function vr(t,r,n,i,o,u){var s=i>>>n&se,a=t&&s0){var f=t&&t.array[s],h=vr(f,r,n-oe,i,o,u);return h===f?t:(c=yr(t,r),c.array[s]=h,c)}return a&&t.array[s]===o?t:(e(u),c=yr(t,r),void 0===o&&s===c.array.length-1?c.array.pop():c.array[s]=o,c)}function yr(t,r){return r&&t&&r===t.ownerID?t:new yn(t?t.array.slice():[],r)}function dr(t,r){if(r>=mr(t._capacity))return t._tail;if(r<1<0;)e=e.array[r>>>n&se],n-=oe;return e}}function gr(t,r,e){void 0!==r&&(r|=0),void 0!==e&&(e|=0);var i=t.__ownerID||new n,o=t._origin,u=t._capacity,s=o+r,a=void 0===e?u:e<0?u+e:o+e;if(s===o&&a===u)return t;if(s>=a)return t.clear();for(var c=t._level,f=t._root,h=0;s+h<0;)f=new yn(f&&f.array.length?[void 0,f]:[],i),c+=oe,h+=1<=1<p?new yn([],i):l;if(l&&_>p&&soe;d-=oe){var g=p>>>d&se;y=y.array[g]=yr(y.array[g],i)}y.array[p>>>oe&se]=l}if(a=_)s-=_,a-=_,c=oe,f=null, -v=v&&v.removeBefore(i,0,s);else if(s>o||_>>c&se;if(m!==_>>>c&se)break;m&&(h+=(1<o&&(f=f.removeBefore(i,c,s-h)),f&&_>>oe<=ue&&u.size>=2*o.size?(i=u.filter(function(t,r){return void 0!==t&&s!==r}),n=i.toKeyedSeq().map(function(t){return t[0]}).flip().toMap(),t.__ownerID&&(n.__ownerID=i.__ownerID=t.__ownerID)):(n=o.remove(r),i=s===u.size-1?u.pop():u.set(s,void 0))}else if(a){if(e===u.get(s)[1])return t;n=o,i=u.set(s,[r,e])}else n=o.set(r,u.size),i=u.set(u.size,[r,e]);return t.__ownerID?(t.size=n.size,t._map=n,t._list=i,t.__hash=void 0,t):zr(n,i)}function br(t){return!(!t||!t[Sn])}function Or(t,r,e,n){var i=Object.create(In);return i.size=t,i._head=r,i.__ownerID=e,i.__hash=n,i.__altered=!1,i}function Er(){return bn||(bn=Or(0))}function qr(t,r){if(t===r)return!0;if(!_(r)||void 0!==t.size&&void 0!==r.size&&t.size!==r.size||void 0!==t.__hash&&void 0!==r.__hash&&t.__hash!==r.__hash||l(t)!==l(r)||v(t)!==v(r)||d(t)!==d(r))return!1;if(0===t.size&&0===r.size)return!0;var e=!y(t);if(d(t)){var n=t.entries();return r.every(function(t,r){var i=n.next().value;return i&&k(i[1],t)&&(e||k(i[0],r))})&&n.next().done}var i=!1;if(void 0===t.size)if(void 0===r.size)"function"==typeof t.cacheResult&&t.cacheResult();else{i=!0;var o=t;t=r,r=o}var u=!0,s=r.__iterate(function(r,n){if(e?!t.has(r):i?!k(r,t.get(n,ae)):!k(t.get(n,ae),r))return u=!1,!1});return u&&t.size===s}function Mr(t,r){var e=function(e){t.prototype[e]=r[e]};return Object.keys(r).forEach(e), -Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(r).forEach(e),t}function Dr(t){return lt(t)?Me(t).map(Dr).toJSON():t}function xr(t){return!(!t||!t[En])}function Ar(t,r){return t.__ownerID?(t.size=r.size,t._map=r,t):r===t._map?t:0===r.size?t.__empty():t.__make(r)}function jr(t,r){var e=Object.create(qn);return e.size=t?t.size:0,e._map=t,e.__ownerID=r,e}function kr(){return Mn||(Mn=jr(Zt()))}function Rr(t,r,e){for(var n=pt(r),i=0;i!==n.length;)if((t=dt(t,n[i++],ae))===ae)return e;return t}function Ur(t,r){return Rr(this,t,r)}function Kr(t,r){return Rr(t,r,ae)!==ae}function Tr(t){return Kr(this,t)}function Cr(){ht(this.size);var t={};return this.__iterate(function(r,e){t[e]=r}),t}function Lr(t,r,e,n,i,o){return ht(t.size),t.__iterate(function(t,o,u){i?(i=!1,e=t):e=r.call(n,e,t,o,u)},o),e}function Br(t,r){return r}function Wr(t,r){return[r,t]}function Nr(t){return function(){return!t.apply(this,arguments)}}function Pr(t){return function(){return-t.apply(this,arguments)}}function Jr(){return ct(arguments)}function Hr(t,r){return tr?-1:0}function Vr(t){if(t.size===1/0)return 0;var r=d(t),e=l(t),n=r?1:0;return Yr(t.__iterate(e?r?function(t,r){n=31*n+Qr(U(t),U(r))|0}:function(t,r){n=n+Qr(U(t),U(r))|0}:r?function(t){n=31*n+U(t)|0}:function(t){n=n+U(t)|0}),n)}function Yr(t,r){return r=Le(r,3432918353),r=Le(r<<15|r>>>-15,461845907),r=Le(r<<13|r>>>-13,5),r=(r+3864292196|0)^t,r=Le(r^r>>>16,2246822507),r=Le(r^r>>>13,3266489909),r=R(r^r>>>16)}function Qr(t,r){return t^r+2654435769+(t<<6)+(t>>2)|0}function Xr(t){return xr(t)&&d(t)}function Fr(t,r){var e=Object.create(Un);return e.size=t?t.size:0,e._map=t,e.__ownerID=r,e}function Gr(){return Kn||(Kn=Fr(Sr()))}function Zr(t,r,e){var n=Object.create(Object.getPrototypeOf(t));return n._values=r,n.__ownerID=e,n}function $r(t){return t._name||t.constructor.name||"Record"}function te(t){return D(t._keys.map(function(r){return[r,t.get(r)]}))}function re(t,r){try{Object.defineProperty(t,r,{get:function(){return this.get(r)},set:function(t){ -ft(this.__ownerID,"Cannot set on an immutable record."),this.set(r,t)}})}catch(t){}}function ee(t,r){return ne([],r||ie,t,"",r&&r.length>2?[]:void 0,{"":t})}function ne(t,r,e,n,i,o){var u=Array.isArray(e)?xe:_t(e)?De:null;if(u){if(~t.indexOf(e))throw new TypeError("Cannot convert circular structure to Immutable");t.push(e),i&&""!==n&&i.push(n);var s=r.call(o,n,u(e).map(function(n,o){return ne(t,r,n,o,i,e)}),i&&i.slice());return t.pop(),i&&i.pop(),s}return e}function ie(t,r){return l(r)?r.toMap():r.toList()}var oe=5,ue=1<=n.length){var r=e.next();if(r.done)return r;n[i]=r.value}return w(t,i,n[i++])})},r}(xe),Le="function"==typeof Math.imul&&Math.imul(4294967295,2)===-2?Math.imul:function(t,r){t|=0,r|=0 -;var e=65535&t,n=65535&r;return e*n+((t>>>16)*n+e*(r>>>16)<<16>>>0)|0},Be=Object.isExtensible,We=function(){try{return Object.defineProperty({},"@",{}),!0}catch(t){return!1}}(),Ne="function"==typeof WeakMap;Ne&&(Ke=new WeakMap);var Pe=0,Je="__immutablehash__";"function"==typeof Symbol&&(Je=Symbol(Je));var He=16,Ve=255,Ye=0,Qe={},Xe=function(t){function r(t,r){this._iter=t,this._useKeys=r,this.size=t.size}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.prototype.get=function(t,r){return this._iter.get(t,r)},r.prototype.has=function(t){return this._iter.has(t)},r.prototype.valueSeq=function(){return this._iter.valueSeq()},r.prototype.reverse=function(){var t=this,r=N(this,!0);return this._useKeys||(r.valueSeq=function(){return t._iter.toSeq().reverse()}),r},r.prototype.map=function(t,r){var e=this,n=W(this,t,r);return this._useKeys||(n.valueSeq=function(){return e._iter.toSeq().map(t,r)}),n},r.prototype.__iterate=function(t,r){var e=this;return this._iter.__iterate(function(r,n){return t(r,n,e)},r)},r.prototype.__iterator=function(t,r){return this._iter.__iterator(t,r)},r}(De);Xe.prototype[le]=!0;var Fe=function(t){function r(t){this._iter=t,this.size=t.size}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.prototype.includes=function(t){return this._iter.includes(t)},r.prototype.__iterate=function(t,r){var e=this,n=0;return r&&i(this),this._iter.__iterate(function(i){return t(i,r?e.size-++n:n++,e)},r)},r.prototype.__iterator=function(t,r){var e=this,n=this._iter.__iterator(ze,r),o=0;return r&&i(this),new Ee(function(){var i=n.next();return i.done?i:w(t,r?e.size-++o:o++,i.value,i)})},r}(xe),Ge=function(t){function r(t){this._iter=t,this.size=t.size}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.prototype.has=function(t){return this._iter.includes(t)},r.prototype.__iterate=function(t,r){var e=this;return this._iter.__iterate(function(r){return t(r,r,e)},r)}, -r.prototype.__iterator=function(t,r){var e=this._iter.__iterator(ze,r);return new Ee(function(){var r=e.next();return r.done?r:w(t,r.value,r.value,r)})},r}(Ae),Ze=function(t){function r(t){this._iter=t,this.size=t.size}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.prototype.entrySeq=function(){return this._iter.toSeq()},r.prototype.__iterate=function(t,r){var e=this;return this._iter.__iterate(function(r){if(r){it(r);var n=_(r);return t(n?r.get(1):r[1],n?r.get(0):r[0],e)}},r)},r.prototype.__iterator=function(t,r){var e=this._iter.__iterator(ze,r);return new Ee(function(){for(;;){var r=e.next();if(r.done)return r;var n=r.value;if(n){it(n);var i=_(n);return w(t,i?n.get(0):n[0],i?n.get(1):n[1],r)}}})},r}(De);Fe.prototype.cacheResult=Xe.prototype.cacheResult=Ge.prototype.cacheResult=Ze.prototype.cacheResult=st;var $e=function(t){function r(r){return null===r||void 0===r?Zt():Qt(r)&&!d(r)?r:Zt().withMutations(function(e){var n=t(r);ht(n.size),n.forEach(function(t,r){return e.set(r,t)})})}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.of=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return Zt().withMutations(function(r){for(var e=0;e=t.length)throw Error("Missing value for key: "+t[e]);r.set(t[e],t[e+1])}})},r.prototype.toString=function(){return this.__toString("Map {","}")},r.prototype.get=function(t,r){return this._root?this._root.get(0,void 0,t,r):r},r.prototype.set=function(t,r){return $t(this,t,r)},r.prototype.remove=function(t){return $t(this,t,ae)},r.prototype.deleteAll=function(t){var r=ye(t);return 0===r.size?this:this.withMutations(function(t){r.forEach(function(r){return t.remove(r)})})},r.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):Zt()},r.prototype.sort=function(t){return mn($(this,t))},r.prototype.sortBy=function(t,r){return mn($(this,r,t))}, -r.prototype.__iterator=function(t,r){return new cn(this,t,r)},r.prototype.__iterate=function(t,r){var e=this,n=0;return this._root&&this._root.iterate(function(r){return n++,t(r[1],r[0],e)},r),n},r.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Gt(this.size,this._root,t,this.__hash):0===this.size?Zt():(this.__ownerID=t,this.__altered=!1,this)},r}(de);$e.isMap=Qt;var tn="@@__IMMUTABLE_MAP__@@",rn=$e.prototype;rn[tn]=!0,rn.delete=rn.remove,rn.removeAll=rn.deleteAll,rn.concat=rn.merge,rn.setIn=bt,rn.removeIn=rn.deleteIn=Et,rn.update=Mt,rn.updateIn=Dt,rn.merge=xt,rn.mergeWith=At,rn.mergeDeep=Bt,rn.mergeDeepWith=Wt,rn.mergeIn=Nt,rn.mergeDeepIn=Pt,rn.withMutations=Jt,rn.wasAltered=Yt,rn.asImmutable=Vt,rn["@@transducer/init"]=rn.asMutable=Ht,rn["@@transducer/step"]=function(t,r){return t.set(r[0],r[1])},rn["@@transducer/result"]=function(t){return t.asImmutable()};var en=function(t,r){this.ownerID=t,this.entries=r};en.prototype.get=function(t,r,e,n){for(var i=this.entries,o=0,u=i.length;o=fn)return nr(t,c,i,o);var _=t&&t===this.ownerID,l=_?c:ct(c);return p?a?f===h-1?l.pop():l[f]=l.pop():l[f]=[i,o]:l.push([i,o]),_?(this.entries=l,this):new en(t,l)}};var nn=function(t,r,e){this.ownerID=t,this.bitmap=r,this.nodes=e};nn.prototype.get=function(t,r,e,n){void 0===r&&(r=U(e));var i=1<<((0===t?r:r>>>t)&se),o=this.bitmap;return 0==(o&i)?n:this.nodes[ur(o&i-1)].get(t+oe,r,e,n)},nn.prototype.update=function(t,r,e,n,i,o,u){void 0===e&&(e=U(n));var s=(0===r?e:e>>>r)&se,a=1<=hn)return or(t,p,c,s,l);if(f&&!l&&2===p.length&&rr(p[1^h]))return p[1^h];if(f&&l&&1===p.length&&rr(l))return l -;var v=t&&t===this.ownerID,y=f?l?c:c^a:c|a,d=f?l?sr(p,h,l,v):cr(p,h,v):ar(p,h,l,v);return v?(this.bitmap=y,this.nodes=d,this):new nn(t,y,d)};var on=function(t,r,e){this.ownerID=t,this.count=r,this.nodes=e};on.prototype.get=function(t,r,e,n){void 0===r&&(r=U(e));var i=(0===t?r:r>>>t)&se,o=this.nodes[i];return o?o.get(t+oe,r,e,n):n},on.prototype.update=function(t,r,e,n,i,o,u){void 0===e&&(e=U(n));var s=(0===r?e:e>>>r)&se,a=i===ae,c=this.nodes,f=c[s];if(a&&!f)return this;var h=tr(f,t,r+oe,e,n,i,o,u);if(h===f)return this;var p=this.count;if(f){if(!h&&--p0&&i=0&&t>>r&se;if(n>=this.array.length)return new yn([],t);var i,o=0===n;if(r>0){var u=this.array[n];if((i=u&&u.removeBefore(t,r-oe,e))===u&&o)return this}if(o&&!i)return this;var s=yr(this,t);if(!o)for(var a=0;a>>r&se -;if(n>=this.array.length)return this;var i;if(r>0){var o=this.array[n];if((i=o&&o.removeAfter(t,r-oe,e))===o&&n===this.array.length-1)return this}var u=yr(this,t);return u.array.splice(n+1),i&&(u.array[n]=i),u};var dn,gn={},mn=function(t){function r(t){return null===t||void 0===t?Sr():wr(t)?t:Sr().withMutations(function(r){var e=de(t);ht(e.size),e.forEach(function(t,e){return r.set(e,t)})})}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.of=function(){return this(arguments)},r.prototype.toString=function(){return this.__toString("OrderedMap {","}")},r.prototype.get=function(t,r){var e=this._map.get(t);return void 0!==e?this._list.get(e)[1]:r},r.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._map.clear(),this._list.clear(),this):Sr()},r.prototype.set=function(t,r){return Ir(this,t,r)},r.prototype.remove=function(t){return Ir(this,t,ae)},r.prototype.wasAltered=function(){return this._map.wasAltered()||this._list.wasAltered()},r.prototype.__iterate=function(t,r){var e=this;return this._list.__iterate(function(r){return r&&t(r[1],r[0],e)},r)},r.prototype.__iterator=function(t,r){return this._list.fromEntrySeq().__iterator(t,r)},r.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var r=this._map.__ensureOwner(t),e=this._list.__ensureOwner(t);return t?zr(r,e,t,this.__hash):0===this.size?Sr():(this.__ownerID=t,this._map=r,this._list=e,this)},r}($e);mn.isOrderedMap=wr,mn.prototype[le]=!0,mn.prototype.delete=mn.prototype.remove;var wn,zn=function(t){function r(t){return null===t||void 0===t?Er():br(t)?t:Er().pushAll(t)}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.of=function(){return this(arguments)},r.prototype.toString=function(){return this.__toString("Stack [","]")},r.prototype.get=function(t,r){var e=this._head;for(t=o(this,t);e&&t--;)e=e.next;return e?e.value:r},r.prototype.peek=function(){return this._head&&this._head.value},r.prototype.push=function(){ -var t=arguments;if(0===arguments.length)return this;for(var r=this.size+arguments.length,e=this._head,n=arguments.length-1;n>=0;n--)e={value:t[n],next:e};return this.__ownerID?(this.size=r,this._head=e,this.__hash=void 0,this.__altered=!0,this):Or(r,e)},r.prototype.pushAll=function(r){if(r=t(r),0===r.size)return this;if(0===this.size&&br(r))return r;ht(r.size);var e=this.size,n=this._head;return r.__iterate(function(t){e++,n={value:t,next:n}},!0),this.__ownerID?(this.size=e,this._head=n,this.__hash=void 0,this.__altered=!0,this):Or(e,n)},r.prototype.pop=function(){return this.slice(1)},r.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):Er()},r.prototype.slice=function(r,e){if(s(r,e,this.size))return this;var n=a(r,this.size);if(c(e,this.size)!==this.size)return t.prototype.slice.call(this,r,e);for(var i=this.size-n,o=this._head;n--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):Or(i,o)},r.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Or(this.size,this._head,t,this.__hash):0===this.size?Er():(this.__ownerID=t,this.__altered=!1,this)},r.prototype.__iterate=function(t,r){var e=this;if(r)return new ke(this.toArray()).__iterate(function(r,n){return t(r,n,e)},r);for(var n=0,i=this._head;i&&t(i.value,n++,e)!==!1;)i=i.next;return n},r.prototype.__iterator=function(t,r){if(r)return new ke(this.toArray()).__iterator(t,r);var e=0,n=this._head;return new Ee(function(){if(n){var r=n.value;return n=n.next,w(t,e++,r)}return z()})},r}(ge);zn.isStack=br;var Sn="@@__IMMUTABLE_STACK__@@",In=zn.prototype;In[Sn]=!0,In.shift=In.pop,In.unshift=In.push,In.unshiftAll=In.pushAll,In.withMutations=Jt,In.wasAltered=Yt,In.asImmutable=Vt,In["@@transducer/init"]=In.asMutable=Ht,In["@@transducer/step"]=function(t,r){return t.unshift(r)},In["@@transducer/result"]=function(t){return t.asImmutable()};var bn,On=function(t){function r(r){ -return null===r||void 0===r?kr():xr(r)&&!d(r)?r:kr().withMutations(function(e){var n=t(r);ht(n.size),n.forEach(function(t){return e.add(t)})})}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.of=function(){return this(arguments)},r.fromKeys=function(t){return this(de(t).keySeq())},r.intersect=function(t){return t=ye(t).toArray(),t.length?qn.intersect.apply(r(t.pop()),t):kr()},r.union=function(t){return t=ye(t).toArray(),t.length?qn.union.apply(r(t.pop()),t):kr()},r.prototype.toString=function(){return this.__toString("Set {","}")},r.prototype.has=function(t){return this._map.has(t)},r.prototype.add=function(t){return Ar(this,this._map.set(t,t))},r.prototype.remove=function(t){return Ar(this,this._map.remove(t))},r.prototype.clear=function(){return Ar(this,this._map.clear())},r.prototype.union=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];return r=r.filter(function(t){return 0!==t.size}),0===r.length?this:0!==this.size||this.__ownerID||1!==r.length?this.withMutations(function(e){for(var n=0;n=0&&r=0&&ethis.size?r:this.find(function(r,e){return e===t},void 0,r)},has:function(t){return(t=o(this,t))>=0&&(void 0!==this.size?this.size===1/0||t0;)r[e]=arguments[e+1];return jt(this,r,t)}function jt(t,r,e){for(var n=[],i=0;i0;)r[e]=arguments[e+1];return Ct(t,r)}function Rt(t,r){for(var e=[],n=arguments.length-2;n-- >0;)e[n]=arguments[n+2];return Ct(r,e,t)}function Ut(t){for(var r=[],e=arguments.length-1;e-- >0;)r[e]=arguments[e+1];return Tt(t,r)}function Kt(t,r){for(var e=[],n=arguments.length-2;n-- >0;)e[n]=arguments[n+2];return Tt(r,e,t)}function Tt(t,r,e){return Ct(t,r,Lt(e))}function Ct(t,r,e){if(!lt(t))throw new TypeError("Cannot merge into non-data-structure value: "+t);if(p(t))return t.mergeWith?t.mergeWith.apply(t,[e].concat(r)):t.concat.apply(t,r);for(var n=Array.isArray(t),i=t,o=n?ge:de,u=n?function(r){i===t&&(i=gt(i)),i.push(r)}:function(r,n){var o=qe.call(i,n),u=o&&e?e(i[n],r,n):r;o&&u===i[n]||(i===t&&(i=gt(i)),i[n]=u)},s=0;s0;)r[e]=arguments[e+1];return Tt(this,r,t)}function Nt(t){for(var r=[],e=arguments.length-1;e-- >0;)r[e]=arguments[e+1];return zt(this,t,Zt(),function(t){return Ct(t,r)})}function Pt(t){for(var r=[],e=arguments.length-1;e-- >0;)r[e]=arguments[e+1];return zt(this,t,Zt(),function(t){return Tt(t,r)})}function Jt(t){var r=this.asMutable();return t(r),r.wasAltered()?r.__ensureOwner(this.__ownerID):this}function Ht(){return this.__ownerID?this:this.__ensureOwner(new n)}function Vt(){return this.__ensureOwner()}function Yt(){return this.__altered}function Qt(t){return!(!t||!t[tn])}function Xt(t,r){return w(t,r[0],r[1])}function Ft(t,r){return{node:t,index:0,__prev:r}}function Gt(t,r,e,n){var i=Object.create(rn);return i.size=t,i._root=r,i.__ownerID=e,i.__hash=n,i.__altered=!1,i}function Zt(){return an||(an=Gt(0))}function $t(t,e,n){ +var i,o;if(t._root){var u=r(ce),s=r(fe);if(i=tr(t._root,t.__ownerID,0,void 0,e,n,u,s),!s.value)return t;o=t.size+(u.value?n===ae?-1:1:0)}else{if(n===ae)return t;o=1,i=new en(t.__ownerID,[[e,n]])}return t.__ownerID?(t.size=o,t._root=i,t.__hash=void 0,t.__altered=!0,t):i?Gt(o,i):Zt()}function tr(t,r,n,i,o,u,s,a){return t?t.update(r,n,i,o,u,s,a):u===ae?t:(e(a),e(s),new sn(r,i,[o,u]))}function rr(t){return t.constructor===sn||t.constructor===un}function er(t,r,e,n,i){if(t.keyHash===n)return new un(r,n,[t.entry,i]);var o,u=(0===e?t.keyHash:t.keyHash>>>e)&se,s=(0===e?n:n>>>e)&se;return new nn(r,1<>>=1)u[s]=1&e?r[o++]:void 0;return u[n]=i,new on(t,o+1,u)}function ur(t){return t-=t>>1&1431655765,t=(858993459&t)+(t>>2&858993459),t=t+(t>>4)&252645135,t+=t>>8,127&(t+=t>>16)}function sr(t,r,e,n){var i=n?t:ct(t);return i[r]=e,i}function ar(t,r,e,n){var i=t.length+1;if(n&&r+1===i)return t[r]=e,t;for(var o=Array(i),u=0,s=0;so?0:o-e,c=u-e;return c>ue&&(c=ue),function(){if(i===c)return gn;var t=r?--c:i++;return n&&n[t]}}function i(t,n,i){var s,a=t&&t.array,c=i>o?0:o-i>>n,f=1+(u-i>>n);return f>ue&&(f=ue),function(){for(;;){if(s){var t=s();if(t!==gn)return t;s=null}if(c===f)return gn;var o=r?--f:c++;s=e(a&&a[o],n-oe,i+(o<=t.size||e<0)return t.withMutations(function(t){e<0?gr(t,e).set(0,n):gr(t,0,e+1).set(e,n)});e+=t._origin;var i=t._tail,u=t._root,s=r(fe);return e>=mr(t._capacity)?i=vr(i,t.__ownerID,0,e,n,s):u=vr(u,t.__ownerID,t._level,e,n,s),s.value?t.__ownerID?(t._root=u,t._tail=i,t.__hash=void 0,t.__altered=!0,t):pr(t._origin,t._capacity,t._level,u,i):t}function vr(t,r,n,i,o,u){var s=i>>>n&se,a=t&&s0){var f=t&&t.array[s],h=vr(f,r,n-oe,i,o,u);return h===f?t:(c=yr(t,r),c.array[s]=h,c)}return a&&t.array[s]===o?t:(e(u),c=yr(t,r),void 0===o&&s===c.array.length-1?c.array.pop():c.array[s]=o,c)}function yr(t,r){return r&&t&&r===t.ownerID?t:new yn(t?t.array.slice():[],r)}function dr(t,r){if(r>=mr(t._capacity))return t._tail;if(r<1<0;)e=e.array[r>>>n&se],n-=oe;return e}}function gr(t,r,e){void 0!==r&&(r|=0),void 0!==e&&(e|=0);var i=t.__ownerID||new n,o=t._origin,u=t._capacity,s=o+r,a=void 0===e?u:e<0?u+e:o+e;if(s===o&&a===u)return t;if(s>=a)return t.clear();for(var c=t._level,f=t._root,h=0;s+h<0;)f=new yn(f&&f.array.length?[void 0,f]:[],i),c+=oe,h+=1<=1<p?new yn([],i):l;if(l&&_>p&&soe;d-=oe){var g=p>>>d&se;y=y.array[g]=yr(y.array[g],i)}y.array[p>>>oe&se]=l}if(a=_)s-=_,a-=_,c=oe,f=null,v=v&&v.removeBefore(i,0,s);else if(s>o||_>>c&se;if(m!==_>>>c&se)break;m&&(h+=(1<o&&(f=f.removeBefore(i,c,s-h)),f&&_>>oe<=ue&&u.size>=2*o.size?(i=u.filter(function(t,r){return void 0!==t&&s!==r}),n=i.toKeyedSeq().map(function(t){return t[0]}).flip().toMap(),t.__ownerID&&(n.__ownerID=i.__ownerID=t.__ownerID)):(n=o.remove(r),i=s===u.size-1?u.pop():u.set(s,void 0))}else if(a){if(e===u.get(s)[1])return t;n=o,i=u.set(s,[r,e])}else n=o.set(r,u.size),i=u.set(u.size,[r,e]);return t.__ownerID?(t.size=n.size,t._map=n,t._list=i,t.__hash=void 0,t):zr(n,i)}function br(t){return!(!t||!t[Sn])}function Or(t,r,e,n){var i=Object.create(In);return i.size=t,i._head=r,i.__ownerID=e,i.__hash=n,i.__altered=!1,i}function Er(){return bn||(bn=Or(0))}function qr(t,r){if(t===r)return!0;if(!_(r)||void 0!==t.size&&void 0!==r.size&&t.size!==r.size||void 0!==t.__hash&&void 0!==r.__hash&&t.__hash!==r.__hash||l(t)!==l(r)||v(t)!==v(r)||d(t)!==d(r))return!1;if(0===t.size&&0===r.size)return!0;var e=!y(t);if(d(t)){var n=t.entries();return r.every(function(t,r){var i=n.next().value;return i&&k(i[1],t)&&(e||k(i[0],r))})&&n.next().done}var i=!1;if(void 0===t.size)if(void 0===r.size)"function"==typeof t.cacheResult&&t.cacheResult();else{i=!0;var o=t;t=r,r=o}var u=!0,s=r.__iterate(function(r,n){if(e?!t.has(r):i?!k(r,t.get(n,ae)):!k(t.get(n,ae),r))return u=!1,!1});return u&&t.size===s}function Mr(t,r){var e=function(e){t.prototype[e]=r[e]};return Object.keys(r).forEach(e),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(r).forEach(e),t}function Dr(t){return lt(t)?Me(t).map(Dr).toJSON():t}function xr(t){return!(!t||!t[En])}function Ar(t,r){return t.__ownerID?(t.size=r.size,t._map=r, +t):r===t._map?t:0===r.size?t.__empty():t.__make(r)}function jr(t,r){var e=Object.create(qn);return e.size=t?t.size:0,e._map=t,e.__ownerID=r,e}function kr(){return Mn||(Mn=jr(Zt()))}function Rr(t,r,e){for(var n=pt(r),i=0;i!==n.length;)if((t=dt(t,n[i++],ae))===ae)return e;return t}function Ur(t,r){return Rr(this,t,r)}function Kr(t,r){return Rr(t,r,ae)!==ae}function Tr(t){return Kr(this,t)}function Cr(){ht(this.size);var t={};return this.__iterate(function(r,e){t[e]=r}),t}function Lr(t,r,e,n,i,o){return ht(t.size),t.__iterate(function(t,o,u){i?(i=!1,e=t):e=r.call(n,e,t,o,u)},o),e}function Br(t,r){return r}function Wr(t,r){return[r,t]}function Nr(t){return function(){return!t.apply(this,arguments)}}function Pr(t){return function(){return-t.apply(this,arguments)}}function Jr(){return ct(arguments)}function Hr(t,r){return tr?-1:0}function Vr(t){if(t.size===1/0)return 0;var r=d(t),e=l(t),n=r?1:0;return Yr(t.__iterate(e?r?function(t,r){n=31*n+Qr(U(t),U(r))|0}:function(t,r){n=n+Qr(U(t),U(r))|0}:r?function(t){n=31*n+U(t)|0}:function(t){n=n+U(t)|0}),n)}function Yr(t,r){return r=Le(r,3432918353),r=Le(r<<15|r>>>-15,461845907),r=Le(r<<13|r>>>-13,5),r=(r+3864292196|0)^t,r=Le(r^r>>>16,2246822507),r=Le(r^r>>>13,3266489909),r=R(r^r>>>16)}function Qr(t,r){return t^r+2654435769+(t<<6)+(t>>2)|0}function Xr(t){return xr(t)&&d(t)}function Fr(t,r){var e=Object.create(Un);return e.size=t?t.size:0,e._map=t,e.__ownerID=r,e}function Gr(){return Kn||(Kn=Fr(Sr()))}function Zr(t,r,e){var n=Object.create(Object.getPrototypeOf(t));return n._values=r,n.__ownerID=e,n}function $r(t){return t._name||t.constructor.name||"Record"}function te(t){return D(t._keys.map(function(r){return[r,t.get(r)]}))}function re(t,r){try{Object.defineProperty(t,r,{get:function(){return this.get(r)},set:function(t){ft(this.__ownerID,"Cannot set on an immutable record."),this.set(r,t)}})}catch(t){}}function ee(t,r){return ne([],r||ie,t,"",r&&r.length>2?[]:void 0,{"":t})}function ne(t,r,e,n,i,o){var u=Array.isArray(e)?xe:_t(e)?De:null;if(u){ +if(~t.indexOf(e))throw new TypeError("Cannot convert circular structure to Immutable");t.push(e),i&&""!==n&&i.push(n);var s=r.call(o,n,u(e).map(function(n,o){return ne(t,r,n,o,i,e)}),i&&i.slice());return t.pop(),i&&i.pop(),s}return e}function ie(t,r){return l(r)?r.toMap():r.toList()}var oe=5,ue=1<=n.length){var r=e.next();if(r.done)return r;n[i]=r.value}return w(t,i,n[i++])})},r}(xe),Le="function"==typeof Math.imul&&Math.imul(4294967295,2)===-2?Math.imul:function(t,r){t|=0,r|=0;var e=65535&t,n=65535&r;return e*n+((t>>>16)*n+e*(r>>>16)<<16>>>0)|0},Be=Object.isExtensible,We=function(){try{return Object.defineProperty({},"@",{}),!0}catch(t){return!1}}(),Ne="function"==typeof WeakMap +;Ne&&(Ke=new WeakMap);var Pe=0,Je="__immutablehash__";"function"==typeof Symbol&&(Je=Symbol(Je));var He=16,Ve=255,Ye=0,Qe={},Xe=function(t){function r(t,r){this._iter=t,this._useKeys=r,this.size=t.size}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.prototype.get=function(t,r){return this._iter.get(t,r)},r.prototype.has=function(t){return this._iter.has(t)},r.prototype.valueSeq=function(){return this._iter.valueSeq()},r.prototype.reverse=function(){var t=this,r=N(this,!0);return this._useKeys||(r.valueSeq=function(){return t._iter.toSeq().reverse()}),r},r.prototype.map=function(t,r){var e=this,n=W(this,t,r);return this._useKeys||(n.valueSeq=function(){return e._iter.toSeq().map(t,r)}),n},r.prototype.__iterate=function(t,r){var e=this;return this._iter.__iterate(function(r,n){return t(r,n,e)},r)},r.prototype.__iterator=function(t,r){return this._iter.__iterator(t,r)},r}(De);Xe.prototype[le]=!0;var Fe=function(t){function r(t){this._iter=t,this.size=t.size}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.prototype.includes=function(t){return this._iter.includes(t)},r.prototype.__iterate=function(t,r){var e=this,n=0;return r&&i(this),this._iter.__iterate(function(i){return t(i,r?e.size-++n:n++,e)},r)},r.prototype.__iterator=function(t,r){var e=this,n=this._iter.__iterator(ze,r),o=0;return r&&i(this),new Ee(function(){var i=n.next();return i.done?i:w(t,r?e.size-++o:o++,i.value,i)})},r}(xe),Ge=function(t){function r(t){this._iter=t,this.size=t.size}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.prototype.has=function(t){return this._iter.includes(t)},r.prototype.__iterate=function(t,r){var e=this;return this._iter.__iterate(function(r){return t(r,r,e)},r)},r.prototype.__iterator=function(t,r){var e=this._iter.__iterator(ze,r);return new Ee(function(){var r=e.next();return r.done?r:w(t,r.value,r.value,r)})},r}(Ae),Ze=function(t){function r(t){this._iter=t,this.size=t.size} +return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.prototype.entrySeq=function(){return this._iter.toSeq()},r.prototype.__iterate=function(t,r){var e=this;return this._iter.__iterate(function(r){if(r){it(r);var n=_(r);return t(n?r.get(1):r[1],n?r.get(0):r[0],e)}},r)},r.prototype.__iterator=function(t,r){var e=this._iter.__iterator(ze,r);return new Ee(function(){for(;;){var r=e.next();if(r.done)return r;var n=r.value;if(n){it(n);var i=_(n);return w(t,i?n.get(0):n[0],i?n.get(1):n[1],r)}}})},r}(De);Fe.prototype.cacheResult=Xe.prototype.cacheResult=Ge.prototype.cacheResult=Ze.prototype.cacheResult=st;var $e=function(t){function r(r){return null===r||void 0===r?Zt():Qt(r)&&!d(r)?r:Zt().withMutations(function(e){var n=t(r);ht(n.size),n.forEach(function(t,r){return e.set(r,t)})})}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.of=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return Zt().withMutations(function(r){for(var e=0;e=t.length)throw Error("Missing value for key: "+t[e]);r.set(t[e],t[e+1])}})},r.prototype.toString=function(){return this.__toString("Map {","}")},r.prototype.get=function(t,r){return this._root?this._root.get(0,void 0,t,r):r},r.prototype.set=function(t,r){return $t(this,t,r)},r.prototype.remove=function(t){return $t(this,t,ae)},r.prototype.deleteAll=function(t){var r=ye(t);return 0===r.size?this:this.withMutations(function(t){r.forEach(function(r){return t.remove(r)})})},r.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):Zt()},r.prototype.sort=function(t){return mn($(this,t))},r.prototype.sortBy=function(t,r){return mn($(this,r,t))},r.prototype.__iterator=function(t,r){return new cn(this,t,r)},r.prototype.__iterate=function(t,r){var e=this,n=0;return this._root&&this._root.iterate(function(r){return n++,t(r[1],r[0],e)},r),n},r.prototype.__ensureOwner=function(t){ +return t===this.__ownerID?this:t?Gt(this.size,this._root,t,this.__hash):0===this.size?Zt():(this.__ownerID=t,this.__altered=!1,this)},r}(de);$e.isMap=Qt;var tn="@@__IMMUTABLE_MAP__@@",rn=$e.prototype;rn[tn]=!0,rn.delete=rn.remove,rn.removeAll=rn.deleteAll,rn.concat=rn.merge,rn.setIn=bt,rn.removeIn=rn.deleteIn=Et,rn.update=Mt,rn.updateIn=Dt,rn.merge=xt,rn.mergeWith=At,rn.mergeDeep=Bt,rn.mergeDeepWith=Wt,rn.mergeIn=Nt,rn.mergeDeepIn=Pt,rn.withMutations=Jt,rn.wasAltered=Yt,rn.asImmutable=Vt,rn["@@transducer/init"]=rn.asMutable=Ht,rn["@@transducer/step"]=function(t,r){return t.set(r[0],r[1])},rn["@@transducer/result"]=function(t){return t.asImmutable()};var en=function(t,r){this.ownerID=t,this.entries=r};en.prototype.get=function(t,r,e,n){for(var i=this.entries,o=0,u=i.length;o=fn)return nr(t,c,i,o);var _=t&&t===this.ownerID,l=_?c:ct(c);return p?a?f===h-1?l.pop():l[f]=l.pop():l[f]=[i,o]:l.push([i,o]),_?(this.entries=l,this):new en(t,l)}};var nn=function(t,r,e){this.ownerID=t,this.bitmap=r,this.nodes=e};nn.prototype.get=function(t,r,e,n){void 0===r&&(r=U(e));var i=1<<((0===t?r:r>>>t)&se),o=this.bitmap;return 0==(o&i)?n:this.nodes[ur(o&i-1)].get(t+oe,r,e,n)},nn.prototype.update=function(t,r,e,n,i,o,u){void 0===e&&(e=U(n));var s=(0===r?e:e>>>r)&se,a=1<=hn)return or(t,p,c,s,l);if(f&&!l&&2===p.length&&rr(p[1^h]))return p[1^h];if(f&&l&&1===p.length&&rr(l))return l;var v=t&&t===this.ownerID,y=f?l?c:c^a:c|a,d=f?l?sr(p,h,l,v):cr(p,h,v):ar(p,h,l,v);return v?(this.bitmap=y,this.nodes=d,this):new nn(t,y,d)};var on=function(t,r,e){this.ownerID=t,this.count=r,this.nodes=e};on.prototype.get=function(t,r,e,n){ +void 0===r&&(r=U(e));var i=(0===t?r:r>>>t)&se,o=this.nodes[i];return o?o.get(t+oe,r,e,n):n},on.prototype.update=function(t,r,e,n,i,o,u){void 0===e&&(e=U(n));var s=(0===r?e:e>>>r)&se,a=i===ae,c=this.nodes,f=c[s];if(a&&!f)return this;var h=tr(f,t,r+oe,e,n,i,o,u);if(h===f)return this;var p=this.count;if(f){if(!h&&--p0&&i=0&&t>>r&se;if(n>=this.array.length)return new yn([],t);var i,o=0===n;if(r>0){var u=this.array[n];if((i=u&&u.removeBefore(t,r-oe,e))===u&&o)return this}if(o&&!i)return this;var s=yr(this,t);if(!o)for(var a=0;a>>r&se;if(n>=this.array.length)return this;var i;if(r>0){var o=this.array[n];if((i=o&&o.removeAfter(t,r-oe,e))===o&&n===this.array.length-1)return this}var u=yr(this,t);return u.array.splice(n+1),i&&(u.array[n]=i),u};var dn,gn={},mn=function(t){function r(t){ +return null===t||void 0===t?Sr():wr(t)?t:Sr().withMutations(function(r){var e=de(t);ht(e.size),e.forEach(function(t,e){return r.set(e,t)})})}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.of=function(){return this(arguments)},r.prototype.toString=function(){return this.__toString("OrderedMap {","}")},r.prototype.get=function(t,r){var e=this._map.get(t);return void 0!==e?this._list.get(e)[1]:r},r.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._map.clear(),this._list.clear(),this):Sr()},r.prototype.set=function(t,r){return Ir(this,t,r)},r.prototype.remove=function(t){return Ir(this,t,ae)},r.prototype.wasAltered=function(){return this._map.wasAltered()||this._list.wasAltered()},r.prototype.__iterate=function(t,r){var e=this;return this._list.__iterate(function(r){return r&&t(r[1],r[0],e)},r)},r.prototype.__iterator=function(t,r){return this._list.fromEntrySeq().__iterator(t,r)},r.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var r=this._map.__ensureOwner(t),e=this._list.__ensureOwner(t);return t?zr(r,e,t,this.__hash):0===this.size?Sr():(this.__ownerID=t,this._map=r,this._list=e,this)},r}($e);mn.isOrderedMap=wr,mn.prototype[le]=!0,mn.prototype.delete=mn.prototype.remove;var wn,zn=function(t){function r(t){return null===t||void 0===t?Er():br(t)?t:Er().pushAll(t)}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.of=function(){return this(arguments)},r.prototype.toString=function(){return this.__toString("Stack [","]")},r.prototype.get=function(t,r){var e=this._head;for(t=o(this,t);e&&t--;)e=e.next;return e?e.value:r},r.prototype.peek=function(){return this._head&&this._head.value},r.prototype.push=function(){var t=arguments;if(0===arguments.length)return this;for(var r=this.size+arguments.length,e=this._head,n=arguments.length-1;n>=0;n--)e={value:t[n],next:e};return this.__ownerID?(this.size=r,this._head=e,this.__hash=void 0,this.__altered=!0,this):Or(r,e)}, +r.prototype.pushAll=function(r){if(r=t(r),0===r.size)return this;if(0===this.size&&br(r))return r;ht(r.size);var e=this.size,n=this._head;return r.__iterate(function(t){e++,n={value:t,next:n}},!0),this.__ownerID?(this.size=e,this._head=n,this.__hash=void 0,this.__altered=!0,this):Or(e,n)},r.prototype.pop=function(){return this.slice(1)},r.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):Er()},r.prototype.slice=function(r,e){if(s(r,e,this.size))return this;var n=a(r,this.size);if(c(e,this.size)!==this.size)return t.prototype.slice.call(this,r,e);for(var i=this.size-n,o=this._head;n--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):Or(i,o)},r.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Or(this.size,this._head,t,this.__hash):0===this.size?Er():(this.__ownerID=t,this.__altered=!1,this)},r.prototype.__iterate=function(t,r){var e=this;if(r)return new ke(this.toArray()).__iterate(function(r,n){return t(r,n,e)},r);for(var n=0,i=this._head;i&&t(i.value,n++,e)!==!1;)i=i.next;return n},r.prototype.__iterator=function(t,r){if(r)return new ke(this.toArray()).__iterator(t,r);var e=0,n=this._head;return new Ee(function(){if(n){var r=n.value;return n=n.next,w(t,e++,r)}return z()})},r}(ge);zn.isStack=br;var Sn="@@__IMMUTABLE_STACK__@@",In=zn.prototype;In[Sn]=!0,In.shift=In.pop,In.unshift=In.push,In.unshiftAll=In.pushAll,In.withMutations=Jt,In.wasAltered=Yt,In.asImmutable=Vt,In["@@transducer/init"]=In.asMutable=Ht,In["@@transducer/step"]=function(t,r){return t.unshift(r)},In["@@transducer/result"]=function(t){return t.asImmutable()};var bn,On=function(t){function r(r){return null===r||void 0===r?kr():xr(r)&&!d(r)?r:kr().withMutations(function(e){var n=t(r);ht(n.size),n.forEach(function(t){return e.add(t)})})}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.of=function(){return this(arguments)},r.fromKeys=function(t){ +return this(de(t).keySeq())},r.intersect=function(t){return t=ye(t).toArray(),t.length?qn.intersect.apply(r(t.pop()),t):kr()},r.union=function(t){return t=ye(t).toArray(),t.length?qn.union.apply(r(t.pop()),t):kr()},r.prototype.toString=function(){return this.__toString("Set {","}")},r.prototype.has=function(t){return this._map.has(t)},r.prototype.add=function(t){return Ar(this,this._map.set(t,t))},r.prototype.remove=function(t){return Ar(this,this._map.remove(t))},r.prototype.clear=function(){return Ar(this,this._map.clear())},r.prototype.union=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];return r=r.filter(function(t){return 0!==t.size}),0===r.length?this:0!==this.size||this.__ownerID||1!==r.length?this.withMutations(function(e){for(var n=0;n=0&&r=0&&ethis.size?r:this.find(function(r,e){return e===t},void 0,r)},has:function(t){return(t=o(this,t))>=0&&(void 0!==this.size?this.size===1/0||t Date: Tue, 17 Oct 2017 00:35:50 +0000 Subject: [PATCH 066/242] Deploy a44b738a4bf51d0b4a8a22c0247bef0ad52011c7 to NPM branch --- README.md | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index ab155b3078..8d9059ce36 100644 --- a/README.md +++ b/README.md @@ -51,37 +51,41 @@ map1.get('b') + " vs. " + map2.get('b') // 2 vs. 50 ### Browser -To use Immutable.js from a browser, download [dist/immutable.min.js](https://github.com/facebook/immutable-js/blob/master/dist/immutable.min.js) -or use a CDN such as [CDNJS](https://cdnjs.com/libraries/immutable) -or [jsDelivr](http://www.jsdelivr.com/#!immutable.js). +Immutable.js has no depenencnies, which makes it predictable to include in a Browser. -Then, add it as a script tag to your page: +It's highly recommended to use a module bundler like [webpack](https://webpack.github.io/), +[rollup](https://rollupjs.org/), or +[browserify](http://browserify.org/). The `immutable` npm module works +without any additional consideration. All examples throughout the documentation +will assume use of this kind of tool. + +Alternatively, Immutable.js may be directly included as a script tag. Download +or link to a CDN such as [CDNJS](https://cdnjs.com/libraries/immutable) +or [jsDelivr](https://www.jsdelivr.com/package/npm/immutable). + +Use a script tag to directly add `Immutable` to the global scope: ```html ``` -Or use an AMD loader (such as [RequireJS](http://requirejs.org/)): +Or use an AMD-style loader (such as [RequireJS](http://requirejs.org/)): ```js require(['./immutable.min.js'], function (Immutable) { - var map1 = Immutable.Map({a:1, b:2, c:3}); - var map2 = map1.set('b', 50); - map1.get('b'); // 2 - map2.get('b'); // 50 + var map1 = Immutable.Map({a:1, b:2, c:3}); + var map2 = map1.set('b', 50); + map1.get('b'); // 2 + map2.get('b'); // 50 }); ``` -If you're using [webpack](https://webpack.github.io/) or -[browserify](http://browserify.org/), the `immutable` npm module also works -from the browser. - ### Flow & TypeScript Use these Immutable collections and sequences as you would use native From 4052ab80264c067b0df9b0a4b04f8d368d1b4610 Mon Sep 17 00:00:00 2001 From: Travis CI Date: Tue, 17 Oct 2017 03:26:45 +0000 Subject: [PATCH 067/242] Deploy 9ce3546a2245e96710593116253f2fa3ceffbd25 to NPM branch --- dist/immutable-nonambient.d.ts | 2 +- dist/immutable.d.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/immutable-nonambient.d.ts b/dist/immutable-nonambient.d.ts index 0e338800ae..501eebb82a 100644 --- a/dist/immutable-nonambient.d.ts +++ b/dist/immutable-nonambient.d.ts @@ -5029,7 +5029,7 @@ * ``` */ export function updateIn(collection: C, keyPath: Iterable, updater: (value: any) => any): C; - + export function updateIn(collection: C, keyPath: Iterable, notSetValue: any, updater: (value: any) => any): C; /** * Returns a copy of the collection with the remaining collections merged in. diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index 02352deb04..360743ce82 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -5029,7 +5029,7 @@ declare module Immutable { * ``` */ export function updateIn(collection: C, keyPath: Iterable, updater: (value: any) => any): C; - + export function updateIn(collection: C, keyPath: Iterable, notSetValue: any, updater: (value: any) => any): C; /** * Returns a copy of the collection with the remaining collections merged in. From 0f57ebe8890c9447cedb1df42e2061ab02b8a3be Mon Sep 17 00:00:00 2001 From: Travis CI Date: Tue, 17 Oct 2017 04:06:25 +0000 Subject: [PATCH 068/242] Deploy d6352e474f8cb664570c69325502d9173ead7759 to NPM branch --- README.md | 198 +++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 135 insertions(+), 63 deletions(-) diff --git a/README.md b/README.md index 8d9059ce36..cadcb900b6 100644 --- a/README.md +++ b/README.md @@ -363,93 +363,100 @@ const nested4 = nested3.updateIn([ 'a', 'b', 'c' ], list => list.push(6)) ``` -Lazy Seq --------- +Equality treats Collections as Values +------------------------------------- -`Seq` describes a lazy operation, allowing them to efficiently chain -use of all the sequence methods (such as `map` and `filter`). +Immutable.js collections are treated as pure data *values*. Two immutable +collections are considered *value equal* (via `.equals()` or `is()`) if they +represent the same collection of values. This differs from JavaScript's typical +*reference equal* (via `===` or `==`) for Objects and Arrays which only +determines if two variables represent references to the same object instance. -**Seq is immutable** — Once a Seq is created, it cannot be -changed, appended to, rearranged or otherwise modified. Instead, any mutative -method called on a Seq will return a new Seq. - -**Seq is lazy** — Seq does as little work as necessary to respond to any -method call. - -For example, the following does not perform any work, because the resulting -Seq is never used: +Consider the example below where two identical `Map` instances are not +*reference equal* but are *value equal*. + ```js -const { Seq } = require('immutable') -const oddSquares = Seq([ 1, 2, 3, 4, 5, 6, 7, 8 ]) - .filter(x => x % 2) - .map(x => x * x) -``` - -Once the Seq is used, it performs only the work necessary. In this -example, no intermediate arrays are ever created, filter is called three times, -and map is only called once: +// First consider: +const obj1 = { a: 1, b: 2, c: 3 } +const obj2 = { a: 1, b: 2, c: 3 } +obj1 !== obj2 // two different instances are always not equal with === -```js -console.log(oddSquares.get(1)); // 9 +const { Map, is } = require('immutable') +const map1 = Map({ a: 1, b: 2, c: 3 }) +const map2 = Map({ a: 1, b: 2, c: 3 }) +map1 !== map2 // two different instances are not reference-equal +map1.equals(map2) // but are value-equal if they have the same values +is(map1, map2) // alternatively can use the is() function ``` -Any collection can be converted to a lazy Seq with `.toSeq()`. +Value equality allows Immutable.js collections to be used as keys in Maps or +values in Sets, and retrieved with different but equivalent collections: ```js -const { Map } = require('immutable') -const seq = Map({ a: 1, b: 2, c: 3 }).toSeq() +const { Map, Set } = require('immutable') +const map1 = Map({ a: 1, b: 2, c: 3 }) +const map2 = Map({ a: 1, b: 2, c: 3 }) +const set = Set().add(map1) +set.has(map2) // true because these are value-equal ``` -Seq allows for the efficient chaining of sequence operations, especially when -converting to a different concrete type (such as to a JS object): +Note: `is()` uses the same measure of equality as [Object.is][] for scalar +strings and numbers, but uses value equality for Immutable collections, +determining if both are immutable and all keys and values are equal +using the same measure of equality. -```js -seq.flip().map(key => key.toUpperCase()).flip().toObject(); -// { A: 1, B: 2, C: 3 } -``` +[Object.is]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is -As well as expressing logic that would otherwise seem memory-limited: +#### Performance tradeoffs - -```js -const { Range } = require('immutable') -Range(1, Infinity) - .skip(1000) - .map(n => -n) - .filter(n => n % 2 === 0) - .take(2) - .reduce((r, n) => r * n, 1); -// 1006008 -``` - -Note: A Collection is always iterated in the same order, however that order may -not always be well defined, as is the case for the `Map`. +While value equality is useful in many circumstances, it has different +performance characteristics than reference equality. Understanding these +tradeoffs may help you decide which to use in each case, especially when used +to memoize some operation. +When comparing two collections, value equality may require considering every +item in each collection, on an `O(N)` time complexity. For large collections of +values, this could become a costly operation. Though if the two are not equal +and hardly similar, the inequality is determined very quickly. In contrast, when +comparing two collections with reference equality, only the initial references +to memory need to be compared which is not based on the size of the collections, +which has an `O(1)` time complexity. Checking reference equality is always very +fast, however just because two collections are not reference-equal does not rule +out the possibility that they may be value-equal. -Equality treats Collections as Data ------------------------------------ +#### Return self on no-op optimization -Immutable.js provides equality which treats immutable data structures as pure -data, performing a deep equality check if necessary. +When possible, Immutable.js avoids creating new objects for updates where no +change in *value* occurred, to allow for efficient *reference equality* checking +to quickly determine if no change occurred. ```js -const { Map, is } = require('immutable') -const map1 = Map({ a: 1, b: 2, c: 3 }) -const map2 = Map({ a: 1, b: 2, c: 3 }) -assert.equal(map1 !== map2, true) // two different instances -assert.equal(is(map1, map2), true) // have equivalent values -assert.equal(map1.equals(map2), true) // alternatively use the equals method +const { Map } = require('immutable') +const originalMap = Map({ a: 1, b: 2, c: 3 }) +const updatedMap = originalMap.set('b', 2) +updatedMap === originalMap // No-op .set() returned the original reference. ``` -`Immutable.is()` uses the same measure of equality as [Object.is][] -including if both are immutable and all keys and values are equal -using the same measure of equality. - -[Object.is]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is +However updates which do result in a change will return a new reference. Each +of these operations occur independently, so two similar updates will not return +the same reference: + +```js +const { Map } = require('immutable') +const originalMap = Map({ a: 1, b: 2, c: 3 }) +const updatedMap = originalMap.set('b', 1000) +// New instance, leaving the original immutable. +updatedMap !== originalMap +const anotherUpdatedMap = originalMap.set('b', 1000) +// Despite both the results of the same operation, each created a new reference. +anotherUpdatedMap !== updatedMap +// However the two are value equal. +anotherUpdatedMap.equals(updatedMap) +``` Batching Mutations ------------------ @@ -493,6 +500,71 @@ and `splice` will always return new immutable data-structures and never mutate a mutable collection. +Lazy Seq +-------- + +`Seq` describes a lazy operation, allowing them to efficiently chain +use of all the sequence methods (such as `map` and `filter`). + +**Seq is immutable** — Once a Seq is created, it cannot be +changed, appended to, rearranged or otherwise modified. Instead, any mutative +method called on a Seq will return a new Seq. + +**Seq is lazy** — Seq does as little work as necessary to respond to any +method call. + +For example, the following does not perform any work, because the resulting +Seq is never used: + +```js +const { Seq } = require('immutable') +const oddSquares = Seq([ 1, 2, 3, 4, 5, 6, 7, 8 ]) + .filter(x => x % 2) + .map(x => x * x) +``` + +Once the Seq is used, it performs only the work necessary. In this +example, no intermediate arrays are ever created, filter is called three times, +and map is only called once: + +```js +console.log(oddSquares.get(1)); // 9 +``` + +Any collection can be converted to a lazy Seq with `.toSeq()`. + + +```js +const { Map } = require('immutable') +const seq = Map({ a: 1, b: 2, c: 3 }).toSeq() +``` + +Seq allows for the efficient chaining of sequence operations, especially when +converting to a different concrete type (such as to a JS object): + +```js +seq.flip().map(key => key.toUpperCase()).flip().toObject(); +// { A: 1, B: 2, C: 3 } +``` + +As well as expressing logic that would otherwise seem memory-limited: + + +```js +const { Range } = require('immutable') +Range(1, Infinity) + .skip(1000) + .map(n => -n) + .filter(n => n % 2 === 0) + .take(2) + .reduce((r, n) => r * n, 1); +// 1006008 +``` + +Note: A Collection is always iterated in the same order, however that order may +not always be well defined, as is the case for the `Map`. + + Documentation ------------- From 93de687695c9703ae5f2cba1aef82bf118840a41 Mon Sep 17 00:00:00 2001 From: Travis CI Date: Tue, 17 Oct 2017 04:08:07 +0000 Subject: [PATCH 069/242] Deploy addff95bafd970af759f9272ede7a1fea8730a12 to NPM branch --- README.md | 62 ++++++++++++++++++++++------------ dist/immutable-nonambient.d.ts | 38 ++++++++++++++------- dist/immutable.d.ts | 38 ++++++++++++++------- 3 files changed, 90 insertions(+), 48 deletions(-) diff --git a/README.md b/README.md index cadcb900b6..5a399ae061 100644 --- a/README.md +++ b/README.md @@ -321,6 +321,19 @@ const mapped = foo.map(x => x * x); var mapped = foo.map(function (x) { return x * x; }); ``` +All Immutable.js collections are [Iterable][Iterators], which allows them to be +used anywhere an Iterable is expected, such as when spreading into an Array. + + +```js +const { List } = require('immutable') +const aList = List([ 1, 2, 3 ]) +const anArray = [ 0, ...aList, 4, 5 ] // [ 0, 1, 2, 3, 4, 5 ] +``` + +Note: A Collection is always iterated in the same order, however that order may +not always be well defined, as is the case for the `Map` and `Set`. + [Iterators]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/The_Iterator_protocol [Arrow Functions]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions [Classes]: http://wiki.ecmascript.org/doku.php?id=strawman:maximally_minimal_classes @@ -504,50 +517,58 @@ Lazy Seq -------- `Seq` describes a lazy operation, allowing them to efficiently chain -use of all the sequence methods (such as `map` and `filter`). +use of all the higher-order collection methods (such as `map` and `filter`) +by not creating intermediate collections. **Seq is immutable** — Once a Seq is created, it cannot be changed, appended to, rearranged or otherwise modified. Instead, any mutative -method called on a Seq will return a new Seq. +method called on a `Seq` will return a new `Seq`. -**Seq is lazy** — Seq does as little work as necessary to respond to any -method call. +**Seq is lazy** — `Seq` does as little work as necessary to respond to any +method call. Values are often created during iteration, including implicit +iteration when reducing or converting to a concrete data structure such as +a `List` or JavaScript `Array`. -For example, the following does not perform any work, because the resulting -Seq is never used: +For example, the following performs no work, because the resulting +`Seq`'s values are never iterated: ```js const { Seq } = require('immutable') const oddSquares = Seq([ 1, 2, 3, 4, 5, 6, 7, 8 ]) - .filter(x => x % 2) + .filter(x => x % 2 !== 0) .map(x => x * x) ``` -Once the Seq is used, it performs only the work necessary. In this -example, no intermediate arrays are ever created, filter is called three times, -and map is only called once: +Once the `Seq` is used, it performs only the work necessary. In this +example, no intermediate arrays are ever created, filter is called three +times, and map is only called once: ```js -console.log(oddSquares.get(1)); // 9 +oddSquares.get(1); // 9 ``` -Any collection can be converted to a lazy Seq with `.toSeq()`. +Any collection can be converted to a lazy Seq with `Seq()`. ```js const { Map } = require('immutable') -const seq = Map({ a: 1, b: 2, c: 3 }).toSeq() +const map = Map({ a: 1, b: 2, c: 3 } +const lazySeq = Seq(map) ``` -Seq allows for the efficient chaining of sequence operations, especially when -converting to a different concrete type (such as to a JS object): +`Seq` allows for the efficient chaining of operations, allowing for the +expression of logic that can otherwise be very tedious: ```js -seq.flip().map(key => key.toUpperCase()).flip().toObject(); -// { A: 1, B: 2, C: 3 } +lazySeq + .flip() + .map(key => key.toUpperCase()) + .flip() +// Seq { A: 1, B: 1, C: 1 } ``` -As well as expressing logic that would otherwise seem memory-limited: +As well as expressing logic that would otherwise seem memory or time +limited, for example `Range` is a special kind of Lazy sequence. ```js @@ -557,13 +578,10 @@ Range(1, Infinity) .map(n => -n) .filter(n => n % 2 === 0) .take(2) - .reduce((r, n) => r * n, 1); + .reduce((r, n) => r * n, 1) // 1006008 ``` -Note: A Collection is always iterated in the same order, however that order may -not always be well defined, as is the case for the `Map`. - Documentation ------------- diff --git a/dist/immutable-nonambient.d.ts b/dist/immutable-nonambient.d.ts index 501eebb82a..8d28d87243 100644 --- a/dist/immutable-nonambient.d.ts +++ b/dist/immutable-nonambient.d.ts @@ -2769,20 +2769,21 @@ } /** - * Represents a sequence of values, but may not be backed by a concrete data - * structure. + * `Seq` describes a lazy operation, allowing them to efficiently chain + * use of all the higher-order collection methods (such as `map` and `filter`) + * by not creating intermediate collections. * * **Seq is immutable** — Once a Seq is created, it cannot be * changed, appended to, rearranged or otherwise modified. Instead, any * mutative method called on a `Seq` will return a new `Seq`. * - * **Seq is lazy** — Seq does as little work as necessary to respond to any + * **Seq is lazy** — `Seq` does as little work as necessary to respond to any * method call. Values are often created during iteration, including implicit * iteration when reducing or converting to a concrete data structure such as * a `List` or JavaScript `Array`. * * For example, the following performs no work, because the resulting - * Seq's values are never iterated: + * `Seq`'s values are never iterated: * * ```js * const { Seq } = require('immutable@4.0.0-rc.7') @@ -2791,27 +2792,38 @@ * .map(x => x * x) * ``` * - * Once the Seq is used, it performs only the work necessary. In this - * example, no intermediate data structures are ever created, filter is only - * called three times, and map is only called once: + * Once the `Seq` is used, it performs only the work necessary. In this + * example, no intermediate arrays are ever created, filter is called three + * times, and map is only called once: * - * ``` - * oddSquares.get(1)); // 9 + * ```js + * oddSquares.get(1); // 9 * ``` * - * Seq allows for the efficient chaining of operations, - * allowing for the expression of logic that can otherwise be very tedious: + * Any collection can be converted to a lazy Seq with `Seq()`. * + * + * ```js + * const { Map } = require('immutable') + * const map = Map({ a: 1, b: 2, c: 3 } + * const lazySeq = Seq(map) * ``` - * Seq({ a: 1, b: 1, c: 1}) + * + * `Seq` allows for the efficient chaining of operations, allowing for the + * expression of logic that can otherwise be very tedious: + * + * ```js + * lazySeq * .flip() * .map(key => key.toUpperCase()) * .flip() * // Seq { A: 1, B: 1, C: 1 } * ``` * - * As well as expressing logic that would otherwise be memory or time limited: + * As well as expressing logic that would otherwise seem memory or time + * limited, for example `Range` is a special kind of Lazy sequence. * + * * ```js * const { Range } = require('immutable@4.0.0-rc.7') * Range(1, Infinity) diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index 360743ce82..3fc5269e7b 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -2769,20 +2769,21 @@ declare module Immutable { } /** - * Represents a sequence of values, but may not be backed by a concrete data - * structure. + * `Seq` describes a lazy operation, allowing them to efficiently chain + * use of all the higher-order collection methods (such as `map` and `filter`) + * by not creating intermediate collections. * * **Seq is immutable** — Once a Seq is created, it cannot be * changed, appended to, rearranged or otherwise modified. Instead, any * mutative method called on a `Seq` will return a new `Seq`. * - * **Seq is lazy** — Seq does as little work as necessary to respond to any + * **Seq is lazy** — `Seq` does as little work as necessary to respond to any * method call. Values are often created during iteration, including implicit * iteration when reducing or converting to a concrete data structure such as * a `List` or JavaScript `Array`. * * For example, the following performs no work, because the resulting - * Seq's values are never iterated: + * `Seq`'s values are never iterated: * * ```js * const { Seq } = require('immutable@4.0.0-rc.7') @@ -2791,27 +2792,38 @@ declare module Immutable { * .map(x => x * x) * ``` * - * Once the Seq is used, it performs only the work necessary. In this - * example, no intermediate data structures are ever created, filter is only - * called three times, and map is only called once: + * Once the `Seq` is used, it performs only the work necessary. In this + * example, no intermediate arrays are ever created, filter is called three + * times, and map is only called once: * - * ``` - * oddSquares.get(1)); // 9 + * ```js + * oddSquares.get(1); // 9 * ``` * - * Seq allows for the efficient chaining of operations, - * allowing for the expression of logic that can otherwise be very tedious: + * Any collection can be converted to a lazy Seq with `Seq()`. * + * + * ```js + * const { Map } = require('immutable') + * const map = Map({ a: 1, b: 2, c: 3 } + * const lazySeq = Seq(map) * ``` - * Seq({ a: 1, b: 1, c: 1}) + * + * `Seq` allows for the efficient chaining of operations, allowing for the + * expression of logic that can otherwise be very tedious: + * + * ```js + * lazySeq * .flip() * .map(key => key.toUpperCase()) * .flip() * // Seq { A: 1, B: 1, C: 1 } * ``` * - * As well as expressing logic that would otherwise be memory or time limited: + * As well as expressing logic that would otherwise seem memory or time + * limited, for example `Range` is a special kind of Lazy sequence. * + * * ```js * const { Range } = require('immutable@4.0.0-rc.7') * Range(1, Infinity) From f918a5fc79ef84f2e06e762c616f9d93eb151b0c Mon Sep 17 00:00:00 2001 From: Travis CI Date: Tue, 17 Oct 2017 04:18:31 +0000 Subject: [PATCH 070/242] Deploy 91585d2db3230cd8cdc96365731897afe1cb54d2 to NPM branch --- dist/immutable-nonambient.d.ts | 18 +++++++++++++++++- dist/immutable.d.ts | 18 +++++++++++++++++- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/dist/immutable-nonambient.d.ts b/dist/immutable-nonambient.d.ts index 8d28d87243..c4ecc87426 100644 --- a/dist/immutable-nonambient.d.ts +++ b/dist/immutable-nonambient.d.ts @@ -522,6 +522,9 @@ * // List [ 1, 2, 3, 4 ] * ``` * + * Since `delete()` re-indexes values, it produces a complete copy, which + * has `O(N)` complexity. + * * Note: `delete` *cannot* be used in `withMutations`. * * @alias remove @@ -543,12 +546,15 @@ * // List [ 0, 1, 2, 3, 4, 5 ] * ``` * + * Since `insert()` re-indexes values, it produces a complete copy, which + * has `O(N)` complexity. + * * Note: `insert` *cannot* be used in `withMutations`. */ insert(index: number, value: T): List; /** - * Returns a new List with 0 size and no values. + * Returns a new List with 0 size and no values in constant time. * * ```js -const { Map } = require('immutable') +const { Map, List } = require('immutable') const map1 = Map({ a: 1, b: 2, c: 3, d: 4 }) const map2 = Map({ c: 10, a: 20, t: 30 }) const obj = { d: 100, o: 200, g: 300 } const map3 = map1.merge(map2, obj); // Map { a: 20, b: 2, c: 10, d: 100, t: 30, o: 200, g: 300 } +const list1 = List([ 1, 2, 3 ]) +const list2 = List([ 4, 5, 6 ]) +const array = [ 7, 8, 9 ] +const list3 = list1.concat(list2, array) +// List [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ] ``` This is possible because Immutable.js can treat any JavaScript Array or Object From 601d3135d4d4bb779de680a4b30bc5c3f1f81a9e Mon Sep 17 00:00:00 2001 From: Travis CI Date: Tue, 17 Oct 2017 04:34:32 +0000 Subject: [PATCH 072/242] Deploy c94abfcbf44d6697b5d824e1e32a57c2d88ff913 to NPM branch --- bower.json | 2 +- dist/immutable-nonambient.d.ts | 240 ++++++++++++++++----------------- dist/immutable.d.ts | 240 ++++++++++++++++----------------- dist/immutable.es.js | 2 +- dist/immutable.js | 2 +- dist/immutable.min.js | 2 +- package.json | 2 +- 7 files changed, 245 insertions(+), 245 deletions(-) diff --git a/bower.json b/bower.json index 0ad7a3934f..b7899869b0 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "immutable", - "version": "4.0.0-rc.7", + "version": "4.0.0-rc.8", "description": "Immutable Data Collections", "license": "MIT", "homepage": "https://facebook.github.com/immutable-js", diff --git a/dist/immutable-nonambient.d.ts b/dist/immutable-nonambient.d.ts index c4ecc87426..8a81d6a798 100644 --- a/dist/immutable-nonambient.d.ts +++ b/dist/immutable-nonambient.d.ts @@ -118,7 +118,7 @@ * * * ```js - * const { fromJS, isKeyed } = require('immutable@4.0.0-rc.7') + * const { fromJS, isKeyed } = require('immutable@4.0.0-rc.8') * function (key, value) { * return isKeyed(value) ? value.Map() : value.toList() * } @@ -132,7 +132,7 @@ * * * ```js - * const { fromJS, isKeyed } = require('immutable@4.0.0-rc.7') + * const { fromJS, isKeyed } = require('immutable@4.0.0-rc.8') * fromJS({ a: {b: [10, 20, 30]}, c: 40}, function (key, value, path) { * console.log(key, value, path) * return isKeyed(value) ? value.toOrderedMap() : value.toList() @@ -149,7 +149,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.7') + * const { Map } = require('immutable@4.0.0-rc.8') * let obj = { 1: "one" }; * Object.keys(obj); // [ "1" ] * assert.equal(obj["1"], obj[1]); // "one" === "one" @@ -185,7 +185,7 @@ * * * ```js - * const { Map, is } = require('immutable@4.0.0-rc.7') + * const { Map, is } = require('immutable@4.0.0-rc.8') * const map1 = Map({ a: 1, b: 1, c: 1 }) * const map2 = Map({ a: 1, b: 1, c: 1 }) * assert.equal(map1 !== map2, true) @@ -234,7 +234,7 @@ * * * ```js - * const { isImmutable, Map, List, Stack } = require('immutable@4.0.0-rc.7'); + * const { isImmutable, Map, List, Stack } = require('immutable@4.0.0-rc.8'); * isImmutable([]); // false * isImmutable({}); // false * isImmutable(Map()); // true @@ -250,7 +250,7 @@ * * * ```js - * const { isCollection, Map, List, Stack } = require('immutable@4.0.0-rc.7'); + * const { isCollection, Map, List, Stack } = require('immutable@4.0.0-rc.8'); * isCollection([]); // false * isCollection({}); // false * isCollection(Map()); // true @@ -265,7 +265,7 @@ * * * ```js - * const { isKeyed, Map, List, Stack } = require('immutable@4.0.0-rc.7'); + * const { isKeyed, Map, List, Stack } = require('immutable@4.0.0-rc.8'); * isKeyed([]); // false * isKeyed({}); // false * isKeyed(Map()); // true @@ -280,7 +280,7 @@ * * * ```js - * const { isIndexed, Map, List, Stack, Set } = require('immutable@4.0.0-rc.7'); + * const { isIndexed, Map, List, Stack, Set } = require('immutable@4.0.0-rc.8'); * isIndexed([]); // false * isIndexed({}); // false * isIndexed(Map()); // false @@ -296,7 +296,7 @@ * * * ```js - * const { isAssociative, Map, List, Stack, Set } = require('immutable@4.0.0-rc.7'); + * const { isAssociative, Map, List, Stack, Set } = require('immutable@4.0.0-rc.8'); * isAssociative([]); // false * isAssociative({}); // false * isAssociative(Map()); // true @@ -313,7 +313,7 @@ * * * ```js - * const { isOrdered, Map, OrderedMap, List, Set } = require('immutable@4.0.0-rc.7'); + * const { isOrdered, Map, OrderedMap, List, Set } = require('immutable@4.0.0-rc.8'); * isOrdered([]); // false * isOrdered({}); // false * isOrdered(Map()); // false @@ -355,7 +355,7 @@ * * * ```js - * const { List, Set } = require('immutable@4.0.0-rc.7'); + * const { List, Set } = require('immutable@4.0.0-rc.8'); * const a = List([ 1, 2, 3 ]); * const b = List([ 1, 2, 3 ]); * assert.notStrictEqual(a, b); // different instances @@ -401,7 +401,7 @@ * * * ```js - * const { List } = require('immutable@4.0.0-rc.7'); + * const { List } = require('immutable@4.0.0-rc.8'); * List.isList([]); // false * List.isList(List()); // true * ``` @@ -413,7 +413,7 @@ * * * ```js - * const { List } = require('immutable@4.0.0-rc.7'); + * const { List } = require('immutable@4.0.0-rc.8'); * List.of(1, 2, 3, 4) * // List [ 1, 2, 3, 4 ] * ``` @@ -422,7 +422,7 @@ * * * ```js - * const { List } = require('immutable@4.0.0-rc.7'); + * const { List } = require('immutable@4.0.0-rc.8'); * List.of({x:1}, 2, [3], 4) * // List [ { x: 1 }, 2, [ 3 ], 4 ] * ``` @@ -436,7 +436,7 @@ * * * ```js - * const { List, Set } = require('immutable@4.0.0-rc.7') + * const { List, Set } = require('immutable@4.0.0-rc.8') * * const emptyList = List() * // List [] @@ -482,7 +482,7 @@ * enough to include the `index`. * * * ```js * const originalList = List([ 0 ]); @@ -515,7 +515,7 @@ * Note: `delete` cannot be safely used in IE8 * * * ```js * List([ 0, 1, 2, 3, 4 ]).delete(0); @@ -539,7 +539,7 @@ * This is synonymous with `list.splice(index, 0, value)`. * * * ```js * List([ 0, 1, 2, 3, 4 ]).insert(6, 5) @@ -557,7 +557,7 @@ * Returns a new List with 0 size and no values in constant time. * * * ```js * List([ 1, 2, 3, 4 ]).clear() @@ -573,7 +573,7 @@ * List's `size`. * * * ```js * List([ 1, 2, 3, 4 ]).push(5) @@ -606,7 +606,7 @@ * values ahead to higher indices. * * * ```js * List([ 2, 3, 4]).unshift(1); @@ -626,7 +626,7 @@ * value in this List. * * * ```js * List([ 0, 1, 2, 3, 4 ]).shift(); @@ -647,7 +647,7 @@ * List. `v.update(-1)` updates the last item in the List. * * * ```js * const list = List([ 'a', 'b', 'c' ]) @@ -661,7 +661,7 @@ * For example, to sum a List after mapping and filtering: * * * ```js * function sum(collection) { @@ -707,7 +707,7 @@ * * * ```js - * const { List } = require('immutable@4.0.0-rc.7') + * const { List } = require('immutable@4.0.0-rc.8') * const list = List([ 0, 1, 2, List([ 3, 4 ])]) * list.setIn([3, 0], 999); * // List [ 0, 1, 2, List [ 999, 4 ] ] @@ -719,7 +719,7 @@ * * * ```js - * const { List } = require('immutable@4.0.0-rc.7') + * const { List } = require('immutable@4.0.0-rc.8') * const list = List([ 0, 1, 2, { plain: 'object' }]) * list.setIn([3, 'plain'], 'value'); * // List([ 0, 1, 2, { plain: 'value' }]) @@ -735,7 +735,7 @@ * * * ```js - * const { List } = require('immutable@4.0.0-rc.7') + * const { List } = require('immutable@4.0.0-rc.8') * const list = List([ 0, 1, 2, List([ 3, 4 ])]) * list.deleteIn([3, 0]); * // List [ 0, 1, 2, List [ 4 ] ] @@ -747,7 +747,7 @@ * * * ```js - * const { List } = require('immutable@4.0.0-rc.7') + * const { List } = require('immutable@4.0.0-rc.8') * const list = List([ 0, 1, 2, { plain: 'object' }]) * list.removeIn([3, 'plain']); * // List([ 0, 1, 2, {}]) @@ -831,7 +831,7 @@ * `mapper` function. * * * ```js * List([ 1, 2 ]).map(x => 10 * x) @@ -878,7 +878,7 @@ * Like `zipWith`, but using the default `zipper`: creating an `Array`. * * * ```js * const a = List([ 1, 2, 3 ]); @@ -897,7 +897,7 @@ * exhausted. Missing values from shorter collections are filled with `undefined`. * * * ```js * const a = List([ 1, 2 ]); @@ -918,7 +918,7 @@ * custom `zipper` function. * * * ```js * const a = List([ 1, 2, 3 ]); @@ -959,7 +959,7 @@ * * * ```js - * const { Map, List } = require('immutable@4.0.0-rc.7'); + * const { Map, List } = require('immutable@4.0.0-rc.8'); * Map().set(List([ 1 ]), 'listofone').get(List([ 1 ])); * // 'listofone' * ``` @@ -977,7 +977,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.7') + * const { Map } = require('immutable@4.0.0-rc.8') * Map.isMap({}) // false * Map.isMap(Map()) // true * ``` @@ -989,7 +989,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.7') + * const { Map } = require('immutable@4.0.0-rc.8') * Map.of( * 'key', 'value', * 'numerical value', 3, @@ -1011,7 +1011,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.7') + * const { Map } = require('immutable@4.0.0-rc.8') * Map({ key: "value" }) * Map([ [ "key", "value" ] ]) * ``` @@ -1021,7 +1021,7 @@ * quote-less shorthand, while Immutable Maps accept keys of any type. * * * ```js * let obj = { 1: "one" } @@ -1057,7 +1057,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.7') + * const { Map } = require('immutable@4.0.0-rc.8') * const originalMap = Map() * const newerMap = originalMap.set('key', 'value') * const newestMap = newerMap.set('key', 'newer value') @@ -1082,7 +1082,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.7') + * const { Map } = require('immutable@4.0.0-rc.8') * const originalMap = Map({ * key: 'value', * otherKey: 'other value' @@ -1104,7 +1104,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.7') + * const { Map } = require('immutable@4.0.0-rc.8') * const names = Map({ a: "Aaron", b: "Barry", c: "Connor" }) * names.deleteAll([ 'a', 'c' ]) * // Map { "b": "Barry" } @@ -1122,7 +1122,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.7') + * const { Map } = require('immutable@4.0.0-rc.8') * Map({ key: 'value' }).clear() * // Map {} * ``` @@ -1139,7 +1139,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.7') + * const { Map } = require('immutable@4.0.0-rc.8') * const aMap = Map({ key: 'value' }) * const newMap = aMap.update('key', value => value + value) * // Map { "key": "valuevalue" } @@ -1150,7 +1150,7 @@ * `update` and `push` can be used together: * * * ```js * const aMap = Map({ nestedList: List([ 1, 2, 3 ]) }) @@ -1162,7 +1162,7 @@ * function when the value at the key does not exist in the Map. * * * ```js * const aMap = Map({ key: 'value' }) @@ -1175,7 +1175,7 @@ * is provided. * * * ```js * const aMap = Map({ apples: 10 }) @@ -1191,7 +1191,7 @@ * The previous example behaves differently when written with default values: * * * ```js * const aMap = Map({ apples: 10 }) @@ -1203,7 +1203,7 @@ * returned as well. * * * ```js * const aMap = Map({ key: 'value' }) @@ -1217,7 +1217,7 @@ * For example, to sum the values in a Map * * * ```js * function sum(collection) { @@ -1247,7 +1247,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.7') + * const { Map } = require('immutable@4.0.0-rc.8') * const one = Map({ a: 10, b: 20, c: 30 }) * const two = Map({ b: 40, a: 50, d: 60 }) * one.merge(two) // Map { "a": 50, "b": 40, "c": 30, "d": 60 } @@ -1270,7 +1270,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.7') + * const { Map } = require('immutable@4.0.0-rc.8') * const one = Map({ a: 10, b: 20, c: 30 }) * const two = Map({ b: 40, a: 50, d: 60 }) * one.mergeWith((oldVal, newVal) => oldVal / newVal, two) @@ -1296,7 +1296,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.7') + * const { Map } = require('immutable@4.0.0-rc.8') * const one = Map({ a: Map({ x: 10, y: 10 }), b: Map({ x: 20, y: 50 }) }) * const two = Map({ a: Map({ x: 2 }), b: Map({ y: 5 }), c: Map({ z: 3 }) }) * one.mergeDeep(two) @@ -1317,7 +1317,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.7') + * const { Map } = require('immutable@4.0.0-rc.8') * const one = Map({ a: Map({ x: 10, y: 10 }), b: Map({ x: 20, y: 50 }) }) * const two = Map({ a: Map({ x: 2 }), b: Map({ y: 5 }), c: Map({ z: 3 }) }) * one.mergeDeepWith((oldVal, newVal) => oldVal / newVal, two) @@ -1344,7 +1344,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.7') + * const { Map } = require('immutable@4.0.0-rc.8') * const originalMap = Map({ * subObject: Map({ * subKey: 'subvalue', @@ -1380,7 +1380,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.7') + * const { Map } = require('immutable@4.0.0-rc.8') * const originalMap = Map({ * subObject: { * subKey: 'subvalue', @@ -1427,7 +1427,7 @@ * * * ```js - * const { Map, List } = require('immutable@4.0.0-rc.7') + * const { Map, List } = require('immutable@4.0.0-rc.8') * const map = Map({ inMap: Map({ inList: List([ 1, 2, 3 ]) }) }) * const newMap = map.updateIn(['inMap', 'inList'], list => list.push(4)) * // Map { "inMap": Map { "inList": List [ 1, 2, 3, 4 ] } } @@ -1439,7 +1439,7 @@ * provided, otherwise `undefined`. * * * ```js * const map = Map({ a: Map({ b: Map({ c: 10 }) }) }) @@ -1451,7 +1451,7 @@ * no change will occur. This is still true if `notSetValue` is provided. * * * ```js * const map = Map({ a: Map({ b: Map({ c: 10 }) }) }) @@ -1467,7 +1467,7 @@ * The previous example behaves differently when written with default values: * * * ```js * const map = Map({ a: Map({ b: Map({ c: 10 }) }) }) @@ -1480,7 +1480,7 @@ * immutably by creating new copies of those values with the changes applied. * * * ```js * const map = Map({ a: { b: { c: 10 } } }) @@ -1541,7 +1541,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.7') + * const { Map } = require('immutable@4.0.0-rc.8') * const map1 = Map() * const map2 = map1.withMutations(map => { * map.set('a', 1).set('b', 2).set('c', 3) @@ -1709,7 +1709,7 @@ * * * ```js - * const { OrderedMap } = require('immutable@4.0.0-rc.7') + * const { OrderedMap } = require('immutable@4.0.0-rc.8') * const one = OrderedMap({ a: 10, b: 20, c: 30 }) * const two = OrderedMap({ b: 40, a: 50, d: 60 }) * one.merge(two) // OrderedMap { "a": 50, "b": 40, "c": 30, "d": 60 } @@ -1826,7 +1826,7 @@ * a collection of other sets. * * ```js - * const { Set } = require('immutable@4.0.0-rc.7') + * const { Set } = require('immutable@4.0.0-rc.8') * const intersected = Set.intersect([ * Set([ 'a', 'b', 'c' ]) * Set([ 'c', 'a', 't' ]) @@ -1841,7 +1841,7 @@ * collection of other sets. * * ```js - * const { Set } = require('immutable@4.0.0-rc.7') + * const { Set } = require('immutable@4.0.0-rc.8') * const unioned = Set.union([ * Set([ 'a', 'b', 'c' ]) * Set([ 'c', 'a', 't' ]) @@ -2412,7 +2412,7 @@ * infinity. When `start` is equal to `end`, returns empty range. * * ```js - * const { Range } = require('immutable@4.0.0-rc.7') + * const { Range } = require('immutable@4.0.0-rc.8') * Range() // [ 0, 1, 2, 3, ... ] * Range(10) // [ 10, 11, 12, 13, ... ] * Range(10, 15) // [ 10, 11, 12, 13, 14 ] @@ -2429,7 +2429,7 @@ * not defined, returns an infinite `Seq` of `value`. * * ```js - * const { Repeat } = require('immutable@4.0.0-rc.7') + * const { Repeat } = require('immutable@4.0.0-rc.8') * Repeat('foo') // [ 'foo', 'foo', 'foo', ... ] * Repeat('bar', 4) // [ 'bar', 'bar', 'bar', 'bar' ] * ``` @@ -2445,7 +2445,7 @@ * create Record instances. * * ```js - * const { Record } = require('immutable@4.0.0-rc.7') + * const { Record } = require('immutable@4.0.0-rc.8') * const ABRecord = Record({ a: 1, b: 2 }) * const myRecord = new ABRecord({ b: 3 }) * ``` @@ -2577,7 +2577,7 @@ * method. If one was not provided, the string "Record" is returned. * * ```js - * const { Record } = require('immutable@4.0.0-rc.7') + * const { Record } = require('immutable@4.0.0-rc.8') * const Person = Record({ * name: null * }, 'Person') @@ -2595,7 +2595,7 @@ * type: * * * ```js * // makePerson is a Record Factory function @@ -2610,7 +2610,7 @@ * access on the resulting instances: * * * ```js * // Use the Record API @@ -2792,7 +2792,7 @@ * `Seq`'s values are never iterated: * * ```js - * const { Seq } = require('immutable@4.0.0-rc.7') + * const { Seq } = require('immutable@4.0.0-rc.8') * const oddSquares = Seq([ 1, 2, 3, 4, 5, 6, 7, 8 ]) * .filter(x => x % 2 !== 0) * .map(x => x * x) @@ -2831,7 +2831,7 @@ * * * ```js - * const { Range } = require('immutable@4.0.0-rc.7') + * const { Range } = require('immutable@4.0.0-rc.8') * Range(1, Infinity) * .skip(1000) * .map(n => -n) @@ -2910,7 +2910,7 @@ * `mapper` function. * * ```js - * const { Seq } = require('immutable@4.0.0-rc.7') + * const { Seq } = require('immutable@4.0.0-rc.8') * Seq.Keyed({ a: 1, b: 2 }).map(x => 10 * x) * // Seq { "a": 10, "b": 20 } * ``` @@ -3022,7 +3022,7 @@ * `mapper` function. * * ```js - * const { Seq } = require('immutable@4.0.0-rc.7') + * const { Seq } = require('immutable@4.0.0-rc.8') * Seq.Indexed([ 1, 2 ]).map(x => 10 * x) * // Seq [ 10, 20 ] * ``` @@ -3282,7 +3282,7 @@ * `mapper` function. * * ```js - * const { Seq } = require('immutable@4.0.0-rc.7') + * const { Seq } = require('immutable@4.0.0-rc.8') * Seq([ 1, 2 ]).map(x => 10 * x) * // Seq [ 10, 20 ] * ``` @@ -3300,7 +3300,7 @@ * `mapper` function. * * ```js - * const { Seq } = require('immutable@4.0.0-rc.7') + * const { Seq } = require('immutable@4.0.0-rc.8') * Seq([ 1, 2 ]).map(x => 10 * x) * // Seq [ 10, 20 ] * ``` @@ -3369,22 +3369,22 @@ export module Collection { /** - * @deprecated use `const { isKeyed } = require('immutable@4.0.0-rc.7')` + * @deprecated use `const { isKeyed } = require('immutable@4.0.0-rc.8')` */ function isKeyed(maybeKeyed: any): maybeKeyed is Collection.Keyed; /** - * @deprecated use `const { isIndexed } = require('immutable@4.0.0-rc.7')` + * @deprecated use `const { isIndexed } = require('immutable@4.0.0-rc.8')` */ function isIndexed(maybeIndexed: any): maybeIndexed is Collection.Indexed; /** - * @deprecated use `const { isAssociative } = require('immutable@4.0.0-rc.7')` + * @deprecated use `const { isAssociative } = require('immutable@4.0.0-rc.8')` */ function isAssociative(maybeAssociative: any): maybeAssociative is Collection.Keyed | Collection.Indexed; /** - * @deprecated use `const { isOrdered } = require('immutable@4.0.0-rc.7')` + * @deprecated use `const { isOrdered } = require('immutable@4.0.0-rc.8')` */ function isOrdered(maybeOrdered: any): boolean; @@ -3442,7 +3442,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.7') + * const { Map } = require('immutable@4.0.0-rc.8') * Map({ a: 'z', b: 'y' }).flip() * // Map { "z": "a", "y": "b" } * ``` @@ -3460,7 +3460,7 @@ * `mapper` function. * * ```js - * const { Collection } = require('immutable@4.0.0-rc.7') + * const { Collection } = require('immutable@4.0.0-rc.8') * Collection.Keyed({ a: 1, b: 2 }).map(x => 10 * x) * // Seq { "a": 10, "b": 20 } * ``` @@ -3479,7 +3479,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.7') + * const { Map } = require('immutable@4.0.0-rc.8') * Map({ a: 1, b: 2 }).mapKeys(x => x.toUpperCase()) * // Map { "A": 1, "B": 2 } * ``` @@ -3498,7 +3498,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.7') + * const { Map } = require('immutable@4.0.0-rc.8') * Map({ a: 1, b: 2 }) * .mapEntries(([ k, v ]) => [ k.toUpperCase(), v * 2 ]) * // Map { "A": 2, "B": 4 } @@ -3624,10 +3624,10 @@ * second from each, etc. * * * ```js - * const { List } = require('immutable@4.0.0-rc.7') + * const { List } = require('immutable@4.0.0-rc.8') * List([ 1, 2, 3 ]).interleave(List([ 'A', 'B', 'C' ])) * // List [ 1, "A", 2, "B", 3, "C"" ] * ``` @@ -3635,7 +3635,7 @@ * The shortest Collection stops interleave. * * * ```js * List([ 1, 2, 3 ]).interleave( @@ -3662,7 +3662,7 @@ * * * ```js - * const { List } = require('immutable@4.0.0-rc.7') + * const { List } = require('immutable@4.0.0-rc.8') * List([ 'a', 'b', 'c', 'd' ]).splice(1, 2, 'q', 'r', 's') * // List [ "a", "q", "r", "s", "d" ] * ``` @@ -3686,7 +3686,7 @@ * * * * ```js * const a = List([ 1, 2, 3 ]); @@ -3719,7 +3719,7 @@ * collections by using a custom `zipper` function. * * * ```js * const a = List([ 1, 2, 3 ]); @@ -3787,7 +3787,7 @@ * `mapper` function. * * ```js - * const { Collection } = require('immutable@4.0.0-rc.7') + * const { Collection } = require('immutable@4.0.0-rc.8') * Collection.Indexed([1,2]).map(x => 10 * x) * // Seq [ 1, 2 ] * ``` @@ -3839,7 +3839,7 @@ * the value as both the first and second arguments to the provided function. * * ```js - * const { Collection } = require('immutable@4.0.0-rc.7') + * const { Collection } = require('immutable@4.0.0-rc.8') * const seq = Collection.Set([ 'A', 'B', 'C' ]) * // Seq { "A", "B", "C" } * seq.forEach((v, k) => @@ -3971,7 +3971,7 @@ * lookup via a different instance. * * * ```js * const a = List([ 1, 2, 3 ]); @@ -4036,7 +4036,7 @@ * * * ```js - * const { Map, List } = require('immutable@4.0.0-rc.7') + * const { Map, List } = require('immutable@4.0.0-rc.8') * const deepData = Map({ x: List([ Map({ y: 123 }) ]) }); * getIn(deepData, ['x', 0, 'y']) // 123 * ``` @@ -4046,7 +4046,7 @@ * * * ```js - * const { Map, List } = require('immutable@4.0.0-rc.7') + * const { Map, List } = require('immutable@4.0.0-rc.8') * const deepData = Map({ x: [ { y: 123 } ] }); * getIn(deepData, ['x', 0, 'y']) // 123 * ``` @@ -4069,7 +4069,7 @@ * * * ```js - * const { Seq } = require('immutable@4.0.0-rc.7') + * const { Seq } = require('immutable@4.0.0-rc.8') * * function sum(collection) { * return collection.reduce((sum, x) => sum + x, 0) @@ -4165,7 +4165,7 @@ * * * ```js - * const { Map, List } = require('immutable@4.0.0-rc.7') + * const { Map, List } = require('immutable@4.0.0-rc.8') * var myMap = Map({ a: 'Apple', b: 'Banana' }) * List(myMap) // List [ [ "a", "Apple" ], [ "b", "Banana" ] ] * myMap.toList() // List [ "Apple", "Banana" ] @@ -4202,7 +4202,7 @@ * * * ```js - * const { Seq } = require('immutable@4.0.0-rc.7') + * const { Seq } = require('immutable@4.0.0-rc.8') * const indexedSeq = Seq([ 'A', 'B', 'C' ]) * // Seq [ "A", "B", "C" ] * indexedSeq.filter(v => v === 'B') @@ -4283,7 +4283,7 @@ * * * ```js - * const { Collection } = require('immutable@4.0.0-rc.7') + * const { Collection } = require('immutable@4.0.0-rc.8') * Collection({ a: 1, b: 2 }).map(x => 10 * x) * // Seq { "a": 10, "b": 20 } * ``` @@ -4310,7 +4310,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.7') + * const { Map } = require('immutable@4.0.0-rc.8') * Map({ a: 1, b: 2, c: 3, d: 4}).filter(x => x % 2 === 0) * // Map { "b": 2, "d": 4 } * ``` @@ -4333,7 +4333,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.7') + * const { Map } = require('immutable@4.0.0-rc.8') * Map({ a: 1, b: 2, c: 3, d: 4}).filterNot(x => x % 2 === 0) * // Map { "a": 1, "c": 3 } * ``` @@ -4370,7 +4370,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.7') + * const { Map } = require('immutable@4.0.0-rc.8') * Map({ "c": 3, "a": 1, "b": 2 }).sort((a, b) => { * if (a < b) { return -1; } * if (a > b) { return 1; } @@ -4410,7 +4410,7 @@ * * * ```js - * const { List, Map } = require('immutable@4.0.0-rc.7') + * const { List, Map } = require('immutable@4.0.0-rc.8') * const listOfMaps = List([ * Map({ v: 0 }), * Map({ v: 1 }), @@ -4497,7 +4497,7 @@ * * * ```js - * const { List } = require('immutable@4.0.0-rc.7') + * const { List } = require('immutable@4.0.0-rc.8') * List([ 'dog', 'frog', 'cat', 'hat', 'god' ]) * .skipWhile(x => x.match(/g/)) * // List [ "cat", "hat", "god"" ] @@ -4514,7 +4514,7 @@ * * * ```js - * const { List } = require('immutable@4.0.0-rc.7') + * const { List } = require('immutable@4.0.0-rc.8') * List([ 'dog', 'frog', 'cat', 'hat', 'god' ]) * .skipUntil(x => x.match(/hat/)) * // List [ "hat", "god"" ] @@ -4543,7 +4543,7 @@ * * * ```js - * const { List } = require('immutable@4.0.0-rc.7') + * const { List } = require('immutable@4.0.0-rc.8') * List([ 'dog', 'frog', 'cat', 'hat', 'god' ]) * .takeWhile(x => x.match(/o/)) * // List [ "dog", "frog" ] @@ -4560,7 +4560,7 @@ * * * ```js - * const { List } = require('immutable@4.0.0-rc.7') + * const { List } = require('immutable@4.0.0-rc.8') * List([ 'dog', 'frog', 'cat', 'hat', 'god' ]) * .takeUntil(x => x.match(/at/)) * // List [ "dog", "frog" ] @@ -4865,7 +4865,7 @@ * * * ```js - * const { get } = require('immutable@4.0.0-rc.7') + * const { get } = require('immutable@4.0.0-rc.8') * get([ 'dog', 'frog', 'cat' ], 2) // 'frog' * get({ x: 123, y: 456 }, 'x') // 123 * get({ x: 123, y: 456 }, 'z', 'ifNotSet') // 'ifNotSet' @@ -4889,7 +4889,7 @@ * * * ```js - * const { has } = require('immutable@4.0.0-rc.7') + * const { has } = require('immutable@4.0.0-rc.8') * has([ 'dog', 'frog', 'cat' ], 2) // true * has([ 'dog', 'frog', 'cat' ], 5) // false * has({ x: 123, y: 456 }, 'x') // true @@ -4907,7 +4907,7 @@ * * * ```js - * const { remove } = require('immutable@4.0.0-rc.7') + * const { remove } = require('immutable@4.0.0-rc.8') * const originalArray = [ 'dog', 'frog', 'cat' ] * remove(originalArray, 1) // [ 'dog', 'cat' ] * console.log(originalArray) // [ 'dog', 'frog', 'cat' ] @@ -4932,7 +4932,7 @@ * * * ```js - * const { set } = require('immutable@4.0.0-rc.7') + * const { set } = require('immutable@4.0.0-rc.8') * const originalArray = [ 'dog', 'frog', 'cat' ] * set(originalArray, 1, 'cow') // [ 'dog', 'cow', 'cat' ] * console.log(originalArray) // [ 'dog', 'frog', 'cat' ] @@ -4957,7 +4957,7 @@ * * * ```js - * const { update } = require('immutable@4.0.0-rc.7') + * const { update } = require('immutable@4.0.0-rc.8') * const originalArray = [ 'dog', 'frog', 'cat' ] * update(originalArray, 1, val => val.toUpperCase()) // [ 'dog', 'FROG', 'cat' ] * console.log(originalArray) // [ 'dog', 'frog', 'cat' ] @@ -4986,7 +4986,7 @@ * * * ```js - * const { getIn } = require('immutable@4.0.0-rc.7') + * const { getIn } = require('immutable@4.0.0-rc.8') * getIn({ x: { y: { z: 123 }}}, ['x', 'y', 'z']) // 123 * getIn({ x: { y: { z: 123 }}}, ['x', 'q', 'p'], 'ifNotSet') // 'ifNotSet' * ``` @@ -5001,7 +5001,7 @@ * * * ```js - * const { hasIn } = require('immutable@4.0.0-rc.7') + * const { hasIn } = require('immutable@4.0.0-rc.8') * hasIn({ x: { y: { z: 123 }}}, ['x', 'y', 'z']) // true * hasIn({ x: { y: { z: 123 }}}, ['x', 'q', 'p']) // false * ``` @@ -5016,7 +5016,7 @@ * * * ```js - * const { removeIn } = require('immutable@4.0.0-rc.7') + * const { removeIn } = require('immutable@4.0.0-rc.8') * const original = { x: { y: { z: 123 }}} * removeIn(original, ['x', 'y', 'z']) // { x: { y: {}}} * console.log(original) // { x: { y: { z: 123 }}} @@ -5033,7 +5033,7 @@ * * * ```js - * const { setIn } = require('immutable@4.0.0-rc.7') + * const { setIn } = require('immutable@4.0.0-rc.8') * const original = { x: { y: { z: 123 }}} * setIn(original, ['x', 'y', 'z'], 456) // { x: { y: { z: 456 }}} * console.log(original) // { x: { y: { z: 123 }}} @@ -5050,7 +5050,7 @@ * * * ```js - * const { setIn } = require('immutable@4.0.0-rc.7') + * const { setIn } = require('immutable@4.0.0-rc.8') * const original = { x: { y: { z: 123 }}} * setIn(original, ['x', 'y', 'z'], val => val * 6) // { x: { y: { z: 738 }}} * console.log(original) // { x: { y: { z: 123 }}} @@ -5067,7 +5067,7 @@ * * * ```js - * const { merge } = require('immutable@4.0.0-rc.7') + * const { merge } = require('immutable@4.0.0-rc.8') * const original = { x: 123, y: 456 } * merge(original, { y: 789, z: 'abc' }) // { x: 123, y: 789, z: 'abc' } * console.log(original) // { x: { y: { z: 123 }}} @@ -5087,7 +5087,7 @@ * * * ```js - * const { mergeWith } = require('immutable@4.0.0-rc.7') + * const { mergeWith } = require('immutable@4.0.0-rc.8') * const original = { x: 123, y: 456 } * mergeWith( * (oldVal, newVal) => oldVal + newVal, @@ -5112,7 +5112,7 @@ * * * ```js - * const { merge } = require('immutable@4.0.0-rc.7') + * const { merge } = require('immutable@4.0.0-rc.8') * const original = { x: { y: 123 }} * merge(original, { x: { z: 456 }}) // { x: { y: 123, z: 456 }} * console.log(original) // { x: { y: 123 }} @@ -5133,7 +5133,7 @@ * * * ```js - * const { merge } = require('immutable@4.0.0-rc.7') + * const { merge } = require('immutable@4.0.0-rc.8') * const original = { x: { y: 123 }} * mergeDeepWith( * (oldVal, newVal) => oldVal + newVal, diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index 4fe2dc7bc7..ae8f5052da 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -118,7 +118,7 @@ declare module Immutable { * * * ```js - * const { fromJS, isKeyed } = require('immutable@4.0.0-rc.7') + * const { fromJS, isKeyed } = require('immutable@4.0.0-rc.8') * function (key, value) { * return isKeyed(value) ? value.Map() : value.toList() * } @@ -132,7 +132,7 @@ declare module Immutable { * * * ```js - * const { fromJS, isKeyed } = require('immutable@4.0.0-rc.7') + * const { fromJS, isKeyed } = require('immutable@4.0.0-rc.8') * fromJS({ a: {b: [10, 20, 30]}, c: 40}, function (key, value, path) { * console.log(key, value, path) * return isKeyed(value) ? value.toOrderedMap() : value.toList() @@ -149,7 +149,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.7') + * const { Map } = require('immutable@4.0.0-rc.8') * let obj = { 1: "one" }; * Object.keys(obj); // [ "1" ] * assert.equal(obj["1"], obj[1]); // "one" === "one" @@ -185,7 +185,7 @@ declare module Immutable { * * * ```js - * const { Map, is } = require('immutable@4.0.0-rc.7') + * const { Map, is } = require('immutable@4.0.0-rc.8') * const map1 = Map({ a: 1, b: 1, c: 1 }) * const map2 = Map({ a: 1, b: 1, c: 1 }) * assert.equal(map1 !== map2, true) @@ -234,7 +234,7 @@ declare module Immutable { * * * ```js - * const { isImmutable, Map, List, Stack } = require('immutable@4.0.0-rc.7'); + * const { isImmutable, Map, List, Stack } = require('immutable@4.0.0-rc.8'); * isImmutable([]); // false * isImmutable({}); // false * isImmutable(Map()); // true @@ -250,7 +250,7 @@ declare module Immutable { * * * ```js - * const { isCollection, Map, List, Stack } = require('immutable@4.0.0-rc.7'); + * const { isCollection, Map, List, Stack } = require('immutable@4.0.0-rc.8'); * isCollection([]); // false * isCollection({}); // false * isCollection(Map()); // true @@ -265,7 +265,7 @@ declare module Immutable { * * * ```js - * const { isKeyed, Map, List, Stack } = require('immutable@4.0.0-rc.7'); + * const { isKeyed, Map, List, Stack } = require('immutable@4.0.0-rc.8'); * isKeyed([]); // false * isKeyed({}); // false * isKeyed(Map()); // true @@ -280,7 +280,7 @@ declare module Immutable { * * * ```js - * const { isIndexed, Map, List, Stack, Set } = require('immutable@4.0.0-rc.7'); + * const { isIndexed, Map, List, Stack, Set } = require('immutable@4.0.0-rc.8'); * isIndexed([]); // false * isIndexed({}); // false * isIndexed(Map()); // false @@ -296,7 +296,7 @@ declare module Immutable { * * * ```js - * const { isAssociative, Map, List, Stack, Set } = require('immutable@4.0.0-rc.7'); + * const { isAssociative, Map, List, Stack, Set } = require('immutable@4.0.0-rc.8'); * isAssociative([]); // false * isAssociative({}); // false * isAssociative(Map()); // true @@ -313,7 +313,7 @@ declare module Immutable { * * * ```js - * const { isOrdered, Map, OrderedMap, List, Set } = require('immutable@4.0.0-rc.7'); + * const { isOrdered, Map, OrderedMap, List, Set } = require('immutable@4.0.0-rc.8'); * isOrdered([]); // false * isOrdered({}); // false * isOrdered(Map()); // false @@ -355,7 +355,7 @@ declare module Immutable { * * * ```js - * const { List, Set } = require('immutable@4.0.0-rc.7'); + * const { List, Set } = require('immutable@4.0.0-rc.8'); * const a = List([ 1, 2, 3 ]); * const b = List([ 1, 2, 3 ]); * assert.notStrictEqual(a, b); // different instances @@ -401,7 +401,7 @@ declare module Immutable { * * * ```js - * const { List } = require('immutable@4.0.0-rc.7'); + * const { List } = require('immutable@4.0.0-rc.8'); * List.isList([]); // false * List.isList(List()); // true * ``` @@ -413,7 +413,7 @@ declare module Immutable { * * * ```js - * const { List } = require('immutable@4.0.0-rc.7'); + * const { List } = require('immutable@4.0.0-rc.8'); * List.of(1, 2, 3, 4) * // List [ 1, 2, 3, 4 ] * ``` @@ -422,7 +422,7 @@ declare module Immutable { * * * ```js - * const { List } = require('immutable@4.0.0-rc.7'); + * const { List } = require('immutable@4.0.0-rc.8'); * List.of({x:1}, 2, [3], 4) * // List [ { x: 1 }, 2, [ 3 ], 4 ] * ``` @@ -436,7 +436,7 @@ declare module Immutable { * * * ```js - * const { List, Set } = require('immutable@4.0.0-rc.7') + * const { List, Set } = require('immutable@4.0.0-rc.8') * * const emptyList = List() * // List [] @@ -482,7 +482,7 @@ declare module Immutable { * enough to include the `index`. * * * ```js * const originalList = List([ 0 ]); @@ -515,7 +515,7 @@ declare module Immutable { * Note: `delete` cannot be safely used in IE8 * * * ```js * List([ 0, 1, 2, 3, 4 ]).delete(0); @@ -539,7 +539,7 @@ declare module Immutable { * This is synonymous with `list.splice(index, 0, value)`. * * * ```js * List([ 0, 1, 2, 3, 4 ]).insert(6, 5) @@ -557,7 +557,7 @@ declare module Immutable { * Returns a new List with 0 size and no values in constant time. * * * ```js * List([ 1, 2, 3, 4 ]).clear() @@ -573,7 +573,7 @@ declare module Immutable { * List's `size`. * * * ```js * List([ 1, 2, 3, 4 ]).push(5) @@ -606,7 +606,7 @@ declare module Immutable { * values ahead to higher indices. * * * ```js * List([ 2, 3, 4]).unshift(1); @@ -626,7 +626,7 @@ declare module Immutable { * value in this List. * * * ```js * List([ 0, 1, 2, 3, 4 ]).shift(); @@ -647,7 +647,7 @@ declare module Immutable { * List. `v.update(-1)` updates the last item in the List. * * * ```js * const list = List([ 'a', 'b', 'c' ]) @@ -661,7 +661,7 @@ declare module Immutable { * For example, to sum a List after mapping and filtering: * * * ```js * function sum(collection) { @@ -707,7 +707,7 @@ declare module Immutable { * * * ```js - * const { List } = require('immutable@4.0.0-rc.7') + * const { List } = require('immutable@4.0.0-rc.8') * const list = List([ 0, 1, 2, List([ 3, 4 ])]) * list.setIn([3, 0], 999); * // List [ 0, 1, 2, List [ 999, 4 ] ] @@ -719,7 +719,7 @@ declare module Immutable { * * * ```js - * const { List } = require('immutable@4.0.0-rc.7') + * const { List } = require('immutable@4.0.0-rc.8') * const list = List([ 0, 1, 2, { plain: 'object' }]) * list.setIn([3, 'plain'], 'value'); * // List([ 0, 1, 2, { plain: 'value' }]) @@ -735,7 +735,7 @@ declare module Immutable { * * * ```js - * const { List } = require('immutable@4.0.0-rc.7') + * const { List } = require('immutable@4.0.0-rc.8') * const list = List([ 0, 1, 2, List([ 3, 4 ])]) * list.deleteIn([3, 0]); * // List [ 0, 1, 2, List [ 4 ] ] @@ -747,7 +747,7 @@ declare module Immutable { * * * ```js - * const { List } = require('immutable@4.0.0-rc.7') + * const { List } = require('immutable@4.0.0-rc.8') * const list = List([ 0, 1, 2, { plain: 'object' }]) * list.removeIn([3, 'plain']); * // List([ 0, 1, 2, {}]) @@ -831,7 +831,7 @@ declare module Immutable { * `mapper` function. * * * ```js * List([ 1, 2 ]).map(x => 10 * x) @@ -878,7 +878,7 @@ declare module Immutable { * Like `zipWith`, but using the default `zipper`: creating an `Array`. * * * ```js * const a = List([ 1, 2, 3 ]); @@ -897,7 +897,7 @@ declare module Immutable { * exhausted. Missing values from shorter collections are filled with `undefined`. * * * ```js * const a = List([ 1, 2 ]); @@ -918,7 +918,7 @@ declare module Immutable { * custom `zipper` function. * * * ```js * const a = List([ 1, 2, 3 ]); @@ -959,7 +959,7 @@ declare module Immutable { * * * ```js - * const { Map, List } = require('immutable@4.0.0-rc.7'); + * const { Map, List } = require('immutable@4.0.0-rc.8'); * Map().set(List([ 1 ]), 'listofone').get(List([ 1 ])); * // 'listofone' * ``` @@ -977,7 +977,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.7') + * const { Map } = require('immutable@4.0.0-rc.8') * Map.isMap({}) // false * Map.isMap(Map()) // true * ``` @@ -989,7 +989,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.7') + * const { Map } = require('immutable@4.0.0-rc.8') * Map.of( * 'key', 'value', * 'numerical value', 3, @@ -1011,7 +1011,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.7') + * const { Map } = require('immutable@4.0.0-rc.8') * Map({ key: "value" }) * Map([ [ "key", "value" ] ]) * ``` @@ -1021,7 +1021,7 @@ declare module Immutable { * quote-less shorthand, while Immutable Maps accept keys of any type. * * * ```js * let obj = { 1: "one" } @@ -1057,7 +1057,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.7') + * const { Map } = require('immutable@4.0.0-rc.8') * const originalMap = Map() * const newerMap = originalMap.set('key', 'value') * const newestMap = newerMap.set('key', 'newer value') @@ -1082,7 +1082,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.7') + * const { Map } = require('immutable@4.0.0-rc.8') * const originalMap = Map({ * key: 'value', * otherKey: 'other value' @@ -1104,7 +1104,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.7') + * const { Map } = require('immutable@4.0.0-rc.8') * const names = Map({ a: "Aaron", b: "Barry", c: "Connor" }) * names.deleteAll([ 'a', 'c' ]) * // Map { "b": "Barry" } @@ -1122,7 +1122,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.7') + * const { Map } = require('immutable@4.0.0-rc.8') * Map({ key: 'value' }).clear() * // Map {} * ``` @@ -1139,7 +1139,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.7') + * const { Map } = require('immutable@4.0.0-rc.8') * const aMap = Map({ key: 'value' }) * const newMap = aMap.update('key', value => value + value) * // Map { "key": "valuevalue" } @@ -1150,7 +1150,7 @@ declare module Immutable { * `update` and `push` can be used together: * * * ```js * const aMap = Map({ nestedList: List([ 1, 2, 3 ]) }) @@ -1162,7 +1162,7 @@ declare module Immutable { * function when the value at the key does not exist in the Map. * * * ```js * const aMap = Map({ key: 'value' }) @@ -1175,7 +1175,7 @@ declare module Immutable { * is provided. * * * ```js * const aMap = Map({ apples: 10 }) @@ -1191,7 +1191,7 @@ declare module Immutable { * The previous example behaves differently when written with default values: * * * ```js * const aMap = Map({ apples: 10 }) @@ -1203,7 +1203,7 @@ declare module Immutable { * returned as well. * * * ```js * const aMap = Map({ key: 'value' }) @@ -1217,7 +1217,7 @@ declare module Immutable { * For example, to sum the values in a Map * * * ```js * function sum(collection) { @@ -1247,7 +1247,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.7') + * const { Map } = require('immutable@4.0.0-rc.8') * const one = Map({ a: 10, b: 20, c: 30 }) * const two = Map({ b: 40, a: 50, d: 60 }) * one.merge(two) // Map { "a": 50, "b": 40, "c": 30, "d": 60 } @@ -1270,7 +1270,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.7') + * const { Map } = require('immutable@4.0.0-rc.8') * const one = Map({ a: 10, b: 20, c: 30 }) * const two = Map({ b: 40, a: 50, d: 60 }) * one.mergeWith((oldVal, newVal) => oldVal / newVal, two) @@ -1296,7 +1296,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.7') + * const { Map } = require('immutable@4.0.0-rc.8') * const one = Map({ a: Map({ x: 10, y: 10 }), b: Map({ x: 20, y: 50 }) }) * const two = Map({ a: Map({ x: 2 }), b: Map({ y: 5 }), c: Map({ z: 3 }) }) * one.mergeDeep(two) @@ -1317,7 +1317,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.7') + * const { Map } = require('immutable@4.0.0-rc.8') * const one = Map({ a: Map({ x: 10, y: 10 }), b: Map({ x: 20, y: 50 }) }) * const two = Map({ a: Map({ x: 2 }), b: Map({ y: 5 }), c: Map({ z: 3 }) }) * one.mergeDeepWith((oldVal, newVal) => oldVal / newVal, two) @@ -1344,7 +1344,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.7') + * const { Map } = require('immutable@4.0.0-rc.8') * const originalMap = Map({ * subObject: Map({ * subKey: 'subvalue', @@ -1380,7 +1380,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.7') + * const { Map } = require('immutable@4.0.0-rc.8') * const originalMap = Map({ * subObject: { * subKey: 'subvalue', @@ -1427,7 +1427,7 @@ declare module Immutable { * * * ```js - * const { Map, List } = require('immutable@4.0.0-rc.7') + * const { Map, List } = require('immutable@4.0.0-rc.8') * const map = Map({ inMap: Map({ inList: List([ 1, 2, 3 ]) }) }) * const newMap = map.updateIn(['inMap', 'inList'], list => list.push(4)) * // Map { "inMap": Map { "inList": List [ 1, 2, 3, 4 ] } } @@ -1439,7 +1439,7 @@ declare module Immutable { * provided, otherwise `undefined`. * * * ```js * const map = Map({ a: Map({ b: Map({ c: 10 }) }) }) @@ -1451,7 +1451,7 @@ declare module Immutable { * no change will occur. This is still true if `notSetValue` is provided. * * * ```js * const map = Map({ a: Map({ b: Map({ c: 10 }) }) }) @@ -1467,7 +1467,7 @@ declare module Immutable { * The previous example behaves differently when written with default values: * * * ```js * const map = Map({ a: Map({ b: Map({ c: 10 }) }) }) @@ -1480,7 +1480,7 @@ declare module Immutable { * immutably by creating new copies of those values with the changes applied. * * * ```js * const map = Map({ a: { b: { c: 10 } } }) @@ -1541,7 +1541,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.7') + * const { Map } = require('immutable@4.0.0-rc.8') * const map1 = Map() * const map2 = map1.withMutations(map => { * map.set('a', 1).set('b', 2).set('c', 3) @@ -1709,7 +1709,7 @@ declare module Immutable { * * * ```js - * const { OrderedMap } = require('immutable@4.0.0-rc.7') + * const { OrderedMap } = require('immutable@4.0.0-rc.8') * const one = OrderedMap({ a: 10, b: 20, c: 30 }) * const two = OrderedMap({ b: 40, a: 50, d: 60 }) * one.merge(two) // OrderedMap { "a": 50, "b": 40, "c": 30, "d": 60 } @@ -1826,7 +1826,7 @@ declare module Immutable { * a collection of other sets. * * ```js - * const { Set } = require('immutable@4.0.0-rc.7') + * const { Set } = require('immutable@4.0.0-rc.8') * const intersected = Set.intersect([ * Set([ 'a', 'b', 'c' ]) * Set([ 'c', 'a', 't' ]) @@ -1841,7 +1841,7 @@ declare module Immutable { * collection of other sets. * * ```js - * const { Set } = require('immutable@4.0.0-rc.7') + * const { Set } = require('immutable@4.0.0-rc.8') * const unioned = Set.union([ * Set([ 'a', 'b', 'c' ]) * Set([ 'c', 'a', 't' ]) @@ -2412,7 +2412,7 @@ declare module Immutable { * infinity. When `start` is equal to `end`, returns empty range. * * ```js - * const { Range } = require('immutable@4.0.0-rc.7') + * const { Range } = require('immutable@4.0.0-rc.8') * Range() // [ 0, 1, 2, 3, ... ] * Range(10) // [ 10, 11, 12, 13, ... ] * Range(10, 15) // [ 10, 11, 12, 13, 14 ] @@ -2429,7 +2429,7 @@ declare module Immutable { * not defined, returns an infinite `Seq` of `value`. * * ```js - * const { Repeat } = require('immutable@4.0.0-rc.7') + * const { Repeat } = require('immutable@4.0.0-rc.8') * Repeat('foo') // [ 'foo', 'foo', 'foo', ... ] * Repeat('bar', 4) // [ 'bar', 'bar', 'bar', 'bar' ] * ``` @@ -2445,7 +2445,7 @@ declare module Immutable { * create Record instances. * * ```js - * const { Record } = require('immutable@4.0.0-rc.7') + * const { Record } = require('immutable@4.0.0-rc.8') * const ABRecord = Record({ a: 1, b: 2 }) * const myRecord = new ABRecord({ b: 3 }) * ``` @@ -2577,7 +2577,7 @@ declare module Immutable { * method. If one was not provided, the string "Record" is returned. * * ```js - * const { Record } = require('immutable@4.0.0-rc.7') + * const { Record } = require('immutable@4.0.0-rc.8') * const Person = Record({ * name: null * }, 'Person') @@ -2595,7 +2595,7 @@ declare module Immutable { * type: * * * ```js * // makePerson is a Record Factory function @@ -2610,7 +2610,7 @@ declare module Immutable { * access on the resulting instances: * * * ```js * // Use the Record API @@ -2792,7 +2792,7 @@ declare module Immutable { * `Seq`'s values are never iterated: * * ```js - * const { Seq } = require('immutable@4.0.0-rc.7') + * const { Seq } = require('immutable@4.0.0-rc.8') * const oddSquares = Seq([ 1, 2, 3, 4, 5, 6, 7, 8 ]) * .filter(x => x % 2 !== 0) * .map(x => x * x) @@ -2831,7 +2831,7 @@ declare module Immutable { * * * ```js - * const { Range } = require('immutable@4.0.0-rc.7') + * const { Range } = require('immutable@4.0.0-rc.8') * Range(1, Infinity) * .skip(1000) * .map(n => -n) @@ -2910,7 +2910,7 @@ declare module Immutable { * `mapper` function. * * ```js - * const { Seq } = require('immutable@4.0.0-rc.7') + * const { Seq } = require('immutable@4.0.0-rc.8') * Seq.Keyed({ a: 1, b: 2 }).map(x => 10 * x) * // Seq { "a": 10, "b": 20 } * ``` @@ -3022,7 +3022,7 @@ declare module Immutable { * `mapper` function. * * ```js - * const { Seq } = require('immutable@4.0.0-rc.7') + * const { Seq } = require('immutable@4.0.0-rc.8') * Seq.Indexed([ 1, 2 ]).map(x => 10 * x) * // Seq [ 10, 20 ] * ``` @@ -3282,7 +3282,7 @@ declare module Immutable { * `mapper` function. * * ```js - * const { Seq } = require('immutable@4.0.0-rc.7') + * const { Seq } = require('immutable@4.0.0-rc.8') * Seq([ 1, 2 ]).map(x => 10 * x) * // Seq [ 10, 20 ] * ``` @@ -3300,7 +3300,7 @@ declare module Immutable { * `mapper` function. * * ```js - * const { Seq } = require('immutable@4.0.0-rc.7') + * const { Seq } = require('immutable@4.0.0-rc.8') * Seq([ 1, 2 ]).map(x => 10 * x) * // Seq [ 10, 20 ] * ``` @@ -3369,22 +3369,22 @@ declare module Immutable { export module Collection { /** - * @deprecated use `const { isKeyed } = require('immutable@4.0.0-rc.7')` + * @deprecated use `const { isKeyed } = require('immutable@4.0.0-rc.8')` */ function isKeyed(maybeKeyed: any): maybeKeyed is Collection.Keyed; /** - * @deprecated use `const { isIndexed } = require('immutable@4.0.0-rc.7')` + * @deprecated use `const { isIndexed } = require('immutable@4.0.0-rc.8')` */ function isIndexed(maybeIndexed: any): maybeIndexed is Collection.Indexed; /** - * @deprecated use `const { isAssociative } = require('immutable@4.0.0-rc.7')` + * @deprecated use `const { isAssociative } = require('immutable@4.0.0-rc.8')` */ function isAssociative(maybeAssociative: any): maybeAssociative is Collection.Keyed | Collection.Indexed; /** - * @deprecated use `const { isOrdered } = require('immutable@4.0.0-rc.7')` + * @deprecated use `const { isOrdered } = require('immutable@4.0.0-rc.8')` */ function isOrdered(maybeOrdered: any): boolean; @@ -3442,7 +3442,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.7') + * const { Map } = require('immutable@4.0.0-rc.8') * Map({ a: 'z', b: 'y' }).flip() * // Map { "z": "a", "y": "b" } * ``` @@ -3460,7 +3460,7 @@ declare module Immutable { * `mapper` function. * * ```js - * const { Collection } = require('immutable@4.0.0-rc.7') + * const { Collection } = require('immutable@4.0.0-rc.8') * Collection.Keyed({ a: 1, b: 2 }).map(x => 10 * x) * // Seq { "a": 10, "b": 20 } * ``` @@ -3479,7 +3479,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.7') + * const { Map } = require('immutable@4.0.0-rc.8') * Map({ a: 1, b: 2 }).mapKeys(x => x.toUpperCase()) * // Map { "A": 1, "B": 2 } * ``` @@ -3498,7 +3498,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.7') + * const { Map } = require('immutable@4.0.0-rc.8') * Map({ a: 1, b: 2 }) * .mapEntries(([ k, v ]) => [ k.toUpperCase(), v * 2 ]) * // Map { "A": 2, "B": 4 } @@ -3624,10 +3624,10 @@ declare module Immutable { * second from each, etc. * * * ```js - * const { List } = require('immutable@4.0.0-rc.7') + * const { List } = require('immutable@4.0.0-rc.8') * List([ 1, 2, 3 ]).interleave(List([ 'A', 'B', 'C' ])) * // List [ 1, "A", 2, "B", 3, "C"" ] * ``` @@ -3635,7 +3635,7 @@ declare module Immutable { * The shortest Collection stops interleave. * * * ```js * List([ 1, 2, 3 ]).interleave( @@ -3662,7 +3662,7 @@ declare module Immutable { * * * ```js - * const { List } = require('immutable@4.0.0-rc.7') + * const { List } = require('immutable@4.0.0-rc.8') * List([ 'a', 'b', 'c', 'd' ]).splice(1, 2, 'q', 'r', 's') * // List [ "a", "q", "r", "s", "d" ] * ``` @@ -3686,7 +3686,7 @@ declare module Immutable { * * * * ```js * const a = List([ 1, 2, 3 ]); @@ -3719,7 +3719,7 @@ declare module Immutable { * collections by using a custom `zipper` function. * * * ```js * const a = List([ 1, 2, 3 ]); @@ -3787,7 +3787,7 @@ declare module Immutable { * `mapper` function. * * ```js - * const { Collection } = require('immutable@4.0.0-rc.7') + * const { Collection } = require('immutable@4.0.0-rc.8') * Collection.Indexed([1,2]).map(x => 10 * x) * // Seq [ 1, 2 ] * ``` @@ -3839,7 +3839,7 @@ declare module Immutable { * the value as both the first and second arguments to the provided function. * * ```js - * const { Collection } = require('immutable@4.0.0-rc.7') + * const { Collection } = require('immutable@4.0.0-rc.8') * const seq = Collection.Set([ 'A', 'B', 'C' ]) * // Seq { "A", "B", "C" } * seq.forEach((v, k) => @@ -3971,7 +3971,7 @@ declare module Immutable { * lookup via a different instance. * * * ```js * const a = List([ 1, 2, 3 ]); @@ -4036,7 +4036,7 @@ declare module Immutable { * * * ```js - * const { Map, List } = require('immutable@4.0.0-rc.7') + * const { Map, List } = require('immutable@4.0.0-rc.8') * const deepData = Map({ x: List([ Map({ y: 123 }) ]) }); * getIn(deepData, ['x', 0, 'y']) // 123 * ``` @@ -4046,7 +4046,7 @@ declare module Immutable { * * * ```js - * const { Map, List } = require('immutable@4.0.0-rc.7') + * const { Map, List } = require('immutable@4.0.0-rc.8') * const deepData = Map({ x: [ { y: 123 } ] }); * getIn(deepData, ['x', 0, 'y']) // 123 * ``` @@ -4069,7 +4069,7 @@ declare module Immutable { * * * ```js - * const { Seq } = require('immutable@4.0.0-rc.7') + * const { Seq } = require('immutable@4.0.0-rc.8') * * function sum(collection) { * return collection.reduce((sum, x) => sum + x, 0) @@ -4165,7 +4165,7 @@ declare module Immutable { * * * ```js - * const { Map, List } = require('immutable@4.0.0-rc.7') + * const { Map, List } = require('immutable@4.0.0-rc.8') * var myMap = Map({ a: 'Apple', b: 'Banana' }) * List(myMap) // List [ [ "a", "Apple" ], [ "b", "Banana" ] ] * myMap.toList() // List [ "Apple", "Banana" ] @@ -4202,7 +4202,7 @@ declare module Immutable { * * * ```js - * const { Seq } = require('immutable@4.0.0-rc.7') + * const { Seq } = require('immutable@4.0.0-rc.8') * const indexedSeq = Seq([ 'A', 'B', 'C' ]) * // Seq [ "A", "B", "C" ] * indexedSeq.filter(v => v === 'B') @@ -4283,7 +4283,7 @@ declare module Immutable { * * * ```js - * const { Collection } = require('immutable@4.0.0-rc.7') + * const { Collection } = require('immutable@4.0.0-rc.8') * Collection({ a: 1, b: 2 }).map(x => 10 * x) * // Seq { "a": 10, "b": 20 } * ``` @@ -4310,7 +4310,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.7') + * const { Map } = require('immutable@4.0.0-rc.8') * Map({ a: 1, b: 2, c: 3, d: 4}).filter(x => x % 2 === 0) * // Map { "b": 2, "d": 4 } * ``` @@ -4333,7 +4333,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.7') + * const { Map } = require('immutable@4.0.0-rc.8') * Map({ a: 1, b: 2, c: 3, d: 4}).filterNot(x => x % 2 === 0) * // Map { "a": 1, "c": 3 } * ``` @@ -4370,7 +4370,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.7') + * const { Map } = require('immutable@4.0.0-rc.8') * Map({ "c": 3, "a": 1, "b": 2 }).sort((a, b) => { * if (a < b) { return -1; } * if (a > b) { return 1; } @@ -4410,7 +4410,7 @@ declare module Immutable { * * * ```js - * const { List, Map } = require('immutable@4.0.0-rc.7') + * const { List, Map } = require('immutable@4.0.0-rc.8') * const listOfMaps = List([ * Map({ v: 0 }), * Map({ v: 1 }), @@ -4497,7 +4497,7 @@ declare module Immutable { * * * ```js - * const { List } = require('immutable@4.0.0-rc.7') + * const { List } = require('immutable@4.0.0-rc.8') * List([ 'dog', 'frog', 'cat', 'hat', 'god' ]) * .skipWhile(x => x.match(/g/)) * // List [ "cat", "hat", "god"" ] @@ -4514,7 +4514,7 @@ declare module Immutable { * * * ```js - * const { List } = require('immutable@4.0.0-rc.7') + * const { List } = require('immutable@4.0.0-rc.8') * List([ 'dog', 'frog', 'cat', 'hat', 'god' ]) * .skipUntil(x => x.match(/hat/)) * // List [ "hat", "god"" ] @@ -4543,7 +4543,7 @@ declare module Immutable { * * * ```js - * const { List } = require('immutable@4.0.0-rc.7') + * const { List } = require('immutable@4.0.0-rc.8') * List([ 'dog', 'frog', 'cat', 'hat', 'god' ]) * .takeWhile(x => x.match(/o/)) * // List [ "dog", "frog" ] @@ -4560,7 +4560,7 @@ declare module Immutable { * * * ```js - * const { List } = require('immutable@4.0.0-rc.7') + * const { List } = require('immutable@4.0.0-rc.8') * List([ 'dog', 'frog', 'cat', 'hat', 'god' ]) * .takeUntil(x => x.match(/at/)) * // List [ "dog", "frog" ] @@ -4865,7 +4865,7 @@ declare module Immutable { * * * ```js - * const { get } = require('immutable@4.0.0-rc.7') + * const { get } = require('immutable@4.0.0-rc.8') * get([ 'dog', 'frog', 'cat' ], 2) // 'frog' * get({ x: 123, y: 456 }, 'x') // 123 * get({ x: 123, y: 456 }, 'z', 'ifNotSet') // 'ifNotSet' @@ -4889,7 +4889,7 @@ declare module Immutable { * * * ```js - * const { has } = require('immutable@4.0.0-rc.7') + * const { has } = require('immutable@4.0.0-rc.8') * has([ 'dog', 'frog', 'cat' ], 2) // true * has([ 'dog', 'frog', 'cat' ], 5) // false * has({ x: 123, y: 456 }, 'x') // true @@ -4907,7 +4907,7 @@ declare module Immutable { * * * ```js - * const { remove } = require('immutable@4.0.0-rc.7') + * const { remove } = require('immutable@4.0.0-rc.8') * const originalArray = [ 'dog', 'frog', 'cat' ] * remove(originalArray, 1) // [ 'dog', 'cat' ] * console.log(originalArray) // [ 'dog', 'frog', 'cat' ] @@ -4932,7 +4932,7 @@ declare module Immutable { * * * ```js - * const { set } = require('immutable@4.0.0-rc.7') + * const { set } = require('immutable@4.0.0-rc.8') * const originalArray = [ 'dog', 'frog', 'cat' ] * set(originalArray, 1, 'cow') // [ 'dog', 'cow', 'cat' ] * console.log(originalArray) // [ 'dog', 'frog', 'cat' ] @@ -4957,7 +4957,7 @@ declare module Immutable { * * * ```js - * const { update } = require('immutable@4.0.0-rc.7') + * const { update } = require('immutable@4.0.0-rc.8') * const originalArray = [ 'dog', 'frog', 'cat' ] * update(originalArray, 1, val => val.toUpperCase()) // [ 'dog', 'FROG', 'cat' ] * console.log(originalArray) // [ 'dog', 'frog', 'cat' ] @@ -4986,7 +4986,7 @@ declare module Immutable { * * * ```js - * const { getIn } = require('immutable@4.0.0-rc.7') + * const { getIn } = require('immutable@4.0.0-rc.8') * getIn({ x: { y: { z: 123 }}}, ['x', 'y', 'z']) // 123 * getIn({ x: { y: { z: 123 }}}, ['x', 'q', 'p'], 'ifNotSet') // 'ifNotSet' * ``` @@ -5001,7 +5001,7 @@ declare module Immutable { * * * ```js - * const { hasIn } = require('immutable@4.0.0-rc.7') + * const { hasIn } = require('immutable@4.0.0-rc.8') * hasIn({ x: { y: { z: 123 }}}, ['x', 'y', 'z']) // true * hasIn({ x: { y: { z: 123 }}}, ['x', 'q', 'p']) // false * ``` @@ -5016,7 +5016,7 @@ declare module Immutable { * * * ```js - * const { removeIn } = require('immutable@4.0.0-rc.7') + * const { removeIn } = require('immutable@4.0.0-rc.8') * const original = { x: { y: { z: 123 }}} * removeIn(original, ['x', 'y', 'z']) // { x: { y: {}}} * console.log(original) // { x: { y: { z: 123 }}} @@ -5033,7 +5033,7 @@ declare module Immutable { * * * ```js - * const { setIn } = require('immutable@4.0.0-rc.7') + * const { setIn } = require('immutable@4.0.0-rc.8') * const original = { x: { y: { z: 123 }}} * setIn(original, ['x', 'y', 'z'], 456) // { x: { y: { z: 456 }}} * console.log(original) // { x: { y: { z: 123 }}} @@ -5050,7 +5050,7 @@ declare module Immutable { * * * ```js - * const { setIn } = require('immutable@4.0.0-rc.7') + * const { setIn } = require('immutable@4.0.0-rc.8') * const original = { x: { y: { z: 123 }}} * setIn(original, ['x', 'y', 'z'], val => val * 6) // { x: { y: { z: 738 }}} * console.log(original) // { x: { y: { z: 123 }}} @@ -5067,7 +5067,7 @@ declare module Immutable { * * * ```js - * const { merge } = require('immutable@4.0.0-rc.7') + * const { merge } = require('immutable@4.0.0-rc.8') * const original = { x: 123, y: 456 } * merge(original, { y: 789, z: 'abc' }) // { x: 123, y: 789, z: 'abc' } * console.log(original) // { x: { y: { z: 123 }}} @@ -5087,7 +5087,7 @@ declare module Immutable { * * * ```js - * const { mergeWith } = require('immutable@4.0.0-rc.7') + * const { mergeWith } = require('immutable@4.0.0-rc.8') * const original = { x: 123, y: 456 } * mergeWith( * (oldVal, newVal) => oldVal + newVal, @@ -5112,7 +5112,7 @@ declare module Immutable { * * * ```js - * const { merge } = require('immutable@4.0.0-rc.7') + * const { merge } = require('immutable@4.0.0-rc.8') * const original = { x: { y: 123 }} * merge(original, { x: { z: 456 }}) // { x: { y: 123, z: 456 }} * console.log(original) // { x: { y: 123 }} @@ -5133,7 +5133,7 @@ declare module Immutable { * * * ```js - * const { merge } = require('immutable@4.0.0-rc.7') + * const { merge } = require('immutable@4.0.0-rc.8') * const original = { x: { y: 123 }} * mergeDeepWith( * (oldVal, newVal) => oldVal + newVal, diff --git a/dist/immutable.es.js b/dist/immutable.es.js index b0d2534ee4..c976758cc9 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -5697,7 +5697,7 @@ function defaultConverter(k, v) { return isKeyed(v) ? v.toMap() : v.toList(); } -var version = "4.0.0-rc.7"; +var version = "4.0.0-rc.8"; // Functional read/write API var Immutable = { diff --git a/dist/immutable.js b/dist/immutable.js index f3d0d12303..ef17b445ed 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -5703,7 +5703,7 @@ function defaultConverter(k, v) { return isKeyed(v) ? v.toMap() : v.toList(); } -var version = "4.0.0-rc.7"; +var version = "4.0.0-rc.8"; // Functional read/write API var Immutable = { diff --git a/dist/immutable.min.js b/dist/immutable.min.js index dbc4d7586a..278aa1cb01 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -34,5 +34,5 @@ return this.__iterator(ze)},butLast:function(){return this.slice(0,-1)},isEmpty: return 0===t?this:this.slice(0,-Math.max(0,t))},skipWhile:function(t,r){return nt(this,Q(this,t,r,!0))},skipUntil:function(t,r){return this.skipWhile(Nr(t),r)},sortBy:function(t,r){return nt(this,$(this,r,t))},take:function(t){return this.slice(0,Math.max(0,t))},takeLast:function(t){return this.slice(-Math.max(0,t))},takeWhile:function(t,r){return nt(this,Y(this,t,r))},takeUntil:function(t,r){return this.takeWhile(Nr(t),r)},update:function(t){return t(this)},valueSeq:function(){return this.toIndexedSeq()},hashCode:function(){return this.__hash||(this.__hash=Vr(this))}});var An=ye.prototype;An[he]=!0,An[Oe]=An.values,An.toJSON=An.toArray,An.__toStringMapper=vt,An.inspect=An.toSource=function(){return""+this},An.chain=An.flatMap,An.contains=An.includes,Mr(de,{flip:function(){return nt(this,B(this))},mapEntries:function(t,r){var e=this,n=0;return nt(this,this.toSeq().map(function(i,o){return t.call(r,[o,i],n++,e)}).fromEntrySeq())},mapKeys:function(t,r){var e=this;return nt(this,this.toSeq().flip().map(function(n,i){return t.call(r,n,i,e)}).flip())}});var jn=de.prototype;jn[pe]=!0,jn[Oe]=An.entries,jn.toJSON=Cr,jn.__toStringMapper=function(t,r){return vt(r)+": "+vt(t)},Mr(ge,{toKeyedSeq:function(){return new Xe(this,!1)},filter:function(t,r){return nt(this,P(this,t,r,!1))},findIndex:function(t,r){var e=this.findEntry(t,r);return e?e[0]:-1},indexOf:function(t){var r=this.keyOf(t);return void 0===r?-1:r},lastIndexOf:function(t){var r=this.lastKeyOf(t);return void 0===r?-1:r},reverse:function(){return nt(this,N(this,!1))},slice:function(t,r){return nt(this,V(this,t,r,!1))},splice:function(t,r){var e=arguments.length;if(r=Math.max(r||0,0),0===e||2===e&&!r)return this;t=a(t,t<0?this.count():this.size);var n=this.slice(0,t);return nt(this,1===e?n:n.concat(ct(arguments,2),this.slice(t+r)))},findLastIndex:function(t,r){var e=this.findLastEntry(t,r);return e?e[0]:-1},first:function(){return this.get(0)},flatten:function(t){return nt(this,F(this,t,!1))},get:function(t,r){return t=o(this,t), t<0||this.size===1/0||void 0!==this.size&&t>this.size?r:this.find(function(r,e){return e===t},void 0,r)},has:function(t){return(t=o(this,t))>=0&&(void 0!==this.size?this.size===1/0||t Date: Tue, 17 Oct 2017 05:00:28 +0000 Subject: [PATCH 073/242] Deploy 34f1461ab4d57251f06e3beb006467880bbf86a0 to NPM branch --- dist/immutable-nonambient.d.ts | 698 ++++++++++++++++----------------- dist/immutable.d.ts | 698 ++++++++++++++++----------------- 2 files changed, 696 insertions(+), 700 deletions(-) diff --git a/dist/immutable-nonambient.d.ts b/dist/immutable-nonambient.d.ts index 8a81d6a798..8254dfe8e3 100644 --- a/dist/immutable-nonambient.d.ts +++ b/dist/immutable-nonambient.d.ts @@ -100,376 +100,95 @@ /** - * Deeply converts plain JS objects and arrays to Immutable Maps and Lists. - * - * If a `reviver` is optionally provided, it will be called with every - * collection as a Seq (beginning with the most nested collections - * and proceeding to the top-level collection itself), along with the key - * refering to each collection and the parent JS object provided as `this`. - * For the top level, object, the key will be `""`. This `reviver` is expected - * to return a new Immutable Collection, allowing for custom conversions from - * deep JS objects. Finally, a `path` is provided which is the sequence of - * keys to this value from the starting value. - * - * `reviver` acts similarly to the [same parameter in `JSON.parse`][1]. - * - * If `reviver` is not provided, the default behavior will convert Objects - * into Maps and Arrays into Lists like so: - * - * - * ```js - * const { fromJS, isKeyed } = require('immutable@4.0.0-rc.8') - * function (key, value) { - * return isKeyed(value) ? value.Map() : value.toList() - * } - * ``` - * - * `fromJS` is conservative in its conversion. It will only convert - * arrays which pass `Array.isArray` to Lists, and only raw objects (no custom - * prototype) to Map. - * - * Accordingly, this example converts native JS data to OrderedMap and List: - * - * - * ```js - * const { fromJS, isKeyed } = require('immutable@4.0.0-rc.8') - * fromJS({ a: {b: [10, 20, 30]}, c: 40}, function (key, value, path) { - * console.log(key, value, path) - * return isKeyed(value) ? value.toOrderedMap() : value.toList() - * }) - * - * > "b", [ 10, 20, 30 ], [ "a", "b" ] - * > "a", {b: [10, 20, 30]}, [ "a" ] - * > "", {a: {b: [10, 20, 30]}, c: 40}, [] - * ``` - * - * Keep in mind, when using JS objects to construct Immutable Maps, that - * JavaScript Object properties are always strings, even if written in a - * quote-less shorthand, while Immutable Maps accept keys of any type. - * - * - * ```js - * const { Map } = require('immutable@4.0.0-rc.8') - * let obj = { 1: "one" }; - * Object.keys(obj); // [ "1" ] - * assert.equal(obj["1"], obj[1]); // "one" === "one" + * Lists are ordered indexed dense collections, much like a JavaScript + * Array. * - * let map = Map(obj); - * assert.notEqual(map.get("1"), map.get(1)); // "one" !== undefined - * ``` + * Lists are immutable and fully persistent with O(log32 N) gets and sets, + * and O(1) push and pop. * - * Property access for JavaScript Objects first converts the key to a string, - * but since Immutable Map keys can be of any type the argument to `get()` is - * not altered. + * Lists implement Deque, with efficient addition and removal from both the + * end (`push`, `pop`) and beginning (`unshift`, `shift`). * - * [1]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse#Example.3A_Using_the_reviver_parameter - * "Using the reviver parameter" + * Unlike a JavaScript Array, there is no distinction between an + * "unset" index and an index set to `undefined`. `List#forEach` visits all + * indices from 0 to size, regardless of whether they were explicitly defined. */ - export function fromJS( - jsValue: any, - reviver?: ( - key: string | number, - sequence: Collection.Keyed | Collection.Indexed, - path?: Array - ) => any - ): any; + export module List { + + /** + * True if the provided value is a List + * + * + * ```js + * const { List } = require('immutable@4.0.0-rc.8'); + * List.isList([]); // false + * List.isList(List()); // true + * ``` + */ + function isList(maybeList: any): maybeList is List; + /** + * Creates a new List containing `values`. + * + * + * ```js + * const { List } = require('immutable@4.0.0-rc.8'); + * List.of(1, 2, 3, 4) + * // List [ 1, 2, 3, 4 ] + * ``` + * + * Note: Values are not altered or converted in any way. + * + * + * ```js + * const { List } = require('immutable@4.0.0-rc.8'); + * List.of({x:1}, 2, [3], 4) + * // List [ { x: 1 }, 2, [ 3 ], 4 ] + * ``` + */ + function of(...values: Array): List; + } /** - * Value equality check with semantics similar to `Object.is`, but treats - * Immutable `Collection`s as values, equal if the second `Collection` includes - * equivalent values. - * - * It's used throughout Immutable when checking for equality, including `Map` - * key equality and `Set` membership. + * Create a new immutable List containing the values of the provided + * collection-like. * * * ```js - * const { Map, is } = require('immutable@4.0.0-rc.8') - * const map1 = Map({ a: 1, b: 1, c: 1 }) - * const map2 = Map({ a: 1, b: 1, c: 1 }) - * assert.equal(map1 !== map2, true) - * assert.equal(Object.is(map1, map2), false) - * assert.equal(is(map1, map2), true) - * ``` - * - * `is()` compares primitive types like strings and numbers, Immutable.js - * collections like `Map` and `List`, but also any custom object which - * implements `ValueObject` by providing `equals()` and `hashCode()` methods. - * - * Note: Unlike `Object.is`, `Immutable.is` assumes `0` and `-0` are the same - * value, matching the behavior of ES6 Map key equality. - */ - export function is(first: any, second: any): boolean; - - - /** - * The `hash()` function is an important part of how Immutable determines if - * two values are equivalent and is used to determine how to store those - * values. Provided with any value, `hash()` will return a 31-bit integer. - * - * When designing Objects which may be equal, it's important than when a - * `.equals()` method returns true, that both values `.hashCode()` method - * return the same value. `hash()` may be used to produce those values. - * - * For non-Immutable Objects that do not provide a `.hashCode()` functions - * (including plain Objects, plain Arrays, Date objects, etc), a unique hash - * value will be created for each *instance*. That is, the create hash - * represents referential equality, and not value equality for Objects. This - * ensures that if that Object is mutated over time that its hash code will - * remain consistent, allowing Objects to be used as keys and values in - * Immutable.js collections. + * const { List, Set } = require('immutable@4.0.0-rc.8') * - * Note that `hash()` attempts to balance between speed and avoiding - * collisions, however it makes no attempt to produce secure hashes. + * const emptyList = List() + * // List [] * - * *New in Version 4.0* - */ - export function hash(value: any): number; - - /** - * True if `maybeImmutable` is an Immutable Collection or Record. + * const plainArray = [ 1, 2, 3, 4 ] + * const listFromPlainArray = List(plainArray) + * // List [ 1, 2, 3, 4 ] * - * Note: Still returns true even if the collections is within a `withMutations()`. + * const plainSet = Set([ 1, 2, 3, 4 ]) + * const listFromPlainSet = List(plainSet) + * // List [ 1, 2, 3, 4 ] * - * - * ```js - * const { isImmutable, Map, List, Stack } = require('immutable@4.0.0-rc.8'); - * isImmutable([]); // false - * isImmutable({}); // false - * isImmutable(Map()); // true - * isImmutable(List()); // true - * isImmutable(Stack()); // true - * isImmutable(Map().asMutable()); // true - * ``` - */ - export function isImmutable(maybeImmutable: any): maybeImmutable is Collection; - - /** - * True if `maybeCollection` is a Collection, or any of its subclasses. + * const arrayIterator = plainArray[Symbol.iterator]() + * const listFromCollectionArray = List(arrayIterator) + * // List [ 1, 2, 3, 4 ] * - * - * ```js - * const { isCollection, Map, List, Stack } = require('immutable@4.0.0-rc.8'); - * isCollection([]); // false - * isCollection({}); // false - * isCollection(Map()); // true - * isCollection(List()); // true - * isCollection(Stack()); // true + * listFromPlainArray.equals(listFromCollectionArray) // true + * listFromPlainSet.equals(listFromCollectionArray) // true + * listFromPlainSet.equals(listFromPlainArray) // true * ``` */ - export function isCollection(maybeCollection: any): maybeCollection is Collection; + export function List(): List; + export function List(): List; + export function List(collection: Iterable): List; - /** - * True if `maybeKeyed` is a Collection.Keyed, or any of its subclasses. - * - * - * ```js - * const { isKeyed, Map, List, Stack } = require('immutable@4.0.0-rc.8'); - * isKeyed([]); // false - * isKeyed({}); // false - * isKeyed(Map()); // true - * isKeyed(List()); // false - * isKeyed(Stack()); // false - * ``` - */ - export function isKeyed(maybeKeyed: any): maybeKeyed is Collection.Keyed; + export interface List extends Collection.Indexed { - /** - * True if `maybeIndexed` is a Collection.Indexed, or any of its subclasses. - * - * - * ```js - * const { isIndexed, Map, List, Stack, Set } = require('immutable@4.0.0-rc.8'); - * isIndexed([]); // false - * isIndexed({}); // false - * isIndexed(Map()); // false - * isIndexed(List()); // true - * isIndexed(Stack()); // true - * isIndexed(Set()); // false - * ``` - */ - export function isIndexed(maybeIndexed: any): maybeIndexed is Collection.Indexed; + /** + * The number of items in this List. + */ + readonly size: number; - /** - * True if `maybeAssociative` is either a Keyed or Indexed Collection. - * - * - * ```js - * const { isAssociative, Map, List, Stack, Set } = require('immutable@4.0.0-rc.8'); - * isAssociative([]); // false - * isAssociative({}); // false - * isAssociative(Map()); // true - * isAssociative(List()); // true - * isAssociative(Stack()); // true - * isAssociative(Set()); // false - * ``` - */ - export function isAssociative(maybeAssociative: any): maybeAssociative is Collection.Keyed | Collection.Indexed; - - /** - * True if `maybeOrdered` is a Collection where iteration order is well - * defined. True for Collection.Indexed as well as OrderedMap and OrderedSet. - * - * - * ```js - * const { isOrdered, Map, OrderedMap, List, Set } = require('immutable@4.0.0-rc.8'); - * isOrdered([]); // false - * isOrdered({}); // false - * isOrdered(Map()); // false - * isOrdered(OrderedMap()); // true - * isOrdered(List()); // true - * isOrdered(Set()); // false - * ``` - */ - export function isOrdered(maybeOrdered: any): boolean; - - /** - * True if `maybeValue` is a JavaScript Object which has *both* `equals()` - * and `hashCode()` methods. - * - * Any two instances of *value objects* can be compared for value equality with - * `Immutable.is()` and can be used as keys in a `Map` or members in a `Set`. - */ - export function isValueObject(maybeValue: any): maybeValue is ValueObject; - - /** - * The interface to fulfill to qualify as a Value Object. - */ - export interface ValueObject { - /** - * True if this and the other Collection have value equality, as defined - * by `Immutable.is()`. - * - * Note: This is equivalent to `Immutable.is(this, other)`, but provided to - * allow for chained expressions. - */ - equals(other: any): boolean; - - /** - * Computes and returns the hashed identity for this Collection. - * - * The `hashCode` of a Collection is used to determine potential equality, - * and is used when adding this to a `Set` or as a key in a `Map`, enabling - * lookup via a different instance. - * - * - * ```js - * const { List, Set } = require('immutable@4.0.0-rc.8'); - * const a = List([ 1, 2, 3 ]); - * const b = List([ 1, 2, 3 ]); - * assert.notStrictEqual(a, b); // different instances - * const set = Set([ a ]); - * assert.equal(set.has(b), true); - * ``` - * - * Note: hashCode() MUST return a Uint32 number. The easiest way to - * guarantee this is to return `myHash | 0` from a custom implementation. - * - * If two values have the same `hashCode`, they are [not guaranteed - * to be equal][Hash Collision]. If two values have different `hashCode`s, - * they must not be equal. - * - * Note: `hashCode()` is not guaranteed to always be called before - * `equals()`. Most but not all Immutable.js collections use hash codes to - * organize their internal data structures, while all Immutable.js - * collections use equality during lookups. - * - * [Hash Collision]: http://en.wikipedia.org/wiki/Collision_(computer_science) - */ - hashCode(): number; - } - - /** - * Lists are ordered indexed dense collections, much like a JavaScript - * Array. - * - * Lists are immutable and fully persistent with O(log32 N) gets and sets, - * and O(1) push and pop. - * - * Lists implement Deque, with efficient addition and removal from both the - * end (`push`, `pop`) and beginning (`unshift`, `shift`). - * - * Unlike a JavaScript Array, there is no distinction between an - * "unset" index and an index set to `undefined`. `List#forEach` visits all - * indices from 0 to size, regardless of whether they were explicitly defined. - */ - export module List { - - /** - * True if the provided value is a List - * - * - * ```js - * const { List } = require('immutable@4.0.0-rc.8'); - * List.isList([]); // false - * List.isList(List()); // true - * ``` - */ - function isList(maybeList: any): maybeList is List; - - /** - * Creates a new List containing `values`. - * - * - * ```js - * const { List } = require('immutable@4.0.0-rc.8'); - * List.of(1, 2, 3, 4) - * // List [ 1, 2, 3, 4 ] - * ``` - * - * Note: Values are not altered or converted in any way. - * - * - * ```js - * const { List } = require('immutable@4.0.0-rc.8'); - * List.of({x:1}, 2, [3], 4) - * // List [ { x: 1 }, 2, [ 3 ], 4 ] - * ``` - */ - function of(...values: Array): List; - } - - /** - * Create a new immutable List containing the values of the provided - * collection-like. - * - * - * ```js - * const { List, Set } = require('immutable@4.0.0-rc.8') - * - * const emptyList = List() - * // List [] - * - * const plainArray = [ 1, 2, 3, 4 ] - * const listFromPlainArray = List(plainArray) - * // List [ 1, 2, 3, 4 ] - * - * const plainSet = Set([ 1, 2, 3, 4 ]) - * const listFromPlainSet = List(plainSet) - * // List [ 1, 2, 3, 4 ] - * - * const arrayIterator = plainArray[Symbol.iterator]() - * const listFromCollectionArray = List(arrayIterator) - * // List [ 1, 2, 3, 4 ] - * - * listFromPlainArray.equals(listFromCollectionArray) // true - * listFromPlainSet.equals(listFromCollectionArray) // true - * listFromPlainSet.equals(listFromPlainArray) // true - * ``` - */ - export function List(): List; - export function List(): List; - export function List(collection: Iterable): List; - - export interface List extends Collection.Indexed { - - /** - * The number of items in this List. - */ - readonly size: number; - - // Persistent changes + // Persistent changes /** * Returns a new List which includes `value` at `index`. If `index` already @@ -4856,6 +4575,285 @@ isSuperset(iter: Iterable): boolean; } + /** + * The interface to fulfill to qualify as a Value Object. + */ + export interface ValueObject { + /** + * True if this and the other Collection have value equality, as defined + * by `Immutable.is()`. + * + * Note: This is equivalent to `Immutable.is(this, other)`, but provided to + * allow for chained expressions. + */ + equals(other: any): boolean; + + /** + * Computes and returns the hashed identity for this Collection. + * + * The `hashCode` of a Collection is used to determine potential equality, + * and is used when adding this to a `Set` or as a key in a `Map`, enabling + * lookup via a different instance. + * + * + * ```js + * const { List, Set } = require('immutable@4.0.0-rc.8'); + * const a = List([ 1, 2, 3 ]); + * const b = List([ 1, 2, 3 ]); + * assert.notStrictEqual(a, b); // different instances + * const set = Set([ a ]); + * assert.equal(set.has(b), true); + * ``` + * + * Note: hashCode() MUST return a Uint32 number. The easiest way to + * guarantee this is to return `myHash | 0` from a custom implementation. + * + * If two values have the same `hashCode`, they are [not guaranteed + * to be equal][Hash Collision]. If two values have different `hashCode`s, + * they must not be equal. + * + * Note: `hashCode()` is not guaranteed to always be called before + * `equals()`. Most but not all Immutable.js collections use hash codes to + * organize their internal data structures, while all Immutable.js + * collections use equality during lookups. + * + * [Hash Collision]: http://en.wikipedia.org/wiki/Collision_(computer_science) + */ + hashCode(): number; + } + + /** + * Deeply converts plain JS objects and arrays to Immutable Maps and Lists. + * + * If a `reviver` is optionally provided, it will be called with every + * collection as a Seq (beginning with the most nested collections + * and proceeding to the top-level collection itself), along with the key + * refering to each collection and the parent JS object provided as `this`. + * For the top level, object, the key will be `""`. This `reviver` is expected + * to return a new Immutable Collection, allowing for custom conversions from + * deep JS objects. Finally, a `path` is provided which is the sequence of + * keys to this value from the starting value. + * + * `reviver` acts similarly to the [same parameter in `JSON.parse`][1]. + * + * If `reviver` is not provided, the default behavior will convert Objects + * into Maps and Arrays into Lists like so: + * + * + * ```js + * const { fromJS, isKeyed } = require('immutable@4.0.0-rc.8') + * function (key, value) { + * return isKeyed(value) ? value.Map() : value.toList() + * } + * ``` + * + * `fromJS` is conservative in its conversion. It will only convert + * arrays which pass `Array.isArray` to Lists, and only raw objects (no custom + * prototype) to Map. + * + * Accordingly, this example converts native JS data to OrderedMap and List: + * + * + * ```js + * const { fromJS, isKeyed } = require('immutable@4.0.0-rc.8') + * fromJS({ a: {b: [10, 20, 30]}, c: 40}, function (key, value, path) { + * console.log(key, value, path) + * return isKeyed(value) ? value.toOrderedMap() : value.toList() + * }) + * + * > "b", [ 10, 20, 30 ], [ "a", "b" ] + * > "a", {b: [10, 20, 30]}, [ "a" ] + * > "", {a: {b: [10, 20, 30]}, c: 40}, [] + * ``` + * + * Keep in mind, when using JS objects to construct Immutable Maps, that + * JavaScript Object properties are always strings, even if written in a + * quote-less shorthand, while Immutable Maps accept keys of any type. + * + * + * ```js + * const { Map } = require('immutable@4.0.0-rc.8') + * let obj = { 1: "one" }; + * Object.keys(obj); // [ "1" ] + * assert.equal(obj["1"], obj[1]); // "one" === "one" + * + * let map = Map(obj); + * assert.notEqual(map.get("1"), map.get(1)); // "one" !== undefined + * ``` + * + * Property access for JavaScript Objects first converts the key to a string, + * but since Immutable Map keys can be of any type the argument to `get()` is + * not altered. + * + * [1]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse#Example.3A_Using_the_reviver_parameter + * "Using the reviver parameter" + */ + export function fromJS( + jsValue: any, + reviver?: ( + key: string | number, + sequence: Collection.Keyed | Collection.Indexed, + path?: Array + ) => any + ): any; + + /** + * Value equality check with semantics similar to `Object.is`, but treats + * Immutable `Collection`s as values, equal if the second `Collection` includes + * equivalent values. + * + * It's used throughout Immutable when checking for equality, including `Map` + * key equality and `Set` membership. + * + * + * ```js + * const { Map, is } = require('immutable@4.0.0-rc.8') + * const map1 = Map({ a: 1, b: 1, c: 1 }) + * const map2 = Map({ a: 1, b: 1, c: 1 }) + * assert.equal(map1 !== map2, true) + * assert.equal(Object.is(map1, map2), false) + * assert.equal(is(map1, map2), true) + * ``` + * + * `is()` compares primitive types like strings and numbers, Immutable.js + * collections like `Map` and `List`, but also any custom object which + * implements `ValueObject` by providing `equals()` and `hashCode()` methods. + * + * Note: Unlike `Object.is`, `Immutable.is` assumes `0` and `-0` are the same + * value, matching the behavior of ES6 Map key equality. + */ + export function is(first: any, second: any): boolean; + + /** + * The `hash()` function is an important part of how Immutable determines if + * two values are equivalent and is used to determine how to store those + * values. Provided with any value, `hash()` will return a 31-bit integer. + * + * When designing Objects which may be equal, it's important than when a + * `.equals()` method returns true, that both values `.hashCode()` method + * return the same value. `hash()` may be used to produce those values. + * + * For non-Immutable Objects that do not provide a `.hashCode()` functions + * (including plain Objects, plain Arrays, Date objects, etc), a unique hash + * value will be created for each *instance*. That is, the create hash + * represents referential equality, and not value equality for Objects. This + * ensures that if that Object is mutated over time that its hash code will + * remain consistent, allowing Objects to be used as keys and values in + * Immutable.js collections. + * + * Note that `hash()` attempts to balance between speed and avoiding + * collisions, however it makes no attempt to produce secure hashes. + * + * *New in Version 4.0* + */ + export function hash(value: any): number; + + /** + * True if `maybeImmutable` is an Immutable Collection or Record. + * + * Note: Still returns true even if the collections is within a `withMutations()`. + * + * + * ```js + * const { isImmutable, Map, List, Stack } = require('immutable@4.0.0-rc.8'); + * isImmutable([]); // false + * isImmutable({}); // false + * isImmutable(Map()); // true + * isImmutable(List()); // true + * isImmutable(Stack()); // true + * isImmutable(Map().asMutable()); // true + * ``` + */ + export function isImmutable(maybeImmutable: any): maybeImmutable is Collection; + + /** + * True if `maybeCollection` is a Collection, or any of its subclasses. + * + * + * ```js + * const { isCollection, Map, List, Stack } = require('immutable@4.0.0-rc.8'); + * isCollection([]); // false + * isCollection({}); // false + * isCollection(Map()); // true + * isCollection(List()); // true + * isCollection(Stack()); // true + * ``` + */ + export function isCollection(maybeCollection: any): maybeCollection is Collection; + + /** + * True if `maybeKeyed` is a Collection.Keyed, or any of its subclasses. + * + * + * ```js + * const { isKeyed, Map, List, Stack } = require('immutable@4.0.0-rc.8'); + * isKeyed([]); // false + * isKeyed({}); // false + * isKeyed(Map()); // true + * isKeyed(List()); // false + * isKeyed(Stack()); // false + * ``` + */ + export function isKeyed(maybeKeyed: any): maybeKeyed is Collection.Keyed; + + /** + * True if `maybeIndexed` is a Collection.Indexed, or any of its subclasses. + * + * + * ```js + * const { isIndexed, Map, List, Stack, Set } = require('immutable@4.0.0-rc.8'); + * isIndexed([]); // false + * isIndexed({}); // false + * isIndexed(Map()); // false + * isIndexed(List()); // true + * isIndexed(Stack()); // true + * isIndexed(Set()); // false + * ``` + */ + export function isIndexed(maybeIndexed: any): maybeIndexed is Collection.Indexed; + + /** + * True if `maybeAssociative` is either a Keyed or Indexed Collection. + * + * + * ```js + * const { isAssociative, Map, List, Stack, Set } = require('immutable@4.0.0-rc.8'); + * isAssociative([]); // false + * isAssociative({}); // false + * isAssociative(Map()); // true + * isAssociative(List()); // true + * isAssociative(Stack()); // true + * isAssociative(Set()); // false + * ``` + */ + export function isAssociative(maybeAssociative: any): maybeAssociative is Collection.Keyed | Collection.Indexed; + + /** + * True if `maybeOrdered` is a Collection where iteration order is well + * defined. True for Collection.Indexed as well as OrderedMap and OrderedSet. + * + * + * ```js + * const { isOrdered, Map, OrderedMap, List, Set } = require('immutable@4.0.0-rc.8'); + * isOrdered([]); // false + * isOrdered({}); // false + * isOrdered(Map()); // false + * isOrdered(OrderedMap()); // true + * isOrdered(List()); // true + * isOrdered(Set()); // false + * ``` + */ + export function isOrdered(maybeOrdered: any): boolean; + + /** + * True if `maybeValue` is a JavaScript Object which has *both* `equals()` + * and `hashCode()` methods. + * + * Any two instances of *value objects* can be compared for value equality with + * `Immutable.is()` and can be used as keys in a `Map` or members in a `Set`. + */ + export function isValueObject(maybeValue: any): maybeValue is ValueObject; + /** * Returns the value within the provided collection associated with the * provided key, or notSetValue if the key is not defined in the collection. diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index ae8f5052da..b82e13af67 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -100,376 +100,95 @@ declare module Immutable { /** - * Deeply converts plain JS objects and arrays to Immutable Maps and Lists. - * - * If a `reviver` is optionally provided, it will be called with every - * collection as a Seq (beginning with the most nested collections - * and proceeding to the top-level collection itself), along with the key - * refering to each collection and the parent JS object provided as `this`. - * For the top level, object, the key will be `""`. This `reviver` is expected - * to return a new Immutable Collection, allowing for custom conversions from - * deep JS objects. Finally, a `path` is provided which is the sequence of - * keys to this value from the starting value. - * - * `reviver` acts similarly to the [same parameter in `JSON.parse`][1]. - * - * If `reviver` is not provided, the default behavior will convert Objects - * into Maps and Arrays into Lists like so: - * - * - * ```js - * const { fromJS, isKeyed } = require('immutable@4.0.0-rc.8') - * function (key, value) { - * return isKeyed(value) ? value.Map() : value.toList() - * } - * ``` - * - * `fromJS` is conservative in its conversion. It will only convert - * arrays which pass `Array.isArray` to Lists, and only raw objects (no custom - * prototype) to Map. - * - * Accordingly, this example converts native JS data to OrderedMap and List: - * - * - * ```js - * const { fromJS, isKeyed } = require('immutable@4.0.0-rc.8') - * fromJS({ a: {b: [10, 20, 30]}, c: 40}, function (key, value, path) { - * console.log(key, value, path) - * return isKeyed(value) ? value.toOrderedMap() : value.toList() - * }) - * - * > "b", [ 10, 20, 30 ], [ "a", "b" ] - * > "a", {b: [10, 20, 30]}, [ "a" ] - * > "", {a: {b: [10, 20, 30]}, c: 40}, [] - * ``` - * - * Keep in mind, when using JS objects to construct Immutable Maps, that - * JavaScript Object properties are always strings, even if written in a - * quote-less shorthand, while Immutable Maps accept keys of any type. - * - * - * ```js - * const { Map } = require('immutable@4.0.0-rc.8') - * let obj = { 1: "one" }; - * Object.keys(obj); // [ "1" ] - * assert.equal(obj["1"], obj[1]); // "one" === "one" + * Lists are ordered indexed dense collections, much like a JavaScript + * Array. * - * let map = Map(obj); - * assert.notEqual(map.get("1"), map.get(1)); // "one" !== undefined - * ``` + * Lists are immutable and fully persistent with O(log32 N) gets and sets, + * and O(1) push and pop. * - * Property access for JavaScript Objects first converts the key to a string, - * but since Immutable Map keys can be of any type the argument to `get()` is - * not altered. + * Lists implement Deque, with efficient addition and removal from both the + * end (`push`, `pop`) and beginning (`unshift`, `shift`). * - * [1]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse#Example.3A_Using_the_reviver_parameter - * "Using the reviver parameter" + * Unlike a JavaScript Array, there is no distinction between an + * "unset" index and an index set to `undefined`. `List#forEach` visits all + * indices from 0 to size, regardless of whether they were explicitly defined. */ - export function fromJS( - jsValue: any, - reviver?: ( - key: string | number, - sequence: Collection.Keyed | Collection.Indexed, - path?: Array - ) => any - ): any; + export module List { + + /** + * True if the provided value is a List + * + * + * ```js + * const { List } = require('immutable@4.0.0-rc.8'); + * List.isList([]); // false + * List.isList(List()); // true + * ``` + */ + function isList(maybeList: any): maybeList is List; + /** + * Creates a new List containing `values`. + * + * + * ```js + * const { List } = require('immutable@4.0.0-rc.8'); + * List.of(1, 2, 3, 4) + * // List [ 1, 2, 3, 4 ] + * ``` + * + * Note: Values are not altered or converted in any way. + * + * + * ```js + * const { List } = require('immutable@4.0.0-rc.8'); + * List.of({x:1}, 2, [3], 4) + * // List [ { x: 1 }, 2, [ 3 ], 4 ] + * ``` + */ + function of(...values: Array): List; + } /** - * Value equality check with semantics similar to `Object.is`, but treats - * Immutable `Collection`s as values, equal if the second `Collection` includes - * equivalent values. - * - * It's used throughout Immutable when checking for equality, including `Map` - * key equality and `Set` membership. + * Create a new immutable List containing the values of the provided + * collection-like. * * * ```js - * const { Map, is } = require('immutable@4.0.0-rc.8') - * const map1 = Map({ a: 1, b: 1, c: 1 }) - * const map2 = Map({ a: 1, b: 1, c: 1 }) - * assert.equal(map1 !== map2, true) - * assert.equal(Object.is(map1, map2), false) - * assert.equal(is(map1, map2), true) - * ``` - * - * `is()` compares primitive types like strings and numbers, Immutable.js - * collections like `Map` and `List`, but also any custom object which - * implements `ValueObject` by providing `equals()` and `hashCode()` methods. - * - * Note: Unlike `Object.is`, `Immutable.is` assumes `0` and `-0` are the same - * value, matching the behavior of ES6 Map key equality. - */ - export function is(first: any, second: any): boolean; - - - /** - * The `hash()` function is an important part of how Immutable determines if - * two values are equivalent and is used to determine how to store those - * values. Provided with any value, `hash()` will return a 31-bit integer. - * - * When designing Objects which may be equal, it's important than when a - * `.equals()` method returns true, that both values `.hashCode()` method - * return the same value. `hash()` may be used to produce those values. - * - * For non-Immutable Objects that do not provide a `.hashCode()` functions - * (including plain Objects, plain Arrays, Date objects, etc), a unique hash - * value will be created for each *instance*. That is, the create hash - * represents referential equality, and not value equality for Objects. This - * ensures that if that Object is mutated over time that its hash code will - * remain consistent, allowing Objects to be used as keys and values in - * Immutable.js collections. + * const { List, Set } = require('immutable@4.0.0-rc.8') * - * Note that `hash()` attempts to balance between speed and avoiding - * collisions, however it makes no attempt to produce secure hashes. + * const emptyList = List() + * // List [] * - * *New in Version 4.0* - */ - export function hash(value: any): number; - - /** - * True if `maybeImmutable` is an Immutable Collection or Record. + * const plainArray = [ 1, 2, 3, 4 ] + * const listFromPlainArray = List(plainArray) + * // List [ 1, 2, 3, 4 ] * - * Note: Still returns true even if the collections is within a `withMutations()`. + * const plainSet = Set([ 1, 2, 3, 4 ]) + * const listFromPlainSet = List(plainSet) + * // List [ 1, 2, 3, 4 ] * - * - * ```js - * const { isImmutable, Map, List, Stack } = require('immutable@4.0.0-rc.8'); - * isImmutable([]); // false - * isImmutable({}); // false - * isImmutable(Map()); // true - * isImmutable(List()); // true - * isImmutable(Stack()); // true - * isImmutable(Map().asMutable()); // true - * ``` - */ - export function isImmutable(maybeImmutable: any): maybeImmutable is Collection; - - /** - * True if `maybeCollection` is a Collection, or any of its subclasses. + * const arrayIterator = plainArray[Symbol.iterator]() + * const listFromCollectionArray = List(arrayIterator) + * // List [ 1, 2, 3, 4 ] * - * - * ```js - * const { isCollection, Map, List, Stack } = require('immutable@4.0.0-rc.8'); - * isCollection([]); // false - * isCollection({}); // false - * isCollection(Map()); // true - * isCollection(List()); // true - * isCollection(Stack()); // true + * listFromPlainArray.equals(listFromCollectionArray) // true + * listFromPlainSet.equals(listFromCollectionArray) // true + * listFromPlainSet.equals(listFromPlainArray) // true * ``` */ - export function isCollection(maybeCollection: any): maybeCollection is Collection; + export function List(): List; + export function List(): List; + export function List(collection: Iterable): List; - /** - * True if `maybeKeyed` is a Collection.Keyed, or any of its subclasses. - * - * - * ```js - * const { isKeyed, Map, List, Stack } = require('immutable@4.0.0-rc.8'); - * isKeyed([]); // false - * isKeyed({}); // false - * isKeyed(Map()); // true - * isKeyed(List()); // false - * isKeyed(Stack()); // false - * ``` - */ - export function isKeyed(maybeKeyed: any): maybeKeyed is Collection.Keyed; + export interface List extends Collection.Indexed { - /** - * True if `maybeIndexed` is a Collection.Indexed, or any of its subclasses. - * - * - * ```js - * const { isIndexed, Map, List, Stack, Set } = require('immutable@4.0.0-rc.8'); - * isIndexed([]); // false - * isIndexed({}); // false - * isIndexed(Map()); // false - * isIndexed(List()); // true - * isIndexed(Stack()); // true - * isIndexed(Set()); // false - * ``` - */ - export function isIndexed(maybeIndexed: any): maybeIndexed is Collection.Indexed; + /** + * The number of items in this List. + */ + readonly size: number; - /** - * True if `maybeAssociative` is either a Keyed or Indexed Collection. - * - * - * ```js - * const { isAssociative, Map, List, Stack, Set } = require('immutable@4.0.0-rc.8'); - * isAssociative([]); // false - * isAssociative({}); // false - * isAssociative(Map()); // true - * isAssociative(List()); // true - * isAssociative(Stack()); // true - * isAssociative(Set()); // false - * ``` - */ - export function isAssociative(maybeAssociative: any): maybeAssociative is Collection.Keyed | Collection.Indexed; - - /** - * True if `maybeOrdered` is a Collection where iteration order is well - * defined. True for Collection.Indexed as well as OrderedMap and OrderedSet. - * - * - * ```js - * const { isOrdered, Map, OrderedMap, List, Set } = require('immutable@4.0.0-rc.8'); - * isOrdered([]); // false - * isOrdered({}); // false - * isOrdered(Map()); // false - * isOrdered(OrderedMap()); // true - * isOrdered(List()); // true - * isOrdered(Set()); // false - * ``` - */ - export function isOrdered(maybeOrdered: any): boolean; - - /** - * True if `maybeValue` is a JavaScript Object which has *both* `equals()` - * and `hashCode()` methods. - * - * Any two instances of *value objects* can be compared for value equality with - * `Immutable.is()` and can be used as keys in a `Map` or members in a `Set`. - */ - export function isValueObject(maybeValue: any): maybeValue is ValueObject; - - /** - * The interface to fulfill to qualify as a Value Object. - */ - export interface ValueObject { - /** - * True if this and the other Collection have value equality, as defined - * by `Immutable.is()`. - * - * Note: This is equivalent to `Immutable.is(this, other)`, but provided to - * allow for chained expressions. - */ - equals(other: any): boolean; - - /** - * Computes and returns the hashed identity for this Collection. - * - * The `hashCode` of a Collection is used to determine potential equality, - * and is used when adding this to a `Set` or as a key in a `Map`, enabling - * lookup via a different instance. - * - * - * ```js - * const { List, Set } = require('immutable@4.0.0-rc.8'); - * const a = List([ 1, 2, 3 ]); - * const b = List([ 1, 2, 3 ]); - * assert.notStrictEqual(a, b); // different instances - * const set = Set([ a ]); - * assert.equal(set.has(b), true); - * ``` - * - * Note: hashCode() MUST return a Uint32 number. The easiest way to - * guarantee this is to return `myHash | 0` from a custom implementation. - * - * If two values have the same `hashCode`, they are [not guaranteed - * to be equal][Hash Collision]. If two values have different `hashCode`s, - * they must not be equal. - * - * Note: `hashCode()` is not guaranteed to always be called before - * `equals()`. Most but not all Immutable.js collections use hash codes to - * organize their internal data structures, while all Immutable.js - * collections use equality during lookups. - * - * [Hash Collision]: http://en.wikipedia.org/wiki/Collision_(computer_science) - */ - hashCode(): number; - } - - /** - * Lists are ordered indexed dense collections, much like a JavaScript - * Array. - * - * Lists are immutable and fully persistent with O(log32 N) gets and sets, - * and O(1) push and pop. - * - * Lists implement Deque, with efficient addition and removal from both the - * end (`push`, `pop`) and beginning (`unshift`, `shift`). - * - * Unlike a JavaScript Array, there is no distinction between an - * "unset" index and an index set to `undefined`. `List#forEach` visits all - * indices from 0 to size, regardless of whether they were explicitly defined. - */ - export module List { - - /** - * True if the provided value is a List - * - * - * ```js - * const { List } = require('immutable@4.0.0-rc.8'); - * List.isList([]); // false - * List.isList(List()); // true - * ``` - */ - function isList(maybeList: any): maybeList is List; - - /** - * Creates a new List containing `values`. - * - * - * ```js - * const { List } = require('immutable@4.0.0-rc.8'); - * List.of(1, 2, 3, 4) - * // List [ 1, 2, 3, 4 ] - * ``` - * - * Note: Values are not altered or converted in any way. - * - * - * ```js - * const { List } = require('immutable@4.0.0-rc.8'); - * List.of({x:1}, 2, [3], 4) - * // List [ { x: 1 }, 2, [ 3 ], 4 ] - * ``` - */ - function of(...values: Array): List; - } - - /** - * Create a new immutable List containing the values of the provided - * collection-like. - * - * - * ```js - * const { List, Set } = require('immutable@4.0.0-rc.8') - * - * const emptyList = List() - * // List [] - * - * const plainArray = [ 1, 2, 3, 4 ] - * const listFromPlainArray = List(plainArray) - * // List [ 1, 2, 3, 4 ] - * - * const plainSet = Set([ 1, 2, 3, 4 ]) - * const listFromPlainSet = List(plainSet) - * // List [ 1, 2, 3, 4 ] - * - * const arrayIterator = plainArray[Symbol.iterator]() - * const listFromCollectionArray = List(arrayIterator) - * // List [ 1, 2, 3, 4 ] - * - * listFromPlainArray.equals(listFromCollectionArray) // true - * listFromPlainSet.equals(listFromCollectionArray) // true - * listFromPlainSet.equals(listFromPlainArray) // true - * ``` - */ - export function List(): List; - export function List(): List; - export function List(collection: Iterable): List; - - export interface List extends Collection.Indexed { - - /** - * The number of items in this List. - */ - readonly size: number; - - // Persistent changes + // Persistent changes /** * Returns a new List which includes `value` at `index`. If `index` already @@ -4856,6 +4575,285 @@ declare module Immutable { isSuperset(iter: Iterable): boolean; } + /** + * The interface to fulfill to qualify as a Value Object. + */ + export interface ValueObject { + /** + * True if this and the other Collection have value equality, as defined + * by `Immutable.is()`. + * + * Note: This is equivalent to `Immutable.is(this, other)`, but provided to + * allow for chained expressions. + */ + equals(other: any): boolean; + + /** + * Computes and returns the hashed identity for this Collection. + * + * The `hashCode` of a Collection is used to determine potential equality, + * and is used when adding this to a `Set` or as a key in a `Map`, enabling + * lookup via a different instance. + * + * + * ```js + * const { List, Set } = require('immutable@4.0.0-rc.8'); + * const a = List([ 1, 2, 3 ]); + * const b = List([ 1, 2, 3 ]); + * assert.notStrictEqual(a, b); // different instances + * const set = Set([ a ]); + * assert.equal(set.has(b), true); + * ``` + * + * Note: hashCode() MUST return a Uint32 number. The easiest way to + * guarantee this is to return `myHash | 0` from a custom implementation. + * + * If two values have the same `hashCode`, they are [not guaranteed + * to be equal][Hash Collision]. If two values have different `hashCode`s, + * they must not be equal. + * + * Note: `hashCode()` is not guaranteed to always be called before + * `equals()`. Most but not all Immutable.js collections use hash codes to + * organize their internal data structures, while all Immutable.js + * collections use equality during lookups. + * + * [Hash Collision]: http://en.wikipedia.org/wiki/Collision_(computer_science) + */ + hashCode(): number; + } + + /** + * Deeply converts plain JS objects and arrays to Immutable Maps and Lists. + * + * If a `reviver` is optionally provided, it will be called with every + * collection as a Seq (beginning with the most nested collections + * and proceeding to the top-level collection itself), along with the key + * refering to each collection and the parent JS object provided as `this`. + * For the top level, object, the key will be `""`. This `reviver` is expected + * to return a new Immutable Collection, allowing for custom conversions from + * deep JS objects. Finally, a `path` is provided which is the sequence of + * keys to this value from the starting value. + * + * `reviver` acts similarly to the [same parameter in `JSON.parse`][1]. + * + * If `reviver` is not provided, the default behavior will convert Objects + * into Maps and Arrays into Lists like so: + * + * + * ```js + * const { fromJS, isKeyed } = require('immutable@4.0.0-rc.8') + * function (key, value) { + * return isKeyed(value) ? value.Map() : value.toList() + * } + * ``` + * + * `fromJS` is conservative in its conversion. It will only convert + * arrays which pass `Array.isArray` to Lists, and only raw objects (no custom + * prototype) to Map. + * + * Accordingly, this example converts native JS data to OrderedMap and List: + * + * + * ```js + * const { fromJS, isKeyed } = require('immutable@4.0.0-rc.8') + * fromJS({ a: {b: [10, 20, 30]}, c: 40}, function (key, value, path) { + * console.log(key, value, path) + * return isKeyed(value) ? value.toOrderedMap() : value.toList() + * }) + * + * > "b", [ 10, 20, 30 ], [ "a", "b" ] + * > "a", {b: [10, 20, 30]}, [ "a" ] + * > "", {a: {b: [10, 20, 30]}, c: 40}, [] + * ``` + * + * Keep in mind, when using JS objects to construct Immutable Maps, that + * JavaScript Object properties are always strings, even if written in a + * quote-less shorthand, while Immutable Maps accept keys of any type. + * + * + * ```js + * const { Map } = require('immutable@4.0.0-rc.8') + * let obj = { 1: "one" }; + * Object.keys(obj); // [ "1" ] + * assert.equal(obj["1"], obj[1]); // "one" === "one" + * + * let map = Map(obj); + * assert.notEqual(map.get("1"), map.get(1)); // "one" !== undefined + * ``` + * + * Property access for JavaScript Objects first converts the key to a string, + * but since Immutable Map keys can be of any type the argument to `get()` is + * not altered. + * + * [1]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse#Example.3A_Using_the_reviver_parameter + * "Using the reviver parameter" + */ + export function fromJS( + jsValue: any, + reviver?: ( + key: string | number, + sequence: Collection.Keyed | Collection.Indexed, + path?: Array + ) => any + ): any; + + /** + * Value equality check with semantics similar to `Object.is`, but treats + * Immutable `Collection`s as values, equal if the second `Collection` includes + * equivalent values. + * + * It's used throughout Immutable when checking for equality, including `Map` + * key equality and `Set` membership. + * + * + * ```js + * const { Map, is } = require('immutable@4.0.0-rc.8') + * const map1 = Map({ a: 1, b: 1, c: 1 }) + * const map2 = Map({ a: 1, b: 1, c: 1 }) + * assert.equal(map1 !== map2, true) + * assert.equal(Object.is(map1, map2), false) + * assert.equal(is(map1, map2), true) + * ``` + * + * `is()` compares primitive types like strings and numbers, Immutable.js + * collections like `Map` and `List`, but also any custom object which + * implements `ValueObject` by providing `equals()` and `hashCode()` methods. + * + * Note: Unlike `Object.is`, `Immutable.is` assumes `0` and `-0` are the same + * value, matching the behavior of ES6 Map key equality. + */ + export function is(first: any, second: any): boolean; + + /** + * The `hash()` function is an important part of how Immutable determines if + * two values are equivalent and is used to determine how to store those + * values. Provided with any value, `hash()` will return a 31-bit integer. + * + * When designing Objects which may be equal, it's important than when a + * `.equals()` method returns true, that both values `.hashCode()` method + * return the same value. `hash()` may be used to produce those values. + * + * For non-Immutable Objects that do not provide a `.hashCode()` functions + * (including plain Objects, plain Arrays, Date objects, etc), a unique hash + * value will be created for each *instance*. That is, the create hash + * represents referential equality, and not value equality for Objects. This + * ensures that if that Object is mutated over time that its hash code will + * remain consistent, allowing Objects to be used as keys and values in + * Immutable.js collections. + * + * Note that `hash()` attempts to balance between speed and avoiding + * collisions, however it makes no attempt to produce secure hashes. + * + * *New in Version 4.0* + */ + export function hash(value: any): number; + + /** + * True if `maybeImmutable` is an Immutable Collection or Record. + * + * Note: Still returns true even if the collections is within a `withMutations()`. + * + * + * ```js + * const { isImmutable, Map, List, Stack } = require('immutable@4.0.0-rc.8'); + * isImmutable([]); // false + * isImmutable({}); // false + * isImmutable(Map()); // true + * isImmutable(List()); // true + * isImmutable(Stack()); // true + * isImmutable(Map().asMutable()); // true + * ``` + */ + export function isImmutable(maybeImmutable: any): maybeImmutable is Collection; + + /** + * True if `maybeCollection` is a Collection, or any of its subclasses. + * + * + * ```js + * const { isCollection, Map, List, Stack } = require('immutable@4.0.0-rc.8'); + * isCollection([]); // false + * isCollection({}); // false + * isCollection(Map()); // true + * isCollection(List()); // true + * isCollection(Stack()); // true + * ``` + */ + export function isCollection(maybeCollection: any): maybeCollection is Collection; + + /** + * True if `maybeKeyed` is a Collection.Keyed, or any of its subclasses. + * + * + * ```js + * const { isKeyed, Map, List, Stack } = require('immutable@4.0.0-rc.8'); + * isKeyed([]); // false + * isKeyed({}); // false + * isKeyed(Map()); // true + * isKeyed(List()); // false + * isKeyed(Stack()); // false + * ``` + */ + export function isKeyed(maybeKeyed: any): maybeKeyed is Collection.Keyed; + + /** + * True if `maybeIndexed` is a Collection.Indexed, or any of its subclasses. + * + * + * ```js + * const { isIndexed, Map, List, Stack, Set } = require('immutable@4.0.0-rc.8'); + * isIndexed([]); // false + * isIndexed({}); // false + * isIndexed(Map()); // false + * isIndexed(List()); // true + * isIndexed(Stack()); // true + * isIndexed(Set()); // false + * ``` + */ + export function isIndexed(maybeIndexed: any): maybeIndexed is Collection.Indexed; + + /** + * True if `maybeAssociative` is either a Keyed or Indexed Collection. + * + * + * ```js + * const { isAssociative, Map, List, Stack, Set } = require('immutable@4.0.0-rc.8'); + * isAssociative([]); // false + * isAssociative({}); // false + * isAssociative(Map()); // true + * isAssociative(List()); // true + * isAssociative(Stack()); // true + * isAssociative(Set()); // false + * ``` + */ + export function isAssociative(maybeAssociative: any): maybeAssociative is Collection.Keyed | Collection.Indexed; + + /** + * True if `maybeOrdered` is a Collection where iteration order is well + * defined. True for Collection.Indexed as well as OrderedMap and OrderedSet. + * + * + * ```js + * const { isOrdered, Map, OrderedMap, List, Set } = require('immutable@4.0.0-rc.8'); + * isOrdered([]); // false + * isOrdered({}); // false + * isOrdered(Map()); // false + * isOrdered(OrderedMap()); // true + * isOrdered(List()); // true + * isOrdered(Set()); // false + * ``` + */ + export function isOrdered(maybeOrdered: any): boolean; + + /** + * True if `maybeValue` is a JavaScript Object which has *both* `equals()` + * and `hashCode()` methods. + * + * Any two instances of *value objects* can be compared for value equality with + * `Immutable.is()` and can be used as keys in a `Map` or members in a `Set`. + */ + export function isValueObject(maybeValue: any): maybeValue is ValueObject; + /** * Returns the value within the provided collection associated with the * provided key, or notSetValue if the key is not defined in the collection. From c9a3002bc50363f526947c06ce51c28224c000e2 Mon Sep 17 00:00:00 2001 From: Travis CI Date: Tue, 17 Oct 2017 21:32:27 +0000 Subject: [PATCH 074/242] Deploy a7b2b8caa529458d2fcab8ae90c3163d8836e12b to NPM branch --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b778d826fe..7492a177da 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ map1.get('b') + " vs. " + map2.get('b') // 2 vs. 50 ### Browser -Immutable.js has no depenencnies, which makes it predictable to include in a Browser. +Immutable.js has no dependencies, which makes it predictable to include in a Browser. It's highly recommended to use a module bundler like [webpack](https://webpack.github.io/), [rollup](https://rollupjs.org/), or From 5d7daa95eae338fbcd3018c05bb3a0fba997a32b Mon Sep 17 00:00:00 2001 From: Travis CI Date: Tue, 17 Oct 2017 21:47:30 +0000 Subject: [PATCH 075/242] Deploy 41feaa661a69e382a9ce6e029c26d0c53e720e9b to NPM branch --- dist/immutable-nonambient.d.ts | 16 ++++++++-------- dist/immutable.d.ts | 16 ++++++++-------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/dist/immutable-nonambient.d.ts b/dist/immutable-nonambient.d.ts index 8254dfe8e3..bb9455899e 100644 --- a/dist/immutable-nonambient.d.ts +++ b/dist/immutable-nonambient.d.ts @@ -4894,7 +4894,7 @@ * has({ x: 123, y: 456 }, 'z') // false * ``` */ - export function has(collection: Object, key: mixed): boolean; + export function has(collection: Object, key: any): boolean; /** * Returns a copy of the collection with the value at key removed. @@ -4915,10 +4915,10 @@ * ``` */ export function remove>(collection: C, key: K): C; - export function remove, K extends keyof TProps>(collection: C, key: K): C; + export function remove, K extends keyof TProps>(collection: C, key: K): C; export function remove>(collection: C, key: number): C; - export function remove(collection: C, key: K): C; - export function remove(collection: C, key: K): C; + export function remove(collection: C, key: K): C; + export function remove(collection: C, key: K): C; /** * Returns a copy of the collection with the value at key set to the provided @@ -4969,11 +4969,11 @@ export function update, K extends keyof TProps>(record: C, key: K, updater: (value: TProps[K]) => TProps[K]): C; export function update, K extends keyof TProps, NSV>(record: C, key: K, notSetValue: NSV, updater: (value: TProps[K] | NSV) => TProps[K]): C; export function update(collection: Array, key: number, updater: (value: V) => V): Array; - export function update(collection: Array, key: number, notSetValue: NSV, updater: (value: V | NSV) => V): C; + export function update(collection: Array, key: number, notSetValue: NSV, updater: (value: V | NSV) => V): Array; export function update(object: C, key: K, updater: (value: C[K]) => C[K]): C; export function update(object: C, key: K, notSetValue: NSV, updater: (value: C[K] | NSV) => C[K]): C; - export function update(collection: C, key: K, updater: (value: V) => V): {[key: string]: V}; - export function update(collection: C, key: K, notSetValue: NSV, updater: (value: V | NSV) => V): {[key: string]: V}; + export function update(collection: C, key: K, updater: (value: V) => V): {[key: string]: V}; + export function update(collection: C, key: K, notSetValue: NSV, updater: (value: V | NSV) => V): {[key: string]: V}; /** * Returns the value at the provided key path starting at the provided @@ -5142,7 +5142,7 @@ * ``` */ export function mergeDeepWith( - merger: (oldVal: any, newVal: any, key: any) => mixed, + merger: (oldVal: any, newVal: any, key: any) => any, collection: C, ...collections: Array | Iterable<[any, any]> | {[key: string]: any}> ): C; diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index b82e13af67..2a5ffdee05 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -4894,7 +4894,7 @@ declare module Immutable { * has({ x: 123, y: 456 }, 'z') // false * ``` */ - export function has(collection: Object, key: mixed): boolean; + export function has(collection: Object, key: any): boolean; /** * Returns a copy of the collection with the value at key removed. @@ -4915,10 +4915,10 @@ declare module Immutable { * ``` */ export function remove>(collection: C, key: K): C; - export function remove, K extends keyof TProps>(collection: C, key: K): C; + export function remove, K extends keyof TProps>(collection: C, key: K): C; export function remove>(collection: C, key: number): C; - export function remove(collection: C, key: K): C; - export function remove(collection: C, key: K): C; + export function remove(collection: C, key: K): C; + export function remove(collection: C, key: K): C; /** * Returns a copy of the collection with the value at key set to the provided @@ -4969,11 +4969,11 @@ declare module Immutable { export function update, K extends keyof TProps>(record: C, key: K, updater: (value: TProps[K]) => TProps[K]): C; export function update, K extends keyof TProps, NSV>(record: C, key: K, notSetValue: NSV, updater: (value: TProps[K] | NSV) => TProps[K]): C; export function update(collection: Array, key: number, updater: (value: V) => V): Array; - export function update(collection: Array, key: number, notSetValue: NSV, updater: (value: V | NSV) => V): C; + export function update(collection: Array, key: number, notSetValue: NSV, updater: (value: V | NSV) => V): Array; export function update(object: C, key: K, updater: (value: C[K]) => C[K]): C; export function update(object: C, key: K, notSetValue: NSV, updater: (value: C[K] | NSV) => C[K]): C; - export function update(collection: C, key: K, updater: (value: V) => V): {[key: string]: V}; - export function update(collection: C, key: K, notSetValue: NSV, updater: (value: V | NSV) => V): {[key: string]: V}; + export function update(collection: C, key: K, updater: (value: V) => V): {[key: string]: V}; + export function update(collection: C, key: K, notSetValue: NSV, updater: (value: V | NSV) => V): {[key: string]: V}; /** * Returns the value at the provided key path starting at the provided @@ -5142,7 +5142,7 @@ declare module Immutable { * ``` */ export function mergeDeepWith( - merger: (oldVal: any, newVal: any, key: any) => mixed, + merger: (oldVal: any, newVal: any, key: any) => any, collection: C, ...collections: Array | Iterable<[any, any]> | {[key: string]: any}> ): C; From 3da44c4dec5392bd6965edffccbfe561efa3c830 Mon Sep 17 00:00:00 2001 From: Travis CI Date: Wed, 18 Oct 2017 01:58:38 +0000 Subject: [PATCH 076/242] Deploy 2ca04cb0a3f11fd60d77916e36959086f5aebb78 to NPM branch --- dist/immutable.js.flow | 54 +++++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/dist/immutable.js.flow b/dist/immutable.js.flow index 49956190f9..ba58923fc4 100644 --- a/dist/immutable.js.flow +++ b/dist/immutable.js.flow @@ -1397,10 +1397,10 @@ declare class RecordInstance { getIn(keyPath: [], notSetValue?: mixed): this & T; getIn>(keyPath: [K], notSetValue?: mixed): $ElementType; - getIn, K2: $KeyOf<$ElementType>>(keyPath: [K, K2], notSetValue: NSV): $ValOf<$ElementType, K2> | NSV; - getIn, K2: $KeyOf<$ElementType>, K3: $KeyOf<$ValOf<$ElementType, K2>>>(keyPath: [K, K2, K3], notSetValue: NSV): $ValOf<$ValOf<$ElementType, K2>, K3> | NSV; - getIn, K2: $KeyOf<$ElementType>, K3: $KeyOf<$ValOf<$ElementType, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ElementType, K2>, K3>>>(keyPath: [K, K2, K3, K4], notSetValue: NSV): $ValOf<$ValOf<$ValOf<$ElementType, K2>, K3>, K4> | NSV; - getIn, K2: $KeyOf<$ElementType>, K3: $KeyOf<$ValOf<$ElementType, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ElementType, K2>, K3>>, K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ElementType, K2>, K3>, K4>>>(keyPath: [K, K2, K3, K4, K5], notSetValue: NSV): $ValOf<$ValOf<$ValOf<$ValOf<$ElementType, K2>, K3>, K4>, K5> | NSV; + getIn, K2: $KeyOf<$ValOf>>(keyPath: [K, K2], notSetValue: NSV): $ValOf<$ValOf, K2> | NSV; + getIn, K2: $KeyOf<$ValOf>, K3: $KeyOf<$ValOf<$ValOf, K2>>>(keyPath: [K, K2, K3], notSetValue: NSV): $ValOf<$ValOf<$ValOf, K2>, K3> | NSV; + getIn, K2: $KeyOf<$ValOf>, K3: $KeyOf<$ValOf<$ValOf, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>>>(keyPath: [K, K2, K3, K4], notSetValue: NSV): $ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4> | NSV; + getIn, K2: $KeyOf<$ValOf>, K3: $KeyOf<$ValOf<$ValOf, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>>, K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>>>(keyPath: [K, K2, K3, K4, K5], notSetValue: NSV): $ValOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>, K5> | NSV; equals(other: any): boolean; hashCode(): number; @@ -1424,38 +1424,38 @@ declare class RecordInstance { clear(): this & T; setIn(keyPath: [], value: S): S; - setIn, S: $ElementType>(keyPath: [K], value: S): this & T; - setIn, K2: $KeyOf<$ElementType>, S: $ValOf<$ElementType, K2>>(keyPath: [K, K2], value: S): this & T; - setIn, K2: $KeyOf<$ElementType>, K3: $KeyOf<$ValOf<$ElementType, K2>>, S: $ValOf<$ValOf<$ElementType, K2>, K3>>(keyPath: [K, K2, K3], value: S): this & T; - setIn, K2: $KeyOf<$ElementType>, K3: $KeyOf<$ValOf<$ElementType, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ElementType, K2>, K3>>, S: $ValOf<$ValOf<$ValOf<$ElementType, K2>, K3>, K4>>(keyPath: [K, K2, K3, K4], value: S): this & T; - setIn, K2: $KeyOf<$ElementType>, K3: $KeyOf<$ValOf<$ElementType, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ElementType, K2>, K3>>, K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ElementType, K2>, K3>, K4>>, S: $ValOf<$ValOf<$ValOf<$ValOf<$ElementType, K2>, K3>, K4>, K5>>(keyPath: [K, K2, K3, K4, K5], value: S): this & T; + setIn, S: $ValOf>(keyPath: [K], value: S): this & T; + setIn, K2: $KeyOf<$ValOf>, S: $ValOf<$ValOf, K2>>(keyPath: [K, K2], value: S): this & T; + setIn, K2: $KeyOf<$ValOf>, K3: $KeyOf<$ValOf<$ValOf, K2>>, S: $ValOf<$ValOf<$ValOf, K2>, K3>>(keyPath: [K, K2, K3], value: S): this & T; + setIn, K2: $KeyOf<$ValOf>, K3: $KeyOf<$ValOf<$ValOf, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>>, S: $ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>>(keyPath: [K, K2, K3, K4], value: S): this & T; + setIn, K2: $KeyOf<$ValOf>, K3: $KeyOf<$ValOf<$ValOf, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>>, K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>>, S: $ValOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>, K5>>(keyPath: [K, K2, K3, K4, K5], value: S): this & T; deleteIn(keyPath: []): void; deleteIn>(keyPath: [K]): this & T; - deleteIn, K2: $KeyOf<$ElementType>>(keyPath: [K, K2]): this & T; - deleteIn, K2: $KeyOf<$ElementType>, K3: $KeyOf<$ValOf<$ElementType, K2>>>(keyPath: [K, K2, K3]): this & T; - deleteIn, K2: $KeyOf<$ElementType>, K3: $KeyOf<$ValOf<$ElementType, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ElementType, K2>, K3>>>(keyPath: [K, K2, K3, K4]): this & T; - deleteIn, K2: $KeyOf<$ElementType>, K3: $KeyOf<$ValOf<$ElementType, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ElementType, K2>, K3>>, K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ElementType, K2>, K3>, K4>>>(keyPath: [K, K2, K3, K4, K5]): this & T; + deleteIn, K2: $KeyOf<$ValOf>>(keyPath: [K, K2]): this & T; + deleteIn, K2: $KeyOf<$ValOf>, K3: $KeyOf<$ValOf<$ValOf, K2>>>(keyPath: [K, K2, K3]): this & T; + deleteIn, K2: $KeyOf<$ValOf>, K3: $KeyOf<$ValOf<$ValOf, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>>>(keyPath: [K, K2, K3, K4]): this & T; + deleteIn, K2: $KeyOf<$ValOf>, K3: $KeyOf<$ValOf<$ValOf, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>>, K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>>>(keyPath: [K, K2, K3, K4, K5]): this & T; removeIn(keyPath: []): void; removeIn>(keyPath: [K]): this & T; - removeIn, K2: $KeyOf<$ElementType>>(keyPath: [K, K2]): this & T; - removeIn, K2: $KeyOf<$ElementType>, K3: $KeyOf<$ValOf<$ElementType, K2>>>(keyPath: [K, K2, K3]): this & T; - removeIn, K2: $KeyOf<$ElementType>, K3: $KeyOf<$ValOf<$ElementType, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ElementType, K2>, K3>>>(keyPath: [K, K2, K3, K4]): this & T; - removeIn, K2: $KeyOf<$ElementType>, K3: $KeyOf<$ValOf<$ElementType, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ElementType, K2>, K3>>, K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ElementType, K2>, K3>, K4>>>(keyPath: [K, K2, K3, K4, K5]): this & T; + removeIn, K2: $KeyOf<$ValOf>>(keyPath: [K, K2]): this & T; + removeIn, K2: $KeyOf<$ValOf>, K3: $KeyOf<$ValOf<$ValOf, K2>>>(keyPath: [K, K2, K3]): this & T; + removeIn, K2: $KeyOf<$ValOf>, K3: $KeyOf<$ValOf<$ValOf, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>>>(keyPath: [K, K2, K3, K4]): this & T; + removeIn, K2: $KeyOf<$ValOf>, K3: $KeyOf<$ValOf<$ValOf, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>>, K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>>>(keyPath: [K, K2, K3, K4, K5]): this & T; updateIn(keyPath: [], notSetValue: mixed, updater: (value: this) => U): U; updateIn(keyPath: [], updater: (value: this) => U): U; - updateIn, S: $ElementType>(keyPath: [K], notSetValue: NSV, updater: (value: $ElementType) => S): this & T; - updateIn, S: $ElementType>(keyPath: [K], updater: (value: $ElementType) => S): this & T; - updateIn, K2: $KeyOf<$ElementType>, S: $ValOf<$ElementType, K2>>(keyPath: [K, K2], notSetValue: NSV, updater: (value: $ValOf<$ElementType, K2> | NSV) => S): this & T; - updateIn, K2: $KeyOf<$ElementType>, S: $ValOf<$ElementType, K2>>(keyPath: [K, K2], updater: (value: $ValOf<$ElementType, K2>) => S): this & T; - updateIn, K2: $KeyOf<$ElementType>, K3: $KeyOf<$ValOf<$ElementType, K2>>, S: $ValOf<$ValOf<$ElementType, K2>, K3>>(keyPath: [K, K2, K3], notSetValue: NSV, updater: (value: $ValOf<$ValOf<$ElementType, K2>, K3> | NSV) => S): this & T; - updateIn, K2: $KeyOf<$ElementType>, K3: $KeyOf<$ValOf<$ElementType, K2>>, S: $ValOf<$ValOf<$ElementType, K2>, K3>>(keyPath: [K, K2, K3], updater: (value: $ValOf<$ValOf<$ElementType, K2>, K3>) => S): this & T; - updateIn, K2: $KeyOf<$ElementType>, K3: $KeyOf<$ValOf<$ElementType, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ElementType, K2>, K3>>, S: $ValOf<$ValOf<$ValOf<$ElementType, K2>, K3>, K4>>(keyPath: [K, K2, K3, K4], notSetValue: NSV, updater: (value: $ValOf<$ValOf<$ValOf<$ElementType, K2>, K3>, K4> | NSV) => S): this & T; - updateIn, K2: $KeyOf<$ElementType>, K3: $KeyOf<$ValOf<$ElementType, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ElementType, K2>, K3>>, S: $ValOf<$ValOf<$ValOf<$ElementType, K2>, K3>, K4>>(keyPath: [K, K2, K3, K4], updater: (value: $ValOf<$ValOf<$ValOf<$ElementType, K2>, K3>, K4>) => S): this & T; - updateIn, K2: $KeyOf<$ElementType>, K3: $KeyOf<$ValOf<$ElementType, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ElementType, K2>, K3>>, K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ElementType, K2>, K3>, K4>>, S: $ValOf<$ValOf<$ValOf<$ValOf<$ElementType, K2>, K3>, K4>, K5>>(keyPath: [K, K2, K3, K4, K5], notSetValue: NSV, updater: (value: $ValOf<$ValOf<$ValOf<$ValOf<$ElementType, K2>, K3>, K4>, K5> | NSV) => S): this & T; - updateIn, K2: $KeyOf<$ElementType>, K3: $KeyOf<$ValOf<$ElementType, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ElementType, K2>, K3>>, K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ElementType, K2>, K3>, K4>>, S: $ValOf<$ValOf<$ValOf<$ValOf<$ElementType, K2>, K3>, K4>, K5>>(keyPath: [K, K2, K3, K4, K5], updater: (value: $ValOf<$ValOf<$ValOf<$ValOf<$ElementType, K2>, K3>, K4>, K5>) => S): this & T; + updateIn, S: $ValOf>(keyPath: [K], notSetValue: NSV, updater: (value: $ValOf) => S): this & T; + updateIn, S: $ValOf>(keyPath: [K], updater: (value: $ValOf) => S): this & T; + updateIn, K2: $KeyOf<$ValOf>, S: $ValOf<$ValOf, K2>>(keyPath: [K, K2], notSetValue: NSV, updater: (value: $ValOf<$ValOf, K2> | NSV) => S): this & T; + updateIn, K2: $KeyOf<$ValOf>, S: $ValOf<$ValOf, K2>>(keyPath: [K, K2], updater: (value: $ValOf<$ValOf, K2>) => S): this & T; + updateIn, K2: $KeyOf<$ValOf>, K3: $KeyOf<$ValOf<$ValOf, K2>>, S: $ValOf<$ValOf<$ValOf, K2>, K3>>(keyPath: [K, K2, K3], notSetValue: NSV, updater: (value: $ValOf<$ValOf<$ValOf, K2>, K3> | NSV) => S): this & T; + updateIn, K2: $KeyOf<$ValOf>, K3: $KeyOf<$ValOf<$ValOf, K2>>, S: $ValOf<$ValOf<$ValOf, K2>, K3>>(keyPath: [K, K2, K3], updater: (value: $ValOf<$ValOf<$ValOf, K2>, K3>) => S): this & T; + updateIn, K2: $KeyOf<$ValOf>, K3: $KeyOf<$ValOf<$ValOf, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>>, S: $ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>>(keyPath: [K, K2, K3, K4], notSetValue: NSV, updater: (value: $ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4> | NSV) => S): this & T; + updateIn, K2: $KeyOf<$ValOf>, K3: $KeyOf<$ValOf<$ValOf, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>>, S: $ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>>(keyPath: [K, K2, K3, K4], updater: (value: $ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>) => S): this & T; + updateIn, K2: $KeyOf<$ValOf>, K3: $KeyOf<$ValOf<$ValOf, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>>, K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>>, S: $ValOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>, K5>>(keyPath: [K, K2, K3, K4, K5], notSetValue: NSV, updater: (value: $ValOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>, K5> | NSV) => S): this & T; + updateIn, K2: $KeyOf<$ValOf>, K3: $KeyOf<$ValOf<$ValOf, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>>, K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>>, S: $ValOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>, K5>>(keyPath: [K, K2, K3, K4, K5], updater: (value: $ValOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>, K5>) => S): this & T; mergeIn(keyPath: Iterable, ...collections: Array): this & T; mergeDeepIn(keyPath: Iterable, ...collections: Array): this & T; From 468e5655dc76ef5b21f9be5d519a9c889c992339 Mon Sep 17 00:00:00 2001 From: Travis CI Date: Wed, 18 Oct 2017 06:00:00 +0000 Subject: [PATCH 077/242] Deploy 4585b0dcdcb34efcffd0d7935b003441a37d1d71 to NPM branch --- dist/immutable.js.flow | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/dist/immutable.js.flow b/dist/immutable.js.flow index ba58923fc4..5a9fc25663 100644 --- a/dist/immutable.js.flow +++ b/dist/immutable.js.flow @@ -49,6 +49,12 @@ type $ValOf> = $Call< K >; +type $IterableOf = $Call< + & ( | IndexedCollection | SetCollection>(V) => Iterable<$ValOf>) + & ( | RecordInstance | PlainObjInput>(V) => Iterable<[$KeyOf, $ValOf]>), + C +>; + declare class _Collection /*implements ValueObject*/ { equals(other: mixed): boolean; hashCode(): number; @@ -1372,6 +1378,10 @@ type RecordFactory = Class>; // The type of runtime Record instances. type RecordOf = RecordInstance & Values; +// The values of a Record instance. +type _RecordValues | T> = R; +type RecordValues = _RecordValues<*, R>; + declare function isRecord(maybeRecord: any): boolean %checks(maybeRecord instanceof RecordInstance); declare class Record { static (spec: Values, name?: string): RecordFactory; @@ -1383,10 +1393,10 @@ declare class Record { } declare class RecordInstance { - static (values?: $Shape | Iterable<[$Keys, any]>): RecordOf; + static (values?: Iterable<[$Keys, $ValOf]> | $Shape): RecordOf; // Note: a constructor can only create an instance of RecordInstance, // it's encouraged to not use `new` when creating Records. - constructor (values?: $Shape | Iterable<[$Keys, any]>): void; + constructor (values?: Iterable<[$Keys, $ValOf]> | $Shape): void; size: number; @@ -1407,16 +1417,16 @@ declare class RecordInstance { set>(key: K, value: $ElementType): this & T; update>(key: K, updater: (value: $ElementType) => $ElementType): this & T; - merge(...collections: Array<$Shape | Iterable<[$Keys, any]>>): this & T; - mergeDeep(...collections: Array<$Shape | Iterable<[$Keys, any]>>): this & T; + merge(...collections: Array, $ValOf]> | $Shape>): this & T; + mergeDeep(...collections: Array, $ValOf]> | $Shape>): this & T; mergeWith( - merger: (oldVal: any, newVal: any, key: $Keys) => any, - ...collections: Array<$Shape | Iterable<[$Keys, any]>> + merger: (oldVal: $ValOf, newVal: $ValOf, key: $Keys) => $ValOf, + ...collections: Array, $ValOf]> | $Shape> ): this & T; mergeDeepWith( merger: (oldVal: any, newVal: any, key: any) => any, - ...collections: Array<$Shape | Iterable<[$Keys, any]>> + ...collections: Array, $ValOf]> | $Shape> ): this & T; delete>(key: K): this & T; @@ -1471,7 +1481,7 @@ declare class RecordInstance { wasAltered(): boolean; asImmutable(): this & T; - @@iterator(): Iterator<[$Keys, any]>; + @@iterator(): Iterator<[$Keys, $ValOf]>; } declare function fromJS( @@ -1533,21 +1543,21 @@ declare function updateIn, K2: $KeyOf<$ValOf>, K3: $KeyOf< declare function merge( collection: C, - ...collections: Array> | Iterable<[$KeyOf, $ValOf]> | PlainObjInput<$KeyOf, $ValOf>> + ...collections: Array<$IterableOf | $Shape> | PlainObjInput<$KeyOf, $ValOf>> ): C; declare function mergeWith( merger: (oldVal: $ValOf, newVal: $ValOf, key: $KeyOf) => $ValOf, collection: C, - ...collections: Array> | Iterable<[$KeyOf, $ValOf]> | PlainObjInput<$KeyOf, $ValOf>> + ...collections: Array<$IterableOf | $Shape> | PlainObjInput<$KeyOf, $ValOf>> ): C; declare function mergeDeep( collection: C, - ...collections: Array> | Iterable<[$KeyOf, $ValOf]> | PlainObjInput<$KeyOf, $ValOf>> + ...collections: Array<$IterableOf | $Shape> | PlainObjInput<$KeyOf, $ValOf>> ): C; declare function mergeDeepWith( merger: (oldVal: any, newVal: any, key: any) => mixed, collection: C, - ...collections: Array> | Iterable<[$KeyOf, $ValOf]> | PlainObjInput<$KeyOf, $ValOf>> + ...collections: Array<$IterableOf | $Shape> | PlainObjInput<$KeyOf, $ValOf>> ): C; export { From db9d4c3ee200cbcb61f6e8aa3b40c1855508e1fa Mon Sep 17 00:00:00 2001 From: Travis CI Date: Wed, 18 Oct 2017 06:09:23 +0000 Subject: [PATCH 078/242] Deploy 82d05a27bf6f9cb96ba30830c2009819d6906a98 to NPM branch --- bower.json | 2 +- dist/immutable-nonambient.d.ts | 240 ++++++++++++++++----------------- dist/immutable.d.ts | 240 ++++++++++++++++----------------- dist/immutable.es.js | 2 +- dist/immutable.js | 2 +- dist/immutable.min.js | 2 +- package.json | 2 +- 7 files changed, 245 insertions(+), 245 deletions(-) diff --git a/bower.json b/bower.json index b7899869b0..879c420fc6 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "immutable", - "version": "4.0.0-rc.8", + "version": "4.0.0-rc.9", "description": "Immutable Data Collections", "license": "MIT", "homepage": "https://facebook.github.com/immutable-js", diff --git a/dist/immutable-nonambient.d.ts b/dist/immutable-nonambient.d.ts index bb9455899e..1f089c5914 100644 --- a/dist/immutable-nonambient.d.ts +++ b/dist/immutable-nonambient.d.ts @@ -120,7 +120,7 @@ * * * ```js - * const { List } = require('immutable@4.0.0-rc.8'); + * const { List } = require('immutable@4.0.0-rc.9'); * List.isList([]); // false * List.isList(List()); // true * ``` @@ -132,7 +132,7 @@ * * * ```js - * const { List } = require('immutable@4.0.0-rc.8'); + * const { List } = require('immutable@4.0.0-rc.9'); * List.of(1, 2, 3, 4) * // List [ 1, 2, 3, 4 ] * ``` @@ -141,7 +141,7 @@ * * * ```js - * const { List } = require('immutable@4.0.0-rc.8'); + * const { List } = require('immutable@4.0.0-rc.9'); * List.of({x:1}, 2, [3], 4) * // List [ { x: 1 }, 2, [ 3 ], 4 ] * ``` @@ -155,7 +155,7 @@ * * * ```js - * const { List, Set } = require('immutable@4.0.0-rc.8') + * const { List, Set } = require('immutable@4.0.0-rc.9') * * const emptyList = List() * // List [] @@ -201,7 +201,7 @@ * enough to include the `index`. * * * ```js * const originalList = List([ 0 ]); @@ -234,7 +234,7 @@ * Note: `delete` cannot be safely used in IE8 * * * ```js * List([ 0, 1, 2, 3, 4 ]).delete(0); @@ -258,7 +258,7 @@ * This is synonymous with `list.splice(index, 0, value)`. * * * ```js * List([ 0, 1, 2, 3, 4 ]).insert(6, 5) @@ -276,7 +276,7 @@ * Returns a new List with 0 size and no values in constant time. * * * ```js * List([ 1, 2, 3, 4 ]).clear() @@ -292,7 +292,7 @@ * List's `size`. * * * ```js * List([ 1, 2, 3, 4 ]).push(5) @@ -325,7 +325,7 @@ * values ahead to higher indices. * * * ```js * List([ 2, 3, 4]).unshift(1); @@ -345,7 +345,7 @@ * value in this List. * * * ```js * List([ 0, 1, 2, 3, 4 ]).shift(); @@ -366,7 +366,7 @@ * List. `v.update(-1)` updates the last item in the List. * * * ```js * const list = List([ 'a', 'b', 'c' ]) @@ -380,7 +380,7 @@ * For example, to sum a List after mapping and filtering: * * * ```js * function sum(collection) { @@ -426,7 +426,7 @@ * * * ```js - * const { List } = require('immutable@4.0.0-rc.8') + * const { List } = require('immutable@4.0.0-rc.9') * const list = List([ 0, 1, 2, List([ 3, 4 ])]) * list.setIn([3, 0], 999); * // List [ 0, 1, 2, List [ 999, 4 ] ] @@ -438,7 +438,7 @@ * * * ```js - * const { List } = require('immutable@4.0.0-rc.8') + * const { List } = require('immutable@4.0.0-rc.9') * const list = List([ 0, 1, 2, { plain: 'object' }]) * list.setIn([3, 'plain'], 'value'); * // List([ 0, 1, 2, { plain: 'value' }]) @@ -454,7 +454,7 @@ * * * ```js - * const { List } = require('immutable@4.0.0-rc.8') + * const { List } = require('immutable@4.0.0-rc.9') * const list = List([ 0, 1, 2, List([ 3, 4 ])]) * list.deleteIn([3, 0]); * // List [ 0, 1, 2, List [ 4 ] ] @@ -466,7 +466,7 @@ * * * ```js - * const { List } = require('immutable@4.0.0-rc.8') + * const { List } = require('immutable@4.0.0-rc.9') * const list = List([ 0, 1, 2, { plain: 'object' }]) * list.removeIn([3, 'plain']); * // List([ 0, 1, 2, {}]) @@ -550,7 +550,7 @@ * `mapper` function. * * * ```js * List([ 1, 2 ]).map(x => 10 * x) @@ -597,7 +597,7 @@ * Like `zipWith`, but using the default `zipper`: creating an `Array`. * * * ```js * const a = List([ 1, 2, 3 ]); @@ -616,7 +616,7 @@ * exhausted. Missing values from shorter collections are filled with `undefined`. * * * ```js * const a = List([ 1, 2 ]); @@ -637,7 +637,7 @@ * custom `zipper` function. * * * ```js * const a = List([ 1, 2, 3 ]); @@ -678,7 +678,7 @@ * * * ```js - * const { Map, List } = require('immutable@4.0.0-rc.8'); + * const { Map, List } = require('immutable@4.0.0-rc.9'); * Map().set(List([ 1 ]), 'listofone').get(List([ 1 ])); * // 'listofone' * ``` @@ -696,7 +696,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.8') + * const { Map } = require('immutable@4.0.0-rc.9') * Map.isMap({}) // false * Map.isMap(Map()) // true * ``` @@ -708,7 +708,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.8') + * const { Map } = require('immutable@4.0.0-rc.9') * Map.of( * 'key', 'value', * 'numerical value', 3, @@ -730,7 +730,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.8') + * const { Map } = require('immutable@4.0.0-rc.9') * Map({ key: "value" }) * Map([ [ "key", "value" ] ]) * ``` @@ -740,7 +740,7 @@ * quote-less shorthand, while Immutable Maps accept keys of any type. * * * ```js * let obj = { 1: "one" } @@ -776,7 +776,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.8') + * const { Map } = require('immutable@4.0.0-rc.9') * const originalMap = Map() * const newerMap = originalMap.set('key', 'value') * const newestMap = newerMap.set('key', 'newer value') @@ -801,7 +801,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.8') + * const { Map } = require('immutable@4.0.0-rc.9') * const originalMap = Map({ * key: 'value', * otherKey: 'other value' @@ -823,7 +823,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.8') + * const { Map } = require('immutable@4.0.0-rc.9') * const names = Map({ a: "Aaron", b: "Barry", c: "Connor" }) * names.deleteAll([ 'a', 'c' ]) * // Map { "b": "Barry" } @@ -841,7 +841,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.8') + * const { Map } = require('immutable@4.0.0-rc.9') * Map({ key: 'value' }).clear() * // Map {} * ``` @@ -858,7 +858,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.8') + * const { Map } = require('immutable@4.0.0-rc.9') * const aMap = Map({ key: 'value' }) * const newMap = aMap.update('key', value => value + value) * // Map { "key": "valuevalue" } @@ -869,7 +869,7 @@ * `update` and `push` can be used together: * * * ```js * const aMap = Map({ nestedList: List([ 1, 2, 3 ]) }) @@ -881,7 +881,7 @@ * function when the value at the key does not exist in the Map. * * * ```js * const aMap = Map({ key: 'value' }) @@ -894,7 +894,7 @@ * is provided. * * * ```js * const aMap = Map({ apples: 10 }) @@ -910,7 +910,7 @@ * The previous example behaves differently when written with default values: * * * ```js * const aMap = Map({ apples: 10 }) @@ -922,7 +922,7 @@ * returned as well. * * * ```js * const aMap = Map({ key: 'value' }) @@ -936,7 +936,7 @@ * For example, to sum the values in a Map * * * ```js * function sum(collection) { @@ -966,7 +966,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.8') + * const { Map } = require('immutable@4.0.0-rc.9') * const one = Map({ a: 10, b: 20, c: 30 }) * const two = Map({ b: 40, a: 50, d: 60 }) * one.merge(two) // Map { "a": 50, "b": 40, "c": 30, "d": 60 } @@ -989,7 +989,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.8') + * const { Map } = require('immutable@4.0.0-rc.9') * const one = Map({ a: 10, b: 20, c: 30 }) * const two = Map({ b: 40, a: 50, d: 60 }) * one.mergeWith((oldVal, newVal) => oldVal / newVal, two) @@ -1015,7 +1015,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.8') + * const { Map } = require('immutable@4.0.0-rc.9') * const one = Map({ a: Map({ x: 10, y: 10 }), b: Map({ x: 20, y: 50 }) }) * const two = Map({ a: Map({ x: 2 }), b: Map({ y: 5 }), c: Map({ z: 3 }) }) * one.mergeDeep(two) @@ -1036,7 +1036,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.8') + * const { Map } = require('immutable@4.0.0-rc.9') * const one = Map({ a: Map({ x: 10, y: 10 }), b: Map({ x: 20, y: 50 }) }) * const two = Map({ a: Map({ x: 2 }), b: Map({ y: 5 }), c: Map({ z: 3 }) }) * one.mergeDeepWith((oldVal, newVal) => oldVal / newVal, two) @@ -1063,7 +1063,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.8') + * const { Map } = require('immutable@4.0.0-rc.9') * const originalMap = Map({ * subObject: Map({ * subKey: 'subvalue', @@ -1099,7 +1099,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.8') + * const { Map } = require('immutable@4.0.0-rc.9') * const originalMap = Map({ * subObject: { * subKey: 'subvalue', @@ -1146,7 +1146,7 @@ * * * ```js - * const { Map, List } = require('immutable@4.0.0-rc.8') + * const { Map, List } = require('immutable@4.0.0-rc.9') * const map = Map({ inMap: Map({ inList: List([ 1, 2, 3 ]) }) }) * const newMap = map.updateIn(['inMap', 'inList'], list => list.push(4)) * // Map { "inMap": Map { "inList": List [ 1, 2, 3, 4 ] } } @@ -1158,7 +1158,7 @@ * provided, otherwise `undefined`. * * * ```js * const map = Map({ a: Map({ b: Map({ c: 10 }) }) }) @@ -1170,7 +1170,7 @@ * no change will occur. This is still true if `notSetValue` is provided. * * * ```js * const map = Map({ a: Map({ b: Map({ c: 10 }) }) }) @@ -1186,7 +1186,7 @@ * The previous example behaves differently when written with default values: * * * ```js * const map = Map({ a: Map({ b: Map({ c: 10 }) }) }) @@ -1199,7 +1199,7 @@ * immutably by creating new copies of those values with the changes applied. * * * ```js * const map = Map({ a: { b: { c: 10 } } }) @@ -1260,7 +1260,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.8') + * const { Map } = require('immutable@4.0.0-rc.9') * const map1 = Map() * const map2 = map1.withMutations(map => { * map.set('a', 1).set('b', 2).set('c', 3) @@ -1428,7 +1428,7 @@ * * * ```js - * const { OrderedMap } = require('immutable@4.0.0-rc.8') + * const { OrderedMap } = require('immutable@4.0.0-rc.9') * const one = OrderedMap({ a: 10, b: 20, c: 30 }) * const two = OrderedMap({ b: 40, a: 50, d: 60 }) * one.merge(two) // OrderedMap { "a": 50, "b": 40, "c": 30, "d": 60 } @@ -1545,7 +1545,7 @@ * a collection of other sets. * * ```js - * const { Set } = require('immutable@4.0.0-rc.8') + * const { Set } = require('immutable@4.0.0-rc.9') * const intersected = Set.intersect([ * Set([ 'a', 'b', 'c' ]) * Set([ 'c', 'a', 't' ]) @@ -1560,7 +1560,7 @@ * collection of other sets. * * ```js - * const { Set } = require('immutable@4.0.0-rc.8') + * const { Set } = require('immutable@4.0.0-rc.9') * const unioned = Set.union([ * Set([ 'a', 'b', 'c' ]) * Set([ 'c', 'a', 't' ]) @@ -2131,7 +2131,7 @@ * infinity. When `start` is equal to `end`, returns empty range. * * ```js - * const { Range } = require('immutable@4.0.0-rc.8') + * const { Range } = require('immutable@4.0.0-rc.9') * Range() // [ 0, 1, 2, 3, ... ] * Range(10) // [ 10, 11, 12, 13, ... ] * Range(10, 15) // [ 10, 11, 12, 13, 14 ] @@ -2148,7 +2148,7 @@ * not defined, returns an infinite `Seq` of `value`. * * ```js - * const { Repeat } = require('immutable@4.0.0-rc.8') + * const { Repeat } = require('immutable@4.0.0-rc.9') * Repeat('foo') // [ 'foo', 'foo', 'foo', ... ] * Repeat('bar', 4) // [ 'bar', 'bar', 'bar', 'bar' ] * ``` @@ -2164,7 +2164,7 @@ * create Record instances. * * ```js - * const { Record } = require('immutable@4.0.0-rc.8') + * const { Record } = require('immutable@4.0.0-rc.9') * const ABRecord = Record({ a: 1, b: 2 }) * const myRecord = new ABRecord({ b: 3 }) * ``` @@ -2296,7 +2296,7 @@ * method. If one was not provided, the string "Record" is returned. * * ```js - * const { Record } = require('immutable@4.0.0-rc.8') + * const { Record } = require('immutable@4.0.0-rc.9') * const Person = Record({ * name: null * }, 'Person') @@ -2314,7 +2314,7 @@ * type: * * * ```js * // makePerson is a Record Factory function @@ -2329,7 +2329,7 @@ * access on the resulting instances: * * * ```js * // Use the Record API @@ -2511,7 +2511,7 @@ * `Seq`'s values are never iterated: * * ```js - * const { Seq } = require('immutable@4.0.0-rc.8') + * const { Seq } = require('immutable@4.0.0-rc.9') * const oddSquares = Seq([ 1, 2, 3, 4, 5, 6, 7, 8 ]) * .filter(x => x % 2 !== 0) * .map(x => x * x) @@ -2550,7 +2550,7 @@ * * * ```js - * const { Range } = require('immutable@4.0.0-rc.8') + * const { Range } = require('immutable@4.0.0-rc.9') * Range(1, Infinity) * .skip(1000) * .map(n => -n) @@ -2629,7 +2629,7 @@ * `mapper` function. * * ```js - * const { Seq } = require('immutable@4.0.0-rc.8') + * const { Seq } = require('immutable@4.0.0-rc.9') * Seq.Keyed({ a: 1, b: 2 }).map(x => 10 * x) * // Seq { "a": 10, "b": 20 } * ``` @@ -2741,7 +2741,7 @@ * `mapper` function. * * ```js - * const { Seq } = require('immutable@4.0.0-rc.8') + * const { Seq } = require('immutable@4.0.0-rc.9') * Seq.Indexed([ 1, 2 ]).map(x => 10 * x) * // Seq [ 10, 20 ] * ``` @@ -3001,7 +3001,7 @@ * `mapper` function. * * ```js - * const { Seq } = require('immutable@4.0.0-rc.8') + * const { Seq } = require('immutable@4.0.0-rc.9') * Seq([ 1, 2 ]).map(x => 10 * x) * // Seq [ 10, 20 ] * ``` @@ -3019,7 +3019,7 @@ * `mapper` function. * * ```js - * const { Seq } = require('immutable@4.0.0-rc.8') + * const { Seq } = require('immutable@4.0.0-rc.9') * Seq([ 1, 2 ]).map(x => 10 * x) * // Seq [ 10, 20 ] * ``` @@ -3088,22 +3088,22 @@ export module Collection { /** - * @deprecated use `const { isKeyed } = require('immutable@4.0.0-rc.8')` + * @deprecated use `const { isKeyed } = require('immutable@4.0.0-rc.9')` */ function isKeyed(maybeKeyed: any): maybeKeyed is Collection.Keyed; /** - * @deprecated use `const { isIndexed } = require('immutable@4.0.0-rc.8')` + * @deprecated use `const { isIndexed } = require('immutable@4.0.0-rc.9')` */ function isIndexed(maybeIndexed: any): maybeIndexed is Collection.Indexed; /** - * @deprecated use `const { isAssociative } = require('immutable@4.0.0-rc.8')` + * @deprecated use `const { isAssociative } = require('immutable@4.0.0-rc.9')` */ function isAssociative(maybeAssociative: any): maybeAssociative is Collection.Keyed | Collection.Indexed; /** - * @deprecated use `const { isOrdered } = require('immutable@4.0.0-rc.8')` + * @deprecated use `const { isOrdered } = require('immutable@4.0.0-rc.9')` */ function isOrdered(maybeOrdered: any): boolean; @@ -3161,7 +3161,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.8') + * const { Map } = require('immutable@4.0.0-rc.9') * Map({ a: 'z', b: 'y' }).flip() * // Map { "z": "a", "y": "b" } * ``` @@ -3179,7 +3179,7 @@ * `mapper` function. * * ```js - * const { Collection } = require('immutable@4.0.0-rc.8') + * const { Collection } = require('immutable@4.0.0-rc.9') * Collection.Keyed({ a: 1, b: 2 }).map(x => 10 * x) * // Seq { "a": 10, "b": 20 } * ``` @@ -3198,7 +3198,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.8') + * const { Map } = require('immutable@4.0.0-rc.9') * Map({ a: 1, b: 2 }).mapKeys(x => x.toUpperCase()) * // Map { "A": 1, "B": 2 } * ``` @@ -3217,7 +3217,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.8') + * const { Map } = require('immutable@4.0.0-rc.9') * Map({ a: 1, b: 2 }) * .mapEntries(([ k, v ]) => [ k.toUpperCase(), v * 2 ]) * // Map { "A": 2, "B": 4 } @@ -3343,10 +3343,10 @@ * second from each, etc. * * * ```js - * const { List } = require('immutable@4.0.0-rc.8') + * const { List } = require('immutable@4.0.0-rc.9') * List([ 1, 2, 3 ]).interleave(List([ 'A', 'B', 'C' ])) * // List [ 1, "A", 2, "B", 3, "C"" ] * ``` @@ -3354,7 +3354,7 @@ * The shortest Collection stops interleave. * * * ```js * List([ 1, 2, 3 ]).interleave( @@ -3381,7 +3381,7 @@ * * * ```js - * const { List } = require('immutable@4.0.0-rc.8') + * const { List } = require('immutable@4.0.0-rc.9') * List([ 'a', 'b', 'c', 'd' ]).splice(1, 2, 'q', 'r', 's') * // List [ "a", "q", "r", "s", "d" ] * ``` @@ -3405,7 +3405,7 @@ * * * * ```js * const a = List([ 1, 2, 3 ]); @@ -3438,7 +3438,7 @@ * collections by using a custom `zipper` function. * * * ```js * const a = List([ 1, 2, 3 ]); @@ -3506,7 +3506,7 @@ * `mapper` function. * * ```js - * const { Collection } = require('immutable@4.0.0-rc.8') + * const { Collection } = require('immutable@4.0.0-rc.9') * Collection.Indexed([1,2]).map(x => 10 * x) * // Seq [ 1, 2 ] * ``` @@ -3558,7 +3558,7 @@ * the value as both the first and second arguments to the provided function. * * ```js - * const { Collection } = require('immutable@4.0.0-rc.8') + * const { Collection } = require('immutable@4.0.0-rc.9') * const seq = Collection.Set([ 'A', 'B', 'C' ]) * // Seq { "A", "B", "C" } * seq.forEach((v, k) => @@ -3690,7 +3690,7 @@ * lookup via a different instance. * * * ```js * const a = List([ 1, 2, 3 ]); @@ -3755,7 +3755,7 @@ * * * ```js - * const { Map, List } = require('immutable@4.0.0-rc.8') + * const { Map, List } = require('immutable@4.0.0-rc.9') * const deepData = Map({ x: List([ Map({ y: 123 }) ]) }); * getIn(deepData, ['x', 0, 'y']) // 123 * ``` @@ -3765,7 +3765,7 @@ * * * ```js - * const { Map, List } = require('immutable@4.0.0-rc.8') + * const { Map, List } = require('immutable@4.0.0-rc.9') * const deepData = Map({ x: [ { y: 123 } ] }); * getIn(deepData, ['x', 0, 'y']) // 123 * ``` @@ -3788,7 +3788,7 @@ * * * ```js - * const { Seq } = require('immutable@4.0.0-rc.8') + * const { Seq } = require('immutable@4.0.0-rc.9') * * function sum(collection) { * return collection.reduce((sum, x) => sum + x, 0) @@ -3884,7 +3884,7 @@ * * * ```js - * const { Map, List } = require('immutable@4.0.0-rc.8') + * const { Map, List } = require('immutable@4.0.0-rc.9') * var myMap = Map({ a: 'Apple', b: 'Banana' }) * List(myMap) // List [ [ "a", "Apple" ], [ "b", "Banana" ] ] * myMap.toList() // List [ "Apple", "Banana" ] @@ -3921,7 +3921,7 @@ * * * ```js - * const { Seq } = require('immutable@4.0.0-rc.8') + * const { Seq } = require('immutable@4.0.0-rc.9') * const indexedSeq = Seq([ 'A', 'B', 'C' ]) * // Seq [ "A", "B", "C" ] * indexedSeq.filter(v => v === 'B') @@ -4002,7 +4002,7 @@ * * * ```js - * const { Collection } = require('immutable@4.0.0-rc.8') + * const { Collection } = require('immutable@4.0.0-rc.9') * Collection({ a: 1, b: 2 }).map(x => 10 * x) * // Seq { "a": 10, "b": 20 } * ``` @@ -4029,7 +4029,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.8') + * const { Map } = require('immutable@4.0.0-rc.9') * Map({ a: 1, b: 2, c: 3, d: 4}).filter(x => x % 2 === 0) * // Map { "b": 2, "d": 4 } * ``` @@ -4052,7 +4052,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.8') + * const { Map } = require('immutable@4.0.0-rc.9') * Map({ a: 1, b: 2, c: 3, d: 4}).filterNot(x => x % 2 === 0) * // Map { "a": 1, "c": 3 } * ``` @@ -4089,7 +4089,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.8') + * const { Map } = require('immutable@4.0.0-rc.9') * Map({ "c": 3, "a": 1, "b": 2 }).sort((a, b) => { * if (a < b) { return -1; } * if (a > b) { return 1; } @@ -4129,7 +4129,7 @@ * * * ```js - * const { List, Map } = require('immutable@4.0.0-rc.8') + * const { List, Map } = require('immutable@4.0.0-rc.9') * const listOfMaps = List([ * Map({ v: 0 }), * Map({ v: 1 }), @@ -4216,7 +4216,7 @@ * * * ```js - * const { List } = require('immutable@4.0.0-rc.8') + * const { List } = require('immutable@4.0.0-rc.9') * List([ 'dog', 'frog', 'cat', 'hat', 'god' ]) * .skipWhile(x => x.match(/g/)) * // List [ "cat", "hat", "god"" ] @@ -4233,7 +4233,7 @@ * * * ```js - * const { List } = require('immutable@4.0.0-rc.8') + * const { List } = require('immutable@4.0.0-rc.9') * List([ 'dog', 'frog', 'cat', 'hat', 'god' ]) * .skipUntil(x => x.match(/hat/)) * // List [ "hat", "god"" ] @@ -4262,7 +4262,7 @@ * * * ```js - * const { List } = require('immutable@4.0.0-rc.8') + * const { List } = require('immutable@4.0.0-rc.9') * List([ 'dog', 'frog', 'cat', 'hat', 'god' ]) * .takeWhile(x => x.match(/o/)) * // List [ "dog", "frog" ] @@ -4279,7 +4279,7 @@ * * * ```js - * const { List } = require('immutable@4.0.0-rc.8') + * const { List } = require('immutable@4.0.0-rc.9') * List([ 'dog', 'frog', 'cat', 'hat', 'god' ]) * .takeUntil(x => x.match(/at/)) * // List [ "dog", "frog" ] @@ -4597,7 +4597,7 @@ * * * ```js - * const { List, Set } = require('immutable@4.0.0-rc.8'); + * const { List, Set } = require('immutable@4.0.0-rc.9'); * const a = List([ 1, 2, 3 ]); * const b = List([ 1, 2, 3 ]); * assert.notStrictEqual(a, b); // different instances @@ -4641,7 +4641,7 @@ * * * ```js - * const { fromJS, isKeyed } = require('immutable@4.0.0-rc.8') + * const { fromJS, isKeyed } = require('immutable@4.0.0-rc.9') * function (key, value) { * return isKeyed(value) ? value.Map() : value.toList() * } @@ -4655,7 +4655,7 @@ * * * ```js - * const { fromJS, isKeyed } = require('immutable@4.0.0-rc.8') + * const { fromJS, isKeyed } = require('immutable@4.0.0-rc.9') * fromJS({ a: {b: [10, 20, 30]}, c: 40}, function (key, value, path) { * console.log(key, value, path) * return isKeyed(value) ? value.toOrderedMap() : value.toList() @@ -4672,7 +4672,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.8') + * const { Map } = require('immutable@4.0.0-rc.9') * let obj = { 1: "one" }; * Object.keys(obj); // [ "1" ] * assert.equal(obj["1"], obj[1]); // "one" === "one" @@ -4707,7 +4707,7 @@ * * * ```js - * const { Map, is } = require('immutable@4.0.0-rc.8') + * const { Map, is } = require('immutable@4.0.0-rc.9') * const map1 = Map({ a: 1, b: 1, c: 1 }) * const map2 = Map({ a: 1, b: 1, c: 1 }) * assert.equal(map1 !== map2, true) @@ -4755,7 +4755,7 @@ * * * ```js - * const { isImmutable, Map, List, Stack } = require('immutable@4.0.0-rc.8'); + * const { isImmutable, Map, List, Stack } = require('immutable@4.0.0-rc.9'); * isImmutable([]); // false * isImmutable({}); // false * isImmutable(Map()); // true @@ -4771,7 +4771,7 @@ * * * ```js - * const { isCollection, Map, List, Stack } = require('immutable@4.0.0-rc.8'); + * const { isCollection, Map, List, Stack } = require('immutable@4.0.0-rc.9'); * isCollection([]); // false * isCollection({}); // false * isCollection(Map()); // true @@ -4786,7 +4786,7 @@ * * * ```js - * const { isKeyed, Map, List, Stack } = require('immutable@4.0.0-rc.8'); + * const { isKeyed, Map, List, Stack } = require('immutable@4.0.0-rc.9'); * isKeyed([]); // false * isKeyed({}); // false * isKeyed(Map()); // true @@ -4801,7 +4801,7 @@ * * * ```js - * const { isIndexed, Map, List, Stack, Set } = require('immutable@4.0.0-rc.8'); + * const { isIndexed, Map, List, Stack, Set } = require('immutable@4.0.0-rc.9'); * isIndexed([]); // false * isIndexed({}); // false * isIndexed(Map()); // false @@ -4817,7 +4817,7 @@ * * * ```js - * const { isAssociative, Map, List, Stack, Set } = require('immutable@4.0.0-rc.8'); + * const { isAssociative, Map, List, Stack, Set } = require('immutable@4.0.0-rc.9'); * isAssociative([]); // false * isAssociative({}); // false * isAssociative(Map()); // true @@ -4834,7 +4834,7 @@ * * * ```js - * const { isOrdered, Map, OrderedMap, List, Set } = require('immutable@4.0.0-rc.8'); + * const { isOrdered, Map, OrderedMap, List, Set } = require('immutable@4.0.0-rc.9'); * isOrdered([]); // false * isOrdered({}); // false * isOrdered(Map()); // false @@ -4863,7 +4863,7 @@ * * * ```js - * const { get } = require('immutable@4.0.0-rc.8') + * const { get } = require('immutable@4.0.0-rc.9') * get([ 'dog', 'frog', 'cat' ], 2) // 'frog' * get({ x: 123, y: 456 }, 'x') // 123 * get({ x: 123, y: 456 }, 'z', 'ifNotSet') // 'ifNotSet' @@ -4887,7 +4887,7 @@ * * * ```js - * const { has } = require('immutable@4.0.0-rc.8') + * const { has } = require('immutable@4.0.0-rc.9') * has([ 'dog', 'frog', 'cat' ], 2) // true * has([ 'dog', 'frog', 'cat' ], 5) // false * has({ x: 123, y: 456 }, 'x') // true @@ -4905,7 +4905,7 @@ * * * ```js - * const { remove } = require('immutable@4.0.0-rc.8') + * const { remove } = require('immutable@4.0.0-rc.9') * const originalArray = [ 'dog', 'frog', 'cat' ] * remove(originalArray, 1) // [ 'dog', 'cat' ] * console.log(originalArray) // [ 'dog', 'frog', 'cat' ] @@ -4930,7 +4930,7 @@ * * * ```js - * const { set } = require('immutable@4.0.0-rc.8') + * const { set } = require('immutable@4.0.0-rc.9') * const originalArray = [ 'dog', 'frog', 'cat' ] * set(originalArray, 1, 'cow') // [ 'dog', 'cow', 'cat' ] * console.log(originalArray) // [ 'dog', 'frog', 'cat' ] @@ -4955,7 +4955,7 @@ * * * ```js - * const { update } = require('immutable@4.0.0-rc.8') + * const { update } = require('immutable@4.0.0-rc.9') * const originalArray = [ 'dog', 'frog', 'cat' ] * update(originalArray, 1, val => val.toUpperCase()) // [ 'dog', 'FROG', 'cat' ] * console.log(originalArray) // [ 'dog', 'frog', 'cat' ] @@ -4984,7 +4984,7 @@ * * * ```js - * const { getIn } = require('immutable@4.0.0-rc.8') + * const { getIn } = require('immutable@4.0.0-rc.9') * getIn({ x: { y: { z: 123 }}}, ['x', 'y', 'z']) // 123 * getIn({ x: { y: { z: 123 }}}, ['x', 'q', 'p'], 'ifNotSet') // 'ifNotSet' * ``` @@ -4999,7 +4999,7 @@ * * * ```js - * const { hasIn } = require('immutable@4.0.0-rc.8') + * const { hasIn } = require('immutable@4.0.0-rc.9') * hasIn({ x: { y: { z: 123 }}}, ['x', 'y', 'z']) // true * hasIn({ x: { y: { z: 123 }}}, ['x', 'q', 'p']) // false * ``` @@ -5014,7 +5014,7 @@ * * * ```js - * const { removeIn } = require('immutable@4.0.0-rc.8') + * const { removeIn } = require('immutable@4.0.0-rc.9') * const original = { x: { y: { z: 123 }}} * removeIn(original, ['x', 'y', 'z']) // { x: { y: {}}} * console.log(original) // { x: { y: { z: 123 }}} @@ -5031,7 +5031,7 @@ * * * ```js - * const { setIn } = require('immutable@4.0.0-rc.8') + * const { setIn } = require('immutable@4.0.0-rc.9') * const original = { x: { y: { z: 123 }}} * setIn(original, ['x', 'y', 'z'], 456) // { x: { y: { z: 456 }}} * console.log(original) // { x: { y: { z: 123 }}} @@ -5048,7 +5048,7 @@ * * * ```js - * const { setIn } = require('immutable@4.0.0-rc.8') + * const { setIn } = require('immutable@4.0.0-rc.9') * const original = { x: { y: { z: 123 }}} * setIn(original, ['x', 'y', 'z'], val => val * 6) // { x: { y: { z: 738 }}} * console.log(original) // { x: { y: { z: 123 }}} @@ -5065,7 +5065,7 @@ * * * ```js - * const { merge } = require('immutable@4.0.0-rc.8') + * const { merge } = require('immutable@4.0.0-rc.9') * const original = { x: 123, y: 456 } * merge(original, { y: 789, z: 'abc' }) // { x: 123, y: 789, z: 'abc' } * console.log(original) // { x: { y: { z: 123 }}} @@ -5085,7 +5085,7 @@ * * * ```js - * const { mergeWith } = require('immutable@4.0.0-rc.8') + * const { mergeWith } = require('immutable@4.0.0-rc.9') * const original = { x: 123, y: 456 } * mergeWith( * (oldVal, newVal) => oldVal + newVal, @@ -5110,7 +5110,7 @@ * * * ```js - * const { merge } = require('immutable@4.0.0-rc.8') + * const { merge } = require('immutable@4.0.0-rc.9') * const original = { x: { y: 123 }} * merge(original, { x: { z: 456 }}) // { x: { y: 123, z: 456 }} * console.log(original) // { x: { y: 123 }} @@ -5131,7 +5131,7 @@ * * * ```js - * const { merge } = require('immutable@4.0.0-rc.8') + * const { merge } = require('immutable@4.0.0-rc.9') * const original = { x: { y: 123 }} * mergeDeepWith( * (oldVal, newVal) => oldVal + newVal, diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index 2a5ffdee05..777264e384 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -120,7 +120,7 @@ declare module Immutable { * * * ```js - * const { List } = require('immutable@4.0.0-rc.8'); + * const { List } = require('immutable@4.0.0-rc.9'); * List.isList([]); // false * List.isList(List()); // true * ``` @@ -132,7 +132,7 @@ declare module Immutable { * * * ```js - * const { List } = require('immutable@4.0.0-rc.8'); + * const { List } = require('immutable@4.0.0-rc.9'); * List.of(1, 2, 3, 4) * // List [ 1, 2, 3, 4 ] * ``` @@ -141,7 +141,7 @@ declare module Immutable { * * * ```js - * const { List } = require('immutable@4.0.0-rc.8'); + * const { List } = require('immutable@4.0.0-rc.9'); * List.of({x:1}, 2, [3], 4) * // List [ { x: 1 }, 2, [ 3 ], 4 ] * ``` @@ -155,7 +155,7 @@ declare module Immutable { * * * ```js - * const { List, Set } = require('immutable@4.0.0-rc.8') + * const { List, Set } = require('immutable@4.0.0-rc.9') * * const emptyList = List() * // List [] @@ -201,7 +201,7 @@ declare module Immutable { * enough to include the `index`. * * * ```js * const originalList = List([ 0 ]); @@ -234,7 +234,7 @@ declare module Immutable { * Note: `delete` cannot be safely used in IE8 * * * ```js * List([ 0, 1, 2, 3, 4 ]).delete(0); @@ -258,7 +258,7 @@ declare module Immutable { * This is synonymous with `list.splice(index, 0, value)`. * * * ```js * List([ 0, 1, 2, 3, 4 ]).insert(6, 5) @@ -276,7 +276,7 @@ declare module Immutable { * Returns a new List with 0 size and no values in constant time. * * * ```js * List([ 1, 2, 3, 4 ]).clear() @@ -292,7 +292,7 @@ declare module Immutable { * List's `size`. * * * ```js * List([ 1, 2, 3, 4 ]).push(5) @@ -325,7 +325,7 @@ declare module Immutable { * values ahead to higher indices. * * * ```js * List([ 2, 3, 4]).unshift(1); @@ -345,7 +345,7 @@ declare module Immutable { * value in this List. * * * ```js * List([ 0, 1, 2, 3, 4 ]).shift(); @@ -366,7 +366,7 @@ declare module Immutable { * List. `v.update(-1)` updates the last item in the List. * * * ```js * const list = List([ 'a', 'b', 'c' ]) @@ -380,7 +380,7 @@ declare module Immutable { * For example, to sum a List after mapping and filtering: * * * ```js * function sum(collection) { @@ -426,7 +426,7 @@ declare module Immutable { * * * ```js - * const { List } = require('immutable@4.0.0-rc.8') + * const { List } = require('immutable@4.0.0-rc.9') * const list = List([ 0, 1, 2, List([ 3, 4 ])]) * list.setIn([3, 0], 999); * // List [ 0, 1, 2, List [ 999, 4 ] ] @@ -438,7 +438,7 @@ declare module Immutable { * * * ```js - * const { List } = require('immutable@4.0.0-rc.8') + * const { List } = require('immutable@4.0.0-rc.9') * const list = List([ 0, 1, 2, { plain: 'object' }]) * list.setIn([3, 'plain'], 'value'); * // List([ 0, 1, 2, { plain: 'value' }]) @@ -454,7 +454,7 @@ declare module Immutable { * * * ```js - * const { List } = require('immutable@4.0.0-rc.8') + * const { List } = require('immutable@4.0.0-rc.9') * const list = List([ 0, 1, 2, List([ 3, 4 ])]) * list.deleteIn([3, 0]); * // List [ 0, 1, 2, List [ 4 ] ] @@ -466,7 +466,7 @@ declare module Immutable { * * * ```js - * const { List } = require('immutable@4.0.0-rc.8') + * const { List } = require('immutable@4.0.0-rc.9') * const list = List([ 0, 1, 2, { plain: 'object' }]) * list.removeIn([3, 'plain']); * // List([ 0, 1, 2, {}]) @@ -550,7 +550,7 @@ declare module Immutable { * `mapper` function. * * * ```js * List([ 1, 2 ]).map(x => 10 * x) @@ -597,7 +597,7 @@ declare module Immutable { * Like `zipWith`, but using the default `zipper`: creating an `Array`. * * * ```js * const a = List([ 1, 2, 3 ]); @@ -616,7 +616,7 @@ declare module Immutable { * exhausted. Missing values from shorter collections are filled with `undefined`. * * * ```js * const a = List([ 1, 2 ]); @@ -637,7 +637,7 @@ declare module Immutable { * custom `zipper` function. * * * ```js * const a = List([ 1, 2, 3 ]); @@ -678,7 +678,7 @@ declare module Immutable { * * * ```js - * const { Map, List } = require('immutable@4.0.0-rc.8'); + * const { Map, List } = require('immutable@4.0.0-rc.9'); * Map().set(List([ 1 ]), 'listofone').get(List([ 1 ])); * // 'listofone' * ``` @@ -696,7 +696,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.8') + * const { Map } = require('immutable@4.0.0-rc.9') * Map.isMap({}) // false * Map.isMap(Map()) // true * ``` @@ -708,7 +708,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.8') + * const { Map } = require('immutable@4.0.0-rc.9') * Map.of( * 'key', 'value', * 'numerical value', 3, @@ -730,7 +730,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.8') + * const { Map } = require('immutable@4.0.0-rc.9') * Map({ key: "value" }) * Map([ [ "key", "value" ] ]) * ``` @@ -740,7 +740,7 @@ declare module Immutable { * quote-less shorthand, while Immutable Maps accept keys of any type. * * * ```js * let obj = { 1: "one" } @@ -776,7 +776,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.8') + * const { Map } = require('immutable@4.0.0-rc.9') * const originalMap = Map() * const newerMap = originalMap.set('key', 'value') * const newestMap = newerMap.set('key', 'newer value') @@ -801,7 +801,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.8') + * const { Map } = require('immutable@4.0.0-rc.9') * const originalMap = Map({ * key: 'value', * otherKey: 'other value' @@ -823,7 +823,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.8') + * const { Map } = require('immutable@4.0.0-rc.9') * const names = Map({ a: "Aaron", b: "Barry", c: "Connor" }) * names.deleteAll([ 'a', 'c' ]) * // Map { "b": "Barry" } @@ -841,7 +841,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.8') + * const { Map } = require('immutable@4.0.0-rc.9') * Map({ key: 'value' }).clear() * // Map {} * ``` @@ -858,7 +858,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.8') + * const { Map } = require('immutable@4.0.0-rc.9') * const aMap = Map({ key: 'value' }) * const newMap = aMap.update('key', value => value + value) * // Map { "key": "valuevalue" } @@ -869,7 +869,7 @@ declare module Immutable { * `update` and `push` can be used together: * * * ```js * const aMap = Map({ nestedList: List([ 1, 2, 3 ]) }) @@ -881,7 +881,7 @@ declare module Immutable { * function when the value at the key does not exist in the Map. * * * ```js * const aMap = Map({ key: 'value' }) @@ -894,7 +894,7 @@ declare module Immutable { * is provided. * * * ```js * const aMap = Map({ apples: 10 }) @@ -910,7 +910,7 @@ declare module Immutable { * The previous example behaves differently when written with default values: * * * ```js * const aMap = Map({ apples: 10 }) @@ -922,7 +922,7 @@ declare module Immutable { * returned as well. * * * ```js * const aMap = Map({ key: 'value' }) @@ -936,7 +936,7 @@ declare module Immutable { * For example, to sum the values in a Map * * * ```js * function sum(collection) { @@ -966,7 +966,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.8') + * const { Map } = require('immutable@4.0.0-rc.9') * const one = Map({ a: 10, b: 20, c: 30 }) * const two = Map({ b: 40, a: 50, d: 60 }) * one.merge(two) // Map { "a": 50, "b": 40, "c": 30, "d": 60 } @@ -989,7 +989,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.8') + * const { Map } = require('immutable@4.0.0-rc.9') * const one = Map({ a: 10, b: 20, c: 30 }) * const two = Map({ b: 40, a: 50, d: 60 }) * one.mergeWith((oldVal, newVal) => oldVal / newVal, two) @@ -1015,7 +1015,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.8') + * const { Map } = require('immutable@4.0.0-rc.9') * const one = Map({ a: Map({ x: 10, y: 10 }), b: Map({ x: 20, y: 50 }) }) * const two = Map({ a: Map({ x: 2 }), b: Map({ y: 5 }), c: Map({ z: 3 }) }) * one.mergeDeep(two) @@ -1036,7 +1036,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.8') + * const { Map } = require('immutable@4.0.0-rc.9') * const one = Map({ a: Map({ x: 10, y: 10 }), b: Map({ x: 20, y: 50 }) }) * const two = Map({ a: Map({ x: 2 }), b: Map({ y: 5 }), c: Map({ z: 3 }) }) * one.mergeDeepWith((oldVal, newVal) => oldVal / newVal, two) @@ -1063,7 +1063,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.8') + * const { Map } = require('immutable@4.0.0-rc.9') * const originalMap = Map({ * subObject: Map({ * subKey: 'subvalue', @@ -1099,7 +1099,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.8') + * const { Map } = require('immutable@4.0.0-rc.9') * const originalMap = Map({ * subObject: { * subKey: 'subvalue', @@ -1146,7 +1146,7 @@ declare module Immutable { * * * ```js - * const { Map, List } = require('immutable@4.0.0-rc.8') + * const { Map, List } = require('immutable@4.0.0-rc.9') * const map = Map({ inMap: Map({ inList: List([ 1, 2, 3 ]) }) }) * const newMap = map.updateIn(['inMap', 'inList'], list => list.push(4)) * // Map { "inMap": Map { "inList": List [ 1, 2, 3, 4 ] } } @@ -1158,7 +1158,7 @@ declare module Immutable { * provided, otherwise `undefined`. * * * ```js * const map = Map({ a: Map({ b: Map({ c: 10 }) }) }) @@ -1170,7 +1170,7 @@ declare module Immutable { * no change will occur. This is still true if `notSetValue` is provided. * * * ```js * const map = Map({ a: Map({ b: Map({ c: 10 }) }) }) @@ -1186,7 +1186,7 @@ declare module Immutable { * The previous example behaves differently when written with default values: * * * ```js * const map = Map({ a: Map({ b: Map({ c: 10 }) }) }) @@ -1199,7 +1199,7 @@ declare module Immutable { * immutably by creating new copies of those values with the changes applied. * * * ```js * const map = Map({ a: { b: { c: 10 } } }) @@ -1260,7 +1260,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.8') + * const { Map } = require('immutable@4.0.0-rc.9') * const map1 = Map() * const map2 = map1.withMutations(map => { * map.set('a', 1).set('b', 2).set('c', 3) @@ -1428,7 +1428,7 @@ declare module Immutable { * * * ```js - * const { OrderedMap } = require('immutable@4.0.0-rc.8') + * const { OrderedMap } = require('immutable@4.0.0-rc.9') * const one = OrderedMap({ a: 10, b: 20, c: 30 }) * const two = OrderedMap({ b: 40, a: 50, d: 60 }) * one.merge(two) // OrderedMap { "a": 50, "b": 40, "c": 30, "d": 60 } @@ -1545,7 +1545,7 @@ declare module Immutable { * a collection of other sets. * * ```js - * const { Set } = require('immutable@4.0.0-rc.8') + * const { Set } = require('immutable@4.0.0-rc.9') * const intersected = Set.intersect([ * Set([ 'a', 'b', 'c' ]) * Set([ 'c', 'a', 't' ]) @@ -1560,7 +1560,7 @@ declare module Immutable { * collection of other sets. * * ```js - * const { Set } = require('immutable@4.0.0-rc.8') + * const { Set } = require('immutable@4.0.0-rc.9') * const unioned = Set.union([ * Set([ 'a', 'b', 'c' ]) * Set([ 'c', 'a', 't' ]) @@ -2131,7 +2131,7 @@ declare module Immutable { * infinity. When `start` is equal to `end`, returns empty range. * * ```js - * const { Range } = require('immutable@4.0.0-rc.8') + * const { Range } = require('immutable@4.0.0-rc.9') * Range() // [ 0, 1, 2, 3, ... ] * Range(10) // [ 10, 11, 12, 13, ... ] * Range(10, 15) // [ 10, 11, 12, 13, 14 ] @@ -2148,7 +2148,7 @@ declare module Immutable { * not defined, returns an infinite `Seq` of `value`. * * ```js - * const { Repeat } = require('immutable@4.0.0-rc.8') + * const { Repeat } = require('immutable@4.0.0-rc.9') * Repeat('foo') // [ 'foo', 'foo', 'foo', ... ] * Repeat('bar', 4) // [ 'bar', 'bar', 'bar', 'bar' ] * ``` @@ -2164,7 +2164,7 @@ declare module Immutable { * create Record instances. * * ```js - * const { Record } = require('immutable@4.0.0-rc.8') + * const { Record } = require('immutable@4.0.0-rc.9') * const ABRecord = Record({ a: 1, b: 2 }) * const myRecord = new ABRecord({ b: 3 }) * ``` @@ -2296,7 +2296,7 @@ declare module Immutable { * method. If one was not provided, the string "Record" is returned. * * ```js - * const { Record } = require('immutable@4.0.0-rc.8') + * const { Record } = require('immutable@4.0.0-rc.9') * const Person = Record({ * name: null * }, 'Person') @@ -2314,7 +2314,7 @@ declare module Immutable { * type: * * * ```js * // makePerson is a Record Factory function @@ -2329,7 +2329,7 @@ declare module Immutable { * access on the resulting instances: * * * ```js * // Use the Record API @@ -2511,7 +2511,7 @@ declare module Immutable { * `Seq`'s values are never iterated: * * ```js - * const { Seq } = require('immutable@4.0.0-rc.8') + * const { Seq } = require('immutable@4.0.0-rc.9') * const oddSquares = Seq([ 1, 2, 3, 4, 5, 6, 7, 8 ]) * .filter(x => x % 2 !== 0) * .map(x => x * x) @@ -2550,7 +2550,7 @@ declare module Immutable { * * * ```js - * const { Range } = require('immutable@4.0.0-rc.8') + * const { Range } = require('immutable@4.0.0-rc.9') * Range(1, Infinity) * .skip(1000) * .map(n => -n) @@ -2629,7 +2629,7 @@ declare module Immutable { * `mapper` function. * * ```js - * const { Seq } = require('immutable@4.0.0-rc.8') + * const { Seq } = require('immutable@4.0.0-rc.9') * Seq.Keyed({ a: 1, b: 2 }).map(x => 10 * x) * // Seq { "a": 10, "b": 20 } * ``` @@ -2741,7 +2741,7 @@ declare module Immutable { * `mapper` function. * * ```js - * const { Seq } = require('immutable@4.0.0-rc.8') + * const { Seq } = require('immutable@4.0.0-rc.9') * Seq.Indexed([ 1, 2 ]).map(x => 10 * x) * // Seq [ 10, 20 ] * ``` @@ -3001,7 +3001,7 @@ declare module Immutable { * `mapper` function. * * ```js - * const { Seq } = require('immutable@4.0.0-rc.8') + * const { Seq } = require('immutable@4.0.0-rc.9') * Seq([ 1, 2 ]).map(x => 10 * x) * // Seq [ 10, 20 ] * ``` @@ -3019,7 +3019,7 @@ declare module Immutable { * `mapper` function. * * ```js - * const { Seq } = require('immutable@4.0.0-rc.8') + * const { Seq } = require('immutable@4.0.0-rc.9') * Seq([ 1, 2 ]).map(x => 10 * x) * // Seq [ 10, 20 ] * ``` @@ -3088,22 +3088,22 @@ declare module Immutable { export module Collection { /** - * @deprecated use `const { isKeyed } = require('immutable@4.0.0-rc.8')` + * @deprecated use `const { isKeyed } = require('immutable@4.0.0-rc.9')` */ function isKeyed(maybeKeyed: any): maybeKeyed is Collection.Keyed; /** - * @deprecated use `const { isIndexed } = require('immutable@4.0.0-rc.8')` + * @deprecated use `const { isIndexed } = require('immutable@4.0.0-rc.9')` */ function isIndexed(maybeIndexed: any): maybeIndexed is Collection.Indexed; /** - * @deprecated use `const { isAssociative } = require('immutable@4.0.0-rc.8')` + * @deprecated use `const { isAssociative } = require('immutable@4.0.0-rc.9')` */ function isAssociative(maybeAssociative: any): maybeAssociative is Collection.Keyed | Collection.Indexed; /** - * @deprecated use `const { isOrdered } = require('immutable@4.0.0-rc.8')` + * @deprecated use `const { isOrdered } = require('immutable@4.0.0-rc.9')` */ function isOrdered(maybeOrdered: any): boolean; @@ -3161,7 +3161,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.8') + * const { Map } = require('immutable@4.0.0-rc.9') * Map({ a: 'z', b: 'y' }).flip() * // Map { "z": "a", "y": "b" } * ``` @@ -3179,7 +3179,7 @@ declare module Immutable { * `mapper` function. * * ```js - * const { Collection } = require('immutable@4.0.0-rc.8') + * const { Collection } = require('immutable@4.0.0-rc.9') * Collection.Keyed({ a: 1, b: 2 }).map(x => 10 * x) * // Seq { "a": 10, "b": 20 } * ``` @@ -3198,7 +3198,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.8') + * const { Map } = require('immutable@4.0.0-rc.9') * Map({ a: 1, b: 2 }).mapKeys(x => x.toUpperCase()) * // Map { "A": 1, "B": 2 } * ``` @@ -3217,7 +3217,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.8') + * const { Map } = require('immutable@4.0.0-rc.9') * Map({ a: 1, b: 2 }) * .mapEntries(([ k, v ]) => [ k.toUpperCase(), v * 2 ]) * // Map { "A": 2, "B": 4 } @@ -3343,10 +3343,10 @@ declare module Immutable { * second from each, etc. * * * ```js - * const { List } = require('immutable@4.0.0-rc.8') + * const { List } = require('immutable@4.0.0-rc.9') * List([ 1, 2, 3 ]).interleave(List([ 'A', 'B', 'C' ])) * // List [ 1, "A", 2, "B", 3, "C"" ] * ``` @@ -3354,7 +3354,7 @@ declare module Immutable { * The shortest Collection stops interleave. * * * ```js * List([ 1, 2, 3 ]).interleave( @@ -3381,7 +3381,7 @@ declare module Immutable { * * * ```js - * const { List } = require('immutable@4.0.0-rc.8') + * const { List } = require('immutable@4.0.0-rc.9') * List([ 'a', 'b', 'c', 'd' ]).splice(1, 2, 'q', 'r', 's') * // List [ "a", "q", "r", "s", "d" ] * ``` @@ -3405,7 +3405,7 @@ declare module Immutable { * * * * ```js * const a = List([ 1, 2, 3 ]); @@ -3438,7 +3438,7 @@ declare module Immutable { * collections by using a custom `zipper` function. * * * ```js * const a = List([ 1, 2, 3 ]); @@ -3506,7 +3506,7 @@ declare module Immutable { * `mapper` function. * * ```js - * const { Collection } = require('immutable@4.0.0-rc.8') + * const { Collection } = require('immutable@4.0.0-rc.9') * Collection.Indexed([1,2]).map(x => 10 * x) * // Seq [ 1, 2 ] * ``` @@ -3558,7 +3558,7 @@ declare module Immutable { * the value as both the first and second arguments to the provided function. * * ```js - * const { Collection } = require('immutable@4.0.0-rc.8') + * const { Collection } = require('immutable@4.0.0-rc.9') * const seq = Collection.Set([ 'A', 'B', 'C' ]) * // Seq { "A", "B", "C" } * seq.forEach((v, k) => @@ -3690,7 +3690,7 @@ declare module Immutable { * lookup via a different instance. * * * ```js * const a = List([ 1, 2, 3 ]); @@ -3755,7 +3755,7 @@ declare module Immutable { * * * ```js - * const { Map, List } = require('immutable@4.0.0-rc.8') + * const { Map, List } = require('immutable@4.0.0-rc.9') * const deepData = Map({ x: List([ Map({ y: 123 }) ]) }); * getIn(deepData, ['x', 0, 'y']) // 123 * ``` @@ -3765,7 +3765,7 @@ declare module Immutable { * * * ```js - * const { Map, List } = require('immutable@4.0.0-rc.8') + * const { Map, List } = require('immutable@4.0.0-rc.9') * const deepData = Map({ x: [ { y: 123 } ] }); * getIn(deepData, ['x', 0, 'y']) // 123 * ``` @@ -3788,7 +3788,7 @@ declare module Immutable { * * * ```js - * const { Seq } = require('immutable@4.0.0-rc.8') + * const { Seq } = require('immutable@4.0.0-rc.9') * * function sum(collection) { * return collection.reduce((sum, x) => sum + x, 0) @@ -3884,7 +3884,7 @@ declare module Immutable { * * * ```js - * const { Map, List } = require('immutable@4.0.0-rc.8') + * const { Map, List } = require('immutable@4.0.0-rc.9') * var myMap = Map({ a: 'Apple', b: 'Banana' }) * List(myMap) // List [ [ "a", "Apple" ], [ "b", "Banana" ] ] * myMap.toList() // List [ "Apple", "Banana" ] @@ -3921,7 +3921,7 @@ declare module Immutable { * * * ```js - * const { Seq } = require('immutable@4.0.0-rc.8') + * const { Seq } = require('immutable@4.0.0-rc.9') * const indexedSeq = Seq([ 'A', 'B', 'C' ]) * // Seq [ "A", "B", "C" ] * indexedSeq.filter(v => v === 'B') @@ -4002,7 +4002,7 @@ declare module Immutable { * * * ```js - * const { Collection } = require('immutable@4.0.0-rc.8') + * const { Collection } = require('immutable@4.0.0-rc.9') * Collection({ a: 1, b: 2 }).map(x => 10 * x) * // Seq { "a": 10, "b": 20 } * ``` @@ -4029,7 +4029,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.8') + * const { Map } = require('immutable@4.0.0-rc.9') * Map({ a: 1, b: 2, c: 3, d: 4}).filter(x => x % 2 === 0) * // Map { "b": 2, "d": 4 } * ``` @@ -4052,7 +4052,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.8') + * const { Map } = require('immutable@4.0.0-rc.9') * Map({ a: 1, b: 2, c: 3, d: 4}).filterNot(x => x % 2 === 0) * // Map { "a": 1, "c": 3 } * ``` @@ -4089,7 +4089,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.8') + * const { Map } = require('immutable@4.0.0-rc.9') * Map({ "c": 3, "a": 1, "b": 2 }).sort((a, b) => { * if (a < b) { return -1; } * if (a > b) { return 1; } @@ -4129,7 +4129,7 @@ declare module Immutable { * * * ```js - * const { List, Map } = require('immutable@4.0.0-rc.8') + * const { List, Map } = require('immutable@4.0.0-rc.9') * const listOfMaps = List([ * Map({ v: 0 }), * Map({ v: 1 }), @@ -4216,7 +4216,7 @@ declare module Immutable { * * * ```js - * const { List } = require('immutable@4.0.0-rc.8') + * const { List } = require('immutable@4.0.0-rc.9') * List([ 'dog', 'frog', 'cat', 'hat', 'god' ]) * .skipWhile(x => x.match(/g/)) * // List [ "cat", "hat", "god"" ] @@ -4233,7 +4233,7 @@ declare module Immutable { * * * ```js - * const { List } = require('immutable@4.0.0-rc.8') + * const { List } = require('immutable@4.0.0-rc.9') * List([ 'dog', 'frog', 'cat', 'hat', 'god' ]) * .skipUntil(x => x.match(/hat/)) * // List [ "hat", "god"" ] @@ -4262,7 +4262,7 @@ declare module Immutable { * * * ```js - * const { List } = require('immutable@4.0.0-rc.8') + * const { List } = require('immutable@4.0.0-rc.9') * List([ 'dog', 'frog', 'cat', 'hat', 'god' ]) * .takeWhile(x => x.match(/o/)) * // List [ "dog", "frog" ] @@ -4279,7 +4279,7 @@ declare module Immutable { * * * ```js - * const { List } = require('immutable@4.0.0-rc.8') + * const { List } = require('immutable@4.0.0-rc.9') * List([ 'dog', 'frog', 'cat', 'hat', 'god' ]) * .takeUntil(x => x.match(/at/)) * // List [ "dog", "frog" ] @@ -4597,7 +4597,7 @@ declare module Immutable { * * * ```js - * const { List, Set } = require('immutable@4.0.0-rc.8'); + * const { List, Set } = require('immutable@4.0.0-rc.9'); * const a = List([ 1, 2, 3 ]); * const b = List([ 1, 2, 3 ]); * assert.notStrictEqual(a, b); // different instances @@ -4641,7 +4641,7 @@ declare module Immutable { * * * ```js - * const { fromJS, isKeyed } = require('immutable@4.0.0-rc.8') + * const { fromJS, isKeyed } = require('immutable@4.0.0-rc.9') * function (key, value) { * return isKeyed(value) ? value.Map() : value.toList() * } @@ -4655,7 +4655,7 @@ declare module Immutable { * * * ```js - * const { fromJS, isKeyed } = require('immutable@4.0.0-rc.8') + * const { fromJS, isKeyed } = require('immutable@4.0.0-rc.9') * fromJS({ a: {b: [10, 20, 30]}, c: 40}, function (key, value, path) { * console.log(key, value, path) * return isKeyed(value) ? value.toOrderedMap() : value.toList() @@ -4672,7 +4672,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.8') + * const { Map } = require('immutable@4.0.0-rc.9') * let obj = { 1: "one" }; * Object.keys(obj); // [ "1" ] * assert.equal(obj["1"], obj[1]); // "one" === "one" @@ -4707,7 +4707,7 @@ declare module Immutable { * * * ```js - * const { Map, is } = require('immutable@4.0.0-rc.8') + * const { Map, is } = require('immutable@4.0.0-rc.9') * const map1 = Map({ a: 1, b: 1, c: 1 }) * const map2 = Map({ a: 1, b: 1, c: 1 }) * assert.equal(map1 !== map2, true) @@ -4755,7 +4755,7 @@ declare module Immutable { * * * ```js - * const { isImmutable, Map, List, Stack } = require('immutable@4.0.0-rc.8'); + * const { isImmutable, Map, List, Stack } = require('immutable@4.0.0-rc.9'); * isImmutable([]); // false * isImmutable({}); // false * isImmutable(Map()); // true @@ -4771,7 +4771,7 @@ declare module Immutable { * * * ```js - * const { isCollection, Map, List, Stack } = require('immutable@4.0.0-rc.8'); + * const { isCollection, Map, List, Stack } = require('immutable@4.0.0-rc.9'); * isCollection([]); // false * isCollection({}); // false * isCollection(Map()); // true @@ -4786,7 +4786,7 @@ declare module Immutable { * * * ```js - * const { isKeyed, Map, List, Stack } = require('immutable@4.0.0-rc.8'); + * const { isKeyed, Map, List, Stack } = require('immutable@4.0.0-rc.9'); * isKeyed([]); // false * isKeyed({}); // false * isKeyed(Map()); // true @@ -4801,7 +4801,7 @@ declare module Immutable { * * * ```js - * const { isIndexed, Map, List, Stack, Set } = require('immutable@4.0.0-rc.8'); + * const { isIndexed, Map, List, Stack, Set } = require('immutable@4.0.0-rc.9'); * isIndexed([]); // false * isIndexed({}); // false * isIndexed(Map()); // false @@ -4817,7 +4817,7 @@ declare module Immutable { * * * ```js - * const { isAssociative, Map, List, Stack, Set } = require('immutable@4.0.0-rc.8'); + * const { isAssociative, Map, List, Stack, Set } = require('immutable@4.0.0-rc.9'); * isAssociative([]); // false * isAssociative({}); // false * isAssociative(Map()); // true @@ -4834,7 +4834,7 @@ declare module Immutable { * * * ```js - * const { isOrdered, Map, OrderedMap, List, Set } = require('immutable@4.0.0-rc.8'); + * const { isOrdered, Map, OrderedMap, List, Set } = require('immutable@4.0.0-rc.9'); * isOrdered([]); // false * isOrdered({}); // false * isOrdered(Map()); // false @@ -4863,7 +4863,7 @@ declare module Immutable { * * * ```js - * const { get } = require('immutable@4.0.0-rc.8') + * const { get } = require('immutable@4.0.0-rc.9') * get([ 'dog', 'frog', 'cat' ], 2) // 'frog' * get({ x: 123, y: 456 }, 'x') // 123 * get({ x: 123, y: 456 }, 'z', 'ifNotSet') // 'ifNotSet' @@ -4887,7 +4887,7 @@ declare module Immutable { * * * ```js - * const { has } = require('immutable@4.0.0-rc.8') + * const { has } = require('immutable@4.0.0-rc.9') * has([ 'dog', 'frog', 'cat' ], 2) // true * has([ 'dog', 'frog', 'cat' ], 5) // false * has({ x: 123, y: 456 }, 'x') // true @@ -4905,7 +4905,7 @@ declare module Immutable { * * * ```js - * const { remove } = require('immutable@4.0.0-rc.8') + * const { remove } = require('immutable@4.0.0-rc.9') * const originalArray = [ 'dog', 'frog', 'cat' ] * remove(originalArray, 1) // [ 'dog', 'cat' ] * console.log(originalArray) // [ 'dog', 'frog', 'cat' ] @@ -4930,7 +4930,7 @@ declare module Immutable { * * * ```js - * const { set } = require('immutable@4.0.0-rc.8') + * const { set } = require('immutable@4.0.0-rc.9') * const originalArray = [ 'dog', 'frog', 'cat' ] * set(originalArray, 1, 'cow') // [ 'dog', 'cow', 'cat' ] * console.log(originalArray) // [ 'dog', 'frog', 'cat' ] @@ -4955,7 +4955,7 @@ declare module Immutable { * * * ```js - * const { update } = require('immutable@4.0.0-rc.8') + * const { update } = require('immutable@4.0.0-rc.9') * const originalArray = [ 'dog', 'frog', 'cat' ] * update(originalArray, 1, val => val.toUpperCase()) // [ 'dog', 'FROG', 'cat' ] * console.log(originalArray) // [ 'dog', 'frog', 'cat' ] @@ -4984,7 +4984,7 @@ declare module Immutable { * * * ```js - * const { getIn } = require('immutable@4.0.0-rc.8') + * const { getIn } = require('immutable@4.0.0-rc.9') * getIn({ x: { y: { z: 123 }}}, ['x', 'y', 'z']) // 123 * getIn({ x: { y: { z: 123 }}}, ['x', 'q', 'p'], 'ifNotSet') // 'ifNotSet' * ``` @@ -4999,7 +4999,7 @@ declare module Immutable { * * * ```js - * const { hasIn } = require('immutable@4.0.0-rc.8') + * const { hasIn } = require('immutable@4.0.0-rc.9') * hasIn({ x: { y: { z: 123 }}}, ['x', 'y', 'z']) // true * hasIn({ x: { y: { z: 123 }}}, ['x', 'q', 'p']) // false * ``` @@ -5014,7 +5014,7 @@ declare module Immutable { * * * ```js - * const { removeIn } = require('immutable@4.0.0-rc.8') + * const { removeIn } = require('immutable@4.0.0-rc.9') * const original = { x: { y: { z: 123 }}} * removeIn(original, ['x', 'y', 'z']) // { x: { y: {}}} * console.log(original) // { x: { y: { z: 123 }}} @@ -5031,7 +5031,7 @@ declare module Immutable { * * * ```js - * const { setIn } = require('immutable@4.0.0-rc.8') + * const { setIn } = require('immutable@4.0.0-rc.9') * const original = { x: { y: { z: 123 }}} * setIn(original, ['x', 'y', 'z'], 456) // { x: { y: { z: 456 }}} * console.log(original) // { x: { y: { z: 123 }}} @@ -5048,7 +5048,7 @@ declare module Immutable { * * * ```js - * const { setIn } = require('immutable@4.0.0-rc.8') + * const { setIn } = require('immutable@4.0.0-rc.9') * const original = { x: { y: { z: 123 }}} * setIn(original, ['x', 'y', 'z'], val => val * 6) // { x: { y: { z: 738 }}} * console.log(original) // { x: { y: { z: 123 }}} @@ -5065,7 +5065,7 @@ declare module Immutable { * * * ```js - * const { merge } = require('immutable@4.0.0-rc.8') + * const { merge } = require('immutable@4.0.0-rc.9') * const original = { x: 123, y: 456 } * merge(original, { y: 789, z: 'abc' }) // { x: 123, y: 789, z: 'abc' } * console.log(original) // { x: { y: { z: 123 }}} @@ -5085,7 +5085,7 @@ declare module Immutable { * * * ```js - * const { mergeWith } = require('immutable@4.0.0-rc.8') + * const { mergeWith } = require('immutable@4.0.0-rc.9') * const original = { x: 123, y: 456 } * mergeWith( * (oldVal, newVal) => oldVal + newVal, @@ -5110,7 +5110,7 @@ declare module Immutable { * * * ```js - * const { merge } = require('immutable@4.0.0-rc.8') + * const { merge } = require('immutable@4.0.0-rc.9') * const original = { x: { y: 123 }} * merge(original, { x: { z: 456 }}) // { x: { y: 123, z: 456 }} * console.log(original) // { x: { y: 123 }} @@ -5131,7 +5131,7 @@ declare module Immutable { * * * ```js - * const { merge } = require('immutable@4.0.0-rc.8') + * const { merge } = require('immutable@4.0.0-rc.9') * const original = { x: { y: 123 }} * mergeDeepWith( * (oldVal, newVal) => oldVal + newVal, diff --git a/dist/immutable.es.js b/dist/immutable.es.js index c976758cc9..7c837e1604 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -5697,7 +5697,7 @@ function defaultConverter(k, v) { return isKeyed(v) ? v.toMap() : v.toList(); } -var version = "4.0.0-rc.8"; +var version = "4.0.0-rc.9"; // Functional read/write API var Immutable = { diff --git a/dist/immutable.js b/dist/immutable.js index ef17b445ed..4440113161 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -5703,7 +5703,7 @@ function defaultConverter(k, v) { return isKeyed(v) ? v.toMap() : v.toList(); } -var version = "4.0.0-rc.8"; +var version = "4.0.0-rc.9"; // Functional read/write API var Immutable = { diff --git a/dist/immutable.min.js b/dist/immutable.min.js index 278aa1cb01..a3e9f4d637 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -34,5 +34,5 @@ return this.__iterator(ze)},butLast:function(){return this.slice(0,-1)},isEmpty: return 0===t?this:this.slice(0,-Math.max(0,t))},skipWhile:function(t,r){return nt(this,Q(this,t,r,!0))},skipUntil:function(t,r){return this.skipWhile(Nr(t),r)},sortBy:function(t,r){return nt(this,$(this,r,t))},take:function(t){return this.slice(0,Math.max(0,t))},takeLast:function(t){return this.slice(-Math.max(0,t))},takeWhile:function(t,r){return nt(this,Y(this,t,r))},takeUntil:function(t,r){return this.takeWhile(Nr(t),r)},update:function(t){return t(this)},valueSeq:function(){return this.toIndexedSeq()},hashCode:function(){return this.__hash||(this.__hash=Vr(this))}});var An=ye.prototype;An[he]=!0,An[Oe]=An.values,An.toJSON=An.toArray,An.__toStringMapper=vt,An.inspect=An.toSource=function(){return""+this},An.chain=An.flatMap,An.contains=An.includes,Mr(de,{flip:function(){return nt(this,B(this))},mapEntries:function(t,r){var e=this,n=0;return nt(this,this.toSeq().map(function(i,o){return t.call(r,[o,i],n++,e)}).fromEntrySeq())},mapKeys:function(t,r){var e=this;return nt(this,this.toSeq().flip().map(function(n,i){return t.call(r,n,i,e)}).flip())}});var jn=de.prototype;jn[pe]=!0,jn[Oe]=An.entries,jn.toJSON=Cr,jn.__toStringMapper=function(t,r){return vt(r)+": "+vt(t)},Mr(ge,{toKeyedSeq:function(){return new Xe(this,!1)},filter:function(t,r){return nt(this,P(this,t,r,!1))},findIndex:function(t,r){var e=this.findEntry(t,r);return e?e[0]:-1},indexOf:function(t){var r=this.keyOf(t);return void 0===r?-1:r},lastIndexOf:function(t){var r=this.lastKeyOf(t);return void 0===r?-1:r},reverse:function(){return nt(this,N(this,!1))},slice:function(t,r){return nt(this,V(this,t,r,!1))},splice:function(t,r){var e=arguments.length;if(r=Math.max(r||0,0),0===e||2===e&&!r)return this;t=a(t,t<0?this.count():this.size);var n=this.slice(0,t);return nt(this,1===e?n:n.concat(ct(arguments,2),this.slice(t+r)))},findLastIndex:function(t,r){var e=this.findLastEntry(t,r);return e?e[0]:-1},first:function(){return this.get(0)},flatten:function(t){return nt(this,F(this,t,!1))},get:function(t,r){return t=o(this,t), t<0||this.size===1/0||void 0!==this.size&&t>this.size?r:this.find(function(r,e){return e===t},void 0,r)},has:function(t){return(t=o(this,t))>=0&&(void 0!==this.size?this.size===1/0||t Date: Wed, 18 Oct 2017 22:17:23 +0000 Subject: [PATCH 079/242] Deploy 140c39926ff0efb33e5ef05a660522d03736a861 to NPM branch --- dist/immutable.es.js | 3 +-- dist/immutable.js | 3 +-- dist/immutable.min.js | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/dist/immutable.es.js b/dist/immutable.es.js index 7c837e1604..3ac12aac32 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -2397,12 +2397,11 @@ var MapPrototype = Map.prototype; MapPrototype[IS_MAP_SENTINEL] = true; MapPrototype[DELETE] = MapPrototype.remove; MapPrototype.removeAll = MapPrototype.deleteAll; -MapPrototype.concat = MapPrototype.merge; MapPrototype.setIn = setIn$$1; MapPrototype.removeIn = MapPrototype.deleteIn = deleteIn; MapPrototype.update = update$$1; MapPrototype.updateIn = updateIn$1; -MapPrototype.merge = merge; +MapPrototype.merge = MapPrototype.concat = merge; MapPrototype.mergeWith = mergeWith; MapPrototype.mergeDeep = mergeDeep; MapPrototype.mergeDeepWith = mergeDeepWith; diff --git a/dist/immutable.js b/dist/immutable.js index 4440113161..71c278b1dc 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -2403,12 +2403,11 @@ var MapPrototype = Map.prototype; MapPrototype[IS_MAP_SENTINEL] = true; MapPrototype[DELETE] = MapPrototype.remove; MapPrototype.removeAll = MapPrototype.deleteAll; -MapPrototype.concat = MapPrototype.merge; MapPrototype.setIn = setIn$$1; MapPrototype.removeIn = MapPrototype.deleteIn = deleteIn; MapPrototype.update = update$$1; MapPrototype.updateIn = updateIn$1; -MapPrototype.merge = merge; +MapPrototype.merge = MapPrototype.concat = merge; MapPrototype.mergeWith = mergeWith; MapPrototype.mergeDeep = mergeDeep; MapPrototype.mergeDeepWith = mergeDeepWith; diff --git a/dist/immutable.min.js b/dist/immutable.min.js index a3e9f4d637..358d879257 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -21,7 +21,7 @@ r.prototype.__iterator=function(t,r){var e=this._cache;if(e){var n=e.length,i=0; r.prototype.has=function(t){return qe.call(this._object,t)},r.prototype.__iterate=function(t,r){for(var e=this,n=this._object,i=this._keys,o=i.length,u=0;u!==o;){var s=i[r?o-++u:u++];if(t(n[s],s,e)===!1)break}return u},r.prototype.__iterator=function(t,r){var e=this._object,n=this._keys,i=n.length,o=0;return new Ee(function(){if(o===i)return z();var u=n[r?i-++o:o++];return w(t,u,e[u])})},r}(De);Re.prototype[le]=!0;var Ue,Ke,Te=function(t){function r(t){this._collection=t,this.size=t.length||t.size}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.prototype.__iterateUncached=function(t,r){var e=this;if(r)return this.cacheResult().__iterate(t,r);var n=this._collection,i=b(n),o=0;if(I(i))for(var u;!(u=i.next()).done&&t(u.value,o++,e)!==!1;);return o},r.prototype.__iteratorUncached=function(t,r){if(r)return this.cacheResult().__iterator(t,r);var e=this._collection,n=b(e);if(!I(n))return new Ee(z);var i=0;return new Ee(function(){var r=n.next();return r.done?r:w(t,i++,r.value)})},r}(xe),Ce=function(t){function r(t){this._iterator=t,this._iteratorCache=[]}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.prototype.__iterateUncached=function(t,r){var e=this;if(r)return this.cacheResult().__iterate(t,r);for(var n=this._iterator,i=this._iteratorCache,o=0;o=n.length){var r=e.next();if(r.done)return r;n[i]=r.value}return w(t,i,n[i++])})},r}(xe),Le="function"==typeof Math.imul&&Math.imul(4294967295,2)===-2?Math.imul:function(t,r){t|=0,r|=0;var e=65535&t,n=65535&r;return e*n+((t>>>16)*n+e*(r>>>16)<<16>>>0)|0},Be=Object.isExtensible,We=function(){try{return Object.defineProperty({},"@",{}),!0}catch(t){return!1}}(),Ne="function"==typeof WeakMap ;Ne&&(Ke=new WeakMap);var Pe=0,Je="__immutablehash__";"function"==typeof Symbol&&(Je=Symbol(Je));var He=16,Ve=255,Ye=0,Qe={},Xe=function(t){function r(t,r){this._iter=t,this._useKeys=r,this.size=t.size}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.prototype.get=function(t,r){return this._iter.get(t,r)},r.prototype.has=function(t){return this._iter.has(t)},r.prototype.valueSeq=function(){return this._iter.valueSeq()},r.prototype.reverse=function(){var t=this,r=N(this,!0);return this._useKeys||(r.valueSeq=function(){return t._iter.toSeq().reverse()}),r},r.prototype.map=function(t,r){var e=this,n=W(this,t,r);return this._useKeys||(n.valueSeq=function(){return e._iter.toSeq().map(t,r)}),n},r.prototype.__iterate=function(t,r){var e=this;return this._iter.__iterate(function(r,n){return t(r,n,e)},r)},r.prototype.__iterator=function(t,r){return this._iter.__iterator(t,r)},r}(De);Xe.prototype[le]=!0;var Fe=function(t){function r(t){this._iter=t,this.size=t.size}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.prototype.includes=function(t){return this._iter.includes(t)},r.prototype.__iterate=function(t,r){var e=this,n=0;return r&&i(this),this._iter.__iterate(function(i){return t(i,r?e.size-++n:n++,e)},r)},r.prototype.__iterator=function(t,r){var e=this,n=this._iter.__iterator(ze,r),o=0;return r&&i(this),new Ee(function(){var i=n.next();return i.done?i:w(t,r?e.size-++o:o++,i.value,i)})},r}(xe),Ge=function(t){function r(t){this._iter=t,this.size=t.size}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.prototype.has=function(t){return this._iter.includes(t)},r.prototype.__iterate=function(t,r){var e=this;return this._iter.__iterate(function(r){return t(r,r,e)},r)},r.prototype.__iterator=function(t,r){var e=this._iter.__iterator(ze,r);return new Ee(function(){var r=e.next();return r.done?r:w(t,r.value,r.value,r)})},r}(Ae),Ze=function(t){function r(t){this._iter=t,this.size=t.size} return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.prototype.entrySeq=function(){return this._iter.toSeq()},r.prototype.__iterate=function(t,r){var e=this;return this._iter.__iterate(function(r){if(r){it(r);var n=_(r);return t(n?r.get(1):r[1],n?r.get(0):r[0],e)}},r)},r.prototype.__iterator=function(t,r){var e=this._iter.__iterator(ze,r);return new Ee(function(){for(;;){var r=e.next();if(r.done)return r;var n=r.value;if(n){it(n);var i=_(n);return w(t,i?n.get(0):n[0],i?n.get(1):n[1],r)}}})},r}(De);Fe.prototype.cacheResult=Xe.prototype.cacheResult=Ge.prototype.cacheResult=Ze.prototype.cacheResult=st;var $e=function(t){function r(r){return null===r||void 0===r?Zt():Qt(r)&&!d(r)?r:Zt().withMutations(function(e){var n=t(r);ht(n.size),n.forEach(function(t,r){return e.set(r,t)})})}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.of=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return Zt().withMutations(function(r){for(var e=0;e=t.length)throw Error("Missing value for key: "+t[e]);r.set(t[e],t[e+1])}})},r.prototype.toString=function(){return this.__toString("Map {","}")},r.prototype.get=function(t,r){return this._root?this._root.get(0,void 0,t,r):r},r.prototype.set=function(t,r){return $t(this,t,r)},r.prototype.remove=function(t){return $t(this,t,ae)},r.prototype.deleteAll=function(t){var r=ye(t);return 0===r.size?this:this.withMutations(function(t){r.forEach(function(r){return t.remove(r)})})},r.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):Zt()},r.prototype.sort=function(t){return mn($(this,t))},r.prototype.sortBy=function(t,r){return mn($(this,r,t))},r.prototype.__iterator=function(t,r){return new cn(this,t,r)},r.prototype.__iterate=function(t,r){var e=this,n=0;return this._root&&this._root.iterate(function(r){return n++,t(r[1],r[0],e)},r),n},r.prototype.__ensureOwner=function(t){ -return t===this.__ownerID?this:t?Gt(this.size,this._root,t,this.__hash):0===this.size?Zt():(this.__ownerID=t,this.__altered=!1,this)},r}(de);$e.isMap=Qt;var tn="@@__IMMUTABLE_MAP__@@",rn=$e.prototype;rn[tn]=!0,rn.delete=rn.remove,rn.removeAll=rn.deleteAll,rn.concat=rn.merge,rn.setIn=bt,rn.removeIn=rn.deleteIn=Et,rn.update=Mt,rn.updateIn=Dt,rn.merge=xt,rn.mergeWith=At,rn.mergeDeep=Bt,rn.mergeDeepWith=Wt,rn.mergeIn=Nt,rn.mergeDeepIn=Pt,rn.withMutations=Jt,rn.wasAltered=Yt,rn.asImmutable=Vt,rn["@@transducer/init"]=rn.asMutable=Ht,rn["@@transducer/step"]=function(t,r){return t.set(r[0],r[1])},rn["@@transducer/result"]=function(t){return t.asImmutable()};var en=function(t,r){this.ownerID=t,this.entries=r};en.prototype.get=function(t,r,e,n){for(var i=this.entries,o=0,u=i.length;o=fn)return nr(t,c,i,o);var _=t&&t===this.ownerID,l=_?c:ct(c);return p?a?f===h-1?l.pop():l[f]=l.pop():l[f]=[i,o]:l.push([i,o]),_?(this.entries=l,this):new en(t,l)}};var nn=function(t,r,e){this.ownerID=t,this.bitmap=r,this.nodes=e};nn.prototype.get=function(t,r,e,n){void 0===r&&(r=U(e));var i=1<<((0===t?r:r>>>t)&se),o=this.bitmap;return 0==(o&i)?n:this.nodes[ur(o&i-1)].get(t+oe,r,e,n)},nn.prototype.update=function(t,r,e,n,i,o,u){void 0===e&&(e=U(n));var s=(0===r?e:e>>>r)&se,a=1<=hn)return or(t,p,c,s,l);if(f&&!l&&2===p.length&&rr(p[1^h]))return p[1^h];if(f&&l&&1===p.length&&rr(l))return l;var v=t&&t===this.ownerID,y=f?l?c:c^a:c|a,d=f?l?sr(p,h,l,v):cr(p,h,v):ar(p,h,l,v);return v?(this.bitmap=y,this.nodes=d,this):new nn(t,y,d)};var on=function(t,r,e){this.ownerID=t,this.count=r,this.nodes=e};on.prototype.get=function(t,r,e,n){ +return t===this.__ownerID?this:t?Gt(this.size,this._root,t,this.__hash):0===this.size?Zt():(this.__ownerID=t,this.__altered=!1,this)},r}(de);$e.isMap=Qt;var tn="@@__IMMUTABLE_MAP__@@",rn=$e.prototype;rn[tn]=!0,rn.delete=rn.remove,rn.removeAll=rn.deleteAll,rn.setIn=bt,rn.removeIn=rn.deleteIn=Et,rn.update=Mt,rn.updateIn=Dt,rn.merge=rn.concat=xt,rn.mergeWith=At,rn.mergeDeep=Bt,rn.mergeDeepWith=Wt,rn.mergeIn=Nt,rn.mergeDeepIn=Pt,rn.withMutations=Jt,rn.wasAltered=Yt,rn.asImmutable=Vt,rn["@@transducer/init"]=rn.asMutable=Ht,rn["@@transducer/step"]=function(t,r){return t.set(r[0],r[1])},rn["@@transducer/result"]=function(t){return t.asImmutable()};var en=function(t,r){this.ownerID=t,this.entries=r};en.prototype.get=function(t,r,e,n){for(var i=this.entries,o=0,u=i.length;o=fn)return nr(t,c,i,o);var _=t&&t===this.ownerID,l=_?c:ct(c);return p?a?f===h-1?l.pop():l[f]=l.pop():l[f]=[i,o]:l.push([i,o]),_?(this.entries=l,this):new en(t,l)}};var nn=function(t,r,e){this.ownerID=t,this.bitmap=r,this.nodes=e};nn.prototype.get=function(t,r,e,n){void 0===r&&(r=U(e));var i=1<<((0===t?r:r>>>t)&se),o=this.bitmap;return 0==(o&i)?n:this.nodes[ur(o&i-1)].get(t+oe,r,e,n)},nn.prototype.update=function(t,r,e,n,i,o,u){void 0===e&&(e=U(n));var s=(0===r?e:e>>>r)&se,a=1<=hn)return or(t,p,c,s,l);if(f&&!l&&2===p.length&&rr(p[1^h]))return p[1^h];if(f&&l&&1===p.length&&rr(l))return l;var v=t&&t===this.ownerID,y=f?l?c:c^a:c|a,d=f?l?sr(p,h,l,v):cr(p,h,v):ar(p,h,l,v);return v?(this.bitmap=y,this.nodes=d,this):new nn(t,y,d)};var on=function(t,r,e){this.ownerID=t,this.count=r,this.nodes=e};on.prototype.get=function(t,r,e,n){ void 0===r&&(r=U(e));var i=(0===t?r:r>>>t)&se,o=this.nodes[i];return o?o.get(t+oe,r,e,n):n},on.prototype.update=function(t,r,e,n,i,o,u){void 0===e&&(e=U(n));var s=(0===r?e:e>>>r)&se,a=i===ae,c=this.nodes,f=c[s];if(a&&!f)return this;var h=tr(f,t,r+oe,e,n,i,o,u);if(h===f)return this;var p=this.count;if(f){if(!h&&--p0&&i=0&&t>>r&se;if(n>=this.array.length)return new yn([],t);var i,o=0===n;if(r>0){var u=this.array[n];if((i=u&&u.removeBefore(t,r-oe,e))===u&&o)return this}if(o&&!i)return this;var s=yr(this,t);if(!o)for(var a=0;a>>r&se;if(n>=this.array.length)return this;var i;if(r>0){var o=this.array[n];if((i=o&&o.removeAfter(t,r-oe,e))===o&&n===this.array.length-1)return this}var u=yr(this,t);return u.array.splice(n+1),i&&(u.array[n]=i),u};var dn,gn={},mn=function(t){function r(t){ From dce702d60bc74b5513f4d34cede1e94666710e2c Mon Sep 17 00:00:00 2001 From: Travis CI Date: Wed, 18 Oct 2017 22:28:50 +0000 Subject: [PATCH 080/242] Deploy 4b695f1f0210fa5f27d2111bad44327732e7019d to NPM branch --- dist/immutable.es.js | 22 +++++++++++----------- dist/immutable.js | 22 +++++++++++----------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/dist/immutable.es.js b/dist/immutable.es.js index 3ac12aac32..d8d54b3394 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -217,7 +217,7 @@ function iteratorValue(type, k, v, iteratorResult) { ? (iteratorResult.value = value) : (iteratorResult = { value: value, - done: false + done: false, }); return iteratorResult; } @@ -892,7 +892,7 @@ function hashJSObj(obj) { enumerable: false, configurable: false, writable: false, - value: hashed + value: hashed, }); } else if ( obj.propertyIsEnumerable !== undefined && @@ -2844,7 +2844,7 @@ function mapIteratorFrame(node, prev) { return { node: node, index: 0, - __prev: prev + __prev: prev, }; } @@ -3899,7 +3899,7 @@ var Stack = (function (IndexedCollection$$1) { for (var ii = arguments.length - 1; ii >= 0; ii--) { head = { value: arguments$1[ii], - next: head + next: head, }; } if (this.__ownerID) { @@ -3927,7 +3927,7 @@ var Stack = (function (IndexedCollection$$1) { newSize++; head = { value: value, - next: head + next: head, }; }, /* reverse */ true); if (this.__ownerID) { @@ -4973,7 +4973,7 @@ mixin(Collection, { hashCode: function hashCode() { return this.__hash || (this.__hash = hashCollection(this)); - } + }, // ### Internal @@ -5022,7 +5022,7 @@ mixin(KeyedCollection, { .map(function (k, v) { return mapper.call(context, k, v, this$1); }) .flip() ); - } + }, }); var KeyedCollectionPrototype = KeyedCollection.prototype; @@ -5159,7 +5159,7 @@ mixin(IndexedCollection, { var collections = arrCopy(arguments); collections[0] = this; return reify(this, zipWithFactory(this, zipper, collections)); - } + }, }); var IndexedCollectionPrototype = IndexedCollection.prototype; @@ -5181,7 +5181,7 @@ mixin(SetCollection, { keySeq: function keySeq() { return this.valueSeq(); - } + }, }); SetCollection.prototype.has = CollectionPrototype.includes; @@ -5548,7 +5548,7 @@ function setProp(prototype, name) { set: function(value) { invariant(this.__ownerID, 'Cannot set on an immutable record.'); this.set(name, value); - } + }, }); } catch (error) { // Object.defineProperty failed. Probably IE8. @@ -5743,7 +5743,7 @@ var Immutable = { set: set, setIn: setIn$1, update: update$1, - updateIn: updateIn + updateIn: updateIn, }; // Note: Iterable is deprecated diff --git a/dist/immutable.js b/dist/immutable.js index 71c278b1dc..fb76289a52 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -223,7 +223,7 @@ function iteratorValue(type, k, v, iteratorResult) { ? (iteratorResult.value = value) : (iteratorResult = { value: value, - done: false + done: false, }); return iteratorResult; } @@ -898,7 +898,7 @@ function hashJSObj(obj) { enumerable: false, configurable: false, writable: false, - value: hashed + value: hashed, }); } else if ( obj.propertyIsEnumerable !== undefined && @@ -2850,7 +2850,7 @@ function mapIteratorFrame(node, prev) { return { node: node, index: 0, - __prev: prev + __prev: prev, }; } @@ -3905,7 +3905,7 @@ var Stack = (function (IndexedCollection$$1) { for (var ii = arguments.length - 1; ii >= 0; ii--) { head = { value: arguments$1[ii], - next: head + next: head, }; } if (this.__ownerID) { @@ -3933,7 +3933,7 @@ var Stack = (function (IndexedCollection$$1) { newSize++; head = { value: value, - next: head + next: head, }; }, /* reverse */ true); if (this.__ownerID) { @@ -4979,7 +4979,7 @@ mixin(Collection, { hashCode: function hashCode() { return this.__hash || (this.__hash = hashCollection(this)); - } + }, // ### Internal @@ -5028,7 +5028,7 @@ mixin(KeyedCollection, { .map(function (k, v) { return mapper.call(context, k, v, this$1); }) .flip() ); - } + }, }); var KeyedCollectionPrototype = KeyedCollection.prototype; @@ -5165,7 +5165,7 @@ mixin(IndexedCollection, { var collections = arrCopy(arguments); collections[0] = this; return reify(this, zipWithFactory(this, zipper, collections)); - } + }, }); var IndexedCollectionPrototype = IndexedCollection.prototype; @@ -5187,7 +5187,7 @@ mixin(SetCollection, { keySeq: function keySeq() { return this.valueSeq(); - } + }, }); SetCollection.prototype.has = CollectionPrototype.includes; @@ -5554,7 +5554,7 @@ function setProp(prototype, name) { set: function(value) { invariant(this.__ownerID, 'Cannot set on an immutable record.'); this.set(name, value); - } + }, }); } catch (error) { // Object.defineProperty failed. Probably IE8. @@ -5749,7 +5749,7 @@ var Immutable = { set: set, setIn: setIn$1, update: update$1, - updateIn: updateIn + updateIn: updateIn, }; // Note: Iterable is deprecated From 79406311c3a9e704377a2d1e96973ae2e3d11cc1 Mon Sep 17 00:00:00 2001 From: Travis CI Date: Wed, 18 Oct 2017 23:42:46 +0000 Subject: [PATCH 081/242] Deploy fa9a247016f22f731445a09b65f5f8b07fc584b0 to NPM branch --- dist/immutable-nonambient.d.ts | 12 ++++++------ dist/immutable.d.ts | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/dist/immutable-nonambient.d.ts b/dist/immutable-nonambient.d.ts index 1f089c5914..23d46298d3 100644 --- a/dist/immutable-nonambient.d.ts +++ b/dist/immutable-nonambient.d.ts @@ -4960,7 +4960,7 @@ * update(originalArray, 1, val => val.toUpperCase()) // [ 'dog', 'FROG', 'cat' ] * console.log(originalArray) // [ 'dog', 'frog', 'cat' ] * const originalObject = { x: 123, y: 456 } - * set(originalObject, 'x', val => val * 6) // { x: 738, y: 456 } + * update(originalObject, 'x', val => val * 6) // { x: 738, y: 456 } * console.log(originalObject) // { x: 123, y: 456 } * ``` */ @@ -5048,9 +5048,9 @@ * * * ```js - * const { setIn } = require('immutable@4.0.0-rc.9') + * const { updateIn } = require('immutable@4.0.0-rc.9') * const original = { x: { y: { z: 123 }}} - * setIn(original, ['x', 'y', 'z'], val => val * 6) // { x: { y: { z: 738 }}} + * updateIn(original, ['x', 'y', 'z'], val => val * 6) // { x: { y: { z: 738 }}} * console.log(original) // { x: { y: { z: 123 }}} * ``` */ @@ -5110,9 +5110,9 @@ * * * ```js - * const { merge } = require('immutable@4.0.0-rc.9') + * const { mergeDeep } = require('immutable@4.0.0-rc.9') * const original = { x: { y: 123 }} - * merge(original, { x: { z: 456 }}) // { x: { y: 123, z: 456 }} + * mergeDeep(original, { x: { z: 456 }}) // { x: { y: 123, z: 456 }} * console.log(original) // { x: { y: 123 }} * ``` */ @@ -5131,7 +5131,7 @@ * * * ```js - * const { merge } = require('immutable@4.0.0-rc.9') + * const { mergeDeepWith } = require('immutable@4.0.0-rc.9') * const original = { x: { y: 123 }} * mergeDeepWith( * (oldVal, newVal) => oldVal + newVal, diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index 777264e384..61ebf8e8cf 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -4960,7 +4960,7 @@ declare module Immutable { * update(originalArray, 1, val => val.toUpperCase()) // [ 'dog', 'FROG', 'cat' ] * console.log(originalArray) // [ 'dog', 'frog', 'cat' ] * const originalObject = { x: 123, y: 456 } - * set(originalObject, 'x', val => val * 6) // { x: 738, y: 456 } + * update(originalObject, 'x', val => val * 6) // { x: 738, y: 456 } * console.log(originalObject) // { x: 123, y: 456 } * ``` */ @@ -5048,9 +5048,9 @@ declare module Immutable { * * * ```js - * const { setIn } = require('immutable@4.0.0-rc.9') + * const { updateIn } = require('immutable@4.0.0-rc.9') * const original = { x: { y: { z: 123 }}} - * setIn(original, ['x', 'y', 'z'], val => val * 6) // { x: { y: { z: 738 }}} + * updateIn(original, ['x', 'y', 'z'], val => val * 6) // { x: { y: { z: 738 }}} * console.log(original) // { x: { y: { z: 123 }}} * ``` */ @@ -5110,9 +5110,9 @@ declare module Immutable { * * * ```js - * const { merge } = require('immutable@4.0.0-rc.9') + * const { mergeDeep } = require('immutable@4.0.0-rc.9') * const original = { x: { y: 123 }} - * merge(original, { x: { z: 456 }}) // { x: { y: 123, z: 456 }} + * mergeDeep(original, { x: { z: 456 }}) // { x: { y: 123, z: 456 }} * console.log(original) // { x: { y: 123 }} * ``` */ @@ -5131,7 +5131,7 @@ declare module Immutable { * * * ```js - * const { merge } = require('immutable@4.0.0-rc.9') + * const { mergeDeepWith } = require('immutable@4.0.0-rc.9') * const original = { x: { y: 123 }} * mergeDeepWith( * (oldVal, newVal) => oldVal + newVal, From ff7d0c985ac9b1f96edc08657b12044885daa287 Mon Sep 17 00:00:00 2001 From: Travis CI Date: Thu, 19 Oct 2017 02:56:00 +0000 Subject: [PATCH 082/242] Deploy e9c7a1d84449d65c45bc81416be11ce3e59cc1ca to NPM branch --- dist/immutable-nonambient.d.ts | 7 +++++++ dist/immutable.d.ts | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/dist/immutable-nonambient.d.ts b/dist/immutable-nonambient.d.ts index 23d46298d3..c14b331583 100644 --- a/dist/immutable-nonambient.d.ts +++ b/dist/immutable-nonambient.d.ts @@ -1638,6 +1638,13 @@ /** * Returns a Set excluding any values contained within `collections`. * + * + * ```js + * const { OrderedSet } = require('immutable@4.0.0-rc.9') + * OrderedSet([ 1, 2, 3 ]).subtract([1, 3]) + * // OrderedSet [2] + * ``` + * * Note: `subtract` can be used in `withMutations`. */ subtract(...collections: Array>): this; diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index 61ebf8e8cf..87e396076c 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -1638,6 +1638,13 @@ declare module Immutable { /** * Returns a Set excluding any values contained within `collections`. * + * + * ```js + * const { OrderedSet } = require('immutable@4.0.0-rc.9') + * OrderedSet([ 1, 2, 3 ]).subtract([1, 3]) + * // OrderedSet [2] + * ``` + * * Note: `subtract` can be used in `withMutations`. */ subtract(...collections: Array>): this; From 5f7950ca6e07db42a307050c12376b7c67e54b6d Mon Sep 17 00:00:00 2001 From: Travis CI Date: Thu, 19 Oct 2017 02:59:08 +0000 Subject: [PATCH 083/242] Deploy 0d34c76b68d51712488beabddb5109af6dc2e1ec to NPM branch --- dist/immutable-nonambient.d.ts | 242 ++++++++++++++++----------------- dist/immutable.d.ts | 242 ++++++++++++++++----------------- 2 files changed, 242 insertions(+), 242 deletions(-) diff --git a/dist/immutable-nonambient.d.ts b/dist/immutable-nonambient.d.ts index c14b331583..0cb462d2b6 100644 --- a/dist/immutable-nonambient.d.ts +++ b/dist/immutable-nonambient.d.ts @@ -120,7 +120,7 @@ * * * ```js - * const { List } = require('immutable@4.0.0-rc.9'); + * const { List } = require('immutable'); * List.isList([]); // false * List.isList(List()); // true * ``` @@ -132,7 +132,7 @@ * * * ```js - * const { List } = require('immutable@4.0.0-rc.9'); + * const { List } = require('immutable'); * List.of(1, 2, 3, 4) * // List [ 1, 2, 3, 4 ] * ``` @@ -141,7 +141,7 @@ * * * ```js - * const { List } = require('immutable@4.0.0-rc.9'); + * const { List } = require('immutable'); * List.of({x:1}, 2, [3], 4) * // List [ { x: 1 }, 2, [ 3 ], 4 ] * ``` @@ -155,7 +155,7 @@ * * * ```js - * const { List, Set } = require('immutable@4.0.0-rc.9') + * const { List, Set } = require('immutable') * * const emptyList = List() * // List [] @@ -201,7 +201,7 @@ * enough to include the `index`. * * * ```js * const originalList = List([ 0 ]); @@ -234,7 +234,7 @@ * Note: `delete` cannot be safely used in IE8 * * * ```js * List([ 0, 1, 2, 3, 4 ]).delete(0); @@ -258,7 +258,7 @@ * This is synonymous with `list.splice(index, 0, value)`. * * * ```js * List([ 0, 1, 2, 3, 4 ]).insert(6, 5) @@ -276,7 +276,7 @@ * Returns a new List with 0 size and no values in constant time. * * * ```js * List([ 1, 2, 3, 4 ]).clear() @@ -292,7 +292,7 @@ * List's `size`. * * * ```js * List([ 1, 2, 3, 4 ]).push(5) @@ -325,7 +325,7 @@ * values ahead to higher indices. * * * ```js * List([ 2, 3, 4]).unshift(1); @@ -345,7 +345,7 @@ * value in this List. * * * ```js * List([ 0, 1, 2, 3, 4 ]).shift(); @@ -366,7 +366,7 @@ * List. `v.update(-1)` updates the last item in the List. * * * ```js * const list = List([ 'a', 'b', 'c' ]) @@ -380,7 +380,7 @@ * For example, to sum a List after mapping and filtering: * * * ```js * function sum(collection) { @@ -426,7 +426,7 @@ * * * ```js - * const { List } = require('immutable@4.0.0-rc.9') + * const { List } = require('immutable') * const list = List([ 0, 1, 2, List([ 3, 4 ])]) * list.setIn([3, 0], 999); * // List [ 0, 1, 2, List [ 999, 4 ] ] @@ -438,7 +438,7 @@ * * * ```js - * const { List } = require('immutable@4.0.0-rc.9') + * const { List } = require('immutable') * const list = List([ 0, 1, 2, { plain: 'object' }]) * list.setIn([3, 'plain'], 'value'); * // List([ 0, 1, 2, { plain: 'value' }]) @@ -454,7 +454,7 @@ * * * ```js - * const { List } = require('immutable@4.0.0-rc.9') + * const { List } = require('immutable') * const list = List([ 0, 1, 2, List([ 3, 4 ])]) * list.deleteIn([3, 0]); * // List [ 0, 1, 2, List [ 4 ] ] @@ -466,7 +466,7 @@ * * * ```js - * const { List } = require('immutable@4.0.0-rc.9') + * const { List } = require('immutable') * const list = List([ 0, 1, 2, { plain: 'object' }]) * list.removeIn([3, 'plain']); * // List([ 0, 1, 2, {}]) @@ -550,7 +550,7 @@ * `mapper` function. * * * ```js * List([ 1, 2 ]).map(x => 10 * x) @@ -597,7 +597,7 @@ * Like `zipWith`, but using the default `zipper`: creating an `Array`. * * * ```js * const a = List([ 1, 2, 3 ]); @@ -616,7 +616,7 @@ * exhausted. Missing values from shorter collections are filled with `undefined`. * * * ```js * const a = List([ 1, 2 ]); @@ -637,7 +637,7 @@ * custom `zipper` function. * * * ```js * const a = List([ 1, 2, 3 ]); @@ -678,7 +678,7 @@ * * * ```js - * const { Map, List } = require('immutable@4.0.0-rc.9'); + * const { Map, List } = require('immutable'); * Map().set(List([ 1 ]), 'listofone').get(List([ 1 ])); * // 'listofone' * ``` @@ -696,7 +696,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.9') + * const { Map } = require('immutable') * Map.isMap({}) // false * Map.isMap(Map()) // true * ``` @@ -708,7 +708,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.9') + * const { Map } = require('immutable') * Map.of( * 'key', 'value', * 'numerical value', 3, @@ -730,7 +730,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.9') + * const { Map } = require('immutable') * Map({ key: "value" }) * Map([ [ "key", "value" ] ]) * ``` @@ -740,7 +740,7 @@ * quote-less shorthand, while Immutable Maps accept keys of any type. * * * ```js * let obj = { 1: "one" } @@ -776,7 +776,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.9') + * const { Map } = require('immutable') * const originalMap = Map() * const newerMap = originalMap.set('key', 'value') * const newestMap = newerMap.set('key', 'newer value') @@ -801,7 +801,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.9') + * const { Map } = require('immutable') * const originalMap = Map({ * key: 'value', * otherKey: 'other value' @@ -823,7 +823,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.9') + * const { Map } = require('immutable') * const names = Map({ a: "Aaron", b: "Barry", c: "Connor" }) * names.deleteAll([ 'a', 'c' ]) * // Map { "b": "Barry" } @@ -841,7 +841,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.9') + * const { Map } = require('immutable') * Map({ key: 'value' }).clear() * // Map {} * ``` @@ -858,7 +858,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.9') + * const { Map } = require('immutable') * const aMap = Map({ key: 'value' }) * const newMap = aMap.update('key', value => value + value) * // Map { "key": "valuevalue" } @@ -869,7 +869,7 @@ * `update` and `push` can be used together: * * * ```js * const aMap = Map({ nestedList: List([ 1, 2, 3 ]) }) @@ -881,7 +881,7 @@ * function when the value at the key does not exist in the Map. * * * ```js * const aMap = Map({ key: 'value' }) @@ -894,7 +894,7 @@ * is provided. * * * ```js * const aMap = Map({ apples: 10 }) @@ -910,7 +910,7 @@ * The previous example behaves differently when written with default values: * * * ```js * const aMap = Map({ apples: 10 }) @@ -922,7 +922,7 @@ * returned as well. * * * ```js * const aMap = Map({ key: 'value' }) @@ -936,7 +936,7 @@ * For example, to sum the values in a Map * * * ```js * function sum(collection) { @@ -966,7 +966,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.9') + * const { Map } = require('immutable') * const one = Map({ a: 10, b: 20, c: 30 }) * const two = Map({ b: 40, a: 50, d: 60 }) * one.merge(two) // Map { "a": 50, "b": 40, "c": 30, "d": 60 } @@ -989,7 +989,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.9') + * const { Map } = require('immutable') * const one = Map({ a: 10, b: 20, c: 30 }) * const two = Map({ b: 40, a: 50, d: 60 }) * one.mergeWith((oldVal, newVal) => oldVal / newVal, two) @@ -1015,7 +1015,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.9') + * const { Map } = require('immutable') * const one = Map({ a: Map({ x: 10, y: 10 }), b: Map({ x: 20, y: 50 }) }) * const two = Map({ a: Map({ x: 2 }), b: Map({ y: 5 }), c: Map({ z: 3 }) }) * one.mergeDeep(two) @@ -1036,7 +1036,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.9') + * const { Map } = require('immutable') * const one = Map({ a: Map({ x: 10, y: 10 }), b: Map({ x: 20, y: 50 }) }) * const two = Map({ a: Map({ x: 2 }), b: Map({ y: 5 }), c: Map({ z: 3 }) }) * one.mergeDeepWith((oldVal, newVal) => oldVal / newVal, two) @@ -1063,7 +1063,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.9') + * const { Map } = require('immutable') * const originalMap = Map({ * subObject: Map({ * subKey: 'subvalue', @@ -1099,7 +1099,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.9') + * const { Map } = require('immutable') * const originalMap = Map({ * subObject: { * subKey: 'subvalue', @@ -1146,7 +1146,7 @@ * * * ```js - * const { Map, List } = require('immutable@4.0.0-rc.9') + * const { Map, List } = require('immutable') * const map = Map({ inMap: Map({ inList: List([ 1, 2, 3 ]) }) }) * const newMap = map.updateIn(['inMap', 'inList'], list => list.push(4)) * // Map { "inMap": Map { "inList": List [ 1, 2, 3, 4 ] } } @@ -1158,7 +1158,7 @@ * provided, otherwise `undefined`. * * * ```js * const map = Map({ a: Map({ b: Map({ c: 10 }) }) }) @@ -1170,7 +1170,7 @@ * no change will occur. This is still true if `notSetValue` is provided. * * * ```js * const map = Map({ a: Map({ b: Map({ c: 10 }) }) }) @@ -1186,7 +1186,7 @@ * The previous example behaves differently when written with default values: * * * ```js * const map = Map({ a: Map({ b: Map({ c: 10 }) }) }) @@ -1199,7 +1199,7 @@ * immutably by creating new copies of those values with the changes applied. * * * ```js * const map = Map({ a: { b: { c: 10 } } }) @@ -1260,7 +1260,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.9') + * const { Map } = require('immutable') * const map1 = Map() * const map2 = map1.withMutations(map => { * map.set('a', 1).set('b', 2).set('c', 3) @@ -1428,7 +1428,7 @@ * * * ```js - * const { OrderedMap } = require('immutable@4.0.0-rc.9') + * const { OrderedMap } = require('immutable') * const one = OrderedMap({ a: 10, b: 20, c: 30 }) * const two = OrderedMap({ b: 40, a: 50, d: 60 }) * one.merge(two) // OrderedMap { "a": 50, "b": 40, "c": 30, "d": 60 } @@ -1545,7 +1545,7 @@ * a collection of other sets. * * ```js - * const { Set } = require('immutable@4.0.0-rc.9') + * const { Set } = require('immutable') * const intersected = Set.intersect([ * Set([ 'a', 'b', 'c' ]) * Set([ 'c', 'a', 't' ]) @@ -1560,7 +1560,7 @@ * collection of other sets. * * ```js - * const { Set } = require('immutable@4.0.0-rc.9') + * const { Set } = require('immutable') * const unioned = Set.union([ * Set([ 'a', 'b', 'c' ]) * Set([ 'c', 'a', 't' ]) @@ -1640,7 +1640,7 @@ * * * ```js - * const { OrderedSet } = require('immutable@4.0.0-rc.9') + * const { OrderedSet } = require('immutable') * OrderedSet([ 1, 2, 3 ]).subtract([1, 3]) * // OrderedSet [2] * ``` @@ -2138,7 +2138,7 @@ * infinity. When `start` is equal to `end`, returns empty range. * * ```js - * const { Range } = require('immutable@4.0.0-rc.9') + * const { Range } = require('immutable') * Range() // [ 0, 1, 2, 3, ... ] * Range(10) // [ 10, 11, 12, 13, ... ] * Range(10, 15) // [ 10, 11, 12, 13, 14 ] @@ -2155,7 +2155,7 @@ * not defined, returns an infinite `Seq` of `value`. * * ```js - * const { Repeat } = require('immutable@4.0.0-rc.9') + * const { Repeat } = require('immutable') * Repeat('foo') // [ 'foo', 'foo', 'foo', ... ] * Repeat('bar', 4) // [ 'bar', 'bar', 'bar', 'bar' ] * ``` @@ -2171,7 +2171,7 @@ * create Record instances. * * ```js - * const { Record } = require('immutable@4.0.0-rc.9') + * const { Record } = require('immutable') * const ABRecord = Record({ a: 1, b: 2 }) * const myRecord = new ABRecord({ b: 3 }) * ``` @@ -2303,7 +2303,7 @@ * method. If one was not provided, the string "Record" is returned. * * ```js - * const { Record } = require('immutable@4.0.0-rc.9') + * const { Record } = require('immutable') * const Person = Record({ * name: null * }, 'Person') @@ -2321,7 +2321,7 @@ * type: * * * ```js * // makePerson is a Record Factory function @@ -2336,7 +2336,7 @@ * access on the resulting instances: * * * ```js * // Use the Record API @@ -2518,7 +2518,7 @@ * `Seq`'s values are never iterated: * * ```js - * const { Seq } = require('immutable@4.0.0-rc.9') + * const { Seq } = require('immutable') * const oddSquares = Seq([ 1, 2, 3, 4, 5, 6, 7, 8 ]) * .filter(x => x % 2 !== 0) * .map(x => x * x) @@ -2557,7 +2557,7 @@ * * * ```js - * const { Range } = require('immutable@4.0.0-rc.9') + * const { Range } = require('immutable') * Range(1, Infinity) * .skip(1000) * .map(n => -n) @@ -2636,7 +2636,7 @@ * `mapper` function. * * ```js - * const { Seq } = require('immutable@4.0.0-rc.9') + * const { Seq } = require('immutable') * Seq.Keyed({ a: 1, b: 2 }).map(x => 10 * x) * // Seq { "a": 10, "b": 20 } * ``` @@ -2748,7 +2748,7 @@ * `mapper` function. * * ```js - * const { Seq } = require('immutable@4.0.0-rc.9') + * const { Seq } = require('immutable') * Seq.Indexed([ 1, 2 ]).map(x => 10 * x) * // Seq [ 10, 20 ] * ``` @@ -3008,7 +3008,7 @@ * `mapper` function. * * ```js - * const { Seq } = require('immutable@4.0.0-rc.9') + * const { Seq } = require('immutable') * Seq([ 1, 2 ]).map(x => 10 * x) * // Seq [ 10, 20 ] * ``` @@ -3026,7 +3026,7 @@ * `mapper` function. * * ```js - * const { Seq } = require('immutable@4.0.0-rc.9') + * const { Seq } = require('immutable') * Seq([ 1, 2 ]).map(x => 10 * x) * // Seq [ 10, 20 ] * ``` @@ -3095,22 +3095,22 @@ export module Collection { /** - * @deprecated use `const { isKeyed } = require('immutable@4.0.0-rc.9')` + * @deprecated use `const { isKeyed } = require('immutable')` */ function isKeyed(maybeKeyed: any): maybeKeyed is Collection.Keyed; /** - * @deprecated use `const { isIndexed } = require('immutable@4.0.0-rc.9')` + * @deprecated use `const { isIndexed } = require('immutable')` */ function isIndexed(maybeIndexed: any): maybeIndexed is Collection.Indexed; /** - * @deprecated use `const { isAssociative } = require('immutable@4.0.0-rc.9')` + * @deprecated use `const { isAssociative } = require('immutable')` */ function isAssociative(maybeAssociative: any): maybeAssociative is Collection.Keyed | Collection.Indexed; /** - * @deprecated use `const { isOrdered } = require('immutable@4.0.0-rc.9')` + * @deprecated use `const { isOrdered } = require('immutable')` */ function isOrdered(maybeOrdered: any): boolean; @@ -3168,7 +3168,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.9') + * const { Map } = require('immutable') * Map({ a: 'z', b: 'y' }).flip() * // Map { "z": "a", "y": "b" } * ``` @@ -3186,7 +3186,7 @@ * `mapper` function. * * ```js - * const { Collection } = require('immutable@4.0.0-rc.9') + * const { Collection } = require('immutable') * Collection.Keyed({ a: 1, b: 2 }).map(x => 10 * x) * // Seq { "a": 10, "b": 20 } * ``` @@ -3205,7 +3205,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.9') + * const { Map } = require('immutable') * Map({ a: 1, b: 2 }).mapKeys(x => x.toUpperCase()) * // Map { "A": 1, "B": 2 } * ``` @@ -3224,7 +3224,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.9') + * const { Map } = require('immutable') * Map({ a: 1, b: 2 }) * .mapEntries(([ k, v ]) => [ k.toUpperCase(), v * 2 ]) * // Map { "A": 2, "B": 4 } @@ -3350,10 +3350,10 @@ * second from each, etc. * * * ```js - * const { List } = require('immutable@4.0.0-rc.9') + * const { List } = require('immutable') * List([ 1, 2, 3 ]).interleave(List([ 'A', 'B', 'C' ])) * // List [ 1, "A", 2, "B", 3, "C"" ] * ``` @@ -3361,7 +3361,7 @@ * The shortest Collection stops interleave. * * * ```js * List([ 1, 2, 3 ]).interleave( @@ -3388,7 +3388,7 @@ * * * ```js - * const { List } = require('immutable@4.0.0-rc.9') + * const { List } = require('immutable') * List([ 'a', 'b', 'c', 'd' ]).splice(1, 2, 'q', 'r', 's') * // List [ "a", "q", "r", "s", "d" ] * ``` @@ -3412,7 +3412,7 @@ * * * * ```js * const a = List([ 1, 2, 3 ]); @@ -3445,7 +3445,7 @@ * collections by using a custom `zipper` function. * * * ```js * const a = List([ 1, 2, 3 ]); @@ -3513,7 +3513,7 @@ * `mapper` function. * * ```js - * const { Collection } = require('immutable@4.0.0-rc.9') + * const { Collection } = require('immutable') * Collection.Indexed([1,2]).map(x => 10 * x) * // Seq [ 1, 2 ] * ``` @@ -3565,7 +3565,7 @@ * the value as both the first and second arguments to the provided function. * * ```js - * const { Collection } = require('immutable@4.0.0-rc.9') + * const { Collection } = require('immutable') * const seq = Collection.Set([ 'A', 'B', 'C' ]) * // Seq { "A", "B", "C" } * seq.forEach((v, k) => @@ -3697,7 +3697,7 @@ * lookup via a different instance. * * * ```js * const a = List([ 1, 2, 3 ]); @@ -3762,7 +3762,7 @@ * * * ```js - * const { Map, List } = require('immutable@4.0.0-rc.9') + * const { Map, List } = require('immutable') * const deepData = Map({ x: List([ Map({ y: 123 }) ]) }); * getIn(deepData, ['x', 0, 'y']) // 123 * ``` @@ -3772,7 +3772,7 @@ * * * ```js - * const { Map, List } = require('immutable@4.0.0-rc.9') + * const { Map, List } = require('immutable') * const deepData = Map({ x: [ { y: 123 } ] }); * getIn(deepData, ['x', 0, 'y']) // 123 * ``` @@ -3795,7 +3795,7 @@ * * * ```js - * const { Seq } = require('immutable@4.0.0-rc.9') + * const { Seq } = require('immutable') * * function sum(collection) { * return collection.reduce((sum, x) => sum + x, 0) @@ -3891,7 +3891,7 @@ * * * ```js - * const { Map, List } = require('immutable@4.0.0-rc.9') + * const { Map, List } = require('immutable') * var myMap = Map({ a: 'Apple', b: 'Banana' }) * List(myMap) // List [ [ "a", "Apple" ], [ "b", "Banana" ] ] * myMap.toList() // List [ "Apple", "Banana" ] @@ -3928,7 +3928,7 @@ * * * ```js - * const { Seq } = require('immutable@4.0.0-rc.9') + * const { Seq } = require('immutable') * const indexedSeq = Seq([ 'A', 'B', 'C' ]) * // Seq [ "A", "B", "C" ] * indexedSeq.filter(v => v === 'B') @@ -4009,7 +4009,7 @@ * * * ```js - * const { Collection } = require('immutable@4.0.0-rc.9') + * const { Collection } = require('immutable') * Collection({ a: 1, b: 2 }).map(x => 10 * x) * // Seq { "a": 10, "b": 20 } * ``` @@ -4036,7 +4036,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.9') + * const { Map } = require('immutable') * Map({ a: 1, b: 2, c: 3, d: 4}).filter(x => x % 2 === 0) * // Map { "b": 2, "d": 4 } * ``` @@ -4059,7 +4059,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.9') + * const { Map } = require('immutable') * Map({ a: 1, b: 2, c: 3, d: 4}).filterNot(x => x % 2 === 0) * // Map { "a": 1, "c": 3 } * ``` @@ -4096,7 +4096,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.9') + * const { Map } = require('immutable') * Map({ "c": 3, "a": 1, "b": 2 }).sort((a, b) => { * if (a < b) { return -1; } * if (a > b) { return 1; } @@ -4136,7 +4136,7 @@ * * * ```js - * const { List, Map } = require('immutable@4.0.0-rc.9') + * const { List, Map } = require('immutable') * const listOfMaps = List([ * Map({ v: 0 }), * Map({ v: 1 }), @@ -4223,7 +4223,7 @@ * * * ```js - * const { List } = require('immutable@4.0.0-rc.9') + * const { List } = require('immutable') * List([ 'dog', 'frog', 'cat', 'hat', 'god' ]) * .skipWhile(x => x.match(/g/)) * // List [ "cat", "hat", "god"" ] @@ -4240,7 +4240,7 @@ * * * ```js - * const { List } = require('immutable@4.0.0-rc.9') + * const { List } = require('immutable') * List([ 'dog', 'frog', 'cat', 'hat', 'god' ]) * .skipUntil(x => x.match(/hat/)) * // List [ "hat", "god"" ] @@ -4269,7 +4269,7 @@ * * * ```js - * const { List } = require('immutable@4.0.0-rc.9') + * const { List } = require('immutable') * List([ 'dog', 'frog', 'cat', 'hat', 'god' ]) * .takeWhile(x => x.match(/o/)) * // List [ "dog", "frog" ] @@ -4286,7 +4286,7 @@ * * * ```js - * const { List } = require('immutable@4.0.0-rc.9') + * const { List } = require('immutable') * List([ 'dog', 'frog', 'cat', 'hat', 'god' ]) * .takeUntil(x => x.match(/at/)) * // List [ "dog", "frog" ] @@ -4604,7 +4604,7 @@ * * * ```js - * const { List, Set } = require('immutable@4.0.0-rc.9'); + * const { List, Set } = require('immutable'); * const a = List([ 1, 2, 3 ]); * const b = List([ 1, 2, 3 ]); * assert.notStrictEqual(a, b); // different instances @@ -4648,7 +4648,7 @@ * * * ```js - * const { fromJS, isKeyed } = require('immutable@4.0.0-rc.9') + * const { fromJS, isKeyed } = require('immutable') * function (key, value) { * return isKeyed(value) ? value.Map() : value.toList() * } @@ -4662,7 +4662,7 @@ * * * ```js - * const { fromJS, isKeyed } = require('immutable@4.0.0-rc.9') + * const { fromJS, isKeyed } = require('immutable') * fromJS({ a: {b: [10, 20, 30]}, c: 40}, function (key, value, path) { * console.log(key, value, path) * return isKeyed(value) ? value.toOrderedMap() : value.toList() @@ -4679,7 +4679,7 @@ * * * ```js - * const { Map } = require('immutable@4.0.0-rc.9') + * const { Map } = require('immutable') * let obj = { 1: "one" }; * Object.keys(obj); // [ "1" ] * assert.equal(obj["1"], obj[1]); // "one" === "one" @@ -4714,7 +4714,7 @@ * * * ```js - * const { Map, is } = require('immutable@4.0.0-rc.9') + * const { Map, is } = require('immutable') * const map1 = Map({ a: 1, b: 1, c: 1 }) * const map2 = Map({ a: 1, b: 1, c: 1 }) * assert.equal(map1 !== map2, true) @@ -4762,7 +4762,7 @@ * * * ```js - * const { isImmutable, Map, List, Stack } = require('immutable@4.0.0-rc.9'); + * const { isImmutable, Map, List, Stack } = require('immutable'); * isImmutable([]); // false * isImmutable({}); // false * isImmutable(Map()); // true @@ -4778,7 +4778,7 @@ * * * ```js - * const { isCollection, Map, List, Stack } = require('immutable@4.0.0-rc.9'); + * const { isCollection, Map, List, Stack } = require('immutable'); * isCollection([]); // false * isCollection({}); // false * isCollection(Map()); // true @@ -4793,7 +4793,7 @@ * * * ```js - * const { isKeyed, Map, List, Stack } = require('immutable@4.0.0-rc.9'); + * const { isKeyed, Map, List, Stack } = require('immutable'); * isKeyed([]); // false * isKeyed({}); // false * isKeyed(Map()); // true @@ -4808,7 +4808,7 @@ * * * ```js - * const { isIndexed, Map, List, Stack, Set } = require('immutable@4.0.0-rc.9'); + * const { isIndexed, Map, List, Stack, Set } = require('immutable'); * isIndexed([]); // false * isIndexed({}); // false * isIndexed(Map()); // false @@ -4824,7 +4824,7 @@ * * * ```js - * const { isAssociative, Map, List, Stack, Set } = require('immutable@4.0.0-rc.9'); + * const { isAssociative, Map, List, Stack, Set } = require('immutable'); * isAssociative([]); // false * isAssociative({}); // false * isAssociative(Map()); // true @@ -4841,7 +4841,7 @@ * * * ```js - * const { isOrdered, Map, OrderedMap, List, Set } = require('immutable@4.0.0-rc.9'); + * const { isOrdered, Map, OrderedMap, List, Set } = require('immutable'); * isOrdered([]); // false * isOrdered({}); // false * isOrdered(Map()); // false @@ -4870,7 +4870,7 @@ * * * ```js - * const { get } = require('immutable@4.0.0-rc.9') + * const { get } = require('immutable') * get([ 'dog', 'frog', 'cat' ], 2) // 'frog' * get({ x: 123, y: 456 }, 'x') // 123 * get({ x: 123, y: 456 }, 'z', 'ifNotSet') // 'ifNotSet' @@ -4894,7 +4894,7 @@ * * * ```js - * const { has } = require('immutable@4.0.0-rc.9') + * const { has } = require('immutable') * has([ 'dog', 'frog', 'cat' ], 2) // true * has([ 'dog', 'frog', 'cat' ], 5) // false * has({ x: 123, y: 456 }, 'x') // true @@ -4912,7 +4912,7 @@ * * * ```js - * const { remove } = require('immutable@4.0.0-rc.9') + * const { remove } = require('immutable') * const originalArray = [ 'dog', 'frog', 'cat' ] * remove(originalArray, 1) // [ 'dog', 'cat' ] * console.log(originalArray) // [ 'dog', 'frog', 'cat' ] @@ -4937,7 +4937,7 @@ * * * ```js - * const { set } = require('immutable@4.0.0-rc.9') + * const { set } = require('immutable') * const originalArray = [ 'dog', 'frog', 'cat' ] * set(originalArray, 1, 'cow') // [ 'dog', 'cow', 'cat' ] * console.log(originalArray) // [ 'dog', 'frog', 'cat' ] @@ -4962,7 +4962,7 @@ * * * ```js - * const { update } = require('immutable@4.0.0-rc.9') + * const { update } = require('immutable') * const originalArray = [ 'dog', 'frog', 'cat' ] * update(originalArray, 1, val => val.toUpperCase()) // [ 'dog', 'FROG', 'cat' ] * console.log(originalArray) // [ 'dog', 'frog', 'cat' ] @@ -4991,7 +4991,7 @@ * * * ```js - * const { getIn } = require('immutable@4.0.0-rc.9') + * const { getIn } = require('immutable') * getIn({ x: { y: { z: 123 }}}, ['x', 'y', 'z']) // 123 * getIn({ x: { y: { z: 123 }}}, ['x', 'q', 'p'], 'ifNotSet') // 'ifNotSet' * ``` @@ -5006,7 +5006,7 @@ * * * ```js - * const { hasIn } = require('immutable@4.0.0-rc.9') + * const { hasIn } = require('immutable') * hasIn({ x: { y: { z: 123 }}}, ['x', 'y', 'z']) // true * hasIn({ x: { y: { z: 123 }}}, ['x', 'q', 'p']) // false * ``` @@ -5021,7 +5021,7 @@ * * * ```js - * const { removeIn } = require('immutable@4.0.0-rc.9') + * const { removeIn } = require('immutable') * const original = { x: { y: { z: 123 }}} * removeIn(original, ['x', 'y', 'z']) // { x: { y: {}}} * console.log(original) // { x: { y: { z: 123 }}} @@ -5038,7 +5038,7 @@ * * * ```js - * const { setIn } = require('immutable@4.0.0-rc.9') + * const { setIn } = require('immutable') * const original = { x: { y: { z: 123 }}} * setIn(original, ['x', 'y', 'z'], 456) // { x: { y: { z: 456 }}} * console.log(original) // { x: { y: { z: 123 }}} @@ -5055,7 +5055,7 @@ * * * ```js - * const { updateIn } = require('immutable@4.0.0-rc.9') + * const { updateIn } = require('immutable') * const original = { x: { y: { z: 123 }}} * updateIn(original, ['x', 'y', 'z'], val => val * 6) // { x: { y: { z: 738 }}} * console.log(original) // { x: { y: { z: 123 }}} @@ -5072,7 +5072,7 @@ * * * ```js - * const { merge } = require('immutable@4.0.0-rc.9') + * const { merge } = require('immutable') * const original = { x: 123, y: 456 } * merge(original, { y: 789, z: 'abc' }) // { x: 123, y: 789, z: 'abc' } * console.log(original) // { x: { y: { z: 123 }}} @@ -5092,7 +5092,7 @@ * * * ```js - * const { mergeWith } = require('immutable@4.0.0-rc.9') + * const { mergeWith } = require('immutable') * const original = { x: 123, y: 456 } * mergeWith( * (oldVal, newVal) => oldVal + newVal, @@ -5117,7 +5117,7 @@ * * * ```js - * const { mergeDeep } = require('immutable@4.0.0-rc.9') + * const { mergeDeep } = require('immutable') * const original = { x: { y: 123 }} * mergeDeep(original, { x: { z: 456 }}) // { x: { y: 123, z: 456 }} * console.log(original) // { x: { y: 123 }} @@ -5138,7 +5138,7 @@ * * * ```js - * const { mergeDeepWith } = require('immutable@4.0.0-rc.9') + * const { mergeDeepWith } = require('immutable') * const original = { x: { y: 123 }} * mergeDeepWith( * (oldVal, newVal) => oldVal + newVal, diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index 87e396076c..1f757e06aa 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -120,7 +120,7 @@ declare module Immutable { * * * ```js - * const { List } = require('immutable@4.0.0-rc.9'); + * const { List } = require('immutable'); * List.isList([]); // false * List.isList(List()); // true * ``` @@ -132,7 +132,7 @@ declare module Immutable { * * * ```js - * const { List } = require('immutable@4.0.0-rc.9'); + * const { List } = require('immutable'); * List.of(1, 2, 3, 4) * // List [ 1, 2, 3, 4 ] * ``` @@ -141,7 +141,7 @@ declare module Immutable { * * * ```js - * const { List } = require('immutable@4.0.0-rc.9'); + * const { List } = require('immutable'); * List.of({x:1}, 2, [3], 4) * // List [ { x: 1 }, 2, [ 3 ], 4 ] * ``` @@ -155,7 +155,7 @@ declare module Immutable { * * * ```js - * const { List, Set } = require('immutable@4.0.0-rc.9') + * const { List, Set } = require('immutable') * * const emptyList = List() * // List [] @@ -201,7 +201,7 @@ declare module Immutable { * enough to include the `index`. * * * ```js * const originalList = List([ 0 ]); @@ -234,7 +234,7 @@ declare module Immutable { * Note: `delete` cannot be safely used in IE8 * * * ```js * List([ 0, 1, 2, 3, 4 ]).delete(0); @@ -258,7 +258,7 @@ declare module Immutable { * This is synonymous with `list.splice(index, 0, value)`. * * * ```js * List([ 0, 1, 2, 3, 4 ]).insert(6, 5) @@ -276,7 +276,7 @@ declare module Immutable { * Returns a new List with 0 size and no values in constant time. * * * ```js * List([ 1, 2, 3, 4 ]).clear() @@ -292,7 +292,7 @@ declare module Immutable { * List's `size`. * * * ```js * List([ 1, 2, 3, 4 ]).push(5) @@ -325,7 +325,7 @@ declare module Immutable { * values ahead to higher indices. * * * ```js * List([ 2, 3, 4]).unshift(1); @@ -345,7 +345,7 @@ declare module Immutable { * value in this List. * * * ```js * List([ 0, 1, 2, 3, 4 ]).shift(); @@ -366,7 +366,7 @@ declare module Immutable { * List. `v.update(-1)` updates the last item in the List. * * * ```js * const list = List([ 'a', 'b', 'c' ]) @@ -380,7 +380,7 @@ declare module Immutable { * For example, to sum a List after mapping and filtering: * * * ```js * function sum(collection) { @@ -426,7 +426,7 @@ declare module Immutable { * * * ```js - * const { List } = require('immutable@4.0.0-rc.9') + * const { List } = require('immutable') * const list = List([ 0, 1, 2, List([ 3, 4 ])]) * list.setIn([3, 0], 999); * // List [ 0, 1, 2, List [ 999, 4 ] ] @@ -438,7 +438,7 @@ declare module Immutable { * * * ```js - * const { List } = require('immutable@4.0.0-rc.9') + * const { List } = require('immutable') * const list = List([ 0, 1, 2, { plain: 'object' }]) * list.setIn([3, 'plain'], 'value'); * // List([ 0, 1, 2, { plain: 'value' }]) @@ -454,7 +454,7 @@ declare module Immutable { * * * ```js - * const { List } = require('immutable@4.0.0-rc.9') + * const { List } = require('immutable') * const list = List([ 0, 1, 2, List([ 3, 4 ])]) * list.deleteIn([3, 0]); * // List [ 0, 1, 2, List [ 4 ] ] @@ -466,7 +466,7 @@ declare module Immutable { * * * ```js - * const { List } = require('immutable@4.0.0-rc.9') + * const { List } = require('immutable') * const list = List([ 0, 1, 2, { plain: 'object' }]) * list.removeIn([3, 'plain']); * // List([ 0, 1, 2, {}]) @@ -550,7 +550,7 @@ declare module Immutable { * `mapper` function. * * * ```js * List([ 1, 2 ]).map(x => 10 * x) @@ -597,7 +597,7 @@ declare module Immutable { * Like `zipWith`, but using the default `zipper`: creating an `Array`. * * * ```js * const a = List([ 1, 2, 3 ]); @@ -616,7 +616,7 @@ declare module Immutable { * exhausted. Missing values from shorter collections are filled with `undefined`. * * * ```js * const a = List([ 1, 2 ]); @@ -637,7 +637,7 @@ declare module Immutable { * custom `zipper` function. * * * ```js * const a = List([ 1, 2, 3 ]); @@ -678,7 +678,7 @@ declare module Immutable { * * * ```js - * const { Map, List } = require('immutable@4.0.0-rc.9'); + * const { Map, List } = require('immutable'); * Map().set(List([ 1 ]), 'listofone').get(List([ 1 ])); * // 'listofone' * ``` @@ -696,7 +696,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.9') + * const { Map } = require('immutable') * Map.isMap({}) // false * Map.isMap(Map()) // true * ``` @@ -708,7 +708,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.9') + * const { Map } = require('immutable') * Map.of( * 'key', 'value', * 'numerical value', 3, @@ -730,7 +730,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.9') + * const { Map } = require('immutable') * Map({ key: "value" }) * Map([ [ "key", "value" ] ]) * ``` @@ -740,7 +740,7 @@ declare module Immutable { * quote-less shorthand, while Immutable Maps accept keys of any type. * * * ```js * let obj = { 1: "one" } @@ -776,7 +776,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.9') + * const { Map } = require('immutable') * const originalMap = Map() * const newerMap = originalMap.set('key', 'value') * const newestMap = newerMap.set('key', 'newer value') @@ -801,7 +801,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.9') + * const { Map } = require('immutable') * const originalMap = Map({ * key: 'value', * otherKey: 'other value' @@ -823,7 +823,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.9') + * const { Map } = require('immutable') * const names = Map({ a: "Aaron", b: "Barry", c: "Connor" }) * names.deleteAll([ 'a', 'c' ]) * // Map { "b": "Barry" } @@ -841,7 +841,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.9') + * const { Map } = require('immutable') * Map({ key: 'value' }).clear() * // Map {} * ``` @@ -858,7 +858,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.9') + * const { Map } = require('immutable') * const aMap = Map({ key: 'value' }) * const newMap = aMap.update('key', value => value + value) * // Map { "key": "valuevalue" } @@ -869,7 +869,7 @@ declare module Immutable { * `update` and `push` can be used together: * * * ```js * const aMap = Map({ nestedList: List([ 1, 2, 3 ]) }) @@ -881,7 +881,7 @@ declare module Immutable { * function when the value at the key does not exist in the Map. * * * ```js * const aMap = Map({ key: 'value' }) @@ -894,7 +894,7 @@ declare module Immutable { * is provided. * * * ```js * const aMap = Map({ apples: 10 }) @@ -910,7 +910,7 @@ declare module Immutable { * The previous example behaves differently when written with default values: * * * ```js * const aMap = Map({ apples: 10 }) @@ -922,7 +922,7 @@ declare module Immutable { * returned as well. * * * ```js * const aMap = Map({ key: 'value' }) @@ -936,7 +936,7 @@ declare module Immutable { * For example, to sum the values in a Map * * * ```js * function sum(collection) { @@ -966,7 +966,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.9') + * const { Map } = require('immutable') * const one = Map({ a: 10, b: 20, c: 30 }) * const two = Map({ b: 40, a: 50, d: 60 }) * one.merge(two) // Map { "a": 50, "b": 40, "c": 30, "d": 60 } @@ -989,7 +989,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.9') + * const { Map } = require('immutable') * const one = Map({ a: 10, b: 20, c: 30 }) * const two = Map({ b: 40, a: 50, d: 60 }) * one.mergeWith((oldVal, newVal) => oldVal / newVal, two) @@ -1015,7 +1015,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.9') + * const { Map } = require('immutable') * const one = Map({ a: Map({ x: 10, y: 10 }), b: Map({ x: 20, y: 50 }) }) * const two = Map({ a: Map({ x: 2 }), b: Map({ y: 5 }), c: Map({ z: 3 }) }) * one.mergeDeep(two) @@ -1036,7 +1036,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.9') + * const { Map } = require('immutable') * const one = Map({ a: Map({ x: 10, y: 10 }), b: Map({ x: 20, y: 50 }) }) * const two = Map({ a: Map({ x: 2 }), b: Map({ y: 5 }), c: Map({ z: 3 }) }) * one.mergeDeepWith((oldVal, newVal) => oldVal / newVal, two) @@ -1063,7 +1063,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.9') + * const { Map } = require('immutable') * const originalMap = Map({ * subObject: Map({ * subKey: 'subvalue', @@ -1099,7 +1099,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.9') + * const { Map } = require('immutable') * const originalMap = Map({ * subObject: { * subKey: 'subvalue', @@ -1146,7 +1146,7 @@ declare module Immutable { * * * ```js - * const { Map, List } = require('immutable@4.0.0-rc.9') + * const { Map, List } = require('immutable') * const map = Map({ inMap: Map({ inList: List([ 1, 2, 3 ]) }) }) * const newMap = map.updateIn(['inMap', 'inList'], list => list.push(4)) * // Map { "inMap": Map { "inList": List [ 1, 2, 3, 4 ] } } @@ -1158,7 +1158,7 @@ declare module Immutable { * provided, otherwise `undefined`. * * * ```js * const map = Map({ a: Map({ b: Map({ c: 10 }) }) }) @@ -1170,7 +1170,7 @@ declare module Immutable { * no change will occur. This is still true if `notSetValue` is provided. * * * ```js * const map = Map({ a: Map({ b: Map({ c: 10 }) }) }) @@ -1186,7 +1186,7 @@ declare module Immutable { * The previous example behaves differently when written with default values: * * * ```js * const map = Map({ a: Map({ b: Map({ c: 10 }) }) }) @@ -1199,7 +1199,7 @@ declare module Immutable { * immutably by creating new copies of those values with the changes applied. * * * ```js * const map = Map({ a: { b: { c: 10 } } }) @@ -1260,7 +1260,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.9') + * const { Map } = require('immutable') * const map1 = Map() * const map2 = map1.withMutations(map => { * map.set('a', 1).set('b', 2).set('c', 3) @@ -1428,7 +1428,7 @@ declare module Immutable { * * * ```js - * const { OrderedMap } = require('immutable@4.0.0-rc.9') + * const { OrderedMap } = require('immutable') * const one = OrderedMap({ a: 10, b: 20, c: 30 }) * const two = OrderedMap({ b: 40, a: 50, d: 60 }) * one.merge(two) // OrderedMap { "a": 50, "b": 40, "c": 30, "d": 60 } @@ -1545,7 +1545,7 @@ declare module Immutable { * a collection of other sets. * * ```js - * const { Set } = require('immutable@4.0.0-rc.9') + * const { Set } = require('immutable') * const intersected = Set.intersect([ * Set([ 'a', 'b', 'c' ]) * Set([ 'c', 'a', 't' ]) @@ -1560,7 +1560,7 @@ declare module Immutable { * collection of other sets. * * ```js - * const { Set } = require('immutable@4.0.0-rc.9') + * const { Set } = require('immutable') * const unioned = Set.union([ * Set([ 'a', 'b', 'c' ]) * Set([ 'c', 'a', 't' ]) @@ -1640,7 +1640,7 @@ declare module Immutable { * * * ```js - * const { OrderedSet } = require('immutable@4.0.0-rc.9') + * const { OrderedSet } = require('immutable') * OrderedSet([ 1, 2, 3 ]).subtract([1, 3]) * // OrderedSet [2] * ``` @@ -2138,7 +2138,7 @@ declare module Immutable { * infinity. When `start` is equal to `end`, returns empty range. * * ```js - * const { Range } = require('immutable@4.0.0-rc.9') + * const { Range } = require('immutable') * Range() // [ 0, 1, 2, 3, ... ] * Range(10) // [ 10, 11, 12, 13, ... ] * Range(10, 15) // [ 10, 11, 12, 13, 14 ] @@ -2155,7 +2155,7 @@ declare module Immutable { * not defined, returns an infinite `Seq` of `value`. * * ```js - * const { Repeat } = require('immutable@4.0.0-rc.9') + * const { Repeat } = require('immutable') * Repeat('foo') // [ 'foo', 'foo', 'foo', ... ] * Repeat('bar', 4) // [ 'bar', 'bar', 'bar', 'bar' ] * ``` @@ -2171,7 +2171,7 @@ declare module Immutable { * create Record instances. * * ```js - * const { Record } = require('immutable@4.0.0-rc.9') + * const { Record } = require('immutable') * const ABRecord = Record({ a: 1, b: 2 }) * const myRecord = new ABRecord({ b: 3 }) * ``` @@ -2303,7 +2303,7 @@ declare module Immutable { * method. If one was not provided, the string "Record" is returned. * * ```js - * const { Record } = require('immutable@4.0.0-rc.9') + * const { Record } = require('immutable') * const Person = Record({ * name: null * }, 'Person') @@ -2321,7 +2321,7 @@ declare module Immutable { * type: * * * ```js * // makePerson is a Record Factory function @@ -2336,7 +2336,7 @@ declare module Immutable { * access on the resulting instances: * * * ```js * // Use the Record API @@ -2518,7 +2518,7 @@ declare module Immutable { * `Seq`'s values are never iterated: * * ```js - * const { Seq } = require('immutable@4.0.0-rc.9') + * const { Seq } = require('immutable') * const oddSquares = Seq([ 1, 2, 3, 4, 5, 6, 7, 8 ]) * .filter(x => x % 2 !== 0) * .map(x => x * x) @@ -2557,7 +2557,7 @@ declare module Immutable { * * * ```js - * const { Range } = require('immutable@4.0.0-rc.9') + * const { Range } = require('immutable') * Range(1, Infinity) * .skip(1000) * .map(n => -n) @@ -2636,7 +2636,7 @@ declare module Immutable { * `mapper` function. * * ```js - * const { Seq } = require('immutable@4.0.0-rc.9') + * const { Seq } = require('immutable') * Seq.Keyed({ a: 1, b: 2 }).map(x => 10 * x) * // Seq { "a": 10, "b": 20 } * ``` @@ -2748,7 +2748,7 @@ declare module Immutable { * `mapper` function. * * ```js - * const { Seq } = require('immutable@4.0.0-rc.9') + * const { Seq } = require('immutable') * Seq.Indexed([ 1, 2 ]).map(x => 10 * x) * // Seq [ 10, 20 ] * ``` @@ -3008,7 +3008,7 @@ declare module Immutable { * `mapper` function. * * ```js - * const { Seq } = require('immutable@4.0.0-rc.9') + * const { Seq } = require('immutable') * Seq([ 1, 2 ]).map(x => 10 * x) * // Seq [ 10, 20 ] * ``` @@ -3026,7 +3026,7 @@ declare module Immutable { * `mapper` function. * * ```js - * const { Seq } = require('immutable@4.0.0-rc.9') + * const { Seq } = require('immutable') * Seq([ 1, 2 ]).map(x => 10 * x) * // Seq [ 10, 20 ] * ``` @@ -3095,22 +3095,22 @@ declare module Immutable { export module Collection { /** - * @deprecated use `const { isKeyed } = require('immutable@4.0.0-rc.9')` + * @deprecated use `const { isKeyed } = require('immutable')` */ function isKeyed(maybeKeyed: any): maybeKeyed is Collection.Keyed; /** - * @deprecated use `const { isIndexed } = require('immutable@4.0.0-rc.9')` + * @deprecated use `const { isIndexed } = require('immutable')` */ function isIndexed(maybeIndexed: any): maybeIndexed is Collection.Indexed; /** - * @deprecated use `const { isAssociative } = require('immutable@4.0.0-rc.9')` + * @deprecated use `const { isAssociative } = require('immutable')` */ function isAssociative(maybeAssociative: any): maybeAssociative is Collection.Keyed | Collection.Indexed; /** - * @deprecated use `const { isOrdered } = require('immutable@4.0.0-rc.9')` + * @deprecated use `const { isOrdered } = require('immutable')` */ function isOrdered(maybeOrdered: any): boolean; @@ -3168,7 +3168,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.9') + * const { Map } = require('immutable') * Map({ a: 'z', b: 'y' }).flip() * // Map { "z": "a", "y": "b" } * ``` @@ -3186,7 +3186,7 @@ declare module Immutable { * `mapper` function. * * ```js - * const { Collection } = require('immutable@4.0.0-rc.9') + * const { Collection } = require('immutable') * Collection.Keyed({ a: 1, b: 2 }).map(x => 10 * x) * // Seq { "a": 10, "b": 20 } * ``` @@ -3205,7 +3205,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.9') + * const { Map } = require('immutable') * Map({ a: 1, b: 2 }).mapKeys(x => x.toUpperCase()) * // Map { "A": 1, "B": 2 } * ``` @@ -3224,7 +3224,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.9') + * const { Map } = require('immutable') * Map({ a: 1, b: 2 }) * .mapEntries(([ k, v ]) => [ k.toUpperCase(), v * 2 ]) * // Map { "A": 2, "B": 4 } @@ -3350,10 +3350,10 @@ declare module Immutable { * second from each, etc. * * * ```js - * const { List } = require('immutable@4.0.0-rc.9') + * const { List } = require('immutable') * List([ 1, 2, 3 ]).interleave(List([ 'A', 'B', 'C' ])) * // List [ 1, "A", 2, "B", 3, "C"" ] * ``` @@ -3361,7 +3361,7 @@ declare module Immutable { * The shortest Collection stops interleave. * * * ```js * List([ 1, 2, 3 ]).interleave( @@ -3388,7 +3388,7 @@ declare module Immutable { * * * ```js - * const { List } = require('immutable@4.0.0-rc.9') + * const { List } = require('immutable') * List([ 'a', 'b', 'c', 'd' ]).splice(1, 2, 'q', 'r', 's') * // List [ "a", "q", "r", "s", "d" ] * ``` @@ -3412,7 +3412,7 @@ declare module Immutable { * * * * ```js * const a = List([ 1, 2, 3 ]); @@ -3445,7 +3445,7 @@ declare module Immutable { * collections by using a custom `zipper` function. * * * ```js * const a = List([ 1, 2, 3 ]); @@ -3513,7 +3513,7 @@ declare module Immutable { * `mapper` function. * * ```js - * const { Collection } = require('immutable@4.0.0-rc.9') + * const { Collection } = require('immutable') * Collection.Indexed([1,2]).map(x => 10 * x) * // Seq [ 1, 2 ] * ``` @@ -3565,7 +3565,7 @@ declare module Immutable { * the value as both the first and second arguments to the provided function. * * ```js - * const { Collection } = require('immutable@4.0.0-rc.9') + * const { Collection } = require('immutable') * const seq = Collection.Set([ 'A', 'B', 'C' ]) * // Seq { "A", "B", "C" } * seq.forEach((v, k) => @@ -3697,7 +3697,7 @@ declare module Immutable { * lookup via a different instance. * * * ```js * const a = List([ 1, 2, 3 ]); @@ -3762,7 +3762,7 @@ declare module Immutable { * * * ```js - * const { Map, List } = require('immutable@4.0.0-rc.9') + * const { Map, List } = require('immutable') * const deepData = Map({ x: List([ Map({ y: 123 }) ]) }); * getIn(deepData, ['x', 0, 'y']) // 123 * ``` @@ -3772,7 +3772,7 @@ declare module Immutable { * * * ```js - * const { Map, List } = require('immutable@4.0.0-rc.9') + * const { Map, List } = require('immutable') * const deepData = Map({ x: [ { y: 123 } ] }); * getIn(deepData, ['x', 0, 'y']) // 123 * ``` @@ -3795,7 +3795,7 @@ declare module Immutable { * * * ```js - * const { Seq } = require('immutable@4.0.0-rc.9') + * const { Seq } = require('immutable') * * function sum(collection) { * return collection.reduce((sum, x) => sum + x, 0) @@ -3891,7 +3891,7 @@ declare module Immutable { * * * ```js - * const { Map, List } = require('immutable@4.0.0-rc.9') + * const { Map, List } = require('immutable') * var myMap = Map({ a: 'Apple', b: 'Banana' }) * List(myMap) // List [ [ "a", "Apple" ], [ "b", "Banana" ] ] * myMap.toList() // List [ "Apple", "Banana" ] @@ -3928,7 +3928,7 @@ declare module Immutable { * * * ```js - * const { Seq } = require('immutable@4.0.0-rc.9') + * const { Seq } = require('immutable') * const indexedSeq = Seq([ 'A', 'B', 'C' ]) * // Seq [ "A", "B", "C" ] * indexedSeq.filter(v => v === 'B') @@ -4009,7 +4009,7 @@ declare module Immutable { * * * ```js - * const { Collection } = require('immutable@4.0.0-rc.9') + * const { Collection } = require('immutable') * Collection({ a: 1, b: 2 }).map(x => 10 * x) * // Seq { "a": 10, "b": 20 } * ``` @@ -4036,7 +4036,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.9') + * const { Map } = require('immutable') * Map({ a: 1, b: 2, c: 3, d: 4}).filter(x => x % 2 === 0) * // Map { "b": 2, "d": 4 } * ``` @@ -4059,7 +4059,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.9') + * const { Map } = require('immutable') * Map({ a: 1, b: 2, c: 3, d: 4}).filterNot(x => x % 2 === 0) * // Map { "a": 1, "c": 3 } * ``` @@ -4096,7 +4096,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.9') + * const { Map } = require('immutable') * Map({ "c": 3, "a": 1, "b": 2 }).sort((a, b) => { * if (a < b) { return -1; } * if (a > b) { return 1; } @@ -4136,7 +4136,7 @@ declare module Immutable { * * * ```js - * const { List, Map } = require('immutable@4.0.0-rc.9') + * const { List, Map } = require('immutable') * const listOfMaps = List([ * Map({ v: 0 }), * Map({ v: 1 }), @@ -4223,7 +4223,7 @@ declare module Immutable { * * * ```js - * const { List } = require('immutable@4.0.0-rc.9') + * const { List } = require('immutable') * List([ 'dog', 'frog', 'cat', 'hat', 'god' ]) * .skipWhile(x => x.match(/g/)) * // List [ "cat", "hat", "god"" ] @@ -4240,7 +4240,7 @@ declare module Immutable { * * * ```js - * const { List } = require('immutable@4.0.0-rc.9') + * const { List } = require('immutable') * List([ 'dog', 'frog', 'cat', 'hat', 'god' ]) * .skipUntil(x => x.match(/hat/)) * // List [ "hat", "god"" ] @@ -4269,7 +4269,7 @@ declare module Immutable { * * * ```js - * const { List } = require('immutable@4.0.0-rc.9') + * const { List } = require('immutable') * List([ 'dog', 'frog', 'cat', 'hat', 'god' ]) * .takeWhile(x => x.match(/o/)) * // List [ "dog", "frog" ] @@ -4286,7 +4286,7 @@ declare module Immutable { * * * ```js - * const { List } = require('immutable@4.0.0-rc.9') + * const { List } = require('immutable') * List([ 'dog', 'frog', 'cat', 'hat', 'god' ]) * .takeUntil(x => x.match(/at/)) * // List [ "dog", "frog" ] @@ -4604,7 +4604,7 @@ declare module Immutable { * * * ```js - * const { List, Set } = require('immutable@4.0.0-rc.9'); + * const { List, Set } = require('immutable'); * const a = List([ 1, 2, 3 ]); * const b = List([ 1, 2, 3 ]); * assert.notStrictEqual(a, b); // different instances @@ -4648,7 +4648,7 @@ declare module Immutable { * * * ```js - * const { fromJS, isKeyed } = require('immutable@4.0.0-rc.9') + * const { fromJS, isKeyed } = require('immutable') * function (key, value) { * return isKeyed(value) ? value.Map() : value.toList() * } @@ -4662,7 +4662,7 @@ declare module Immutable { * * * ```js - * const { fromJS, isKeyed } = require('immutable@4.0.0-rc.9') + * const { fromJS, isKeyed } = require('immutable') * fromJS({ a: {b: [10, 20, 30]}, c: 40}, function (key, value, path) { * console.log(key, value, path) * return isKeyed(value) ? value.toOrderedMap() : value.toList() @@ -4679,7 +4679,7 @@ declare module Immutable { * * * ```js - * const { Map } = require('immutable@4.0.0-rc.9') + * const { Map } = require('immutable') * let obj = { 1: "one" }; * Object.keys(obj); // [ "1" ] * assert.equal(obj["1"], obj[1]); // "one" === "one" @@ -4714,7 +4714,7 @@ declare module Immutable { * * * ```js - * const { Map, is } = require('immutable@4.0.0-rc.9') + * const { Map, is } = require('immutable') * const map1 = Map({ a: 1, b: 1, c: 1 }) * const map2 = Map({ a: 1, b: 1, c: 1 }) * assert.equal(map1 !== map2, true) @@ -4762,7 +4762,7 @@ declare module Immutable { * * * ```js - * const { isImmutable, Map, List, Stack } = require('immutable@4.0.0-rc.9'); + * const { isImmutable, Map, List, Stack } = require('immutable'); * isImmutable([]); // false * isImmutable({}); // false * isImmutable(Map()); // true @@ -4778,7 +4778,7 @@ declare module Immutable { * * * ```js - * const { isCollection, Map, List, Stack } = require('immutable@4.0.0-rc.9'); + * const { isCollection, Map, List, Stack } = require('immutable'); * isCollection([]); // false * isCollection({}); // false * isCollection(Map()); // true @@ -4793,7 +4793,7 @@ declare module Immutable { * * * ```js - * const { isKeyed, Map, List, Stack } = require('immutable@4.0.0-rc.9'); + * const { isKeyed, Map, List, Stack } = require('immutable'); * isKeyed([]); // false * isKeyed({}); // false * isKeyed(Map()); // true @@ -4808,7 +4808,7 @@ declare module Immutable { * * * ```js - * const { isIndexed, Map, List, Stack, Set } = require('immutable@4.0.0-rc.9'); + * const { isIndexed, Map, List, Stack, Set } = require('immutable'); * isIndexed([]); // false * isIndexed({}); // false * isIndexed(Map()); // false @@ -4824,7 +4824,7 @@ declare module Immutable { * * * ```js - * const { isAssociative, Map, List, Stack, Set } = require('immutable@4.0.0-rc.9'); + * const { isAssociative, Map, List, Stack, Set } = require('immutable'); * isAssociative([]); // false * isAssociative({}); // false * isAssociative(Map()); // true @@ -4841,7 +4841,7 @@ declare module Immutable { * * * ```js - * const { isOrdered, Map, OrderedMap, List, Set } = require('immutable@4.0.0-rc.9'); + * const { isOrdered, Map, OrderedMap, List, Set } = require('immutable'); * isOrdered([]); // false * isOrdered({}); // false * isOrdered(Map()); // false @@ -4870,7 +4870,7 @@ declare module Immutable { * * * ```js - * const { get } = require('immutable@4.0.0-rc.9') + * const { get } = require('immutable') * get([ 'dog', 'frog', 'cat' ], 2) // 'frog' * get({ x: 123, y: 456 }, 'x') // 123 * get({ x: 123, y: 456 }, 'z', 'ifNotSet') // 'ifNotSet' @@ -4894,7 +4894,7 @@ declare module Immutable { * * * ```js - * const { has } = require('immutable@4.0.0-rc.9') + * const { has } = require('immutable') * has([ 'dog', 'frog', 'cat' ], 2) // true * has([ 'dog', 'frog', 'cat' ], 5) // false * has({ x: 123, y: 456 }, 'x') // true @@ -4912,7 +4912,7 @@ declare module Immutable { * * * ```js - * const { remove } = require('immutable@4.0.0-rc.9') + * const { remove } = require('immutable') * const originalArray = [ 'dog', 'frog', 'cat' ] * remove(originalArray, 1) // [ 'dog', 'cat' ] * console.log(originalArray) // [ 'dog', 'frog', 'cat' ] @@ -4937,7 +4937,7 @@ declare module Immutable { * * * ```js - * const { set } = require('immutable@4.0.0-rc.9') + * const { set } = require('immutable') * const originalArray = [ 'dog', 'frog', 'cat' ] * set(originalArray, 1, 'cow') // [ 'dog', 'cow', 'cat' ] * console.log(originalArray) // [ 'dog', 'frog', 'cat' ] @@ -4962,7 +4962,7 @@ declare module Immutable { * * * ```js - * const { update } = require('immutable@4.0.0-rc.9') + * const { update } = require('immutable') * const originalArray = [ 'dog', 'frog', 'cat' ] * update(originalArray, 1, val => val.toUpperCase()) // [ 'dog', 'FROG', 'cat' ] * console.log(originalArray) // [ 'dog', 'frog', 'cat' ] @@ -4991,7 +4991,7 @@ declare module Immutable { * * * ```js - * const { getIn } = require('immutable@4.0.0-rc.9') + * const { getIn } = require('immutable') * getIn({ x: { y: { z: 123 }}}, ['x', 'y', 'z']) // 123 * getIn({ x: { y: { z: 123 }}}, ['x', 'q', 'p'], 'ifNotSet') // 'ifNotSet' * ``` @@ -5006,7 +5006,7 @@ declare module Immutable { * * * ```js - * const { hasIn } = require('immutable@4.0.0-rc.9') + * const { hasIn } = require('immutable') * hasIn({ x: { y: { z: 123 }}}, ['x', 'y', 'z']) // true * hasIn({ x: { y: { z: 123 }}}, ['x', 'q', 'p']) // false * ``` @@ -5021,7 +5021,7 @@ declare module Immutable { * * * ```js - * const { removeIn } = require('immutable@4.0.0-rc.9') + * const { removeIn } = require('immutable') * const original = { x: { y: { z: 123 }}} * removeIn(original, ['x', 'y', 'z']) // { x: { y: {}}} * console.log(original) // { x: { y: { z: 123 }}} @@ -5038,7 +5038,7 @@ declare module Immutable { * * * ```js - * const { setIn } = require('immutable@4.0.0-rc.9') + * const { setIn } = require('immutable') * const original = { x: { y: { z: 123 }}} * setIn(original, ['x', 'y', 'z'], 456) // { x: { y: { z: 456 }}} * console.log(original) // { x: { y: { z: 123 }}} @@ -5055,7 +5055,7 @@ declare module Immutable { * * * ```js - * const { updateIn } = require('immutable@4.0.0-rc.9') + * const { updateIn } = require('immutable') * const original = { x: { y: { z: 123 }}} * updateIn(original, ['x', 'y', 'z'], val => val * 6) // { x: { y: { z: 738 }}} * console.log(original) // { x: { y: { z: 123 }}} @@ -5072,7 +5072,7 @@ declare module Immutable { * * * ```js - * const { merge } = require('immutable@4.0.0-rc.9') + * const { merge } = require('immutable') * const original = { x: 123, y: 456 } * merge(original, { y: 789, z: 'abc' }) // { x: 123, y: 789, z: 'abc' } * console.log(original) // { x: { y: { z: 123 }}} @@ -5092,7 +5092,7 @@ declare module Immutable { * * * ```js - * const { mergeWith } = require('immutable@4.0.0-rc.9') + * const { mergeWith } = require('immutable') * const original = { x: 123, y: 456 } * mergeWith( * (oldVal, newVal) => oldVal + newVal, @@ -5117,7 +5117,7 @@ declare module Immutable { * * * ```js - * const { mergeDeep } = require('immutable@4.0.0-rc.9') + * const { mergeDeep } = require('immutable') * const original = { x: { y: 123 }} * mergeDeep(original, { x: { z: 456 }}) // { x: { y: 123, z: 456 }} * console.log(original) // { x: { y: 123 }} @@ -5138,7 +5138,7 @@ declare module Immutable { * * * ```js - * const { mergeDeepWith } = require('immutable@4.0.0-rc.9') + * const { mergeDeepWith } = require('immutable') * const original = { x: { y: 123 }} * mergeDeepWith( * (oldVal, newVal) => oldVal + newVal, From 772691d8f43ac6545e0b6d9042e0e1c19bf95cb2 Mon Sep 17 00:00:00 2001 From: Travis CI Date: Fri, 20 Oct 2017 03:28:40 +0000 Subject: [PATCH 084/242] Deploy 97a33d2a1f00aa1f1a616666f239237afeb41d13 to NPM branch --- dist/immutable-nonambient.d.ts | 19 +++++++++++++++---- dist/immutable.d.ts | 19 +++++++++++++++---- 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/dist/immutable-nonambient.d.ts b/dist/immutable-nonambient.d.ts index 0cb462d2b6..1ea227368f 100644 --- a/dist/immutable-nonambient.d.ts +++ b/dist/immutable-nonambient.d.ts @@ -1280,14 +1280,18 @@ * a mutable copy of this collection. Mutable copies *always* return `this`, * and thus shouldn't be used for equality. Your function should never return * a mutable copy of a collection, only use it internally to create a new - * collection. If possible, use `withMutations` as it provides an easier to - * use API. + * collection. + * + * If possible, use `withMutations` to work with temporary mutable copies as + * it provides an easier to use API and considers many common optimizations. * * Note: if the collection is already mutable, `asMutable` returns itself. * * Note: Not all methods can be used on a mutable collection or within * `withMutations`! Read the documentation for each method to see if it * is safe to use in `withMutations`. + * + * @see `Map#asImmutable` */ asMutable(): this; @@ -1301,8 +1305,15 @@ /** * The yin to `asMutable`'s yang. Because it applies to mutable collections, - * this operation is *mutable* and returns itself. Once performed, the mutable - * copy has become immutable and can be safely returned from a function. + * this operation is *mutable* and may return itself (though may not + * return itself, i.e. if the result is an empty collection). Once + * performed, the original mutable copy must no longer be mutated since it + * may be the immutable result. + * + * If possible, use `withMutations` to work with temporary mutable copies as + * it provides an easier to use API and considers many common optimizations. + * + * @see `Map#asMutable` */ asImmutable(): this; diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index 1f757e06aa..acbc6ea8de 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -1280,14 +1280,18 @@ declare module Immutable { * a mutable copy of this collection. Mutable copies *always* return `this`, * and thus shouldn't be used for equality. Your function should never return * a mutable copy of a collection, only use it internally to create a new - * collection. If possible, use `withMutations` as it provides an easier to - * use API. + * collection. + * + * If possible, use `withMutations` to work with temporary mutable copies as + * it provides an easier to use API and considers many common optimizations. * * Note: if the collection is already mutable, `asMutable` returns itself. * * Note: Not all methods can be used on a mutable collection or within * `withMutations`! Read the documentation for each method to see if it * is safe to use in `withMutations`. + * + * @see `Map#asImmutable` */ asMutable(): this; @@ -1301,8 +1305,15 @@ declare module Immutable { /** * The yin to `asMutable`'s yang. Because it applies to mutable collections, - * this operation is *mutable* and returns itself. Once performed, the mutable - * copy has become immutable and can be safely returned from a function. + * this operation is *mutable* and may return itself (though may not + * return itself, i.e. if the result is an empty collection). Once + * performed, the original mutable copy must no longer be mutated since it + * may be the immutable result. + * + * If possible, use `withMutations` to work with temporary mutable copies as + * it provides an easier to use API and considers many common optimizations. + * + * @see `Map#asMutable` */ asImmutable(): this; From 98f4cc1957dcbf937f0589eaa3e48ae714cbddee Mon Sep 17 00:00:00 2001 From: Travis CI Date: Fri, 20 Oct 2017 03:31:23 +0000 Subject: [PATCH 085/242] Deploy d23746f44ffc025d7bdcee7d7bb79c37d3dc3ea5 to NPM branch --- dist/immutable-nonambient.d.ts | 31 ++++++++++++++++++++++++++++--- dist/immutable.d.ts | 31 ++++++++++++++++++++++++++++--- dist/immutable.js.flow | 4 ++-- 3 files changed, 58 insertions(+), 8 deletions(-) diff --git a/dist/immutable-nonambient.d.ts b/dist/immutable-nonambient.d.ts index 1ea227368f..d09da9d06f 100644 --- a/dist/immutable-nonambient.d.ts +++ b/dist/immutable-nonambient.d.ts @@ -2239,12 +2239,12 @@ * **Flow Typing Records:** * * Immutable.js exports two Flow types designed to make it easier to use - * Records with flow typed code, `RecordOf` and `RecordFactory`. + * Records with flow typed code, `RecordOf` and `RecordFactory`. * * When defining a new kind of Record factory function, use a flow type that * describes the values the record contains along with `RecordFactory`. * To type instances of the Record (which the factory function returns), - * use `RecordOf`. + * use `RecordOf`. * * Typically, new Record definitions will export both the Record factory * function as well as the Record instance type for use in other code. @@ -2254,7 +2254,8 @@ * * // Use RecordFactory for defining new Record factory functions. * type Point3DProps = { x: number, y: number, z: number }; - * const makePoint3D: RecordFactory = Record({ x: 0, y: 0, z: 0 }); + * const defaultValues: Point3DProps = { x: 0, y: 0, z: 0 }; + * const makePoint3D: RecordFactory = Record(defaultValues); * export makePoint3D; * * // Use RecordOf for defining new instances of that Record. @@ -2262,6 +2263,30 @@ * const some3DPoint: Point3D = makePoint3D({ x: 10, y: 20, z: 30 }); * ``` * + * **Flow Typing Record Subclasses:** + * + * Records can be subclassed as a means to add additional methods to Record + * instances. This is generally discouraged in favor of a more functional API, + * since Subclasses have some minor overhead. However the ability to create + * a rich API on Record types can be quite valuable. + * + * When using Flow to type Subclasses, do not use `RecordFactory`, + * instead apply the props type when subclassing: + * + * ```js + * type PersonProps = {name: string, age: number}; + * const defaultValues: PersonProps = {name: 'Aristotle', age: 2400}; + * const PersonRecord = Record(defaultValues); + * class Person extends PersonRecord { + * getName(): string { + * return this.get('name') + * } + * + * setName(name: string): this { + * return this.set('name', name); + * } + * } + * ``` * * **Choosing Records vs plain JavaScript objects** * diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index acbc6ea8de..9a66449a1a 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -2239,12 +2239,12 @@ declare module Immutable { * **Flow Typing Records:** * * Immutable.js exports two Flow types designed to make it easier to use - * Records with flow typed code, `RecordOf` and `RecordFactory`. + * Records with flow typed code, `RecordOf` and `RecordFactory`. * * When defining a new kind of Record factory function, use a flow type that * describes the values the record contains along with `RecordFactory`. * To type instances of the Record (which the factory function returns), - * use `RecordOf`. + * use `RecordOf`. * * Typically, new Record definitions will export both the Record factory * function as well as the Record instance type for use in other code. @@ -2254,7 +2254,8 @@ declare module Immutable { * * // Use RecordFactory for defining new Record factory functions. * type Point3DProps = { x: number, y: number, z: number }; - * const makePoint3D: RecordFactory = Record({ x: 0, y: 0, z: 0 }); + * const defaultValues: Point3DProps = { x: 0, y: 0, z: 0 }; + * const makePoint3D: RecordFactory = Record(defaultValues); * export makePoint3D; * * // Use RecordOf for defining new instances of that Record. @@ -2262,6 +2263,30 @@ declare module Immutable { * const some3DPoint: Point3D = makePoint3D({ x: 10, y: 20, z: 30 }); * ``` * + * **Flow Typing Record Subclasses:** + * + * Records can be subclassed as a means to add additional methods to Record + * instances. This is generally discouraged in favor of a more functional API, + * since Subclasses have some minor overhead. However the ability to create + * a rich API on Record types can be quite valuable. + * + * When using Flow to type Subclasses, do not use `RecordFactory`, + * instead apply the props type when subclassing: + * + * ```js + * type PersonProps = {name: string, age: number}; + * const defaultValues: PersonProps = {name: 'Aristotle', age: 2400}; + * const PersonRecord = Record(defaultValues); + * class Person extends PersonRecord { + * getName(): string { + * return this.get('name') + * } + * + * setName(name: string): this { + * return this.set('name', name); + * } + * } + * ``` * * **Choosing Records vs plain JavaScript objects** * diff --git a/dist/immutable.js.flow b/dist/immutable.js.flow index 5a9fc25663..6859e94eb9 100644 --- a/dist/immutable.js.flow +++ b/dist/immutable.js.flow @@ -1384,8 +1384,8 @@ type RecordValues = _RecordValues<*, R>; declare function isRecord(maybeRecord: any): boolean %checks(maybeRecord instanceof RecordInstance); declare class Record { - static (spec: Values, name?: string): RecordFactory; - constructor(spec: Values, name?: string): RecordFactory; + static (spec: Values, name?: string): typeof RecordInstance; + constructor(spec: Values, name?: string): typeof RecordInstance; static isRecord: typeof isRecord; From cb161ac0053c8b6b04ef5b2820460bab6286d9cb Mon Sep 17 00:00:00 2001 From: Travis CI Date: Tue, 15 May 2018 16:33:22 +0000 Subject: [PATCH 086/242] Deploy 611a3b3fac3756b88ad05f1bc37d1b9fef252d90 to NPM branch --- README.md | 4 ++-- dist/immutable.es.js | 6 +++++- dist/immutable.js | 6 +++++- dist/immutable.min.js | 46 +++++++++++++++++++++---------------------- 4 files changed, 35 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index 7492a177da..5ac56f2145 100644 --- a/README.md +++ b/README.md @@ -556,8 +556,8 @@ Any collection can be converted to a lazy Seq with `Seq()`. ```js -const { Map } = require('immutable') -const map = Map({ a: 1, b: 2, c: 3 } +const { Map, Seq } = require('immutable') +const map = Map({ a: 1, b: 2, c: 3 }) const lazySeq = Seq(map) ``` diff --git a/dist/immutable.es.js b/dist/immutable.es.js index d8d54b3394..ff1899ba53 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -2108,7 +2108,11 @@ function mergeIntoKeyedWith(collection, collections, merger) { if (iters.length === 0) { return collection; } - if (collection.size === 0 && !collection.__ownerID && iters.length === 1) { + if ( + collection.toSeq().size === 0 && + !collection.__ownerID && + iters.length === 1 + ) { return collection.constructor(iters[0]); } return collection.withMutations(function (collection) { diff --git a/dist/immutable.js b/dist/immutable.js index fb76289a52..ccdc4e49e3 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -2114,7 +2114,11 @@ function mergeIntoKeyedWith(collection, collections, merger) { if (iters.length === 0) { return collection; } - if (collection.size === 0 && !collection.__ownerID && iters.length === 1) { + if ( + collection.toSeq().size === 0 && + !collection.__ownerID && + iters.length === 1 + ) { return collection.constructor(iters[0]); } return collection.withMutations(function (collection) { diff --git a/dist/immutable.min.js b/dist/immutable.min.js index 358d879257..df87285e23 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -10,29 +10,29 @@ return t.documentElement&&t.documentElement.uniqueID}}function B(t){var r=ut(t); if(r.call(e,t,o,a))return s++,i(t,n?o:s-1,u)},o),s},i.__iteratorUncached=function(i,o){var u=t.__iterator(Se,o),s=0;return new Ee(function(){for(;;){var o=u.next();if(o.done)return o;var a=o.value,c=a[0],f=a[1];if(r.call(e,f,c,t))return w(i,n?c:s++,f,o)}})},i}function J(t,r,e){var n=$e().asMutable();return t.__iterate(function(i,o){n.update(r.call(e,i,o,t),0,function(t){return t+1})}),n.asImmutable()}function H(t,r,e){var n=l(t),i=(d(t)?mn():$e()).asMutable();t.__iterate(function(o,u){i.update(r.call(e,o,u,t),function(t){return t=t||[],t.push(n?[u,o]:o),t})});var o=ot(t);return i.map(function(r){return nt(t,o(r))})}function V(t,r,e,n){var i=t.size;if(s(r,e,i))return t;var u=a(r,i),f=c(e,i);if(u!==u||f!==f)return V(t.toSeq().cacheResult(),r,e,n);var h,p=f-u;p===p&&(h=p<0?0:p);var _=ut(t);return _.size=0===h?h:t.size&&h||void 0,!n&&q(t)&&h>=0&&(_.get=function(r,e){return r=o(this,r),r>=0&&rh)return z();var t=i.next();return n||r===ze||t.done?t:r===we?w(r,s-1,void 0,t):w(r,s-1,t.value[1],t)})},_}function Y(t,r,e){var n=ut(t);return n.__iterateUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterate(n,i);var u=0;return t.__iterate(function(t,i,s){return r.call(e,t,i,s)&&++u&&n(t,i,o)}),u},n.__iteratorUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterator(n,i);var u=t.__iterator(Se,i),s=!0;return new Ee(function(){if(!s)return z();var t=u.next();if(t.done)return t;var i=t.value,a=i[0],c=i[1];return r.call(e,c,a,o)?n===Se?t:w(n,a,c,t):(s=!1,z())})},n}function Q(t,r,e,n){var i=ut(t);return i.__iterateUncached=function(i,o){var u=this ;if(o)return this.cacheResult().__iterate(i,o);var s=!0,a=0;return t.__iterate(function(t,o,c){if(!s||!(s=r.call(e,t,o,c)))return a++,i(t,n?o:a-1,u)}),a},i.__iteratorUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterator(i,o);var s=t.__iterator(Se,o),a=!0,c=0;return new Ee(function(){var t,o,f;do{if(t=s.next(),t.done)return n||i===ze?t:i===we?w(i,c++,void 0,t):w(i,c++,t.value[1],t);var h=t.value;o=h[0],f=h[1],a&&(a=r.call(e,f,o,u))}while(a);return i===Se?t:w(i,o,f,t)})},i}function X(t,r){var e=l(t),n=[t].concat(r).map(function(t){return _(t)?e&&(t=de(t)):t=e?D(t):x(Array.isArray(t)?t:[t]),t}).filter(function(t){return 0!==t.size});if(0===n.length)return t;if(1===n.length){var i=n[0];if(i===t||e&&l(i)||v(t)&&v(i))return i}var o=new ke(n);return e?o=o.toKeyedSeq():v(t)||(o=o.toSetSeq()),o=o.flatten(!0),o.size=n.reduce(function(t,r){if(void 0!==t){var e=r.size;if(void 0!==e)return t+e}},0),o}function F(t,r,e){var n=ut(t);return n.__iterateUncached=function(i,o){function u(t,c){t.__iterate(function(t,o){return(!r||c0}function et(t,r,e,n){var i=ut(t),o=new ke(e).map(function(t){return t.size});return i.size=n?o.max():o.min(),i.__iterate=function(t,r){for(var e,n=this,i=this.__iterator(ze,r),o=0;!(e=i.next()).done&&t(e.value,o++,n)!==!1;);return o},i.__iteratorUncached=function(t,i){var o=e.map(function(t){return t=ye(t),b(i?t.reverse():t)}),u=0,s=!1;return new Ee(function(){var e;return s||(e=o.map(function(t){return t.next()}),s=n?e.every(function(t){return t.done}):e.some(function(t){return t.done})),s?z():w(t,u++,r.apply(null,e.map(function(t){return t.value})))})},i}function nt(t,r){return t===r?t:q(t)?r:t.constructor(r)}function it(t){if(t!==Object(t))throw new TypeError("Expected [K, V] tuple: "+t)}function ot(t){return l(t)?de:v(t)?ge:me}function ut(t){return Object.create((l(t)?De:v(t)?xe:Ae).prototype)}function st(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size,this):Me.prototype.cacheResult.call(this)}function at(t,r){return void 0===t&&void 0===r?0:void 0===t?1:void 0===r?-1:t>r?1:t0;)r[e]=arguments[e+1];return jt(this,r,t)}function jt(t,r,e){for(var n=[],i=0;i0;)r[e]=arguments[e+1];return Ct(t,r)}function Rt(t,r){for(var e=[],n=arguments.length-2;n-- >0;)e[n]=arguments[n+2];return Ct(r,e,t)}function Ut(t){for(var r=[],e=arguments.length-1;e-- >0;)r[e]=arguments[e+1];return Tt(t,r)}function Kt(t,r){for(var e=[],n=arguments.length-2;n-- >0;)e[n]=arguments[n+2];return Tt(r,e,t)}function Tt(t,r,e){return Ct(t,r,Lt(e))}function Ct(t,r,e){if(!lt(t))throw new TypeError("Cannot merge into non-data-structure value: "+t);if(p(t))return t.mergeWith?t.mergeWith.apply(t,[e].concat(r)):t.concat.apply(t,r);for(var n=Array.isArray(t),i=t,o=n?ge:de,u=n?function(r){i===t&&(i=gt(i)),i.push(r)}:function(r,n){var o=qe.call(i,n),u=o&&e?e(i[n],r,n):r;o&&u===i[n]||(i===t&&(i=gt(i)),i[n]=u)},s=0;s0;)r[e]=arguments[e+1];return Tt(this,r,t)}function Nt(t){for(var r=[],e=arguments.length-1;e-- >0;)r[e]=arguments[e+1];return zt(this,t,Zt(),function(t){return Ct(t,r)})}function Pt(t){for(var r=[],e=arguments.length-1;e-- >0;)r[e]=arguments[e+1];return zt(this,t,Zt(),function(t){return Tt(t,r)})}function Jt(t){var r=this.asMutable();return t(r),r.wasAltered()?r.__ensureOwner(this.__ownerID):this}function Ht(){return this.__ownerID?this:this.__ensureOwner(new n)}function Vt(){return this.__ensureOwner()}function Yt(){return this.__altered}function Qt(t){return!(!t||!t[tn])}function Xt(t,r){return w(t,r[0],r[1])}function Ft(t,r){return{node:t,index:0,__prev:r}}function Gt(t,r,e,n){var i=Object.create(rn);return i.size=t,i._root=r,i.__ownerID=e,i.__hash=n,i.__altered=!1,i}function Zt(){return an||(an=Gt(0))}function $t(t,e,n){ -var i,o;if(t._root){var u=r(ce),s=r(fe);if(i=tr(t._root,t.__ownerID,0,void 0,e,n,u,s),!s.value)return t;o=t.size+(u.value?n===ae?-1:1:0)}else{if(n===ae)return t;o=1,i=new en(t.__ownerID,[[e,n]])}return t.__ownerID?(t.size=o,t._root=i,t.__hash=void 0,t.__altered=!0,t):i?Gt(o,i):Zt()}function tr(t,r,n,i,o,u,s,a){return t?t.update(r,n,i,o,u,s,a):u===ae?t:(e(a),e(s),new sn(r,i,[o,u]))}function rr(t){return t.constructor===sn||t.constructor===un}function er(t,r,e,n,i){if(t.keyHash===n)return new un(r,n,[t.entry,i]);var o,u=(0===e?t.keyHash:t.keyHash>>>e)&se,s=(0===e?n:n>>>e)&se;return new nn(r,1<>>=1)u[s]=1&e?r[o++]:void 0;return u[n]=i,new on(t,o+1,u)}function ur(t){return t-=t>>1&1431655765,t=(858993459&t)+(t>>2&858993459),t=t+(t>>4)&252645135,t+=t>>8,127&(t+=t>>16)}function sr(t,r,e,n){var i=n?t:ct(t);return i[r]=e,i}function ar(t,r,e,n){var i=t.length+1;if(n&&r+1===i)return t[r]=e,t;for(var o=Array(i),u=0,s=0;so?0:o-e,c=u-e;return c>ue&&(c=ue),function(){if(i===c)return gn;var t=r?--c:i++;return n&&n[t]}}function i(t,n,i){var s,a=t&&t.array,c=i>o?0:o-i>>n,f=1+(u-i>>n);return f>ue&&(f=ue),function(){for(;;){if(s){var t=s();if(t!==gn)return t;s=null}if(c===f)return gn;var o=r?--f:c++;s=e(a&&a[o],n-oe,i+(o<=t.size||e<0)return t.withMutations(function(t){e<0?gr(t,e).set(0,n):gr(t,0,e+1).set(e,n)});e+=t._origin;var i=t._tail,u=t._root,s=r(fe);return e>=mr(t._capacity)?i=vr(i,t.__ownerID,0,e,n,s):u=vr(u,t.__ownerID,t._level,e,n,s),s.value?t.__ownerID?(t._root=u,t._tail=i,t.__hash=void 0,t.__altered=!0,t):pr(t._origin,t._capacity,t._level,u,i):t}function vr(t,r,n,i,o,u){var s=i>>>n&se,a=t&&s0){var f=t&&t.array[s],h=vr(f,r,n-oe,i,o,u);return h===f?t:(c=yr(t,r),c.array[s]=h,c)}return a&&t.array[s]===o?t:(e(u),c=yr(t,r),void 0===o&&s===c.array.length-1?c.array.pop():c.array[s]=o,c)}function yr(t,r){return r&&t&&r===t.ownerID?t:new yn(t?t.array.slice():[],r)}function dr(t,r){if(r>=mr(t._capacity))return t._tail;if(r<1<0;)e=e.array[r>>>n&se],n-=oe;return e}}function gr(t,r,e){void 0!==r&&(r|=0),void 0!==e&&(e|=0);var i=t.__ownerID||new n,o=t._origin,u=t._capacity,s=o+r,a=void 0===e?u:e<0?u+e:o+e;if(s===o&&a===u)return t;if(s>=a)return t.clear();for(var c=t._level,f=t._root,h=0;s+h<0;)f=new yn(f&&f.array.length?[void 0,f]:[],i),c+=oe,h+=1<=1<p?new yn([],i):l;if(l&&_>p&&soe;d-=oe){var g=p>>>d&se;y=y.array[g]=yr(y.array[g],i)}y.array[p>>>oe&se]=l}if(a=_)s-=_,a-=_,c=oe,f=null,v=v&&v.removeBefore(i,0,s);else if(s>o||_>>c&se;if(m!==_>>>c&se)break;m&&(h+=(1<o&&(f=f.removeBefore(i,c,s-h)),f&&_>>oe<=ue&&u.size>=2*o.size?(i=u.filter(function(t,r){return void 0!==t&&s!==r}),n=i.toKeyedSeq().map(function(t){return t[0]}).flip().toMap(),t.__ownerID&&(n.__ownerID=i.__ownerID=t.__ownerID)):(n=o.remove(r),i=s===u.size-1?u.pop():u.set(s,void 0))}else if(a){if(e===u.get(s)[1])return t;n=o,i=u.set(s,[r,e])}else n=o.set(r,u.size),i=u.set(u.size,[r,e]);return t.__ownerID?(t.size=n.size,t._map=n,t._list=i,t.__hash=void 0,t):zr(n,i)}function br(t){return!(!t||!t[Sn])}function Or(t,r,e,n){var i=Object.create(In);return i.size=t,i._head=r,i.__ownerID=e,i.__hash=n,i.__altered=!1,i}function Er(){return bn||(bn=Or(0))}function qr(t,r){if(t===r)return!0;if(!_(r)||void 0!==t.size&&void 0!==r.size&&t.size!==r.size||void 0!==t.__hash&&void 0!==r.__hash&&t.__hash!==r.__hash||l(t)!==l(r)||v(t)!==v(r)||d(t)!==d(r))return!1;if(0===t.size&&0===r.size)return!0;var e=!y(t);if(d(t)){var n=t.entries();return r.every(function(t,r){var i=n.next().value;return i&&k(i[1],t)&&(e||k(i[0],r))})&&n.next().done}var i=!1;if(void 0===t.size)if(void 0===r.size)"function"==typeof t.cacheResult&&t.cacheResult();else{i=!0;var o=t;t=r,r=o}var u=!0,s=r.__iterate(function(r,n){if(e?!t.has(r):i?!k(r,t.get(n,ae)):!k(t.get(n,ae),r))return u=!1,!1});return u&&t.size===s}function Mr(t,r){var e=function(e){t.prototype[e]=r[e]};return Object.keys(r).forEach(e),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(r).forEach(e),t}function Dr(t){return lt(t)?Me(t).map(Dr).toJSON():t}function xr(t){return!(!t||!t[En])}function Ar(t,r){return t.__ownerID?(t.size=r.size,t._map=r, -t):r===t._map?t:0===r.size?t.__empty():t.__make(r)}function jr(t,r){var e=Object.create(qn);return e.size=t?t.size:0,e._map=t,e.__ownerID=r,e}function kr(){return Mn||(Mn=jr(Zt()))}function Rr(t,r,e){for(var n=pt(r),i=0;i!==n.length;)if((t=dt(t,n[i++],ae))===ae)return e;return t}function Ur(t,r){return Rr(this,t,r)}function Kr(t,r){return Rr(t,r,ae)!==ae}function Tr(t){return Kr(this,t)}function Cr(){ht(this.size);var t={};return this.__iterate(function(r,e){t[e]=r}),t}function Lr(t,r,e,n,i,o){return ht(t.size),t.__iterate(function(t,o,u){i?(i=!1,e=t):e=r.call(n,e,t,o,u)},o),e}function Br(t,r){return r}function Wr(t,r){return[r,t]}function Nr(t){return function(){return!t.apply(this,arguments)}}function Pr(t){return function(){return-t.apply(this,arguments)}}function Jr(){return ct(arguments)}function Hr(t,r){return tr?-1:0}function Vr(t){if(t.size===1/0)return 0;var r=d(t),e=l(t),n=r?1:0;return Yr(t.__iterate(e?r?function(t,r){n=31*n+Qr(U(t),U(r))|0}:function(t,r){n=n+Qr(U(t),U(r))|0}:r?function(t){n=31*n+U(t)|0}:function(t){n=n+U(t)|0}),n)}function Yr(t,r){return r=Le(r,3432918353),r=Le(r<<15|r>>>-15,461845907),r=Le(r<<13|r>>>-13,5),r=(r+3864292196|0)^t,r=Le(r^r>>>16,2246822507),r=Le(r^r>>>13,3266489909),r=R(r^r>>>16)}function Qr(t,r){return t^r+2654435769+(t<<6)+(t>>2)|0}function Xr(t){return xr(t)&&d(t)}function Fr(t,r){var e=Object.create(Un);return e.size=t?t.size:0,e._map=t,e.__ownerID=r,e}function Gr(){return Kn||(Kn=Fr(Sr()))}function Zr(t,r,e){var n=Object.create(Object.getPrototypeOf(t));return n._values=r,n.__ownerID=e,n}function $r(t){return t._name||t.constructor.name||"Record"}function te(t){return D(t._keys.map(function(r){return[r,t.get(r)]}))}function re(t,r){try{Object.defineProperty(t,r,{get:function(){return this.get(r)},set:function(t){ft(this.__ownerID,"Cannot set on an immutable record."),this.set(r,t)}})}catch(t){}}function ee(t,r){return ne([],r||ie,t,"",r&&r.length>2?[]:void 0,{"":t})}function ne(t,r,e,n,i,o){var u=Array.isArray(e)?xe:_t(e)?De:null;if(u){ -if(~t.indexOf(e))throw new TypeError("Cannot convert circular structure to Immutable");t.push(e),i&&""!==n&&i.push(n);var s=r.call(o,n,u(e).map(function(n,o){return ne(t,r,n,o,i,e)}),i&&i.slice());return t.pop(),i&&i.pop(),s}return e}function ie(t,r){return l(r)?r.toMap():r.toList()}var oe=5,ue=1<=n.length){var r=e.next();if(r.done)return r;n[i]=r.value}return w(t,i,n[i++])})},r}(xe),Le="function"==typeof Math.imul&&Math.imul(4294967295,2)===-2?Math.imul:function(t,r){t|=0,r|=0;var e=65535&t,n=65535&r;return e*n+((t>>>16)*n+e*(r>>>16)<<16>>>0)|0},Be=Object.isExtensible,We=function(){try{return Object.defineProperty({},"@",{}),!0}catch(t){return!1}}(),Ne="function"==typeof WeakMap -;Ne&&(Ke=new WeakMap);var Pe=0,Je="__immutablehash__";"function"==typeof Symbol&&(Je=Symbol(Je));var He=16,Ve=255,Ye=0,Qe={},Xe=function(t){function r(t,r){this._iter=t,this._useKeys=r,this.size=t.size}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.prototype.get=function(t,r){return this._iter.get(t,r)},r.prototype.has=function(t){return this._iter.has(t)},r.prototype.valueSeq=function(){return this._iter.valueSeq()},r.prototype.reverse=function(){var t=this,r=N(this,!0);return this._useKeys||(r.valueSeq=function(){return t._iter.toSeq().reverse()}),r},r.prototype.map=function(t,r){var e=this,n=W(this,t,r);return this._useKeys||(n.valueSeq=function(){return e._iter.toSeq().map(t,r)}),n},r.prototype.__iterate=function(t,r){var e=this;return this._iter.__iterate(function(r,n){return t(r,n,e)},r)},r.prototype.__iterator=function(t,r){return this._iter.__iterator(t,r)},r}(De);Xe.prototype[le]=!0;var Fe=function(t){function r(t){this._iter=t,this.size=t.size}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.prototype.includes=function(t){return this._iter.includes(t)},r.prototype.__iterate=function(t,r){var e=this,n=0;return r&&i(this),this._iter.__iterate(function(i){return t(i,r?e.size-++n:n++,e)},r)},r.prototype.__iterator=function(t,r){var e=this,n=this._iter.__iterator(ze,r),o=0;return r&&i(this),new Ee(function(){var i=n.next();return i.done?i:w(t,r?e.size-++o:o++,i.value,i)})},r}(xe),Ge=function(t){function r(t){this._iter=t,this.size=t.size}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.prototype.has=function(t){return this._iter.includes(t)},r.prototype.__iterate=function(t,r){var e=this;return this._iter.__iterate(function(r){return t(r,r,e)},r)},r.prototype.__iterator=function(t,r){var e=this._iter.__iterator(ze,r);return new Ee(function(){var r=e.next();return r.done?r:w(t,r.value,r.value,r)})},r}(Ae),Ze=function(t){function r(t){this._iter=t,this.size=t.size} -return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.prototype.entrySeq=function(){return this._iter.toSeq()},r.prototype.__iterate=function(t,r){var e=this;return this._iter.__iterate(function(r){if(r){it(r);var n=_(r);return t(n?r.get(1):r[1],n?r.get(0):r[0],e)}},r)},r.prototype.__iterator=function(t,r){var e=this._iter.__iterator(ze,r);return new Ee(function(){for(;;){var r=e.next();if(r.done)return r;var n=r.value;if(n){it(n);var i=_(n);return w(t,i?n.get(0):n[0],i?n.get(1):n[1],r)}}})},r}(De);Fe.prototype.cacheResult=Xe.prototype.cacheResult=Ge.prototype.cacheResult=Ze.prototype.cacheResult=st;var $e=function(t){function r(r){return null===r||void 0===r?Zt():Qt(r)&&!d(r)?r:Zt().withMutations(function(e){var n=t(r);ht(n.size),n.forEach(function(t,r){return e.set(r,t)})})}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.of=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return Zt().withMutations(function(r){for(var e=0;e=t.length)throw Error("Missing value for key: "+t[e]);r.set(t[e],t[e+1])}})},r.prototype.toString=function(){return this.__toString("Map {","}")},r.prototype.get=function(t,r){return this._root?this._root.get(0,void 0,t,r):r},r.prototype.set=function(t,r){return $t(this,t,r)},r.prototype.remove=function(t){return $t(this,t,ae)},r.prototype.deleteAll=function(t){var r=ye(t);return 0===r.size?this:this.withMutations(function(t){r.forEach(function(r){return t.remove(r)})})},r.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):Zt()},r.prototype.sort=function(t){return mn($(this,t))},r.prototype.sortBy=function(t,r){return mn($(this,r,t))},r.prototype.__iterator=function(t,r){return new cn(this,t,r)},r.prototype.__iterate=function(t,r){var e=this,n=0;return this._root&&this._root.iterate(function(r){return n++,t(r[1],r[0],e)},r),n},r.prototype.__ensureOwner=function(t){ -return t===this.__ownerID?this:t?Gt(this.size,this._root,t,this.__hash):0===this.size?Zt():(this.__ownerID=t,this.__altered=!1,this)},r}(de);$e.isMap=Qt;var tn="@@__IMMUTABLE_MAP__@@",rn=$e.prototype;rn[tn]=!0,rn.delete=rn.remove,rn.removeAll=rn.deleteAll,rn.setIn=bt,rn.removeIn=rn.deleteIn=Et,rn.update=Mt,rn.updateIn=Dt,rn.merge=rn.concat=xt,rn.mergeWith=At,rn.mergeDeep=Bt,rn.mergeDeepWith=Wt,rn.mergeIn=Nt,rn.mergeDeepIn=Pt,rn.withMutations=Jt,rn.wasAltered=Yt,rn.asImmutable=Vt,rn["@@transducer/init"]=rn.asMutable=Ht,rn["@@transducer/step"]=function(t,r){return t.set(r[0],r[1])},rn["@@transducer/result"]=function(t){return t.asImmutable()};var en=function(t,r){this.ownerID=t,this.entries=r};en.prototype.get=function(t,r,e,n){for(var i=this.entries,o=0,u=i.length;o=fn)return nr(t,c,i,o);var _=t&&t===this.ownerID,l=_?c:ct(c);return p?a?f===h-1?l.pop():l[f]=l.pop():l[f]=[i,o]:l.push([i,o]),_?(this.entries=l,this):new en(t,l)}};var nn=function(t,r,e){this.ownerID=t,this.bitmap=r,this.nodes=e};nn.prototype.get=function(t,r,e,n){void 0===r&&(r=U(e));var i=1<<((0===t?r:r>>>t)&se),o=this.bitmap;return 0==(o&i)?n:this.nodes[ur(o&i-1)].get(t+oe,r,e,n)},nn.prototype.update=function(t,r,e,n,i,o,u){void 0===e&&(e=U(n));var s=(0===r?e:e>>>r)&se,a=1<=hn)return or(t,p,c,s,l);if(f&&!l&&2===p.length&&rr(p[1^h]))return p[1^h];if(f&&l&&1===p.length&&rr(l))return l;var v=t&&t===this.ownerID,y=f?l?c:c^a:c|a,d=f?l?sr(p,h,l,v):cr(p,h,v):ar(p,h,l,v);return v?(this.bitmap=y,this.nodes=d,this):new nn(t,y,d)};var on=function(t,r,e){this.ownerID=t,this.count=r,this.nodes=e};on.prototype.get=function(t,r,e,n){ -void 0===r&&(r=U(e));var i=(0===t?r:r>>>t)&se,o=this.nodes[i];return o?o.get(t+oe,r,e,n):n},on.prototype.update=function(t,r,e,n,i,o,u){void 0===e&&(e=U(n));var s=(0===r?e:e>>>r)&se,a=i===ae,c=this.nodes,f=c[s];if(a&&!f)return this;var h=tr(f,t,r+oe,e,n,i,o,u);if(h===f)return this;var p=this.count;if(f){if(!h&&--p0&&i=0&&t>>r&se;if(n>=this.array.length)return new yn([],t);var i,o=0===n;if(r>0){var u=this.array[n];if((i=u&&u.removeBefore(t,r-oe,e))===u&&o)return this}if(o&&!i)return this;var s=yr(this,t);if(!o)for(var a=0;a>>r&se;if(n>=this.array.length)return this;var i;if(r>0){var o=this.array[n];if((i=o&&o.removeAfter(t,r-oe,e))===o&&n===this.array.length-1)return this}var u=yr(this,t);return u.array.splice(n+1),i&&(u.array[n]=i),u};var dn,gn={},mn=function(t){function r(t){ -return null===t||void 0===t?Sr():wr(t)?t:Sr().withMutations(function(r){var e=de(t);ht(e.size),e.forEach(function(t,e){return r.set(e,t)})})}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.of=function(){return this(arguments)},r.prototype.toString=function(){return this.__toString("OrderedMap {","}")},r.prototype.get=function(t,r){var e=this._map.get(t);return void 0!==e?this._list.get(e)[1]:r},r.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._map.clear(),this._list.clear(),this):Sr()},r.prototype.set=function(t,r){return Ir(this,t,r)},r.prototype.remove=function(t){return Ir(this,t,ae)},r.prototype.wasAltered=function(){return this._map.wasAltered()||this._list.wasAltered()},r.prototype.__iterate=function(t,r){var e=this;return this._list.__iterate(function(r){return r&&t(r[1],r[0],e)},r)},r.prototype.__iterator=function(t,r){return this._list.fromEntrySeq().__iterator(t,r)},r.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var r=this._map.__ensureOwner(t),e=this._list.__ensureOwner(t);return t?zr(r,e,t,this.__hash):0===this.size?Sr():(this.__ownerID=t,this._map=r,this._list=e,this)},r}($e);mn.isOrderedMap=wr,mn.prototype[le]=!0,mn.prototype.delete=mn.prototype.remove;var wn,zn=function(t){function r(t){return null===t||void 0===t?Er():br(t)?t:Er().pushAll(t)}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.of=function(){return this(arguments)},r.prototype.toString=function(){return this.__toString("Stack [","]")},r.prototype.get=function(t,r){var e=this._head;for(t=o(this,t);e&&t--;)e=e.next;return e?e.value:r},r.prototype.peek=function(){return this._head&&this._head.value},r.prototype.push=function(){var t=arguments;if(0===arguments.length)return this;for(var r=this.size+arguments.length,e=this._head,n=arguments.length-1;n>=0;n--)e={value:t[n],next:e};return this.__ownerID?(this.size=r,this._head=e,this.__hash=void 0,this.__altered=!0,this):Or(r,e)}, -r.prototype.pushAll=function(r){if(r=t(r),0===r.size)return this;if(0===this.size&&br(r))return r;ht(r.size);var e=this.size,n=this._head;return r.__iterate(function(t){e++,n={value:t,next:n}},!0),this.__ownerID?(this.size=e,this._head=n,this.__hash=void 0,this.__altered=!0,this):Or(e,n)},r.prototype.pop=function(){return this.slice(1)},r.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):Er()},r.prototype.slice=function(r,e){if(s(r,e,this.size))return this;var n=a(r,this.size);if(c(e,this.size)!==this.size)return t.prototype.slice.call(this,r,e);for(var i=this.size-n,o=this._head;n--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):Or(i,o)},r.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Or(this.size,this._head,t,this.__hash):0===this.size?Er():(this.__ownerID=t,this.__altered=!1,this)},r.prototype.__iterate=function(t,r){var e=this;if(r)return new ke(this.toArray()).__iterate(function(r,n){return t(r,n,e)},r);for(var n=0,i=this._head;i&&t(i.value,n++,e)!==!1;)i=i.next;return n},r.prototype.__iterator=function(t,r){if(r)return new ke(this.toArray()).__iterator(t,r);var e=0,n=this._head;return new Ee(function(){if(n){var r=n.value;return n=n.next,w(t,e++,r)}return z()})},r}(ge);zn.isStack=br;var Sn="@@__IMMUTABLE_STACK__@@",In=zn.prototype;In[Sn]=!0,In.shift=In.pop,In.unshift=In.push,In.unshiftAll=In.pushAll,In.withMutations=Jt,In.wasAltered=Yt,In.asImmutable=Vt,In["@@transducer/init"]=In.asMutable=Ht,In["@@transducer/step"]=function(t,r){return t.unshift(r)},In["@@transducer/result"]=function(t){return t.asImmutable()};var bn,On=function(t){function r(r){return null===r||void 0===r?kr():xr(r)&&!d(r)?r:kr().withMutations(function(e){var n=t(r);ht(n.size),n.forEach(function(t){return e.add(t)})})}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.of=function(){return this(arguments)},r.fromKeys=function(t){ -return this(de(t).keySeq())},r.intersect=function(t){return t=ye(t).toArray(),t.length?qn.intersect.apply(r(t.pop()),t):kr()},r.union=function(t){return t=ye(t).toArray(),t.length?qn.union.apply(r(t.pop()),t):kr()},r.prototype.toString=function(){return this.__toString("Set {","}")},r.prototype.has=function(t){return this._map.has(t)},r.prototype.add=function(t){return Ar(this,this._map.set(t,t))},r.prototype.remove=function(t){return Ar(this,this._map.remove(t))},r.prototype.clear=function(){return Ar(this,this._map.clear())},r.prototype.union=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];return r=r.filter(function(t){return 0!==t.size}),0===r.length?this:0!==this.size||this.__ownerID||1!==r.length?this.withMutations(function(e){for(var n=0;n=0&&r=0&&ethis.size?r:this.find(function(r,e){return e===t},void 0,r)},has:function(t){return(t=o(this,t))>=0&&(void 0!==this.size?this.size===1/0||t0;)r[e]=arguments[e+1];return jt(this,r,t)}function jt(t,r,e){for(var n=[],i=0;i0;)r[e]=arguments[e+1];return Ct(t,r)}function Rt(t,r){for(var e=[],n=arguments.length-2;n-- >0;)e[n]=arguments[n+2];return Ct(r,e,t)}function Ut(t){for(var r=[],e=arguments.length-1;e-- >0;)r[e]=arguments[e+1];return Tt(t,r)}function Kt(t,r){for(var e=[],n=arguments.length-2;n-- >0;)e[n]=arguments[n+2];return Tt(r,e,t)}function Tt(t,r,e){return Ct(t,r,Lt(e))}function Ct(t,r,e){if(!lt(t))throw new TypeError("Cannot merge into non-data-structure value: "+t);if(p(t))return t.mergeWith?t.mergeWith.apply(t,[e].concat(r)):t.concat.apply(t,r);for(var n=Array.isArray(t),i=t,o=n?ge:de,u=n?function(r){i===t&&(i=gt(i)),i.push(r)}:function(r,n){var o=qe.call(i,n),u=o&&e?e(i[n],r,n):r;o&&u===i[n]||(i===t&&(i=gt(i)),i[n]=u)},s=0;s0;)r[e]=arguments[e+1];return Tt(this,r,t)}function Nt(t){for(var r=[],e=arguments.length-1;e-- >0;)r[e]=arguments[e+1];return zt(this,t,Zt(),function(t){return Ct(t,r)})}function Pt(t){for(var r=[],e=arguments.length-1;e-- >0;)r[e]=arguments[e+1];return zt(this,t,Zt(),function(t){return Tt(t,r)})}function Jt(t){var r=this.asMutable();return t(r),r.wasAltered()?r.__ensureOwner(this.__ownerID):this}function Ht(){return this.__ownerID?this:this.__ensureOwner(new n)}function Vt(){return this.__ensureOwner()}function Yt(){return this.__altered}function Qt(t){return!(!t||!t[tn])}function Xt(t,r){return w(t,r[0],r[1])}function Ft(t,r){return{node:t,index:0,__prev:r}}function Gt(t,r,e,n){var i=Object.create(rn);return i.size=t,i._root=r, +i.__ownerID=e,i.__hash=n,i.__altered=!1,i}function Zt(){return an||(an=Gt(0))}function $t(t,e,n){var i,o;if(t._root){var u=r(ce),s=r(fe);if(i=tr(t._root,t.__ownerID,0,void 0,e,n,u,s),!s.value)return t;o=t.size+(u.value?n===ae?-1:1:0)}else{if(n===ae)return t;o=1,i=new en(t.__ownerID,[[e,n]])}return t.__ownerID?(t.size=o,t._root=i,t.__hash=void 0,t.__altered=!0,t):i?Gt(o,i):Zt()}function tr(t,r,n,i,o,u,s,a){return t?t.update(r,n,i,o,u,s,a):u===ae?t:(e(a),e(s),new sn(r,i,[o,u]))}function rr(t){return t.constructor===sn||t.constructor===un}function er(t,r,e,n,i){if(t.keyHash===n)return new un(r,n,[t.entry,i]);var o,u=(0===e?t.keyHash:t.keyHash>>>e)&se,s=(0===e?n:n>>>e)&se;return new nn(r,1<>>=1)u[s]=1&e?r[o++]:void 0;return u[n]=i,new on(t,o+1,u)}function ur(t){return t-=t>>1&1431655765,t=(858993459&t)+(t>>2&858993459),t=t+(t>>4)&252645135,t+=t>>8,127&(t+=t>>16)}function sr(t,r,e,n){var i=n?t:ct(t);return i[r]=e,i}function ar(t,r,e,n){var i=t.length+1;if(n&&r+1===i)return t[r]=e,t;for(var o=Array(i),u=0,s=0;so?0:o-e,c=u-e;return c>ue&&(c=ue),function(){if(i===c)return gn;var t=r?--c:i++;return n&&n[t]}}function i(t,n,i){var s,a=t&&t.array,c=i>o?0:o-i>>n,f=1+(u-i>>n);return f>ue&&(f=ue),function(){for(;;){if(s){var t=s();if(t!==gn)return t;s=null}if(c===f)return gn +;var o=r?--f:c++;s=e(a&&a[o],n-oe,i+(o<=t.size||e<0)return t.withMutations(function(t){e<0?gr(t,e).set(0,n):gr(t,0,e+1).set(e,n)});e+=t._origin;var i=t._tail,u=t._root,s=r(fe);return e>=mr(t._capacity)?i=vr(i,t.__ownerID,0,e,n,s):u=vr(u,t.__ownerID,t._level,e,n,s),s.value?t.__ownerID?(t._root=u,t._tail=i,t.__hash=void 0,t.__altered=!0,t):pr(t._origin,t._capacity,t._level,u,i):t}function vr(t,r,n,i,o,u){var s=i>>>n&se,a=t&&s0){var f=t&&t.array[s],h=vr(f,r,n-oe,i,o,u);return h===f?t:(c=yr(t,r),c.array[s]=h,c)}return a&&t.array[s]===o?t:(e(u),c=yr(t,r),void 0===o&&s===c.array.length-1?c.array.pop():c.array[s]=o,c)}function yr(t,r){return r&&t&&r===t.ownerID?t:new yn(t?t.array.slice():[],r)}function dr(t,r){if(r>=mr(t._capacity))return t._tail;if(r<1<0;)e=e.array[r>>>n&se],n-=oe;return e}}function gr(t,r,e){void 0!==r&&(r|=0),void 0!==e&&(e|=0);var i=t.__ownerID||new n,o=t._origin,u=t._capacity,s=o+r,a=void 0===e?u:e<0?u+e:o+e;if(s===o&&a===u)return t;if(s>=a)return t.clear();for(var c=t._level,f=t._root,h=0;s+h<0;)f=new yn(f&&f.array.length?[void 0,f]:[],i),c+=oe,h+=1<=1<p?new yn([],i):l;if(l&&_>p&&soe;d-=oe){var g=p>>>d&se;y=y.array[g]=yr(y.array[g],i)}y.array[p>>>oe&se]=l}if(a=_)s-=_,a-=_,c=oe,f=null,v=v&&v.removeBefore(i,0,s);else if(s>o||_>>c&se;if(m!==_>>>c&se)break;m&&(h+=(1<o&&(f=f.removeBefore(i,c,s-h)),f&&_>>oe<=ue&&u.size>=2*o.size?(i=u.filter(function(t,r){return void 0!==t&&s!==r}),n=i.toKeyedSeq().map(function(t){return t[0]}).flip().toMap(),t.__ownerID&&(n.__ownerID=i.__ownerID=t.__ownerID)):(n=o.remove(r),i=s===u.size-1?u.pop():u.set(s,void 0))}else if(a){if(e===u.get(s)[1])return t;n=o,i=u.set(s,[r,e])}else n=o.set(r,u.size),i=u.set(u.size,[r,e]);return t.__ownerID?(t.size=n.size,t._map=n,t._list=i,t.__hash=void 0,t):zr(n,i)}function br(t){return!(!t||!t[Sn])}function Or(t,r,e,n){var i=Object.create(In);return i.size=t,i._head=r,i.__ownerID=e,i.__hash=n,i.__altered=!1,i}function Er(){return bn||(bn=Or(0))}function qr(t,r){if(t===r)return!0;if(!_(r)||void 0!==t.size&&void 0!==r.size&&t.size!==r.size||void 0!==t.__hash&&void 0!==r.__hash&&t.__hash!==r.__hash||l(t)!==l(r)||v(t)!==v(r)||d(t)!==d(r))return!1;if(0===t.size&&0===r.size)return!0;var e=!y(t);if(d(t)){var n=t.entries();return r.every(function(t,r){var i=n.next().value;return i&&k(i[1],t)&&(e||k(i[0],r))})&&n.next().done}var i=!1;if(void 0===t.size)if(void 0===r.size)"function"==typeof t.cacheResult&&t.cacheResult();else{i=!0;var o=t;t=r,r=o}var u=!0,s=r.__iterate(function(r,n){if(e?!t.has(r):i?!k(r,t.get(n,ae)):!k(t.get(n,ae),r))return u=!1,!1});return u&&t.size===s}function Mr(t,r){var e=function(e){t.prototype[e]=r[e]};return Object.keys(r).forEach(e),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(r).forEach(e),t}function Dr(t){return lt(t)?Me(t).map(Dr).toJSON():t}function xr(t){ +return!(!t||!t[En])}function Ar(t,r){return t.__ownerID?(t.size=r.size,t._map=r,t):r===t._map?t:0===r.size?t.__empty():t.__make(r)}function jr(t,r){var e=Object.create(qn);return e.size=t?t.size:0,e._map=t,e.__ownerID=r,e}function kr(){return Mn||(Mn=jr(Zt()))}function Rr(t,r,e){for(var n=pt(r),i=0;i!==n.length;)if((t=dt(t,n[i++],ae))===ae)return e;return t}function Ur(t,r){return Rr(this,t,r)}function Kr(t,r){return Rr(t,r,ae)!==ae}function Tr(t){return Kr(this,t)}function Cr(){ht(this.size);var t={};return this.__iterate(function(r,e){t[e]=r}),t}function Lr(t,r,e,n,i,o){return ht(t.size),t.__iterate(function(t,o,u){i?(i=!1,e=t):e=r.call(n,e,t,o,u)},o),e}function Br(t,r){return r}function Wr(t,r){return[r,t]}function Nr(t){return function(){return!t.apply(this,arguments)}}function Pr(t){return function(){return-t.apply(this,arguments)}}function Jr(){return ct(arguments)}function Hr(t,r){return tr?-1:0}function Vr(t){if(t.size===1/0)return 0;var r=d(t),e=l(t),n=r?1:0;return Yr(t.__iterate(e?r?function(t,r){n=31*n+Qr(U(t),U(r))|0}:function(t,r){n=n+Qr(U(t),U(r))|0}:r?function(t){n=31*n+U(t)|0}:function(t){n=n+U(t)|0}),n)}function Yr(t,r){return r=Le(r,3432918353),r=Le(r<<15|r>>>-15,461845907),r=Le(r<<13|r>>>-13,5),r=(r+3864292196|0)^t,r=Le(r^r>>>16,2246822507),r=Le(r^r>>>13,3266489909),r=R(r^r>>>16)}function Qr(t,r){return t^r+2654435769+(t<<6)+(t>>2)|0}function Xr(t){return xr(t)&&d(t)}function Fr(t,r){var e=Object.create(Un);return e.size=t?t.size:0,e._map=t,e.__ownerID=r,e}function Gr(){return Kn||(Kn=Fr(Sr()))}function Zr(t,r,e){var n=Object.create(Object.getPrototypeOf(t));return n._values=r,n.__ownerID=e,n}function $r(t){return t._name||t.constructor.name||"Record"}function te(t){return D(t._keys.map(function(r){return[r,t.get(r)]}))}function re(t,r){try{Object.defineProperty(t,r,{get:function(){return this.get(r)},set:function(t){ft(this.__ownerID,"Cannot set on an immutable record."),this.set(r,t)}})}catch(t){}}function ee(t,r){return ne([],r||ie,t,"",r&&r.length>2?[]:void 0,{"":t})} +function ne(t,r,e,n,i,o){var u=Array.isArray(e)?xe:_t(e)?De:null;if(u){if(~t.indexOf(e))throw new TypeError("Cannot convert circular structure to Immutable");t.push(e),i&&""!==n&&i.push(n);var s=r.call(o,n,u(e).map(function(n,o){return ne(t,r,n,o,i,e)}),i&&i.slice());return t.pop(),i&&i.pop(),s}return e}function ie(t,r){return l(r)?r.toMap():r.toList()}var oe=5,ue=1<=n.length){var r=e.next();if(r.done)return r;n[i]=r.value}return w(t,i,n[i++])})},r}(xe),Le="function"==typeof Math.imul&&Math.imul(4294967295,2)===-2?Math.imul:function(t,r){t|=0,r|=0;var e=65535&t,n=65535&r;return e*n+((t>>>16)*n+e*(r>>>16)<<16>>>0)|0},Be=Object.isExtensible,We=function(){try{return Object.defineProperty({},"@",{}),!0 +}catch(t){return!1}}(),Ne="function"==typeof WeakMap;Ne&&(Ke=new WeakMap);var Pe=0,Je="__immutablehash__";"function"==typeof Symbol&&(Je=Symbol(Je));var He=16,Ve=255,Ye=0,Qe={},Xe=function(t){function r(t,r){this._iter=t,this._useKeys=r,this.size=t.size}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.prototype.get=function(t,r){return this._iter.get(t,r)},r.prototype.has=function(t){return this._iter.has(t)},r.prototype.valueSeq=function(){return this._iter.valueSeq()},r.prototype.reverse=function(){var t=this,r=N(this,!0);return this._useKeys||(r.valueSeq=function(){return t._iter.toSeq().reverse()}),r},r.prototype.map=function(t,r){var e=this,n=W(this,t,r);return this._useKeys||(n.valueSeq=function(){return e._iter.toSeq().map(t,r)}),n},r.prototype.__iterate=function(t,r){var e=this;return this._iter.__iterate(function(r,n){return t(r,n,e)},r)},r.prototype.__iterator=function(t,r){return this._iter.__iterator(t,r)},r}(De);Xe.prototype[le]=!0;var Fe=function(t){function r(t){this._iter=t,this.size=t.size}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.prototype.includes=function(t){return this._iter.includes(t)},r.prototype.__iterate=function(t,r){var e=this,n=0;return r&&i(this),this._iter.__iterate(function(i){return t(i,r?e.size-++n:n++,e)},r)},r.prototype.__iterator=function(t,r){var e=this,n=this._iter.__iterator(ze,r),o=0;return r&&i(this),new Ee(function(){var i=n.next();return i.done?i:w(t,r?e.size-++o:o++,i.value,i)})},r}(xe),Ge=function(t){function r(t){this._iter=t,this.size=t.size}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.prototype.has=function(t){return this._iter.includes(t)},r.prototype.__iterate=function(t,r){var e=this;return this._iter.__iterate(function(r){return t(r,r,e)},r)},r.prototype.__iterator=function(t,r){var e=this._iter.__iterator(ze,r);return new Ee(function(){var r=e.next();return r.done?r:w(t,r.value,r.value,r)})},r +}(Ae),Ze=function(t){function r(t){this._iter=t,this.size=t.size}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.prototype.entrySeq=function(){return this._iter.toSeq()},r.prototype.__iterate=function(t,r){var e=this;return this._iter.__iterate(function(r){if(r){it(r);var n=_(r);return t(n?r.get(1):r[1],n?r.get(0):r[0],e)}},r)},r.prototype.__iterator=function(t,r){var e=this._iter.__iterator(ze,r);return new Ee(function(){for(;;){var r=e.next();if(r.done)return r;var n=r.value;if(n){it(n);var i=_(n);return w(t,i?n.get(0):n[0],i?n.get(1):n[1],r)}}})},r}(De);Fe.prototype.cacheResult=Xe.prototype.cacheResult=Ge.prototype.cacheResult=Ze.prototype.cacheResult=st;var $e=function(t){function r(r){return null===r||void 0===r?Zt():Qt(r)&&!d(r)?r:Zt().withMutations(function(e){var n=t(r);ht(n.size),n.forEach(function(t,r){return e.set(r,t)})})}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.of=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return Zt().withMutations(function(r){for(var e=0;e=t.length)throw Error("Missing value for key: "+t[e]);r.set(t[e],t[e+1])}})},r.prototype.toString=function(){return this.__toString("Map {","}")},r.prototype.get=function(t,r){return this._root?this._root.get(0,void 0,t,r):r},r.prototype.set=function(t,r){return $t(this,t,r)},r.prototype.remove=function(t){return $t(this,t,ae)},r.prototype.deleteAll=function(t){var r=ye(t);return 0===r.size?this:this.withMutations(function(t){r.forEach(function(r){return t.remove(r)})})},r.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):Zt()},r.prototype.sort=function(t){return mn($(this,t))},r.prototype.sortBy=function(t,r){return mn($(this,r,t))},r.prototype.__iterator=function(t,r){return new cn(this,t,r)},r.prototype.__iterate=function(t,r){var e=this,n=0;return this._root&&this._root.iterate(function(r){return n++, +t(r[1],r[0],e)},r),n},r.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Gt(this.size,this._root,t,this.__hash):0===this.size?Zt():(this.__ownerID=t,this.__altered=!1,this)},r}(de);$e.isMap=Qt;var tn="@@__IMMUTABLE_MAP__@@",rn=$e.prototype;rn[tn]=!0,rn.delete=rn.remove,rn.removeAll=rn.deleteAll,rn.setIn=bt,rn.removeIn=rn.deleteIn=Et,rn.update=Mt,rn.updateIn=Dt,rn.merge=rn.concat=xt,rn.mergeWith=At,rn.mergeDeep=Bt,rn.mergeDeepWith=Wt,rn.mergeIn=Nt,rn.mergeDeepIn=Pt,rn.withMutations=Jt,rn.wasAltered=Yt,rn.asImmutable=Vt,rn["@@transducer/init"]=rn.asMutable=Ht,rn["@@transducer/step"]=function(t,r){return t.set(r[0],r[1])},rn["@@transducer/result"]=function(t){return t.asImmutable()};var en=function(t,r){this.ownerID=t,this.entries=r};en.prototype.get=function(t,r,e,n){for(var i=this.entries,o=0,u=i.length;o=fn)return nr(t,c,i,o);var _=t&&t===this.ownerID,l=_?c:ct(c);return p?a?f===h-1?l.pop():l[f]=l.pop():l[f]=[i,o]:l.push([i,o]),_?(this.entries=l,this):new en(t,l)}};var nn=function(t,r,e){this.ownerID=t,this.bitmap=r,this.nodes=e};nn.prototype.get=function(t,r,e,n){void 0===r&&(r=U(e));var i=1<<((0===t?r:r>>>t)&se),o=this.bitmap;return 0==(o&i)?n:this.nodes[ur(o&i-1)].get(t+oe,r,e,n)},nn.prototype.update=function(t,r,e,n,i,o,u){void 0===e&&(e=U(n));var s=(0===r?e:e>>>r)&se,a=1<=hn)return or(t,p,c,s,l);if(f&&!l&&2===p.length&&rr(p[1^h]))return p[1^h];if(f&&l&&1===p.length&&rr(l))return l;var v=t&&t===this.ownerID,y=f?l?c:c^a:c|a,d=f?l?sr(p,h,l,v):cr(p,h,v):ar(p,h,l,v);return v?(this.bitmap=y,this.nodes=d,this):new nn(t,y,d)};var on=function(t,r,e){this.ownerID=t,this.count=r, +this.nodes=e};on.prototype.get=function(t,r,e,n){void 0===r&&(r=U(e));var i=(0===t?r:r>>>t)&se,o=this.nodes[i];return o?o.get(t+oe,r,e,n):n},on.prototype.update=function(t,r,e,n,i,o,u){void 0===e&&(e=U(n));var s=(0===r?e:e>>>r)&se,a=i===ae,c=this.nodes,f=c[s];if(a&&!f)return this;var h=tr(f,t,r+oe,e,n,i,o,u);if(h===f)return this;var p=this.count;if(f){if(!h&&--p0&&i=0&&t>>r&se;if(n>=this.array.length)return new yn([],t);var i,o=0===n;if(r>0){var u=this.array[n];if((i=u&&u.removeBefore(t,r-oe,e))===u&&o)return this}if(o&&!i)return this;var s=yr(this,t);if(!o)for(var a=0;a>>r&se;if(n>=this.array.length)return this;var i;if(r>0){var o=this.array[n];if((i=o&&o.removeAfter(t,r-oe,e))===o&&n===this.array.length-1)return this}var u=yr(this,t);return u.array.splice(n+1), +i&&(u.array[n]=i),u};var dn,gn={},mn=function(t){function r(t){return null===t||void 0===t?Sr():wr(t)?t:Sr().withMutations(function(r){var e=de(t);ht(e.size),e.forEach(function(t,e){return r.set(e,t)})})}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.of=function(){return this(arguments)},r.prototype.toString=function(){return this.__toString("OrderedMap {","}")},r.prototype.get=function(t,r){var e=this._map.get(t);return void 0!==e?this._list.get(e)[1]:r},r.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._map.clear(),this._list.clear(),this):Sr()},r.prototype.set=function(t,r){return Ir(this,t,r)},r.prototype.remove=function(t){return Ir(this,t,ae)},r.prototype.wasAltered=function(){return this._map.wasAltered()||this._list.wasAltered()},r.prototype.__iterate=function(t,r){var e=this;return this._list.__iterate(function(r){return r&&t(r[1],r[0],e)},r)},r.prototype.__iterator=function(t,r){return this._list.fromEntrySeq().__iterator(t,r)},r.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var r=this._map.__ensureOwner(t),e=this._list.__ensureOwner(t);return t?zr(r,e,t,this.__hash):0===this.size?Sr():(this.__ownerID=t,this._map=r,this._list=e,this)},r}($e);mn.isOrderedMap=wr,mn.prototype[le]=!0,mn.prototype.delete=mn.prototype.remove;var wn,zn=function(t){function r(t){return null===t||void 0===t?Er():br(t)?t:Er().pushAll(t)}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.of=function(){return this(arguments)},r.prototype.toString=function(){return this.__toString("Stack [","]")},r.prototype.get=function(t,r){var e=this._head;for(t=o(this,t);e&&t--;)e=e.next;return e?e.value:r},r.prototype.peek=function(){return this._head&&this._head.value},r.prototype.push=function(){var t=arguments;if(0===arguments.length)return this;for(var r=this.size+arguments.length,e=this._head,n=arguments.length-1;n>=0;n--)e={value:t[n],next:e};return this.__ownerID?(this.size=r, +this._head=e,this.__hash=void 0,this.__altered=!0,this):Or(r,e)},r.prototype.pushAll=function(r){if(r=t(r),0===r.size)return this;if(0===this.size&&br(r))return r;ht(r.size);var e=this.size,n=this._head;return r.__iterate(function(t){e++,n={value:t,next:n}},!0),this.__ownerID?(this.size=e,this._head=n,this.__hash=void 0,this.__altered=!0,this):Or(e,n)},r.prototype.pop=function(){return this.slice(1)},r.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):Er()},r.prototype.slice=function(r,e){if(s(r,e,this.size))return this;var n=a(r,this.size);if(c(e,this.size)!==this.size)return t.prototype.slice.call(this,r,e);for(var i=this.size-n,o=this._head;n--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):Or(i,o)},r.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Or(this.size,this._head,t,this.__hash):0===this.size?Er():(this.__ownerID=t,this.__altered=!1,this)},r.prototype.__iterate=function(t,r){var e=this;if(r)return new ke(this.toArray()).__iterate(function(r,n){return t(r,n,e)},r);for(var n=0,i=this._head;i&&t(i.value,n++,e)!==!1;)i=i.next;return n},r.prototype.__iterator=function(t,r){if(r)return new ke(this.toArray()).__iterator(t,r);var e=0,n=this._head;return new Ee(function(){if(n){var r=n.value;return n=n.next,w(t,e++,r)}return z()})},r}(ge);zn.isStack=br;var Sn="@@__IMMUTABLE_STACK__@@",In=zn.prototype;In[Sn]=!0,In.shift=In.pop,In.unshift=In.push,In.unshiftAll=In.pushAll,In.withMutations=Jt,In.wasAltered=Yt,In.asImmutable=Vt,In["@@transducer/init"]=In.asMutable=Ht,In["@@transducer/step"]=function(t,r){return t.unshift(r)},In["@@transducer/result"]=function(t){return t.asImmutable()};var bn,On=function(t){function r(r){return null===r||void 0===r?kr():xr(r)&&!d(r)?r:kr().withMutations(function(e){var n=t(r);ht(n.size),n.forEach(function(t){return e.add(t)})})}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype), +r.prototype.constructor=r,r.of=function(){return this(arguments)},r.fromKeys=function(t){return this(de(t).keySeq())},r.intersect=function(t){return t=ye(t).toArray(),t.length?qn.intersect.apply(r(t.pop()),t):kr()},r.union=function(t){return t=ye(t).toArray(),t.length?qn.union.apply(r(t.pop()),t):kr()},r.prototype.toString=function(){return this.__toString("Set {","}")},r.prototype.has=function(t){return this._map.has(t)},r.prototype.add=function(t){return Ar(this,this._map.set(t,t))},r.prototype.remove=function(t){return Ar(this,this._map.remove(t))},r.prototype.clear=function(){return Ar(this,this._map.clear())},r.prototype.union=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];return r=r.filter(function(t){return 0!==t.size}),0===r.length?this:0!==this.size||this.__ownerID||1!==r.length?this.withMutations(function(e){for(var n=0;n=0&&r=0&&ethis.size?r:this.find(function(r,e){return e===t},void 0,r)},has:function(t){return(t=o(this,t))>=0&&(void 0!==this.size?this.size===1/0||t Date: Tue, 15 May 2018 16:34:31 +0000 Subject: [PATCH 087/242] Deploy a22ece71ec6a7f715c7ff4da415021b3d9ac4f0e to NPM branch --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5ac56f2145..7492a177da 100644 --- a/README.md +++ b/README.md @@ -556,8 +556,8 @@ Any collection can be converted to a lazy Seq with `Seq()`. ```js -const { Map, Seq } = require('immutable') -const map = Map({ a: 1, b: 2, c: 3 }) +const { Map } = require('immutable') +const map = Map({ a: 1, b: 2, c: 3 } const lazySeq = Seq(map) ``` From b3b7b5ff0a922dd984c544cd96ccdf467c894cbe Mon Sep 17 00:00:00 2001 From: Travis CI Date: Tue, 15 May 2018 16:35:16 +0000 Subject: [PATCH 088/242] Deploy 72e5fbca0098a5656010894431b0c7672393f9e6 to NPM branch --- README.md | 4 ++-- dist/immutable-nonambient.d.ts | 21 +++++++++++++++++++++ dist/immutable.d.ts | 21 +++++++++++++++++++++ 3 files changed, 44 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7492a177da..5ac56f2145 100644 --- a/README.md +++ b/README.md @@ -556,8 +556,8 @@ Any collection can be converted to a lazy Seq with `Seq()`. ```js -const { Map } = require('immutable') -const map = Map({ a: 1, b: 2, c: 3 } +const { Map, Seq } = require('immutable') +const map = Map({ a: 1, b: 2, c: 3 }) const lazySeq = Seq(map) ``` diff --git a/dist/immutable-nonambient.d.ts b/dist/immutable-nonambient.d.ts index d09da9d06f..0afc87a4b6 100644 --- a/dist/immutable-nonambient.d.ts +++ b/dist/immutable-nonambient.d.ts @@ -1429,6 +1429,27 @@ */ readonly size: number; + /** + * Returns a new OrderedMap also containing the new key, value pair. If an equivalent + * key already exists in this OrderedMap, it will be replaced while maintaining the + * existing order. + * + * + * ```js + * const { OrderedMapMap } = require('immutable') + * const originalMap = Immutable.OrderedMap({a:1, b:1, c:1}) + * const updatedMap = originalMap.set('b', 2) + * + * originalMap + * // OrderedMap {a: 1, b: 1, c: 1} + * updatedMap + * // OrderedMap {a: 1, b: 2, c: 1} + * ``` + * + * Note: `set` can be used in `withMutations`. + */ + set(key: K, value: V): this; + /** * Returns a new OrderedMap resulting from merging the provided Collections * (or JS objects) into this OrderedMap. In other words, this takes each diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index 9a66449a1a..a2acf971c6 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -1429,6 +1429,27 @@ declare module Immutable { */ readonly size: number; + /** + * Returns a new OrderedMap also containing the new key, value pair. If an equivalent + * key already exists in this OrderedMap, it will be replaced while maintaining the + * existing order. + * + * + * ```js + * const { OrderedMapMap } = require('immutable') + * const originalMap = Immutable.OrderedMap({a:1, b:1, c:1}) + * const updatedMap = originalMap.set('b', 2) + * + * originalMap + * // OrderedMap {a: 1, b: 1, c: 1} + * updatedMap + * // OrderedMap {a: 1, b: 2, c: 1} + * ``` + * + * Note: `set` can be used in `withMutations`. + */ + set(key: K, value: V): this; + /** * Returns a new OrderedMap resulting from merging the provided Collections * (or JS objects) into this OrderedMap. In other words, this takes each From 4ab58c9e34265d4e9393771f4b988b655ce193fc Mon Sep 17 00:00:00 2001 From: Travis CI Date: Tue, 15 May 2018 16:36:50 +0000 Subject: [PATCH 089/242] Deploy 1ad6fc396a78369c05868ee715e70d97c6bc685c to NPM branch --- dist/immutable-nonambient.d.ts | 2 +- dist/immutable.d.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/immutable-nonambient.d.ts b/dist/immutable-nonambient.d.ts index 0afc87a4b6..63df7f3608 100644 --- a/dist/immutable-nonambient.d.ts +++ b/dist/immutable-nonambient.d.ts @@ -4707,7 +4707,7 @@ * ```js * const { fromJS, isKeyed } = require('immutable') * function (key, value) { - * return isKeyed(value) ? value.Map() : value.toList() + * return isKeyed(value) ? value.toMap() : value.toList() * } * ``` * diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index a2acf971c6..7bff3820d6 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -4707,7 +4707,7 @@ declare module Immutable { * ```js * const { fromJS, isKeyed } = require('immutable') * function (key, value) { - * return isKeyed(value) ? value.Map() : value.toList() + * return isKeyed(value) ? value.toMap() : value.toList() * } * ``` * From aa77b32aa0c99cfe7a55f88f32c2e2c1a7872ca1 Mon Sep 17 00:00:00 2001 From: Travis CI Date: Tue, 15 May 2018 16:41:17 +0000 Subject: [PATCH 090/242] Deploy b3bde7d67e8e3e2770fbbd325f0209dbb07b368f to NPM branch --- dist/immutable-nonambient.d.ts | 2 +- dist/immutable.d.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/immutable-nonambient.d.ts b/dist/immutable-nonambient.d.ts index 63df7f3608..eda1f7c6e3 100644 --- a/dist/immutable-nonambient.d.ts +++ b/dist/immutable-nonambient.d.ts @@ -2311,7 +2311,7 @@ * * **Choosing Records vs plain JavaScript objects** * - * Records ofters a persistently immutable alternative to plain JavaScript + * Records offer a persistently immutable alternative to plain JavaScript * objects, however they're not required to be used within Immutable.js * collections. In fact, the deep-access and deep-updating functions * like `getIn()` and `setIn()` work with plain JavaScript Objects as well. diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index 7bff3820d6..6b68da8c2d 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -2311,7 +2311,7 @@ declare module Immutable { * * **Choosing Records vs plain JavaScript objects** * - * Records ofters a persistently immutable alternative to plain JavaScript + * Records offer a persistently immutable alternative to plain JavaScript * objects, however they're not required to be used within Immutable.js * collections. In fact, the deep-access and deep-updating functions * like `getIn()` and `setIn()` work with plain JavaScript Objects as well. From aae7e6680ffb377feac0720563fd569a0511974d Mon Sep 17 00:00:00 2001 From: Travis CI Date: Tue, 15 May 2018 16:43:41 +0000 Subject: [PATCH 091/242] Deploy d9308b73b52c85b2ed9dfcf7ed060046e7492c46 to NPM branch --- contrib/cursor/README.md | 2 +- contrib/cursor/index.d.ts | 2 +- dist/immutable-nonambient.d.ts | 2 +- dist/immutable.d.ts | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/contrib/cursor/README.md b/contrib/cursor/README.md index 3f255dc961..6404844814 100644 --- a/contrib/cursor/README.md +++ b/contrib/cursor/README.md @@ -17,7 +17,7 @@ collection to portions of your application while maintaining a central point aware of changes to the entire data structure: an `onChange` function which is called whenever a cursor or sub-cursor calls `update`. -This is particularly useful when used in conjuction with component-based UI +This is particularly useful when used in conjunction with component-based UI libraries like [React](https://facebook.github.io/react/) or to simulate "state" throughout an application while maintaining a single flow of logic. diff --git a/contrib/cursor/index.d.ts b/contrib/cursor/index.d.ts index 495fde9aa7..ce3df11580 100644 --- a/contrib/cursor/index.d.ts +++ b/contrib/cursor/index.d.ts @@ -14,7 +14,7 @@ * collection to portions of your application while maintaining a central point * aware of changes to the entire data structure. * - * This is particularly useful when used in conjuction with component-based UI + * This is particularly useful when used in conjunction with component-based UI * libraries like [React](http://facebook.github.io/react/) or to simulate * "state" throughout an application while maintaining a single flow of logic. * diff --git a/dist/immutable-nonambient.d.ts b/dist/immutable-nonambient.d.ts index eda1f7c6e3..8e5af7515c 100644 --- a/dist/immutable-nonambient.d.ts +++ b/dist/immutable-nonambient.d.ts @@ -4692,7 +4692,7 @@ * If a `reviver` is optionally provided, it will be called with every * collection as a Seq (beginning with the most nested collections * and proceeding to the top-level collection itself), along with the key - * refering to each collection and the parent JS object provided as `this`. + * referring to each collection and the parent JS object provided as `this`. * For the top level, object, the key will be `""`. This `reviver` is expected * to return a new Immutable Collection, allowing for custom conversions from * deep JS objects. Finally, a `path` is provided which is the sequence of diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index 6b68da8c2d..0ee299d02c 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -4692,7 +4692,7 @@ declare module Immutable { * If a `reviver` is optionally provided, it will be called with every * collection as a Seq (beginning with the most nested collections * and proceeding to the top-level collection itself), along with the key - * refering to each collection and the parent JS object provided as `this`. + * referring to each collection and the parent JS object provided as `this`. * For the top level, object, the key will be `""`. This `reviver` is expected * to return a new Immutable Collection, allowing for custom conversions from * deep JS objects. Finally, a `path` is provided which is the sequence of From efabb4755d9fe2020c3d0390a635c9f058ab5add Mon Sep 17 00:00:00 2001 From: Travis CI Date: Tue, 15 May 2018 16:45:26 +0000 Subject: [PATCH 092/242] Deploy 273ec43cc66909d44c221d99e17af72b96b730ec to NPM branch --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5ac56f2145..295739383d 100644 --- a/README.md +++ b/README.md @@ -238,7 +238,7 @@ alpha.map((v, k) => k.toUpperCase()).join(); ### Convert from raw JavaScript objects and arrays. Designed to inter-operate with your existing JavaScript, Immutable.js -accepts plain JavaScript Arrays and Objects anywhere a method expects an +accepts plain JavaScript Arrays and Objects anywhere a method expects a `Collection`. From 1dae16101a16a648687a826c52b368f55a265d9e Mon Sep 17 00:00:00 2001 From: Travis CI Date: Tue, 15 May 2018 16:46:18 +0000 Subject: [PATCH 093/242] Deploy ba16b269e97bb75bee80760f496c8dbd387eba1d to NPM branch --- dist/immutable-nonambient.d.ts | 4 ++-- dist/immutable.d.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dist/immutable-nonambient.d.ts b/dist/immutable-nonambient.d.ts index 8e5af7515c..4e108fa42a 100644 --- a/dist/immutable-nonambient.d.ts +++ b/dist/immutable-nonambient.d.ts @@ -3821,7 +3821,7 @@ * ```js * const { Map, List } = require('immutable') * const deepData = Map({ x: List([ Map({ y: 123 }) ]) }); - * getIn(deepData, ['x', 0, 'y']) // 123 + * deepData.getIn(['x', 0, 'y']) // 123 * ``` * * Plain JavaScript Object or Arrays may be nested within an Immutable.js @@ -3831,7 +3831,7 @@ * ```js * const { Map, List } = require('immutable') * const deepData = Map({ x: [ { y: 123 } ] }); - * getIn(deepData, ['x', 0, 'y']) // 123 + * deepData.getIn(['x', 0, 'y']) // 123 * ``` */ getIn(searchKeyPath: Iterable, notSetValue?: any): any; diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index 0ee299d02c..c03771f394 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -3821,7 +3821,7 @@ declare module Immutable { * ```js * const { Map, List } = require('immutable') * const deepData = Map({ x: List([ Map({ y: 123 }) ]) }); - * getIn(deepData, ['x', 0, 'y']) // 123 + * deepData.getIn(['x', 0, 'y']) // 123 * ``` * * Plain JavaScript Object or Arrays may be nested within an Immutable.js @@ -3831,7 +3831,7 @@ declare module Immutable { * ```js * const { Map, List } = require('immutable') * const deepData = Map({ x: [ { y: 123 } ] }); - * getIn(deepData, ['x', 0, 'y']) // 123 + * deepData.getIn(['x', 0, 'y']) // 123 * ``` */ getIn(searchKeyPath: Iterable, notSetValue?: any): any; From 7ca0deaffe9f9e2a015165865d7a14d3d718f7fd Mon Sep 17 00:00:00 2001 From: Travis CI Date: Tue, 15 May 2018 16:46:48 +0000 Subject: [PATCH 094/242] Deploy 7295c5f9fba14bfca8702901720655bb48c28e39 to NPM branch --- dist/immutable-nonambient.d.ts | 4 ++-- dist/immutable.d.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dist/immutable-nonambient.d.ts b/dist/immutable-nonambient.d.ts index 4e108fa42a..6993ae66c0 100644 --- a/dist/immutable-nonambient.d.ts +++ b/dist/immutable-nonambient.d.ts @@ -5132,7 +5132,7 @@ * const { merge } = require('immutable') * const original = { x: 123, y: 456 } * merge(original, { y: 789, z: 'abc' }) // { x: 123, y: 789, z: 'abc' } - * console.log(original) // { x: { y: { z: 123 }}} + * console.log(original) // { x: 123, y: 456 } * ``` */ export function merge( @@ -5156,7 +5156,7 @@ * original, * { y: 789, z: 'abc' } * ) // { x: 123, y: 1245, z: 'abc' } - * console.log(original) // { x: { y: { z: 123 }}} + * console.log(original) // { x: 123, y: 456 } * ``` */ export function mergeWith( diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index c03771f394..8e5e3e0686 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -5132,7 +5132,7 @@ declare module Immutable { * const { merge } = require('immutable') * const original = { x: 123, y: 456 } * merge(original, { y: 789, z: 'abc' }) // { x: 123, y: 789, z: 'abc' } - * console.log(original) // { x: { y: { z: 123 }}} + * console.log(original) // { x: 123, y: 456 } * ``` */ export function merge( @@ -5156,7 +5156,7 @@ declare module Immutable { * original, * { y: 789, z: 'abc' } * ) // { x: 123, y: 1245, z: 'abc' } - * console.log(original) // { x: { y: { z: 123 }}} + * console.log(original) // { x: 123, y: 456 } * ``` */ export function mergeWith( From e1f226d50c7bc1b1f79ae5aca907feb761e25973 Mon Sep 17 00:00:00 2001 From: Travis CI Date: Tue, 15 May 2018 16:48:30 +0000 Subject: [PATCH 095/242] Deploy 7fbc9d4f3dd4b18b3a0301ababff7e621fc325a7 to NPM branch --- dist/immutable.js.flow | 1 + 1 file changed, 1 insertion(+) diff --git a/dist/immutable.js.flow b/dist/immutable.js.flow index 6859e94eb9..505fd51a27 100644 --- a/dist/immutable.js.flow +++ b/dist/immutable.js.flow @@ -1655,6 +1655,7 @@ export type { SetSeq, RecordFactory, RecordOf, + RecordInstance, ValueObject, $KeyOf, From e3f474b8eb3af6f58f6b6c55efdc23ea0762a922 Mon Sep 17 00:00:00 2001 From: Travis CI Date: Tue, 15 May 2018 16:53:35 +0000 Subject: [PATCH 096/242] Deploy 9237d487a894c54d88f15958c221fedbec4122f7 to NPM branch --- dist/immutable-nonambient.d.ts | 3 ++- dist/immutable.d.ts | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/dist/immutable-nonambient.d.ts b/dist/immutable-nonambient.d.ts index 6993ae66c0..35788df1ac 100644 --- a/dist/immutable-nonambient.d.ts +++ b/dist/immutable-nonambient.d.ts @@ -2452,7 +2452,8 @@ * notSetValue will be returned if provided. Note that this scenario would * produce an error when using Flow or TypeScript. */ - get(key: K, notSetValue: any): TProps[K]; + get(key: K, notSetValue?: any): TProps[K]; + get(key: string, notSetValue: T): T; // Reading deep values diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index 8e5e3e0686..7421d1e15b 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -2452,7 +2452,8 @@ declare module Immutable { * notSetValue will be returned if provided. Note that this scenario would * produce an error when using Flow or TypeScript. */ - get(key: K, notSetValue: any): TProps[K]; + get(key: K, notSetValue?: any): TProps[K]; + get(key: string, notSetValue: T): T; // Reading deep values From 9cec78432426e7e46bc4f20e729700b1394e4a7a Mon Sep 17 00:00:00 2001 From: Travis CI Date: Thu, 17 May 2018 11:40:39 +0000 Subject: [PATCH 097/242] Deploy 7ea2223a9994cb0268b68073c521fa3ac78acfeb to NPM branch --- dist/immutable-nonambient.d.ts | 10 +++++----- dist/immutable.d.ts | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/dist/immutable-nonambient.d.ts b/dist/immutable-nonambient.d.ts index 35788df1ac..674156bd7b 100644 --- a/dist/immutable-nonambient.d.ts +++ b/dist/immutable-nonambient.d.ts @@ -1430,14 +1430,14 @@ readonly size: number; /** - * Returns a new OrderedMap also containing the new key, value pair. If an equivalent - * key already exists in this OrderedMap, it will be replaced while maintaining the - * existing order. + * Returns a new OrderedMap also containing the new key, value pair. If an + * equivalent key already exists in this OrderedMap, it will be replaced + * while maintaining the existing order. * * * ```js - * const { OrderedMapMap } = require('immutable') - * const originalMap = Immutable.OrderedMap({a:1, b:1, c:1}) + * const { OrderedMap } = require('immutable') + * const originalMap = OrderedMap({a:1, b:1, c:1}) * const updatedMap = originalMap.set('b', 2) * * originalMap diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index 7421d1e15b..c67f86d3c3 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -1430,14 +1430,14 @@ declare module Immutable { readonly size: number; /** - * Returns a new OrderedMap also containing the new key, value pair. If an equivalent - * key already exists in this OrderedMap, it will be replaced while maintaining the - * existing order. + * Returns a new OrderedMap also containing the new key, value pair. If an + * equivalent key already exists in this OrderedMap, it will be replaced + * while maintaining the existing order. * * * ```js - * const { OrderedMapMap } = require('immutable') - * const originalMap = Immutable.OrderedMap({a:1, b:1, c:1}) + * const { OrderedMap } = require('immutable') + * const originalMap = OrderedMap({a:1, b:1, c:1}) * const updatedMap = originalMap.set('b', 2) * * originalMap From d137abaa9ec2a5eadd0b95f7c42e596cc49c1a23 Mon Sep 17 00:00:00 2001 From: Travis CI Date: Thu, 17 May 2018 12:00:23 +0000 Subject: [PATCH 098/242] Deploy a1029bba958d4a7274fc7ae540a9a0f1563e8b8d to NPM branch --- dist/immutable.js.flow | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dist/immutable.js.flow b/dist/immutable.js.flow index 505fd51a27..1aff84ada2 100644 --- a/dist/immutable.js.flow +++ b/dist/immutable.js.flow @@ -1401,7 +1401,9 @@ declare class RecordInstance { size: number; has(key: string): boolean; - get>(key: K, notSetValue: mixed): $ElementType; + + get>(key: K, ..._: []): $ElementType; + get, NSV>(key: K, notSetValue: NSV): $ElementType | NSV; hasIn(keyPath: Iterable): boolean; From 188f100cff4ef1d4d0e9240929a0c6f06d4da039 Mon Sep 17 00:00:00 2001 From: Travis CI Date: Thu, 17 May 2018 12:27:35 +0000 Subject: [PATCH 099/242] Deploy 3f3e789b743561ec147c91cfcb888f7cde45c235 to NPM branch --- dist/immutable.es.js | 2 +- dist/immutable.js | 2 +- dist/immutable.min.js | 12 ++++++------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/dist/immutable.es.js b/dist/immutable.es.js index ff1899ba53..51997a37fb 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -814,7 +814,7 @@ function hash(o) { // Drop any high bits from accidentally long hash codes. return smi(o.hashCode()); } - if (type === 'object') { + if (type === 'object' || type === 'function') { return hashJSObj(o); } if (typeof o.toString === 'function') { diff --git a/dist/immutable.js b/dist/immutable.js index ccdc4e49e3..da6af3c81e 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -820,7 +820,7 @@ function hash(o) { // Drop any high bits from accidentally long hash codes. return smi(o.hashCode()); } - if (type === 'object') { + if (type === 'object' || type === 'function') { return hashJSObj(o); } if (typeof o.toString === 'function') { diff --git a/dist/immutable.min.js b/dist/immutable.min.js index df87285e23..4409eef265 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -5,12 +5,12 @@ * LICENSE file in the root directory of this source tree. */ !function(t,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r(t.Immutable={})}(this,function(t){"use strict";function r(t){return t.value=!1,t}function e(t){t&&(t.value=!0)}function n(){}function i(t){return void 0===t.size&&(t.size=t.__iterate(u)),t.size}function o(t,r){if("number"!=typeof r){var e=r>>>0;if(""+e!==r||4294967295===e)return NaN;r=e}return r<0?i(t)+r:r}function u(){return!0}function s(t,r,e){return(0===t&&!h(t)||void 0!==e&&t<=-e)&&(void 0===r||void 0!==e&&r>=e)}function a(t,r){return f(t,r,0)}function c(t,r){return f(t,r,r)}function f(t,r,e){return void 0===t?e:h(t)?r===1/0?r:0|Math.max(0,r+t):void 0===r||r===t?t:0|Math.min(r,t)}function h(t){return t<0||0===t&&1/t==-(1/0)}function p(t){return _(t)||g(t)}function _(t){return!(!t||!t[he])}function l(t){return!(!t||!t[pe])}function v(t){return!(!t||!t[_e])}function y(t){return l(t)||v(t)}function d(t){return!(!t||!t[le])}function g(t){return!(!t||!t[ve])}function m(t){return!(!t||"function"!=typeof t.equals||"function"!=typeof t.hashCode)}function w(t,r,e,n){var i=0===t?r:1===t?e:[r,e];return n?n.value=i:n={value:i,done:!1},n}function z(){return{value:void 0,done:!0}}function S(t){return!!O(t)}function I(t){return t&&"function"==typeof t.next}function b(t){var r=O(t);return r&&r.call(t)}function O(t){var r=t&&(Ie&&t[Ie]||t[be]);if("function"==typeof r)return r}function E(t){return t&&"number"==typeof t.length}function q(t){return!(!t||!t[je])}function M(){return Ue||(Ue=new ke([]))}function D(t){var r=Array.isArray(t)?new ke(t):I(t)?new Ce(t):S(t)?new Te(t):void 0;if(r)return r.fromEntrySeq();if("object"==typeof t)return new Re(t);throw new TypeError("Expected Array or collection object of [k, v] entries, or keyed object: "+t)}function x(t){var r=j(t);if(r)return r;throw new TypeError("Expected Array or collection object of values: "+t)}function A(t){var r=j(t);if(r)return r;if("object"==typeof t)return new Re(t) -;throw new TypeError("Expected Array or collection object of values, or keyed object: "+t)}function j(t){return E(t)?new ke(t):I(t)?new Ce(t):S(t)?new Te(t):void 0}function k(t,r){if(t===r||t!==t&&r!==r)return!0;if(!t||!r)return!1;if("function"==typeof t.valueOf&&"function"==typeof r.valueOf){if(t=t.valueOf(),r=r.valueOf(),t===r||t!==t&&r!==r)return!0;if(!t||!r)return!1}return!!(m(t)&&m(r)&&t.equals(r))}function R(t){return t>>>1&1073741824|3221225471&t}function U(t){if(t===!1||null===t||void 0===t)return 0;if("function"==typeof t.valueOf&&((t=t.valueOf())===!1||null===t||void 0===t))return 0;if(t===!0)return 1;var r=typeof t;if("number"===r){if(t!==t||t===1/0)return 0;var e=0|t;for(e!==t&&(e^=4294967295*t);t>4294967295;)t/=4294967295,e^=t;return R(e)}if("string"===r)return t.length>He?K(t):T(t);if("function"==typeof t.hashCode)return R(t.hashCode());if("object"===r)return C(t);if("function"==typeof t.toString)return T(""+t);throw Error("Value type "+r+" cannot be hashed.")}function K(t){var r=Qe[t];return void 0===r&&(r=T(t),Ye===Ve&&(Ye=0,Qe={}),Ye++,Qe[t]=r),r}function T(t){for(var r=0,e=0;e0)switch(t.nodeType){case 1:return t.uniqueID;case 9: -return t.documentElement&&t.documentElement.uniqueID}}function B(t){var r=ut(t);return r._iter=t,r.size=t.size,r.flip=function(){return t},r.reverse=function(){var r=t.reverse.apply(this);return r.flip=function(){return t.reverse()},r},r.has=function(r){return t.includes(r)},r.includes=function(r){return t.has(r)},r.cacheResult=st,r.__iterateUncached=function(r,e){var n=this;return t.__iterate(function(t,e){return r(e,t,n)!==!1},e)},r.__iteratorUncached=function(r,e){if(r===Se){var n=t.__iterator(r,e);return new Ee(function(){var t=n.next();if(!t.done){var r=t.value[0];t.value[0]=t.value[1],t.value[1]=r}return t})}return t.__iterator(r===ze?we:ze,e)},r}function W(t,r,e){var n=ut(t);return n.size=t.size,n.has=function(r){return t.has(r)},n.get=function(n,i){var o=t.get(n,ae);return o===ae?i:r.call(e,o,n,t)},n.__iterateUncached=function(n,i){var o=this;return t.__iterate(function(t,i,u){return n(r.call(e,t,i,u),i,o)!==!1},i)},n.__iteratorUncached=function(n,i){var o=t.__iterator(Se,i);return new Ee(function(){var i=o.next();if(i.done)return i;var u=i.value,s=u[0];return w(n,s,r.call(e,u[1],s,t),i)})},n}function N(t,r){var e=this,n=ut(t);return n._iter=t,n.size=t.size,n.reverse=function(){return t},t.flip&&(n.flip=function(){var r=B(t);return r.reverse=function(){return t.flip()},r}),n.get=function(e,n){return t.get(r?e:-1-e,n)},n.has=function(e){return t.has(r?e:-1-e)},n.includes=function(r){return t.includes(r)},n.cacheResult=st,n.__iterate=function(e,n){var o=this,u=0;return n&&i(t),t.__iterate(function(t,i){return e(t,r?i:n?o.size-++u:u++,o)},!n)},n.__iterator=function(n,o){var u=0;o&&i(t);var s=t.__iterator(Se,!o);return new Ee(function(){var t=s.next();if(t.done)return t;var i=t.value;return w(n,r?i[0]:o?e.size-++u:u++,i[1],t)})},n}function P(t,r,e,n){var i=ut(t);return n&&(i.has=function(n){var i=t.get(n,ae);return i!==ae&&!!r.call(e,i,n,t)},i.get=function(n,i){var o=t.get(n,ae);return o!==ae&&r.call(e,o,n,t)?o:i}),i.__iterateUncached=function(i,o){var u=this,s=0;return t.__iterate(function(t,o,a){ -if(r.call(e,t,o,a))return s++,i(t,n?o:s-1,u)},o),s},i.__iteratorUncached=function(i,o){var u=t.__iterator(Se,o),s=0;return new Ee(function(){for(;;){var o=u.next();if(o.done)return o;var a=o.value,c=a[0],f=a[1];if(r.call(e,f,c,t))return w(i,n?c:s++,f,o)}})},i}function J(t,r,e){var n=$e().asMutable();return t.__iterate(function(i,o){n.update(r.call(e,i,o,t),0,function(t){return t+1})}),n.asImmutable()}function H(t,r,e){var n=l(t),i=(d(t)?mn():$e()).asMutable();t.__iterate(function(o,u){i.update(r.call(e,o,u,t),function(t){return t=t||[],t.push(n?[u,o]:o),t})});var o=ot(t);return i.map(function(r){return nt(t,o(r))})}function V(t,r,e,n){var i=t.size;if(s(r,e,i))return t;var u=a(r,i),f=c(e,i);if(u!==u||f!==f)return V(t.toSeq().cacheResult(),r,e,n);var h,p=f-u;p===p&&(h=p<0?0:p);var _=ut(t);return _.size=0===h?h:t.size&&h||void 0,!n&&q(t)&&h>=0&&(_.get=function(r,e){return r=o(this,r),r>=0&&rh)return z();var t=i.next();return n||r===ze||t.done?t:r===we?w(r,s-1,void 0,t):w(r,s-1,t.value[1],t)})},_}function Y(t,r,e){var n=ut(t);return n.__iterateUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterate(n,i);var u=0;return t.__iterate(function(t,i,s){return r.call(e,t,i,s)&&++u&&n(t,i,o)}),u},n.__iteratorUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterator(n,i);var u=t.__iterator(Se,i),s=!0;return new Ee(function(){if(!s)return z();var t=u.next();if(t.done)return t;var i=t.value,a=i[0],c=i[1];return r.call(e,c,a,o)?n===Se?t:w(n,a,c,t):(s=!1,z())})},n}function Q(t,r,e,n){var i=ut(t);return i.__iterateUncached=function(i,o){var u=this -;if(o)return this.cacheResult().__iterate(i,o);var s=!0,a=0;return t.__iterate(function(t,o,c){if(!s||!(s=r.call(e,t,o,c)))return a++,i(t,n?o:a-1,u)}),a},i.__iteratorUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterator(i,o);var s=t.__iterator(Se,o),a=!0,c=0;return new Ee(function(){var t,o,f;do{if(t=s.next(),t.done)return n||i===ze?t:i===we?w(i,c++,void 0,t):w(i,c++,t.value[1],t);var h=t.value;o=h[0],f=h[1],a&&(a=r.call(e,f,o,u))}while(a);return i===Se?t:w(i,o,f,t)})},i}function X(t,r){var e=l(t),n=[t].concat(r).map(function(t){return _(t)?e&&(t=de(t)):t=e?D(t):x(Array.isArray(t)?t:[t]),t}).filter(function(t){return 0!==t.size});if(0===n.length)return t;if(1===n.length){var i=n[0];if(i===t||e&&l(i)||v(t)&&v(i))return i}var o=new ke(n);return e?o=o.toKeyedSeq():v(t)||(o=o.toSetSeq()),o=o.flatten(!0),o.size=n.reduce(function(t,r){if(void 0!==t){var e=r.size;if(void 0!==e)return t+e}},0),o}function F(t,r,e){var n=ut(t);return n.__iterateUncached=function(i,o){function u(t,c){t.__iterate(function(t,o){return(!r||c0}function et(t,r,e,n){var i=ut(t),o=new ke(e).map(function(t){return t.size});return i.size=n?o.max():o.min(),i.__iterate=function(t,r){for(var e,n=this,i=this.__iterator(ze,r),o=0;!(e=i.next()).done&&t(e.value,o++,n)!==!1;);return o},i.__iteratorUncached=function(t,i){var o=e.map(function(t){return t=ye(t),b(i?t.reverse():t)}),u=0,s=!1;return new Ee(function(){var e;return s||(e=o.map(function(t){return t.next()}),s=n?e.every(function(t){return t.done}):e.some(function(t){return t.done})),s?z():w(t,u++,r.apply(null,e.map(function(t){return t.value})))})},i}function nt(t,r){return t===r?t:q(t)?r:t.constructor(r)}function it(t){if(t!==Object(t))throw new TypeError("Expected [K, V] tuple: "+t)}function ot(t){return l(t)?de:v(t)?ge:me}function ut(t){return Object.create((l(t)?De:v(t)?xe:Ae).prototype)}function st(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size,this):Me.prototype.cacheResult.call(this)}function at(t,r){return void 0===t&&void 0===r?0:void 0===t?1:void 0===r?-1:t>r?1:t0;)r[e]=arguments[e+1];return jt(this,r,t)}function jt(t,r,e){for(var n=[],i=0;i>>1&1073741824|3221225471&t}function U(t){if(t===!1||null===t||void 0===t)return 0;if("function"==typeof t.valueOf&&((t=t.valueOf())===!1||null===t||void 0===t))return 0;if(t===!0)return 1;var r=typeof t;if("number"===r){if(t!==t||t===1/0)return 0;var e=0|t;for(e!==t&&(e^=4294967295*t);t>4294967295;)t/=4294967295,e^=t;return R(e)}if("string"===r)return t.length>He?K(t):T(t);if("function"==typeof t.hashCode)return R(t.hashCode());if("object"===r||"function"===r)return C(t);if("function"==typeof t.toString)return T(""+t);throw Error("Value type "+r+" cannot be hashed.")}function K(t){var r=Qe[t];return void 0===r&&(r=T(t),Ye===Ve&&(Ye=0,Qe={}),Ye++,Qe[t]=r),r}function T(t){for(var r=0,e=0;e0)switch(t.nodeType){case 1: +return t.uniqueID;case 9:return t.documentElement&&t.documentElement.uniqueID}}function B(t){var r=ut(t);return r._iter=t,r.size=t.size,r.flip=function(){return t},r.reverse=function(){var r=t.reverse.apply(this);return r.flip=function(){return t.reverse()},r},r.has=function(r){return t.includes(r)},r.includes=function(r){return t.has(r)},r.cacheResult=st,r.__iterateUncached=function(r,e){var n=this;return t.__iterate(function(t,e){return r(e,t,n)!==!1},e)},r.__iteratorUncached=function(r,e){if(r===Se){var n=t.__iterator(r,e);return new Ee(function(){var t=n.next();if(!t.done){var r=t.value[0];t.value[0]=t.value[1],t.value[1]=r}return t})}return t.__iterator(r===ze?we:ze,e)},r}function W(t,r,e){var n=ut(t);return n.size=t.size,n.has=function(r){return t.has(r)},n.get=function(n,i){var o=t.get(n,ae);return o===ae?i:r.call(e,o,n,t)},n.__iterateUncached=function(n,i){var o=this;return t.__iterate(function(t,i,u){return n(r.call(e,t,i,u),i,o)!==!1},i)},n.__iteratorUncached=function(n,i){var o=t.__iterator(Se,i);return new Ee(function(){var i=o.next();if(i.done)return i;var u=i.value,s=u[0];return w(n,s,r.call(e,u[1],s,t),i)})},n}function N(t,r){var e=this,n=ut(t);return n._iter=t,n.size=t.size,n.reverse=function(){return t},t.flip&&(n.flip=function(){var r=B(t);return r.reverse=function(){return t.flip()},r}),n.get=function(e,n){return t.get(r?e:-1-e,n)},n.has=function(e){return t.has(r?e:-1-e)},n.includes=function(r){return t.includes(r)},n.cacheResult=st,n.__iterate=function(e,n){var o=this,u=0;return n&&i(t),t.__iterate(function(t,i){return e(t,r?i:n?o.size-++u:u++,o)},!n)},n.__iterator=function(n,o){var u=0;o&&i(t);var s=t.__iterator(Se,!o);return new Ee(function(){var t=s.next();if(t.done)return t;var i=t.value;return w(n,r?i[0]:o?e.size-++u:u++,i[1],t)})},n}function P(t,r,e,n){var i=ut(t);return n&&(i.has=function(n){var i=t.get(n,ae);return i!==ae&&!!r.call(e,i,n,t)},i.get=function(n,i){var o=t.get(n,ae);return o!==ae&&r.call(e,o,n,t)?o:i}),i.__iterateUncached=function(i,o){var u=this,s=0 +;return t.__iterate(function(t,o,a){if(r.call(e,t,o,a))return s++,i(t,n?o:s-1,u)},o),s},i.__iteratorUncached=function(i,o){var u=t.__iterator(Se,o),s=0;return new Ee(function(){for(;;){var o=u.next();if(o.done)return o;var a=o.value,c=a[0],f=a[1];if(r.call(e,f,c,t))return w(i,n?c:s++,f,o)}})},i}function J(t,r,e){var n=$e().asMutable();return t.__iterate(function(i,o){n.update(r.call(e,i,o,t),0,function(t){return t+1})}),n.asImmutable()}function H(t,r,e){var n=l(t),i=(d(t)?mn():$e()).asMutable();t.__iterate(function(o,u){i.update(r.call(e,o,u,t),function(t){return t=t||[],t.push(n?[u,o]:o),t})});var o=ot(t);return i.map(function(r){return nt(t,o(r))})}function V(t,r,e,n){var i=t.size;if(s(r,e,i))return t;var u=a(r,i),f=c(e,i);if(u!==u||f!==f)return V(t.toSeq().cacheResult(),r,e,n);var h,p=f-u;p===p&&(h=p<0?0:p);var _=ut(t);return _.size=0===h?h:t.size&&h||void 0,!n&&q(t)&&h>=0&&(_.get=function(r,e){return r=o(this,r),r>=0&&rh)return z();var t=i.next();return n||r===ze||t.done?t:r===we?w(r,s-1,void 0,t):w(r,s-1,t.value[1],t)})},_}function Y(t,r,e){var n=ut(t);return n.__iterateUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterate(n,i);var u=0;return t.__iterate(function(t,i,s){return r.call(e,t,i,s)&&++u&&n(t,i,o)}),u},n.__iteratorUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterator(n,i);var u=t.__iterator(Se,i),s=!0;return new Ee(function(){if(!s)return z();var t=u.next();if(t.done)return t;var i=t.value,a=i[0],c=i[1];return r.call(e,c,a,o)?n===Se?t:w(n,a,c,t):(s=!1,z())})},n}function Q(t,r,e,n){var i=ut(t) +;return i.__iterateUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterate(i,o);var s=!0,a=0;return t.__iterate(function(t,o,c){if(!s||!(s=r.call(e,t,o,c)))return a++,i(t,n?o:a-1,u)}),a},i.__iteratorUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterator(i,o);var s=t.__iterator(Se,o),a=!0,c=0;return new Ee(function(){var t,o,f;do{if(t=s.next(),t.done)return n||i===ze?t:i===we?w(i,c++,void 0,t):w(i,c++,t.value[1],t);var h=t.value;o=h[0],f=h[1],a&&(a=r.call(e,f,o,u))}while(a);return i===Se?t:w(i,o,f,t)})},i}function X(t,r){var e=l(t),n=[t].concat(r).map(function(t){return _(t)?e&&(t=de(t)):t=e?D(t):x(Array.isArray(t)?t:[t]),t}).filter(function(t){return 0!==t.size});if(0===n.length)return t;if(1===n.length){var i=n[0];if(i===t||e&&l(i)||v(t)&&v(i))return i}var o=new ke(n);return e?o=o.toKeyedSeq():v(t)||(o=o.toSetSeq()),o=o.flatten(!0),o.size=n.reduce(function(t,r){if(void 0!==t){var e=r.size;if(void 0!==e)return t+e}},0),o}function F(t,r,e){var n=ut(t);return n.__iterateUncached=function(i,o){function u(t,c){t.__iterate(function(t,o){return(!r||c0}function et(t,r,e,n){var i=ut(t),o=new ke(e).map(function(t){return t.size});return i.size=n?o.max():o.min(),i.__iterate=function(t,r){for(var e,n=this,i=this.__iterator(ze,r),o=0;!(e=i.next()).done&&t(e.value,o++,n)!==!1;);return o},i.__iteratorUncached=function(t,i){var o=e.map(function(t){return t=ye(t),b(i?t.reverse():t)}),u=0,s=!1;return new Ee(function(){var e;return s||(e=o.map(function(t){return t.next()}),s=n?e.every(function(t){return t.done}):e.some(function(t){return t.done})),s?z():w(t,u++,r.apply(null,e.map(function(t){return t.value})))})},i}function nt(t,r){return t===r?t:q(t)?r:t.constructor(r)}function it(t){if(t!==Object(t))throw new TypeError("Expected [K, V] tuple: "+t)}function ot(t){return l(t)?de:v(t)?ge:me}function ut(t){return Object.create((l(t)?De:v(t)?xe:Ae).prototype)}function st(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size,this):Me.prototype.cacheResult.call(this)}function at(t,r){return void 0===t&&void 0===r?0:void 0===t?1:void 0===r?-1:t>r?1:t0;)r[e]=arguments[e+1];return jt(this,r,t)}function jt(t,r,e){for(var n=[],i=0;i0;)r[e]=arguments[e+1];return Ct(t,r)}function Rt(t,r){for(var e=[],n=arguments.length-2;n-- >0;)e[n]=arguments[n+2];return Ct(r,e,t)}function Ut(t){for(var r=[],e=arguments.length-1;e-- >0;)r[e]=arguments[e+1];return Tt(t,r)}function Kt(t,r){for(var e=[],n=arguments.length-2;n-- >0;)e[n]=arguments[n+2];return Tt(r,e,t)}function Tt(t,r,e){return Ct(t,r,Lt(e))}function Ct(t,r,e){if(!lt(t))throw new TypeError("Cannot merge into non-data-structure value: "+t);if(p(t))return t.mergeWith?t.mergeWith.apply(t,[e].concat(r)):t.concat.apply(t,r);for(var n=Array.isArray(t),i=t,o=n?ge:de,u=n?function(r){i===t&&(i=gt(i)),i.push(r)}:function(r,n){var o=qe.call(i,n),u=o&&e?e(i[n],r,n):r;o&&u===i[n]||(i===t&&(i=gt(i)),i[n]=u)},s=0;s0;)r[e]=arguments[e+1];return Tt(this,r,t)}function Nt(t){for(var r=[],e=arguments.length-1;e-- >0;)r[e]=arguments[e+1];return zt(this,t,Zt(),function(t){return Ct(t,r)})}function Pt(t){for(var r=[],e=arguments.length-1;e-- >0;)r[e]=arguments[e+1];return zt(this,t,Zt(),function(t){return Tt(t,r)})}function Jt(t){var r=this.asMutable();return t(r),r.wasAltered()?r.__ensureOwner(this.__ownerID):this}function Ht(){return this.__ownerID?this:this.__ensureOwner(new n)}function Vt(){return this.__ensureOwner()}function Yt(){return this.__altered}function Qt(t){return!(!t||!t[tn])}function Xt(t,r){return w(t,r[0],r[1])}function Ft(t,r){return{node:t,index:0,__prev:r}}function Gt(t,r,e,n){var i=Object.create(rn);return i.size=t,i._root=r, i.__ownerID=e,i.__hash=n,i.__altered=!1,i}function Zt(){return an||(an=Gt(0))}function $t(t,e,n){var i,o;if(t._root){var u=r(ce),s=r(fe);if(i=tr(t._root,t.__ownerID,0,void 0,e,n,u,s),!s.value)return t;o=t.size+(u.value?n===ae?-1:1:0)}else{if(n===ae)return t;o=1,i=new en(t.__ownerID,[[e,n]])}return t.__ownerID?(t.size=o,t._root=i,t.__hash=void 0,t.__altered=!0,t):i?Gt(o,i):Zt()}function tr(t,r,n,i,o,u,s,a){return t?t.update(r,n,i,o,u,s,a):u===ae?t:(e(a),e(s),new sn(r,i,[o,u]))}function rr(t){return t.constructor===sn||t.constructor===un}function er(t,r,e,n,i){if(t.keyHash===n)return new un(r,n,[t.entry,i]);var o,u=(0===e?t.keyHash:t.keyHash>>>e)&se,s=(0===e?n:n>>>e)&se;return new nn(r,1<>>=1)u[s]=1&e?r[o++]:void 0;return u[n]=i,new on(t,o+1,u)}function ur(t){return t-=t>>1&1431655765,t=(858993459&t)+(t>>2&858993459),t=t+(t>>4)&252645135,t+=t>>8,127&(t+=t>>16)}function sr(t,r,e,n){var i=n?t:ct(t);return i[r]=e,i}function ar(t,r,e,n){var i=t.length+1;if(n&&r+1===i)return t[r]=e,t;for(var o=Array(i),u=0,s=0;so?0:o-e,c=u-e;return c>ue&&(c=ue),function(){if(i===c)return gn;var t=r?--c:i++;return n&&n[t]}}function i(t,n,i){var s,a=t&&t.array,c=i>o?0:o-i>>n,f=1+(u-i>>n);return f>ue&&(f=ue),function(){for(;;){if(s){var t=s();if(t!==gn)return t;s=null}if(c===f)return gn ;var o=r?--f:c++;s=e(a&&a[o],n-oe,i+(o<=t.size||e<0)return t.withMutations(function(t){e<0?gr(t,e).set(0,n):gr(t,0,e+1).set(e,n)});e+=t._origin;var i=t._tail,u=t._root,s=r(fe);return e>=mr(t._capacity)?i=vr(i,t.__ownerID,0,e,n,s):u=vr(u,t.__ownerID,t._level,e,n,s),s.value?t.__ownerID?(t._root=u,t._tail=i,t.__hash=void 0,t.__altered=!0,t):pr(t._origin,t._capacity,t._level,u,i):t}function vr(t,r,n,i,o,u){var s=i>>>n&se,a=t&&s0){var f=t&&t.array[s],h=vr(f,r,n-oe,i,o,u);return h===f?t:(c=yr(t,r),c.array[s]=h,c)}return a&&t.array[s]===o?t:(e(u),c=yr(t,r),void 0===o&&s===c.array.length-1?c.array.pop():c.array[s]=o,c)}function yr(t,r){return r&&t&&r===t.ownerID?t:new yn(t?t.array.slice():[],r)}function dr(t,r){if(r>=mr(t._capacity))return t._tail;if(r<1<0;)e=e.array[r>>>n&se],n-=oe;return e}}function gr(t,r,e){void 0!==r&&(r|=0),void 0!==e&&(e|=0);var i=t.__ownerID||new n,o=t._origin,u=t._capacity,s=o+r,a=void 0===e?u:e<0?u+e:o+e;if(s===o&&a===u)return t;if(s>=a)return t.clear();for(var c=t._level,f=t._root,h=0;s+h<0;)f=new yn(f&&f.array.length?[void 0,f]:[],i),c+=oe,h+=1<=1<p?new yn([],i):l;if(l&&_>p&&soe;d-=oe){var g=p>>>d&se;y=y.array[g]=yr(y.array[g],i)}y.array[p>>>oe&se]=l}if(a=_)s-=_,a-=_,c=oe,f=null,v=v&&v.removeBefore(i,0,s);else if(s>o||_>>c&se;if(m!==_>>>c&se)break;m&&(h+=(1< Date: Thu, 17 May 2018 12:30:11 +0000 Subject: [PATCH 100/242] Deploy 0ebb7781c03d57e2e0c011975e85e57252d80d09 to NPM branch --- README.md | 2 +- dist/immutable-nonambient.d.ts | 2 +- dist/immutable.d.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 295739383d..3a61d541f1 100644 --- a/README.md +++ b/README.md @@ -158,7 +158,7 @@ instead of the `===` operator which determines object reference identity. ```js const { Map } = require('immutable') -const map1 = Map( {a: 1, b: 2, c: 3 }) +const map1 = Map({ a: 1, b: 2, c: 3 }) const map2 = map1.set('b', 2) assert.equal(map1, map2) // uses map1.equals assert.strictEqual(map1, map2) // uses === diff --git a/dist/immutable-nonambient.d.ts b/dist/immutable-nonambient.d.ts index 674156bd7b..cc2da5ba9e 100644 --- a/dist/immutable-nonambient.d.ts +++ b/dist/immutable-nonambient.d.ts @@ -80,7 +80,7 @@ * * * Note: All examples are presented in the modern [ES2015][] version of - * JavaScript. To run in older browsers, they need to be translated to ES3. + * JavaScript. Use tools like Babel to support older browsers. * * For example: * diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index c67f86d3c3..fde4a5c339 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -80,7 +80,7 @@ * * * Note: All examples are presented in the modern [ES2015][] version of - * JavaScript. To run in older browsers, they need to be translated to ES3. + * JavaScript. Use tools like Babel to support older browsers. * * For example: * From c0387bdf32f73a2755438819764e9646f58590ad Mon Sep 17 00:00:00 2001 From: Travis CI Date: Thu, 17 May 2018 12:30:16 +0000 Subject: [PATCH 101/242] Deploy 2786db59fd01c7e2577ff45bc2e8f2b826a8d3ef to NPM branch --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3a61d541f1..295739383d 100644 --- a/README.md +++ b/README.md @@ -158,7 +158,7 @@ instead of the `===` operator which determines object reference identity. ```js const { Map } = require('immutable') -const map1 = Map({ a: 1, b: 2, c: 3 }) +const map1 = Map( {a: 1, b: 2, c: 3 }) const map2 = map1.set('b', 2) assert.equal(map1, map2) // uses map1.equals assert.strictEqual(map1, map2) // uses === From 9348ee72f74e648f6d071f029993bef98f0eacba Mon Sep 17 00:00:00 2001 From: Travis CI Date: Thu, 17 May 2018 12:52:30 +0000 Subject: [PATCH 102/242] Deploy 8f45d0ea058be7ae1ec9a9a64075a929d7f6f482 to NPM branch --- README.md | 2 +- dist/immutable.es.js | 76 +++++++++++++++++++++++++++++++++----------- dist/immutable.js | 76 +++++++++++++++++++++++++++++++++----------- 3 files changed, 115 insertions(+), 39 deletions(-) diff --git a/README.md b/README.md index 295739383d..3a61d541f1 100644 --- a/README.md +++ b/README.md @@ -158,7 +158,7 @@ instead of the `===` operator which determines object reference identity. ```js const { Map } = require('immutable') -const map1 = Map( {a: 1, b: 2, c: 3 }) +const map1 = Map({ a: 1, b: 2, c: 3 }) const map2 = map1.set('b', 2) assert.equal(map1, map2) // uses map1.equals assert.strictEqual(map1, map2) // uses === diff --git a/dist/immutable.es.js b/dist/immutable.es.js index 51997a37fb..a8fa05adb5 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -86,7 +86,9 @@ function resolveIndex(index, size, defaultIndex) { return index === undefined ? defaultIndex : isNeg(index) - ? size === Infinity ? size : Math.max(0, size + index) | 0 + ? size === Infinity + ? size + : Math.max(0, size + index) | 0 : size === undefined || size === index ? index : Math.min(size, index) | 0; @@ -259,7 +261,9 @@ var Seq = (function (Collection$$1) { function Seq(value) { return value === null || value === undefined ? emptySequence() - : isImmutable(value) ? value.toSeq() : seqFromValue(value); + : isImmutable(value) + ? value.toSeq() + : seqFromValue(value); } if ( Collection$$1 ) Seq.__proto__ = Collection$$1; @@ -328,8 +332,12 @@ var KeyedSeq = (function (Seq) { return value === null || value === undefined ? emptySequence().toKeyedSeq() : isCollection(value) - ? isKeyed(value) ? value.toSeq() : value.fromEntrySeq() - : isRecord(value) ? value.toSeq() : keyedSeqFromValue(value); + ? isKeyed(value) + ? value.toSeq() + : value.fromEntrySeq() + : isRecord(value) + ? value.toSeq() + : keyedSeqFromValue(value); } if ( Seq ) KeyedSeq.__proto__ = Seq; @@ -348,7 +356,9 @@ var IndexedSeq = (function (Seq) { return value === null || value === undefined ? emptySequence() : isCollection(value) - ? isKeyed(value) ? value.entrySeq() : value.toIndexedSeq() + ? isKeyed(value) + ? value.entrySeq() + : value.toIndexedSeq() : isRecord(value) ? value.toSeq().entrySeq() : indexedSeqFromValue(value); @@ -632,7 +642,9 @@ function keyedSeqFromValue(value) { ? new ArraySeq(value) : isIterator(value) ? new IteratorSeq(value) - : hasIterator(value) ? new CollectionSeq(value) : undefined; + : hasIterator(value) + ? new CollectionSeq(value) + : undefined; if (seq) { return seq.fromEntrySeq(); } @@ -673,7 +685,9 @@ function maybeIndexedSeqFromValue(value) { ? new ArraySeq(value) : isIterator(value) ? new IteratorSeq(value) - : hasIterator(value) ? new CollectionSeq(value) : undefined; + : hasIterator(value) + ? new CollectionSeq(value) + : undefined; } /** @@ -1722,7 +1736,9 @@ function sortFactory(collection, comparator, mapper) { ); return isKeyedCollection ? KeyedSeq(entries) - : isIndexed(collection) ? IndexedSeq(entries) : SetSeq(entries); + : isIndexed(collection) + ? IndexedSeq(entries) + : SetSeq(entries); } function maxFactory(collection, comparator, mapper) { @@ -1821,14 +1837,18 @@ function validateEntry(entry) { function collectionClass(collection) { return isKeyed(collection) ? KeyedCollection - : isIndexed(collection) ? IndexedCollection : SetCollection; + : isIndexed(collection) + ? IndexedCollection + : SetCollection; } function makeSequence(collection) { return Object.create( (isKeyed(collection) ? KeyedSeq - : isIndexed(collection) ? IndexedSeq : SetSeq + : isIndexed(collection) + ? IndexedSeq + : SetSeq ).prototype ); } @@ -2210,7 +2230,9 @@ function deepMergerWith(merger) { function deepMerger(oldValue, newValue, key) { return isDataStructure(oldValue) && isDataStructure(newValue) ? mergeWithSources(oldValue, [newValue], deepMerger) - : merger ? merger(oldValue, newValue, key) : newValue; + : merger + ? merger(oldValue, newValue, key) + : newValue; } return deepMerger; } @@ -3107,7 +3129,9 @@ var List = (function (IndexedCollection$$1) { ? this : index === 0 ? this.shift() - : index === this.size - 1 ? this.pop() : this.splice(index, 1); + : index === this.size - 1 + ? this.pop() + : this.splice(index, 1); }; List.prototype.insert = function insert (index, value) { @@ -3560,7 +3584,9 @@ function setListBounds(list, begin, end) { var newCapacity = end === undefined ? oldCapacity - : end < 0 ? oldCapacity + end : oldOrigin + end; + : end < 0 + ? oldCapacity + end + : oldOrigin + end; if (newOrigin === oldOrigin && newCapacity === oldCapacity) { return list; } @@ -3607,7 +3633,9 @@ function setListBounds(list, begin, end) { var newTail = newTailOffset < oldTailOffset ? listNodeFor(list, newCapacity - 1) - : newTailOffset > oldTailOffset ? new VNode([], owner) : oldTail; + : newTailOffset > oldTailOffset + ? new VNode([], owner) + : oldTail; // Merge Tail into tree. if ( @@ -3860,7 +3888,9 @@ var Stack = (function (IndexedCollection$$1) { function Stack(value) { return value === null || value === undefined ? emptyStack() - : isStack(value) ? value : emptyStack().pushAll(value); + : isStack(value) + ? value + : emptyStack().pushAll(value); } if ( IndexedCollection$$1 ) Stack.__proto__ = IndexedCollection$$1; @@ -4138,7 +4168,9 @@ function deepEqual(a, b) { if ( notAssociative ? !a.has(v) - : flipped ? !is(v, a.get(k, NOT_SET)) : !is(a.get(k, NOT_SET), v) + : flipped + ? !is(v, a.get(k, NOT_SET)) + : !is(a.get(k, NOT_SET), v) ) { allEqual = false; return false; @@ -4370,7 +4402,9 @@ function updateSet(set, newMap) { } return newMap === set._map ? set - : newMap.size === 0 ? set.__empty() : set.__make(newMap); + : newMap.size === 0 + ? set.__empty() + : set.__make(newMap); } function makeSet(map, ownerID) { @@ -4623,7 +4657,9 @@ mixin(Collection, { toSeq: function toSeq() { return isIndexed(this) ? this.toIndexedSeq() - : isKeyed(this) ? this.toKeyedSeq() : this.toSetSeq(); + : isKeyed(this) + ? this.toKeyedSeq() + : this.toSetSeq(); }, toStack: function toStack() { @@ -5675,7 +5711,9 @@ function fromJS(value, converter) { function fromJSWith(stack, converter, value, key, keyPath, parentValue) { var toSeq = Array.isArray(value) ? IndexedSeq - : isPlainObj(value) ? KeyedSeq : null; + : isPlainObj(value) + ? KeyedSeq + : null; if (toSeq) { if (~stack.indexOf(value)) { throw new TypeError('Cannot convert circular structure to Immutable'); diff --git a/dist/immutable.js b/dist/immutable.js index da6af3c81e..bfa601dfd1 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -92,7 +92,9 @@ function resolveIndex(index, size, defaultIndex) { return index === undefined ? defaultIndex : isNeg(index) - ? size === Infinity ? size : Math.max(0, size + index) | 0 + ? size === Infinity + ? size + : Math.max(0, size + index) | 0 : size === undefined || size === index ? index : Math.min(size, index) | 0; @@ -265,7 +267,9 @@ var Seq = (function (Collection$$1) { function Seq(value) { return value === null || value === undefined ? emptySequence() - : isImmutable(value) ? value.toSeq() : seqFromValue(value); + : isImmutable(value) + ? value.toSeq() + : seqFromValue(value); } if ( Collection$$1 ) Seq.__proto__ = Collection$$1; @@ -334,8 +338,12 @@ var KeyedSeq = (function (Seq) { return value === null || value === undefined ? emptySequence().toKeyedSeq() : isCollection(value) - ? isKeyed(value) ? value.toSeq() : value.fromEntrySeq() - : isRecord(value) ? value.toSeq() : keyedSeqFromValue(value); + ? isKeyed(value) + ? value.toSeq() + : value.fromEntrySeq() + : isRecord(value) + ? value.toSeq() + : keyedSeqFromValue(value); } if ( Seq ) KeyedSeq.__proto__ = Seq; @@ -354,7 +362,9 @@ var IndexedSeq = (function (Seq) { return value === null || value === undefined ? emptySequence() : isCollection(value) - ? isKeyed(value) ? value.entrySeq() : value.toIndexedSeq() + ? isKeyed(value) + ? value.entrySeq() + : value.toIndexedSeq() : isRecord(value) ? value.toSeq().entrySeq() : indexedSeqFromValue(value); @@ -638,7 +648,9 @@ function keyedSeqFromValue(value) { ? new ArraySeq(value) : isIterator(value) ? new IteratorSeq(value) - : hasIterator(value) ? new CollectionSeq(value) : undefined; + : hasIterator(value) + ? new CollectionSeq(value) + : undefined; if (seq) { return seq.fromEntrySeq(); } @@ -679,7 +691,9 @@ function maybeIndexedSeqFromValue(value) { ? new ArraySeq(value) : isIterator(value) ? new IteratorSeq(value) - : hasIterator(value) ? new CollectionSeq(value) : undefined; + : hasIterator(value) + ? new CollectionSeq(value) + : undefined; } /** @@ -1728,7 +1742,9 @@ function sortFactory(collection, comparator, mapper) { ); return isKeyedCollection ? KeyedSeq(entries) - : isIndexed(collection) ? IndexedSeq(entries) : SetSeq(entries); + : isIndexed(collection) + ? IndexedSeq(entries) + : SetSeq(entries); } function maxFactory(collection, comparator, mapper) { @@ -1827,14 +1843,18 @@ function validateEntry(entry) { function collectionClass(collection) { return isKeyed(collection) ? KeyedCollection - : isIndexed(collection) ? IndexedCollection : SetCollection; + : isIndexed(collection) + ? IndexedCollection + : SetCollection; } function makeSequence(collection) { return Object.create( (isKeyed(collection) ? KeyedSeq - : isIndexed(collection) ? IndexedSeq : SetSeq + : isIndexed(collection) + ? IndexedSeq + : SetSeq ).prototype ); } @@ -2216,7 +2236,9 @@ function deepMergerWith(merger) { function deepMerger(oldValue, newValue, key) { return isDataStructure(oldValue) && isDataStructure(newValue) ? mergeWithSources(oldValue, [newValue], deepMerger) - : merger ? merger(oldValue, newValue, key) : newValue; + : merger + ? merger(oldValue, newValue, key) + : newValue; } return deepMerger; } @@ -3113,7 +3135,9 @@ var List = (function (IndexedCollection$$1) { ? this : index === 0 ? this.shift() - : index === this.size - 1 ? this.pop() : this.splice(index, 1); + : index === this.size - 1 + ? this.pop() + : this.splice(index, 1); }; List.prototype.insert = function insert (index, value) { @@ -3566,7 +3590,9 @@ function setListBounds(list, begin, end) { var newCapacity = end === undefined ? oldCapacity - : end < 0 ? oldCapacity + end : oldOrigin + end; + : end < 0 + ? oldCapacity + end + : oldOrigin + end; if (newOrigin === oldOrigin && newCapacity === oldCapacity) { return list; } @@ -3613,7 +3639,9 @@ function setListBounds(list, begin, end) { var newTail = newTailOffset < oldTailOffset ? listNodeFor(list, newCapacity - 1) - : newTailOffset > oldTailOffset ? new VNode([], owner) : oldTail; + : newTailOffset > oldTailOffset + ? new VNode([], owner) + : oldTail; // Merge Tail into tree. if ( @@ -3866,7 +3894,9 @@ var Stack = (function (IndexedCollection$$1) { function Stack(value) { return value === null || value === undefined ? emptyStack() - : isStack(value) ? value : emptyStack().pushAll(value); + : isStack(value) + ? value + : emptyStack().pushAll(value); } if ( IndexedCollection$$1 ) Stack.__proto__ = IndexedCollection$$1; @@ -4144,7 +4174,9 @@ function deepEqual(a, b) { if ( notAssociative ? !a.has(v) - : flipped ? !is(v, a.get(k, NOT_SET)) : !is(a.get(k, NOT_SET), v) + : flipped + ? !is(v, a.get(k, NOT_SET)) + : !is(a.get(k, NOT_SET), v) ) { allEqual = false; return false; @@ -4376,7 +4408,9 @@ function updateSet(set, newMap) { } return newMap === set._map ? set - : newMap.size === 0 ? set.__empty() : set.__make(newMap); + : newMap.size === 0 + ? set.__empty() + : set.__make(newMap); } function makeSet(map, ownerID) { @@ -4629,7 +4663,9 @@ mixin(Collection, { toSeq: function toSeq() { return isIndexed(this) ? this.toIndexedSeq() - : isKeyed(this) ? this.toKeyedSeq() : this.toSetSeq(); + : isKeyed(this) + ? this.toKeyedSeq() + : this.toSetSeq(); }, toStack: function toStack() { @@ -5681,7 +5717,9 @@ function fromJS(value, converter) { function fromJSWith(stack, converter, value, key, keyPath, parentValue) { var toSeq = Array.isArray(value) ? IndexedSeq - : isPlainObj(value) ? KeyedSeq : null; + : isPlainObj(value) + ? KeyedSeq + : null; if (toSeq) { if (~stack.indexOf(value)) { throw new TypeError('Cannot convert circular structure to Immutable'); From 4e26b32b80a58673723fcf5b09ba96ccbd394f1d Mon Sep 17 00:00:00 2001 From: Travis CI Date: Thu, 17 May 2018 14:44:24 +0000 Subject: [PATCH 103/242] Deploy 4ca6e19a8abce46a461d50f6987ace8ecbe45a12 to NPM branch --- dist/immutable.js.flow | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dist/immutable.js.flow b/dist/immutable.js.flow index 1aff84ada2..9904310f83 100644 --- a/dist/immutable.js.flow +++ b/dist/immutable.js.flow @@ -1456,8 +1456,8 @@ declare class RecordInstance { removeIn, K2: $KeyOf<$ValOf>, K3: $KeyOf<$ValOf<$ValOf, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>>>(keyPath: [K, K2, K3, K4]): this & T; removeIn, K2: $KeyOf<$ValOf>, K3: $KeyOf<$ValOf<$ValOf, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>>, K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>>>(keyPath: [K, K2, K3, K4, K5]): this & T; - updateIn(keyPath: [], notSetValue: mixed, updater: (value: this) => U): U; - updateIn(keyPath: [], updater: (value: this) => U): U; + updateIn(keyPath: [], notSetValue: mixed, updater: (value: this & T) => U): U; + updateIn(keyPath: [], updater: (value: this & T) => U): U; updateIn, S: $ValOf>(keyPath: [K], notSetValue: NSV, updater: (value: $ValOf) => S): this & T; updateIn, S: $ValOf>(keyPath: [K], updater: (value: $ValOf) => S): this & T; updateIn, K2: $KeyOf<$ValOf>, S: $ValOf<$ValOf, K2>>(keyPath: [K, K2], notSetValue: NSV, updater: (value: $ValOf<$ValOf, K2> | NSV) => S): this & T; @@ -1478,7 +1478,7 @@ declare class RecordInstance { toJSON(): T; toObject(): T; - withMutations(mutator: (mutable: this) => mixed): this & T; + withMutations(mutator: (mutable: this & T) => mixed): this & T; asMutable(): this & T; wasAltered(): boolean; asImmutable(): this & T; From 4908d52f4957e7cd78ed2a777912e29f0ed5c667 Mon Sep 17 00:00:00 2001 From: Travis CI Date: Thu, 17 May 2018 14:48:20 +0000 Subject: [PATCH 104/242] Deploy d960d5c4e00f616aa2aec0ecd765735525c6166f to NPM branch --- dist/immutable-nonambient.d.ts | 6 ------ dist/immutable.d.ts | 6 ------ dist/immutable.es.js | 18 ++++++++++++++++++ dist/immutable.js | 18 ++++++++++++++++++ dist/immutable.min.js | 32 ++++++++++++++++---------------- 5 files changed, 52 insertions(+), 28 deletions(-) diff --git a/dist/immutable-nonambient.d.ts b/dist/immutable-nonambient.d.ts index cc2da5ba9e..c061bce027 100644 --- a/dist/immutable-nonambient.d.ts +++ b/dist/immutable-nonambient.d.ts @@ -556,9 +556,6 @@ * List([ 1, 2 ]).map(x => 10 * x) * // List [ 10, 20 ] * ``` - * - * Note: `map()` always returns a new instance, even if it produced the same - * value at every step. */ map( mapper: (value: T, key: number, iter: this) => M, @@ -1325,9 +1322,6 @@ * * Map({ a: 1, b: 2 }).map(x => 10 * x) * // Map { a: 10, b: 20 } - * - * Note: `map()` always returns a new instance, even if it produced the same - * value at every step. */ map( mapper: (value: V, key: K, iter: this) => M, diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index fde4a5c339..c273a526ed 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -556,9 +556,6 @@ declare module Immutable { * List([ 1, 2 ]).map(x => 10 * x) * // List [ 10, 20 ] * ``` - * - * Note: `map()` always returns a new instance, even if it produced the same - * value at every step. */ map( mapper: (value: T, key: number, iter: this) => M, @@ -1325,9 +1322,6 @@ declare module Immutable { * * Map({ a: 1, b: 2 }).map(x => 10 * x) * // Map { a: 10, b: 20 } - * - * Note: `map()` always returns a new instance, even if it produced the same - * value at every step. */ map( mapper: (value: V, key: K, iter: this) => M, diff --git a/dist/immutable.es.js b/dist/immutable.es.js index a8fa05adb5..423e746aa5 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -2375,6 +2375,14 @@ var Map = (function (KeyedCollection$$1) { return OrderedMap(sortFactory(this, comparator, mapper)); }; + Map.prototype.map = function map (mapper, context) { + return this.withMutations(function (map) { + map.forEach(function (value, key) { + map.set(key, mapper.call(context, value, key, map)); + }); + }); + }; + // @pragma Mutability Map.prototype.__iterator = function __iterator (type, reverse) { @@ -3214,6 +3222,16 @@ var List = (function (IndexedCollection$$1) { return setListBounds(this, 0, size); }; + List.prototype.map = function map (mapper, context) { + var this$1 = this; + + return this.withMutations(function (list) { + for (var i = 0; i < this$1.size; i++) { + list.set(i, mapper.call(context, list.get(i), i, list)); + } + }); + }; + // @pragma Iteration List.prototype.slice = function slice (begin, end) { diff --git a/dist/immutable.js b/dist/immutable.js index bfa601dfd1..a498074d7d 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -2381,6 +2381,14 @@ var Map = (function (KeyedCollection$$1) { return OrderedMap(sortFactory(this, comparator, mapper)); }; + Map.prototype.map = function map (mapper, context) { + return this.withMutations(function (map) { + map.forEach(function (value, key) { + map.set(key, mapper.call(context, value, key, map)); + }); + }); + }; + // @pragma Mutability Map.prototype.__iterator = function __iterator (type, reverse) { @@ -3220,6 +3228,16 @@ var List = (function (IndexedCollection$$1) { return setListBounds(this, 0, size); }; + List.prototype.map = function map (mapper, context) { + var this$1 = this; + + return this.withMutations(function (list) { + for (var i = 0; i < this$1.size; i++) { + list.set(i, mapper.call(context, list.get(i), i, list)); + } + }); + }; + // @pragma Iteration List.prototype.slice = function slice (begin, end) { diff --git a/dist/immutable.min.js b/dist/immutable.min.js index 4409eef265..6a27aefe43 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -20,19 +20,19 @@ function ne(t,r,e,n,i,o){var u=Array.isArray(e)?xe:_t(e)?De:null;if(u){if(~t.ind return o}return this.__iterateUncached(t,r)},r.prototype.__iterator=function(t,r){var e=this._cache;if(e){var n=e.length,i=0;return new Ee(function(){if(i===n)return z();var o=e[r?n-++i:i++];return w(t,o[0],o[1])})}return this.__iteratorUncached(t,r)},r}(ye),De=function(t){function r(t){return null===t||void 0===t?M().toKeyedSeq():_(t)?l(t)?t.toSeq():t.fromEntrySeq():g(t)?t.toSeq():D(t)}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.prototype.toKeyedSeq=function(){return this},r}(Me),xe=function(t){function r(t){return null===t||void 0===t?M():_(t)?l(t)?t.entrySeq():t.toIndexedSeq():g(t)?t.toSeq().entrySeq():x(t)}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.of=function(){return r(arguments)},r.prototype.toIndexedSeq=function(){return this},r.prototype.toString=function(){return this.__toString("Seq [","]")},r}(Me),Ae=function(t){function r(t){return(_(t)&&!y(t)?t:xe(t)).toSetSeq()}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.of=function(){return r(arguments)},r.prototype.toSetSeq=function(){return this},r}(Me);Me.isSeq=q,Me.Keyed=De,Me.Set=Ae,Me.Indexed=xe;var je="@@__IMMUTABLE_SEQ__@@";Me.prototype[je]=!0;var ke=function(t){function r(t){this._array=t,this.size=t.length}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.prototype.get=function(t,r){return this.has(t)?this._array[o(this,t)]:r},r.prototype.__iterate=function(t,r){for(var e=this,n=this._array,i=n.length,o=0;o!==i;){var u=r?i-++o:o++;if(t(n[u],u,e)===!1)break}return o},r.prototype.__iterator=function(t,r){var e=this._array,n=e.length,i=0;return new Ee(function(){if(i===n)return z();var o=r?n-++i:i++;return w(t,o,e[o])})},r}(xe),Re=function(t){function r(t){var r=Object.keys(t);this._object=t,this._keys=r,this.size=r.length}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.prototype.get=function(t,r){ return void 0===r||this.has(t)?this._object[t]:r},r.prototype.has=function(t){return qe.call(this._object,t)},r.prototype.__iterate=function(t,r){for(var e=this,n=this._object,i=this._keys,o=i.length,u=0;u!==o;){var s=i[r?o-++u:u++];if(t(n[s],s,e)===!1)break}return u},r.prototype.__iterator=function(t,r){var e=this._object,n=this._keys,i=n.length,o=0;return new Ee(function(){if(o===i)return z();var u=n[r?i-++o:o++];return w(t,u,e[u])})},r}(De);Re.prototype[le]=!0;var Ue,Ke,Te=function(t){function r(t){this._collection=t,this.size=t.length||t.size}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.prototype.__iterateUncached=function(t,r){var e=this;if(r)return this.cacheResult().__iterate(t,r);var n=this._collection,i=b(n),o=0;if(I(i))for(var u;!(u=i.next()).done&&t(u.value,o++,e)!==!1;);return o},r.prototype.__iteratorUncached=function(t,r){if(r)return this.cacheResult().__iterator(t,r);var e=this._collection,n=b(e);if(!I(n))return new Ee(z);var i=0;return new Ee(function(){var r=n.next();return r.done?r:w(t,i++,r.value)})},r}(xe),Ce=function(t){function r(t){this._iterator=t,this._iteratorCache=[]}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.prototype.__iterateUncached=function(t,r){var e=this;if(r)return this.cacheResult().__iterate(t,r);for(var n=this._iterator,i=this._iteratorCache,o=0;o=n.length){var r=e.next();if(r.done)return r;n[i]=r.value}return w(t,i,n[i++])})},r}(xe),Le="function"==typeof Math.imul&&Math.imul(4294967295,2)===-2?Math.imul:function(t,r){t|=0,r|=0;var e=65535&t,n=65535&r;return e*n+((t>>>16)*n+e*(r>>>16)<<16>>>0)|0},Be=Object.isExtensible,We=function(){try{return Object.defineProperty({},"@",{}),!0 }catch(t){return!1}}(),Ne="function"==typeof WeakMap;Ne&&(Ke=new WeakMap);var Pe=0,Je="__immutablehash__";"function"==typeof Symbol&&(Je=Symbol(Je));var He=16,Ve=255,Ye=0,Qe={},Xe=function(t){function r(t,r){this._iter=t,this._useKeys=r,this.size=t.size}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.prototype.get=function(t,r){return this._iter.get(t,r)},r.prototype.has=function(t){return this._iter.has(t)},r.prototype.valueSeq=function(){return this._iter.valueSeq()},r.prototype.reverse=function(){var t=this,r=N(this,!0);return this._useKeys||(r.valueSeq=function(){return t._iter.toSeq().reverse()}),r},r.prototype.map=function(t,r){var e=this,n=W(this,t,r);return this._useKeys||(n.valueSeq=function(){return e._iter.toSeq().map(t,r)}),n},r.prototype.__iterate=function(t,r){var e=this;return this._iter.__iterate(function(r,n){return t(r,n,e)},r)},r.prototype.__iterator=function(t,r){return this._iter.__iterator(t,r)},r}(De);Xe.prototype[le]=!0;var Fe=function(t){function r(t){this._iter=t,this.size=t.size}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.prototype.includes=function(t){return this._iter.includes(t)},r.prototype.__iterate=function(t,r){var e=this,n=0;return r&&i(this),this._iter.__iterate(function(i){return t(i,r?e.size-++n:n++,e)},r)},r.prototype.__iterator=function(t,r){var e=this,n=this._iter.__iterator(ze,r),o=0;return r&&i(this),new Ee(function(){var i=n.next();return i.done?i:w(t,r?e.size-++o:o++,i.value,i)})},r}(xe),Ge=function(t){function r(t){this._iter=t,this.size=t.size}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.prototype.has=function(t){return this._iter.includes(t)},r.prototype.__iterate=function(t,r){var e=this;return this._iter.__iterate(function(r){return t(r,r,e)},r)},r.prototype.__iterator=function(t,r){var e=this._iter.__iterator(ze,r);return new Ee(function(){var r=e.next();return r.done?r:w(t,r.value,r.value,r)})},r -}(Ae),Ze=function(t){function r(t){this._iter=t,this.size=t.size}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.prototype.entrySeq=function(){return this._iter.toSeq()},r.prototype.__iterate=function(t,r){var e=this;return this._iter.__iterate(function(r){if(r){it(r);var n=_(r);return t(n?r.get(1):r[1],n?r.get(0):r[0],e)}},r)},r.prototype.__iterator=function(t,r){var e=this._iter.__iterator(ze,r);return new Ee(function(){for(;;){var r=e.next();if(r.done)return r;var n=r.value;if(n){it(n);var i=_(n);return w(t,i?n.get(0):n[0],i?n.get(1):n[1],r)}}})},r}(De);Fe.prototype.cacheResult=Xe.prototype.cacheResult=Ge.prototype.cacheResult=Ze.prototype.cacheResult=st;var $e=function(t){function r(r){return null===r||void 0===r?Zt():Qt(r)&&!d(r)?r:Zt().withMutations(function(e){var n=t(r);ht(n.size),n.forEach(function(t,r){return e.set(r,t)})})}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.of=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return Zt().withMutations(function(r){for(var e=0;e=t.length)throw Error("Missing value for key: "+t[e]);r.set(t[e],t[e+1])}})},r.prototype.toString=function(){return this.__toString("Map {","}")},r.prototype.get=function(t,r){return this._root?this._root.get(0,void 0,t,r):r},r.prototype.set=function(t,r){return $t(this,t,r)},r.prototype.remove=function(t){return $t(this,t,ae)},r.prototype.deleteAll=function(t){var r=ye(t);return 0===r.size?this:this.withMutations(function(t){r.forEach(function(r){return t.remove(r)})})},r.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):Zt()},r.prototype.sort=function(t){return mn($(this,t))},r.prototype.sortBy=function(t,r){return mn($(this,r,t))},r.prototype.__iterator=function(t,r){return new cn(this,t,r)},r.prototype.__iterate=function(t,r){var e=this,n=0;return this._root&&this._root.iterate(function(r){return n++, -t(r[1],r[0],e)},r),n},r.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Gt(this.size,this._root,t,this.__hash):0===this.size?Zt():(this.__ownerID=t,this.__altered=!1,this)},r}(de);$e.isMap=Qt;var tn="@@__IMMUTABLE_MAP__@@",rn=$e.prototype;rn[tn]=!0,rn.delete=rn.remove,rn.removeAll=rn.deleteAll,rn.setIn=bt,rn.removeIn=rn.deleteIn=Et,rn.update=Mt,rn.updateIn=Dt,rn.merge=rn.concat=xt,rn.mergeWith=At,rn.mergeDeep=Bt,rn.mergeDeepWith=Wt,rn.mergeIn=Nt,rn.mergeDeepIn=Pt,rn.withMutations=Jt,rn.wasAltered=Yt,rn.asImmutable=Vt,rn["@@transducer/init"]=rn.asMutable=Ht,rn["@@transducer/step"]=function(t,r){return t.set(r[0],r[1])},rn["@@transducer/result"]=function(t){return t.asImmutable()};var en=function(t,r){this.ownerID=t,this.entries=r};en.prototype.get=function(t,r,e,n){for(var i=this.entries,o=0,u=i.length;o=fn)return nr(t,c,i,o);var _=t&&t===this.ownerID,l=_?c:ct(c);return p?a?f===h-1?l.pop():l[f]=l.pop():l[f]=[i,o]:l.push([i,o]),_?(this.entries=l,this):new en(t,l)}};var nn=function(t,r,e){this.ownerID=t,this.bitmap=r,this.nodes=e};nn.prototype.get=function(t,r,e,n){void 0===r&&(r=U(e));var i=1<<((0===t?r:r>>>t)&se),o=this.bitmap;return 0==(o&i)?n:this.nodes[ur(o&i-1)].get(t+oe,r,e,n)},nn.prototype.update=function(t,r,e,n,i,o,u){void 0===e&&(e=U(n));var s=(0===r?e:e>>>r)&se,a=1<=hn)return or(t,p,c,s,l);if(f&&!l&&2===p.length&&rr(p[1^h]))return p[1^h];if(f&&l&&1===p.length&&rr(l))return l;var v=t&&t===this.ownerID,y=f?l?c:c^a:c|a,d=f?l?sr(p,h,l,v):cr(p,h,v):ar(p,h,l,v);return v?(this.bitmap=y,this.nodes=d,this):new nn(t,y,d)};var on=function(t,r,e){this.ownerID=t,this.count=r, -this.nodes=e};on.prototype.get=function(t,r,e,n){void 0===r&&(r=U(e));var i=(0===t?r:r>>>t)&se,o=this.nodes[i];return o?o.get(t+oe,r,e,n):n},on.prototype.update=function(t,r,e,n,i,o,u){void 0===e&&(e=U(n));var s=(0===r?e:e>>>r)&se,a=i===ae,c=this.nodes,f=c[s];if(a&&!f)return this;var h=tr(f,t,r+oe,e,n,i,o,u);if(h===f)return this;var p=this.count;if(f){if(!h&&--p0&&i=0&&t>>r&se;if(n>=this.array.length)return new yn([],t);var i,o=0===n;if(r>0){var u=this.array[n];if((i=u&&u.removeBefore(t,r-oe,e))===u&&o)return this}if(o&&!i)return this;var s=yr(this,t);if(!o)for(var a=0;a>>r&se;if(n>=this.array.length)return this;var i;if(r>0){var o=this.array[n];if((i=o&&o.removeAfter(t,r-oe,e))===o&&n===this.array.length-1)return this}var u=yr(this,t);return u.array.splice(n+1), -i&&(u.array[n]=i),u};var dn,gn={},mn=function(t){function r(t){return null===t||void 0===t?Sr():wr(t)?t:Sr().withMutations(function(r){var e=de(t);ht(e.size),e.forEach(function(t,e){return r.set(e,t)})})}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.of=function(){return this(arguments)},r.prototype.toString=function(){return this.__toString("OrderedMap {","}")},r.prototype.get=function(t,r){var e=this._map.get(t);return void 0!==e?this._list.get(e)[1]:r},r.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._map.clear(),this._list.clear(),this):Sr()},r.prototype.set=function(t,r){return Ir(this,t,r)},r.prototype.remove=function(t){return Ir(this,t,ae)},r.prototype.wasAltered=function(){return this._map.wasAltered()||this._list.wasAltered()},r.prototype.__iterate=function(t,r){var e=this;return this._list.__iterate(function(r){return r&&t(r[1],r[0],e)},r)},r.prototype.__iterator=function(t,r){return this._list.fromEntrySeq().__iterator(t,r)},r.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var r=this._map.__ensureOwner(t),e=this._list.__ensureOwner(t);return t?zr(r,e,t,this.__hash):0===this.size?Sr():(this.__ownerID=t,this._map=r,this._list=e,this)},r}($e);mn.isOrderedMap=wr,mn.prototype[le]=!0,mn.prototype.delete=mn.prototype.remove;var wn,zn=function(t){function r(t){return null===t||void 0===t?Er():br(t)?t:Er().pushAll(t)}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.of=function(){return this(arguments)},r.prototype.toString=function(){return this.__toString("Stack [","]")},r.prototype.get=function(t,r){var e=this._head;for(t=o(this,t);e&&t--;)e=e.next;return e?e.value:r},r.prototype.peek=function(){return this._head&&this._head.value},r.prototype.push=function(){var t=arguments;if(0===arguments.length)return this;for(var r=this.size+arguments.length,e=this._head,n=arguments.length-1;n>=0;n--)e={value:t[n],next:e};return this.__ownerID?(this.size=r, -this._head=e,this.__hash=void 0,this.__altered=!0,this):Or(r,e)},r.prototype.pushAll=function(r){if(r=t(r),0===r.size)return this;if(0===this.size&&br(r))return r;ht(r.size);var e=this.size,n=this._head;return r.__iterate(function(t){e++,n={value:t,next:n}},!0),this.__ownerID?(this.size=e,this._head=n,this.__hash=void 0,this.__altered=!0,this):Or(e,n)},r.prototype.pop=function(){return this.slice(1)},r.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):Er()},r.prototype.slice=function(r,e){if(s(r,e,this.size))return this;var n=a(r,this.size);if(c(e,this.size)!==this.size)return t.prototype.slice.call(this,r,e);for(var i=this.size-n,o=this._head;n--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):Or(i,o)},r.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Or(this.size,this._head,t,this.__hash):0===this.size?Er():(this.__ownerID=t,this.__altered=!1,this)},r.prototype.__iterate=function(t,r){var e=this;if(r)return new ke(this.toArray()).__iterate(function(r,n){return t(r,n,e)},r);for(var n=0,i=this._head;i&&t(i.value,n++,e)!==!1;)i=i.next;return n},r.prototype.__iterator=function(t,r){if(r)return new ke(this.toArray()).__iterator(t,r);var e=0,n=this._head;return new Ee(function(){if(n){var r=n.value;return n=n.next,w(t,e++,r)}return z()})},r}(ge);zn.isStack=br;var Sn="@@__IMMUTABLE_STACK__@@",In=zn.prototype;In[Sn]=!0,In.shift=In.pop,In.unshift=In.push,In.unshiftAll=In.pushAll,In.withMutations=Jt,In.wasAltered=Yt,In.asImmutable=Vt,In["@@transducer/init"]=In.asMutable=Ht,In["@@transducer/step"]=function(t,r){return t.unshift(r)},In["@@transducer/result"]=function(t){return t.asImmutable()};var bn,On=function(t){function r(r){return null===r||void 0===r?kr():xr(r)&&!d(r)?r:kr().withMutations(function(e){var n=t(r);ht(n.size),n.forEach(function(t){return e.add(t)})})}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype), -r.prototype.constructor=r,r.of=function(){return this(arguments)},r.fromKeys=function(t){return this(de(t).keySeq())},r.intersect=function(t){return t=ye(t).toArray(),t.length?qn.intersect.apply(r(t.pop()),t):kr()},r.union=function(t){return t=ye(t).toArray(),t.length?qn.union.apply(r(t.pop()),t):kr()},r.prototype.toString=function(){return this.__toString("Set {","}")},r.prototype.has=function(t){return this._map.has(t)},r.prototype.add=function(t){return Ar(this,this._map.set(t,t))},r.prototype.remove=function(t){return Ar(this,this._map.remove(t))},r.prototype.clear=function(){return Ar(this,this._map.clear())},r.prototype.union=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];return r=r.filter(function(t){return 0!==t.size}),0===r.length?this:0!==this.size||this.__ownerID||1!==r.length?this.withMutations(function(e){for(var n=0;n=0&&r=0&&ethis.size?r:this.find(function(r,e){return e===t},void 0,r)},has:function(t){return(t=o(this,t))>=0&&(void 0!==this.size?this.size===1/0||t=t.length)throw Error("Missing value for key: "+t[e]);r.set(t[e],t[e+1])}})},r.prototype.toString=function(){return this.__toString("Map {","}")},r.prototype.get=function(t,r){return this._root?this._root.get(0,void 0,t,r):r},r.prototype.set=function(t,r){return $t(this,t,r)},r.prototype.remove=function(t){return $t(this,t,ae)},r.prototype.deleteAll=function(t){var r=ye(t);return 0===r.size?this:this.withMutations(function(t){r.forEach(function(r){return t.remove(r)})})},r.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):Zt()},r.prototype.sort=function(t){return mn($(this,t))},r.prototype.sortBy=function(t,r){return mn($(this,r,t))},r.prototype.map=function(t,r){return this.withMutations(function(e){e.forEach(function(n,i){e.set(i,t.call(r,n,i,e))})})},r.prototype.__iterator=function(t,r){return new cn(this,t,r) +},r.prototype.__iterate=function(t,r){var e=this,n=0;return this._root&&this._root.iterate(function(r){return n++,t(r[1],r[0],e)},r),n},r.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Gt(this.size,this._root,t,this.__hash):0===this.size?Zt():(this.__ownerID=t,this.__altered=!1,this)},r}(de);$e.isMap=Qt;var tn="@@__IMMUTABLE_MAP__@@",rn=$e.prototype;rn[tn]=!0,rn.delete=rn.remove,rn.removeAll=rn.deleteAll,rn.setIn=bt,rn.removeIn=rn.deleteIn=Et,rn.update=Mt,rn.updateIn=Dt,rn.merge=rn.concat=xt,rn.mergeWith=At,rn.mergeDeep=Bt,rn.mergeDeepWith=Wt,rn.mergeIn=Nt,rn.mergeDeepIn=Pt,rn.withMutations=Jt,rn.wasAltered=Yt,rn.asImmutable=Vt,rn["@@transducer/init"]=rn.asMutable=Ht,rn["@@transducer/step"]=function(t,r){return t.set(r[0],r[1])},rn["@@transducer/result"]=function(t){return t.asImmutable()};var en=function(t,r){this.ownerID=t,this.entries=r};en.prototype.get=function(t,r,e,n){for(var i=this.entries,o=0,u=i.length;o=fn)return nr(t,c,i,o);var _=t&&t===this.ownerID,l=_?c:ct(c);return p?a?f===h-1?l.pop():l[f]=l.pop():l[f]=[i,o]:l.push([i,o]),_?(this.entries=l,this):new en(t,l)}};var nn=function(t,r,e){this.ownerID=t,this.bitmap=r,this.nodes=e};nn.prototype.get=function(t,r,e,n){void 0===r&&(r=U(e));var i=1<<((0===t?r:r>>>t)&se),o=this.bitmap;return 0==(o&i)?n:this.nodes[ur(o&i-1)].get(t+oe,r,e,n)},nn.prototype.update=function(t,r,e,n,i,o,u){void 0===e&&(e=U(n));var s=(0===r?e:e>>>r)&se,a=1<=hn)return or(t,p,c,s,l);if(f&&!l&&2===p.length&&rr(p[1^h]))return p[1^h];if(f&&l&&1===p.length&&rr(l))return l +;var v=t&&t===this.ownerID,y=f?l?c:c^a:c|a,d=f?l?sr(p,h,l,v):cr(p,h,v):ar(p,h,l,v);return v?(this.bitmap=y,this.nodes=d,this):new nn(t,y,d)};var on=function(t,r,e){this.ownerID=t,this.count=r,this.nodes=e};on.prototype.get=function(t,r,e,n){void 0===r&&(r=U(e));var i=(0===t?r:r>>>t)&se,o=this.nodes[i];return o?o.get(t+oe,r,e,n):n},on.prototype.update=function(t,r,e,n,i,o,u){void 0===e&&(e=U(n));var s=(0===r?e:e>>>r)&se,a=i===ae,c=this.nodes,f=c[s];if(a&&!f)return this;var h=tr(f,t,r+oe,e,n,i,o,u);if(h===f)return this;var p=this.count;if(f){if(!h&&--p0&&i=0&&t>>r&se;if(n>=this.array.length)return new yn([],t);var i,o=0===n;if(r>0){var u=this.array[n];if((i=u&&u.removeBefore(t,r-oe,e))===u&&o)return this}if(o&&!i)return this;var s=yr(this,t);if(!o)for(var a=0;a>>r&se;if(n>=this.array.length)return this;var i;if(r>0){var o=this.array[n];if((i=o&&o.removeAfter(t,r-oe,e))===o&&n===this.array.length-1)return this}var u=yr(this,t);return u.array.splice(n+1),i&&(u.array[n]=i),u};var dn,gn={},mn=function(t){function r(t){return null===t||void 0===t?Sr():wr(t)?t:Sr().withMutations(function(r){var e=de(t);ht(e.size),e.forEach(function(t,e){return r.set(e,t)})})}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.of=function(){return this(arguments)},r.prototype.toString=function(){return this.__toString("OrderedMap {","}")},r.prototype.get=function(t,r){var e=this._map.get(t);return void 0!==e?this._list.get(e)[1]:r},r.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._map.clear(),this._list.clear(),this):Sr()},r.prototype.set=function(t,r){return Ir(this,t,r)},r.prototype.remove=function(t){return Ir(this,t,ae)},r.prototype.wasAltered=function(){return this._map.wasAltered()||this._list.wasAltered()},r.prototype.__iterate=function(t,r){var e=this;return this._list.__iterate(function(r){return r&&t(r[1],r[0],e)},r)},r.prototype.__iterator=function(t,r){return this._list.fromEntrySeq().__iterator(t,r)},r.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var r=this._map.__ensureOwner(t),e=this._list.__ensureOwner(t);return t?zr(r,e,t,this.__hash):0===this.size?Sr():(this.__ownerID=t,this._map=r,this._list=e,this)},r}($e);mn.isOrderedMap=wr,mn.prototype[le]=!0,mn.prototype.delete=mn.prototype.remove;var wn,zn=function(t){function r(t){return null===t||void 0===t?Er():br(t)?t:Er().pushAll(t)}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.of=function(){return this(arguments)},r.prototype.toString=function(){return this.__toString("Stack [","]")},r.prototype.get=function(t,r){var e=this._head;for(t=o(this,t);e&&t--;)e=e.next +;return e?e.value:r},r.prototype.peek=function(){return this._head&&this._head.value},r.prototype.push=function(){var t=arguments;if(0===arguments.length)return this;for(var r=this.size+arguments.length,e=this._head,n=arguments.length-1;n>=0;n--)e={value:t[n],next:e};return this.__ownerID?(this.size=r,this._head=e,this.__hash=void 0,this.__altered=!0,this):Or(r,e)},r.prototype.pushAll=function(r){if(r=t(r),0===r.size)return this;if(0===this.size&&br(r))return r;ht(r.size);var e=this.size,n=this._head;return r.__iterate(function(t){e++,n={value:t,next:n}},!0),this.__ownerID?(this.size=e,this._head=n,this.__hash=void 0,this.__altered=!0,this):Or(e,n)},r.prototype.pop=function(){return this.slice(1)},r.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):Er()},r.prototype.slice=function(r,e){if(s(r,e,this.size))return this;var n=a(r,this.size);if(c(e,this.size)!==this.size)return t.prototype.slice.call(this,r,e);for(var i=this.size-n,o=this._head;n--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):Or(i,o)},r.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Or(this.size,this._head,t,this.__hash):0===this.size?Er():(this.__ownerID=t,this.__altered=!1,this)},r.prototype.__iterate=function(t,r){var e=this;if(r)return new ke(this.toArray()).__iterate(function(r,n){return t(r,n,e)},r);for(var n=0,i=this._head;i&&t(i.value,n++,e)!==!1;)i=i.next;return n},r.prototype.__iterator=function(t,r){if(r)return new ke(this.toArray()).__iterator(t,r);var e=0,n=this._head;return new Ee(function(){if(n){var r=n.value;return n=n.next,w(t,e++,r)}return z()})},r}(ge);zn.isStack=br;var Sn="@@__IMMUTABLE_STACK__@@",In=zn.prototype;In[Sn]=!0,In.shift=In.pop,In.unshift=In.push,In.unshiftAll=In.pushAll,In.withMutations=Jt,In.wasAltered=Yt,In.asImmutable=Vt,In["@@transducer/init"]=In.asMutable=Ht,In["@@transducer/step"]=function(t,r){return t.unshift(r)}, +In["@@transducer/result"]=function(t){return t.asImmutable()};var bn,On=function(t){function r(r){return null===r||void 0===r?kr():xr(r)&&!d(r)?r:kr().withMutations(function(e){var n=t(r);ht(n.size),n.forEach(function(t){return e.add(t)})})}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.of=function(){return this(arguments)},r.fromKeys=function(t){return this(de(t).keySeq())},r.intersect=function(t){return t=ye(t).toArray(),t.length?qn.intersect.apply(r(t.pop()),t):kr()},r.union=function(t){return t=ye(t).toArray(),t.length?qn.union.apply(r(t.pop()),t):kr()},r.prototype.toString=function(){return this.__toString("Set {","}")},r.prototype.has=function(t){return this._map.has(t)},r.prototype.add=function(t){return Ar(this,this._map.set(t,t))},r.prototype.remove=function(t){return Ar(this,this._map.remove(t))},r.prototype.clear=function(){return Ar(this,this._map.clear())},r.prototype.union=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];return r=r.filter(function(t){return 0!==t.size}),0===r.length?this:0!==this.size||this.__ownerID||1!==r.length?this.withMutations(function(e){for(var n=0;n=0&&r=0&&ethis.size?r:this.find(function(r,e){return e===t},void 0,r)},has:function(t){return(t=o(this,t))>=0&&(void 0!==this.size?this.size===1/0||t Date: Thu, 17 May 2018 15:01:09 +0000 Subject: [PATCH 105/242] Deploy 5726bd18de1cc527d1635a45421c278e47f8f9a9 to NPM branch --- dist/immutable-nonambient.d.ts | 6 ------ dist/immutable.d.ts | 6 ------ dist/immutable.es.js | 6 ++++++ dist/immutable.js | 6 ++++++ dist/immutable.min.js | 18 +++++++++--------- 5 files changed, 21 insertions(+), 21 deletions(-) diff --git a/dist/immutable-nonambient.d.ts b/dist/immutable-nonambient.d.ts index c061bce027..8872fe1237 100644 --- a/dist/immutable-nonambient.d.ts +++ b/dist/immutable-nonambient.d.ts @@ -1714,9 +1714,6 @@ * * Set([1,2]).map(x => 10 * x) * // Set [10,20] - * - * Note: `map()` always returns a new instance, even if it produced the same - * value at every step. */ map( mapper: (value: T, key: T, iter: this) => M, @@ -1816,9 +1813,6 @@ * * OrderedSet([ 1, 2 ]).map(x => 10 * x) * // OrderedSet [10, 20] - * - * Note: `map()` always returns a new instance, even if it produced the same - * value at every step. */ map( mapper: (value: T, key: T, iter: this) => M, diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index c273a526ed..a330bf4336 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -1714,9 +1714,6 @@ declare module Immutable { * * Set([1,2]).map(x => 10 * x) * // Set [10,20] - * - * Note: `map()` always returns a new instance, even if it produced the same - * value at every step. */ map( mapper: (value: T, key: T, iter: this) => M, @@ -1816,9 +1813,6 @@ declare module Immutable { * * OrderedSet([ 1, 2 ]).map(x => 10 * x) * // OrderedSet [10, 20] - * - * Note: `map()` always returns a new instance, even if it produced the same - * value at every step. */ map( mapper: (value: T, key: T, iter: this) => M, diff --git a/dist/immutable.es.js b/dist/immutable.es.js index 423e746aa5..c231d59ae2 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -4284,6 +4284,12 @@ var Set = (function (SetCollection$$1) { // @pragma Composition + Set.prototype.map = function map (mapper, context) { + var this$1 = this; + + return updateSet(this, this._map.map(function (v) { return mapper(v, v, this$1); }, context)); + }; + Set.prototype.union = function union () { var iters = [], len = arguments.length; while ( len-- ) iters[ len ] = arguments[ len ]; diff --git a/dist/immutable.js b/dist/immutable.js index a498074d7d..f885aaf935 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -4290,6 +4290,12 @@ var Set = (function (SetCollection$$1) { // @pragma Composition + Set.prototype.map = function map (mapper, context) { + var this$1 = this; + + return updateSet(this, this._map.map(function (v) { return mapper(v, v, this$1); }, context)); + }; + Set.prototype.union = function union () { var iters = [], len = arguments.length; while ( len-- ) iters[ len ] = arguments[ len ]; diff --git a/dist/immutable.min.js b/dist/immutable.min.js index 6a27aefe43..9f712334f8 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -27,12 +27,12 @@ sn.prototype.iterate=function(t,r){return t(this.entry)};var an,cn=function(t){f ;for(var e=0;e>>r&se;if(n>=this.array.length)return new yn([],t);var i,o=0===n;if(r>0){var u=this.array[n];if((i=u&&u.removeBefore(t,r-oe,e))===u&&o)return this}if(o&&!i)return this;var s=yr(this,t);if(!o)for(var a=0;a>>r&se;if(n>=this.array.length)return this;var i;if(r>0){var o=this.array[n];if((i=o&&o.removeAfter(t,r-oe,e))===o&&n===this.array.length-1)return this}var u=yr(this,t);return u.array.splice(n+1),i&&(u.array[n]=i),u};var dn,gn={},mn=function(t){function r(t){return null===t||void 0===t?Sr():wr(t)?t:Sr().withMutations(function(r){var e=de(t);ht(e.size),e.forEach(function(t,e){return r.set(e,t)})})}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.of=function(){return this(arguments)},r.prototype.toString=function(){return this.__toString("OrderedMap {","}")},r.prototype.get=function(t,r){var e=this._map.get(t);return void 0!==e?this._list.get(e)[1]:r},r.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._map.clear(),this._list.clear(),this):Sr()},r.prototype.set=function(t,r){return Ir(this,t,r)},r.prototype.remove=function(t){return Ir(this,t,ae)},r.prototype.wasAltered=function(){return this._map.wasAltered()||this._list.wasAltered()},r.prototype.__iterate=function(t,r){var e=this;return this._list.__iterate(function(r){return r&&t(r[1],r[0],e)},r)},r.prototype.__iterator=function(t,r){return this._list.fromEntrySeq().__iterator(t,r)},r.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var r=this._map.__ensureOwner(t),e=this._list.__ensureOwner(t);return t?zr(r,e,t,this.__hash):0===this.size?Sr():(this.__ownerID=t,this._map=r,this._list=e,this)},r}($e);mn.isOrderedMap=wr,mn.prototype[le]=!0,mn.prototype.delete=mn.prototype.remove;var wn,zn=function(t){function r(t){return null===t||void 0===t?Er():br(t)?t:Er().pushAll(t)}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.of=function(){return this(arguments)},r.prototype.toString=function(){return this.__toString("Stack [","]")},r.prototype.get=function(t,r){var e=this._head;for(t=o(this,t);e&&t--;)e=e.next ;return e?e.value:r},r.prototype.peek=function(){return this._head&&this._head.value},r.prototype.push=function(){var t=arguments;if(0===arguments.length)return this;for(var r=this.size+arguments.length,e=this._head,n=arguments.length-1;n>=0;n--)e={value:t[n],next:e};return this.__ownerID?(this.size=r,this._head=e,this.__hash=void 0,this.__altered=!0,this):Or(r,e)},r.prototype.pushAll=function(r){if(r=t(r),0===r.size)return this;if(0===this.size&&br(r))return r;ht(r.size);var e=this.size,n=this._head;return r.__iterate(function(t){e++,n={value:t,next:n}},!0),this.__ownerID?(this.size=e,this._head=n,this.__hash=void 0,this.__altered=!0,this):Or(e,n)},r.prototype.pop=function(){return this.slice(1)},r.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):Er()},r.prototype.slice=function(r,e){if(s(r,e,this.size))return this;var n=a(r,this.size);if(c(e,this.size)!==this.size)return t.prototype.slice.call(this,r,e);for(var i=this.size-n,o=this._head;n--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):Or(i,o)},r.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Or(this.size,this._head,t,this.__hash):0===this.size?Er():(this.__ownerID=t,this.__altered=!1,this)},r.prototype.__iterate=function(t,r){var e=this;if(r)return new ke(this.toArray()).__iterate(function(r,n){return t(r,n,e)},r);for(var n=0,i=this._head;i&&t(i.value,n++,e)!==!1;)i=i.next;return n},r.prototype.__iterator=function(t,r){if(r)return new ke(this.toArray()).__iterator(t,r);var e=0,n=this._head;return new Ee(function(){if(n){var r=n.value;return n=n.next,w(t,e++,r)}return z()})},r}(ge);zn.isStack=br;var Sn="@@__IMMUTABLE_STACK__@@",In=zn.prototype;In[Sn]=!0,In.shift=In.pop,In.unshift=In.push,In.unshiftAll=In.pushAll,In.withMutations=Jt,In.wasAltered=Yt,In.asImmutable=Vt,In["@@transducer/init"]=In.asMutable=Ht,In["@@transducer/step"]=function(t,r){return t.unshift(r)}, -In["@@transducer/result"]=function(t){return t.asImmutable()};var bn,On=function(t){function r(r){return null===r||void 0===r?kr():xr(r)&&!d(r)?r:kr().withMutations(function(e){var n=t(r);ht(n.size),n.forEach(function(t){return e.add(t)})})}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.of=function(){return this(arguments)},r.fromKeys=function(t){return this(de(t).keySeq())},r.intersect=function(t){return t=ye(t).toArray(),t.length?qn.intersect.apply(r(t.pop()),t):kr()},r.union=function(t){return t=ye(t).toArray(),t.length?qn.union.apply(r(t.pop()),t):kr()},r.prototype.toString=function(){return this.__toString("Set {","}")},r.prototype.has=function(t){return this._map.has(t)},r.prototype.add=function(t){return Ar(this,this._map.set(t,t))},r.prototype.remove=function(t){return Ar(this,this._map.remove(t))},r.prototype.clear=function(){return Ar(this,this._map.clear())},r.prototype.union=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];return r=r.filter(function(t){return 0!==t.size}),0===r.length?this:0!==this.size||this.__ownerID||1!==r.length?this.withMutations(function(e){for(var n=0;n=0&&r=0&&ethis.size?r:this.find(function(r,e){return e===t},void 0,r)},has:function(t){return(t=o(this,t))>=0&&(void 0!==this.size?this.size===1/0||t=0&&r=0&&ethis.size?r:this.find(function(r,e){return e===t},void 0,r)},has:function(t){return(t=o(this,t))>=0&&(void 0!==this.size?this.size===1/0||t Date: Thu, 17 May 2018 15:01:21 +0000 Subject: [PATCH 106/242] Deploy b29b484669a6a263455e70f58008f30f9ecc4dd9 to NPM branch --- dist/immutable.es.js | 17 +++++++++++- dist/immutable.js | 17 +++++++++++- dist/immutable.min.js | 64 +++++++++++++++++++++---------------------- 3 files changed, 64 insertions(+), 34 deletions(-) diff --git a/dist/immutable.es.js b/dist/immutable.es.js index c231d59ae2..6c86fb3e94 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -254,7 +254,22 @@ function getIteratorFn(iterable) { var hasOwnProperty = Object.prototype.hasOwnProperty; function isArrayLike(value) { - return value && typeof value.length === 'number'; + if (Array.isArray(value) || typeof value === 'string') { + return true; + } + + return ( + value && + typeof value === 'object' && + Number.isInteger(value.length) && + value.length >= 0 && + (value.length === 0 + ? // Only {length: 0} is considered Array-like. + Object.keys(value).length === 1 + : // An object is only Array-like if it has a property where the last value + // in the array-like may be found (which could be undefined). + value.hasOwnProperty(value.length - 1)) + ); } var Seq = (function (Collection$$1) { diff --git a/dist/immutable.js b/dist/immutable.js index f885aaf935..06a1b14031 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -260,7 +260,22 @@ function getIteratorFn(iterable) { var hasOwnProperty = Object.prototype.hasOwnProperty; function isArrayLike(value) { - return value && typeof value.length === 'number'; + if (Array.isArray(value) || typeof value === 'string') { + return true; + } + + return ( + value && + typeof value === 'object' && + Number.isInteger(value.length) && + value.length >= 0 && + (value.length === 0 + ? // Only {length: 0} is considered Array-like. + Object.keys(value).length === 1 + : // An object is only Array-like if it has a property where the last value + // in the array-like may be found (which could be undefined). + value.hasOwnProperty(value.length - 1)) + ); } var Seq = (function (Collection$$1) { diff --git a/dist/immutable.min.js b/dist/immutable.min.js index 9f712334f8..b2d18965cf 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -4,35 +4,35 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ -!function(t,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r(t.Immutable={})}(this,function(t){"use strict";function r(t){return t.value=!1,t}function e(t){t&&(t.value=!0)}function n(){}function i(t){return void 0===t.size&&(t.size=t.__iterate(u)),t.size}function o(t,r){if("number"!=typeof r){var e=r>>>0;if(""+e!==r||4294967295===e)return NaN;r=e}return r<0?i(t)+r:r}function u(){return!0}function s(t,r,e){return(0===t&&!h(t)||void 0!==e&&t<=-e)&&(void 0===r||void 0!==e&&r>=e)}function a(t,r){return f(t,r,0)}function c(t,r){return f(t,r,r)}function f(t,r,e){return void 0===t?e:h(t)?r===1/0?r:0|Math.max(0,r+t):void 0===r||r===t?t:0|Math.min(r,t)}function h(t){return t<0||0===t&&1/t==-(1/0)}function p(t){return _(t)||g(t)}function _(t){return!(!t||!t[he])}function l(t){return!(!t||!t[pe])}function v(t){return!(!t||!t[_e])}function y(t){return l(t)||v(t)}function d(t){return!(!t||!t[le])}function g(t){return!(!t||!t[ve])}function m(t){return!(!t||"function"!=typeof t.equals||"function"!=typeof t.hashCode)}function w(t,r,e,n){var i=0===t?r:1===t?e:[r,e];return n?n.value=i:n={value:i,done:!1},n}function z(){return{value:void 0,done:!0}}function S(t){return!!O(t)}function I(t){return t&&"function"==typeof t.next}function b(t){var r=O(t);return r&&r.call(t)}function O(t){var r=t&&(Ie&&t[Ie]||t[be]);if("function"==typeof r)return r}function E(t){return t&&"number"==typeof t.length}function q(t){return!(!t||!t[je])}function M(){return Ue||(Ue=new ke([]))}function D(t){var r=Array.isArray(t)?new ke(t):I(t)?new Ce(t):S(t)?new Te(t):void 0;if(r)return r.fromEntrySeq();if("object"==typeof t)return new Re(t);throw new TypeError("Expected Array or collection object of [k, v] entries, or keyed object: "+t)}function x(t){var r=j(t);if(r)return r;throw new TypeError("Expected Array or collection object of values: "+t)}function A(t){var r=j(t);if(r)return r;if("object"==typeof t)return new Re(t) -;throw new TypeError("Expected Array or collection object of values, or keyed object: "+t)}function j(t){return E(t)?new ke(t):I(t)?new Ce(t):S(t)?new Te(t):void 0}function k(t,r){if(t===r||t!==t&&r!==r)return!0;if(!t||!r)return!1;if("function"==typeof t.valueOf&&"function"==typeof r.valueOf){if(t=t.valueOf(),r=r.valueOf(),t===r||t!==t&&r!==r)return!0;if(!t||!r)return!1}return!!(m(t)&&m(r)&&t.equals(r))}function R(t){return t>>>1&1073741824|3221225471&t}function U(t){if(t===!1||null===t||void 0===t)return 0;if("function"==typeof t.valueOf&&((t=t.valueOf())===!1||null===t||void 0===t))return 0;if(t===!0)return 1;var r=typeof t;if("number"===r){if(t!==t||t===1/0)return 0;var e=0|t;for(e!==t&&(e^=4294967295*t);t>4294967295;)t/=4294967295,e^=t;return R(e)}if("string"===r)return t.length>He?K(t):T(t);if("function"==typeof t.hashCode)return R(t.hashCode());if("object"===r||"function"===r)return C(t);if("function"==typeof t.toString)return T(""+t);throw Error("Value type "+r+" cannot be hashed.")}function K(t){var r=Qe[t];return void 0===r&&(r=T(t),Ye===Ve&&(Ye=0,Qe={}),Ye++,Qe[t]=r),r}function T(t){for(var r=0,e=0;e0)switch(t.nodeType){case 1: -return t.uniqueID;case 9:return t.documentElement&&t.documentElement.uniqueID}}function B(t){var r=ut(t);return r._iter=t,r.size=t.size,r.flip=function(){return t},r.reverse=function(){var r=t.reverse.apply(this);return r.flip=function(){return t.reverse()},r},r.has=function(r){return t.includes(r)},r.includes=function(r){return t.has(r)},r.cacheResult=st,r.__iterateUncached=function(r,e){var n=this;return t.__iterate(function(t,e){return r(e,t,n)!==!1},e)},r.__iteratorUncached=function(r,e){if(r===Se){var n=t.__iterator(r,e);return new Ee(function(){var t=n.next();if(!t.done){var r=t.value[0];t.value[0]=t.value[1],t.value[1]=r}return t})}return t.__iterator(r===ze?we:ze,e)},r}function W(t,r,e){var n=ut(t);return n.size=t.size,n.has=function(r){return t.has(r)},n.get=function(n,i){var o=t.get(n,ae);return o===ae?i:r.call(e,o,n,t)},n.__iterateUncached=function(n,i){var o=this;return t.__iterate(function(t,i,u){return n(r.call(e,t,i,u),i,o)!==!1},i)},n.__iteratorUncached=function(n,i){var o=t.__iterator(Se,i);return new Ee(function(){var i=o.next();if(i.done)return i;var u=i.value,s=u[0];return w(n,s,r.call(e,u[1],s,t),i)})},n}function N(t,r){var e=this,n=ut(t);return n._iter=t,n.size=t.size,n.reverse=function(){return t},t.flip&&(n.flip=function(){var r=B(t);return r.reverse=function(){return t.flip()},r}),n.get=function(e,n){return t.get(r?e:-1-e,n)},n.has=function(e){return t.has(r?e:-1-e)},n.includes=function(r){return t.includes(r)},n.cacheResult=st,n.__iterate=function(e,n){var o=this,u=0;return n&&i(t),t.__iterate(function(t,i){return e(t,r?i:n?o.size-++u:u++,o)},!n)},n.__iterator=function(n,o){var u=0;o&&i(t);var s=t.__iterator(Se,!o);return new Ee(function(){var t=s.next();if(t.done)return t;var i=t.value;return w(n,r?i[0]:o?e.size-++u:u++,i[1],t)})},n}function P(t,r,e,n){var i=ut(t);return n&&(i.has=function(n){var i=t.get(n,ae);return i!==ae&&!!r.call(e,i,n,t)},i.get=function(n,i){var o=t.get(n,ae);return o!==ae&&r.call(e,o,n,t)?o:i}),i.__iterateUncached=function(i,o){var u=this,s=0 -;return t.__iterate(function(t,o,a){if(r.call(e,t,o,a))return s++,i(t,n?o:s-1,u)},o),s},i.__iteratorUncached=function(i,o){var u=t.__iterator(Se,o),s=0;return new Ee(function(){for(;;){var o=u.next();if(o.done)return o;var a=o.value,c=a[0],f=a[1];if(r.call(e,f,c,t))return w(i,n?c:s++,f,o)}})},i}function J(t,r,e){var n=$e().asMutable();return t.__iterate(function(i,o){n.update(r.call(e,i,o,t),0,function(t){return t+1})}),n.asImmutable()}function H(t,r,e){var n=l(t),i=(d(t)?mn():$e()).asMutable();t.__iterate(function(o,u){i.update(r.call(e,o,u,t),function(t){return t=t||[],t.push(n?[u,o]:o),t})});var o=ot(t);return i.map(function(r){return nt(t,o(r))})}function V(t,r,e,n){var i=t.size;if(s(r,e,i))return t;var u=a(r,i),f=c(e,i);if(u!==u||f!==f)return V(t.toSeq().cacheResult(),r,e,n);var h,p=f-u;p===p&&(h=p<0?0:p);var _=ut(t);return _.size=0===h?h:t.size&&h||void 0,!n&&q(t)&&h>=0&&(_.get=function(r,e){return r=o(this,r),r>=0&&rh)return z();var t=i.next();return n||r===ze||t.done?t:r===we?w(r,s-1,void 0,t):w(r,s-1,t.value[1],t)})},_}function Y(t,r,e){var n=ut(t);return n.__iterateUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterate(n,i);var u=0;return t.__iterate(function(t,i,s){return r.call(e,t,i,s)&&++u&&n(t,i,o)}),u},n.__iteratorUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterator(n,i);var u=t.__iterator(Se,i),s=!0;return new Ee(function(){if(!s)return z();var t=u.next();if(t.done)return t;var i=t.value,a=i[0],c=i[1];return r.call(e,c,a,o)?n===Se?t:w(n,a,c,t):(s=!1,z())})},n}function Q(t,r,e,n){var i=ut(t) -;return i.__iterateUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterate(i,o);var s=!0,a=0;return t.__iterate(function(t,o,c){if(!s||!(s=r.call(e,t,o,c)))return a++,i(t,n?o:a-1,u)}),a},i.__iteratorUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterator(i,o);var s=t.__iterator(Se,o),a=!0,c=0;return new Ee(function(){var t,o,f;do{if(t=s.next(),t.done)return n||i===ze?t:i===we?w(i,c++,void 0,t):w(i,c++,t.value[1],t);var h=t.value;o=h[0],f=h[1],a&&(a=r.call(e,f,o,u))}while(a);return i===Se?t:w(i,o,f,t)})},i}function X(t,r){var e=l(t),n=[t].concat(r).map(function(t){return _(t)?e&&(t=de(t)):t=e?D(t):x(Array.isArray(t)?t:[t]),t}).filter(function(t){return 0!==t.size});if(0===n.length)return t;if(1===n.length){var i=n[0];if(i===t||e&&l(i)||v(t)&&v(i))return i}var o=new ke(n);return e?o=o.toKeyedSeq():v(t)||(o=o.toSetSeq()),o=o.flatten(!0),o.size=n.reduce(function(t,r){if(void 0!==t){var e=r.size;if(void 0!==e)return t+e}},0),o}function F(t,r,e){var n=ut(t);return n.__iterateUncached=function(i,o){function u(t,c){t.__iterate(function(t,o){return(!r||c0}function et(t,r,e,n){var i=ut(t),o=new ke(e).map(function(t){return t.size});return i.size=n?o.max():o.min(),i.__iterate=function(t,r){for(var e,n=this,i=this.__iterator(ze,r),o=0;!(e=i.next()).done&&t(e.value,o++,n)!==!1;);return o},i.__iteratorUncached=function(t,i){var o=e.map(function(t){return t=ye(t),b(i?t.reverse():t)}),u=0,s=!1;return new Ee(function(){var e;return s||(e=o.map(function(t){return t.next()}),s=n?e.every(function(t){return t.done}):e.some(function(t){return t.done})),s?z():w(t,u++,r.apply(null,e.map(function(t){return t.value})))})},i}function nt(t,r){return t===r?t:q(t)?r:t.constructor(r)}function it(t){if(t!==Object(t))throw new TypeError("Expected [K, V] tuple: "+t)}function ot(t){return l(t)?de:v(t)?ge:me}function ut(t){return Object.create((l(t)?De:v(t)?xe:Ae).prototype)}function st(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size,this):Me.prototype.cacheResult.call(this)}function at(t,r){return void 0===t&&void 0===r?0:void 0===t?1:void 0===r?-1:t>r?1:t0;)r[e]=arguments[e+1];return jt(this,r,t)}function jt(t,r,e){for(var n=[],i=0;i0;)r[e]=arguments[e+1];return Ct(t,r)}function Rt(t,r){for(var e=[],n=arguments.length-2;n-- >0;)e[n]=arguments[n+2];return Ct(r,e,t)}function Ut(t){for(var r=[],e=arguments.length-1;e-- >0;)r[e]=arguments[e+1];return Tt(t,r)}function Kt(t,r){for(var e=[],n=arguments.length-2;n-- >0;)e[n]=arguments[n+2];return Tt(r,e,t)}function Tt(t,r,e){return Ct(t,r,Lt(e))}function Ct(t,r,e){if(!lt(t))throw new TypeError("Cannot merge into non-data-structure value: "+t);if(p(t))return t.mergeWith?t.mergeWith.apply(t,[e].concat(r)):t.concat.apply(t,r);for(var n=Array.isArray(t),i=t,o=n?ge:de,u=n?function(r){i===t&&(i=gt(i)),i.push(r)}:function(r,n){var o=qe.call(i,n),u=o&&e?e(i[n],r,n):r;o&&u===i[n]||(i===t&&(i=gt(i)),i[n]=u)},s=0;s0;)r[e]=arguments[e+1];return Tt(this,r,t)}function Nt(t){for(var r=[],e=arguments.length-1;e-- >0;)r[e]=arguments[e+1];return zt(this,t,Zt(),function(t){return Ct(t,r)})}function Pt(t){for(var r=[],e=arguments.length-1;e-- >0;)r[e]=arguments[e+1];return zt(this,t,Zt(),function(t){return Tt(t,r)})}function Jt(t){var r=this.asMutable();return t(r),r.wasAltered()?r.__ensureOwner(this.__ownerID):this}function Ht(){return this.__ownerID?this:this.__ensureOwner(new n)}function Vt(){return this.__ensureOwner()}function Yt(){return this.__altered}function Qt(t){return!(!t||!t[tn])}function Xt(t,r){return w(t,r[0],r[1])}function Ft(t,r){return{node:t,index:0,__prev:r}}function Gt(t,r,e,n){var i=Object.create(rn);return i.size=t,i._root=r, -i.__ownerID=e,i.__hash=n,i.__altered=!1,i}function Zt(){return an||(an=Gt(0))}function $t(t,e,n){var i,o;if(t._root){var u=r(ce),s=r(fe);if(i=tr(t._root,t.__ownerID,0,void 0,e,n,u,s),!s.value)return t;o=t.size+(u.value?n===ae?-1:1:0)}else{if(n===ae)return t;o=1,i=new en(t.__ownerID,[[e,n]])}return t.__ownerID?(t.size=o,t._root=i,t.__hash=void 0,t.__altered=!0,t):i?Gt(o,i):Zt()}function tr(t,r,n,i,o,u,s,a){return t?t.update(r,n,i,o,u,s,a):u===ae?t:(e(a),e(s),new sn(r,i,[o,u]))}function rr(t){return t.constructor===sn||t.constructor===un}function er(t,r,e,n,i){if(t.keyHash===n)return new un(r,n,[t.entry,i]);var o,u=(0===e?t.keyHash:t.keyHash>>>e)&se,s=(0===e?n:n>>>e)&se;return new nn(r,1<>>=1)u[s]=1&e?r[o++]:void 0;return u[n]=i,new on(t,o+1,u)}function ur(t){return t-=t>>1&1431655765,t=(858993459&t)+(t>>2&858993459),t=t+(t>>4)&252645135,t+=t>>8,127&(t+=t>>16)}function sr(t,r,e,n){var i=n?t:ct(t);return i[r]=e,i}function ar(t,r,e,n){var i=t.length+1;if(n&&r+1===i)return t[r]=e,t;for(var o=Array(i),u=0,s=0;so?0:o-e,c=u-e;return c>ue&&(c=ue),function(){if(i===c)return gn;var t=r?--c:i++;return n&&n[t]}}function i(t,n,i){var s,a=t&&t.array,c=i>o?0:o-i>>n,f=1+(u-i>>n);return f>ue&&(f=ue),function(){for(;;){if(s){var t=s();if(t!==gn)return t;s=null}if(c===f)return gn -;var o=r?--f:c++;s=e(a&&a[o],n-oe,i+(o<=t.size||e<0)return t.withMutations(function(t){e<0?gr(t,e).set(0,n):gr(t,0,e+1).set(e,n)});e+=t._origin;var i=t._tail,u=t._root,s=r(fe);return e>=mr(t._capacity)?i=vr(i,t.__ownerID,0,e,n,s):u=vr(u,t.__ownerID,t._level,e,n,s),s.value?t.__ownerID?(t._root=u,t._tail=i,t.__hash=void 0,t.__altered=!0,t):pr(t._origin,t._capacity,t._level,u,i):t}function vr(t,r,n,i,o,u){var s=i>>>n&se,a=t&&s0){var f=t&&t.array[s],h=vr(f,r,n-oe,i,o,u);return h===f?t:(c=yr(t,r),c.array[s]=h,c)}return a&&t.array[s]===o?t:(e(u),c=yr(t,r),void 0===o&&s===c.array.length-1?c.array.pop():c.array[s]=o,c)}function yr(t,r){return r&&t&&r===t.ownerID?t:new yn(t?t.array.slice():[],r)}function dr(t,r){if(r>=mr(t._capacity))return t._tail;if(r<1<0;)e=e.array[r>>>n&se],n-=oe;return e}}function gr(t,r,e){void 0!==r&&(r|=0),void 0!==e&&(e|=0);var i=t.__ownerID||new n,o=t._origin,u=t._capacity,s=o+r,a=void 0===e?u:e<0?u+e:o+e;if(s===o&&a===u)return t;if(s>=a)return t.clear();for(var c=t._level,f=t._root,h=0;s+h<0;)f=new yn(f&&f.array.length?[void 0,f]:[],i),c+=oe,h+=1<=1<p?new yn([],i):l;if(l&&_>p&&soe;d-=oe){var g=p>>>d&se;y=y.array[g]=yr(y.array[g],i)}y.array[p>>>oe&se]=l}if(a=_)s-=_,a-=_,c=oe,f=null,v=v&&v.removeBefore(i,0,s);else if(s>o||_>>c&se;if(m!==_>>>c&se)break;m&&(h+=(1<o&&(f=f.removeBefore(i,c,s-h)),f&&_>>oe<=ue&&u.size>=2*o.size?(i=u.filter(function(t,r){return void 0!==t&&s!==r}),n=i.toKeyedSeq().map(function(t){return t[0]}).flip().toMap(),t.__ownerID&&(n.__ownerID=i.__ownerID=t.__ownerID)):(n=o.remove(r),i=s===u.size-1?u.pop():u.set(s,void 0))}else if(a){if(e===u.get(s)[1])return t;n=o,i=u.set(s,[r,e])}else n=o.set(r,u.size),i=u.set(u.size,[r,e]);return t.__ownerID?(t.size=n.size,t._map=n,t._list=i,t.__hash=void 0,t):zr(n,i)}function br(t){return!(!t||!t[Sn])}function Or(t,r,e,n){var i=Object.create(In);return i.size=t,i._head=r,i.__ownerID=e,i.__hash=n,i.__altered=!1,i}function Er(){return bn||(bn=Or(0))}function qr(t,r){if(t===r)return!0;if(!_(r)||void 0!==t.size&&void 0!==r.size&&t.size!==r.size||void 0!==t.__hash&&void 0!==r.__hash&&t.__hash!==r.__hash||l(t)!==l(r)||v(t)!==v(r)||d(t)!==d(r))return!1;if(0===t.size&&0===r.size)return!0;var e=!y(t);if(d(t)){var n=t.entries();return r.every(function(t,r){var i=n.next().value;return i&&k(i[1],t)&&(e||k(i[0],r))})&&n.next().done}var i=!1;if(void 0===t.size)if(void 0===r.size)"function"==typeof t.cacheResult&&t.cacheResult();else{i=!0;var o=t;t=r,r=o}var u=!0,s=r.__iterate(function(r,n){if(e?!t.has(r):i?!k(r,t.get(n,ae)):!k(t.get(n,ae),r))return u=!1,!1});return u&&t.size===s}function Mr(t,r){var e=function(e){t.prototype[e]=r[e]};return Object.keys(r).forEach(e),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(r).forEach(e),t}function Dr(t){return lt(t)?Me(t).map(Dr).toJSON():t}function xr(t){ -return!(!t||!t[En])}function Ar(t,r){return t.__ownerID?(t.size=r.size,t._map=r,t):r===t._map?t:0===r.size?t.__empty():t.__make(r)}function jr(t,r){var e=Object.create(qn);return e.size=t?t.size:0,e._map=t,e.__ownerID=r,e}function kr(){return Mn||(Mn=jr(Zt()))}function Rr(t,r,e){for(var n=pt(r),i=0;i!==n.length;)if((t=dt(t,n[i++],ae))===ae)return e;return t}function Ur(t,r){return Rr(this,t,r)}function Kr(t,r){return Rr(t,r,ae)!==ae}function Tr(t){return Kr(this,t)}function Cr(){ht(this.size);var t={};return this.__iterate(function(r,e){t[e]=r}),t}function Lr(t,r,e,n,i,o){return ht(t.size),t.__iterate(function(t,o,u){i?(i=!1,e=t):e=r.call(n,e,t,o,u)},o),e}function Br(t,r){return r}function Wr(t,r){return[r,t]}function Nr(t){return function(){return!t.apply(this,arguments)}}function Pr(t){return function(){return-t.apply(this,arguments)}}function Jr(){return ct(arguments)}function Hr(t,r){return tr?-1:0}function Vr(t){if(t.size===1/0)return 0;var r=d(t),e=l(t),n=r?1:0;return Yr(t.__iterate(e?r?function(t,r){n=31*n+Qr(U(t),U(r))|0}:function(t,r){n=n+Qr(U(t),U(r))|0}:r?function(t){n=31*n+U(t)|0}:function(t){n=n+U(t)|0}),n)}function Yr(t,r){return r=Le(r,3432918353),r=Le(r<<15|r>>>-15,461845907),r=Le(r<<13|r>>>-13,5),r=(r+3864292196|0)^t,r=Le(r^r>>>16,2246822507),r=Le(r^r>>>13,3266489909),r=R(r^r>>>16)}function Qr(t,r){return t^r+2654435769+(t<<6)+(t>>2)|0}function Xr(t){return xr(t)&&d(t)}function Fr(t,r){var e=Object.create(Un);return e.size=t?t.size:0,e._map=t,e.__ownerID=r,e}function Gr(){return Kn||(Kn=Fr(Sr()))}function Zr(t,r,e){var n=Object.create(Object.getPrototypeOf(t));return n._values=r,n.__ownerID=e,n}function $r(t){return t._name||t.constructor.name||"Record"}function te(t){return D(t._keys.map(function(r){return[r,t.get(r)]}))}function re(t,r){try{Object.defineProperty(t,r,{get:function(){return this.get(r)},set:function(t){ft(this.__ownerID,"Cannot set on an immutable record."),this.set(r,t)}})}catch(t){}}function ee(t,r){return ne([],r||ie,t,"",r&&r.length>2?[]:void 0,{"":t})} -function ne(t,r,e,n,i,o){var u=Array.isArray(e)?xe:_t(e)?De:null;if(u){if(~t.indexOf(e))throw new TypeError("Cannot convert circular structure to Immutable");t.push(e),i&&""!==n&&i.push(n);var s=r.call(o,n,u(e).map(function(n,o){return ne(t,r,n,o,i,e)}),i&&i.slice());return t.pop(),i&&i.pop(),s}return e}function ie(t,r){return l(r)?r.toMap():r.toList()}var oe=5,ue=1<=n.length){var r=e.next();if(r.done)return r;n[i]=r.value}return w(t,i,n[i++])})},r}(xe),Le="function"==typeof Math.imul&&Math.imul(4294967295,2)===-2?Math.imul:function(t,r){t|=0,r|=0;var e=65535&t,n=65535&r;return e*n+((t>>>16)*n+e*(r>>>16)<<16>>>0)|0},Be=Object.isExtensible,We=function(){try{return Object.defineProperty({},"@",{}),!0 -}catch(t){return!1}}(),Ne="function"==typeof WeakMap;Ne&&(Ke=new WeakMap);var Pe=0,Je="__immutablehash__";"function"==typeof Symbol&&(Je=Symbol(Je));var He=16,Ve=255,Ye=0,Qe={},Xe=function(t){function r(t,r){this._iter=t,this._useKeys=r,this.size=t.size}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.prototype.get=function(t,r){return this._iter.get(t,r)},r.prototype.has=function(t){return this._iter.has(t)},r.prototype.valueSeq=function(){return this._iter.valueSeq()},r.prototype.reverse=function(){var t=this,r=N(this,!0);return this._useKeys||(r.valueSeq=function(){return t._iter.toSeq().reverse()}),r},r.prototype.map=function(t,r){var e=this,n=W(this,t,r);return this._useKeys||(n.valueSeq=function(){return e._iter.toSeq().map(t,r)}),n},r.prototype.__iterate=function(t,r){var e=this;return this._iter.__iterate(function(r,n){return t(r,n,e)},r)},r.prototype.__iterator=function(t,r){return this._iter.__iterator(t,r)},r}(De);Xe.prototype[le]=!0;var Fe=function(t){function r(t){this._iter=t,this.size=t.size}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.prototype.includes=function(t){return this._iter.includes(t)},r.prototype.__iterate=function(t,r){var e=this,n=0;return r&&i(this),this._iter.__iterate(function(i){return t(i,r?e.size-++n:n++,e)},r)},r.prototype.__iterator=function(t,r){var e=this,n=this._iter.__iterator(ze,r),o=0;return r&&i(this),new Ee(function(){var i=n.next();return i.done?i:w(t,r?e.size-++o:o++,i.value,i)})},r}(xe),Ge=function(t){function r(t){this._iter=t,this.size=t.size}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.prototype.has=function(t){return this._iter.includes(t)},r.prototype.__iterate=function(t,r){var e=this;return this._iter.__iterate(function(r){return t(r,r,e)},r)},r.prototype.__iterator=function(t,r){var e=this._iter.__iterator(ze,r);return new Ee(function(){var r=e.next();return r.done?r:w(t,r.value,r.value,r)})},r -}(Ae),Ze=function(t){function r(t){this._iter=t,this.size=t.size}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.prototype.entrySeq=function(){return this._iter.toSeq()},r.prototype.__iterate=function(t,r){var e=this;return this._iter.__iterate(function(r){if(r){it(r);var n=_(r);return t(n?r.get(1):r[1],n?r.get(0):r[0],e)}},r)},r.prototype.__iterator=function(t,r){var e=this._iter.__iterator(ze,r);return new Ee(function(){for(;;){var r=e.next();if(r.done)return r;var n=r.value;if(n){it(n);var i=_(n);return w(t,i?n.get(0):n[0],i?n.get(1):n[1],r)}}})},r}(De);Fe.prototype.cacheResult=Xe.prototype.cacheResult=Ge.prototype.cacheResult=Ze.prototype.cacheResult=st;var $e=function(t){function r(r){return null===r||void 0===r?Zt():Qt(r)&&!d(r)?r:Zt().withMutations(function(e){var n=t(r);ht(n.size),n.forEach(function(t,r){return e.set(r,t)})})}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.of=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return Zt().withMutations(function(r){for(var e=0;e=t.length)throw Error("Missing value for key: "+t[e]);r.set(t[e],t[e+1])}})},r.prototype.toString=function(){return this.__toString("Map {","}")},r.prototype.get=function(t,r){return this._root?this._root.get(0,void 0,t,r):r},r.prototype.set=function(t,r){return $t(this,t,r)},r.prototype.remove=function(t){return $t(this,t,ae)},r.prototype.deleteAll=function(t){var r=ye(t);return 0===r.size?this:this.withMutations(function(t){r.forEach(function(r){return t.remove(r)})})},r.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):Zt()},r.prototype.sort=function(t){return mn($(this,t))},r.prototype.sortBy=function(t,r){return mn($(this,r,t))},r.prototype.map=function(t,r){return this.withMutations(function(e){e.forEach(function(n,i){e.set(i,t.call(r,n,i,e))})})},r.prototype.__iterator=function(t,r){return new cn(this,t,r) -},r.prototype.__iterate=function(t,r){var e=this,n=0;return this._root&&this._root.iterate(function(r){return n++,t(r[1],r[0],e)},r),n},r.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Gt(this.size,this._root,t,this.__hash):0===this.size?Zt():(this.__ownerID=t,this.__altered=!1,this)},r}(de);$e.isMap=Qt;var tn="@@__IMMUTABLE_MAP__@@",rn=$e.prototype;rn[tn]=!0,rn.delete=rn.remove,rn.removeAll=rn.deleteAll,rn.setIn=bt,rn.removeIn=rn.deleteIn=Et,rn.update=Mt,rn.updateIn=Dt,rn.merge=rn.concat=xt,rn.mergeWith=At,rn.mergeDeep=Bt,rn.mergeDeepWith=Wt,rn.mergeIn=Nt,rn.mergeDeepIn=Pt,rn.withMutations=Jt,rn.wasAltered=Yt,rn.asImmutable=Vt,rn["@@transducer/init"]=rn.asMutable=Ht,rn["@@transducer/step"]=function(t,r){return t.set(r[0],r[1])},rn["@@transducer/result"]=function(t){return t.asImmutable()};var en=function(t,r){this.ownerID=t,this.entries=r};en.prototype.get=function(t,r,e,n){for(var i=this.entries,o=0,u=i.length;o=fn)return nr(t,c,i,o);var _=t&&t===this.ownerID,l=_?c:ct(c);return p?a?f===h-1?l.pop():l[f]=l.pop():l[f]=[i,o]:l.push([i,o]),_?(this.entries=l,this):new en(t,l)}};var nn=function(t,r,e){this.ownerID=t,this.bitmap=r,this.nodes=e};nn.prototype.get=function(t,r,e,n){void 0===r&&(r=U(e));var i=1<<((0===t?r:r>>>t)&se),o=this.bitmap;return 0==(o&i)?n:this.nodes[ur(o&i-1)].get(t+oe,r,e,n)},nn.prototype.update=function(t,r,e,n,i,o,u){void 0===e&&(e=U(n));var s=(0===r?e:e>>>r)&se,a=1<=hn)return or(t,p,c,s,l);if(f&&!l&&2===p.length&&rr(p[1^h]))return p[1^h];if(f&&l&&1===p.length&&rr(l))return l -;var v=t&&t===this.ownerID,y=f?l?c:c^a:c|a,d=f?l?sr(p,h,l,v):cr(p,h,v):ar(p,h,l,v);return v?(this.bitmap=y,this.nodes=d,this):new nn(t,y,d)};var on=function(t,r,e){this.ownerID=t,this.count=r,this.nodes=e};on.prototype.get=function(t,r,e,n){void 0===r&&(r=U(e));var i=(0===t?r:r>>>t)&se,o=this.nodes[i];return o?o.get(t+oe,r,e,n):n},on.prototype.update=function(t,r,e,n,i,o,u){void 0===e&&(e=U(n));var s=(0===r?e:e>>>r)&se,a=i===ae,c=this.nodes,f=c[s];if(a&&!f)return this;var h=tr(f,t,r+oe,e,n,i,o,u);if(h===f)return this;var p=this.count;if(f){if(!h&&--p0&&i=0&&t>>r&se;if(n>=this.array.length)return new yn([],t);var i,o=0===n;if(r>0){var u=this.array[n];if((i=u&&u.removeBefore(t,r-oe,e))===u&&o)return this}if(o&&!i)return this;var s=yr(this,t);if(!o)for(var a=0;a>>r&se;if(n>=this.array.length)return this;var i;if(r>0){var o=this.array[n];if((i=o&&o.removeAfter(t,r-oe,e))===o&&n===this.array.length-1)return this}var u=yr(this,t);return u.array.splice(n+1),i&&(u.array[n]=i),u};var dn,gn={},mn=function(t){function r(t){return null===t||void 0===t?Sr():wr(t)?t:Sr().withMutations(function(r){var e=de(t);ht(e.size),e.forEach(function(t,e){return r.set(e,t)})})}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.of=function(){return this(arguments)},r.prototype.toString=function(){return this.__toString("OrderedMap {","}")},r.prototype.get=function(t,r){var e=this._map.get(t);return void 0!==e?this._list.get(e)[1]:r},r.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._map.clear(),this._list.clear(),this):Sr()},r.prototype.set=function(t,r){return Ir(this,t,r)},r.prototype.remove=function(t){return Ir(this,t,ae)},r.prototype.wasAltered=function(){return this._map.wasAltered()||this._list.wasAltered()},r.prototype.__iterate=function(t,r){var e=this;return this._list.__iterate(function(r){return r&&t(r[1],r[0],e)},r)},r.prototype.__iterator=function(t,r){return this._list.fromEntrySeq().__iterator(t,r)},r.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var r=this._map.__ensureOwner(t),e=this._list.__ensureOwner(t);return t?zr(r,e,t,this.__hash):0===this.size?Sr():(this.__ownerID=t,this._map=r,this._list=e,this)},r}($e);mn.isOrderedMap=wr,mn.prototype[le]=!0,mn.prototype.delete=mn.prototype.remove;var wn,zn=function(t){function r(t){return null===t||void 0===t?Er():br(t)?t:Er().pushAll(t)}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.of=function(){return this(arguments)},r.prototype.toString=function(){return this.__toString("Stack [","]")},r.prototype.get=function(t,r){var e=this._head;for(t=o(this,t);e&&t--;)e=e.next -;return e?e.value:r},r.prototype.peek=function(){return this._head&&this._head.value},r.prototype.push=function(){var t=arguments;if(0===arguments.length)return this;for(var r=this.size+arguments.length,e=this._head,n=arguments.length-1;n>=0;n--)e={value:t[n],next:e};return this.__ownerID?(this.size=r,this._head=e,this.__hash=void 0,this.__altered=!0,this):Or(r,e)},r.prototype.pushAll=function(r){if(r=t(r),0===r.size)return this;if(0===this.size&&br(r))return r;ht(r.size);var e=this.size,n=this._head;return r.__iterate(function(t){e++,n={value:t,next:n}},!0),this.__ownerID?(this.size=e,this._head=n,this.__hash=void 0,this.__altered=!0,this):Or(e,n)},r.prototype.pop=function(){return this.slice(1)},r.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):Er()},r.prototype.slice=function(r,e){if(s(r,e,this.size))return this;var n=a(r,this.size);if(c(e,this.size)!==this.size)return t.prototype.slice.call(this,r,e);for(var i=this.size-n,o=this._head;n--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):Or(i,o)},r.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Or(this.size,this._head,t,this.__hash):0===this.size?Er():(this.__ownerID=t,this.__altered=!1,this)},r.prototype.__iterate=function(t,r){var e=this;if(r)return new ke(this.toArray()).__iterate(function(r,n){return t(r,n,e)},r);for(var n=0,i=this._head;i&&t(i.value,n++,e)!==!1;)i=i.next;return n},r.prototype.__iterator=function(t,r){if(r)return new ke(this.toArray()).__iterator(t,r);var e=0,n=this._head;return new Ee(function(){if(n){var r=n.value;return n=n.next,w(t,e++,r)}return z()})},r}(ge);zn.isStack=br;var Sn="@@__IMMUTABLE_STACK__@@",In=zn.prototype;In[Sn]=!0,In.shift=In.pop,In.unshift=In.push,In.unshiftAll=In.pushAll,In.withMutations=Jt,In.wasAltered=Yt,In.asImmutable=Vt,In["@@transducer/init"]=In.asMutable=Ht,In["@@transducer/step"]=function(t,r){return t.unshift(r)}, -In["@@transducer/result"]=function(t){return t.asImmutable()};var bn,On=function(t){function r(r){return null===r||void 0===r?kr():xr(r)&&!d(r)?r:kr().withMutations(function(e){var n=t(r);ht(n.size),n.forEach(function(t){return e.add(t)})})}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.of=function(){return this(arguments)},r.fromKeys=function(t){return this(de(t).keySeq())},r.intersect=function(t){return t=ye(t).toArray(),t.length?qn.intersect.apply(r(t.pop()),t):kr()},r.union=function(t){return t=ye(t).toArray(),t.length?qn.union.apply(r(t.pop()),t):kr()},r.prototype.toString=function(){return this.__toString("Set {","}")},r.prototype.has=function(t){return this._map.has(t)},r.prototype.add=function(t){return Ar(this,this._map.set(t,t))},r.prototype.remove=function(t){return Ar(this,this._map.remove(t))},r.prototype.clear=function(){return Ar(this,this._map.clear())},r.prototype.map=function(t,r){var e=this;return Ar(this,this._map.map(function(r){return t(r,r,e)},r))},r.prototype.union=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];return r=r.filter(function(t){return 0!==t.size}),0===r.length?this:0!==this.size||this.__ownerID||1!==r.length?this.withMutations(function(e){for(var n=0;n=0&&r=0&&ethis.size?r:this.find(function(r,e){return e===t},void 0,r)},has:function(t){return(t=o(this,t))>=0&&(void 0!==this.size?this.size===1/0||t>>0;if(""+e!==r||4294967295===e)return NaN;r=e}return r<0?i(t)+r:r}function u(){return!0}function s(t,r,e){return(0===t&&!h(t)||void 0!==e&&t<=-e)&&(void 0===r||void 0!==e&&r>=e)}function a(t,r){return f(t,r,0)}function c(t,r){return f(t,r,r)}function f(t,r,e){return void 0===t?e:h(t)?r===1/0?r:0|Math.max(0,r+t):void 0===r||r===t?t:0|Math.min(r,t)}function h(t){return t<0||0===t&&1/t==-(1/0)}function p(t){return _(t)||g(t)}function _(t){return!(!t||!t[he])}function l(t){return!(!t||!t[pe])}function v(t){return!(!t||!t[_e])}function y(t){return l(t)||v(t)}function d(t){return!(!t||!t[le])}function g(t){return!(!t||!t[ve])}function m(t){return!(!t||"function"!=typeof t.equals||"function"!=typeof t.hashCode)}function w(t,r,e,n){var i=0===t?r:1===t?e:[r,e];return n?n.value=i:n={value:i,done:!1},n}function z(){return{value:void 0,done:!0}}function S(t){return!!O(t)}function I(t){return t&&"function"==typeof t.next}function b(t){var r=O(t);return r&&r.call(t)}function O(t){var r=t&&(Ie&&t[Ie]||t[be]);if("function"==typeof r)return r}function E(t){return!(!Array.isArray(t)&&"string"!=typeof t)||t&&"object"==typeof t&&Number.isInteger(t.length)&&t.length>=0&&(0===t.length?1===Object.keys(t).length:t.hasOwnProperty(t.length-1))}function q(t){return!(!t||!t[je])}function M(){return Ue||(Ue=new ke([]))}function D(t){var r=Array.isArray(t)?new ke(t):I(t)?new Ce(t):S(t)?new Te(t):void 0;if(r)return r.fromEntrySeq();if("object"==typeof t)return new Re(t);throw new TypeError("Expected Array or collection object of [k, v] entries, or keyed object: "+t)}function A(t){var r=j(t);if(r)return r +;throw new TypeError("Expected Array or collection object of values: "+t)}function x(t){var r=j(t);if(r)return r;if("object"==typeof t)return new Re(t);throw new TypeError("Expected Array or collection object of values, or keyed object: "+t)}function j(t){return E(t)?new ke(t):I(t)?new Ce(t):S(t)?new Te(t):void 0}function k(t,r){if(t===r||t!==t&&r!==r)return!0;if(!t||!r)return!1;if("function"==typeof t.valueOf&&"function"==typeof r.valueOf){if(t=t.valueOf(),r=r.valueOf(),t===r||t!==t&&r!==r)return!0;if(!t||!r)return!1}return!!(m(t)&&m(r)&&t.equals(r))}function R(t){return t>>>1&1073741824|3221225471&t}function U(t){if(t===!1||null===t||void 0===t)return 0;if("function"==typeof t.valueOf&&((t=t.valueOf())===!1||null===t||void 0===t))return 0;if(t===!0)return 1;var r=typeof t;if("number"===r){if(t!==t||t===1/0)return 0;var e=0|t;for(e!==t&&(e^=4294967295*t);t>4294967295;)t/=4294967295,e^=t;return R(e)}if("string"===r)return t.length>He?K(t):T(t);if("function"==typeof t.hashCode)return R(t.hashCode());if("object"===r||"function"===r)return C(t);if("function"==typeof t.toString)return T(""+t);throw Error("Value type "+r+" cannot be hashed.")}function K(t){var r=Qe[t];return void 0===r&&(r=T(t),Ye===Ve&&(Ye=0,Qe={}),Ye++,Qe[t]=r),r}function T(t){for(var r=0,e=0;e0)switch(t.nodeType){case 1:return t.uniqueID;case 9:return t.documentElement&&t.documentElement.uniqueID}}function B(t){var r=ut(t);return r._iter=t,r.size=t.size,r.flip=function(){return t},r.reverse=function(){var r=t.reverse.apply(this);return r.flip=function(){return t.reverse()},r},r.has=function(r){return t.includes(r)},r.includes=function(r){return t.has(r)},r.cacheResult=st,r.__iterateUncached=function(r,e){var n=this;return t.__iterate(function(t,e){return r(e,t,n)!==!1},e)},r.__iteratorUncached=function(r,e){if(r===Se){var n=t.__iterator(r,e);return new Ee(function(){var t=n.next();if(!t.done){var r=t.value[0];t.value[0]=t.value[1],t.value[1]=r}return t})}return t.__iterator(r===ze?we:ze,e)},r}function W(t,r,e){var n=ut(t);return n.size=t.size,n.has=function(r){return t.has(r)},n.get=function(n,i){var o=t.get(n,ae);return o===ae?i:r.call(e,o,n,t)},n.__iterateUncached=function(n,i){var o=this;return t.__iterate(function(t,i,u){return n(r.call(e,t,i,u),i,o)!==!1},i)},n.__iteratorUncached=function(n,i){var o=t.__iterator(Se,i);return new Ee(function(){var i=o.next();if(i.done)return i;var u=i.value,s=u[0];return w(n,s,r.call(e,u[1],s,t),i)})},n}function N(t,r){var e=this,n=ut(t);return n._iter=t,n.size=t.size,n.reverse=function(){return t},t.flip&&(n.flip=function(){var r=B(t);return r.reverse=function(){return t.flip()},r}),n.get=function(e,n){return t.get(r?e:-1-e,n)},n.has=function(e){return t.has(r?e:-1-e)},n.includes=function(r){return t.includes(r)},n.cacheResult=st,n.__iterate=function(e,n){var o=this,u=0;return n&&i(t),t.__iterate(function(t,i){return e(t,r?i:n?o.size-++u:u++,o)},!n)},n.__iterator=function(n,o){var u=0;o&&i(t);var s=t.__iterator(Se,!o);return new Ee(function(){var t=s.next();if(t.done)return t;var i=t.value;return w(n,r?i[0]:o?e.size-++u:u++,i[1],t)})},n}function P(t,r,e,n){var i=ut(t);return n&&(i.has=function(n){var i=t.get(n,ae) +;return i!==ae&&!!r.call(e,i,n,t)},i.get=function(n,i){var o=t.get(n,ae);return o!==ae&&r.call(e,o,n,t)?o:i}),i.__iterateUncached=function(i,o){var u=this,s=0;return t.__iterate(function(t,o,a){if(r.call(e,t,o,a))return s++,i(t,n?o:s-1,u)},o),s},i.__iteratorUncached=function(i,o){var u=t.__iterator(Se,o),s=0;return new Ee(function(){for(;;){var o=u.next();if(o.done)return o;var a=o.value,c=a[0],f=a[1];if(r.call(e,f,c,t))return w(i,n?c:s++,f,o)}})},i}function J(t,r,e){var n=$e().asMutable();return t.__iterate(function(i,o){n.update(r.call(e,i,o,t),0,function(t){return t+1})}),n.asImmutable()}function H(t,r,e){var n=l(t),i=(d(t)?mn():$e()).asMutable();t.__iterate(function(o,u){i.update(r.call(e,o,u,t),function(t){return t=t||[],t.push(n?[u,o]:o),t})});var o=ot(t);return i.map(function(r){return nt(t,o(r))})}function V(t,r,e,n){var i=t.size;if(s(r,e,i))return t;var u=a(r,i),f=c(e,i);if(u!==u||f!==f)return V(t.toSeq().cacheResult(),r,e,n);var h,p=f-u;p===p&&(h=p<0?0:p);var _=ut(t);return _.size=0===h?h:t.size&&h||void 0,!n&&q(t)&&h>=0&&(_.get=function(r,e){return r=o(this,r),r>=0&&rh)return z();var t=i.next();return n||r===ze||t.done?t:r===we?w(r,s-1,void 0,t):w(r,s-1,t.value[1],t)})},_}function Y(t,r,e){var n=ut(t);return n.__iterateUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterate(n,i);var u=0;return t.__iterate(function(t,i,s){return r.call(e,t,i,s)&&++u&&n(t,i,o)}),u},n.__iteratorUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterator(n,i);var u=t.__iterator(Se,i),s=!0;return new Ee(function(){if(!s)return z();var t=u.next() +;if(t.done)return t;var i=t.value,a=i[0],c=i[1];return r.call(e,c,a,o)?n===Se?t:w(n,a,c,t):(s=!1,z())})},n}function Q(t,r,e,n){var i=ut(t);return i.__iterateUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterate(i,o);var s=!0,a=0;return t.__iterate(function(t,o,c){if(!s||!(s=r.call(e,t,o,c)))return a++,i(t,n?o:a-1,u)}),a},i.__iteratorUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterator(i,o);var s=t.__iterator(Se,o),a=!0,c=0;return new Ee(function(){var t,o,f;do{if(t=s.next(),t.done)return n||i===ze?t:i===we?w(i,c++,void 0,t):w(i,c++,t.value[1],t);var h=t.value;o=h[0],f=h[1],a&&(a=r.call(e,f,o,u))}while(a);return i===Se?t:w(i,o,f,t)})},i}function X(t,r){var e=l(t),n=[t].concat(r).map(function(t){return _(t)?e&&(t=de(t)):t=e?D(t):A(Array.isArray(t)?t:[t]),t}).filter(function(t){return 0!==t.size});if(0===n.length)return t;if(1===n.length){var i=n[0];if(i===t||e&&l(i)||v(t)&&v(i))return i}var o=new ke(n);return e?o=o.toKeyedSeq():v(t)||(o=o.toSetSeq()),o=o.flatten(!0),o.size=n.reduce(function(t,r){if(void 0!==t){var e=r.size;if(void 0!==e)return t+e}},0),o}function F(t,r,e){var n=ut(t);return n.__iterateUncached=function(i,o){function u(t,c){t.__iterate(function(t,o){return(!r||c0}function et(t,r,e,n){var i=ut(t),o=new ke(e).map(function(t){return t.size});return i.size=n?o.max():o.min(),i.__iterate=function(t,r){for(var e,n=this,i=this.__iterator(ze,r),o=0;!(e=i.next()).done&&t(e.value,o++,n)!==!1;);return o},i.__iteratorUncached=function(t,i){var o=e.map(function(t){return t=ye(t),b(i?t.reverse():t)}),u=0,s=!1;return new Ee(function(){var e;return s||(e=o.map(function(t){return t.next()}),s=n?e.every(function(t){return t.done}):e.some(function(t){return t.done})),s?z():w(t,u++,r.apply(null,e.map(function(t){return t.value})))})},i}function nt(t,r){return t===r?t:q(t)?r:t.constructor(r)}function it(t){if(t!==Object(t))throw new TypeError("Expected [K, V] tuple: "+t)}function ot(t){return l(t)?de:v(t)?ge:me}function ut(t){return Object.create((l(t)?De:v(t)?Ae:xe).prototype)}function st(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size,this):Me.prototype.cacheResult.call(this)}function at(t,r){return void 0===t&&void 0===r?0:void 0===t?1:void 0===r?-1:t>r?1:t0;)r[e]=arguments[e+1];return jt(this,r,t)}function jt(t,r,e){for(var n=[],i=0;i0;)r[e]=arguments[e+1];return Ct(t,r)}function Rt(t,r){for(var e=[],n=arguments.length-2;n-- >0;)e[n]=arguments[n+2];return Ct(r,e,t)}function Ut(t){for(var r=[],e=arguments.length-1;e-- >0;)r[e]=arguments[e+1];return Tt(t,r)}function Kt(t,r){for(var e=[],n=arguments.length-2;n-- >0;)e[n]=arguments[n+2];return Tt(r,e,t)}function Tt(t,r,e){return Ct(t,r,Lt(e))}function Ct(t,r,e){if(!lt(t))throw new TypeError("Cannot merge into non-data-structure value: "+t);if(p(t))return t.mergeWith?t.mergeWith.apply(t,[e].concat(r)):t.concat.apply(t,r);for(var n=Array.isArray(t),i=t,o=n?ge:de,u=n?function(r){i===t&&(i=gt(i)),i.push(r)}:function(r,n){var o=qe.call(i,n),u=o&&e?e(i[n],r,n):r;o&&u===i[n]||(i===t&&(i=gt(i)),i[n]=u)},s=0;s0;)r[e]=arguments[e+1];return Tt(this,r,t)}function Nt(t){for(var r=[],e=arguments.length-1;e-- >0;)r[e]=arguments[e+1];return zt(this,t,Zt(),function(t){return Ct(t,r)})}function Pt(t){for(var r=[],e=arguments.length-1;e-- >0;)r[e]=arguments[e+1];return zt(this,t,Zt(),function(t){return Tt(t,r)})}function Jt(t){var r=this.asMutable();return t(r),r.wasAltered()?r.__ensureOwner(this.__ownerID):this}function Ht(){return this.__ownerID?this:this.__ensureOwner(new n)}function Vt(){return this.__ensureOwner()}function Yt(){return this.__altered}function Qt(t){ +return!(!t||!t[tn])}function Xt(t,r){return w(t,r[0],r[1])}function Ft(t,r){return{node:t,index:0,__prev:r}}function Gt(t,r,e,n){var i=Object.create(rn);return i.size=t,i._root=r,i.__ownerID=e,i.__hash=n,i.__altered=!1,i}function Zt(){return an||(an=Gt(0))}function $t(t,e,n){var i,o;if(t._root){var u=r(ce),s=r(fe);if(i=tr(t._root,t.__ownerID,0,void 0,e,n,u,s),!s.value)return t;o=t.size+(u.value?n===ae?-1:1:0)}else{if(n===ae)return t;o=1,i=new en(t.__ownerID,[[e,n]])}return t.__ownerID?(t.size=o,t._root=i,t.__hash=void 0,t.__altered=!0,t):i?Gt(o,i):Zt()}function tr(t,r,n,i,o,u,s,a){return t?t.update(r,n,i,o,u,s,a):u===ae?t:(e(a),e(s),new sn(r,i,[o,u]))}function rr(t){return t.constructor===sn||t.constructor===un}function er(t,r,e,n,i){if(t.keyHash===n)return new un(r,n,[t.entry,i]);var o,u=(0===e?t.keyHash:t.keyHash>>>e)&se,s=(0===e?n:n>>>e)&se;return new nn(r,1<>>=1)u[s]=1&e?r[o++]:void 0;return u[n]=i,new on(t,o+1,u)}function ur(t){return t-=t>>1&1431655765,t=(858993459&t)+(t>>2&858993459),t=t+(t>>4)&252645135,t+=t>>8,127&(t+=t>>16)}function sr(t,r,e,n){var i=n?t:ct(t);return i[r]=e,i}function ar(t,r,e,n){var i=t.length+1;if(n&&r+1===i)return t[r]=e,t;for(var o=Array(i),u=0,s=0;so?0:o-e,c=u-e;return c>ue&&(c=ue),function(){if(i===c)return gn;var t=r?--c:i++;return n&&n[t]}} +function i(t,n,i){var s,a=t&&t.array,c=i>o?0:o-i>>n,f=1+(u-i>>n);return f>ue&&(f=ue),function(){for(;;){if(s){var t=s();if(t!==gn)return t;s=null}if(c===f)return gn;var o=r?--f:c++;s=e(a&&a[o],n-oe,i+(o<=t.size||e<0)return t.withMutations(function(t){e<0?gr(t,e).set(0,n):gr(t,0,e+1).set(e,n)});e+=t._origin;var i=t._tail,u=t._root,s=r(fe);return e>=mr(t._capacity)?i=vr(i,t.__ownerID,0,e,n,s):u=vr(u,t.__ownerID,t._level,e,n,s),s.value?t.__ownerID?(t._root=u,t._tail=i,t.__hash=void 0,t.__altered=!0,t):pr(t._origin,t._capacity,t._level,u,i):t}function vr(t,r,n,i,o,u){var s=i>>>n&se,a=t&&s0){var f=t&&t.array[s],h=vr(f,r,n-oe,i,o,u);return h===f?t:(c=yr(t,r),c.array[s]=h,c)}return a&&t.array[s]===o?t:(e(u),c=yr(t,r),void 0===o&&s===c.array.length-1?c.array.pop():c.array[s]=o,c)}function yr(t,r){return r&&t&&r===t.ownerID?t:new yn(t?t.array.slice():[],r)}function dr(t,r){if(r>=mr(t._capacity))return t._tail;if(r<1<0;)e=e.array[r>>>n&se],n-=oe;return e}}function gr(t,r,e){void 0!==r&&(r|=0),void 0!==e&&(e|=0);var i=t.__ownerID||new n,o=t._origin,u=t._capacity,s=o+r,a=void 0===e?u:e<0?u+e:o+e;if(s===o&&a===u)return t;if(s>=a)return t.clear();for(var c=t._level,f=t._root,h=0;s+h<0;)f=new yn(f&&f.array.length?[void 0,f]:[],i),c+=oe,h+=1<=1<p?new yn([],i):l;if(l&&_>p&&soe;d-=oe){var g=p>>>d&se;y=y.array[g]=yr(y.array[g],i)}y.array[p>>>oe&se]=l}if(a=_)s-=_,a-=_,c=oe,f=null, +v=v&&v.removeBefore(i,0,s);else if(s>o||_>>c&se;if(m!==_>>>c&se)break;m&&(h+=(1<o&&(f=f.removeBefore(i,c,s-h)),f&&_>>oe<=ue&&u.size>=2*o.size?(i=u.filter(function(t,r){return void 0!==t&&s!==r}),n=i.toKeyedSeq().map(function(t){return t[0]}).flip().toMap(),t.__ownerID&&(n.__ownerID=i.__ownerID=t.__ownerID)):(n=o.remove(r),i=s===u.size-1?u.pop():u.set(s,void 0))}else if(a){if(e===u.get(s)[1])return t;n=o,i=u.set(s,[r,e])}else n=o.set(r,u.size),i=u.set(u.size,[r,e]);return t.__ownerID?(t.size=n.size,t._map=n,t._list=i,t.__hash=void 0,t):zr(n,i)}function br(t){return!(!t||!t[Sn])}function Or(t,r,e,n){var i=Object.create(In);return i.size=t,i._head=r,i.__ownerID=e,i.__hash=n,i.__altered=!1,i}function Er(){return bn||(bn=Or(0))}function qr(t,r){if(t===r)return!0;if(!_(r)||void 0!==t.size&&void 0!==r.size&&t.size!==r.size||void 0!==t.__hash&&void 0!==r.__hash&&t.__hash!==r.__hash||l(t)!==l(r)||v(t)!==v(r)||d(t)!==d(r))return!1;if(0===t.size&&0===r.size)return!0;var e=!y(t);if(d(t)){var n=t.entries();return r.every(function(t,r){var i=n.next().value;return i&&k(i[1],t)&&(e||k(i[0],r))})&&n.next().done}var i=!1;if(void 0===t.size)if(void 0===r.size)"function"==typeof t.cacheResult&&t.cacheResult();else{i=!0;var o=t;t=r,r=o}var u=!0,s=r.__iterate(function(r,n){if(e?!t.has(r):i?!k(r,t.get(n,ae)):!k(t.get(n,ae),r))return u=!1,!1});return u&&t.size===s}function Mr(t,r){var e=function(e){t.prototype[e]=r[e]};return Object.keys(r).forEach(e), +Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(r).forEach(e),t}function Dr(t){return lt(t)?Me(t).map(Dr).toJSON():t}function Ar(t){return!(!t||!t[En])}function xr(t,r){return t.__ownerID?(t.size=r.size,t._map=r,t):r===t._map?t:0===r.size?t.__empty():t.__make(r)}function jr(t,r){var e=Object.create(qn);return e.size=t?t.size:0,e._map=t,e.__ownerID=r,e}function kr(){return Mn||(Mn=jr(Zt()))}function Rr(t,r,e){for(var n=pt(r),i=0;i!==n.length;)if((t=dt(t,n[i++],ae))===ae)return e;return t}function Ur(t,r){return Rr(this,t,r)}function Kr(t,r){return Rr(t,r,ae)!==ae}function Tr(t){return Kr(this,t)}function Cr(){ht(this.size);var t={};return this.__iterate(function(r,e){t[e]=r}),t}function Lr(t,r,e,n,i,o){return ht(t.size),t.__iterate(function(t,o,u){i?(i=!1,e=t):e=r.call(n,e,t,o,u)},o),e}function Br(t,r){return r}function Wr(t,r){return[r,t]}function Nr(t){return function(){return!t.apply(this,arguments)}}function Pr(t){return function(){return-t.apply(this,arguments)}}function Jr(){return ct(arguments)}function Hr(t,r){return tr?-1:0}function Vr(t){if(t.size===1/0)return 0;var r=d(t),e=l(t),n=r?1:0;return Yr(t.__iterate(e?r?function(t,r){n=31*n+Qr(U(t),U(r))|0}:function(t,r){n=n+Qr(U(t),U(r))|0}:r?function(t){n=31*n+U(t)|0}:function(t){n=n+U(t)|0}),n)}function Yr(t,r){return r=Le(r,3432918353),r=Le(r<<15|r>>>-15,461845907),r=Le(r<<13|r>>>-13,5),r=(r+3864292196|0)^t,r=Le(r^r>>>16,2246822507),r=Le(r^r>>>13,3266489909),r=R(r^r>>>16)}function Qr(t,r){return t^r+2654435769+(t<<6)+(t>>2)|0}function Xr(t){return Ar(t)&&d(t)}function Fr(t,r){var e=Object.create(Un);return e.size=t?t.size:0,e._map=t,e.__ownerID=r,e}function Gr(){return Kn||(Kn=Fr(Sr()))}function Zr(t,r,e){var n=Object.create(Object.getPrototypeOf(t));return n._values=r,n.__ownerID=e,n}function $r(t){return t._name||t.constructor.name||"Record"}function te(t){return D(t._keys.map(function(r){return[r,t.get(r)]}))}function re(t,r){try{Object.defineProperty(t,r,{get:function(){return this.get(r)},set:function(t){ +ft(this.__ownerID,"Cannot set on an immutable record."),this.set(r,t)}})}catch(t){}}function ee(t,r){return ne([],r||ie,t,"",r&&r.length>2?[]:void 0,{"":t})}function ne(t,r,e,n,i,o){var u=Array.isArray(e)?Ae:_t(e)?De:null;if(u){if(~t.indexOf(e))throw new TypeError("Cannot convert circular structure to Immutable");t.push(e),i&&""!==n&&i.push(n);var s=r.call(o,n,u(e).map(function(n,o){return ne(t,r,n,o,i,e)}),i&&i.slice());return t.pop(),i&&i.pop(),s}return e}function ie(t,r){return l(r)?r.toMap():r.toList()}var oe=5,ue=1<=n.length){var r=e.next();if(r.done)return r;n[i]=r.value}return w(t,i,n[i++])})},r}(Ae),Le="function"==typeof Math.imul&&Math.imul(4294967295,2)===-2?Math.imul:function(t,r){t|=0,r|=0 +;var e=65535&t,n=65535&r;return e*n+((t>>>16)*n+e*(r>>>16)<<16>>>0)|0},Be=Object.isExtensible,We=function(){try{return Object.defineProperty({},"@",{}),!0}catch(t){return!1}}(),Ne="function"==typeof WeakMap;Ne&&(Ke=new WeakMap);var Pe=0,Je="__immutablehash__";"function"==typeof Symbol&&(Je=Symbol(Je));var He=16,Ve=255,Ye=0,Qe={},Xe=function(t){function r(t,r){this._iter=t,this._useKeys=r,this.size=t.size}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.prototype.get=function(t,r){return this._iter.get(t,r)},r.prototype.has=function(t){return this._iter.has(t)},r.prototype.valueSeq=function(){return this._iter.valueSeq()},r.prototype.reverse=function(){var t=this,r=N(this,!0);return this._useKeys||(r.valueSeq=function(){return t._iter.toSeq().reverse()}),r},r.prototype.map=function(t,r){var e=this,n=W(this,t,r);return this._useKeys||(n.valueSeq=function(){return e._iter.toSeq().map(t,r)}),n},r.prototype.__iterate=function(t,r){var e=this;return this._iter.__iterate(function(r,n){return t(r,n,e)},r)},r.prototype.__iterator=function(t,r){return this._iter.__iterator(t,r)},r}(De);Xe.prototype[le]=!0;var Fe=function(t){function r(t){this._iter=t,this.size=t.size}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.prototype.includes=function(t){return this._iter.includes(t)},r.prototype.__iterate=function(t,r){var e=this,n=0;return r&&i(this),this._iter.__iterate(function(i){return t(i,r?e.size-++n:n++,e)},r)},r.prototype.__iterator=function(t,r){var e=this,n=this._iter.__iterator(ze,r),o=0;return r&&i(this),new Ee(function(){var i=n.next();return i.done?i:w(t,r?e.size-++o:o++,i.value,i)})},r}(Ae),Ge=function(t){function r(t){this._iter=t,this.size=t.size}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.prototype.has=function(t){return this._iter.includes(t)},r.prototype.__iterate=function(t,r){var e=this;return this._iter.__iterate(function(r){return t(r,r,e)},r)}, +r.prototype.__iterator=function(t,r){var e=this._iter.__iterator(ze,r);return new Ee(function(){var r=e.next();return r.done?r:w(t,r.value,r.value,r)})},r}(xe),Ze=function(t){function r(t){this._iter=t,this.size=t.size}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.prototype.entrySeq=function(){return this._iter.toSeq()},r.prototype.__iterate=function(t,r){var e=this;return this._iter.__iterate(function(r){if(r){it(r);var n=_(r);return t(n?r.get(1):r[1],n?r.get(0):r[0],e)}},r)},r.prototype.__iterator=function(t,r){var e=this._iter.__iterator(ze,r);return new Ee(function(){for(;;){var r=e.next();if(r.done)return r;var n=r.value;if(n){it(n);var i=_(n);return w(t,i?n.get(0):n[0],i?n.get(1):n[1],r)}}})},r}(De);Fe.prototype.cacheResult=Xe.prototype.cacheResult=Ge.prototype.cacheResult=Ze.prototype.cacheResult=st;var $e=function(t){function r(r){return null===r||void 0===r?Zt():Qt(r)&&!d(r)?r:Zt().withMutations(function(e){var n=t(r);ht(n.size),n.forEach(function(t,r){return e.set(r,t)})})}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.of=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return Zt().withMutations(function(r){for(var e=0;e=t.length)throw Error("Missing value for key: "+t[e]);r.set(t[e],t[e+1])}})},r.prototype.toString=function(){return this.__toString("Map {","}")},r.prototype.get=function(t,r){return this._root?this._root.get(0,void 0,t,r):r},r.prototype.set=function(t,r){return $t(this,t,r)},r.prototype.remove=function(t){return $t(this,t,ae)},r.prototype.deleteAll=function(t){var r=ye(t);return 0===r.size?this:this.withMutations(function(t){r.forEach(function(r){return t.remove(r)})})},r.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):Zt()},r.prototype.sort=function(t){return mn($(this,t))},r.prototype.sortBy=function(t,r){return mn($(this,r,t))}, +r.prototype.map=function(t,r){return this.withMutations(function(e){e.forEach(function(n,i){e.set(i,t.call(r,n,i,e))})})},r.prototype.__iterator=function(t,r){return new cn(this,t,r)},r.prototype.__iterate=function(t,r){var e=this,n=0;return this._root&&this._root.iterate(function(r){return n++,t(r[1],r[0],e)},r),n},r.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Gt(this.size,this._root,t,this.__hash):0===this.size?Zt():(this.__ownerID=t,this.__altered=!1,this)},r}(de);$e.isMap=Qt;var tn="@@__IMMUTABLE_MAP__@@",rn=$e.prototype;rn[tn]=!0,rn.delete=rn.remove,rn.removeAll=rn.deleteAll,rn.setIn=bt,rn.removeIn=rn.deleteIn=Et,rn.update=Mt,rn.updateIn=Dt,rn.merge=rn.concat=At,rn.mergeWith=xt,rn.mergeDeep=Bt,rn.mergeDeepWith=Wt,rn.mergeIn=Nt,rn.mergeDeepIn=Pt,rn.withMutations=Jt,rn.wasAltered=Yt,rn.asImmutable=Vt,rn["@@transducer/init"]=rn.asMutable=Ht,rn["@@transducer/step"]=function(t,r){return t.set(r[0],r[1])},rn["@@transducer/result"]=function(t){return t.asImmutable()};var en=function(t,r){this.ownerID=t,this.entries=r};en.prototype.get=function(t,r,e,n){for(var i=this.entries,o=0,u=i.length;o=fn)return nr(t,c,i,o);var _=t&&t===this.ownerID,l=_?c:ct(c);return p?a?f===h-1?l.pop():l[f]=l.pop():l[f]=[i,o]:l.push([i,o]),_?(this.entries=l,this):new en(t,l)}};var nn=function(t,r,e){this.ownerID=t,this.bitmap=r,this.nodes=e};nn.prototype.get=function(t,r,e,n){void 0===r&&(r=U(e));var i=1<<((0===t?r:r>>>t)&se),o=this.bitmap;return 0==(o&i)?n:this.nodes[ur(o&i-1)].get(t+oe,r,e,n)},nn.prototype.update=function(t,r,e,n,i,o,u){void 0===e&&(e=U(n));var s=(0===r?e:e>>>r)&se,a=1<=hn)return or(t,p,c,s,l);if(f&&!l&&2===p.length&&rr(p[1^h]))return p[1^h];if(f&&l&&1===p.length&&rr(l))return l;var v=t&&t===this.ownerID,y=f?l?c:c^a:c|a,d=f?l?sr(p,h,l,v):cr(p,h,v):ar(p,h,l,v);return v?(this.bitmap=y,this.nodes=d,this):new nn(t,y,d)};var on=function(t,r,e){this.ownerID=t,this.count=r,this.nodes=e};on.prototype.get=function(t,r,e,n){void 0===r&&(r=U(e));var i=(0===t?r:r>>>t)&se,o=this.nodes[i];return o?o.get(t+oe,r,e,n):n},on.prototype.update=function(t,r,e,n,i,o,u){void 0===e&&(e=U(n));var s=(0===r?e:e>>>r)&se,a=i===ae,c=this.nodes,f=c[s];if(a&&!f)return this;var h=tr(f,t,r+oe,e,n,i,o,u);if(h===f)return this;var p=this.count;if(f){if(!h&&--p0&&i=0&&t>>r&se;if(n>=this.array.length)return new yn([],t);var i,o=0===n;if(r>0){var u=this.array[n] +;if((i=u&&u.removeBefore(t,r-oe,e))===u&&o)return this}if(o&&!i)return this;var s=yr(this,t);if(!o)for(var a=0;a>>r&se;if(n>=this.array.length)return this;var i;if(r>0){var o=this.array[n];if((i=o&&o.removeAfter(t,r-oe,e))===o&&n===this.array.length-1)return this}var u=yr(this,t);return u.array.splice(n+1),i&&(u.array[n]=i),u};var dn,gn={},mn=function(t){function r(t){return null===t||void 0===t?Sr():wr(t)?t:Sr().withMutations(function(r){var e=de(t);ht(e.size),e.forEach(function(t,e){return r.set(e,t)})})}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.of=function(){return this(arguments)},r.prototype.toString=function(){return this.__toString("OrderedMap {","}")},r.prototype.get=function(t,r){var e=this._map.get(t);return void 0!==e?this._list.get(e)[1]:r},r.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._map.clear(),this._list.clear(),this):Sr()},r.prototype.set=function(t,r){return Ir(this,t,r)},r.prototype.remove=function(t){return Ir(this,t,ae)},r.prototype.wasAltered=function(){return this._map.wasAltered()||this._list.wasAltered()},r.prototype.__iterate=function(t,r){var e=this;return this._list.__iterate(function(r){return r&&t(r[1],r[0],e)},r)},r.prototype.__iterator=function(t,r){return this._list.fromEntrySeq().__iterator(t,r)},r.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var r=this._map.__ensureOwner(t),e=this._list.__ensureOwner(t);return t?zr(r,e,t,this.__hash):0===this.size?Sr():(this.__ownerID=t,this._map=r,this._list=e,this)},r}($e);mn.isOrderedMap=wr,mn.prototype[le]=!0,mn.prototype.delete=mn.prototype.remove;var wn,zn=function(t){function r(t){return null===t||void 0===t?Er():br(t)?t:Er().pushAll(t)}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.of=function(){ +return this(arguments)},r.prototype.toString=function(){return this.__toString("Stack [","]")},r.prototype.get=function(t,r){var e=this._head;for(t=o(this,t);e&&t--;)e=e.next;return e?e.value:r},r.prototype.peek=function(){return this._head&&this._head.value},r.prototype.push=function(){var t=arguments;if(0===arguments.length)return this;for(var r=this.size+arguments.length,e=this._head,n=arguments.length-1;n>=0;n--)e={value:t[n],next:e};return this.__ownerID?(this.size=r,this._head=e,this.__hash=void 0,this.__altered=!0,this):Or(r,e)},r.prototype.pushAll=function(r){if(r=t(r),0===r.size)return this;if(0===this.size&&br(r))return r;ht(r.size);var e=this.size,n=this._head;return r.__iterate(function(t){e++,n={value:t,next:n}},!0),this.__ownerID?(this.size=e,this._head=n,this.__hash=void 0,this.__altered=!0,this):Or(e,n)},r.prototype.pop=function(){return this.slice(1)},r.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):Er()},r.prototype.slice=function(r,e){if(s(r,e,this.size))return this;var n=a(r,this.size);if(c(e,this.size)!==this.size)return t.prototype.slice.call(this,r,e);for(var i=this.size-n,o=this._head;n--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):Or(i,o)},r.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Or(this.size,this._head,t,this.__hash):0===this.size?Er():(this.__ownerID=t,this.__altered=!1,this)},r.prototype.__iterate=function(t,r){var e=this;if(r)return new ke(this.toArray()).__iterate(function(r,n){return t(r,n,e)},r);for(var n=0,i=this._head;i&&t(i.value,n++,e)!==!1;)i=i.next;return n},r.prototype.__iterator=function(t,r){if(r)return new ke(this.toArray()).__iterator(t,r);var e=0,n=this._head;return new Ee(function(){if(n){var r=n.value;return n=n.next,w(t,e++,r)}return z()})},r}(ge);zn.isStack=br;var Sn="@@__IMMUTABLE_STACK__@@",In=zn.prototype;In[Sn]=!0,In.shift=In.pop,In.unshift=In.push,In.unshiftAll=In.pushAll, +In.withMutations=Jt,In.wasAltered=Yt,In.asImmutable=Vt,In["@@transducer/init"]=In.asMutable=Ht,In["@@transducer/step"]=function(t,r){return t.unshift(r)},In["@@transducer/result"]=function(t){return t.asImmutable()};var bn,On=function(t){function r(r){return null===r||void 0===r?kr():Ar(r)&&!d(r)?r:kr().withMutations(function(e){var n=t(r);ht(n.size),n.forEach(function(t){return e.add(t)})})}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.of=function(){return this(arguments)},r.fromKeys=function(t){return this(de(t).keySeq())},r.intersect=function(t){return t=ye(t).toArray(),t.length?qn.intersect.apply(r(t.pop()),t):kr()},r.union=function(t){return t=ye(t).toArray(),t.length?qn.union.apply(r(t.pop()),t):kr()},r.prototype.toString=function(){return this.__toString("Set {","}")},r.prototype.has=function(t){return this._map.has(t)},r.prototype.add=function(t){return xr(this,this._map.set(t,t))},r.prototype.remove=function(t){return xr(this,this._map.remove(t))},r.prototype.clear=function(){return xr(this,this._map.clear())},r.prototype.map=function(t,r){var e=this;return xr(this,this._map.map(function(r){return t(r,r,e)},r))},r.prototype.union=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];return r=r.filter(function(t){return 0!==t.size}),0===r.length?this:0!==this.size||this.__ownerID||1!==r.length?this.withMutations(function(e){for(var n=0;n=0&&r=0&&ethis.size?r:this.find(function(r,e){return e===t},void 0,r)},has:function(t){return(t=o(this,t))>=0&&(void 0!==this.size?this.size===1/0||t Date: Thu, 17 May 2018 15:24:55 +0000 Subject: [PATCH 107/242] Deploy 901bd403b9864cf2b1681165c9f9b73a1ccc17d5 to NPM branch --- README.md | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 3a61d541f1..584a3d23bf 100644 --- a/README.md +++ b/README.md @@ -152,18 +152,16 @@ objects represent some thing which could change over time, a value represents the state of that thing at a particular instance of time. This principle is most important to understanding the appropriate use of immutable data. In order to treat Immutable.js collections as values, it's important to use the -`Immutable.is()` function or `.equals()` method to determine value equality -instead of the `===` operator which determines object reference identity. +`Immutable.is()` function or `.equals()` method to determine *value equality* +instead of the `===` operator which determines object *reference identity*. ```js const { Map } = require('immutable') const map1 = Map({ a: 1, b: 2, c: 3 }) -const map2 = map1.set('b', 2) -assert.equal(map1, map2) // uses map1.equals -assert.strictEqual(map1, map2) // uses === -const map3 = map1.set('b', 50) -assert.notEqual(map1, map3) // uses map1.equals +const map2 = Map({ a: 1, b: 2, c: 3 }) +map1.equals(map2) // true +map1 === map2 // false ``` Note: As a performance optimization Immutable.js attempts to return the existing @@ -174,6 +172,14 @@ which would prefer to re-run the function if a deeper equality check could potentially be more costly. The `===` equality check is also used internally by `Immutable.is` and `.equals()` as a performance optimization. + +```js +const { Map } = require('immutable') +const map1 = Map({ a: 1, b: 2, c: 3 }) +const map2 = map1.set('b', 2) // Set to same value +map1 === map2 // true +``` + If an object is immutable, it can be "copied" simply by making another reference to it instead of copying the entire object. Because a reference is much smaller than the object itself, this results in memory savings and a potential boost in @@ -182,8 +188,8 @@ execution speed for programs which rely on copies (such as an undo-stack). ```js const { Map } = require('immutable') -const map1 = Map({ a: 1, b: 2, c: 3 }) -const clone = map1; +const map = Map({ a: 1, b: 2, c: 3 }) +const mapCopy = map; // Look, "copies" are free! ``` [React]: http://facebook.github.io/react/ @@ -279,11 +285,11 @@ shorthand, while Immutable Maps accept keys of any type. const { fromJS } = require('immutable') const obj = { 1: "one" } -Object.keys(obj) // [ "1" ] -assert.equal(obj["1"], obj[1]) // "one" === "one" +console.log(Object.keys(obj)) // [ "1" ] +console.log(obj["1"], obj[1]) // "one", "one" const map = fromJS(obj) -assert.notEqual(map.get("1"), map.get(1)) // "one" !== undefined +console.log(map.get("1"), map.get(1)) // "one", undefined ``` Property access for JavaScript Objects first converts the key to a string, but From aec69b363cca2ca917f5d64556034734d1a6ec3a Mon Sep 17 00:00:00 2001 From: Travis CI Date: Thu, 17 May 2018 15:47:57 +0000 Subject: [PATCH 108/242] Deploy cc239f4baa691df4b6dadc3cbe89e6721903df59 to NPM branch --- dist/immutable.es.js | 89 +- dist/immutable.js | 10341 ++++++++++++++++++++--------------------- 2 files changed, 5214 insertions(+), 5216 deletions(-) diff --git a/dist/immutable.es.js b/dist/immutable.es.js index 6c86fb3e94..10997a5247 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -2088,12 +2088,12 @@ function updateInDeeply( ); } -function setIn$1(collection, keyPath, value) { +function setIn(collection, keyPath, value) { return updateIn(collection, keyPath, NOT_SET, function () { return value; }); } -function setIn$$1(keyPath, v) { - return setIn$1(this, keyPath, v); +function setIn$1(keyPath, v) { + return setIn(this, keyPath, v); } function removeIn(collection, keyPath) { @@ -2104,14 +2104,14 @@ function deleteIn(keyPath) { return removeIn(this, keyPath); } -function update$1(collection, key, notSetValue, updater) { +function update(collection, key, notSetValue, updater) { return updateIn(collection, [key], notSetValue, updater); } -function update$$1(key, notSetValue, updater) { +function update$1(key, notSetValue, updater) { return arguments.length === 1 ? key(this) - : update$1(this, key, notSetValue, updater); + : update(this, key, notSetValue, updater); } function updateIn$1(keyPath, notSetValue, updater) { @@ -2153,7 +2153,7 @@ function mergeIntoKeyedWith(collection, collections, merger) { return collection.withMutations(function (collection) { var mergeIntoCollection = merger ? function (value, key) { - update$1( + update( collection, key, NOT_SET, @@ -2183,14 +2183,14 @@ function mergeWith$1(merger, collection) { return mergeWithSources(collection, sources, merger); } -function mergeDeep$1(collection) { +function mergeDeep(collection) { var sources = [], len = arguments.length - 1; while ( len-- > 0 ) sources[ len ] = arguments[ len + 1 ]; return mergeDeepWithSources(collection, sources); } -function mergeDeepWith$1(merger, collection) { +function mergeDeepWith(merger, collection) { var sources = [], len = arguments.length - 2; while ( len-- > 0 ) sources[ len ] = arguments[ len + 2 ]; @@ -2252,14 +2252,14 @@ function deepMergerWith(merger) { return deepMerger; } -function mergeDeep() { +function mergeDeep$1() { var iters = [], len = arguments.length; while ( len-- ) iters[ len ] = arguments[ len ]; return mergeDeepWithSources(this, iters); } -function mergeDeepWith(merger) { +function mergeDeepWith$1(merger) { var iters = [], len = arguments.length - 1; while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; @@ -2446,14 +2446,14 @@ var MapPrototype = Map.prototype; MapPrototype[IS_MAP_SENTINEL] = true; MapPrototype[DELETE] = MapPrototype.remove; MapPrototype.removeAll = MapPrototype.deleteAll; -MapPrototype.setIn = setIn$$1; +MapPrototype.setIn = setIn$1; MapPrototype.removeIn = MapPrototype.deleteIn = deleteIn; -MapPrototype.update = update$$1; +MapPrototype.update = update$1; MapPrototype.updateIn = updateIn$1; MapPrototype.merge = MapPrototype.concat = merge; MapPrototype.mergeWith = mergeWith; -MapPrototype.mergeDeep = mergeDeep; -MapPrototype.mergeDeepWith = mergeDeepWith; +MapPrototype.mergeDeep = mergeDeep$1; +MapPrototype.mergeDeepWith = mergeDeepWith$1; MapPrototype.mergeIn = mergeIn; MapPrototype.mergeDeepIn = mergeDeepIn; MapPrototype.withMutations = withMutations; @@ -2484,7 +2484,7 @@ ArrayMapNode.prototype.get = function get (shift, keyHash, key, notSetValue) { return notSetValue; }; -ArrayMapNode.prototype.update = function update$$1 (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { +ArrayMapNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { var removed = value === NOT_SET; var entries = this.entries; @@ -2557,7 +2557,7 @@ BitmapIndexedNode.prototype.get = function get (shift, keyHash, key, notSetValue ); }; -BitmapIndexedNode.prototype.update = function update$$1 (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { +BitmapIndexedNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { if (keyHash === undefined) { keyHash = hash(key); } @@ -2639,7 +2639,7 @@ HashArrayMapNode.prototype.get = function get (shift, keyHash, key, notSetValue) : notSetValue; }; -HashArrayMapNode.prototype.update = function update$$1 (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { +HashArrayMapNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { if (keyHash === undefined) { keyHash = hash(key); } @@ -2704,7 +2704,7 @@ HashCollisionNode.prototype.get = function get (shift, keyHash, key, notSetValue return notSetValue; }; -HashCollisionNode.prototype.update = function update$$1 (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { +HashCollisionNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { if (keyHash === undefined) { keyHash = hash(key); } @@ -2774,7 +2774,7 @@ ValueNode.prototype.get = function get (shift, keyHash, key, notSetValue) { return is(key, this.entry[0]) ? this.entry[1] : notSetValue; }; -ValueNode.prototype.update = function update$$1 (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { +ValueNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { var removed = value === NOT_SET; var keyMatch = is(key, this.entry[0]); if (keyMatch ? value === this.entry[1] : removed) { @@ -3324,9 +3324,9 @@ var ListPrototype = List.prototype; ListPrototype[IS_LIST_SENTINEL] = true; ListPrototype[DELETE] = ListPrototype.remove; ListPrototype.merge = ListPrototype.concat; -ListPrototype.setIn = setIn$$1; +ListPrototype.setIn = setIn$1; ListPrototype.deleteIn = ListPrototype.removeIn = deleteIn; -ListPrototype.update = update$$1; +ListPrototype.update = update$1; ListPrototype.updateIn = updateIn$1; ListPrototype.mergeIn = mergeIn; ListPrototype.mergeDeepIn = mergeDeepIn; @@ -3349,7 +3349,7 @@ var VNode = function VNode(array, ownerID) { // TODO: seems like these methods are very similar VNode.prototype.removeBefore = function removeBefore (ownerID, level, index) { - if (index === level ? 1 << level : 0 || this.array.length === 0) { + if (index === level ? 1 << level : this.array.length === 0) { return this; } var originIndex = (index >>> level) & MASK; @@ -4598,7 +4598,7 @@ var Range = (function (IndexedSeq$$1) { var EMPTY_RANGE; -function getIn$1(collection, searchKeyPath, notSetValue) { +function getIn(collection, searchKeyPath, notSetValue) { var keyPath = coerceKeyPath(searchKeyPath); var i = 0; while (i !== keyPath.length) { @@ -4610,16 +4610,16 @@ function getIn$1(collection, searchKeyPath, notSetValue) { return collection; } -function getIn$$1(searchKeyPath, notSetValue) { - return getIn$1(this, searchKeyPath, notSetValue); +function getIn$1(searchKeyPath, notSetValue) { + return getIn(this, searchKeyPath, notSetValue); } -function hasIn$1(collection, keyPath) { - return getIn$1(collection, keyPath, NOT_SET) !== NOT_SET; +function hasIn(collection, keyPath) { + return getIn(collection, keyPath, NOT_SET) !== NOT_SET; } -function hasIn$$1(searchKeyPath) { - return hasIn$1(this, searchKeyPath); +function hasIn$1(searchKeyPath) { + return hasIn(this, searchKeyPath); } function toObject() { @@ -4933,7 +4933,7 @@ mixin(Collection, { return this.find(function (_, key) { return is(key, searchKey); }, undefined, notSetValue); }, - getIn: getIn$$1, + getIn: getIn$1, groupBy: function groupBy(grouper, context) { return groupByFactory(this, grouper, context); @@ -4943,7 +4943,7 @@ mixin(Collection, { return this.get(searchKey, NOT_SET) !== NOT_SET; }, - hasIn: hasIn$$1, + hasIn: hasIn$1, isSubset: function isSubset(iter) { iter = typeof iter.includes === 'function' ? iter : Collection(iter); @@ -5582,16 +5582,16 @@ var RecordPrototype = Record.prototype; RecordPrototype[IS_RECORD_SENTINEL] = true; RecordPrototype[DELETE] = RecordPrototype.remove; RecordPrototype.deleteIn = RecordPrototype.removeIn = deleteIn; -RecordPrototype.getIn = getIn$$1; +RecordPrototype.getIn = getIn$1; RecordPrototype.hasIn = CollectionPrototype.hasIn; RecordPrototype.merge = merge; RecordPrototype.mergeWith = mergeWith; RecordPrototype.mergeIn = mergeIn; -RecordPrototype.mergeDeep = mergeDeep; -RecordPrototype.mergeDeepWith = mergeDeepWith; +RecordPrototype.mergeDeep = mergeDeep$1; +RecordPrototype.mergeDeepWith = mergeDeepWith$1; RecordPrototype.mergeDeepIn = mergeDeepIn; -RecordPrototype.setIn = setIn$$1; -RecordPrototype.update = update$$1; +RecordPrototype.setIn = setIn$1; +RecordPrototype.update = update$1; RecordPrototype.updateIn = updateIn$1; RecordPrototype.withMutations = withMutations; RecordPrototype.asMutable = asMutable; @@ -5779,7 +5779,6 @@ function defaultConverter(k, v) { var version = "4.0.0-rc.9"; -// Functional read/write API var Immutable = { version: version, @@ -5812,23 +5811,23 @@ var Immutable = { isValueObject: isValueObject, get: get, - getIn: getIn$1, + getIn: getIn, has: has, - hasIn: hasIn$1, + hasIn: hasIn, merge: merge$1, - mergeDeep: mergeDeep$1, + mergeDeep: mergeDeep, mergeWith: mergeWith$1, - mergeDeepWith: mergeDeepWith$1, + mergeDeepWith: mergeDeepWith, remove: remove, removeIn: removeIn, set: set, - setIn: setIn$1, - update: update$1, + setIn: setIn, + update: update, updateIn: updateIn, }; // Note: Iterable is deprecated var Iterable = Collection; -export { version, Collection, Iterable, Seq, Map, OrderedMap, List, Stack, Set, OrderedSet, Record, Range, Repeat, is, fromJS, hash, isImmutable, isCollection, isKeyed, isIndexed, isAssociative, isOrdered, isValueObject, get, getIn$1 as getIn, has, hasIn$1 as hasIn, merge$1 as merge, mergeDeep$1 as mergeDeep, mergeWith$1 as mergeWith, mergeDeepWith$1 as mergeDeepWith, remove, removeIn, set, setIn$1 as setIn, update$1 as update, updateIn }; export default Immutable; +export { version, Collection, Iterable, Seq, Map, OrderedMap, List, Stack, Set, OrderedSet, Record, Range, Repeat, is, fromJS, hash, isImmutable, isCollection, isKeyed, isIndexed, isAssociative, isOrdered, isValueObject, get, getIn, has, hasIn, merge$1 as merge, mergeDeep, mergeWith$1 as mergeWith, mergeDeepWith, remove, removeIn, set, setIn, update, updateIn }; diff --git a/dist/immutable.js b/dist/immutable.js index 06a1b14031..7ca9e64c5d 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -6,5875 +6,5874 @@ */ (function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : - typeof define === 'function' && define.amd ? define(['exports'], factory) : - (factory((global.Immutable = {}))); + typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : + typeof define === 'function' && define.amd ? define(['exports'], factory) : + (factory((global.Immutable = {}))); }(this, (function (exports) { 'use strict'; -// Used for setting prototype methods that IE8 chokes on. -var DELETE = 'delete'; - -// Constants describing the size of trie nodes. -var SHIFT = 5; // Resulted in best performance after ______? -var SIZE = 1 << SHIFT; -var MASK = SIZE - 1; - -// A consistent shared value representing "not set" which equals nothing other -// than itself, and nothing that could be provided externally. -var NOT_SET = {}; - -// Boolean references, Rough equivalent of `bool &`. -var CHANGE_LENGTH = { value: false }; -var DID_ALTER = { value: false }; - -function MakeRef(ref) { - ref.value = false; - return ref; -} - -function SetRef(ref) { - ref && (ref.value = true); -} - -// A function which returns a value representing an "owner" for transient writes -// to tries. The return value will only ever equal itself, and will not equal -// the return of any subsequent call of this function. -function OwnerID() {} - -function ensureSize(iter) { - if (iter.size === undefined) { - iter.size = iter.__iterate(returnTrue); - } - return iter.size; -} - -function wrapIndex(iter, index) { - // This implements "is array index" which the ECMAString spec defines as: - // - // A String property name P is an array index if and only if - // ToString(ToUint32(P)) is equal to P and ToUint32(P) is not equal - // to 2^32−1. - // - // http://www.ecma-international.org/ecma-262/6.0/#sec-array-exotic-objects - if (typeof index !== 'number') { - var uint32Index = index >>> 0; // N >>> 0 is shorthand for ToUint32 - if ('' + uint32Index !== index || uint32Index === 4294967295) { - return NaN; - } - index = uint32Index; - } - return index < 0 ? ensureSize(iter) + index : index; -} - -function returnTrue() { - return true; -} - -function wholeSlice(begin, end, size) { - return ( - ((begin === 0 && !isNeg(begin)) || - (size !== undefined && begin <= -size)) && - (end === undefined || (size !== undefined && end >= size)) - ); -} - -function resolveBegin(begin, size) { - return resolveIndex(begin, size, 0); -} - -function resolveEnd(end, size) { - return resolveIndex(end, size, size); -} - -function resolveIndex(index, size, defaultIndex) { - // Sanitize indices using this shorthand for ToInt32(argument) - // http://www.ecma-international.org/ecma-262/6.0/#sec-toint32 - return index === undefined - ? defaultIndex - : isNeg(index) - ? size === Infinity - ? size - : Math.max(0, size + index) | 0 - : size === undefined || size === index - ? index - : Math.min(size, index) | 0; -} - -function isNeg(value) { - // Account for -0 which is negative, but not less than 0. - return value < 0 || (value === 0 && 1 / value === -Infinity); -} - -function isImmutable(maybeImmutable) { - return isCollection(maybeImmutable) || isRecord(maybeImmutable); -} - -function isCollection(maybeCollection) { - return !!(maybeCollection && maybeCollection[IS_ITERABLE_SENTINEL]); -} - -function isKeyed(maybeKeyed) { - return !!(maybeKeyed && maybeKeyed[IS_KEYED_SENTINEL]); -} - -function isIndexed(maybeIndexed) { - return !!(maybeIndexed && maybeIndexed[IS_INDEXED_SENTINEL]); -} - -function isAssociative(maybeAssociative) { - return isKeyed(maybeAssociative) || isIndexed(maybeAssociative); -} - -function isOrdered(maybeOrdered) { - return !!(maybeOrdered && maybeOrdered[IS_ORDERED_SENTINEL]); -} - -function isRecord(maybeRecord) { - return !!(maybeRecord && maybeRecord[IS_RECORD_SENTINEL]); -} - -function isValueObject(maybeValue) { - return !!( - maybeValue && - typeof maybeValue.equals === 'function' && - typeof maybeValue.hashCode === 'function' - ); -} - -var IS_ITERABLE_SENTINEL = '@@__IMMUTABLE_ITERABLE__@@'; -var IS_KEYED_SENTINEL = '@@__IMMUTABLE_KEYED__@@'; -var IS_INDEXED_SENTINEL = '@@__IMMUTABLE_INDEXED__@@'; -var IS_ORDERED_SENTINEL = '@@__IMMUTABLE_ORDERED__@@'; -var IS_RECORD_SENTINEL = '@@__IMMUTABLE_RECORD__@@'; - -var Collection = function Collection(value) { - return isCollection(value) ? value : Seq(value); -}; - -var KeyedCollection = (function (Collection) { - function KeyedCollection(value) { - return isKeyed(value) ? value : KeyedSeq(value); - } - - if ( Collection ) KeyedCollection.__proto__ = Collection; - KeyedCollection.prototype = Object.create( Collection && Collection.prototype ); - KeyedCollection.prototype.constructor = KeyedCollection; - - return KeyedCollection; -}(Collection)); - -var IndexedCollection = (function (Collection) { - function IndexedCollection(value) { - return isIndexed(value) ? value : IndexedSeq(value); - } - - if ( Collection ) IndexedCollection.__proto__ = Collection; - IndexedCollection.prototype = Object.create( Collection && Collection.prototype ); - IndexedCollection.prototype.constructor = IndexedCollection; - - return IndexedCollection; -}(Collection)); - -var SetCollection = (function (Collection) { - function SetCollection(value) { - return isCollection(value) && !isAssociative(value) ? value : SetSeq(value); - } - - if ( Collection ) SetCollection.__proto__ = Collection; - SetCollection.prototype = Object.create( Collection && Collection.prototype ); - SetCollection.prototype.constructor = SetCollection; - - return SetCollection; -}(Collection)); - -Collection.Keyed = KeyedCollection; -Collection.Indexed = IndexedCollection; -Collection.Set = SetCollection; - -var ITERATE_KEYS = 0; -var ITERATE_VALUES = 1; -var ITERATE_ENTRIES = 2; - -var REAL_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator; -var FAUX_ITERATOR_SYMBOL = '@@iterator'; + // Used for setting prototype methods that IE8 chokes on. + var DELETE = 'delete'; -var ITERATOR_SYMBOL = REAL_ITERATOR_SYMBOL || FAUX_ITERATOR_SYMBOL; + // Constants describing the size of trie nodes. + var SHIFT = 5; // Resulted in best performance after ______? + var SIZE = 1 << SHIFT; + var MASK = SIZE - 1; -var Iterator = function Iterator(next) { - this.next = next; -}; + // A consistent shared value representing "not set" which equals nothing other + // than itself, and nothing that could be provided externally. + var NOT_SET = {}; -Iterator.prototype.toString = function toString () { - return '[Iterator]'; -}; + // Boolean references, Rough equivalent of `bool &`. + var CHANGE_LENGTH = { value: false }; + var DID_ALTER = { value: false }; -Iterator.KEYS = ITERATE_KEYS; -Iterator.VALUES = ITERATE_VALUES; -Iterator.ENTRIES = ITERATE_ENTRIES; - -Iterator.prototype.inspect = Iterator.prototype.toSource = function() { - return this.toString(); -}; -Iterator.prototype[ITERATOR_SYMBOL] = function() { - return this; -}; - -function iteratorValue(type, k, v, iteratorResult) { - var value = type === 0 ? k : type === 1 ? v : [k, v]; - iteratorResult - ? (iteratorResult.value = value) - : (iteratorResult = { - value: value, - done: false, - }); - return iteratorResult; -} - -function iteratorDone() { - return { value: undefined, done: true }; -} - -function hasIterator(maybeIterable) { - return !!getIteratorFn(maybeIterable); -} + function MakeRef(ref) { + ref.value = false; + return ref; + } -function isIterator(maybeIterator) { - return maybeIterator && typeof maybeIterator.next === 'function'; -} + function SetRef(ref) { + ref && (ref.value = true); + } -function getIterator(iterable) { - var iteratorFn = getIteratorFn(iterable); - return iteratorFn && iteratorFn.call(iterable); -} + // A function which returns a value representing an "owner" for transient writes + // to tries. The return value will only ever equal itself, and will not equal + // the return of any subsequent call of this function. + function OwnerID() {} -function getIteratorFn(iterable) { - var iteratorFn = - iterable && - ((REAL_ITERATOR_SYMBOL && iterable[REAL_ITERATOR_SYMBOL]) || - iterable[FAUX_ITERATOR_SYMBOL]); - if (typeof iteratorFn === 'function') { - return iteratorFn; + function ensureSize(iter) { + if (iter.size === undefined) { + iter.size = iter.__iterate(returnTrue); + } + return iter.size; } -} -var hasOwnProperty = Object.prototype.hasOwnProperty; + function wrapIndex(iter, index) { + // This implements "is array index" which the ECMAString spec defines as: + // + // A String property name P is an array index if and only if + // ToString(ToUint32(P)) is equal to P and ToUint32(P) is not equal + // to 2^32−1. + // + // http://www.ecma-international.org/ecma-262/6.0/#sec-array-exotic-objects + if (typeof index !== 'number') { + var uint32Index = index >>> 0; // N >>> 0 is shorthand for ToUint32 + if ('' + uint32Index !== index || uint32Index === 4294967295) { + return NaN; + } + index = uint32Index; + } + return index < 0 ? ensureSize(iter) + index : index; + } -function isArrayLike(value) { - if (Array.isArray(value) || typeof value === 'string') { + function returnTrue() { return true; } - return ( - value && - typeof value === 'object' && - Number.isInteger(value.length) && - value.length >= 0 && - (value.length === 0 - ? // Only {length: 0} is considered Array-like. - Object.keys(value).length === 1 - : // An object is only Array-like if it has a property where the last value - // in the array-like may be found (which could be undefined). - value.hasOwnProperty(value.length - 1)) - ); -} - -var Seq = (function (Collection$$1) { - function Seq(value) { - return value === null || value === undefined - ? emptySequence() - : isImmutable(value) - ? value.toSeq() - : seqFromValue(value); - } - - if ( Collection$$1 ) Seq.__proto__ = Collection$$1; - Seq.prototype = Object.create( Collection$$1 && Collection$$1.prototype ); - Seq.prototype.constructor = Seq; - - Seq.prototype.toSeq = function toSeq () { - return this; - }; - - Seq.prototype.toString = function toString () { - return this.__toString('Seq {', '}'); - }; + function wholeSlice(begin, end, size) { + return ( + ((begin === 0 && !isNeg(begin)) || + (size !== undefined && begin <= -size)) && + (end === undefined || (size !== undefined && end >= size)) + ); + } - Seq.prototype.cacheResult = function cacheResult () { - if (!this._cache && this.__iterateUncached) { - this._cache = this.entrySeq().toArray(); - this.size = this._cache.length; - } - return this; - }; + function resolveBegin(begin, size) { + return resolveIndex(begin, size, 0); + } - // abstract __iterateUncached(fn, reverse) + function resolveEnd(end, size) { + return resolveIndex(end, size, size); + } - Seq.prototype.__iterate = function __iterate (fn, reverse) { - var this$1 = this; + function resolveIndex(index, size, defaultIndex) { + // Sanitize indices using this shorthand for ToInt32(argument) + // http://www.ecma-international.org/ecma-262/6.0/#sec-toint32 + return index === undefined + ? defaultIndex + : isNeg(index) + ? size === Infinity + ? size + : Math.max(0, size + index) | 0 + : size === undefined || size === index + ? index + : Math.min(size, index) | 0; + } - var cache = this._cache; - if (cache) { - var size = cache.length; - var i = 0; - while (i !== size) { - var entry = cache[reverse ? size - ++i : i++]; - if (fn(entry[1], entry[0], this$1) === false) { - break; - } - } - return i; - } - return this.__iterateUncached(fn, reverse); - }; + function isNeg(value) { + // Account for -0 which is negative, but not less than 0. + return value < 0 || (value === 0 && 1 / value === -Infinity); + } - // abstract __iteratorUncached(type, reverse) + function isImmutable(maybeImmutable) { + return isCollection(maybeImmutable) || isRecord(maybeImmutable); + } - Seq.prototype.__iterator = function __iterator (type, reverse) { - var cache = this._cache; - if (cache) { - var size = cache.length; - var i = 0; - return new Iterator(function () { - if (i === size) { - return iteratorDone(); - } - var entry = cache[reverse ? size - ++i : i++]; - return iteratorValue(type, entry[0], entry[1]); - }); - } - return this.__iteratorUncached(type, reverse); - }; + function isCollection(maybeCollection) { + return !!(maybeCollection && maybeCollection[IS_ITERABLE_SENTINEL]); + } - return Seq; -}(Collection)); + function isKeyed(maybeKeyed) { + return !!(maybeKeyed && maybeKeyed[IS_KEYED_SENTINEL]); + } -var KeyedSeq = (function (Seq) { - function KeyedSeq(value) { - return value === null || value === undefined - ? emptySequence().toKeyedSeq() - : isCollection(value) - ? isKeyed(value) - ? value.toSeq() - : value.fromEntrySeq() - : isRecord(value) - ? value.toSeq() - : keyedSeqFromValue(value); + function isIndexed(maybeIndexed) { + return !!(maybeIndexed && maybeIndexed[IS_INDEXED_SENTINEL]); } - if ( Seq ) KeyedSeq.__proto__ = Seq; - KeyedSeq.prototype = Object.create( Seq && Seq.prototype ); - KeyedSeq.prototype.constructor = KeyedSeq; + function isAssociative(maybeAssociative) { + return isKeyed(maybeAssociative) || isIndexed(maybeAssociative); + } - KeyedSeq.prototype.toKeyedSeq = function toKeyedSeq () { - return this; - }; + function isOrdered(maybeOrdered) { + return !!(maybeOrdered && maybeOrdered[IS_ORDERED_SENTINEL]); + } - return KeyedSeq; -}(Seq)); + function isRecord(maybeRecord) { + return !!(maybeRecord && maybeRecord[IS_RECORD_SENTINEL]); + } -var IndexedSeq = (function (Seq) { - function IndexedSeq(value) { - return value === null || value === undefined - ? emptySequence() - : isCollection(value) - ? isKeyed(value) - ? value.entrySeq() - : value.toIndexedSeq() - : isRecord(value) - ? value.toSeq().entrySeq() - : indexedSeqFromValue(value); + function isValueObject(maybeValue) { + return !!( + maybeValue && + typeof maybeValue.equals === 'function' && + typeof maybeValue.hashCode === 'function' + ); } - if ( Seq ) IndexedSeq.__proto__ = Seq; - IndexedSeq.prototype = Object.create( Seq && Seq.prototype ); - IndexedSeq.prototype.constructor = IndexedSeq; + var IS_ITERABLE_SENTINEL = '@@__IMMUTABLE_ITERABLE__@@'; + var IS_KEYED_SENTINEL = '@@__IMMUTABLE_KEYED__@@'; + var IS_INDEXED_SENTINEL = '@@__IMMUTABLE_INDEXED__@@'; + var IS_ORDERED_SENTINEL = '@@__IMMUTABLE_ORDERED__@@'; + var IS_RECORD_SENTINEL = '@@__IMMUTABLE_RECORD__@@'; - IndexedSeq.of = function of (/*...values*/) { - return IndexedSeq(arguments); + var Collection = function Collection(value) { + return isCollection(value) ? value : Seq(value); }; - IndexedSeq.prototype.toIndexedSeq = function toIndexedSeq () { - return this; - }; + var KeyedCollection = (function (Collection) { + function KeyedCollection(value) { + return isKeyed(value) ? value : KeyedSeq(value); + } - IndexedSeq.prototype.toString = function toString () { - return this.__toString('Seq [', ']'); - }; + if ( Collection ) KeyedCollection.__proto__ = Collection; + KeyedCollection.prototype = Object.create( Collection && Collection.prototype ); + KeyedCollection.prototype.constructor = KeyedCollection; - return IndexedSeq; -}(Seq)); + return KeyedCollection; + }(Collection)); -var SetSeq = (function (Seq) { - function SetSeq(value) { - return (isCollection(value) && !isAssociative(value) - ? value - : IndexedSeq(value) - ).toSetSeq(); - } + var IndexedCollection = (function (Collection) { + function IndexedCollection(value) { + return isIndexed(value) ? value : IndexedSeq(value); + } - if ( Seq ) SetSeq.__proto__ = Seq; - SetSeq.prototype = Object.create( Seq && Seq.prototype ); - SetSeq.prototype.constructor = SetSeq; + if ( Collection ) IndexedCollection.__proto__ = Collection; + IndexedCollection.prototype = Object.create( Collection && Collection.prototype ); + IndexedCollection.prototype.constructor = IndexedCollection; - SetSeq.of = function of (/*...values*/) { - return SetSeq(arguments); - }; + return IndexedCollection; + }(Collection)); - SetSeq.prototype.toSetSeq = function toSetSeq () { - return this; - }; + var SetCollection = (function (Collection) { + function SetCollection(value) { + return isCollection(value) && !isAssociative(value) ? value : SetSeq(value); + } - return SetSeq; -}(Seq)); + if ( Collection ) SetCollection.__proto__ = Collection; + SetCollection.prototype = Object.create( Collection && Collection.prototype ); + SetCollection.prototype.constructor = SetCollection; -Seq.isSeq = isSeq; -Seq.Keyed = KeyedSeq; -Seq.Set = SetSeq; -Seq.Indexed = IndexedSeq; + return SetCollection; + }(Collection)); -var IS_SEQ_SENTINEL = '@@__IMMUTABLE_SEQ__@@'; + Collection.Keyed = KeyedCollection; + Collection.Indexed = IndexedCollection; + Collection.Set = SetCollection; -Seq.prototype[IS_SEQ_SENTINEL] = true; + var ITERATE_KEYS = 0; + var ITERATE_VALUES = 1; + var ITERATE_ENTRIES = 2; -// #pragma Root Sequences + var REAL_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator; + var FAUX_ITERATOR_SYMBOL = '@@iterator'; -var ArraySeq = (function (IndexedSeq) { - function ArraySeq(array) { - this._array = array; - this.size = array.length; - } + var ITERATOR_SYMBOL = REAL_ITERATOR_SYMBOL || FAUX_ITERATOR_SYMBOL; - if ( IndexedSeq ) ArraySeq.__proto__ = IndexedSeq; - ArraySeq.prototype = Object.create( IndexedSeq && IndexedSeq.prototype ); - ArraySeq.prototype.constructor = ArraySeq; + var Iterator = function Iterator(next) { + this.next = next; + }; - ArraySeq.prototype.get = function get (index, notSetValue) { - return this.has(index) ? this._array[wrapIndex(this, index)] : notSetValue; + Iterator.prototype.toString = function toString () { + return '[Iterator]'; }; - ArraySeq.prototype.__iterate = function __iterate (fn, reverse) { - var this$1 = this; + Iterator.KEYS = ITERATE_KEYS; + Iterator.VALUES = ITERATE_VALUES; + Iterator.ENTRIES = ITERATE_ENTRIES; - var array = this._array; - var size = array.length; - var i = 0; - while (i !== size) { - var ii = reverse ? size - ++i : i++; - if (fn(array[ii], ii, this$1) === false) { - break; - } - } - return i; + Iterator.prototype.inspect = Iterator.prototype.toSource = function() { + return this.toString(); }; - - ArraySeq.prototype.__iterator = function __iterator (type, reverse) { - var array = this._array; - var size = array.length; - var i = 0; - return new Iterator(function () { - if (i === size) { - return iteratorDone(); - } - var ii = reverse ? size - ++i : i++; - return iteratorValue(type, ii, array[ii]); - }); + Iterator.prototype[ITERATOR_SYMBOL] = function() { + return this; }; - return ArraySeq; -}(IndexedSeq)); - -var ObjectSeq = (function (KeyedSeq) { - function ObjectSeq(object) { - var keys = Object.keys(object); - this._object = object; - this._keys = keys; - this.size = keys.length; + function iteratorValue(type, k, v, iteratorResult) { + var value = type === 0 ? k : type === 1 ? v : [k, v]; + iteratorResult + ? (iteratorResult.value = value) + : (iteratorResult = { + value: value, + done: false, + }); + return iteratorResult; } - if ( KeyedSeq ) ObjectSeq.__proto__ = KeyedSeq; - ObjectSeq.prototype = Object.create( KeyedSeq && KeyedSeq.prototype ); - ObjectSeq.prototype.constructor = ObjectSeq; + function iteratorDone() { + return { value: undefined, done: true }; + } - ObjectSeq.prototype.get = function get (key, notSetValue) { - if (notSetValue !== undefined && !this.has(key)) { - return notSetValue; - } - return this._object[key]; - }; + function hasIterator(maybeIterable) { + return !!getIteratorFn(maybeIterable); + } - ObjectSeq.prototype.has = function has (key) { - return hasOwnProperty.call(this._object, key); - }; + function isIterator(maybeIterator) { + return maybeIterator && typeof maybeIterator.next === 'function'; + } - ObjectSeq.prototype.__iterate = function __iterate (fn, reverse) { - var this$1 = this; + function getIterator(iterable) { + var iteratorFn = getIteratorFn(iterable); + return iteratorFn && iteratorFn.call(iterable); + } - var object = this._object; - var keys = this._keys; - var size = keys.length; - var i = 0; - while (i !== size) { - var key = keys[reverse ? size - ++i : i++]; - if (fn(object[key], key, this$1) === false) { - break; - } + function getIteratorFn(iterable) { + var iteratorFn = + iterable && + ((REAL_ITERATOR_SYMBOL && iterable[REAL_ITERATOR_SYMBOL]) || + iterable[FAUX_ITERATOR_SYMBOL]); + if (typeof iteratorFn === 'function') { + return iteratorFn; } - return i; - }; + } - ObjectSeq.prototype.__iterator = function __iterator (type, reverse) { - var object = this._object; - var keys = this._keys; - var size = keys.length; - var i = 0; - return new Iterator(function () { - if (i === size) { - return iteratorDone(); - } - var key = keys[reverse ? size - ++i : i++]; - return iteratorValue(type, key, object[key]); - }); - }; + var hasOwnProperty = Object.prototype.hasOwnProperty; - return ObjectSeq; -}(KeyedSeq)); -ObjectSeq.prototype[IS_ORDERED_SENTINEL] = true; + function isArrayLike(value) { + if (Array.isArray(value) || typeof value === 'string') { + return true; + } -var CollectionSeq = (function (IndexedSeq) { - function CollectionSeq(collection) { - this._collection = collection; - this.size = collection.length || collection.size; + return ( + value && + typeof value === 'object' && + Number.isInteger(value.length) && + value.length >= 0 && + (value.length === 0 + ? // Only {length: 0} is considered Array-like. + Object.keys(value).length === 1 + : // An object is only Array-like if it has a property where the last value + // in the array-like may be found (which could be undefined). + value.hasOwnProperty(value.length - 1)) + ); } - if ( IndexedSeq ) CollectionSeq.__proto__ = IndexedSeq; - CollectionSeq.prototype = Object.create( IndexedSeq && IndexedSeq.prototype ); - CollectionSeq.prototype.constructor = CollectionSeq; - - CollectionSeq.prototype.__iterateUncached = function __iterateUncached (fn, reverse) { - var this$1 = this; - - if (reverse) { - return this.cacheResult().__iterate(fn, reverse); - } - var collection = this._collection; - var iterator = getIterator(collection); - var iterations = 0; - if (isIterator(iterator)) { - var step; - while (!(step = iterator.next()).done) { - if (fn(step.value, iterations++, this$1) === false) { - break; - } - } + var Seq = (function (Collection$$1) { + function Seq(value) { + return value === null || value === undefined + ? emptySequence() + : isImmutable(value) + ? value.toSeq() + : seqFromValue(value); } - return iterations; - }; - CollectionSeq.prototype.__iteratorUncached = function __iteratorUncached (type, reverse) { - if (reverse) { - return this.cacheResult().__iterator(type, reverse); - } - var collection = this._collection; - var iterator = getIterator(collection); - if (!isIterator(iterator)) { - return new Iterator(iteratorDone); - } - var iterations = 0; - return new Iterator(function () { - var step = iterator.next(); - return step.done ? step : iteratorValue(type, iterations++, step.value); - }); - }; + if ( Collection$$1 ) Seq.__proto__ = Collection$$1; + Seq.prototype = Object.create( Collection$$1 && Collection$$1.prototype ); + Seq.prototype.constructor = Seq; - return CollectionSeq; -}(IndexedSeq)); + Seq.prototype.toSeq = function toSeq () { + return this; + }; -var IteratorSeq = (function (IndexedSeq) { - function IteratorSeq(iterator) { - this._iterator = iterator; - this._iteratorCache = []; - } + Seq.prototype.toString = function toString () { + return this.__toString('Seq {', '}'); + }; - if ( IndexedSeq ) IteratorSeq.__proto__ = IndexedSeq; - IteratorSeq.prototype = Object.create( IndexedSeq && IndexedSeq.prototype ); - IteratorSeq.prototype.constructor = IteratorSeq; + Seq.prototype.cacheResult = function cacheResult () { + if (!this._cache && this.__iterateUncached) { + this._cache = this.entrySeq().toArray(); + this.size = this._cache.length; + } + return this; + }; - IteratorSeq.prototype.__iterateUncached = function __iterateUncached (fn, reverse) { - var this$1 = this; + // abstract __iterateUncached(fn, reverse) - if (reverse) { - return this.cacheResult().__iterate(fn, reverse); - } - var iterator = this._iterator; - var cache = this._iteratorCache; - var iterations = 0; - while (iterations < cache.length) { - if (fn(cache[iterations], iterations++, this$1) === false) { - return iterations; - } - } - var step; - while (!(step = iterator.next()).done) { - var val = step.value; - cache[iterations] = val; - if (fn(val, iterations++, this$1) === false) { - break; - } - } - return iterations; - }; + Seq.prototype.__iterate = function __iterate (fn, reverse) { + var this$1 = this; - IteratorSeq.prototype.__iteratorUncached = function __iteratorUncached (type, reverse) { - if (reverse) { - return this.cacheResult().__iterator(type, reverse); - } - var iterator = this._iterator; - var cache = this._iteratorCache; - var iterations = 0; - return new Iterator(function () { - if (iterations >= cache.length) { - var step = iterator.next(); - if (step.done) { - return step; + var cache = this._cache; + if (cache) { + var size = cache.length; + var i = 0; + while (i !== size) { + var entry = cache[reverse ? size - ++i : i++]; + if (fn(entry[1], entry[0], this$1) === false) { + break; + } } - cache[iterations] = step.value; + return i; } - return iteratorValue(type, iterations, cache[iterations++]); - }); - }; + return this.__iterateUncached(fn, reverse); + }; - return IteratorSeq; -}(IndexedSeq)); - -// # pragma Helper functions - -function isSeq(maybeSeq) { - return !!(maybeSeq && maybeSeq[IS_SEQ_SENTINEL]); -} - -var EMPTY_SEQ; - -function emptySequence() { - return EMPTY_SEQ || (EMPTY_SEQ = new ArraySeq([])); -} - -function keyedSeqFromValue(value) { - var seq = Array.isArray(value) - ? new ArraySeq(value) - : isIterator(value) - ? new IteratorSeq(value) - : hasIterator(value) - ? new CollectionSeq(value) - : undefined; - if (seq) { - return seq.fromEntrySeq(); - } - if (typeof value === 'object') { - return new ObjectSeq(value); - } - throw new TypeError( - 'Expected Array or collection object of [k, v] entries, or keyed object: ' + - value - ); -} - -function indexedSeqFromValue(value) { - var seq = maybeIndexedSeqFromValue(value); - if (seq) { - return seq; - } - throw new TypeError( - 'Expected Array or collection object of values: ' + value - ); -} - -function seqFromValue(value) { - var seq = maybeIndexedSeqFromValue(value); - if (seq) { - return seq; - } - if (typeof value === 'object') { - return new ObjectSeq(value); - } - throw new TypeError( - 'Expected Array or collection object of values, or keyed object: ' + value - ); -} - -function maybeIndexedSeqFromValue(value) { - return isArrayLike(value) - ? new ArraySeq(value) - : isIterator(value) - ? new IteratorSeq(value) - : hasIterator(value) - ? new CollectionSeq(value) - : undefined; -} + // abstract __iteratorUncached(type, reverse) -/** - * An extension of the "same-value" algorithm as [described for use by ES6 Map - * and Set](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map#Key_equality) - * - * NaN is considered the same as NaN, however -0 and 0 are considered the same - * value, which is different from the algorithm described by - * [`Object.is`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is). - * - * This is extended further to allow Objects to describe the values they - * represent, by way of `valueOf` or `equals` (and `hashCode`). - * - * Note: because of this extension, the key equality of Immutable.Map and the - * value equality of Immutable.Set will differ from ES6 Map and Set. - * - * ### Defining custom values - * - * The easiest way to describe the value an object represents is by implementing - * `valueOf`. For example, `Date` represents a value by returning a unix - * timestamp for `valueOf`: - * - * var date1 = new Date(1234567890000); // Fri Feb 13 2009 ... - * var date2 = new Date(1234567890000); - * date1.valueOf(); // 1234567890000 - * assert( date1 !== date2 ); - * assert( Immutable.is( date1, date2 ) ); - * - * Note: overriding `valueOf` may have other implications if you use this object - * where JavaScript expects a primitive, such as implicit string coercion. - * - * For more complex types, especially collections, implementing `valueOf` may - * not be performant. An alternative is to implement `equals` and `hashCode`. - * - * `equals` takes another object, presumably of similar type, and returns true - * if it is equal. Equality is symmetrical, so the same result should be - * returned if this and the argument are flipped. - * - * assert( a.equals(b) === b.equals(a) ); - * - * `hashCode` returns a 32bit integer number representing the object which will - * be used to determine how to store the value object in a Map or Set. You must - * provide both or neither methods, one must not exist without the other. - * - * Also, an important relationship between these methods must be upheld: if two - * values are equal, they *must* return the same hashCode. If the values are not - * equal, they might have the same hashCode; this is called a hash collision, - * and while undesirable for performance reasons, it is acceptable. - * - * if (a.equals(b)) { - * assert( a.hashCode() === b.hashCode() ); - * } - * - * All Immutable collections are Value Objects: they implement `equals()` - * and `hashCode()`. - */ -function is(valueA, valueB) { - if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) { - return true; - } - if (!valueA || !valueB) { - return false; - } - if ( - typeof valueA.valueOf === 'function' && - typeof valueB.valueOf === 'function' - ) { - valueA = valueA.valueOf(); - valueB = valueB.valueOf(); - if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) { - return true; - } - if (!valueA || !valueB) { - return false; - } - } - return !!( - isValueObject(valueA) && - isValueObject(valueB) && - valueA.equals(valueB) - ); -} - -var imul = - typeof Math.imul === 'function' && Math.imul(0xffffffff, 2) === -2 - ? Math.imul - : function imul(a, b) { - a |= 0; // int - b |= 0; // int - var c = a & 0xffff; - var d = b & 0xffff; - // Shift by 0 fixes the sign on the high part. - return (c * d + ((((a >>> 16) * d + c * (b >>> 16)) << 16) >>> 0)) | 0; // int - }; + Seq.prototype.__iterator = function __iterator (type, reverse) { + var cache = this._cache; + if (cache) { + var size = cache.length; + var i = 0; + return new Iterator(function () { + if (i === size) { + return iteratorDone(); + } + var entry = cache[reverse ? size - ++i : i++]; + return iteratorValue(type, entry[0], entry[1]); + }); + } + return this.__iteratorUncached(type, reverse); + }; -// v8 has an optimization for storing 31-bit signed numbers. -// Values which have either 00 or 11 as the high order bits qualify. -// This function drops the highest order bit in a signed number, maintaining -// the sign bit. -function smi(i32) { - return ((i32 >>> 1) & 0x40000000) | (i32 & 0xbfffffff); -} + return Seq; + }(Collection)); -function hash(o) { - if (o === false || o === null || o === undefined) { - return 0; - } - if (typeof o.valueOf === 'function') { - o = o.valueOf(); - if (o === false || o === null || o === undefined) { - return 0; - } - } - if (o === true) { - return 1; - } - var type = typeof o; - if (type === 'number') { - if (o !== o || o === Infinity) { - return 0; - } - var h = o | 0; - if (h !== o) { - h ^= o * 0xffffffff; - } - while (o > 0xffffffff) { - o /= 0xffffffff; - h ^= o; - } - return smi(h); - } - if (type === 'string') { - return o.length > STRING_HASH_CACHE_MIN_STRLEN - ? cachedHashString(o) - : hashString(o); - } - if (typeof o.hashCode === 'function') { - // Drop any high bits from accidentally long hash codes. - return smi(o.hashCode()); - } - if (type === 'object' || type === 'function') { - return hashJSObj(o); - } - if (typeof o.toString === 'function') { - return hashString(o.toString()); - } - throw new Error('Value type ' + type + ' cannot be hashed.'); -} - -function cachedHashString(string) { - var hashed = stringHashCache[string]; - if (hashed === undefined) { - hashed = hashString(string); - if (STRING_HASH_CACHE_SIZE === STRING_HASH_CACHE_MAX_SIZE) { - STRING_HASH_CACHE_SIZE = 0; - stringHashCache = {}; - } - STRING_HASH_CACHE_SIZE++; - stringHashCache[string] = hashed; - } - return hashed; -} - -// http://jsperf.com/hashing-strings -function hashString(string) { - // This is the hash from JVM - // The hash code for a string is computed as - // s[0] * 31 ^ (n - 1) + s[1] * 31 ^ (n - 2) + ... + s[n - 1], - // where s[i] is the ith character of the string and n is the length of - // the string. We "mod" the result to make it between 0 (inclusive) and 2^31 - // (exclusive) by dropping high bits. - var hashed = 0; - for (var ii = 0; ii < string.length; ii++) { - hashed = (31 * hashed + string.charCodeAt(ii)) | 0; - } - return smi(hashed); -} - -function hashJSObj(obj) { - var hashed; - if (usingWeakMap) { - hashed = weakMap.get(obj); - if (hashed !== undefined) { - return hashed; + var KeyedSeq = (function (Seq) { + function KeyedSeq(value) { + return value === null || value === undefined + ? emptySequence().toKeyedSeq() + : isCollection(value) + ? isKeyed(value) + ? value.toSeq() + : value.fromEntrySeq() + : isRecord(value) + ? value.toSeq() + : keyedSeqFromValue(value); } - } - hashed = obj[UID_HASH_KEY]; - if (hashed !== undefined) { - return hashed; - } + if ( Seq ) KeyedSeq.__proto__ = Seq; + KeyedSeq.prototype = Object.create( Seq && Seq.prototype ); + KeyedSeq.prototype.constructor = KeyedSeq; - if (!canDefineProperty) { - hashed = obj.propertyIsEnumerable && obj.propertyIsEnumerable[UID_HASH_KEY]; - if (hashed !== undefined) { - return hashed; - } + KeyedSeq.prototype.toKeyedSeq = function toKeyedSeq () { + return this; + }; - hashed = getIENodeHash(obj); - if (hashed !== undefined) { - return hashed; + return KeyedSeq; + }(Seq)); + + var IndexedSeq = (function (Seq) { + function IndexedSeq(value) { + return value === null || value === undefined + ? emptySequence() + : isCollection(value) + ? isKeyed(value) + ? value.entrySeq() + : value.toIndexedSeq() + : isRecord(value) + ? value.toSeq().entrySeq() + : indexedSeqFromValue(value); } - } - hashed = ++objHashUID; - if (objHashUID & 0x40000000) { - objHashUID = 0; - } + if ( Seq ) IndexedSeq.__proto__ = Seq; + IndexedSeq.prototype = Object.create( Seq && Seq.prototype ); + IndexedSeq.prototype.constructor = IndexedSeq; - if (usingWeakMap) { - weakMap.set(obj, hashed); - } else if (isExtensible !== undefined && isExtensible(obj) === false) { - throw new Error('Non-extensible objects are not allowed as keys.'); - } else if (canDefineProperty) { - Object.defineProperty(obj, UID_HASH_KEY, { - enumerable: false, - configurable: false, - writable: false, - value: hashed, - }); - } else if ( - obj.propertyIsEnumerable !== undefined && - obj.propertyIsEnumerable === obj.constructor.prototype.propertyIsEnumerable - ) { - // Since we can't define a non-enumerable property on the object - // we'll hijack one of the less-used non-enumerable properties to - // save our hash on it. Since this is a function it will not show up in - // `JSON.stringify` which is what we want. - obj.propertyIsEnumerable = function() { - return this.constructor.prototype.propertyIsEnumerable.apply( - this, - arguments - ); + IndexedSeq.of = function of (/*...values*/) { + return IndexedSeq(arguments); }; - obj.propertyIsEnumerable[UID_HASH_KEY] = hashed; - } else if (obj.nodeType !== undefined) { - // At this point we couldn't get the IE `uniqueID` to use as a hash - // and we couldn't use a non-enumerable property to exploit the - // dontEnum bug so we simply add the `UID_HASH_KEY` on the node - // itself. - obj[UID_HASH_KEY] = hashed; - } else { - throw new Error('Unable to set a non-enumerable property on object.'); - } - return hashed; -} + IndexedSeq.prototype.toIndexedSeq = function toIndexedSeq () { + return this; + }; -// Get references to ES5 object methods. -var isExtensible = Object.isExtensible; + IndexedSeq.prototype.toString = function toString () { + return this.__toString('Seq [', ']'); + }; -// True if Object.defineProperty works as expected. IE8 fails this test. -var canDefineProperty = (function() { - try { - Object.defineProperty({}, '@', {}); - return true; - } catch (e) { - return false; - } -})(); + return IndexedSeq; + }(Seq)); -// IE has a `uniqueID` property on DOM nodes. We can construct the hash from it -// and avoid memory leaks from the IE cloneNode bug. -function getIENodeHash(node) { - if (node && node.nodeType > 0) { - switch (node.nodeType) { - case 1: // Element - return node.uniqueID; - case 9: // Document - return node.documentElement && node.documentElement.uniqueID; + var SetSeq = (function (Seq) { + function SetSeq(value) { + return (isCollection(value) && !isAssociative(value) + ? value + : IndexedSeq(value) + ).toSetSeq(); } - } -} - -// If possible, use a WeakMap. -var usingWeakMap = typeof WeakMap === 'function'; -var weakMap; -if (usingWeakMap) { - weakMap = new WeakMap(); -} -var objHashUID = 0; + if ( Seq ) SetSeq.__proto__ = Seq; + SetSeq.prototype = Object.create( Seq && Seq.prototype ); + SetSeq.prototype.constructor = SetSeq; -var UID_HASH_KEY = '__immutablehash__'; -if (typeof Symbol === 'function') { - UID_HASH_KEY = Symbol(UID_HASH_KEY); -} - -var STRING_HASH_CACHE_MIN_STRLEN = 16; -var STRING_HASH_CACHE_MAX_SIZE = 255; -var STRING_HASH_CACHE_SIZE = 0; -var stringHashCache = {}; + SetSeq.of = function of (/*...values*/) { + return SetSeq(arguments); + }; -var ToKeyedSequence = (function (KeyedSeq$$1) { - function ToKeyedSequence(indexed, useKeys) { - this._iter = indexed; - this._useKeys = useKeys; - this.size = indexed.size; - } + SetSeq.prototype.toSetSeq = function toSetSeq () { + return this; + }; - if ( KeyedSeq$$1 ) ToKeyedSequence.__proto__ = KeyedSeq$$1; - ToKeyedSequence.prototype = Object.create( KeyedSeq$$1 && KeyedSeq$$1.prototype ); - ToKeyedSequence.prototype.constructor = ToKeyedSequence; + return SetSeq; + }(Seq)); - ToKeyedSequence.prototype.get = function get (key, notSetValue) { - return this._iter.get(key, notSetValue); - }; + Seq.isSeq = isSeq; + Seq.Keyed = KeyedSeq; + Seq.Set = SetSeq; + Seq.Indexed = IndexedSeq; - ToKeyedSequence.prototype.has = function has (key) { - return this._iter.has(key); - }; + var IS_SEQ_SENTINEL = '@@__IMMUTABLE_SEQ__@@'; - ToKeyedSequence.prototype.valueSeq = function valueSeq () { - return this._iter.valueSeq(); - }; + Seq.prototype[IS_SEQ_SENTINEL] = true; - ToKeyedSequence.prototype.reverse = function reverse () { - var this$1 = this; + // #pragma Root Sequences - var reversedSequence = reverseFactory(this, true); - if (!this._useKeys) { - reversedSequence.valueSeq = function () { return this$1._iter.toSeq().reverse(); }; + var ArraySeq = (function (IndexedSeq) { + function ArraySeq(array) { + this._array = array; + this.size = array.length; } - return reversedSequence; - }; - - ToKeyedSequence.prototype.map = function map (mapper, context) { - var this$1 = this; - var mappedSequence = mapFactory(this, mapper, context); - if (!this._useKeys) { - mappedSequence.valueSeq = function () { return this$1._iter.toSeq().map(mapper, context); }; - } - return mappedSequence; - }; + if ( IndexedSeq ) ArraySeq.__proto__ = IndexedSeq; + ArraySeq.prototype = Object.create( IndexedSeq && IndexedSeq.prototype ); + ArraySeq.prototype.constructor = ArraySeq; - ToKeyedSequence.prototype.__iterate = function __iterate (fn, reverse) { - var this$1 = this; + ArraySeq.prototype.get = function get (index, notSetValue) { + return this.has(index) ? this._array[wrapIndex(this, index)] : notSetValue; + }; - return this._iter.__iterate(function (v, k) { return fn(v, k, this$1); }, reverse); - }; + ArraySeq.prototype.__iterate = function __iterate (fn, reverse) { + var this$1 = this; - ToKeyedSequence.prototype.__iterator = function __iterator (type, reverse) { - return this._iter.__iterator(type, reverse); - }; + var array = this._array; + var size = array.length; + var i = 0; + while (i !== size) { + var ii = reverse ? size - ++i : i++; + if (fn(array[ii], ii, this$1) === false) { + break; + } + } + return i; + }; - return ToKeyedSequence; -}(KeyedSeq)); -ToKeyedSequence.prototype[IS_ORDERED_SENTINEL] = true; + ArraySeq.prototype.__iterator = function __iterator (type, reverse) { + var array = this._array; + var size = array.length; + var i = 0; + return new Iterator(function () { + if (i === size) { + return iteratorDone(); + } + var ii = reverse ? size - ++i : i++; + return iteratorValue(type, ii, array[ii]); + }); + }; -var ToIndexedSequence = (function (IndexedSeq$$1) { - function ToIndexedSequence(iter) { - this._iter = iter; - this.size = iter.size; - } + return ArraySeq; + }(IndexedSeq)); - if ( IndexedSeq$$1 ) ToIndexedSequence.__proto__ = IndexedSeq$$1; - ToIndexedSequence.prototype = Object.create( IndexedSeq$$1 && IndexedSeq$$1.prototype ); - ToIndexedSequence.prototype.constructor = ToIndexedSequence; + var ObjectSeq = (function (KeyedSeq) { + function ObjectSeq(object) { + var keys = Object.keys(object); + this._object = object; + this._keys = keys; + this.size = keys.length; + } - ToIndexedSequence.prototype.includes = function includes (value) { - return this._iter.includes(value); - }; + if ( KeyedSeq ) ObjectSeq.__proto__ = KeyedSeq; + ObjectSeq.prototype = Object.create( KeyedSeq && KeyedSeq.prototype ); + ObjectSeq.prototype.constructor = ObjectSeq; - ToIndexedSequence.prototype.__iterate = function __iterate (fn, reverse) { - var this$1 = this; + ObjectSeq.prototype.get = function get (key, notSetValue) { + if (notSetValue !== undefined && !this.has(key)) { + return notSetValue; + } + return this._object[key]; + }; - var i = 0; - reverse && ensureSize(this); - return this._iter.__iterate( - function (v) { return fn(v, reverse ? this$1.size - ++i : i++, this$1); }, - reverse - ); - }; + ObjectSeq.prototype.has = function has (key) { + return hasOwnProperty.call(this._object, key); + }; - ToIndexedSequence.prototype.__iterator = function __iterator (type, reverse) { - var this$1 = this; + ObjectSeq.prototype.__iterate = function __iterate (fn, reverse) { + var this$1 = this; - var iterator = this._iter.__iterator(ITERATE_VALUES, reverse); - var i = 0; - reverse && ensureSize(this); - return new Iterator(function () { - var step = iterator.next(); - return step.done - ? step - : iteratorValue( - type, - reverse ? this$1.size - ++i : i++, - step.value, - step - ); - }); - }; - - return ToIndexedSequence; -}(IndexedSeq)); - -var ToSetSequence = (function (SetSeq$$1) { - function ToSetSequence(iter) { - this._iter = iter; - this.size = iter.size; - } - - if ( SetSeq$$1 ) ToSetSequence.__proto__ = SetSeq$$1; - ToSetSequence.prototype = Object.create( SetSeq$$1 && SetSeq$$1.prototype ); - ToSetSequence.prototype.constructor = ToSetSequence; - - ToSetSequence.prototype.has = function has (key) { - return this._iter.includes(key); - }; - - ToSetSequence.prototype.__iterate = function __iterate (fn, reverse) { - var this$1 = this; - - return this._iter.__iterate(function (v) { return fn(v, v, this$1); }, reverse); - }; - - ToSetSequence.prototype.__iterator = function __iterator (type, reverse) { - var iterator = this._iter.__iterator(ITERATE_VALUES, reverse); - return new Iterator(function () { - var step = iterator.next(); - return step.done - ? step - : iteratorValue(type, step.value, step.value, step); - }); - }; + var object = this._object; + var keys = this._keys; + var size = keys.length; + var i = 0; + while (i !== size) { + var key = keys[reverse ? size - ++i : i++]; + if (fn(object[key], key, this$1) === false) { + break; + } + } + return i; + }; - return ToSetSequence; -}(SetSeq)); + ObjectSeq.prototype.__iterator = function __iterator (type, reverse) { + var object = this._object; + var keys = this._keys; + var size = keys.length; + var i = 0; + return new Iterator(function () { + if (i === size) { + return iteratorDone(); + } + var key = keys[reverse ? size - ++i : i++]; + return iteratorValue(type, key, object[key]); + }); + }; -var FromEntriesSequence = (function (KeyedSeq$$1) { - function FromEntriesSequence(entries) { - this._iter = entries; - this.size = entries.size; - } + return ObjectSeq; + }(KeyedSeq)); + ObjectSeq.prototype[IS_ORDERED_SENTINEL] = true; - if ( KeyedSeq$$1 ) FromEntriesSequence.__proto__ = KeyedSeq$$1; - FromEntriesSequence.prototype = Object.create( KeyedSeq$$1 && KeyedSeq$$1.prototype ); - FromEntriesSequence.prototype.constructor = FromEntriesSequence; + var CollectionSeq = (function (IndexedSeq) { + function CollectionSeq(collection) { + this._collection = collection; + this.size = collection.length || collection.size; + } - FromEntriesSequence.prototype.entrySeq = function entrySeq () { - return this._iter.toSeq(); - }; + if ( IndexedSeq ) CollectionSeq.__proto__ = IndexedSeq; + CollectionSeq.prototype = Object.create( IndexedSeq && IndexedSeq.prototype ); + CollectionSeq.prototype.constructor = CollectionSeq; - FromEntriesSequence.prototype.__iterate = function __iterate (fn, reverse) { - var this$1 = this; + CollectionSeq.prototype.__iterateUncached = function __iterateUncached (fn, reverse) { + var this$1 = this; - return this._iter.__iterate(function (entry) { - // Check if entry exists first so array access doesn't throw for holes - // in the parent iteration. - if (entry) { - validateEntry(entry); - var indexedCollection = isCollection(entry); - return fn( - indexedCollection ? entry.get(1) : entry[1], - indexedCollection ? entry.get(0) : entry[0], - this$1 - ); + if (reverse) { + return this.cacheResult().__iterate(fn, reverse); } - }, reverse); - }; - - FromEntriesSequence.prototype.__iterator = function __iterator (type, reverse) { - var iterator = this._iter.__iterator(ITERATE_VALUES, reverse); - return new Iterator(function () { - while (true) { - var step = iterator.next(); - if (step.done) { - return step; - } - var entry = step.value; - // Check if entry exists first so array access doesn't throw for holes - // in the parent iteration. - if (entry) { - validateEntry(entry); - var indexedCollection = isCollection(entry); - return iteratorValue( - type, - indexedCollection ? entry.get(0) : entry[0], - indexedCollection ? entry.get(1) : entry[1], - step - ); + var collection = this._collection; + var iterator = getIterator(collection); + var iterations = 0; + if (isIterator(iterator)) { + var step; + while (!(step = iterator.next()).done) { + if (fn(step.value, iterations++, this$1) === false) { + break; + } } } - }); - }; - - return FromEntriesSequence; -}(KeyedSeq)); - -ToIndexedSequence.prototype.cacheResult = ToKeyedSequence.prototype.cacheResult = ToSetSequence.prototype.cacheResult = FromEntriesSequence.prototype.cacheResult = cacheResultThrough; - -function flipFactory(collection) { - var flipSequence = makeSequence(collection); - flipSequence._iter = collection; - flipSequence.size = collection.size; - flipSequence.flip = function () { return collection; }; - flipSequence.reverse = function() { - var reversedSequence = collection.reverse.apply(this); // super.reverse() - reversedSequence.flip = function () { return collection.reverse(); }; - return reversedSequence; - }; - flipSequence.has = function (key) { return collection.includes(key); }; - flipSequence.includes = function (key) { return collection.has(key); }; - flipSequence.cacheResult = cacheResultThrough; - flipSequence.__iterateUncached = function(fn, reverse) { - var this$1 = this; + return iterations; + }; - return collection.__iterate(function (v, k) { return fn(k, v, this$1) !== false; }, reverse); - }; - flipSequence.__iteratorUncached = function(type, reverse) { - if (type === ITERATE_ENTRIES) { - var iterator = collection.__iterator(type, reverse); + CollectionSeq.prototype.__iteratorUncached = function __iteratorUncached (type, reverse) { + if (reverse) { + return this.cacheResult().__iterator(type, reverse); + } + var collection = this._collection; + var iterator = getIterator(collection); + if (!isIterator(iterator)) { + return new Iterator(iteratorDone); + } + var iterations = 0; return new Iterator(function () { var step = iterator.next(); - if (!step.done) { - var k = step.value[0]; - step.value[0] = step.value[1]; - step.value[1] = k; - } - return step; + return step.done ? step : iteratorValue(type, iterations++, step.value); }); - } - return collection.__iterator( - type === ITERATE_VALUES ? ITERATE_KEYS : ITERATE_VALUES, - reverse - ); - }; - return flipSequence; -} - -function mapFactory(collection, mapper, context) { - var mappedSequence = makeSequence(collection); - mappedSequence.size = collection.size; - mappedSequence.has = function (key) { return collection.has(key); }; - mappedSequence.get = function (key, notSetValue) { - var v = collection.get(key, NOT_SET); - return v === NOT_SET - ? notSetValue - : mapper.call(context, v, key, collection); - }; - mappedSequence.__iterateUncached = function(fn, reverse) { - var this$1 = this; + }; - return collection.__iterate( - function (v, k, c) { return fn(mapper.call(context, v, k, c), k, this$1) !== false; }, - reverse - ); - }; - mappedSequence.__iteratorUncached = function(type, reverse) { - var iterator = collection.__iterator(ITERATE_ENTRIES, reverse); - return new Iterator(function () { - var step = iterator.next(); - if (step.done) { - return step; - } - var entry = step.value; - var key = entry[0]; - return iteratorValue( - type, - key, - mapper.call(context, entry[1], key, collection), - step - ); - }); - }; - return mappedSequence; -} - -function reverseFactory(collection, useKeys) { - var this$1 = this; - - var reversedSequence = makeSequence(collection); - reversedSequence._iter = collection; - reversedSequence.size = collection.size; - reversedSequence.reverse = function () { return collection; }; - if (collection.flip) { - reversedSequence.flip = function() { - var flipSequence = flipFactory(collection); - flipSequence.reverse = function () { return collection.flip(); }; - return flipSequence; - }; - } - reversedSequence.get = function (key, notSetValue) { return collection.get(useKeys ? key : -1 - key, notSetValue); }; - reversedSequence.has = function (key) { return collection.has(useKeys ? key : -1 - key); }; - reversedSequence.includes = function (value) { return collection.includes(value); }; - reversedSequence.cacheResult = cacheResultThrough; - reversedSequence.__iterate = function(fn, reverse) { - var this$1 = this; + return CollectionSeq; + }(IndexedSeq)); - var i = 0; - reverse && ensureSize(collection); - return collection.__iterate( - function (v, k) { return fn(v, useKeys ? k : reverse ? this$1.size - ++i : i++, this$1); }, - !reverse - ); - }; - reversedSequence.__iterator = function (type, reverse) { - var i = 0; - reverse && ensureSize(collection); - var iterator = collection.__iterator(ITERATE_ENTRIES, !reverse); - return new Iterator(function () { - var step = iterator.next(); - if (step.done) { - return step; - } - var entry = step.value; - return iteratorValue( - type, - useKeys ? entry[0] : reverse ? this$1.size - ++i : i++, - entry[1], - step - ); - }); - }; - return reversedSequence; -} + var IteratorSeq = (function (IndexedSeq) { + function IteratorSeq(iterator) { + this._iterator = iterator; + this._iteratorCache = []; + } -function filterFactory(collection, predicate, context, useKeys) { - var filterSequence = makeSequence(collection); - if (useKeys) { - filterSequence.has = function (key) { - var v = collection.get(key, NOT_SET); - return v !== NOT_SET && !!predicate.call(context, v, key, collection); - }; - filterSequence.get = function (key, notSetValue) { - var v = collection.get(key, NOT_SET); - return v !== NOT_SET && predicate.call(context, v, key, collection) - ? v - : notSetValue; - }; - } - filterSequence.__iterateUncached = function(fn, reverse) { - var this$1 = this; + if ( IndexedSeq ) IteratorSeq.__proto__ = IndexedSeq; + IteratorSeq.prototype = Object.create( IndexedSeq && IndexedSeq.prototype ); + IteratorSeq.prototype.constructor = IteratorSeq; - var iterations = 0; - collection.__iterate(function (v, k, c) { - if (predicate.call(context, v, k, c)) { - iterations++; - return fn(v, useKeys ? k : iterations - 1, this$1); + IteratorSeq.prototype.__iterateUncached = function __iterateUncached (fn, reverse) { + var this$1 = this; + + if (reverse) { + return this.cacheResult().__iterate(fn, reverse); } - }, reverse); - return iterations; - }; - filterSequence.__iteratorUncached = function(type, reverse) { - var iterator = collection.__iterator(ITERATE_ENTRIES, reverse); - var iterations = 0; - return new Iterator(function () { - while (true) { - var step = iterator.next(); - if (step.done) { - return step; + var iterator = this._iterator; + var cache = this._iteratorCache; + var iterations = 0; + while (iterations < cache.length) { + if (fn(cache[iterations], iterations++, this$1) === false) { + return iterations; } - var entry = step.value; - var key = entry[0]; - var value = entry[1]; - if (predicate.call(context, value, key, collection)) { - return iteratorValue(type, useKeys ? key : iterations++, value, step); + } + var step; + while (!(step = iterator.next()).done) { + var val = step.value; + cache[iterations] = val; + if (fn(val, iterations++, this$1) === false) { + break; } } - }); - }; - return filterSequence; -} + return iterations; + }; -function countByFactory(collection, grouper, context) { - var groups = Map().asMutable(); - collection.__iterate(function (v, k) { - groups.update(grouper.call(context, v, k, collection), 0, function (a) { return a + 1; }); - }); - return groups.asImmutable(); -} - -function groupByFactory(collection, grouper, context) { - var isKeyedIter = isKeyed(collection); - var groups = (isOrdered(collection) ? OrderedMap() : Map()).asMutable(); - collection.__iterate(function (v, k) { - groups.update( - grouper.call(context, v, k, collection), - function (a) { return ((a = a || []), a.push(isKeyedIter ? [k, v] : v), a); } - ); - }); - var coerce = collectionClass(collection); - return groups.map(function (arr) { return reify(collection, coerce(arr)); }); -} + IteratorSeq.prototype.__iteratorUncached = function __iteratorUncached (type, reverse) { + if (reverse) { + return this.cacheResult().__iterator(type, reverse); + } + var iterator = this._iterator; + var cache = this._iteratorCache; + var iterations = 0; + return new Iterator(function () { + if (iterations >= cache.length) { + var step = iterator.next(); + if (step.done) { + return step; + } + cache[iterations] = step.value; + } + return iteratorValue(type, iterations, cache[iterations++]); + }); + }; -function sliceFactory(collection, begin, end, useKeys) { - var originalSize = collection.size; + return IteratorSeq; + }(IndexedSeq)); - if (wholeSlice(begin, end, originalSize)) { - return collection; + // # pragma Helper functions + + function isSeq(maybeSeq) { + return !!(maybeSeq && maybeSeq[IS_SEQ_SENTINEL]); } - var resolvedBegin = resolveBegin(begin, originalSize); - var resolvedEnd = resolveEnd(end, originalSize); + var EMPTY_SEQ; - // begin or end will be NaN if they were provided as negative numbers and - // this collection's size is unknown. In that case, cache first so there is - // a known size and these do not resolve to NaN. - if (resolvedBegin !== resolvedBegin || resolvedEnd !== resolvedEnd) { - return sliceFactory(collection.toSeq().cacheResult(), begin, end, useKeys); + function emptySequence() { + return EMPTY_SEQ || (EMPTY_SEQ = new ArraySeq([])); } - // Note: resolvedEnd is undefined when the original sequence's length is - // unknown and this slice did not supply an end and should contain all - // elements after resolvedBegin. - // In that case, resolvedSize will be NaN and sliceSize will remain undefined. - var resolvedSize = resolvedEnd - resolvedBegin; - var sliceSize; - if (resolvedSize === resolvedSize) { - sliceSize = resolvedSize < 0 ? 0 : resolvedSize; + function keyedSeqFromValue(value) { + var seq = Array.isArray(value) + ? new ArraySeq(value) + : isIterator(value) + ? new IteratorSeq(value) + : hasIterator(value) + ? new CollectionSeq(value) + : undefined; + if (seq) { + return seq.fromEntrySeq(); + } + if (typeof value === 'object') { + return new ObjectSeq(value); + } + throw new TypeError( + 'Expected Array or collection object of [k, v] entries, or keyed object: ' + + value + ); } - var sliceSeq = makeSequence(collection); - - // If collection.size is undefined, the size of the realized sliceSeq is - // unknown at this point unless the number of items to slice is 0 - sliceSeq.size = - sliceSize === 0 ? sliceSize : (collection.size && sliceSize) || undefined; - - if (!useKeys && isSeq(collection) && sliceSize >= 0) { - sliceSeq.get = function(index, notSetValue) { - index = wrapIndex(this, index); - return index >= 0 && index < sliceSize - ? collection.get(index + resolvedBegin, notSetValue) - : notSetValue; - }; + function indexedSeqFromValue(value) { + var seq = maybeIndexedSeqFromValue(value); + if (seq) { + return seq; + } + throw new TypeError( + 'Expected Array or collection object of values: ' + value + ); } - sliceSeq.__iterateUncached = function(fn, reverse) { - var this$1 = this; - - if (sliceSize === 0) { - return 0; + function seqFromValue(value) { + var seq = maybeIndexedSeqFromValue(value); + if (seq) { + return seq; } - if (reverse) { - return this.cacheResult().__iterate(fn, reverse); + if (typeof value === 'object') { + return new ObjectSeq(value); } - var skipped = 0; - var isSkipping = true; - var iterations = 0; - collection.__iterate(function (v, k) { - if (!(isSkipping && (isSkipping = skipped++ < resolvedBegin))) { - iterations++; - return ( - fn(v, useKeys ? k : iterations - 1, this$1) !== false && - iterations !== sliceSize - ); - } - }); - return iterations; - }; + throw new TypeError( + 'Expected Array or collection object of values, or keyed object: ' + value + ); + } - sliceSeq.__iteratorUncached = function(type, reverse) { - if (sliceSize !== 0 && reverse) { - return this.cacheResult().__iterator(type, reverse); + function maybeIndexedSeqFromValue(value) { + return isArrayLike(value) + ? new ArraySeq(value) + : isIterator(value) + ? new IteratorSeq(value) + : hasIterator(value) + ? new CollectionSeq(value) + : undefined; + } + + /** + * An extension of the "same-value" algorithm as [described for use by ES6 Map + * and Set](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map#Key_equality) + * + * NaN is considered the same as NaN, however -0 and 0 are considered the same + * value, which is different from the algorithm described by + * [`Object.is`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is). + * + * This is extended further to allow Objects to describe the values they + * represent, by way of `valueOf` or `equals` (and `hashCode`). + * + * Note: because of this extension, the key equality of Immutable.Map and the + * value equality of Immutable.Set will differ from ES6 Map and Set. + * + * ### Defining custom values + * + * The easiest way to describe the value an object represents is by implementing + * `valueOf`. For example, `Date` represents a value by returning a unix + * timestamp for `valueOf`: + * + * var date1 = new Date(1234567890000); // Fri Feb 13 2009 ... + * var date2 = new Date(1234567890000); + * date1.valueOf(); // 1234567890000 + * assert( date1 !== date2 ); + * assert( Immutable.is( date1, date2 ) ); + * + * Note: overriding `valueOf` may have other implications if you use this object + * where JavaScript expects a primitive, such as implicit string coercion. + * + * For more complex types, especially collections, implementing `valueOf` may + * not be performant. An alternative is to implement `equals` and `hashCode`. + * + * `equals` takes another object, presumably of similar type, and returns true + * if it is equal. Equality is symmetrical, so the same result should be + * returned if this and the argument are flipped. + * + * assert( a.equals(b) === b.equals(a) ); + * + * `hashCode` returns a 32bit integer number representing the object which will + * be used to determine how to store the value object in a Map or Set. You must + * provide both or neither methods, one must not exist without the other. + * + * Also, an important relationship between these methods must be upheld: if two + * values are equal, they *must* return the same hashCode. If the values are not + * equal, they might have the same hashCode; this is called a hash collision, + * and while undesirable for performance reasons, it is acceptable. + * + * if (a.equals(b)) { + * assert( a.hashCode() === b.hashCode() ); + * } + * + * All Immutable collections are Value Objects: they implement `equals()` + * and `hashCode()`. + */ + function is(valueA, valueB) { + if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) { + return true; } - // Don't bother instantiating parent iterator if taking 0. - if (sliceSize === 0) { - return new Iterator(iteratorDone); + if (!valueA || !valueB) { + return false; } - var iterator = collection.__iterator(type, reverse); - var skipped = 0; - var iterations = 0; - return new Iterator(function () { - while (skipped++ < resolvedBegin) { - iterator.next(); - } - if (++iterations > sliceSize) { - return iteratorDone(); - } - var step = iterator.next(); - if (useKeys || type === ITERATE_VALUES || step.done) { - return step; + if ( + typeof valueA.valueOf === 'function' && + typeof valueB.valueOf === 'function' + ) { + valueA = valueA.valueOf(); + valueB = valueB.valueOf(); + if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) { + return true; } - if (type === ITERATE_KEYS) { - return iteratorValue(type, iterations - 1, undefined, step); + if (!valueA || !valueB) { + return false; } - return iteratorValue(type, iterations - 1, step.value[1], step); - }); - }; + } + return !!( + isValueObject(valueA) && + isValueObject(valueB) && + valueA.equals(valueB) + ); + } - return sliceSeq; -} + var imul = + typeof Math.imul === 'function' && Math.imul(0xffffffff, 2) === -2 + ? Math.imul + : function imul(a, b) { + a |= 0; // int + b |= 0; // int + var c = a & 0xffff; + var d = b & 0xffff; + // Shift by 0 fixes the sign on the high part. + return (c * d + ((((a >>> 16) * d + c * (b >>> 16)) << 16) >>> 0)) | 0; // int + }; -function takeWhileFactory(collection, predicate, context) { - var takeSequence = makeSequence(collection); - takeSequence.__iterateUncached = function(fn, reverse) { - var this$1 = this; + // v8 has an optimization for storing 31-bit signed numbers. + // Values which have either 00 or 11 as the high order bits qualify. + // This function drops the highest order bit in a signed number, maintaining + // the sign bit. + function smi(i32) { + return ((i32 >>> 1) & 0x40000000) | (i32 & 0xbfffffff); + } - if (reverse) { - return this.cacheResult().__iterate(fn, reverse); + function hash(o) { + if (o === false || o === null || o === undefined) { + return 0; } - var iterations = 0; - collection.__iterate( - function (v, k, c) { return predicate.call(context, v, k, c) && ++iterations && fn(v, k, this$1); } - ); - return iterations; - }; - takeSequence.__iteratorUncached = function(type, reverse) { - var this$1 = this; - - if (reverse) { - return this.cacheResult().__iterator(type, reverse); + if (typeof o.valueOf === 'function') { + o = o.valueOf(); + if (o === false || o === null || o === undefined) { + return 0; + } } - var iterator = collection.__iterator(ITERATE_ENTRIES, reverse); - var iterating = true; - return new Iterator(function () { - if (!iterating) { - return iteratorDone(); + if (o === true) { + return 1; + } + var type = typeof o; + if (type === 'number') { + if (o !== o || o === Infinity) { + return 0; } - var step = iterator.next(); - if (step.done) { - return step; + var h = o | 0; + if (h !== o) { + h ^= o * 0xffffffff; } - var entry = step.value; - var k = entry[0]; - var v = entry[1]; - if (!predicate.call(context, v, k, this$1)) { - iterating = false; - return iteratorDone(); + while (o > 0xffffffff) { + o /= 0xffffffff; + h ^= o; } - return type === ITERATE_ENTRIES ? step : iteratorValue(type, k, v, step); - }); - }; - return takeSequence; -} - -function skipWhileFactory(collection, predicate, context, useKeys) { - var skipSequence = makeSequence(collection); - skipSequence.__iterateUncached = function(fn, reverse) { - var this$1 = this; - - if (reverse) { - return this.cacheResult().__iterate(fn, reverse); + return smi(h); } - var isSkipping = true; - var iterations = 0; - collection.__iterate(function (v, k, c) { - if (!(isSkipping && (isSkipping = predicate.call(context, v, k, c)))) { - iterations++; - return fn(v, useKeys ? k : iterations - 1, this$1); - } - }); - return iterations; - }; - skipSequence.__iteratorUncached = function(type, reverse) { - var this$1 = this; - - if (reverse) { - return this.cacheResult().__iterator(type, reverse); + if (type === 'string') { + return o.length > STRING_HASH_CACHE_MIN_STRLEN + ? cachedHashString(o) + : hashString(o); } - var iterator = collection.__iterator(ITERATE_ENTRIES, reverse); - var skipping = true; - var iterations = 0; - return new Iterator(function () { - var step; - var k; - var v; - do { - step = iterator.next(); - if (step.done) { - if (useKeys || type === ITERATE_VALUES) { - return step; - } - if (type === ITERATE_KEYS) { - return iteratorValue(type, iterations++, undefined, step); - } - return iteratorValue(type, iterations++, step.value[1], step); - } - var entry = step.value; - k = entry[0]; - v = entry[1]; - skipping && (skipping = predicate.call(context, v, k, this$1)); - } while (skipping); - return type === ITERATE_ENTRIES ? step : iteratorValue(type, k, v, step); - }); - }; - return skipSequence; -} - -function concatFactory(collection, values) { - var isKeyedCollection = isKeyed(collection); - var iters = [collection] - .concat(values) - .map(function (v) { - if (!isCollection(v)) { - v = isKeyedCollection - ? keyedSeqFromValue(v) - : indexedSeqFromValue(Array.isArray(v) ? v : [v]); - } else if (isKeyedCollection) { - v = KeyedCollection(v); - } - return v; - }) - .filter(function (v) { return v.size !== 0; }); - - if (iters.length === 0) { - return collection; + if (typeof o.hashCode === 'function') { + // Drop any high bits from accidentally long hash codes. + return smi(o.hashCode()); + } + if (type === 'object' || type === 'function') { + return hashJSObj(o); + } + if (typeof o.toString === 'function') { + return hashString(o.toString()); + } + throw new Error('Value type ' + type + ' cannot be hashed.'); } - if (iters.length === 1) { - var singleton = iters[0]; - if ( - singleton === collection || - (isKeyedCollection && isKeyed(singleton)) || - (isIndexed(collection) && isIndexed(singleton)) - ) { - return singleton; + function cachedHashString(string) { + var hashed = stringHashCache[string]; + if (hashed === undefined) { + hashed = hashString(string); + if (STRING_HASH_CACHE_SIZE === STRING_HASH_CACHE_MAX_SIZE) { + STRING_HASH_CACHE_SIZE = 0; + stringHashCache = {}; + } + STRING_HASH_CACHE_SIZE++; + stringHashCache[string] = hashed; } + return hashed; } - var concatSeq = new ArraySeq(iters); - if (isKeyedCollection) { - concatSeq = concatSeq.toKeyedSeq(); - } else if (!isIndexed(collection)) { - concatSeq = concatSeq.toSetSeq(); + // http://jsperf.com/hashing-strings + function hashString(string) { + // This is the hash from JVM + // The hash code for a string is computed as + // s[0] * 31 ^ (n - 1) + s[1] * 31 ^ (n - 2) + ... + s[n - 1], + // where s[i] is the ith character of the string and n is the length of + // the string. We "mod" the result to make it between 0 (inclusive) and 2^31 + // (exclusive) by dropping high bits. + var hashed = 0; + for (var ii = 0; ii < string.length; ii++) { + hashed = (31 * hashed + string.charCodeAt(ii)) | 0; + } + return smi(hashed); } - concatSeq = concatSeq.flatten(true); - concatSeq.size = iters.reduce(function (sum, seq) { - if (sum !== undefined) { - var size = seq.size; - if (size !== undefined) { - return sum + size; + + function hashJSObj(obj) { + var hashed; + if (usingWeakMap) { + hashed = weakMap.get(obj); + if (hashed !== undefined) { + return hashed; } } - }, 0); - return concatSeq; -} -function flattenFactory(collection, depth, useKeys) { - var flatSequence = makeSequence(collection); - flatSequence.__iterateUncached = function(fn, reverse) { - if (reverse) { - return this.cacheResult().__iterate(fn, reverse); - } - var iterations = 0; - var stopped = false; - function flatDeep(iter, currentDepth) { - iter.__iterate(function (v, k) { - if ((!depth || currentDepth < depth) && isCollection(v)) { - flatDeep(v, currentDepth + 1); - } else { - iterations++; - if (fn(v, useKeys ? k : iterations - 1, flatSequence) === false) { - stopped = true; - } - } - return !stopped; - }, reverse); + hashed = obj[UID_HASH_KEY]; + if (hashed !== undefined) { + return hashed; } - flatDeep(collection, 0); - return iterations; - }; - flatSequence.__iteratorUncached = function(type, reverse) { - if (reverse) { - return this.cacheResult().__iterator(type, reverse); - } - var iterator = collection.__iterator(type, reverse); - var stack = []; - var iterations = 0; - return new Iterator(function () { - while (iterator) { - var step = iterator.next(); - if (step.done !== false) { - iterator = stack.pop(); - continue; - } - var v = step.value; - if (type === ITERATE_ENTRIES) { - v = v[1]; - } - if ((!depth || stack.length < depth) && isCollection(v)) { - stack.push(iterator); - iterator = v.__iterator(type, reverse); - } else { - return useKeys ? step : iteratorValue(type, iterations++, v, step); - } - } - return iteratorDone(); - }); - }; - return flatSequence; -} - -function flatMapFactory(collection, mapper, context) { - var coerce = collectionClass(collection); - return collection - .toSeq() - .map(function (v, k) { return coerce(mapper.call(context, v, k, collection)); }) - .flatten(true); -} - -function interposeFactory(collection, separator) { - var interposedSequence = makeSequence(collection); - interposedSequence.size = collection.size && collection.size * 2 - 1; - interposedSequence.__iterateUncached = function(fn, reverse) { - var this$1 = this; - var iterations = 0; - collection.__iterate( - function (v) { return (!iterations || fn(separator, iterations++, this$1) !== false) && - fn(v, iterations++, this$1) !== false; }, - reverse - ); - return iterations; - }; - interposedSequence.__iteratorUncached = function(type, reverse) { - var iterator = collection.__iterator(ITERATE_VALUES, reverse); - var iterations = 0; - var step; - return new Iterator(function () { - if (!step || iterations % 2) { - step = iterator.next(); - if (step.done) { - return step; - } + if (!canDefineProperty) { + hashed = obj.propertyIsEnumerable && obj.propertyIsEnumerable[UID_HASH_KEY]; + if (hashed !== undefined) { + return hashed; } - return iterations % 2 - ? iteratorValue(type, iterations++, separator) - : iteratorValue(type, iterations++, step.value, step); - }); - }; - return interposedSequence; -} - -function sortFactory(collection, comparator, mapper) { - if (!comparator) { - comparator = defaultComparator; - } - var isKeyedCollection = isKeyed(collection); - var index = 0; - var entries = collection - .toSeq() - .map(function (v, k) { return [k, v, index++, mapper ? mapper(v, k, collection) : v]; }) - .valueSeq() - .toArray(); - entries.sort(function (a, b) { return comparator(a[3], b[3]) || a[2] - b[2]; }).forEach( - isKeyedCollection - ? function (v, i) { - entries[i].length = 2; - } - : function (v, i) { - entries[i] = v[1]; - } - ); - return isKeyedCollection - ? KeyedSeq(entries) - : isIndexed(collection) - ? IndexedSeq(entries) - : SetSeq(entries); -} - -function maxFactory(collection, comparator, mapper) { - if (!comparator) { - comparator = defaultComparator; - } - if (mapper) { - var entry = collection - .toSeq() - .map(function (v, k) { return [v, mapper(v, k, collection)]; }) - .reduce(function (a, b) { return (maxCompare(comparator, a[1], b[1]) ? b : a); }); - return entry && entry[0]; - } - return collection.reduce(function (a, b) { return (maxCompare(comparator, a, b) ? b : a); }); -} - -function maxCompare(comparator, a, b) { - var comp = comparator(b, a); - // b is considered the new max if the comparator declares them equal, but - // they are not equal and b is in fact a nullish value. - return ( - (comp === 0 && b !== a && (b === undefined || b === null || b !== b)) || - comp > 0 - ); -} - -function zipWithFactory(keyIter, zipper, iters, zipAll) { - var zipSequence = makeSequence(keyIter); - var sizes = new ArraySeq(iters).map(function (i) { return i.size; }); - zipSequence.size = zipAll ? sizes.max() : sizes.min(); - // Note: this a generic base implementation of __iterate in terms of - // __iterator which may be more generically useful in the future. - zipSequence.__iterate = function(fn, reverse) { - var this$1 = this; - /* generic: - var iterator = this.__iterator(ITERATE_ENTRIES, reverse); - var step; - var iterations = 0; - while (!(step = iterator.next()).done) { - iterations++; - if (fn(step.value[1], step.value[0], this) === false) { - break; - } - } - return iterations; - */ - // indexed: - var iterator = this.__iterator(ITERATE_VALUES, reverse); - var step; - var iterations = 0; - while (!(step = iterator.next()).done) { - if (fn(step.value, iterations++, this$1) === false) { - break; + hashed = getIENodeHash(obj); + if (hashed !== undefined) { + return hashed; } } - return iterations; - }; - zipSequence.__iteratorUncached = function(type, reverse) { - var iterators = iters.map( - function (i) { return ((i = Collection(i)), getIterator(reverse ? i.reverse() : i)); } - ); - var iterations = 0; - var isDone = false; - return new Iterator(function () { - var steps; - if (!isDone) { - steps = iterators.map(function (i) { return i.next(); }); - isDone = zipAll ? steps.every(function (s) { return s.done; }) : steps.some(function (s) { return s.done; }); - } - if (isDone) { - return iteratorDone(); - } - return iteratorValue( - type, - iterations++, - zipper.apply(null, steps.map(function (s) { return s.value; })) - ); - }); - }; - return zipSequence; -} -// #pragma Helper Functions + hashed = ++objHashUID; + if (objHashUID & 0x40000000) { + objHashUID = 0; + } -function reify(iter, seq) { - return iter === seq ? iter : isSeq(iter) ? seq : iter.constructor(seq); -} + if (usingWeakMap) { + weakMap.set(obj, hashed); + } else if (isExtensible !== undefined && isExtensible(obj) === false) { + throw new Error('Non-extensible objects are not allowed as keys.'); + } else if (canDefineProperty) { + Object.defineProperty(obj, UID_HASH_KEY, { + enumerable: false, + configurable: false, + writable: false, + value: hashed, + }); + } else if ( + obj.propertyIsEnumerable !== undefined && + obj.propertyIsEnumerable === obj.constructor.prototype.propertyIsEnumerable + ) { + // Since we can't define a non-enumerable property on the object + // we'll hijack one of the less-used non-enumerable properties to + // save our hash on it. Since this is a function it will not show up in + // `JSON.stringify` which is what we want. + obj.propertyIsEnumerable = function() { + return this.constructor.prototype.propertyIsEnumerable.apply( + this, + arguments + ); + }; + obj.propertyIsEnumerable[UID_HASH_KEY] = hashed; + } else if (obj.nodeType !== undefined) { + // At this point we couldn't get the IE `uniqueID` to use as a hash + // and we couldn't use a non-enumerable property to exploit the + // dontEnum bug so we simply add the `UID_HASH_KEY` on the node + // itself. + obj[UID_HASH_KEY] = hashed; + } else { + throw new Error('Unable to set a non-enumerable property on object.'); + } -function validateEntry(entry) { - if (entry !== Object(entry)) { - throw new TypeError('Expected [K, V] tuple: ' + entry); + return hashed; } -} -function collectionClass(collection) { - return isKeyed(collection) - ? KeyedCollection - : isIndexed(collection) - ? IndexedCollection - : SetCollection; -} + // Get references to ES5 object methods. + var isExtensible = Object.isExtensible; -function makeSequence(collection) { - return Object.create( - (isKeyed(collection) - ? KeyedSeq + // True if Object.defineProperty works as expected. IE8 fails this test. + var canDefineProperty = (function() { + try { + Object.defineProperty({}, '@', {}); + return true; + } catch (e) { + return false; + } + })(); + + // IE has a `uniqueID` property on DOM nodes. We can construct the hash from it + // and avoid memory leaks from the IE cloneNode bug. + function getIENodeHash(node) { + if (node && node.nodeType > 0) { + switch (node.nodeType) { + case 1: // Element + return node.uniqueID; + case 9: // Document + return node.documentElement && node.documentElement.uniqueID; + } + } + } + + // If possible, use a WeakMap. + var usingWeakMap = typeof WeakMap === 'function'; + var weakMap; + if (usingWeakMap) { + weakMap = new WeakMap(); + } + + var objHashUID = 0; + + var UID_HASH_KEY = '__immutablehash__'; + if (typeof Symbol === 'function') { + UID_HASH_KEY = Symbol(UID_HASH_KEY); + } + + var STRING_HASH_CACHE_MIN_STRLEN = 16; + var STRING_HASH_CACHE_MAX_SIZE = 255; + var STRING_HASH_CACHE_SIZE = 0; + var stringHashCache = {}; + + var ToKeyedSequence = (function (KeyedSeq$$1) { + function ToKeyedSequence(indexed, useKeys) { + this._iter = indexed; + this._useKeys = useKeys; + this.size = indexed.size; + } + + if ( KeyedSeq$$1 ) ToKeyedSequence.__proto__ = KeyedSeq$$1; + ToKeyedSequence.prototype = Object.create( KeyedSeq$$1 && KeyedSeq$$1.prototype ); + ToKeyedSequence.prototype.constructor = ToKeyedSequence; + + ToKeyedSequence.prototype.get = function get (key, notSetValue) { + return this._iter.get(key, notSetValue); + }; + + ToKeyedSequence.prototype.has = function has (key) { + return this._iter.has(key); + }; + + ToKeyedSequence.prototype.valueSeq = function valueSeq () { + return this._iter.valueSeq(); + }; + + ToKeyedSequence.prototype.reverse = function reverse () { + var this$1 = this; + + var reversedSequence = reverseFactory(this, true); + if (!this._useKeys) { + reversedSequence.valueSeq = function () { return this$1._iter.toSeq().reverse(); }; + } + return reversedSequence; + }; + + ToKeyedSequence.prototype.map = function map (mapper, context) { + var this$1 = this; + + var mappedSequence = mapFactory(this, mapper, context); + if (!this._useKeys) { + mappedSequence.valueSeq = function () { return this$1._iter.toSeq().map(mapper, context); }; + } + return mappedSequence; + }; + + ToKeyedSequence.prototype.__iterate = function __iterate (fn, reverse) { + var this$1 = this; + + return this._iter.__iterate(function (v, k) { return fn(v, k, this$1); }, reverse); + }; + + ToKeyedSequence.prototype.__iterator = function __iterator (type, reverse) { + return this._iter.__iterator(type, reverse); + }; + + return ToKeyedSequence; + }(KeyedSeq)); + ToKeyedSequence.prototype[IS_ORDERED_SENTINEL] = true; + + var ToIndexedSequence = (function (IndexedSeq$$1) { + function ToIndexedSequence(iter) { + this._iter = iter; + this.size = iter.size; + } + + if ( IndexedSeq$$1 ) ToIndexedSequence.__proto__ = IndexedSeq$$1; + ToIndexedSequence.prototype = Object.create( IndexedSeq$$1 && IndexedSeq$$1.prototype ); + ToIndexedSequence.prototype.constructor = ToIndexedSequence; + + ToIndexedSequence.prototype.includes = function includes (value) { + return this._iter.includes(value); + }; + + ToIndexedSequence.prototype.__iterate = function __iterate (fn, reverse) { + var this$1 = this; + + var i = 0; + reverse && ensureSize(this); + return this._iter.__iterate( + function (v) { return fn(v, reverse ? this$1.size - ++i : i++, this$1); }, + reverse + ); + }; + + ToIndexedSequence.prototype.__iterator = function __iterator (type, reverse) { + var this$1 = this; + + var iterator = this._iter.__iterator(ITERATE_VALUES, reverse); + var i = 0; + reverse && ensureSize(this); + return new Iterator(function () { + var step = iterator.next(); + return step.done + ? step + : iteratorValue( + type, + reverse ? this$1.size - ++i : i++, + step.value, + step + ); + }); + }; + + return ToIndexedSequence; + }(IndexedSeq)); + + var ToSetSequence = (function (SetSeq$$1) { + function ToSetSequence(iter) { + this._iter = iter; + this.size = iter.size; + } + + if ( SetSeq$$1 ) ToSetSequence.__proto__ = SetSeq$$1; + ToSetSequence.prototype = Object.create( SetSeq$$1 && SetSeq$$1.prototype ); + ToSetSequence.prototype.constructor = ToSetSequence; + + ToSetSequence.prototype.has = function has (key) { + return this._iter.includes(key); + }; + + ToSetSequence.prototype.__iterate = function __iterate (fn, reverse) { + var this$1 = this; + + return this._iter.__iterate(function (v) { return fn(v, v, this$1); }, reverse); + }; + + ToSetSequence.prototype.__iterator = function __iterator (type, reverse) { + var iterator = this._iter.__iterator(ITERATE_VALUES, reverse); + return new Iterator(function () { + var step = iterator.next(); + return step.done + ? step + : iteratorValue(type, step.value, step.value, step); + }); + }; + + return ToSetSequence; + }(SetSeq)); + + var FromEntriesSequence = (function (KeyedSeq$$1) { + function FromEntriesSequence(entries) { + this._iter = entries; + this.size = entries.size; + } + + if ( KeyedSeq$$1 ) FromEntriesSequence.__proto__ = KeyedSeq$$1; + FromEntriesSequence.prototype = Object.create( KeyedSeq$$1 && KeyedSeq$$1.prototype ); + FromEntriesSequence.prototype.constructor = FromEntriesSequence; + + FromEntriesSequence.prototype.entrySeq = function entrySeq () { + return this._iter.toSeq(); + }; + + FromEntriesSequence.prototype.__iterate = function __iterate (fn, reverse) { + var this$1 = this; + + return this._iter.__iterate(function (entry) { + // Check if entry exists first so array access doesn't throw for holes + // in the parent iteration. + if (entry) { + validateEntry(entry); + var indexedCollection = isCollection(entry); + return fn( + indexedCollection ? entry.get(1) : entry[1], + indexedCollection ? entry.get(0) : entry[0], + this$1 + ); + } + }, reverse); + }; + + FromEntriesSequence.prototype.__iterator = function __iterator (type, reverse) { + var iterator = this._iter.__iterator(ITERATE_VALUES, reverse); + return new Iterator(function () { + while (true) { + var step = iterator.next(); + if (step.done) { + return step; + } + var entry = step.value; + // Check if entry exists first so array access doesn't throw for holes + // in the parent iteration. + if (entry) { + validateEntry(entry); + var indexedCollection = isCollection(entry); + return iteratorValue( + type, + indexedCollection ? entry.get(0) : entry[0], + indexedCollection ? entry.get(1) : entry[1], + step + ); + } + } + }); + }; + + return FromEntriesSequence; + }(KeyedSeq)); + + ToIndexedSequence.prototype.cacheResult = ToKeyedSequence.prototype.cacheResult = ToSetSequence.prototype.cacheResult = FromEntriesSequence.prototype.cacheResult = cacheResultThrough; + + function flipFactory(collection) { + var flipSequence = makeSequence(collection); + flipSequence._iter = collection; + flipSequence.size = collection.size; + flipSequence.flip = function () { return collection; }; + flipSequence.reverse = function() { + var reversedSequence = collection.reverse.apply(this); // super.reverse() + reversedSequence.flip = function () { return collection.reverse(); }; + return reversedSequence; + }; + flipSequence.has = function (key) { return collection.includes(key); }; + flipSequence.includes = function (key) { return collection.has(key); }; + flipSequence.cacheResult = cacheResultThrough; + flipSequence.__iterateUncached = function(fn, reverse) { + var this$1 = this; + + return collection.__iterate(function (v, k) { return fn(k, v, this$1) !== false; }, reverse); + }; + flipSequence.__iteratorUncached = function(type, reverse) { + if (type === ITERATE_ENTRIES) { + var iterator = collection.__iterator(type, reverse); + return new Iterator(function () { + var step = iterator.next(); + if (!step.done) { + var k = step.value[0]; + step.value[0] = step.value[1]; + step.value[1] = k; + } + return step; + }); + } + return collection.__iterator( + type === ITERATE_VALUES ? ITERATE_KEYS : ITERATE_VALUES, + reverse + ); + }; + return flipSequence; + } + + function mapFactory(collection, mapper, context) { + var mappedSequence = makeSequence(collection); + mappedSequence.size = collection.size; + mappedSequence.has = function (key) { return collection.has(key); }; + mappedSequence.get = function (key, notSetValue) { + var v = collection.get(key, NOT_SET); + return v === NOT_SET + ? notSetValue + : mapper.call(context, v, key, collection); + }; + mappedSequence.__iterateUncached = function(fn, reverse) { + var this$1 = this; + + return collection.__iterate( + function (v, k, c) { return fn(mapper.call(context, v, k, c), k, this$1) !== false; }, + reverse + ); + }; + mappedSequence.__iteratorUncached = function(type, reverse) { + var iterator = collection.__iterator(ITERATE_ENTRIES, reverse); + return new Iterator(function () { + var step = iterator.next(); + if (step.done) { + return step; + } + var entry = step.value; + var key = entry[0]; + return iteratorValue( + type, + key, + mapper.call(context, entry[1], key, collection), + step + ); + }); + }; + return mappedSequence; + } + + function reverseFactory(collection, useKeys) { + var this$1 = this; + + var reversedSequence = makeSequence(collection); + reversedSequence._iter = collection; + reversedSequence.size = collection.size; + reversedSequence.reverse = function () { return collection; }; + if (collection.flip) { + reversedSequence.flip = function() { + var flipSequence = flipFactory(collection); + flipSequence.reverse = function () { return collection.flip(); }; + return flipSequence; + }; + } + reversedSequence.get = function (key, notSetValue) { return collection.get(useKeys ? key : -1 - key, notSetValue); }; + reversedSequence.has = function (key) { return collection.has(useKeys ? key : -1 - key); }; + reversedSequence.includes = function (value) { return collection.includes(value); }; + reversedSequence.cacheResult = cacheResultThrough; + reversedSequence.__iterate = function(fn, reverse) { + var this$1 = this; + + var i = 0; + reverse && ensureSize(collection); + return collection.__iterate( + function (v, k) { return fn(v, useKeys ? k : reverse ? this$1.size - ++i : i++, this$1); }, + !reverse + ); + }; + reversedSequence.__iterator = function (type, reverse) { + var i = 0; + reverse && ensureSize(collection); + var iterator = collection.__iterator(ITERATE_ENTRIES, !reverse); + return new Iterator(function () { + var step = iterator.next(); + if (step.done) { + return step; + } + var entry = step.value; + return iteratorValue( + type, + useKeys ? entry[0] : reverse ? this$1.size - ++i : i++, + entry[1], + step + ); + }); + }; + return reversedSequence; + } + + function filterFactory(collection, predicate, context, useKeys) { + var filterSequence = makeSequence(collection); + if (useKeys) { + filterSequence.has = function (key) { + var v = collection.get(key, NOT_SET); + return v !== NOT_SET && !!predicate.call(context, v, key, collection); + }; + filterSequence.get = function (key, notSetValue) { + var v = collection.get(key, NOT_SET); + return v !== NOT_SET && predicate.call(context, v, key, collection) + ? v + : notSetValue; + }; + } + filterSequence.__iterateUncached = function(fn, reverse) { + var this$1 = this; + + var iterations = 0; + collection.__iterate(function (v, k, c) { + if (predicate.call(context, v, k, c)) { + iterations++; + return fn(v, useKeys ? k : iterations - 1, this$1); + } + }, reverse); + return iterations; + }; + filterSequence.__iteratorUncached = function(type, reverse) { + var iterator = collection.__iterator(ITERATE_ENTRIES, reverse); + var iterations = 0; + return new Iterator(function () { + while (true) { + var step = iterator.next(); + if (step.done) { + return step; + } + var entry = step.value; + var key = entry[0]; + var value = entry[1]; + if (predicate.call(context, value, key, collection)) { + return iteratorValue(type, useKeys ? key : iterations++, value, step); + } + } + }); + }; + return filterSequence; + } + + function countByFactory(collection, grouper, context) { + var groups = Map().asMutable(); + collection.__iterate(function (v, k) { + groups.update(grouper.call(context, v, k, collection), 0, function (a) { return a + 1; }); + }); + return groups.asImmutable(); + } + + function groupByFactory(collection, grouper, context) { + var isKeyedIter = isKeyed(collection); + var groups = (isOrdered(collection) ? OrderedMap() : Map()).asMutable(); + collection.__iterate(function (v, k) { + groups.update( + grouper.call(context, v, k, collection), + function (a) { return ((a = a || []), a.push(isKeyedIter ? [k, v] : v), a); } + ); + }); + var coerce = collectionClass(collection); + return groups.map(function (arr) { return reify(collection, coerce(arr)); }); + } + + function sliceFactory(collection, begin, end, useKeys) { + var originalSize = collection.size; + + if (wholeSlice(begin, end, originalSize)) { + return collection; + } + + var resolvedBegin = resolveBegin(begin, originalSize); + var resolvedEnd = resolveEnd(end, originalSize); + + // begin or end will be NaN if they were provided as negative numbers and + // this collection's size is unknown. In that case, cache first so there is + // a known size and these do not resolve to NaN. + if (resolvedBegin !== resolvedBegin || resolvedEnd !== resolvedEnd) { + return sliceFactory(collection.toSeq().cacheResult(), begin, end, useKeys); + } + + // Note: resolvedEnd is undefined when the original sequence's length is + // unknown and this slice did not supply an end and should contain all + // elements after resolvedBegin. + // In that case, resolvedSize will be NaN and sliceSize will remain undefined. + var resolvedSize = resolvedEnd - resolvedBegin; + var sliceSize; + if (resolvedSize === resolvedSize) { + sliceSize = resolvedSize < 0 ? 0 : resolvedSize; + } + + var sliceSeq = makeSequence(collection); + + // If collection.size is undefined, the size of the realized sliceSeq is + // unknown at this point unless the number of items to slice is 0 + sliceSeq.size = + sliceSize === 0 ? sliceSize : (collection.size && sliceSize) || undefined; + + if (!useKeys && isSeq(collection) && sliceSize >= 0) { + sliceSeq.get = function(index, notSetValue) { + index = wrapIndex(this, index); + return index >= 0 && index < sliceSize + ? collection.get(index + resolvedBegin, notSetValue) + : notSetValue; + }; + } + + sliceSeq.__iterateUncached = function(fn, reverse) { + var this$1 = this; + + if (sliceSize === 0) { + return 0; + } + if (reverse) { + return this.cacheResult().__iterate(fn, reverse); + } + var skipped = 0; + var isSkipping = true; + var iterations = 0; + collection.__iterate(function (v, k) { + if (!(isSkipping && (isSkipping = skipped++ < resolvedBegin))) { + iterations++; + return ( + fn(v, useKeys ? k : iterations - 1, this$1) !== false && + iterations !== sliceSize + ); + } + }); + return iterations; + }; + + sliceSeq.__iteratorUncached = function(type, reverse) { + if (sliceSize !== 0 && reverse) { + return this.cacheResult().__iterator(type, reverse); + } + // Don't bother instantiating parent iterator if taking 0. + if (sliceSize === 0) { + return new Iterator(iteratorDone); + } + var iterator = collection.__iterator(type, reverse); + var skipped = 0; + var iterations = 0; + return new Iterator(function () { + while (skipped++ < resolvedBegin) { + iterator.next(); + } + if (++iterations > sliceSize) { + return iteratorDone(); + } + var step = iterator.next(); + if (useKeys || type === ITERATE_VALUES || step.done) { + return step; + } + if (type === ITERATE_KEYS) { + return iteratorValue(type, iterations - 1, undefined, step); + } + return iteratorValue(type, iterations - 1, step.value[1], step); + }); + }; + + return sliceSeq; + } + + function takeWhileFactory(collection, predicate, context) { + var takeSequence = makeSequence(collection); + takeSequence.__iterateUncached = function(fn, reverse) { + var this$1 = this; + + if (reverse) { + return this.cacheResult().__iterate(fn, reverse); + } + var iterations = 0; + collection.__iterate( + function (v, k, c) { return predicate.call(context, v, k, c) && ++iterations && fn(v, k, this$1); } + ); + return iterations; + }; + takeSequence.__iteratorUncached = function(type, reverse) { + var this$1 = this; + + if (reverse) { + return this.cacheResult().__iterator(type, reverse); + } + var iterator = collection.__iterator(ITERATE_ENTRIES, reverse); + var iterating = true; + return new Iterator(function () { + if (!iterating) { + return iteratorDone(); + } + var step = iterator.next(); + if (step.done) { + return step; + } + var entry = step.value; + var k = entry[0]; + var v = entry[1]; + if (!predicate.call(context, v, k, this$1)) { + iterating = false; + return iteratorDone(); + } + return type === ITERATE_ENTRIES ? step : iteratorValue(type, k, v, step); + }); + }; + return takeSequence; + } + + function skipWhileFactory(collection, predicate, context, useKeys) { + var skipSequence = makeSequence(collection); + skipSequence.__iterateUncached = function(fn, reverse) { + var this$1 = this; + + if (reverse) { + return this.cacheResult().__iterate(fn, reverse); + } + var isSkipping = true; + var iterations = 0; + collection.__iterate(function (v, k, c) { + if (!(isSkipping && (isSkipping = predicate.call(context, v, k, c)))) { + iterations++; + return fn(v, useKeys ? k : iterations - 1, this$1); + } + }); + return iterations; + }; + skipSequence.__iteratorUncached = function(type, reverse) { + var this$1 = this; + + if (reverse) { + return this.cacheResult().__iterator(type, reverse); + } + var iterator = collection.__iterator(ITERATE_ENTRIES, reverse); + var skipping = true; + var iterations = 0; + return new Iterator(function () { + var step; + var k; + var v; + do { + step = iterator.next(); + if (step.done) { + if (useKeys || type === ITERATE_VALUES) { + return step; + } + if (type === ITERATE_KEYS) { + return iteratorValue(type, iterations++, undefined, step); + } + return iteratorValue(type, iterations++, step.value[1], step); + } + var entry = step.value; + k = entry[0]; + v = entry[1]; + skipping && (skipping = predicate.call(context, v, k, this$1)); + } while (skipping); + return type === ITERATE_ENTRIES ? step : iteratorValue(type, k, v, step); + }); + }; + return skipSequence; + } + + function concatFactory(collection, values) { + var isKeyedCollection = isKeyed(collection); + var iters = [collection] + .concat(values) + .map(function (v) { + if (!isCollection(v)) { + v = isKeyedCollection + ? keyedSeqFromValue(v) + : indexedSeqFromValue(Array.isArray(v) ? v : [v]); + } else if (isKeyedCollection) { + v = KeyedCollection(v); + } + return v; + }) + .filter(function (v) { return v.size !== 0; }); + + if (iters.length === 0) { + return collection; + } + + if (iters.length === 1) { + var singleton = iters[0]; + if ( + singleton === collection || + (isKeyedCollection && isKeyed(singleton)) || + (isIndexed(collection) && isIndexed(singleton)) + ) { + return singleton; + } + } + + var concatSeq = new ArraySeq(iters); + if (isKeyedCollection) { + concatSeq = concatSeq.toKeyedSeq(); + } else if (!isIndexed(collection)) { + concatSeq = concatSeq.toSetSeq(); + } + concatSeq = concatSeq.flatten(true); + concatSeq.size = iters.reduce(function (sum, seq) { + if (sum !== undefined) { + var size = seq.size; + if (size !== undefined) { + return sum + size; + } + } + }, 0); + return concatSeq; + } + + function flattenFactory(collection, depth, useKeys) { + var flatSequence = makeSequence(collection); + flatSequence.__iterateUncached = function(fn, reverse) { + if (reverse) { + return this.cacheResult().__iterate(fn, reverse); + } + var iterations = 0; + var stopped = false; + function flatDeep(iter, currentDepth) { + iter.__iterate(function (v, k) { + if ((!depth || currentDepth < depth) && isCollection(v)) { + flatDeep(v, currentDepth + 1); + } else { + iterations++; + if (fn(v, useKeys ? k : iterations - 1, flatSequence) === false) { + stopped = true; + } + } + return !stopped; + }, reverse); + } + flatDeep(collection, 0); + return iterations; + }; + flatSequence.__iteratorUncached = function(type, reverse) { + if (reverse) { + return this.cacheResult().__iterator(type, reverse); + } + var iterator = collection.__iterator(type, reverse); + var stack = []; + var iterations = 0; + return new Iterator(function () { + while (iterator) { + var step = iterator.next(); + if (step.done !== false) { + iterator = stack.pop(); + continue; + } + var v = step.value; + if (type === ITERATE_ENTRIES) { + v = v[1]; + } + if ((!depth || stack.length < depth) && isCollection(v)) { + stack.push(iterator); + iterator = v.__iterator(type, reverse); + } else { + return useKeys ? step : iteratorValue(type, iterations++, v, step); + } + } + return iteratorDone(); + }); + }; + return flatSequence; + } + + function flatMapFactory(collection, mapper, context) { + var coerce = collectionClass(collection); + return collection + .toSeq() + .map(function (v, k) { return coerce(mapper.call(context, v, k, collection)); }) + .flatten(true); + } + + function interposeFactory(collection, separator) { + var interposedSequence = makeSequence(collection); + interposedSequence.size = collection.size && collection.size * 2 - 1; + interposedSequence.__iterateUncached = function(fn, reverse) { + var this$1 = this; + + var iterations = 0; + collection.__iterate( + function (v) { return (!iterations || fn(separator, iterations++, this$1) !== false) && + fn(v, iterations++, this$1) !== false; }, + reverse + ); + return iterations; + }; + interposedSequence.__iteratorUncached = function(type, reverse) { + var iterator = collection.__iterator(ITERATE_VALUES, reverse); + var iterations = 0; + var step; + return new Iterator(function () { + if (!step || iterations % 2) { + step = iterator.next(); + if (step.done) { + return step; + } + } + return iterations % 2 + ? iteratorValue(type, iterations++, separator) + : iteratorValue(type, iterations++, step.value, step); + }); + }; + return interposedSequence; + } + + function sortFactory(collection, comparator, mapper) { + if (!comparator) { + comparator = defaultComparator; + } + var isKeyedCollection = isKeyed(collection); + var index = 0; + var entries = collection + .toSeq() + .map(function (v, k) { return [k, v, index++, mapper ? mapper(v, k, collection) : v]; }) + .valueSeq() + .toArray(); + entries.sort(function (a, b) { return comparator(a[3], b[3]) || a[2] - b[2]; }).forEach( + isKeyedCollection + ? function (v, i) { + entries[i].length = 2; + } + : function (v, i) { + entries[i] = v[1]; + } + ); + return isKeyedCollection + ? KeyedSeq(entries) : isIndexed(collection) - ? IndexedSeq - : SetSeq - ).prototype - ); -} - -function cacheResultThrough() { - if (this._iter.cacheResult) { - this._iter.cacheResult(); - this.size = this._iter.size; - return this; + ? IndexedSeq(entries) + : SetSeq(entries); + } + + function maxFactory(collection, comparator, mapper) { + if (!comparator) { + comparator = defaultComparator; + } + if (mapper) { + var entry = collection + .toSeq() + .map(function (v, k) { return [v, mapper(v, k, collection)]; }) + .reduce(function (a, b) { return (maxCompare(comparator, a[1], b[1]) ? b : a); }); + return entry && entry[0]; + } + return collection.reduce(function (a, b) { return (maxCompare(comparator, a, b) ? b : a); }); + } + + function maxCompare(comparator, a, b) { + var comp = comparator(b, a); + // b is considered the new max if the comparator declares them equal, but + // they are not equal and b is in fact a nullish value. + return ( + (comp === 0 && b !== a && (b === undefined || b === null || b !== b)) || + comp > 0 + ); + } + + function zipWithFactory(keyIter, zipper, iters, zipAll) { + var zipSequence = makeSequence(keyIter); + var sizes = new ArraySeq(iters).map(function (i) { return i.size; }); + zipSequence.size = zipAll ? sizes.max() : sizes.min(); + // Note: this a generic base implementation of __iterate in terms of + // __iterator which may be more generically useful in the future. + zipSequence.__iterate = function(fn, reverse) { + var this$1 = this; + + /* generic: + var iterator = this.__iterator(ITERATE_ENTRIES, reverse); + var step; + var iterations = 0; + while (!(step = iterator.next()).done) { + iterations++; + if (fn(step.value[1], step.value[0], this) === false) { + break; + } + } + return iterations; + */ + // indexed: + var iterator = this.__iterator(ITERATE_VALUES, reverse); + var step; + var iterations = 0; + while (!(step = iterator.next()).done) { + if (fn(step.value, iterations++, this$1) === false) { + break; + } + } + return iterations; + }; + zipSequence.__iteratorUncached = function(type, reverse) { + var iterators = iters.map( + function (i) { return ((i = Collection(i)), getIterator(reverse ? i.reverse() : i)); } + ); + var iterations = 0; + var isDone = false; + return new Iterator(function () { + var steps; + if (!isDone) { + steps = iterators.map(function (i) { return i.next(); }); + isDone = zipAll ? steps.every(function (s) { return s.done; }) : steps.some(function (s) { return s.done; }); + } + if (isDone) { + return iteratorDone(); + } + return iteratorValue( + type, + iterations++, + zipper.apply(null, steps.map(function (s) { return s.value; })) + ); + }); + }; + return zipSequence; + } + + // #pragma Helper Functions + + function reify(iter, seq) { + return iter === seq ? iter : isSeq(iter) ? seq : iter.constructor(seq); + } + + function validateEntry(entry) { + if (entry !== Object(entry)) { + throw new TypeError('Expected [K, V] tuple: ' + entry); + } + } + + function collectionClass(collection) { + return isKeyed(collection) + ? KeyedCollection + : isIndexed(collection) + ? IndexedCollection + : SetCollection; + } + + function makeSequence(collection) { + return Object.create( + (isKeyed(collection) + ? KeyedSeq + : isIndexed(collection) + ? IndexedSeq + : SetSeq + ).prototype + ); + } + + function cacheResultThrough() { + if (this._iter.cacheResult) { + this._iter.cacheResult(); + this.size = this._iter.size; + return this; + } + return Seq.prototype.cacheResult.call(this); + } + + function defaultComparator(a, b) { + if (a === undefined && b === undefined) { + return 0; + } + + if (a === undefined) { + return 1; + } + + if (b === undefined) { + return -1; + } + + return a > b ? 1 : a < b ? -1 : 0; + } + + // http://jsperf.com/copy-array-inline + function arrCopy(arr, offset) { + offset = offset || 0; + var len = Math.max(0, arr.length - offset); + var newArr = new Array(len); + for (var ii = 0; ii < len; ii++) { + newArr[ii] = arr[ii + offset]; + } + return newArr; + } + + function invariant(condition, error) { + if (!condition) { throw new Error(error); } + } + + function assertNotInfinite(size) { + invariant( + size !== Infinity, + 'Cannot perform this action with an infinite size.' + ); + } + + function coerceKeyPath(keyPath) { + if (isArrayLike(keyPath) && typeof keyPath !== 'string') { + return keyPath; + } + if (isOrdered(keyPath)) { + return keyPath.toArray(); + } + throw new TypeError( + 'Invalid keyPath: expected Ordered Collection or Array: ' + keyPath + ); + } + + function isPlainObj(value) { + return ( + value && (value.constructor === Object || value.constructor === undefined) + ); + } + + /** + * Returns true if the value is a potentially-persistent data structure, either + * provided by Immutable.js or a plain Array or Object. + */ + function isDataStructure(value) { + return isImmutable(value) || Array.isArray(value) || isPlainObj(value); + } + + /** + * Converts a value to a string, adding quotes if a string was provided. + */ + function quoteString(value) { + try { + return typeof value === 'string' ? JSON.stringify(value) : String(value); + } catch (_ignoreError) { + return JSON.stringify(value); + } + } + + function has(collection, key) { + return isImmutable(collection) + ? collection.has(key) + : isDataStructure(collection) && hasOwnProperty.call(collection, key); + } + + function get(collection, key, notSetValue) { + return isImmutable(collection) + ? collection.get(key, notSetValue) + : !has(collection, key) + ? notSetValue + : typeof collection.get === 'function' + ? collection.get(key) + : collection[key]; + } + + function shallowCopy(from) { + if (Array.isArray(from)) { + return arrCopy(from); + } + var to = {}; + for (var key in from) { + if (hasOwnProperty.call(from, key)) { + to[key] = from[key]; + } + } + return to; + } + + function remove(collection, key) { + if (!isDataStructure(collection)) { + throw new TypeError( + 'Cannot update non-data-structure value: ' + collection + ); + } + if (isImmutable(collection)) { + if (!collection.remove) { + throw new TypeError( + 'Cannot update immutable value without .remove() method: ' + collection + ); + } + return collection.remove(key); + } + if (!hasOwnProperty.call(collection, key)) { + return collection; + } + var collectionCopy = shallowCopy(collection); + if (Array.isArray(collectionCopy)) { + collectionCopy.splice(key, 1); + } else { + delete collectionCopy[key]; + } + return collectionCopy; + } + + function set(collection, key, value) { + if (!isDataStructure(collection)) { + throw new TypeError( + 'Cannot update non-data-structure value: ' + collection + ); + } + if (isImmutable(collection)) { + if (!collection.set) { + throw new TypeError( + 'Cannot update immutable value without .set() method: ' + collection + ); + } + return collection.set(key, value); + } + if (hasOwnProperty.call(collection, key) && value === collection[key]) { + return collection; + } + var collectionCopy = shallowCopy(collection); + collectionCopy[key] = value; + return collectionCopy; + } + + function updateIn(collection, keyPath, notSetValue, updater) { + if (!updater) { + updater = notSetValue; + notSetValue = undefined; + } + var updatedValue = updateInDeeply( + isImmutable(collection), + collection, + coerceKeyPath(keyPath), + 0, + notSetValue, + updater + ); + return updatedValue === NOT_SET ? notSetValue : updatedValue; + } + + function updateInDeeply( + inImmutable, + existing, + keyPath, + i, + notSetValue, + updater + ) { + var wasNotSet = existing === NOT_SET; + if (i === keyPath.length) { + var existingValue = wasNotSet ? notSetValue : existing; + var newValue = updater(existingValue); + return newValue === existingValue ? existing : newValue; + } + if (!wasNotSet && !isDataStructure(existing)) { + throw new TypeError( + 'Cannot update within non-data-structure value in path [' + + keyPath.slice(0, i).map(quoteString) + + ']: ' + + existing + ); + } + var key = keyPath[i]; + var nextExisting = wasNotSet ? NOT_SET : get(existing, key, NOT_SET); + var nextUpdated = updateInDeeply( + nextExisting === NOT_SET ? inImmutable : isImmutable(nextExisting), + nextExisting, + keyPath, + i + 1, + notSetValue, + updater + ); + return nextUpdated === nextExisting + ? existing + : nextUpdated === NOT_SET + ? remove(existing, key) + : set( + wasNotSet ? (inImmutable ? emptyMap() : {}) : existing, + key, + nextUpdated + ); + } + + function setIn(collection, keyPath, value) { + return updateIn(collection, keyPath, NOT_SET, function () { return value; }); + } + + function setIn$1(keyPath, v) { + return setIn(this, keyPath, v); + } + + function removeIn(collection, keyPath) { + return updateIn(collection, keyPath, function () { return NOT_SET; }); + } + + function deleteIn(keyPath) { + return removeIn(this, keyPath); } - return Seq.prototype.cacheResult.call(this); -} -function defaultComparator(a, b) { - if (a === undefined && b === undefined) { - return 0; + function update(collection, key, notSetValue, updater) { + return updateIn(collection, [key], notSetValue, updater); + } + + function update$1(key, notSetValue, updater) { + return arguments.length === 1 + ? key(this) + : update(this, key, notSetValue, updater); + } + + function updateIn$1(keyPath, notSetValue, updater) { + return updateIn(this, keyPath, notSetValue, updater); + } + + function merge() { + var iters = [], len = arguments.length; + while ( len-- ) iters[ len ] = arguments[ len ]; + + return mergeIntoKeyedWith(this, iters); + } + + function mergeWith(merger) { + var iters = [], len = arguments.length - 1; + while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; + + return mergeIntoKeyedWith(this, iters, merger); + } + + function mergeIntoKeyedWith(collection, collections, merger) { + var iters = []; + for (var ii = 0; ii < collections.length; ii++) { + var collection$1 = KeyedCollection(collections[ii]); + if (collection$1.size !== 0) { + iters.push(collection$1); + } + } + if (iters.length === 0) { + return collection; + } + if ( + collection.toSeq().size === 0 && + !collection.__ownerID && + iters.length === 1 + ) { + return collection.constructor(iters[0]); + } + return collection.withMutations(function (collection) { + var mergeIntoCollection = merger + ? function (value, key) { + update( + collection, + key, + NOT_SET, + function (oldVal) { return (oldVal === NOT_SET ? value : merger(oldVal, value, key)); } + ); + } + : function (value, key) { + collection.set(key, value); + }; + for (var ii = 0; ii < iters.length; ii++) { + iters[ii].forEach(mergeIntoCollection); + } + }); + } + + function merge$1(collection) { + var sources = [], len = arguments.length - 1; + while ( len-- > 0 ) sources[ len ] = arguments[ len + 1 ]; + + return mergeWithSources(collection, sources); + } + + function mergeWith$1(merger, collection) { + var sources = [], len = arguments.length - 2; + while ( len-- > 0 ) sources[ len ] = arguments[ len + 2 ]; + + return mergeWithSources(collection, sources, merger); + } + + function mergeDeep(collection) { + var sources = [], len = arguments.length - 1; + while ( len-- > 0 ) sources[ len ] = arguments[ len + 1 ]; + + return mergeDeepWithSources(collection, sources); + } + + function mergeDeepWith(merger, collection) { + var sources = [], len = arguments.length - 2; + while ( len-- > 0 ) sources[ len ] = arguments[ len + 2 ]; + + return mergeDeepWithSources(collection, sources, merger); } - if (a === undefined) { - return 1; + function mergeDeepWithSources(collection, sources, merger) { + return mergeWithSources(collection, sources, deepMergerWith(merger)); } - if (b === undefined) { - return -1; + function mergeWithSources(collection, sources, merger) { + if (!isDataStructure(collection)) { + throw new TypeError( + 'Cannot merge into non-data-structure value: ' + collection + ); + } + if (isImmutable(collection)) { + return collection.mergeWith + ? collection.mergeWith.apply(collection, [ merger ].concat( sources )) + : collection.concat.apply(collection, sources); + } + var isArray = Array.isArray(collection); + var merged = collection; + var Collection$$1 = isArray ? IndexedCollection : KeyedCollection; + var mergeItem = isArray + ? function (value) { + // Copy on write + if (merged === collection) { + merged = shallowCopy(merged); + } + merged.push(value); + } + : function (value, key) { + var hasVal = hasOwnProperty.call(merged, key); + var nextVal = + hasVal && merger ? merger(merged[key], value, key) : value; + if (!hasVal || nextVal !== merged[key]) { + // Copy on write + if (merged === collection) { + merged = shallowCopy(merged); + } + merged[key] = nextVal; + } + }; + for (var i = 0; i < sources.length; i++) { + Collection$$1(sources[i]).forEach(mergeItem); + } + return merged; } - return a > b ? 1 : a < b ? -1 : 0; -} - -// http://jsperf.com/copy-array-inline -function arrCopy(arr, offset) { - offset = offset || 0; - var len = Math.max(0, arr.length - offset); - var newArr = new Array(len); - for (var ii = 0; ii < len; ii++) { - newArr[ii] = arr[ii + offset]; + function deepMergerWith(merger) { + function deepMerger(oldValue, newValue, key) { + return isDataStructure(oldValue) && isDataStructure(newValue) + ? mergeWithSources(oldValue, [newValue], deepMerger) + : merger + ? merger(oldValue, newValue, key) + : newValue; + } + return deepMerger; } - return newArr; -} -function invariant(condition, error) { - if (!condition) { throw new Error(error); } -} - -function assertNotInfinite(size) { - invariant( - size !== Infinity, - 'Cannot perform this action with an infinite size.' - ); -} + function mergeDeep$1() { + var iters = [], len = arguments.length; + while ( len-- ) iters[ len ] = arguments[ len ]; -function coerceKeyPath(keyPath) { - if (isArrayLike(keyPath) && typeof keyPath !== 'string') { - return keyPath; - } - if (isOrdered(keyPath)) { - return keyPath.toArray(); + return mergeDeepWithSources(this, iters); } - throw new TypeError( - 'Invalid keyPath: expected Ordered Collection or Array: ' + keyPath - ); -} -function isPlainObj(value) { - return ( - value && (value.constructor === Object || value.constructor === undefined) - ); -} + function mergeDeepWith$1(merger) { + var iters = [], len = arguments.length - 1; + while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; -/** - * Returns true if the value is a potentially-persistent data structure, either - * provided by Immutable.js or a plain Array or Object. - */ -function isDataStructure(value) { - return isImmutable(value) || Array.isArray(value) || isPlainObj(value); -} + return mergeDeepWithSources(this, iters, merger); + } -/** - * Converts a value to a string, adding quotes if a string was provided. - */ -function quoteString(value) { - try { - return typeof value === 'string' ? JSON.stringify(value) : String(value); - } catch (_ignoreError) { - return JSON.stringify(value); - } -} - -function has(collection, key) { - return isImmutable(collection) - ? collection.has(key) - : isDataStructure(collection) && hasOwnProperty.call(collection, key); -} - -function get(collection, key, notSetValue) { - return isImmutable(collection) - ? collection.get(key, notSetValue) - : !has(collection, key) - ? notSetValue - : typeof collection.get === 'function' - ? collection.get(key) - : collection[key]; -} + function mergeIn(keyPath) { + var iters = [], len = arguments.length - 1; + while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; -function shallowCopy(from) { - if (Array.isArray(from)) { - return arrCopy(from); - } - var to = {}; - for (var key in from) { - if (hasOwnProperty.call(from, key)) { - to[key] = from[key]; - } + return updateIn(this, keyPath, emptyMap(), function (m) { return mergeWithSources(m, iters); }); } - return to; -} -function remove(collection, key) { - if (!isDataStructure(collection)) { - throw new TypeError( - 'Cannot update non-data-structure value: ' + collection + function mergeDeepIn(keyPath) { + var iters = [], len = arguments.length - 1; + while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; + + return updateIn(this, keyPath, emptyMap(), function (m) { return mergeDeepWithSources(m, iters); } ); } - if (isImmutable(collection)) { - if (!collection.remove) { - throw new TypeError( - 'Cannot update immutable value without .remove() method: ' + collection - ); - } - return collection.remove(key); + + function withMutations(fn) { + var mutable = this.asMutable(); + fn(mutable); + return mutable.wasAltered() ? mutable.__ensureOwner(this.__ownerID) : this; } - if (!hasOwnProperty.call(collection, key)) { - return collection; + + function asMutable() { + return this.__ownerID ? this : this.__ensureOwner(new OwnerID()); } - var collectionCopy = shallowCopy(collection); - if (Array.isArray(collectionCopy)) { - collectionCopy.splice(key, 1); - } else { - delete collectionCopy[key]; + + function asImmutable() { + return this.__ensureOwner(); } - return collectionCopy; -} -function set(collection, key, value) { - if (!isDataStructure(collection)) { - throw new TypeError( - 'Cannot update non-data-structure value: ' + collection - ); + function wasAltered() { + return this.__altered; } - if (isImmutable(collection)) { - if (!collection.set) { - throw new TypeError( - 'Cannot update immutable value without .set() method: ' + collection - ); + + var Map = (function (KeyedCollection$$1) { + function Map(value) { + return value === null || value === undefined + ? emptyMap() + : isMap(value) && !isOrdered(value) + ? value + : emptyMap().withMutations(function (map) { + var iter = KeyedCollection$$1(value); + assertNotInfinite(iter.size); + iter.forEach(function (v, k) { return map.set(k, v); }); + }); } - return collection.set(key, value); - } - if (hasOwnProperty.call(collection, key) && value === collection[key]) { - return collection; - } - var collectionCopy = shallowCopy(collection); - collectionCopy[key] = value; - return collectionCopy; -} - -function updateIn(collection, keyPath, notSetValue, updater) { - if (!updater) { - updater = notSetValue; - notSetValue = undefined; - } - var updatedValue = updateInDeeply( - isImmutable(collection), - collection, - coerceKeyPath(keyPath), - 0, - notSetValue, - updater - ); - return updatedValue === NOT_SET ? notSetValue : updatedValue; -} - -function updateInDeeply( - inImmutable, - existing, - keyPath, - i, - notSetValue, - updater -) { - var wasNotSet = existing === NOT_SET; - if (i === keyPath.length) { - var existingValue = wasNotSet ? notSetValue : existing; - var newValue = updater(existingValue); - return newValue === existingValue ? existing : newValue; - } - if (!wasNotSet && !isDataStructure(existing)) { - throw new TypeError( - 'Cannot update within non-data-structure value in path [' + - keyPath.slice(0, i).map(quoteString) + - ']: ' + - existing - ); - } - var key = keyPath[i]; - var nextExisting = wasNotSet ? NOT_SET : get(existing, key, NOT_SET); - var nextUpdated = updateInDeeply( - nextExisting === NOT_SET ? inImmutable : isImmutable(nextExisting), - nextExisting, - keyPath, - i + 1, - notSetValue, - updater - ); - return nextUpdated === nextExisting - ? existing - : nextUpdated === NOT_SET - ? remove(existing, key) - : set( - wasNotSet ? (inImmutable ? emptyMap() : {}) : existing, - key, - nextUpdated - ); -} -function setIn$1(collection, keyPath, value) { - return updateIn(collection, keyPath, NOT_SET, function () { return value; }); -} + if ( KeyedCollection$$1 ) Map.__proto__ = KeyedCollection$$1; + Map.prototype = Object.create( KeyedCollection$$1 && KeyedCollection$$1.prototype ); + Map.prototype.constructor = Map; -function setIn$$1(keyPath, v) { - return setIn$1(this, keyPath, v); -} + Map.of = function of () { + var keyValues = [], len = arguments.length; + while ( len-- ) keyValues[ len ] = arguments[ len ]; -function removeIn(collection, keyPath) { - return updateIn(collection, keyPath, function () { return NOT_SET; }); -} + return emptyMap().withMutations(function (map) { + for (var i = 0; i < keyValues.length; i += 2) { + if (i + 1 >= keyValues.length) { + throw new Error('Missing value for key: ' + keyValues[i]); + } + map.set(keyValues[i], keyValues[i + 1]); + } + }); + }; -function deleteIn(keyPath) { - return removeIn(this, keyPath); -} + Map.prototype.toString = function toString () { + return this.__toString('Map {', '}'); + }; -function update$1(collection, key, notSetValue, updater) { - return updateIn(collection, [key], notSetValue, updater); -} + // @pragma Access -function update$$1(key, notSetValue, updater) { - return arguments.length === 1 - ? key(this) - : update$1(this, key, notSetValue, updater); -} + Map.prototype.get = function get (k, notSetValue) { + return this._root + ? this._root.get(0, undefined, k, notSetValue) + : notSetValue; + }; -function updateIn$1(keyPath, notSetValue, updater) { - return updateIn(this, keyPath, notSetValue, updater); -} + // @pragma Modification -function merge() { - var iters = [], len = arguments.length; - while ( len-- ) iters[ len ] = arguments[ len ]; + Map.prototype.set = function set (k, v) { + return updateMap(this, k, v); + }; - return mergeIntoKeyedWith(this, iters); -} + Map.prototype.remove = function remove (k) { + return updateMap(this, k, NOT_SET); + }; -function mergeWith(merger) { - var iters = [], len = arguments.length - 1; - while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; + Map.prototype.deleteAll = function deleteAll (keys) { + var collection = Collection(keys); - return mergeIntoKeyedWith(this, iters, merger); -} + if (collection.size === 0) { + return this; + } -function mergeIntoKeyedWith(collection, collections, merger) { - var iters = []; - for (var ii = 0; ii < collections.length; ii++) { - var collection$1 = KeyedCollection(collections[ii]); - if (collection$1.size !== 0) { - iters.push(collection$1); - } - } - if (iters.length === 0) { - return collection; - } - if ( - collection.toSeq().size === 0 && - !collection.__ownerID && - iters.length === 1 - ) { - return collection.constructor(iters[0]); - } - return collection.withMutations(function (collection) { - var mergeIntoCollection = merger - ? function (value, key) { - update$1( - collection, - key, - NOT_SET, - function (oldVal) { return (oldVal === NOT_SET ? value : merger(oldVal, value, key)); } - ); - } - : function (value, key) { - collection.set(key, value); - }; - for (var ii = 0; ii < iters.length; ii++) { - iters[ii].forEach(mergeIntoCollection); - } - }); -} + return this.withMutations(function (map) { + collection.forEach(function (key) { return map.remove(key); }); + }); + }; -function merge$1(collection) { - var sources = [], len = arguments.length - 1; - while ( len-- > 0 ) sources[ len ] = arguments[ len + 1 ]; + Map.prototype.clear = function clear () { + if (this.size === 0) { + return this; + } + if (this.__ownerID) { + this.size = 0; + this._root = null; + this.__hash = undefined; + this.__altered = true; + return this; + } + return emptyMap(); + }; - return mergeWithSources(collection, sources); -} + // @pragma Composition -function mergeWith$1(merger, collection) { - var sources = [], len = arguments.length - 2; - while ( len-- > 0 ) sources[ len ] = arguments[ len + 2 ]; + Map.prototype.sort = function sort (comparator) { + // Late binding + return OrderedMap(sortFactory(this, comparator)); + }; - return mergeWithSources(collection, sources, merger); -} + Map.prototype.sortBy = function sortBy (mapper, comparator) { + // Late binding + return OrderedMap(sortFactory(this, comparator, mapper)); + }; -function mergeDeep$1(collection) { - var sources = [], len = arguments.length - 1; - while ( len-- > 0 ) sources[ len ] = arguments[ len + 1 ]; + Map.prototype.map = function map (mapper, context) { + return this.withMutations(function (map) { + map.forEach(function (value, key) { + map.set(key, mapper.call(context, value, key, map)); + }); + }); + }; - return mergeDeepWithSources(collection, sources); -} + // @pragma Mutability -function mergeDeepWith$1(merger, collection) { - var sources = [], len = arguments.length - 2; - while ( len-- > 0 ) sources[ len ] = arguments[ len + 2 ]; + Map.prototype.__iterator = function __iterator (type, reverse) { + return new MapIterator(this, type, reverse); + }; - return mergeDeepWithSources(collection, sources, merger); -} + Map.prototype.__iterate = function __iterate (fn, reverse) { + var this$1 = this; -function mergeDeepWithSources(collection, sources, merger) { - return mergeWithSources(collection, sources, deepMergerWith(merger)); -} + var iterations = 0; + this._root && + this._root.iterate(function (entry) { + iterations++; + return fn(entry[1], entry[0], this$1); + }, reverse); + return iterations; + }; -function mergeWithSources(collection, sources, merger) { - if (!isDataStructure(collection)) { - throw new TypeError( - 'Cannot merge into non-data-structure value: ' + collection - ); - } - if (isImmutable(collection)) { - return collection.mergeWith - ? collection.mergeWith.apply(collection, [ merger ].concat( sources )) - : collection.concat.apply(collection, sources); - } - var isArray = Array.isArray(collection); - var merged = collection; - var Collection$$1 = isArray ? IndexedCollection : KeyedCollection; - var mergeItem = isArray - ? function (value) { - // Copy on write - if (merged === collection) { - merged = shallowCopy(merged); - } - merged.push(value); + Map.prototype.__ensureOwner = function __ensureOwner (ownerID) { + if (ownerID === this.__ownerID) { + return this; } - : function (value, key) { - var hasVal = hasOwnProperty.call(merged, key); - var nextVal = - hasVal && merger ? merger(merged[key], value, key) : value; - if (!hasVal || nextVal !== merged[key]) { - // Copy on write - if (merged === collection) { - merged = shallowCopy(merged); - } - merged[key] = nextVal; + if (!ownerID) { + if (this.size === 0) { + return emptyMap(); } - }; - for (var i = 0; i < sources.length; i++) { - Collection$$1(sources[i]).forEach(mergeItem); - } - return merged; -} - -function deepMergerWith(merger) { - function deepMerger(oldValue, newValue, key) { - return isDataStructure(oldValue) && isDataStructure(newValue) - ? mergeWithSources(oldValue, [newValue], deepMerger) - : merger - ? merger(oldValue, newValue, key) - : newValue; - } - return deepMerger; -} - -function mergeDeep() { - var iters = [], len = arguments.length; - while ( len-- ) iters[ len ] = arguments[ len ]; - - return mergeDeepWithSources(this, iters); -} - -function mergeDeepWith(merger) { - var iters = [], len = arguments.length - 1; - while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; - - return mergeDeepWithSources(this, iters, merger); -} - -function mergeIn(keyPath) { - var iters = [], len = arguments.length - 1; - while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; - - return updateIn(this, keyPath, emptyMap(), function (m) { return mergeWithSources(m, iters); }); -} - -function mergeDeepIn(keyPath) { - var iters = [], len = arguments.length - 1; - while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; - - return updateIn(this, keyPath, emptyMap(), function (m) { return mergeDeepWithSources(m, iters); } - ); -} - -function withMutations(fn) { - var mutable = this.asMutable(); - fn(mutable); - return mutable.wasAltered() ? mutable.__ensureOwner(this.__ownerID) : this; -} - -function asMutable() { - return this.__ownerID ? this : this.__ensureOwner(new OwnerID()); -} - -function asImmutable() { - return this.__ensureOwner(); -} - -function wasAltered() { - return this.__altered; -} - -var Map = (function (KeyedCollection$$1) { - function Map(value) { - return value === null || value === undefined - ? emptyMap() - : isMap(value) && !isOrdered(value) - ? value - : emptyMap().withMutations(function (map) { - var iter = KeyedCollection$$1(value); - assertNotInfinite(iter.size); - iter.forEach(function (v, k) { return map.set(k, v); }); - }); + this.__ownerID = ownerID; + this.__altered = false; + return this; + } + return makeMap(this.size, this._root, ownerID, this.__hash); + }; + + return Map; + }(KeyedCollection)); + + function isMap(maybeMap) { + return !!(maybeMap && maybeMap[IS_MAP_SENTINEL]); } - if ( KeyedCollection$$1 ) Map.__proto__ = KeyedCollection$$1; - Map.prototype = Object.create( KeyedCollection$$1 && KeyedCollection$$1.prototype ); - Map.prototype.constructor = Map; + Map.isMap = isMap; - Map.of = function of () { - var keyValues = [], len = arguments.length; - while ( len-- ) keyValues[ len ] = arguments[ len ]; + var IS_MAP_SENTINEL = '@@__IMMUTABLE_MAP__@@'; - return emptyMap().withMutations(function (map) { - for (var i = 0; i < keyValues.length; i += 2) { - if (i + 1 >= keyValues.length) { - throw new Error('Missing value for key: ' + keyValues[i]); - } - map.set(keyValues[i], keyValues[i + 1]); - } - }); + var MapPrototype = Map.prototype; + MapPrototype[IS_MAP_SENTINEL] = true; + MapPrototype[DELETE] = MapPrototype.remove; + MapPrototype.removeAll = MapPrototype.deleteAll; + MapPrototype.setIn = setIn$1; + MapPrototype.removeIn = MapPrototype.deleteIn = deleteIn; + MapPrototype.update = update$1; + MapPrototype.updateIn = updateIn$1; + MapPrototype.merge = MapPrototype.concat = merge; + MapPrototype.mergeWith = mergeWith; + MapPrototype.mergeDeep = mergeDeep$1; + MapPrototype.mergeDeepWith = mergeDeepWith$1; + MapPrototype.mergeIn = mergeIn; + MapPrototype.mergeDeepIn = mergeDeepIn; + MapPrototype.withMutations = withMutations; + MapPrototype.wasAltered = wasAltered; + MapPrototype.asImmutable = asImmutable; + MapPrototype['@@transducer/init'] = MapPrototype.asMutable = asMutable; + MapPrototype['@@transducer/step'] = function(result, arr) { + return result.set(arr[0], arr[1]); }; - - Map.prototype.toString = function toString () { - return this.__toString('Map {', '}'); + MapPrototype['@@transducer/result'] = function(obj) { + return obj.asImmutable(); }; - // @pragma Access + // #pragma Trie Nodes - Map.prototype.get = function get (k, notSetValue) { - return this._root - ? this._root.get(0, undefined, k, notSetValue) - : notSetValue; + var ArrayMapNode = function ArrayMapNode(ownerID, entries) { + this.ownerID = ownerID; + this.entries = entries; }; - // @pragma Modification + ArrayMapNode.prototype.get = function get (shift, keyHash, key, notSetValue) { + var entries = this.entries; + for (var ii = 0, len = entries.length; ii < len; ii++) { + if (is(key, entries[ii][0])) { + return entries[ii][1]; + } + } + return notSetValue; + }; + + ArrayMapNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { + var removed = value === NOT_SET; + + var entries = this.entries; + var idx = 0; + var len = entries.length; + for (; idx < len; idx++) { + if (is(key, entries[idx][0])) { + break; + } + } + var exists = idx < len; + + if (exists ? entries[idx][1] === value : removed) { + return this; + } + + SetRef(didAlter); + (removed || !exists) && SetRef(didChangeSize); + + if (removed && entries.length === 1) { + return; // undefined + } - Map.prototype.set = function set (k, v) { - return updateMap(this, k, v); + if (!exists && !removed && entries.length >= MAX_ARRAY_MAP_SIZE) { + return createNodes(ownerID, entries, key, value); + } + + var isEditable = ownerID && ownerID === this.ownerID; + var newEntries = isEditable ? entries : arrCopy(entries); + + if (exists) { + if (removed) { + idx === len - 1 + ? newEntries.pop() + : (newEntries[idx] = newEntries.pop()); + } else { + newEntries[idx] = [key, value]; + } + } else { + newEntries.push([key, value]); + } + + if (isEditable) { + this.entries = newEntries; + return this; + } + + return new ArrayMapNode(ownerID, newEntries); + }; + + var BitmapIndexedNode = function BitmapIndexedNode(ownerID, bitmap, nodes) { + this.ownerID = ownerID; + this.bitmap = bitmap; + this.nodes = nodes; }; - Map.prototype.remove = function remove (k) { - return updateMap(this, k, NOT_SET); + BitmapIndexedNode.prototype.get = function get (shift, keyHash, key, notSetValue) { + if (keyHash === undefined) { + keyHash = hash(key); + } + var bit = 1 << ((shift === 0 ? keyHash : keyHash >>> shift) & MASK); + var bitmap = this.bitmap; + return (bitmap & bit) === 0 + ? notSetValue + : this.nodes[popCount(bitmap & (bit - 1))].get( + shift + SHIFT, + keyHash, + key, + notSetValue + ); }; - Map.prototype.deleteAll = function deleteAll (keys) { - var collection = Collection(keys); + BitmapIndexedNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { + if (keyHash === undefined) { + keyHash = hash(key); + } + var keyHashFrag = (shift === 0 ? keyHash : keyHash >>> shift) & MASK; + var bit = 1 << keyHashFrag; + var bitmap = this.bitmap; + var exists = (bitmap & bit) !== 0; - if (collection.size === 0) { + if (!exists && value === NOT_SET) { return this; } - return this.withMutations(function (map) { - collection.forEach(function (key) { return map.remove(key); }); - }); - }; + var idx = popCount(bitmap & (bit - 1)); + var nodes = this.nodes; + var node = exists ? nodes[idx] : undefined; + var newNode = updateNode( + node, + ownerID, + shift + SHIFT, + keyHash, + key, + value, + didChangeSize, + didAlter + ); - Map.prototype.clear = function clear () { - if (this.size === 0) { + if (newNode === node) { return this; } - if (this.__ownerID) { - this.size = 0; - this._root = null; - this.__hash = undefined; - this.__altered = true; + + if (!exists && newNode && nodes.length >= MAX_BITMAP_INDEXED_SIZE) { + return expandNodes(ownerID, nodes, bitmap, keyHashFrag, newNode); + } + + if ( + exists && + !newNode && + nodes.length === 2 && + isLeafNode(nodes[idx ^ 1]) + ) { + return nodes[idx ^ 1]; + } + + if (exists && newNode && nodes.length === 1 && isLeafNode(newNode)) { + return newNode; + } + + var isEditable = ownerID && ownerID === this.ownerID; + var newBitmap = exists ? (newNode ? bitmap : bitmap ^ bit) : bitmap | bit; + var newNodes = exists + ? newNode + ? setAt(nodes, idx, newNode, isEditable) + : spliceOut(nodes, idx, isEditable) + : spliceIn(nodes, idx, newNode, isEditable); + + if (isEditable) { + this.bitmap = newBitmap; + this.nodes = newNodes; return this; } - return emptyMap(); + + return new BitmapIndexedNode(ownerID, newBitmap, newNodes); }; - // @pragma Composition + var HashArrayMapNode = function HashArrayMapNode(ownerID, count, nodes) { + this.ownerID = ownerID; + this.count = count; + this.nodes = nodes; + }; - Map.prototype.sort = function sort (comparator) { - // Late binding - return OrderedMap(sortFactory(this, comparator)); + HashArrayMapNode.prototype.get = function get (shift, keyHash, key, notSetValue) { + if (keyHash === undefined) { + keyHash = hash(key); + } + var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK; + var node = this.nodes[idx]; + return node + ? node.get(shift + SHIFT, keyHash, key, notSetValue) + : notSetValue; }; - Map.prototype.sortBy = function sortBy (mapper, comparator) { - // Late binding - return OrderedMap(sortFactory(this, comparator, mapper)); + HashArrayMapNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { + if (keyHash === undefined) { + keyHash = hash(key); + } + var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK; + var removed = value === NOT_SET; + var nodes = this.nodes; + var node = nodes[idx]; + + if (removed && !node) { + return this; + } + + var newNode = updateNode( + node, + ownerID, + shift + SHIFT, + keyHash, + key, + value, + didChangeSize, + didAlter + ); + if (newNode === node) { + return this; + } + + var newCount = this.count; + if (!node) { + newCount++; + } else if (!newNode) { + newCount--; + if (newCount < MIN_HASH_ARRAY_MAP_SIZE) { + return packNodes(ownerID, nodes, newCount, idx); + } + } + + var isEditable = ownerID && ownerID === this.ownerID; + var newNodes = setAt(nodes, idx, newNode, isEditable); + + if (isEditable) { + this.count = newCount; + this.nodes = newNodes; + return this; + } + + return new HashArrayMapNode(ownerID, newCount, newNodes); }; - Map.prototype.map = function map (mapper, context) { - return this.withMutations(function (map) { - map.forEach(function (value, key) { - map.set(key, mapper.call(context, value, key, map)); - }); - }); + var HashCollisionNode = function HashCollisionNode(ownerID, keyHash, entries) { + this.ownerID = ownerID; + this.keyHash = keyHash; + this.entries = entries; + }; + + HashCollisionNode.prototype.get = function get (shift, keyHash, key, notSetValue) { + var entries = this.entries; + for (var ii = 0, len = entries.length; ii < len; ii++) { + if (is(key, entries[ii][0])) { + return entries[ii][1]; + } + } + return notSetValue; }; - // @pragma Mutability + HashCollisionNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { + if (keyHash === undefined) { + keyHash = hash(key); + } + + var removed = value === NOT_SET; + + if (keyHash !== this.keyHash) { + if (removed) { + return this; + } + SetRef(didAlter); + SetRef(didChangeSize); + return mergeIntoNode(this, ownerID, shift, keyHash, [key, value]); + } + + var entries = this.entries; + var idx = 0; + var len = entries.length; + for (; idx < len; idx++) { + if (is(key, entries[idx][0])) { + break; + } + } + var exists = idx < len; + + if (exists ? entries[idx][1] === value : removed) { + return this; + } + + SetRef(didAlter); + (removed || !exists) && SetRef(didChangeSize); + + if (removed && len === 2) { + return new ValueNode(ownerID, this.keyHash, entries[idx ^ 1]); + } + + var isEditable = ownerID && ownerID === this.ownerID; + var newEntries = isEditable ? entries : arrCopy(entries); + + if (exists) { + if (removed) { + idx === len - 1 + ? newEntries.pop() + : (newEntries[idx] = newEntries.pop()); + } else { + newEntries[idx] = [key, value]; + } + } else { + newEntries.push([key, value]); + } + + if (isEditable) { + this.entries = newEntries; + return this; + } - Map.prototype.__iterator = function __iterator (type, reverse) { - return new MapIterator(this, type, reverse); + return new HashCollisionNode(ownerID, this.keyHash, newEntries); }; - Map.prototype.__iterate = function __iterate (fn, reverse) { - var this$1 = this; + var ValueNode = function ValueNode(ownerID, keyHash, entry) { + this.ownerID = ownerID; + this.keyHash = keyHash; + this.entry = entry; + }; - var iterations = 0; - this._root && - this._root.iterate(function (entry) { - iterations++; - return fn(entry[1], entry[0], this$1); - }, reverse); - return iterations; + ValueNode.prototype.get = function get (shift, keyHash, key, notSetValue) { + return is(key, this.entry[0]) ? this.entry[1] : notSetValue; }; - Map.prototype.__ensureOwner = function __ensureOwner (ownerID) { - if (ownerID === this.__ownerID) { + ValueNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { + var removed = value === NOT_SET; + var keyMatch = is(key, this.entry[0]); + if (keyMatch ? value === this.entry[1] : removed) { return this; } - if (!ownerID) { - if (this.size === 0) { - return emptyMap(); + + SetRef(didAlter); + + if (removed) { + SetRef(didChangeSize); + return; // undefined + } + + if (keyMatch) { + if (ownerID && ownerID === this.ownerID) { + this.entry[1] = value; + return this; } - this.__ownerID = ownerID; - this.__altered = false; - return this; + return new ValueNode(ownerID, this.keyHash, [key, value]); } - return makeMap(this.size, this._root, ownerID, this.__hash); + + SetRef(didChangeSize); + return mergeIntoNode(this, ownerID, shift, hash(key), [key, value]); }; - return Map; -}(KeyedCollection)); - -function isMap(maybeMap) { - return !!(maybeMap && maybeMap[IS_MAP_SENTINEL]); -} - -Map.isMap = isMap; - -var IS_MAP_SENTINEL = '@@__IMMUTABLE_MAP__@@'; - -var MapPrototype = Map.prototype; -MapPrototype[IS_MAP_SENTINEL] = true; -MapPrototype[DELETE] = MapPrototype.remove; -MapPrototype.removeAll = MapPrototype.deleteAll; -MapPrototype.setIn = setIn$$1; -MapPrototype.removeIn = MapPrototype.deleteIn = deleteIn; -MapPrototype.update = update$$1; -MapPrototype.updateIn = updateIn$1; -MapPrototype.merge = MapPrototype.concat = merge; -MapPrototype.mergeWith = mergeWith; -MapPrototype.mergeDeep = mergeDeep; -MapPrototype.mergeDeepWith = mergeDeepWith; -MapPrototype.mergeIn = mergeIn; -MapPrototype.mergeDeepIn = mergeDeepIn; -MapPrototype.withMutations = withMutations; -MapPrototype.wasAltered = wasAltered; -MapPrototype.asImmutable = asImmutable; -MapPrototype['@@transducer/init'] = MapPrototype.asMutable = asMutable; -MapPrototype['@@transducer/step'] = function(result, arr) { - return result.set(arr[0], arr[1]); -}; -MapPrototype['@@transducer/result'] = function(obj) { - return obj.asImmutable(); -}; - -// #pragma Trie Nodes - -var ArrayMapNode = function ArrayMapNode(ownerID, entries) { - this.ownerID = ownerID; - this.entries = entries; -}; - -ArrayMapNode.prototype.get = function get (shift, keyHash, key, notSetValue) { - var entries = this.entries; - for (var ii = 0, len = entries.length; ii < len; ii++) { - if (is(key, entries[ii][0])) { - return entries[ii][1]; - } - } - return notSetValue; -}; - -ArrayMapNode.prototype.update = function update$$1 (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { - var removed = value === NOT_SET; - - var entries = this.entries; - var idx = 0; - var len = entries.length; - for (; idx < len; idx++) { - if (is(key, entries[idx][0])) { - break; - } - } - var exists = idx < len; - - if (exists ? entries[idx][1] === value : removed) { - return this; - } + // #pragma Iterators + + ArrayMapNode.prototype.iterate = HashCollisionNode.prototype.iterate = function( + fn, + reverse + ) { + var entries = this.entries; + for (var ii = 0, maxIndex = entries.length - 1; ii <= maxIndex; ii++) { + if (fn(entries[reverse ? maxIndex - ii : ii]) === false) { + return false; + } + } + }; + + BitmapIndexedNode.prototype.iterate = HashArrayMapNode.prototype.iterate = function( + fn, + reverse + ) { + var nodes = this.nodes; + for (var ii = 0, maxIndex = nodes.length - 1; ii <= maxIndex; ii++) { + var node = nodes[reverse ? maxIndex - ii : ii]; + if (node && node.iterate(fn, reverse) === false) { + return false; + } + } + }; + + // eslint-disable-next-line no-unused-vars + ValueNode.prototype.iterate = function(fn, reverse) { + return fn(this.entry); + }; + + var MapIterator = (function (Iterator$$1) { + function MapIterator(map, type, reverse) { + this._type = type; + this._reverse = reverse; + this._stack = map._root && mapIteratorFrame(map._root); + } - SetRef(didAlter); - (removed || !exists) && SetRef(didChangeSize); + if ( Iterator$$1 ) MapIterator.__proto__ = Iterator$$1; + MapIterator.prototype = Object.create( Iterator$$1 && Iterator$$1.prototype ); + MapIterator.prototype.constructor = MapIterator; - if (removed && entries.length === 1) { - return; // undefined - } + MapIterator.prototype.next = function next () { + var this$1 = this; - if (!exists && !removed && entries.length >= MAX_ARRAY_MAP_SIZE) { - return createNodes(ownerID, entries, key, value); - } + var type = this._type; + var stack = this._stack; + while (stack) { + var node = stack.node; + var index = stack.index++; + var maxIndex = (void 0); + if (node.entry) { + if (index === 0) { + return mapIteratorValue(type, node.entry); + } + } else if (node.entries) { + maxIndex = node.entries.length - 1; + if (index <= maxIndex) { + return mapIteratorValue( + type, + node.entries[this$1._reverse ? maxIndex - index : index] + ); + } + } else { + maxIndex = node.nodes.length - 1; + if (index <= maxIndex) { + var subNode = node.nodes[this$1._reverse ? maxIndex - index : index]; + if (subNode) { + if (subNode.entry) { + return mapIteratorValue(type, subNode.entry); + } + stack = this$1._stack = mapIteratorFrame(subNode, stack); + } + continue; + } + } + stack = this$1._stack = this$1._stack.__prev; + } + return iteratorDone(); + }; - var isEditable = ownerID && ownerID === this.ownerID; - var newEntries = isEditable ? entries : arrCopy(entries); + return MapIterator; + }(Iterator)); - if (exists) { - if (removed) { - idx === len - 1 - ? newEntries.pop() - : (newEntries[idx] = newEntries.pop()); - } else { - newEntries[idx] = [key, value]; - } - } else { - newEntries.push([key, value]); + function mapIteratorValue(type, entry) { + return iteratorValue(type, entry[0], entry[1]); } - if (isEditable) { - this.entries = newEntries; - return this; + function mapIteratorFrame(node, prev) { + return { + node: node, + index: 0, + __prev: prev, + }; } - return new ArrayMapNode(ownerID, newEntries); -}; - -var BitmapIndexedNode = function BitmapIndexedNode(ownerID, bitmap, nodes) { - this.ownerID = ownerID; - this.bitmap = bitmap; - this.nodes = nodes; -}; - -BitmapIndexedNode.prototype.get = function get (shift, keyHash, key, notSetValue) { - if (keyHash === undefined) { - keyHash = hash(key); + function makeMap(size, root, ownerID, hash$$1) { + var map = Object.create(MapPrototype); + map.size = size; + map._root = root; + map.__ownerID = ownerID; + map.__hash = hash$$1; + map.__altered = false; + return map; } - var bit = 1 << ((shift === 0 ? keyHash : keyHash >>> shift) & MASK); - var bitmap = this.bitmap; - return (bitmap & bit) === 0 - ? notSetValue - : this.nodes[popCount(bitmap & (bit - 1))].get( - shift + SHIFT, - keyHash, - key, - notSetValue - ); -}; -BitmapIndexedNode.prototype.update = function update$$1 (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { - if (keyHash === undefined) { - keyHash = hash(key); + var EMPTY_MAP; + function emptyMap() { + return EMPTY_MAP || (EMPTY_MAP = makeMap(0)); } - var keyHashFrag = (shift === 0 ? keyHash : keyHash >>> shift) & MASK; - var bit = 1 << keyHashFrag; - var bitmap = this.bitmap; - var exists = (bitmap & bit) !== 0; - if (!exists && value === NOT_SET) { - return this; + function updateMap(map, k, v) { + var newRoot; + var newSize; + if (!map._root) { + if (v === NOT_SET) { + return map; + } + newSize = 1; + newRoot = new ArrayMapNode(map.__ownerID, [[k, v]]); + } else { + var didChangeSize = MakeRef(CHANGE_LENGTH); + var didAlter = MakeRef(DID_ALTER); + newRoot = updateNode( + map._root, + map.__ownerID, + 0, + undefined, + k, + v, + didChangeSize, + didAlter + ); + if (!didAlter.value) { + return map; + } + newSize = map.size + (didChangeSize.value ? (v === NOT_SET ? -1 : 1) : 0); + } + if (map.__ownerID) { + map.size = newSize; + map._root = newRoot; + map.__hash = undefined; + map.__altered = true; + return map; + } + return newRoot ? makeMap(newSize, newRoot) : emptyMap(); } - var idx = popCount(bitmap & (bit - 1)); - var nodes = this.nodes; - var node = exists ? nodes[idx] : undefined; - var newNode = updateNode( + function updateNode( node, ownerID, - shift + SHIFT, + shift, keyHash, key, value, didChangeSize, didAlter - ); - - if (newNode === node) { - return this; - } - - if (!exists && newNode && nodes.length >= MAX_BITMAP_INDEXED_SIZE) { - return expandNodes(ownerID, nodes, bitmap, keyHashFrag, newNode); - } - - if ( - exists && - !newNode && - nodes.length === 2 && - isLeafNode(nodes[idx ^ 1]) ) { - return nodes[idx ^ 1]; - } - - if (exists && newNode && nodes.length === 1 && isLeafNode(newNode)) { - return newNode; + if (!node) { + if (value === NOT_SET) { + return node; + } + SetRef(didAlter); + SetRef(didChangeSize); + return new ValueNode(ownerID, keyHash, [key, value]); + } + return node.update( + ownerID, + shift, + keyHash, + key, + value, + didChangeSize, + didAlter + ); } - var isEditable = ownerID && ownerID === this.ownerID; - var newBitmap = exists ? (newNode ? bitmap : bitmap ^ bit) : bitmap | bit; - var newNodes = exists - ? newNode - ? setAt(nodes, idx, newNode, isEditable) - : spliceOut(nodes, idx, isEditable) - : spliceIn(nodes, idx, newNode, isEditable); - - if (isEditable) { - this.bitmap = newBitmap; - this.nodes = newNodes; - return this; + function isLeafNode(node) { + return ( + node.constructor === ValueNode || node.constructor === HashCollisionNode + ); } - return new BitmapIndexedNode(ownerID, newBitmap, newNodes); -}; + function mergeIntoNode(node, ownerID, shift, keyHash, entry) { + if (node.keyHash === keyHash) { + return new HashCollisionNode(ownerID, keyHash, [node.entry, entry]); + } -var HashArrayMapNode = function HashArrayMapNode(ownerID, count, nodes) { - this.ownerID = ownerID; - this.count = count; - this.nodes = nodes; -}; + var idx1 = (shift === 0 ? node.keyHash : node.keyHash >>> shift) & MASK; + var idx2 = (shift === 0 ? keyHash : keyHash >>> shift) & MASK; -HashArrayMapNode.prototype.get = function get (shift, keyHash, key, notSetValue) { - if (keyHash === undefined) { - keyHash = hash(key); - } - var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK; - var node = this.nodes[idx]; - return node - ? node.get(shift + SHIFT, keyHash, key, notSetValue) - : notSetValue; -}; + var newNode; + var nodes = + idx1 === idx2 + ? [mergeIntoNode(node, ownerID, shift + SHIFT, keyHash, entry)] + : ((newNode = new ValueNode(ownerID, keyHash, entry)), + idx1 < idx2 ? [node, newNode] : [newNode, node]); -HashArrayMapNode.prototype.update = function update$$1 (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { - if (keyHash === undefined) { - keyHash = hash(key); + return new BitmapIndexedNode(ownerID, (1 << idx1) | (1 << idx2), nodes); } - var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK; - var removed = value === NOT_SET; - var nodes = this.nodes; - var node = nodes[idx]; - if (removed && !node) { - return this; + function createNodes(ownerID, entries, key, value) { + if (!ownerID) { + ownerID = new OwnerID(); + } + var node = new ValueNode(ownerID, hash(key), [key, value]); + for (var ii = 0; ii < entries.length; ii++) { + var entry = entries[ii]; + node = node.update(ownerID, 0, undefined, entry[0], entry[1]); + } + return node; } - var newNode = updateNode( - node, - ownerID, - shift + SHIFT, - keyHash, - key, - value, - didChangeSize, - didAlter - ); - if (newNode === node) { - return this; + function packNodes(ownerID, nodes, count, excluding) { + var bitmap = 0; + var packedII = 0; + var packedNodes = new Array(count); + for (var ii = 0, bit = 1, len = nodes.length; ii < len; ii++, bit <<= 1) { + var node = nodes[ii]; + if (node !== undefined && ii !== excluding) { + bitmap |= bit; + packedNodes[packedII++] = node; + } + } + return new BitmapIndexedNode(ownerID, bitmap, packedNodes); } - var newCount = this.count; - if (!node) { - newCount++; - } else if (!newNode) { - newCount--; - if (newCount < MIN_HASH_ARRAY_MAP_SIZE) { - return packNodes(ownerID, nodes, newCount, idx); + function expandNodes(ownerID, nodes, bitmap, including, node) { + var count = 0; + var expandedNodes = new Array(SIZE); + for (var ii = 0; bitmap !== 0; ii++, bitmap >>>= 1) { + expandedNodes[ii] = bitmap & 1 ? nodes[count++] : undefined; } + expandedNodes[including] = node; + return new HashArrayMapNode(ownerID, count + 1, expandedNodes); } - var isEditable = ownerID && ownerID === this.ownerID; - var newNodes = setAt(nodes, idx, newNode, isEditable); - - if (isEditable) { - this.count = newCount; - this.nodes = newNodes; - return this; + function popCount(x) { + x -= (x >> 1) & 0x55555555; + x = (x & 0x33333333) + ((x >> 2) & 0x33333333); + x = (x + (x >> 4)) & 0x0f0f0f0f; + x += x >> 8; + x += x >> 16; + return x & 0x7f; } - return new HashArrayMapNode(ownerID, newCount, newNodes); -}; - -var HashCollisionNode = function HashCollisionNode(ownerID, keyHash, entries) { - this.ownerID = ownerID; - this.keyHash = keyHash; - this.entries = entries; -}; + function setAt(array, idx, val, canEdit) { + var newArray = canEdit ? array : arrCopy(array); + newArray[idx] = val; + return newArray; + } -HashCollisionNode.prototype.get = function get (shift, keyHash, key, notSetValue) { - var entries = this.entries; - for (var ii = 0, len = entries.length; ii < len; ii++) { - if (is(key, entries[ii][0])) { - return entries[ii][1]; + function spliceIn(array, idx, val, canEdit) { + var newLen = array.length + 1; + if (canEdit && idx + 1 === newLen) { + array[idx] = val; + return array; + } + var newArray = new Array(newLen); + var after = 0; + for (var ii = 0; ii < newLen; ii++) { + if (ii === idx) { + newArray[ii] = val; + after = -1; + } else { + newArray[ii] = array[ii + after]; + } } + return newArray; } - return notSetValue; -}; -HashCollisionNode.prototype.update = function update$$1 (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { - if (keyHash === undefined) { - keyHash = hash(key); + function spliceOut(array, idx, canEdit) { + var newLen = array.length - 1; + if (canEdit && idx === newLen) { + array.pop(); + return array; + } + var newArray = new Array(newLen); + var after = 0; + for (var ii = 0; ii < newLen; ii++) { + if (ii === idx) { + after = 1; + } + newArray[ii] = array[ii + after]; + } + return newArray; } - var removed = value === NOT_SET; + var MAX_ARRAY_MAP_SIZE = SIZE / 4; + var MAX_BITMAP_INDEXED_SIZE = SIZE / 2; + var MIN_HASH_ARRAY_MAP_SIZE = SIZE / 4; - if (keyHash !== this.keyHash) { - if (removed) { - return this; + var List = (function (IndexedCollection$$1) { + function List(value) { + var empty = emptyList(); + if (value === null || value === undefined) { + return empty; + } + if (isList(value)) { + return value; + } + var iter = IndexedCollection$$1(value); + var size = iter.size; + if (size === 0) { + return empty; + } + assertNotInfinite(size); + if (size > 0 && size < SIZE) { + return makeList(0, size, SHIFT, null, new VNode(iter.toArray())); + } + return empty.withMutations(function (list) { + list.setSize(size); + iter.forEach(function (v, i) { return list.set(i, v); }); + }); } - SetRef(didAlter); - SetRef(didChangeSize); - return mergeIntoNode(this, ownerID, shift, keyHash, [key, value]); - } - var entries = this.entries; - var idx = 0; - var len = entries.length; - for (; idx < len; idx++) { - if (is(key, entries[idx][0])) { - break; - } - } - var exists = idx < len; + if ( IndexedCollection$$1 ) List.__proto__ = IndexedCollection$$1; + List.prototype = Object.create( IndexedCollection$$1 && IndexedCollection$$1.prototype ); + List.prototype.constructor = List; - if (exists ? entries[idx][1] === value : removed) { - return this; - } + List.of = function of (/*...values*/) { + return this(arguments); + }; - SetRef(didAlter); - (removed || !exists) && SetRef(didChangeSize); + List.prototype.toString = function toString () { + return this.__toString('List [', ']'); + }; - if (removed && len === 2) { - return new ValueNode(ownerID, this.keyHash, entries[idx ^ 1]); - } + // @pragma Access - var isEditable = ownerID && ownerID === this.ownerID; - var newEntries = isEditable ? entries : arrCopy(entries); + List.prototype.get = function get (index, notSetValue) { + index = wrapIndex(this, index); + if (index >= 0 && index < this.size) { + index += this._origin; + var node = listNodeFor(this, index); + return node && node.array[index & MASK]; + } + return notSetValue; + }; - if (exists) { - if (removed) { - idx === len - 1 - ? newEntries.pop() - : (newEntries[idx] = newEntries.pop()); - } else { - newEntries[idx] = [key, value]; - } - } else { - newEntries.push([key, value]); - } + // @pragma Modification - if (isEditable) { - this.entries = newEntries; - return this; - } + List.prototype.set = function set (index, value) { + return updateList(this, index, value); + }; - return new HashCollisionNode(ownerID, this.keyHash, newEntries); -}; + List.prototype.remove = function remove (index) { + return !this.has(index) + ? this + : index === 0 + ? this.shift() + : index === this.size - 1 + ? this.pop() + : this.splice(index, 1); + }; -var ValueNode = function ValueNode(ownerID, keyHash, entry) { - this.ownerID = ownerID; - this.keyHash = keyHash; - this.entry = entry; -}; + List.prototype.insert = function insert (index, value) { + return this.splice(index, 0, value); + }; -ValueNode.prototype.get = function get (shift, keyHash, key, notSetValue) { - return is(key, this.entry[0]) ? this.entry[1] : notSetValue; -}; + List.prototype.clear = function clear () { + if (this.size === 0) { + return this; + } + if (this.__ownerID) { + this.size = this._origin = this._capacity = 0; + this._level = SHIFT; + this._root = this._tail = null; + this.__hash = undefined; + this.__altered = true; + return this; + } + return emptyList(); + }; -ValueNode.prototype.update = function update$$1 (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { - var removed = value === NOT_SET; - var keyMatch = is(key, this.entry[0]); - if (keyMatch ? value === this.entry[1] : removed) { - return this; - } + List.prototype.push = function push (/*...values*/) { + var values = arguments; + var oldSize = this.size; + return this.withMutations(function (list) { + setListBounds(list, 0, oldSize + values.length); + for (var ii = 0; ii < values.length; ii++) { + list.set(oldSize + ii, values[ii]); + } + }); + }; - SetRef(didAlter); + List.prototype.pop = function pop () { + return setListBounds(this, 0, -1); + }; - if (removed) { - SetRef(didChangeSize); - return; // undefined - } + List.prototype.unshift = function unshift (/*...values*/) { + var values = arguments; + return this.withMutations(function (list) { + setListBounds(list, -values.length); + for (var ii = 0; ii < values.length; ii++) { + list.set(ii, values[ii]); + } + }); + }; - if (keyMatch) { - if (ownerID && ownerID === this.ownerID) { - this.entry[1] = value; - return this; - } - return new ValueNode(ownerID, this.keyHash, [key, value]); - } + List.prototype.shift = function shift () { + return setListBounds(this, 1); + }; - SetRef(didChangeSize); - return mergeIntoNode(this, ownerID, shift, hash(key), [key, value]); -}; + // @pragma Composition -// #pragma Iterators + List.prototype.concat = function concat (/*...collections*/) { + var arguments$1 = arguments; -ArrayMapNode.prototype.iterate = HashCollisionNode.prototype.iterate = function( - fn, - reverse -) { - var entries = this.entries; - for (var ii = 0, maxIndex = entries.length - 1; ii <= maxIndex; ii++) { - if (fn(entries[reverse ? maxIndex - ii : ii]) === false) { - return false; - } - } -}; + var seqs = []; + for (var i = 0; i < arguments.length; i++) { + var argument = arguments$1[i]; + var seq = IndexedCollection$$1( + typeof argument !== 'string' && hasIterator(argument) + ? argument + : [argument] + ); + if (seq.size !== 0) { + seqs.push(seq); + } + } + if (seqs.length === 0) { + return this; + } + if (this.size === 0 && !this.__ownerID && seqs.length === 1) { + return this.constructor(seqs[0]); + } + return this.withMutations(function (list) { + seqs.forEach(function (seq) { return seq.forEach(function (value) { return list.push(value); }); }); + }); + }; -BitmapIndexedNode.prototype.iterate = HashArrayMapNode.prototype.iterate = function( - fn, - reverse -) { - var nodes = this.nodes; - for (var ii = 0, maxIndex = nodes.length - 1; ii <= maxIndex; ii++) { - var node = nodes[reverse ? maxIndex - ii : ii]; - if (node && node.iterate(fn, reverse) === false) { - return false; - } - } -}; + List.prototype.setSize = function setSize (size) { + return setListBounds(this, 0, size); + }; -// eslint-disable-next-line no-unused-vars -ValueNode.prototype.iterate = function(fn, reverse) { - return fn(this.entry); -}; + List.prototype.map = function map (mapper, context) { + var this$1 = this; -var MapIterator = (function (Iterator$$1) { - function MapIterator(map, type, reverse) { - this._type = type; - this._reverse = reverse; - this._stack = map._root && mapIteratorFrame(map._root); - } + return this.withMutations(function (list) { + for (var i = 0; i < this$1.size; i++) { + list.set(i, mapper.call(context, list.get(i), i, list)); + } + }); + }; - if ( Iterator$$1 ) MapIterator.__proto__ = Iterator$$1; - MapIterator.prototype = Object.create( Iterator$$1 && Iterator$$1.prototype ); - MapIterator.prototype.constructor = MapIterator; + // @pragma Iteration - MapIterator.prototype.next = function next () { - var this$1 = this; + List.prototype.slice = function slice (begin, end) { + var size = this.size; + if (wholeSlice(begin, end, size)) { + return this; + } + return setListBounds( + this, + resolveBegin(begin, size), + resolveEnd(end, size) + ); + }; - var type = this._type; - var stack = this._stack; - while (stack) { - var node = stack.node; - var index = stack.index++; - var maxIndex = (void 0); - if (node.entry) { - if (index === 0) { - return mapIteratorValue(type, node.entry); - } - } else if (node.entries) { - maxIndex = node.entries.length - 1; - if (index <= maxIndex) { - return mapIteratorValue( - type, - node.entries[this$1._reverse ? maxIndex - index : index] - ); + List.prototype.__iterator = function __iterator (type, reverse) { + var index = reverse ? this.size : 0; + var values = iterateList(this, reverse); + return new Iterator(function () { + var value = values(); + return value === DONE + ? iteratorDone() + : iteratorValue(type, reverse ? --index : index++, value); + }); + }; + + List.prototype.__iterate = function __iterate (fn, reverse) { + var this$1 = this; + + var index = reverse ? this.size : 0; + var values = iterateList(this, reverse); + var value; + while ((value = values()) !== DONE) { + if (fn(value, reverse ? --index : index++, this$1) === false) { + break; } - } else { - maxIndex = node.nodes.length - 1; - if (index <= maxIndex) { - var subNode = node.nodes[this$1._reverse ? maxIndex - index : index]; - if (subNode) { - if (subNode.entry) { - return mapIteratorValue(type, subNode.entry); - } - stack = this$1._stack = mapIteratorFrame(subNode, stack); - } - continue; + } + return index; + }; + + List.prototype.__ensureOwner = function __ensureOwner (ownerID) { + if (ownerID === this.__ownerID) { + return this; + } + if (!ownerID) { + if (this.size === 0) { + return emptyList(); } + this.__ownerID = ownerID; + this.__altered = false; + return this; } - stack = this$1._stack = this$1._stack.__prev; - } - return iteratorDone(); - }; + return makeList( + this._origin, + this._capacity, + this._level, + this._root, + this._tail, + ownerID, + this.__hash + ); + }; + + return List; + }(IndexedCollection)); + + function isList(maybeList) { + return !!(maybeList && maybeList[IS_LIST_SENTINEL]); + } - return MapIterator; -}(Iterator)); + List.isList = isList; -function mapIteratorValue(type, entry) { - return iteratorValue(type, entry[0], entry[1]); -} + var IS_LIST_SENTINEL = '@@__IMMUTABLE_LIST__@@'; -function mapIteratorFrame(node, prev) { - return { - node: node, - index: 0, - __prev: prev, + var ListPrototype = List.prototype; + ListPrototype[IS_LIST_SENTINEL] = true; + ListPrototype[DELETE] = ListPrototype.remove; + ListPrototype.merge = ListPrototype.concat; + ListPrototype.setIn = setIn$1; + ListPrototype.deleteIn = ListPrototype.removeIn = deleteIn; + ListPrototype.update = update$1; + ListPrototype.updateIn = updateIn$1; + ListPrototype.mergeIn = mergeIn; + ListPrototype.mergeDeepIn = mergeDeepIn; + ListPrototype.withMutations = withMutations; + ListPrototype.wasAltered = wasAltered; + ListPrototype.asImmutable = asImmutable; + ListPrototype['@@transducer/init'] = ListPrototype.asMutable = asMutable; + ListPrototype['@@transducer/step'] = function(result, arr) { + return result.push(arr); + }; + ListPrototype['@@transducer/result'] = function(obj) { + return obj.asImmutable(); }; -} - -function makeMap(size, root, ownerID, hash$$1) { - var map = Object.create(MapPrototype); - map.size = size; - map._root = root; - map.__ownerID = ownerID; - map.__hash = hash$$1; - map.__altered = false; - return map; -} - -var EMPTY_MAP; -function emptyMap() { - return EMPTY_MAP || (EMPTY_MAP = makeMap(0)); -} - -function updateMap(map, k, v) { - var newRoot; - var newSize; - if (!map._root) { - if (v === NOT_SET) { - return map; - } - newSize = 1; - newRoot = new ArrayMapNode(map.__ownerID, [[k, v]]); - } else { - var didChangeSize = MakeRef(CHANGE_LENGTH); - var didAlter = MakeRef(DID_ALTER); - newRoot = updateNode( - map._root, - map.__ownerID, - 0, - undefined, - k, - v, - didChangeSize, - didAlter - ); - if (!didAlter.value) { - return map; - } - newSize = map.size + (didChangeSize.value ? (v === NOT_SET ? -1 : 1) : 0); - } - if (map.__ownerID) { - map.size = newSize; - map._root = newRoot; - map.__hash = undefined; - map.__altered = true; - return map; - } - return newRoot ? makeMap(newSize, newRoot) : emptyMap(); -} - -function updateNode( - node, - ownerID, - shift, - keyHash, - key, - value, - didChangeSize, - didAlter -) { - if (!node) { - if (value === NOT_SET) { - return node; - } - SetRef(didAlter); - SetRef(didChangeSize); - return new ValueNode(ownerID, keyHash, [key, value]); - } - return node.update( - ownerID, - shift, - keyHash, - key, - value, - didChangeSize, - didAlter - ); -} - -function isLeafNode(node) { - return ( - node.constructor === ValueNode || node.constructor === HashCollisionNode - ); -} - -function mergeIntoNode(node, ownerID, shift, keyHash, entry) { - if (node.keyHash === keyHash) { - return new HashCollisionNode(ownerID, keyHash, [node.entry, entry]); - } - - var idx1 = (shift === 0 ? node.keyHash : node.keyHash >>> shift) & MASK; - var idx2 = (shift === 0 ? keyHash : keyHash >>> shift) & MASK; - - var newNode; - var nodes = - idx1 === idx2 - ? [mergeIntoNode(node, ownerID, shift + SHIFT, keyHash, entry)] - : ((newNode = new ValueNode(ownerID, keyHash, entry)), - idx1 < idx2 ? [node, newNode] : [newNode, node]); - - return new BitmapIndexedNode(ownerID, (1 << idx1) | (1 << idx2), nodes); -} - -function createNodes(ownerID, entries, key, value) { - if (!ownerID) { - ownerID = new OwnerID(); - } - var node = new ValueNode(ownerID, hash(key), [key, value]); - for (var ii = 0; ii < entries.length; ii++) { - var entry = entries[ii]; - node = node.update(ownerID, 0, undefined, entry[0], entry[1]); - } - return node; -} - -function packNodes(ownerID, nodes, count, excluding) { - var bitmap = 0; - var packedII = 0; - var packedNodes = new Array(count); - for (var ii = 0, bit = 1, len = nodes.length; ii < len; ii++, bit <<= 1) { - var node = nodes[ii]; - if (node !== undefined && ii !== excluding) { - bitmap |= bit; - packedNodes[packedII++] = node; - } - } - return new BitmapIndexedNode(ownerID, bitmap, packedNodes); -} - -function expandNodes(ownerID, nodes, bitmap, including, node) { - var count = 0; - var expandedNodes = new Array(SIZE); - for (var ii = 0; bitmap !== 0; ii++, bitmap >>>= 1) { - expandedNodes[ii] = bitmap & 1 ? nodes[count++] : undefined; - } - expandedNodes[including] = node; - return new HashArrayMapNode(ownerID, count + 1, expandedNodes); -} - -function popCount(x) { - x -= (x >> 1) & 0x55555555; - x = (x & 0x33333333) + ((x >> 2) & 0x33333333); - x = (x + (x >> 4)) & 0x0f0f0f0f; - x += x >> 8; - x += x >> 16; - return x & 0x7f; -} - -function setAt(array, idx, val, canEdit) { - var newArray = canEdit ? array : arrCopy(array); - newArray[idx] = val; - return newArray; -} - -function spliceIn(array, idx, val, canEdit) { - var newLen = array.length + 1; - if (canEdit && idx + 1 === newLen) { - array[idx] = val; - return array; - } - var newArray = new Array(newLen); - var after = 0; - for (var ii = 0; ii < newLen; ii++) { - if (ii === idx) { - newArray[ii] = val; - after = -1; - } else { - newArray[ii] = array[ii + after]; - } - } - return newArray; -} -function spliceOut(array, idx, canEdit) { - var newLen = array.length - 1; - if (canEdit && idx === newLen) { - array.pop(); - return array; - } - var newArray = new Array(newLen); - var after = 0; - for (var ii = 0; ii < newLen; ii++) { - if (ii === idx) { - after = 1; - } - newArray[ii] = array[ii + after]; - } - return newArray; -} + var VNode = function VNode(array, ownerID) { + this.array = array; + this.ownerID = ownerID; + }; -var MAX_ARRAY_MAP_SIZE = SIZE / 4; -var MAX_BITMAP_INDEXED_SIZE = SIZE / 2; -var MIN_HASH_ARRAY_MAP_SIZE = SIZE / 4; + // TODO: seems like these methods are very similar -var List = (function (IndexedCollection$$1) { - function List(value) { - var empty = emptyList(); - if (value === null || value === undefined) { - return empty; + VNode.prototype.removeBefore = function removeBefore (ownerID, level, index) { + if (index === level ? 1 << level : this.array.length === 0) { + return this; } - if (isList(value)) { - return value; + var originIndex = (index >>> level) & MASK; + if (originIndex >= this.array.length) { + return new VNode([], ownerID); + } + var removingFirst = originIndex === 0; + var newChild; + if (level > 0) { + var oldChild = this.array[originIndex]; + newChild = + oldChild && oldChild.removeBefore(ownerID, level - SHIFT, index); + if (newChild === oldChild && removingFirst) { + return this; + } } - var iter = IndexedCollection$$1(value); - var size = iter.size; - if (size === 0) { - return empty; + if (removingFirst && !newChild) { + return this; } - assertNotInfinite(size); - if (size > 0 && size < SIZE) { - return makeList(0, size, SHIFT, null, new VNode(iter.toArray())); + var editable = editableVNode(this, ownerID); + if (!removingFirst) { + for (var ii = 0; ii < originIndex; ii++) { + editable.array[ii] = undefined; + } } - return empty.withMutations(function (list) { - list.setSize(size); - iter.forEach(function (v, i) { return list.set(i, v); }); - }); - } - - if ( IndexedCollection$$1 ) List.__proto__ = IndexedCollection$$1; - List.prototype = Object.create( IndexedCollection$$1 && IndexedCollection$$1.prototype ); - List.prototype.constructor = List; - - List.of = function of (/*...values*/) { - return this(arguments); + if (newChild) { + editable.array[originIndex] = newChild; + } + return editable; }; - List.prototype.toString = function toString () { - return this.__toString('List [', ']'); - }; + VNode.prototype.removeAfter = function removeAfter (ownerID, level, index) { + if (index === (level ? 1 << level : 0) || this.array.length === 0) { + return this; + } + var sizeIndex = ((index - 1) >>> level) & MASK; + if (sizeIndex >= this.array.length) { + return this; + } - // @pragma Access + var newChild; + if (level > 0) { + var oldChild = this.array[sizeIndex]; + newChild = + oldChild && oldChild.removeAfter(ownerID, level - SHIFT, index); + if (newChild === oldChild && sizeIndex === this.array.length - 1) { + return this; + } + } - List.prototype.get = function get (index, notSetValue) { - index = wrapIndex(this, index); - if (index >= 0 && index < this.size) { - index += this._origin; - var node = listNodeFor(this, index); - return node && node.array[index & MASK]; + var editable = editableVNode(this, ownerID); + editable.array.splice(sizeIndex + 1); + if (newChild) { + editable.array[sizeIndex] = newChild; } - return notSetValue; + return editable; }; - // @pragma Modification - - List.prototype.set = function set (index, value) { - return updateList(this, index, value); - }; + var DONE = {}; - List.prototype.remove = function remove (index) { - return !this.has(index) - ? this - : index === 0 - ? this.shift() - : index === this.size - 1 - ? this.pop() - : this.splice(index, 1); - }; + function iterateList(list, reverse) { + var left = list._origin; + var right = list._capacity; + var tailPos = getTailOffset(right); + var tail = list._tail; - List.prototype.insert = function insert (index, value) { - return this.splice(index, 0, value); - }; + return iterateNodeOrLeaf(list._root, list._level, 0); - List.prototype.clear = function clear () { - if (this.size === 0) { - return this; + function iterateNodeOrLeaf(node, level, offset) { + return level === 0 + ? iterateLeaf(node, offset) + : iterateNode(node, level, offset); } - if (this.__ownerID) { - this.size = this._origin = this._capacity = 0; - this._level = SHIFT; - this._root = this._tail = null; - this.__hash = undefined; - this.__altered = true; - return this; + + function iterateLeaf(node, offset) { + var array = offset === tailPos ? tail && tail.array : node && node.array; + var from = offset > left ? 0 : left - offset; + var to = right - offset; + if (to > SIZE) { + to = SIZE; + } + return function () { + if (from === to) { + return DONE; + } + var idx = reverse ? --to : from++; + return array && array[idx]; + }; } - return emptyList(); - }; - List.prototype.push = function push (/*...values*/) { - var values = arguments; - var oldSize = this.size; - return this.withMutations(function (list) { - setListBounds(list, 0, oldSize + values.length); - for (var ii = 0; ii < values.length; ii++) { - list.set(oldSize + ii, values[ii]); + function iterateNode(node, level, offset) { + var values; + var array = node && node.array; + var from = offset > left ? 0 : (left - offset) >> level; + var to = ((right - offset) >> level) + 1; + if (to > SIZE) { + to = SIZE; } - }); - }; + return function () { + while (true) { + if (values) { + var value = values(); + if (value !== DONE) { + return value; + } + values = null; + } + if (from === to) { + return DONE; + } + var idx = reverse ? --to : from++; + values = iterateNodeOrLeaf( + array && array[idx], + level - SHIFT, + offset + (idx << level) + ); + } + }; + } + } + + function makeList(origin, capacity, level, root, tail, ownerID, hash) { + var list = Object.create(ListPrototype); + list.size = capacity - origin; + list._origin = origin; + list._capacity = capacity; + list._level = level; + list._root = root; + list._tail = tail; + list.__ownerID = ownerID; + list.__hash = hash; + list.__altered = false; + return list; + } - List.prototype.pop = function pop () { - return setListBounds(this, 0, -1); - }; + var EMPTY_LIST; + function emptyList() { + return EMPTY_LIST || (EMPTY_LIST = makeList(0, 0, SHIFT)); + } - List.prototype.unshift = function unshift (/*...values*/) { - var values = arguments; - return this.withMutations(function (list) { - setListBounds(list, -values.length); - for (var ii = 0; ii < values.length; ii++) { - list.set(ii, values[ii]); - } - }); - }; + function updateList(list, index, value) { + index = wrapIndex(list, index); - List.prototype.shift = function shift () { - return setListBounds(this, 1); - }; + if (index !== index) { + return list; + } - // @pragma Composition + if (index >= list.size || index < 0) { + return list.withMutations(function (list) { + index < 0 + ? setListBounds(list, index).set(0, value) + : setListBounds(list, 0, index + 1).set(index, value); + }); + } - List.prototype.concat = function concat (/*...collections*/) { - var arguments$1 = arguments; + index += list._origin; - var seqs = []; - for (var i = 0; i < arguments.length; i++) { - var argument = arguments$1[i]; - var seq = IndexedCollection$$1( - typeof argument !== 'string' && hasIterator(argument) - ? argument - : [argument] + var newTail = list._tail; + var newRoot = list._root; + var didAlter = MakeRef(DID_ALTER); + if (index >= getTailOffset(list._capacity)) { + newTail = updateVNode(newTail, list.__ownerID, 0, index, value, didAlter); + } else { + newRoot = updateVNode( + newRoot, + list.__ownerID, + list._level, + index, + value, + didAlter ); - if (seq.size !== 0) { - seqs.push(seq); - } } - if (seqs.length === 0) { - return this; + + if (!didAlter.value) { + return list; } - if (this.size === 0 && !this.__ownerID && seqs.length === 1) { - return this.constructor(seqs[0]); + + if (list.__ownerID) { + list._root = newRoot; + list._tail = newTail; + list.__hash = undefined; + list.__altered = true; + return list; } - return this.withMutations(function (list) { - seqs.forEach(function (seq) { return seq.forEach(function (value) { return list.push(value); }); }); - }); - }; + return makeList(list._origin, list._capacity, list._level, newRoot, newTail); + } - List.prototype.setSize = function setSize (size) { - return setListBounds(this, 0, size); - }; + function updateVNode(node, ownerID, level, index, value, didAlter) { + var idx = (index >>> level) & MASK; + var nodeHas = node && idx < node.array.length; + if (!nodeHas && value === undefined) { + return node; + } - List.prototype.map = function map (mapper, context) { - var this$1 = this; + var newNode; - return this.withMutations(function (list) { - for (var i = 0; i < this$1.size; i++) { - list.set(i, mapper.call(context, list.get(i), i, list)); + if (level > 0) { + var lowerNode = node && node.array[idx]; + var newLowerNode = updateVNode( + lowerNode, + ownerID, + level - SHIFT, + index, + value, + didAlter + ); + if (newLowerNode === lowerNode) { + return node; } - }); - }; - - // @pragma Iteration + newNode = editableVNode(node, ownerID); + newNode.array[idx] = newLowerNode; + return newNode; + } - List.prototype.slice = function slice (begin, end) { - var size = this.size; - if (wholeSlice(begin, end, size)) { - return this; + if (nodeHas && node.array[idx] === value) { + return node; } - return setListBounds( - this, - resolveBegin(begin, size), - resolveEnd(end, size) - ); - }; - List.prototype.__iterator = function __iterator (type, reverse) { - var index = reverse ? this.size : 0; - var values = iterateList(this, reverse); - return new Iterator(function () { - var value = values(); - return value === DONE - ? iteratorDone() - : iteratorValue(type, reverse ? --index : index++, value); - }); - }; + SetRef(didAlter); - List.prototype.__iterate = function __iterate (fn, reverse) { - var this$1 = this; + newNode = editableVNode(node, ownerID); + if (value === undefined && idx === newNode.array.length - 1) { + newNode.array.pop(); + } else { + newNode.array[idx] = value; + } + return newNode; + } - var index = reverse ? this.size : 0; - var values = iterateList(this, reverse); - var value; - while ((value = values()) !== DONE) { - if (fn(value, reverse ? --index : index++, this$1) === false) { - break; - } + function editableVNode(node, ownerID) { + if (ownerID && node && ownerID === node.ownerID) { + return node; } - return index; - }; + return new VNode(node ? node.array.slice() : [], ownerID); + } - List.prototype.__ensureOwner = function __ensureOwner (ownerID) { - if (ownerID === this.__ownerID) { - return this; + function listNodeFor(list, rawIndex) { + if (rawIndex >= getTailOffset(list._capacity)) { + return list._tail; } - if (!ownerID) { - if (this.size === 0) { - return emptyList(); + if (rawIndex < 1 << (list._level + SHIFT)) { + var node = list._root; + var level = list._level; + while (node && level > 0) { + node = node.array[(rawIndex >>> level) & MASK]; + level -= SHIFT; } - this.__ownerID = ownerID; - this.__altered = false; - return this; + return node; } - return makeList( - this._origin, - this._capacity, - this._level, - this._root, - this._tail, - ownerID, - this.__hash - ); - }; - - return List; -}(IndexedCollection)); - -function isList(maybeList) { - return !!(maybeList && maybeList[IS_LIST_SENTINEL]); -} - -List.isList = isList; - -var IS_LIST_SENTINEL = '@@__IMMUTABLE_LIST__@@'; - -var ListPrototype = List.prototype; -ListPrototype[IS_LIST_SENTINEL] = true; -ListPrototype[DELETE] = ListPrototype.remove; -ListPrototype.merge = ListPrototype.concat; -ListPrototype.setIn = setIn$$1; -ListPrototype.deleteIn = ListPrototype.removeIn = deleteIn; -ListPrototype.update = update$$1; -ListPrototype.updateIn = updateIn$1; -ListPrototype.mergeIn = mergeIn; -ListPrototype.mergeDeepIn = mergeDeepIn; -ListPrototype.withMutations = withMutations; -ListPrototype.wasAltered = wasAltered; -ListPrototype.asImmutable = asImmutable; -ListPrototype['@@transducer/init'] = ListPrototype.asMutable = asMutable; -ListPrototype['@@transducer/step'] = function(result, arr) { - return result.push(arr); -}; -ListPrototype['@@transducer/result'] = function(obj) { - return obj.asImmutable(); -}; - -var VNode = function VNode(array, ownerID) { - this.array = array; - this.ownerID = ownerID; -}; - -// TODO: seems like these methods are very similar - -VNode.prototype.removeBefore = function removeBefore (ownerID, level, index) { - if (index === level ? 1 << level : 0 || this.array.length === 0) { - return this; } - var originIndex = (index >>> level) & MASK; - if (originIndex >= this.array.length) { - return new VNode([], ownerID); - } - var removingFirst = originIndex === 0; - var newChild; - if (level > 0) { - var oldChild = this.array[originIndex]; - newChild = - oldChild && oldChild.removeBefore(ownerID, level - SHIFT, index); - if (newChild === oldChild && removingFirst) { - return this; + + function setListBounds(list, begin, end) { + // Sanitize begin & end using this shorthand for ToInt32(argument) + // http://www.ecma-international.org/ecma-262/6.0/#sec-toint32 + if (begin !== undefined) { + begin |= 0; } - } - if (removingFirst && !newChild) { - return this; - } - var editable = editableVNode(this, ownerID); - if (!removingFirst) { - for (var ii = 0; ii < originIndex; ii++) { - editable.array[ii] = undefined; + if (end !== undefined) { + end |= 0; + } + var owner = list.__ownerID || new OwnerID(); + var oldOrigin = list._origin; + var oldCapacity = list._capacity; + var newOrigin = oldOrigin + begin; + var newCapacity = + end === undefined + ? oldCapacity + : end < 0 + ? oldCapacity + end + : oldOrigin + end; + if (newOrigin === oldOrigin && newCapacity === oldCapacity) { + return list; } - } - if (newChild) { - editable.array[originIndex] = newChild; - } - return editable; -}; - -VNode.prototype.removeAfter = function removeAfter (ownerID, level, index) { - if (index === (level ? 1 << level : 0) || this.array.length === 0) { - return this; - } - var sizeIndex = ((index - 1) >>> level) & MASK; - if (sizeIndex >= this.array.length) { - return this; - } - var newChild; - if (level > 0) { - var oldChild = this.array[sizeIndex]; - newChild = - oldChild && oldChild.removeAfter(ownerID, level - SHIFT, index); - if (newChild === oldChild && sizeIndex === this.array.length - 1) { - return this; + // If it's going to end after it starts, it's empty. + if (newOrigin >= newCapacity) { + return list.clear(); } - } - var editable = editableVNode(this, ownerID); - editable.array.splice(sizeIndex + 1); - if (newChild) { - editable.array[sizeIndex] = newChild; - } - return editable; -}; + var newLevel = list._level; + var newRoot = list._root; -var DONE = {}; + // New origin might need creating a higher root. + var offsetShift = 0; + while (newOrigin + offsetShift < 0) { + newRoot = new VNode( + newRoot && newRoot.array.length ? [undefined, newRoot] : [], + owner + ); + newLevel += SHIFT; + offsetShift += 1 << newLevel; + } + if (offsetShift) { + newOrigin += offsetShift; + oldOrigin += offsetShift; + newCapacity += offsetShift; + oldCapacity += offsetShift; + } -function iterateList(list, reverse) { - var left = list._origin; - var right = list._capacity; - var tailPos = getTailOffset(right); - var tail = list._tail; + var oldTailOffset = getTailOffset(oldCapacity); + var newTailOffset = getTailOffset(newCapacity); - return iterateNodeOrLeaf(list._root, list._level, 0); + // New size might need creating a higher root. + while (newTailOffset >= 1 << (newLevel + SHIFT)) { + newRoot = new VNode( + newRoot && newRoot.array.length ? [newRoot] : [], + owner + ); + newLevel += SHIFT; + } - function iterateNodeOrLeaf(node, level, offset) { - return level === 0 - ? iterateLeaf(node, offset) - : iterateNode(node, level, offset); - } + // Locate or create the new tail. + var oldTail = list._tail; + var newTail = + newTailOffset < oldTailOffset + ? listNodeFor(list, newCapacity - 1) + : newTailOffset > oldTailOffset + ? new VNode([], owner) + : oldTail; - function iterateLeaf(node, offset) { - var array = offset === tailPos ? tail && tail.array : node && node.array; - var from = offset > left ? 0 : left - offset; - var to = right - offset; - if (to > SIZE) { - to = SIZE; - } - return function () { - if (from === to) { - return DONE; + // Merge Tail into tree. + if ( + oldTail && + newTailOffset > oldTailOffset && + newOrigin < oldCapacity && + oldTail.array.length + ) { + newRoot = editableVNode(newRoot, owner); + var node = newRoot; + for (var level = newLevel; level > SHIFT; level -= SHIFT) { + var idx = (oldTailOffset >>> level) & MASK; + node = node.array[idx] = editableVNode(node.array[idx], owner); } - var idx = reverse ? --to : from++; - return array && array[idx]; - }; - } + node.array[(oldTailOffset >>> SHIFT) & MASK] = oldTail; + } - function iterateNode(node, level, offset) { - var values; - var array = node && node.array; - var from = offset > left ? 0 : (left - offset) >> level; - var to = ((right - offset) >> level) + 1; - if (to > SIZE) { - to = SIZE; + // If the size has been reduced, there's a chance the tail needs to be trimmed. + if (newCapacity < oldCapacity) { + newTail = newTail && newTail.removeAfter(owner, 0, newCapacity); } - return function () { - while (true) { - if (values) { - var value = values(); - if (value !== DONE) { - return value; - } - values = null; + + // If the new origin is within the tail, then we do not need a root. + if (newOrigin >= newTailOffset) { + newOrigin -= newTailOffset; + newCapacity -= newTailOffset; + newLevel = SHIFT; + newRoot = null; + newTail = newTail && newTail.removeBefore(owner, 0, newOrigin); + + // Otherwise, if the root has been trimmed, garbage collect. + } else if (newOrigin > oldOrigin || newTailOffset < oldTailOffset) { + offsetShift = 0; + + // Identify the new top root node of the subtree of the old root. + while (newRoot) { + var beginIndex = (newOrigin >>> newLevel) & MASK; + if ((beginIndex !== newTailOffset >>> newLevel) & MASK) { + break; } - if (from === to) { - return DONE; + if (beginIndex) { + offsetShift += (1 << newLevel) * beginIndex; } - var idx = reverse ? --to : from++; - values = iterateNodeOrLeaf( - array && array[idx], - level - SHIFT, - offset + (idx << level) + newLevel -= SHIFT; + newRoot = newRoot.array[beginIndex]; + } + + // Trim the new sides of the new root. + if (newRoot && newOrigin > oldOrigin) { + newRoot = newRoot.removeBefore(owner, newLevel, newOrigin - offsetShift); + } + if (newRoot && newTailOffset < oldTailOffset) { + newRoot = newRoot.removeAfter( + owner, + newLevel, + newTailOffset - offsetShift ); } - }; + if (offsetShift) { + newOrigin -= offsetShift; + newCapacity -= offsetShift; + } + } + + if (list.__ownerID) { + list.size = newCapacity - newOrigin; + list._origin = newOrigin; + list._capacity = newCapacity; + list._level = newLevel; + list._root = newRoot; + list._tail = newTail; + list.__hash = undefined; + list.__altered = true; + return list; + } + return makeList(newOrigin, newCapacity, newLevel, newRoot, newTail); } -} -function makeList(origin, capacity, level, root, tail, ownerID, hash) { - var list = Object.create(ListPrototype); - list.size = capacity - origin; - list._origin = origin; - list._capacity = capacity; - list._level = level; - list._root = root; - list._tail = tail; - list.__ownerID = ownerID; - list.__hash = hash; - list.__altered = false; - return list; -} + function getTailOffset(size) { + return size < SIZE ? 0 : ((size - 1) >>> SHIFT) << SHIFT; + } -var EMPTY_LIST; -function emptyList() { - return EMPTY_LIST || (EMPTY_LIST = makeList(0, 0, SHIFT)); -} + var OrderedMap = (function (Map$$1) { + function OrderedMap(value) { + return value === null || value === undefined + ? emptyOrderedMap() + : isOrderedMap(value) + ? value + : emptyOrderedMap().withMutations(function (map) { + var iter = KeyedCollection(value); + assertNotInfinite(iter.size); + iter.forEach(function (v, k) { return map.set(k, v); }); + }); + } -function updateList(list, index, value) { - index = wrapIndex(list, index); + if ( Map$$1 ) OrderedMap.__proto__ = Map$$1; + OrderedMap.prototype = Object.create( Map$$1 && Map$$1.prototype ); + OrderedMap.prototype.constructor = OrderedMap; - if (index !== index) { - return list; - } + OrderedMap.of = function of (/*...values*/) { + return this(arguments); + }; - if (index >= list.size || index < 0) { - return list.withMutations(function (list) { - index < 0 - ? setListBounds(list, index).set(0, value) - : setListBounds(list, 0, index + 1).set(index, value); - }); - } + OrderedMap.prototype.toString = function toString () { + return this.__toString('OrderedMap {', '}'); + }; - index += list._origin; + // @pragma Access - var newTail = list._tail; - var newRoot = list._root; - var didAlter = MakeRef(DID_ALTER); - if (index >= getTailOffset(list._capacity)) { - newTail = updateVNode(newTail, list.__ownerID, 0, index, value, didAlter); - } else { - newRoot = updateVNode( - newRoot, - list.__ownerID, - list._level, - index, - value, - didAlter - ); - } + OrderedMap.prototype.get = function get (k, notSetValue) { + var index = this._map.get(k); + return index !== undefined ? this._list.get(index)[1] : notSetValue; + }; - if (!didAlter.value) { - return list; - } + // @pragma Modification - if (list.__ownerID) { - list._root = newRoot; - list._tail = newTail; - list.__hash = undefined; - list.__altered = true; - return list; - } - return makeList(list._origin, list._capacity, list._level, newRoot, newTail); -} + OrderedMap.prototype.clear = function clear () { + if (this.size === 0) { + return this; + } + if (this.__ownerID) { + this.size = 0; + this._map.clear(); + this._list.clear(); + return this; + } + return emptyOrderedMap(); + }; -function updateVNode(node, ownerID, level, index, value, didAlter) { - var idx = (index >>> level) & MASK; - var nodeHas = node && idx < node.array.length; - if (!nodeHas && value === undefined) { - return node; - } + OrderedMap.prototype.set = function set (k, v) { + return updateOrderedMap(this, k, v); + }; - var newNode; + OrderedMap.prototype.remove = function remove (k) { + return updateOrderedMap(this, k, NOT_SET); + }; - if (level > 0) { - var lowerNode = node && node.array[idx]; - var newLowerNode = updateVNode( - lowerNode, - ownerID, - level - SHIFT, - index, - value, - didAlter - ); - if (newLowerNode === lowerNode) { - return node; - } - newNode = editableVNode(node, ownerID); - newNode.array[idx] = newLowerNode; - return newNode; - } + OrderedMap.prototype.wasAltered = function wasAltered () { + return this._map.wasAltered() || this._list.wasAltered(); + }; - if (nodeHas && node.array[idx] === value) { - return node; - } + OrderedMap.prototype.__iterate = function __iterate (fn, reverse) { + var this$1 = this; - SetRef(didAlter); + return this._list.__iterate( + function (entry) { return entry && fn(entry[1], entry[0], this$1); }, + reverse + ); + }; - newNode = editableVNode(node, ownerID); - if (value === undefined && idx === newNode.array.length - 1) { - newNode.array.pop(); - } else { - newNode.array[idx] = value; - } - return newNode; -} + OrderedMap.prototype.__iterator = function __iterator (type, reverse) { + return this._list.fromEntrySeq().__iterator(type, reverse); + }; -function editableVNode(node, ownerID) { - if (ownerID && node && ownerID === node.ownerID) { - return node; - } - return new VNode(node ? node.array.slice() : [], ownerID); -} + OrderedMap.prototype.__ensureOwner = function __ensureOwner (ownerID) { + if (ownerID === this.__ownerID) { + return this; + } + var newMap = this._map.__ensureOwner(ownerID); + var newList = this._list.__ensureOwner(ownerID); + if (!ownerID) { + if (this.size === 0) { + return emptyOrderedMap(); + } + this.__ownerID = ownerID; + this._map = newMap; + this._list = newList; + return this; + } + return makeOrderedMap(newMap, newList, ownerID, this.__hash); + }; -function listNodeFor(list, rawIndex) { - if (rawIndex >= getTailOffset(list._capacity)) { - return list._tail; - } - if (rawIndex < 1 << (list._level + SHIFT)) { - var node = list._root; - var level = list._level; - while (node && level > 0) { - node = node.array[(rawIndex >>> level) & MASK]; - level -= SHIFT; - } - return node; - } -} - -function setListBounds(list, begin, end) { - // Sanitize begin & end using this shorthand for ToInt32(argument) - // http://www.ecma-international.org/ecma-262/6.0/#sec-toint32 - if (begin !== undefined) { - begin |= 0; - } - if (end !== undefined) { - end |= 0; - } - var owner = list.__ownerID || new OwnerID(); - var oldOrigin = list._origin; - var oldCapacity = list._capacity; - var newOrigin = oldOrigin + begin; - var newCapacity = - end === undefined - ? oldCapacity - : end < 0 - ? oldCapacity + end - : oldOrigin + end; - if (newOrigin === oldOrigin && newCapacity === oldCapacity) { - return list; - } + return OrderedMap; + }(Map)); - // If it's going to end after it starts, it's empty. - if (newOrigin >= newCapacity) { - return list.clear(); + function isOrderedMap(maybeOrderedMap) { + return isMap(maybeOrderedMap) && isOrdered(maybeOrderedMap); } - var newLevel = list._level; - var newRoot = list._root; - - // New origin might need creating a higher root. - var offsetShift = 0; - while (newOrigin + offsetShift < 0) { - newRoot = new VNode( - newRoot && newRoot.array.length ? [undefined, newRoot] : [], - owner - ); - newLevel += SHIFT; - offsetShift += 1 << newLevel; - } - if (offsetShift) { - newOrigin += offsetShift; - oldOrigin += offsetShift; - newCapacity += offsetShift; - oldCapacity += offsetShift; - } + OrderedMap.isOrderedMap = isOrderedMap; - var oldTailOffset = getTailOffset(oldCapacity); - var newTailOffset = getTailOffset(newCapacity); + OrderedMap.prototype[IS_ORDERED_SENTINEL] = true; + OrderedMap.prototype[DELETE] = OrderedMap.prototype.remove; - // New size might need creating a higher root. - while (newTailOffset >= 1 << (newLevel + SHIFT)) { - newRoot = new VNode( - newRoot && newRoot.array.length ? [newRoot] : [], - owner - ); - newLevel += SHIFT; - } - - // Locate or create the new tail. - var oldTail = list._tail; - var newTail = - newTailOffset < oldTailOffset - ? listNodeFor(list, newCapacity - 1) - : newTailOffset > oldTailOffset - ? new VNode([], owner) - : oldTail; - - // Merge Tail into tree. - if ( - oldTail && - newTailOffset > oldTailOffset && - newOrigin < oldCapacity && - oldTail.array.length - ) { - newRoot = editableVNode(newRoot, owner); - var node = newRoot; - for (var level = newLevel; level > SHIFT; level -= SHIFT) { - var idx = (oldTailOffset >>> level) & MASK; - node = node.array[idx] = editableVNode(node.array[idx], owner); - } - node.array[(oldTailOffset >>> SHIFT) & MASK] = oldTail; + function makeOrderedMap(map, list, ownerID, hash) { + var omap = Object.create(OrderedMap.prototype); + omap.size = map ? map.size : 0; + omap._map = map; + omap._list = list; + omap.__ownerID = ownerID; + omap.__hash = hash; + return omap; } - // If the size has been reduced, there's a chance the tail needs to be trimmed. - if (newCapacity < oldCapacity) { - newTail = newTail && newTail.removeAfter(owner, 0, newCapacity); + var EMPTY_ORDERED_MAP; + function emptyOrderedMap() { + return ( + EMPTY_ORDERED_MAP || + (EMPTY_ORDERED_MAP = makeOrderedMap(emptyMap(), emptyList())) + ); } - // If the new origin is within the tail, then we do not need a root. - if (newOrigin >= newTailOffset) { - newOrigin -= newTailOffset; - newCapacity -= newTailOffset; - newLevel = SHIFT; - newRoot = null; - newTail = newTail && newTail.removeBefore(owner, 0, newOrigin); - - // Otherwise, if the root has been trimmed, garbage collect. - } else if (newOrigin > oldOrigin || newTailOffset < oldTailOffset) { - offsetShift = 0; - - // Identify the new top root node of the subtree of the old root. - while (newRoot) { - var beginIndex = (newOrigin >>> newLevel) & MASK; - if ((beginIndex !== newTailOffset >>> newLevel) & MASK) { - break; + function updateOrderedMap(omap, k, v) { + var map = omap._map; + var list = omap._list; + var i = map.get(k); + var has = i !== undefined; + var newMap; + var newList; + if (v === NOT_SET) { + // removed + if (!has) { + return omap; } - if (beginIndex) { - offsetShift += (1 << newLevel) * beginIndex; + if (list.size >= SIZE && list.size >= map.size * 2) { + newList = list.filter(function (entry, idx) { return entry !== undefined && i !== idx; }); + newMap = newList + .toKeyedSeq() + .map(function (entry) { return entry[0]; }) + .flip() + .toMap(); + if (omap.__ownerID) { + newMap.__ownerID = newList.__ownerID = omap.__ownerID; + } + } else { + newMap = map.remove(k); + newList = i === list.size - 1 ? list.pop() : list.set(i, undefined); } - newLevel -= SHIFT; - newRoot = newRoot.array[beginIndex]; + } else if (has) { + if (v === list.get(i)[1]) { + return omap; + } + newMap = map; + newList = list.set(i, [k, v]); + } else { + newMap = map.set(k, list.size); + newList = list.set(list.size, [k, v]); + } + if (omap.__ownerID) { + omap.size = newMap.size; + omap._map = newMap; + omap._list = newList; + omap.__hash = undefined; + return omap; } + return makeOrderedMap(newMap, newList); + } - // Trim the new sides of the new root. - if (newRoot && newOrigin > oldOrigin) { - newRoot = newRoot.removeBefore(owner, newLevel, newOrigin - offsetShift); - } - if (newRoot && newTailOffset < oldTailOffset) { - newRoot = newRoot.removeAfter( - owner, - newLevel, - newTailOffset - offsetShift - ); + var Stack = (function (IndexedCollection$$1) { + function Stack(value) { + return value === null || value === undefined + ? emptyStack() + : isStack(value) + ? value + : emptyStack().pushAll(value); } - if (offsetShift) { - newOrigin -= offsetShift; - newCapacity -= offsetShift; - } - } - if (list.__ownerID) { - list.size = newCapacity - newOrigin; - list._origin = newOrigin; - list._capacity = newCapacity; - list._level = newLevel; - list._root = newRoot; - list._tail = newTail; - list.__hash = undefined; - list.__altered = true; - return list; - } - return makeList(newOrigin, newCapacity, newLevel, newRoot, newTail); -} + if ( IndexedCollection$$1 ) Stack.__proto__ = IndexedCollection$$1; + Stack.prototype = Object.create( IndexedCollection$$1 && IndexedCollection$$1.prototype ); + Stack.prototype.constructor = Stack; -function getTailOffset(size) { - return size < SIZE ? 0 : ((size - 1) >>> SHIFT) << SHIFT; -} + Stack.of = function of (/*...values*/) { + return this(arguments); + }; -var OrderedMap = (function (Map$$1) { - function OrderedMap(value) { - return value === null || value === undefined - ? emptyOrderedMap() - : isOrderedMap(value) - ? value - : emptyOrderedMap().withMutations(function (map) { - var iter = KeyedCollection(value); - assertNotInfinite(iter.size); - iter.forEach(function (v, k) { return map.set(k, v); }); - }); - } + Stack.prototype.toString = function toString () { + return this.__toString('Stack [', ']'); + }; - if ( Map$$1 ) OrderedMap.__proto__ = Map$$1; - OrderedMap.prototype = Object.create( Map$$1 && Map$$1.prototype ); - OrderedMap.prototype.constructor = OrderedMap; + // @pragma Access - OrderedMap.of = function of (/*...values*/) { - return this(arguments); - }; + Stack.prototype.get = function get (index, notSetValue) { + var head = this._head; + index = wrapIndex(this, index); + while (head && index--) { + head = head.next; + } + return head ? head.value : notSetValue; + }; - OrderedMap.prototype.toString = function toString () { - return this.__toString('OrderedMap {', '}'); - }; + Stack.prototype.peek = function peek () { + return this._head && this._head.value; + }; - // @pragma Access + // @pragma Modification - OrderedMap.prototype.get = function get (k, notSetValue) { - var index = this._map.get(k); - return index !== undefined ? this._list.get(index)[1] : notSetValue; - }; + Stack.prototype.push = function push (/*...values*/) { + var arguments$1 = arguments; - // @pragma Modification + if (arguments.length === 0) { + return this; + } + var newSize = this.size + arguments.length; + var head = this._head; + for (var ii = arguments.length - 1; ii >= 0; ii--) { + head = { + value: arguments$1[ii], + next: head, + }; + } + if (this.__ownerID) { + this.size = newSize; + this._head = head; + this.__hash = undefined; + this.__altered = true; + return this; + } + return makeStack(newSize, head); + }; - OrderedMap.prototype.clear = function clear () { - if (this.size === 0) { - return this; - } - if (this.__ownerID) { - this.size = 0; - this._map.clear(); - this._list.clear(); - return this; - } - return emptyOrderedMap(); - }; + Stack.prototype.pushAll = function pushAll (iter) { + iter = IndexedCollection$$1(iter); + if (iter.size === 0) { + return this; + } + if (this.size === 0 && isStack(iter)) { + return iter; + } + assertNotInfinite(iter.size); + var newSize = this.size; + var head = this._head; + iter.__iterate(function (value) { + newSize++; + head = { + value: value, + next: head, + }; + }, /* reverse */ true); + if (this.__ownerID) { + this.size = newSize; + this._head = head; + this.__hash = undefined; + this.__altered = true; + return this; + } + return makeStack(newSize, head); + }; - OrderedMap.prototype.set = function set (k, v) { - return updateOrderedMap(this, k, v); - }; + Stack.prototype.pop = function pop () { + return this.slice(1); + }; - OrderedMap.prototype.remove = function remove (k) { - return updateOrderedMap(this, k, NOT_SET); - }; + Stack.prototype.clear = function clear () { + if (this.size === 0) { + return this; + } + if (this.__ownerID) { + this.size = 0; + this._head = undefined; + this.__hash = undefined; + this.__altered = true; + return this; + } + return emptyStack(); + }; - OrderedMap.prototype.wasAltered = function wasAltered () { - return this._map.wasAltered() || this._list.wasAltered(); - }; + Stack.prototype.slice = function slice (begin, end) { + if (wholeSlice(begin, end, this.size)) { + return this; + } + var resolvedBegin = resolveBegin(begin, this.size); + var resolvedEnd = resolveEnd(end, this.size); + if (resolvedEnd !== this.size) { + // super.slice(begin, end); + return IndexedCollection$$1.prototype.slice.call(this, begin, end); + } + var newSize = this.size - resolvedBegin; + var head = this._head; + while (resolvedBegin--) { + head = head.next; + } + if (this.__ownerID) { + this.size = newSize; + this._head = head; + this.__hash = undefined; + this.__altered = true; + return this; + } + return makeStack(newSize, head); + }; - OrderedMap.prototype.__iterate = function __iterate (fn, reverse) { - var this$1 = this; + // @pragma Mutability - return this._list.__iterate( - function (entry) { return entry && fn(entry[1], entry[0], this$1); }, - reverse - ); - }; + Stack.prototype.__ensureOwner = function __ensureOwner (ownerID) { + if (ownerID === this.__ownerID) { + return this; + } + if (!ownerID) { + if (this.size === 0) { + return emptyStack(); + } + this.__ownerID = ownerID; + this.__altered = false; + return this; + } + return makeStack(this.size, this._head, ownerID, this.__hash); + }; - OrderedMap.prototype.__iterator = function __iterator (type, reverse) { - return this._list.fromEntrySeq().__iterator(type, reverse); - }; + // @pragma Iteration - OrderedMap.prototype.__ensureOwner = function __ensureOwner (ownerID) { - if (ownerID === this.__ownerID) { - return this; - } - var newMap = this._map.__ensureOwner(ownerID); - var newList = this._list.__ensureOwner(ownerID); - if (!ownerID) { - if (this.size === 0) { - return emptyOrderedMap(); - } - this.__ownerID = ownerID; - this._map = newMap; - this._list = newList; - return this; - } - return makeOrderedMap(newMap, newList, ownerID, this.__hash); - }; + Stack.prototype.__iterate = function __iterate (fn, reverse) { + var this$1 = this; - return OrderedMap; -}(Map)); - -function isOrderedMap(maybeOrderedMap) { - return isMap(maybeOrderedMap) && isOrdered(maybeOrderedMap); -} - -OrderedMap.isOrderedMap = isOrderedMap; - -OrderedMap.prototype[IS_ORDERED_SENTINEL] = true; -OrderedMap.prototype[DELETE] = OrderedMap.prototype.remove; - -function makeOrderedMap(map, list, ownerID, hash) { - var omap = Object.create(OrderedMap.prototype); - omap.size = map ? map.size : 0; - omap._map = map; - omap._list = list; - omap.__ownerID = ownerID; - omap.__hash = hash; - return omap; -} - -var EMPTY_ORDERED_MAP; -function emptyOrderedMap() { - return ( - EMPTY_ORDERED_MAP || - (EMPTY_ORDERED_MAP = makeOrderedMap(emptyMap(), emptyList())) - ); -} - -function updateOrderedMap(omap, k, v) { - var map = omap._map; - var list = omap._list; - var i = map.get(k); - var has = i !== undefined; - var newMap; - var newList; - if (v === NOT_SET) { - // removed - if (!has) { - return omap; - } - if (list.size >= SIZE && list.size >= map.size * 2) { - newList = list.filter(function (entry, idx) { return entry !== undefined && i !== idx; }); - newMap = newList - .toKeyedSeq() - .map(function (entry) { return entry[0]; }) - .flip() - .toMap(); - if (omap.__ownerID) { - newMap.__ownerID = newList.__ownerID = omap.__ownerID; + if (reverse) { + return new ArraySeq(this.toArray()).__iterate( + function (v, k) { return fn(v, k, this$1); }, + reverse + ); } - } else { - newMap = map.remove(k); - newList = i === list.size - 1 ? list.pop() : list.set(i, undefined); - } - } else if (has) { - if (v === list.get(i)[1]) { - return omap; - } - newMap = map; - newList = list.set(i, [k, v]); - } else { - newMap = map.set(k, list.size); - newList = list.set(list.size, [k, v]); - } - if (omap.__ownerID) { - omap.size = newMap.size; - omap._map = newMap; - omap._list = newList; - omap.__hash = undefined; - return omap; - } - return makeOrderedMap(newMap, newList); -} + var iterations = 0; + var node = this._head; + while (node) { + if (fn(node.value, iterations++, this$1) === false) { + break; + } + node = node.next; + } + return iterations; + }; -var Stack = (function (IndexedCollection$$1) { - function Stack(value) { - return value === null || value === undefined - ? emptyStack() - : isStack(value) - ? value - : emptyStack().pushAll(value); - } + Stack.prototype.__iterator = function __iterator (type, reverse) { + if (reverse) { + return new ArraySeq(this.toArray()).__iterator(type, reverse); + } + var iterations = 0; + var node = this._head; + return new Iterator(function () { + if (node) { + var value = node.value; + node = node.next; + return iteratorValue(type, iterations++, value); + } + return iteratorDone(); + }); + }; - if ( IndexedCollection$$1 ) Stack.__proto__ = IndexedCollection$$1; - Stack.prototype = Object.create( IndexedCollection$$1 && IndexedCollection$$1.prototype ); - Stack.prototype.constructor = Stack; + return Stack; + }(IndexedCollection)); - Stack.of = function of (/*...values*/) { - return this(arguments); - }; + function isStack(maybeStack) { + return !!(maybeStack && maybeStack[IS_STACK_SENTINEL]); + } - Stack.prototype.toString = function toString () { - return this.__toString('Stack [', ']'); - }; + Stack.isStack = isStack; - // @pragma Access + var IS_STACK_SENTINEL = '@@__IMMUTABLE_STACK__@@'; - Stack.prototype.get = function get (index, notSetValue) { - var head = this._head; - index = wrapIndex(this, index); - while (head && index--) { - head = head.next; - } - return head ? head.value : notSetValue; + var StackPrototype = Stack.prototype; + StackPrototype[IS_STACK_SENTINEL] = true; + StackPrototype.shift = StackPrototype.pop; + StackPrototype.unshift = StackPrototype.push; + StackPrototype.unshiftAll = StackPrototype.pushAll; + StackPrototype.withMutations = withMutations; + StackPrototype.wasAltered = wasAltered; + StackPrototype.asImmutable = asImmutable; + StackPrototype['@@transducer/init'] = StackPrototype.asMutable = asMutable; + StackPrototype['@@transducer/step'] = function(result, arr) { + return result.unshift(arr); }; - - Stack.prototype.peek = function peek () { - return this._head && this._head.value; + StackPrototype['@@transducer/result'] = function(obj) { + return obj.asImmutable(); }; - // @pragma Modification - - Stack.prototype.push = function push (/*...values*/) { - var arguments$1 = arguments; + function makeStack(size, head, ownerID, hash) { + var map = Object.create(StackPrototype); + map.size = size; + map._head = head; + map.__ownerID = ownerID; + map.__hash = hash; + map.__altered = false; + return map; + } - if (arguments.length === 0) { - return this; - } - var newSize = this.size + arguments.length; - var head = this._head; - for (var ii = arguments.length - 1; ii >= 0; ii--) { - head = { - value: arguments$1[ii], - next: head, - }; - } - if (this.__ownerID) { - this.size = newSize; - this._head = head; - this.__hash = undefined; - this.__altered = true; - return this; - } - return makeStack(newSize, head); - }; + var EMPTY_STACK; + function emptyStack() { + return EMPTY_STACK || (EMPTY_STACK = makeStack(0)); + } - Stack.prototype.pushAll = function pushAll (iter) { - iter = IndexedCollection$$1(iter); - if (iter.size === 0) { - return this; - } - if (this.size === 0 && isStack(iter)) { - return iter; - } - assertNotInfinite(iter.size); - var newSize = this.size; - var head = this._head; - iter.__iterate(function (value) { - newSize++; - head = { - value: value, - next: head, - }; - }, /* reverse */ true); - if (this.__ownerID) { - this.size = newSize; - this._head = head; - this.__hash = undefined; - this.__altered = true; - return this; + function deepEqual(a, b) { + if (a === b) { + return true; } - return makeStack(newSize, head); - }; - - Stack.prototype.pop = function pop () { - return this.slice(1); - }; - Stack.prototype.clear = function clear () { - if (this.size === 0) { - return this; - } - if (this.__ownerID) { - this.size = 0; - this._head = undefined; - this.__hash = undefined; - this.__altered = true; - return this; + if ( + !isCollection(b) || + (a.size !== undefined && b.size !== undefined && a.size !== b.size) || + (a.__hash !== undefined && + b.__hash !== undefined && + a.__hash !== b.__hash) || + isKeyed(a) !== isKeyed(b) || + isIndexed(a) !== isIndexed(b) || + isOrdered(a) !== isOrdered(b) + ) { + return false; } - return emptyStack(); - }; - Stack.prototype.slice = function slice (begin, end) { - if (wholeSlice(begin, end, this.size)) { - return this; - } - var resolvedBegin = resolveBegin(begin, this.size); - var resolvedEnd = resolveEnd(end, this.size); - if (resolvedEnd !== this.size) { - // super.slice(begin, end); - return IndexedCollection$$1.prototype.slice.call(this, begin, end); - } - var newSize = this.size - resolvedBegin; - var head = this._head; - while (resolvedBegin--) { - head = head.next; - } - if (this.__ownerID) { - this.size = newSize; - this._head = head; - this.__hash = undefined; - this.__altered = true; - return this; + if (a.size === 0 && b.size === 0) { + return true; } - return makeStack(newSize, head); - }; - // @pragma Mutability + var notAssociative = !isAssociative(a); - Stack.prototype.__ensureOwner = function __ensureOwner (ownerID) { - if (ownerID === this.__ownerID) { - return this; - } - if (!ownerID) { - if (this.size === 0) { - return emptyStack(); - } - this.__ownerID = ownerID; - this.__altered = false; - return this; + if (isOrdered(a)) { + var entries = a.entries(); + return ( + b.every(function (v, k) { + var entry = entries.next().value; + return entry && is(entry[1], v) && (notAssociative || is(entry[0], k)); + }) && entries.next().done + ); } - return makeStack(this.size, this._head, ownerID, this.__hash); - }; - // @pragma Iteration - - Stack.prototype.__iterate = function __iterate (fn, reverse) { - var this$1 = this; + var flipped = false; - if (reverse) { - return new ArraySeq(this.toArray()).__iterate( - function (v, k) { return fn(v, k, this$1); }, - reverse - ); - } - var iterations = 0; - var node = this._head; - while (node) { - if (fn(node.value, iterations++, this$1) === false) { - break; + if (a.size === undefined) { + if (b.size === undefined) { + if (typeof a.cacheResult === 'function') { + a.cacheResult(); + } + } else { + flipped = true; + var _ = a; + a = b; + b = _; } - node = node.next; } - return iterations; - }; - Stack.prototype.__iterator = function __iterator (type, reverse) { - if (reverse) { - return new ArraySeq(this.toArray()).__iterator(type, reverse); - } - var iterations = 0; - var node = this._head; - return new Iterator(function () { - if (node) { - var value = node.value; - node = node.next; - return iteratorValue(type, iterations++, value); + var allEqual = true; + var bSize = b.__iterate(function (v, k) { + if ( + notAssociative + ? !a.has(v) + : flipped + ? !is(v, a.get(k, NOT_SET)) + : !is(a.get(k, NOT_SET), v) + ) { + allEqual = false; + return false; } - return iteratorDone(); }); - }; - return Stack; -}(IndexedCollection)); - -function isStack(maybeStack) { - return !!(maybeStack && maybeStack[IS_STACK_SENTINEL]); -} - -Stack.isStack = isStack; - -var IS_STACK_SENTINEL = '@@__IMMUTABLE_STACK__@@'; - -var StackPrototype = Stack.prototype; -StackPrototype[IS_STACK_SENTINEL] = true; -StackPrototype.shift = StackPrototype.pop; -StackPrototype.unshift = StackPrototype.push; -StackPrototype.unshiftAll = StackPrototype.pushAll; -StackPrototype.withMutations = withMutations; -StackPrototype.wasAltered = wasAltered; -StackPrototype.asImmutable = asImmutable; -StackPrototype['@@transducer/init'] = StackPrototype.asMutable = asMutable; -StackPrototype['@@transducer/step'] = function(result, arr) { - return result.unshift(arr); -}; -StackPrototype['@@transducer/result'] = function(obj) { - return obj.asImmutable(); -}; - -function makeStack(size, head, ownerID, hash) { - var map = Object.create(StackPrototype); - map.size = size; - map._head = head; - map.__ownerID = ownerID; - map.__hash = hash; - map.__altered = false; - return map; -} - -var EMPTY_STACK; -function emptyStack() { - return EMPTY_STACK || (EMPTY_STACK = makeStack(0)); -} - -function deepEqual(a, b) { - if (a === b) { - return true; - } - - if ( - !isCollection(b) || - (a.size !== undefined && b.size !== undefined && a.size !== b.size) || - (a.__hash !== undefined && - b.__hash !== undefined && - a.__hash !== b.__hash) || - isKeyed(a) !== isKeyed(b) || - isIndexed(a) !== isIndexed(b) || - isOrdered(a) !== isOrdered(b) - ) { - return false; + return allEqual && a.size === bSize; } - if (a.size === 0 && b.size === 0) { - return true; - } + /** + * Contributes additional methods to a constructor + */ + function mixin(ctor, methods) { + var keyCopier = function (key) { + ctor.prototype[key] = methods[key]; + }; + Object.keys(methods).forEach(keyCopier); + Object.getOwnPropertySymbols && + Object.getOwnPropertySymbols(methods).forEach(keyCopier); + return ctor; + } + + function toJS(value) { + return isDataStructure(value) + ? Seq(value) + .map(toJS) + .toJSON() + : value; + } + + var Set = (function (SetCollection$$1) { + function Set(value) { + return value === null || value === undefined + ? emptySet() + : isSet(value) && !isOrdered(value) + ? value + : emptySet().withMutations(function (set) { + var iter = SetCollection$$1(value); + assertNotInfinite(iter.size); + iter.forEach(function (v) { return set.add(v); }); + }); + } + + if ( SetCollection$$1 ) Set.__proto__ = SetCollection$$1; + Set.prototype = Object.create( SetCollection$$1 && SetCollection$$1.prototype ); + Set.prototype.constructor = Set; + + Set.of = function of (/*...values*/) { + return this(arguments); + }; - var notAssociative = !isAssociative(a); + Set.fromKeys = function fromKeys (value) { + return this(KeyedCollection(value).keySeq()); + }; - if (isOrdered(a)) { - var entries = a.entries(); - return ( - b.every(function (v, k) { - var entry = entries.next().value; - return entry && is(entry[1], v) && (notAssociative || is(entry[0], k)); - }) && entries.next().done - ); - } + Set.intersect = function intersect (sets) { + sets = Collection(sets).toArray(); + return sets.length + ? SetPrototype.intersect.apply(Set(sets.pop()), sets) + : emptySet(); + }; - var flipped = false; + Set.union = function union (sets) { + sets = Collection(sets).toArray(); + return sets.length + ? SetPrototype.union.apply(Set(sets.pop()), sets) + : emptySet(); + }; - if (a.size === undefined) { - if (b.size === undefined) { - if (typeof a.cacheResult === 'function') { - a.cacheResult(); - } - } else { - flipped = true; - var _ = a; - a = b; - b = _; - } - } + Set.prototype.toString = function toString () { + return this.__toString('Set {', '}'); + }; - var allEqual = true; - var bSize = b.__iterate(function (v, k) { - if ( - notAssociative - ? !a.has(v) - : flipped - ? !is(v, a.get(k, NOT_SET)) - : !is(a.get(k, NOT_SET), v) - ) { - allEqual = false; - return false; - } - }); + // @pragma Access - return allEqual && a.size === bSize; -} + Set.prototype.has = function has (value) { + return this._map.has(value); + }; -/** - * Contributes additional methods to a constructor - */ -function mixin(ctor, methods) { - var keyCopier = function (key) { - ctor.prototype[key] = methods[key]; - }; - Object.keys(methods).forEach(keyCopier); - Object.getOwnPropertySymbols && - Object.getOwnPropertySymbols(methods).forEach(keyCopier); - return ctor; -} - -function toJS(value) { - return isDataStructure(value) - ? Seq(value) - .map(toJS) - .toJSON() - : value; -} - -var Set = (function (SetCollection$$1) { - function Set(value) { - return value === null || value === undefined - ? emptySet() - : isSet(value) && !isOrdered(value) - ? value - : emptySet().withMutations(function (set) { - var iter = SetCollection$$1(value); - assertNotInfinite(iter.size); - iter.forEach(function (v) { return set.add(v); }); - }); - } + // @pragma Modification - if ( SetCollection$$1 ) Set.__proto__ = SetCollection$$1; - Set.prototype = Object.create( SetCollection$$1 && SetCollection$$1.prototype ); - Set.prototype.constructor = Set; + Set.prototype.add = function add (value) { + return updateSet(this, this._map.set(value, value)); + }; - Set.of = function of (/*...values*/) { - return this(arguments); - }; + Set.prototype.remove = function remove (value) { + return updateSet(this, this._map.remove(value)); + }; - Set.fromKeys = function fromKeys (value) { - return this(KeyedCollection(value).keySeq()); - }; + Set.prototype.clear = function clear () { + return updateSet(this, this._map.clear()); + }; - Set.intersect = function intersect (sets) { - sets = Collection(sets).toArray(); - return sets.length - ? SetPrototype.intersect.apply(Set(sets.pop()), sets) - : emptySet(); - }; + // @pragma Composition - Set.union = function union (sets) { - sets = Collection(sets).toArray(); - return sets.length - ? SetPrototype.union.apply(Set(sets.pop()), sets) - : emptySet(); - }; + Set.prototype.map = function map (mapper, context) { + var this$1 = this; - Set.prototype.toString = function toString () { - return this.__toString('Set {', '}'); - }; + return updateSet(this, this._map.map(function (v) { return mapper(v, v, this$1); }, context)); + }; - // @pragma Access + Set.prototype.union = function union () { + var iters = [], len = arguments.length; + while ( len-- ) iters[ len ] = arguments[ len ]; - Set.prototype.has = function has (value) { - return this._map.has(value); - }; + iters = iters.filter(function (x) { return x.size !== 0; }); + if (iters.length === 0) { + return this; + } + if (this.size === 0 && !this.__ownerID && iters.length === 1) { + return this.constructor(iters[0]); + } + return this.withMutations(function (set) { + for (var ii = 0; ii < iters.length; ii++) { + SetCollection$$1(iters[ii]).forEach(function (value) { return set.add(value); }); + } + }); + }; - // @pragma Modification + Set.prototype.intersect = function intersect () { + var iters = [], len = arguments.length; + while ( len-- ) iters[ len ] = arguments[ len ]; - Set.prototype.add = function add (value) { - return updateSet(this, this._map.set(value, value)); - }; + if (iters.length === 0) { + return this; + } + iters = iters.map(function (iter) { return SetCollection$$1(iter); }); + var toRemove = []; + this.forEach(function (value) { + if (!iters.every(function (iter) { return iter.includes(value); })) { + toRemove.push(value); + } + }); + return this.withMutations(function (set) { + toRemove.forEach(function (value) { + set.remove(value); + }); + }); + }; - Set.prototype.remove = function remove (value) { - return updateSet(this, this._map.remove(value)); - }; + Set.prototype.subtract = function subtract () { + var iters = [], len = arguments.length; + while ( len-- ) iters[ len ] = arguments[ len ]; - Set.prototype.clear = function clear () { - return updateSet(this, this._map.clear()); - }; + if (iters.length === 0) { + return this; + } + iters = iters.map(function (iter) { return SetCollection$$1(iter); }); + var toRemove = []; + this.forEach(function (value) { + if (iters.some(function (iter) { return iter.includes(value); })) { + toRemove.push(value); + } + }); + return this.withMutations(function (set) { + toRemove.forEach(function (value) { + set.remove(value); + }); + }); + }; - // @pragma Composition + Set.prototype.sort = function sort (comparator) { + // Late binding + return OrderedSet(sortFactory(this, comparator)); + }; - Set.prototype.map = function map (mapper, context) { - var this$1 = this; + Set.prototype.sortBy = function sortBy (mapper, comparator) { + // Late binding + return OrderedSet(sortFactory(this, comparator, mapper)); + }; - return updateSet(this, this._map.map(function (v) { return mapper(v, v, this$1); }, context)); - }; + Set.prototype.wasAltered = function wasAltered () { + return this._map.wasAltered(); + }; - Set.prototype.union = function union () { - var iters = [], len = arguments.length; - while ( len-- ) iters[ len ] = arguments[ len ]; + Set.prototype.__iterate = function __iterate (fn, reverse) { + var this$1 = this; - iters = iters.filter(function (x) { return x.size !== 0; }); - if (iters.length === 0) { - return this; - } - if (this.size === 0 && !this.__ownerID && iters.length === 1) { - return this.constructor(iters[0]); - } - return this.withMutations(function (set) { - for (var ii = 0; ii < iters.length; ii++) { - SetCollection$$1(iters[ii]).forEach(function (value) { return set.add(value); }); - } - }); - }; + return this._map.__iterate(function (k) { return fn(k, k, this$1); }, reverse); + }; - Set.prototype.intersect = function intersect () { - var iters = [], len = arguments.length; - while ( len-- ) iters[ len ] = arguments[ len ]; + Set.prototype.__iterator = function __iterator (type, reverse) { + return this._map.__iterator(type, reverse); + }; - if (iters.length === 0) { - return this; - } - iters = iters.map(function (iter) { return SetCollection$$1(iter); }); - var toRemove = []; - this.forEach(function (value) { - if (!iters.every(function (iter) { return iter.includes(value); })) { - toRemove.push(value); + Set.prototype.__ensureOwner = function __ensureOwner (ownerID) { + if (ownerID === this.__ownerID) { + return this; } - }); - return this.withMutations(function (set) { - toRemove.forEach(function (value) { - set.remove(value); - }); - }); - }; - - Set.prototype.subtract = function subtract () { - var iters = [], len = arguments.length; - while ( len-- ) iters[ len ] = arguments[ len ]; - - if (iters.length === 0) { - return this; - } - iters = iters.map(function (iter) { return SetCollection$$1(iter); }); - var toRemove = []; - this.forEach(function (value) { - if (iters.some(function (iter) { return iter.includes(value); })) { - toRemove.push(value); + var newMap = this._map.__ensureOwner(ownerID); + if (!ownerID) { + if (this.size === 0) { + return this.__empty(); + } + this.__ownerID = ownerID; + this._map = newMap; + return this; } - }); - return this.withMutations(function (set) { - toRemove.forEach(function (value) { - set.remove(value); - }); - }); - }; + return this.__make(newMap, ownerID); + }; - Set.prototype.sort = function sort (comparator) { - // Late binding - return OrderedSet(sortFactory(this, comparator)); - }; + return Set; + }(SetCollection)); - Set.prototype.sortBy = function sortBy (mapper, comparator) { - // Late binding - return OrderedSet(sortFactory(this, comparator, mapper)); - }; + function isSet(maybeSet) { + return !!(maybeSet && maybeSet[IS_SET_SENTINEL]); + } - Set.prototype.wasAltered = function wasAltered () { - return this._map.wasAltered(); - }; + Set.isSet = isSet; - Set.prototype.__iterate = function __iterate (fn, reverse) { - var this$1 = this; + var IS_SET_SENTINEL = '@@__IMMUTABLE_SET__@@'; - return this._map.__iterate(function (k) { return fn(k, k, this$1); }, reverse); + var SetPrototype = Set.prototype; + SetPrototype[IS_SET_SENTINEL] = true; + SetPrototype[DELETE] = SetPrototype.remove; + SetPrototype.merge = SetPrototype.concat = SetPrototype.union; + SetPrototype.withMutations = withMutations; + SetPrototype.asImmutable = asImmutable; + SetPrototype['@@transducer/init'] = SetPrototype.asMutable = asMutable; + SetPrototype['@@transducer/step'] = function(result, arr) { + return result.add(arr); }; - - Set.prototype.__iterator = function __iterator (type, reverse) { - return this._map.__iterator(type, reverse); + SetPrototype['@@transducer/result'] = function(obj) { + return obj.asImmutable(); }; - Set.prototype.__ensureOwner = function __ensureOwner (ownerID) { - if (ownerID === this.__ownerID) { - return this; - } - var newMap = this._map.__ensureOwner(ownerID); - if (!ownerID) { - if (this.size === 0) { - return this.__empty(); - } - this.__ownerID = ownerID; - this._map = newMap; - return this; + SetPrototype.__empty = emptySet; + SetPrototype.__make = makeSet; + + function updateSet(set, newMap) { + if (set.__ownerID) { + set.size = newMap.size; + set._map = newMap; + return set; } - return this.__make(newMap, ownerID); - }; + return newMap === set._map + ? set + : newMap.size === 0 + ? set.__empty() + : set.__make(newMap); + } - return Set; -}(SetCollection)); - -function isSet(maybeSet) { - return !!(maybeSet && maybeSet[IS_SET_SENTINEL]); -} - -Set.isSet = isSet; - -var IS_SET_SENTINEL = '@@__IMMUTABLE_SET__@@'; - -var SetPrototype = Set.prototype; -SetPrototype[IS_SET_SENTINEL] = true; -SetPrototype[DELETE] = SetPrototype.remove; -SetPrototype.merge = SetPrototype.concat = SetPrototype.union; -SetPrototype.withMutations = withMutations; -SetPrototype.asImmutable = asImmutable; -SetPrototype['@@transducer/init'] = SetPrototype.asMutable = asMutable; -SetPrototype['@@transducer/step'] = function(result, arr) { - return result.add(arr); -}; -SetPrototype['@@transducer/result'] = function(obj) { - return obj.asImmutable(); -}; - -SetPrototype.__empty = emptySet; -SetPrototype.__make = makeSet; - -function updateSet(set, newMap) { - if (set.__ownerID) { - set.size = newMap.size; - set._map = newMap; + function makeSet(map, ownerID) { + var set = Object.create(SetPrototype); + set.size = map ? map.size : 0; + set._map = map; + set.__ownerID = ownerID; return set; } - return newMap === set._map - ? set - : newMap.size === 0 - ? set.__empty() - : set.__make(newMap); -} - -function makeSet(map, ownerID) { - var set = Object.create(SetPrototype); - set.size = map ? map.size : 0; - set._map = map; - set.__ownerID = ownerID; - return set; -} - -var EMPTY_SET; -function emptySet() { - return EMPTY_SET || (EMPTY_SET = makeSet(emptyMap())); -} -/** - * Returns a lazy seq of nums from start (inclusive) to end - * (exclusive), by step, where start defaults to 0, step to 1, and end to - * infinity. When start is equal to end, returns empty list. - */ -var Range = (function (IndexedSeq$$1) { - function Range(start, end, step) { - if (!(this instanceof Range)) { - return new Range(start, end, step); - } - invariant(step !== 0, 'Cannot step a Range by 0'); - start = start || 0; - if (end === undefined) { - end = Infinity; - } - step = step === undefined ? 1 : Math.abs(step); - if (end < start) { - step = -step; - } - this._start = start; - this._end = end; - this._step = step; - this.size = Math.max(0, Math.ceil((end - start) / step - 1) + 1); - if (this.size === 0) { - if (EMPTY_RANGE) { - return EMPTY_RANGE; + var EMPTY_SET; + function emptySet() { + return EMPTY_SET || (EMPTY_SET = makeSet(emptyMap())); + } + + /** + * Returns a lazy seq of nums from start (inclusive) to end + * (exclusive), by step, where start defaults to 0, step to 1, and end to + * infinity. When start is equal to end, returns empty list. + */ + var Range = (function (IndexedSeq$$1) { + function Range(start, end, step) { + if (!(this instanceof Range)) { + return new Range(start, end, step); + } + invariant(step !== 0, 'Cannot step a Range by 0'); + start = start || 0; + if (end === undefined) { + end = Infinity; + } + step = step === undefined ? 1 : Math.abs(step); + if (end < start) { + step = -step; + } + this._start = start; + this._end = end; + this._step = step; + this.size = Math.max(0, Math.ceil((end - start) / step - 1) + 1); + if (this.size === 0) { + if (EMPTY_RANGE) { + return EMPTY_RANGE; + } + EMPTY_RANGE = this; } - EMPTY_RANGE = this; } - } - if ( IndexedSeq$$1 ) Range.__proto__ = IndexedSeq$$1; - Range.prototype = Object.create( IndexedSeq$$1 && IndexedSeq$$1.prototype ); - Range.prototype.constructor = Range; + if ( IndexedSeq$$1 ) Range.__proto__ = IndexedSeq$$1; + Range.prototype = Object.create( IndexedSeq$$1 && IndexedSeq$$1.prototype ); + Range.prototype.constructor = Range; - Range.prototype.toString = function toString () { - if (this.size === 0) { - return 'Range []'; - } - return ( - 'Range [ ' + - this._start + - '...' + - this._end + - (this._step !== 1 ? ' by ' + this._step : '') + - ' ]' - ); - }; + Range.prototype.toString = function toString () { + if (this.size === 0) { + return 'Range []'; + } + return ( + 'Range [ ' + + this._start + + '...' + + this._end + + (this._step !== 1 ? ' by ' + this._step : '') + + ' ]' + ); + }; - Range.prototype.get = function get (index, notSetValue) { - return this.has(index) - ? this._start + wrapIndex(this, index) * this._step - : notSetValue; - }; + Range.prototype.get = function get (index, notSetValue) { + return this.has(index) + ? this._start + wrapIndex(this, index) * this._step + : notSetValue; + }; - Range.prototype.includes = function includes (searchValue) { - var possibleIndex = (searchValue - this._start) / this._step; - return ( - possibleIndex >= 0 && - possibleIndex < this.size && - possibleIndex === Math.floor(possibleIndex) - ); - }; + Range.prototype.includes = function includes (searchValue) { + var possibleIndex = (searchValue - this._start) / this._step; + return ( + possibleIndex >= 0 && + possibleIndex < this.size && + possibleIndex === Math.floor(possibleIndex) + ); + }; - Range.prototype.slice = function slice (begin, end) { - if (wholeSlice(begin, end, this.size)) { - return this; - } - begin = resolveBegin(begin, this.size); - end = resolveEnd(end, this.size); - if (end <= begin) { - return new Range(0, 0); - } - return new Range( - this.get(begin, this._end), - this.get(end, this._end), - this._step - ); - }; + Range.prototype.slice = function slice (begin, end) { + if (wholeSlice(begin, end, this.size)) { + return this; + } + begin = resolveBegin(begin, this.size); + end = resolveEnd(end, this.size); + if (end <= begin) { + return new Range(0, 0); + } + return new Range( + this.get(begin, this._end), + this.get(end, this._end), + this._step + ); + }; - Range.prototype.indexOf = function indexOf (searchValue) { - var offsetValue = searchValue - this._start; - if (offsetValue % this._step === 0) { - var index = offsetValue / this._step; - if (index >= 0 && index < this.size) { - return index; + Range.prototype.indexOf = function indexOf (searchValue) { + var offsetValue = searchValue - this._start; + if (offsetValue % this._step === 0) { + var index = offsetValue / this._step; + if (index >= 0 && index < this.size) { + return index; + } } - } - return -1; - }; + return -1; + }; - Range.prototype.lastIndexOf = function lastIndexOf (searchValue) { - return this.indexOf(searchValue); - }; + Range.prototype.lastIndexOf = function lastIndexOf (searchValue) { + return this.indexOf(searchValue); + }; - Range.prototype.__iterate = function __iterate (fn, reverse) { - var this$1 = this; + Range.prototype.__iterate = function __iterate (fn, reverse) { + var this$1 = this; - var size = this.size; - var step = this._step; - var value = reverse ? this._start + (size - 1) * step : this._start; - var i = 0; - while (i !== size) { - if (fn(value, reverse ? size - ++i : i++, this$1) === false) { - break; + var size = this.size; + var step = this._step; + var value = reverse ? this._start + (size - 1) * step : this._start; + var i = 0; + while (i !== size) { + if (fn(value, reverse ? size - ++i : i++, this$1) === false) { + break; + } + value += reverse ? -step : step; } - value += reverse ? -step : step; - } - return i; - }; + return i; + }; - Range.prototype.__iterator = function __iterator (type, reverse) { - var size = this.size; - var step = this._step; - var value = reverse ? this._start + (size - 1) * step : this._start; - var i = 0; - return new Iterator(function () { - if (i === size) { - return iteratorDone(); - } - var v = value; - value += reverse ? -step : step; - return iteratorValue(type, reverse ? size - ++i : i++, v); - }); - }; + Range.prototype.__iterator = function __iterator (type, reverse) { + var size = this.size; + var step = this._step; + var value = reverse ? this._start + (size - 1) * step : this._start; + var i = 0; + return new Iterator(function () { + if (i === size) { + return iteratorDone(); + } + var v = value; + value += reverse ? -step : step; + return iteratorValue(type, reverse ? size - ++i : i++, v); + }); + }; - Range.prototype.equals = function equals (other) { - return other instanceof Range - ? this._start === other._start && - this._end === other._end && - this._step === other._step - : deepEqual(this, other); - }; + Range.prototype.equals = function equals (other) { + return other instanceof Range + ? this._start === other._start && + this._end === other._end && + this._step === other._step + : deepEqual(this, other); + }; - return Range; -}(IndexedSeq)); + return Range; + }(IndexedSeq)); -var EMPTY_RANGE; + var EMPTY_RANGE; -function getIn$1(collection, searchKeyPath, notSetValue) { - var keyPath = coerceKeyPath(searchKeyPath); - var i = 0; - while (i !== keyPath.length) { - collection = get(collection, keyPath[i++], NOT_SET); - if (collection === NOT_SET) { - return notSetValue; + function getIn(collection, searchKeyPath, notSetValue) { + var keyPath = coerceKeyPath(searchKeyPath); + var i = 0; + while (i !== keyPath.length) { + collection = get(collection, keyPath[i++], NOT_SET); + if (collection === NOT_SET) { + return notSetValue; + } } + return collection; } - return collection; -} - -function getIn$$1(searchKeyPath, notSetValue) { - return getIn$1(this, searchKeyPath, notSetValue); -} -function hasIn$1(collection, keyPath) { - return getIn$1(collection, keyPath, NOT_SET) !== NOT_SET; -} - -function hasIn$$1(searchKeyPath) { - return hasIn$1(this, searchKeyPath); -} - -function toObject() { - assertNotInfinite(this.size); - var object = {}; - this.__iterate(function (v, k) { - object[k] = v; - }); - return object; -} - -// Note: all of these methods are deprecated. -Collection.isIterable = isCollection; -Collection.isKeyed = isKeyed; -Collection.isIndexed = isIndexed; -Collection.isAssociative = isAssociative; -Collection.isOrdered = isOrdered; + function getIn$1(searchKeyPath, notSetValue) { + return getIn(this, searchKeyPath, notSetValue); + } -Collection.Iterator = Iterator; + function hasIn(collection, keyPath) { + return getIn(collection, keyPath, NOT_SET) !== NOT_SET; + } -mixin(Collection, { - // ### Conversion to other types + function hasIn$1(searchKeyPath) { + return hasIn(this, searchKeyPath); + } - toArray: function toArray() { + function toObject() { assertNotInfinite(this.size); - var array = new Array(this.size || 0); - var useTuples = isKeyed(this); - var i = 0; + var object = {}; this.__iterate(function (v, k) { - // Keyed collections produce an array of tuples. - array[i++] = useTuples ? [k, v] : v; + object[k] = v; }); - return array; - }, - - toIndexedSeq: function toIndexedSeq() { - return new ToIndexedSequence(this); - }, - - toJS: function toJS$1() { - return toJS(this); - }, - - toKeyedSeq: function toKeyedSeq() { - return new ToKeyedSequence(this, true); - }, - - toMap: function toMap() { - // Use Late Binding here to solve the circular dependency. - return Map(this.toKeyedSeq()); - }, - - toObject: toObject, - - toOrderedMap: function toOrderedMap() { - // Use Late Binding here to solve the circular dependency. - return OrderedMap(this.toKeyedSeq()); - }, - - toOrderedSet: function toOrderedSet() { - // Use Late Binding here to solve the circular dependency. - return OrderedSet(isKeyed(this) ? this.valueSeq() : this); - }, - - toSet: function toSet() { - // Use Late Binding here to solve the circular dependency. - return Set(isKeyed(this) ? this.valueSeq() : this); - }, - - toSetSeq: function toSetSeq() { - return new ToSetSequence(this); - }, - - toSeq: function toSeq() { - return isIndexed(this) - ? this.toIndexedSeq() - : isKeyed(this) - ? this.toKeyedSeq() - : this.toSetSeq(); - }, - - toStack: function toStack() { - // Use Late Binding here to solve the circular dependency. - return Stack(isKeyed(this) ? this.valueSeq() : this); - }, - - toList: function toList() { - // Use Late Binding here to solve the circular dependency. - return List(isKeyed(this) ? this.valueSeq() : this); - }, - - // ### Common JavaScript methods and properties - - toString: function toString() { - return '[Collection]'; - }, - - __toString: function __toString(head, tail) { - if (this.size === 0) { - return head + tail; - } - return ( - head + - ' ' + - this.toSeq() - .map(this.__toStringMapper) - .join(', ') + - ' ' + - tail - ); - }, - - // ### ES6 Collection methods (ES6 Array and Map) - - concat: function concat() { - var values = [], len = arguments.length; - while ( len-- ) values[ len ] = arguments[ len ]; + return object; + } - return reify(this, concatFactory(this, values)); - }, + // Note: all of these methods are deprecated. + Collection.isIterable = isCollection; + Collection.isKeyed = isKeyed; + Collection.isIndexed = isIndexed; + Collection.isAssociative = isAssociative; + Collection.isOrdered = isOrdered; - includes: function includes(searchValue) { - return this.some(function (value) { return is(value, searchValue); }); - }, + Collection.Iterator = Iterator; - entries: function entries() { - return this.__iterator(ITERATE_ENTRIES); - }, + mixin(Collection, { + // ### Conversion to other types - every: function every(predicate, context) { - assertNotInfinite(this.size); - var returnValue = true; - this.__iterate(function (v, k, c) { - if (!predicate.call(context, v, k, c)) { - returnValue = false; - return false; + toArray: function toArray() { + assertNotInfinite(this.size); + var array = new Array(this.size || 0); + var useTuples = isKeyed(this); + var i = 0; + this.__iterate(function (v, k) { + // Keyed collections produce an array of tuples. + array[i++] = useTuples ? [k, v] : v; + }); + return array; + }, + + toIndexedSeq: function toIndexedSeq() { + return new ToIndexedSequence(this); + }, + + toJS: function toJS$1() { + return toJS(this); + }, + + toKeyedSeq: function toKeyedSeq() { + return new ToKeyedSequence(this, true); + }, + + toMap: function toMap() { + // Use Late Binding here to solve the circular dependency. + return Map(this.toKeyedSeq()); + }, + + toObject: toObject, + + toOrderedMap: function toOrderedMap() { + // Use Late Binding here to solve the circular dependency. + return OrderedMap(this.toKeyedSeq()); + }, + + toOrderedSet: function toOrderedSet() { + // Use Late Binding here to solve the circular dependency. + return OrderedSet(isKeyed(this) ? this.valueSeq() : this); + }, + + toSet: function toSet() { + // Use Late Binding here to solve the circular dependency. + return Set(isKeyed(this) ? this.valueSeq() : this); + }, + + toSetSeq: function toSetSeq() { + return new ToSetSequence(this); + }, + + toSeq: function toSeq() { + return isIndexed(this) + ? this.toIndexedSeq() + : isKeyed(this) + ? this.toKeyedSeq() + : this.toSetSeq(); + }, + + toStack: function toStack() { + // Use Late Binding here to solve the circular dependency. + return Stack(isKeyed(this) ? this.valueSeq() : this); + }, + + toList: function toList() { + // Use Late Binding here to solve the circular dependency. + return List(isKeyed(this) ? this.valueSeq() : this); + }, + + // ### Common JavaScript methods and properties + + toString: function toString() { + return '[Collection]'; + }, + + __toString: function __toString(head, tail) { + if (this.size === 0) { + return head + tail; } - }); - return returnValue; - }, + return ( + head + + ' ' + + this.toSeq() + .map(this.__toStringMapper) + .join(', ') + + ' ' + + tail + ); + }, - filter: function filter(predicate, context) { - return reify(this, filterFactory(this, predicate, context, true)); - }, + // ### ES6 Collection methods (ES6 Array and Map) - find: function find(predicate, context, notSetValue) { - var entry = this.findEntry(predicate, context); - return entry ? entry[1] : notSetValue; - }, + concat: function concat() { + var values = [], len = arguments.length; + while ( len-- ) values[ len ] = arguments[ len ]; - forEach: function forEach(sideEffect, context) { - assertNotInfinite(this.size); - return this.__iterate(context ? sideEffect.bind(context) : sideEffect); - }, + return reify(this, concatFactory(this, values)); + }, - join: function join(separator) { - assertNotInfinite(this.size); - separator = separator !== undefined ? '' + separator : ','; - var joined = ''; - var isFirst = true; - this.__iterate(function (v) { - isFirst ? (isFirst = false) : (joined += separator); - joined += v !== null && v !== undefined ? v.toString() : ''; - }); - return joined; - }, - - keys: function keys() { - return this.__iterator(ITERATE_KEYS); - }, - - map: function map(mapper, context) { - return reify(this, mapFactory(this, mapper, context)); - }, - - reduce: function reduce$1(reducer, initialReduction, context) { - return reduce( - this, - reducer, - initialReduction, - context, - arguments.length < 2, - false - ); - }, - - reduceRight: function reduceRight(reducer, initialReduction, context) { - return reduce( - this, - reducer, - initialReduction, - context, - arguments.length < 2, - true - ); - }, + includes: function includes(searchValue) { + return this.some(function (value) { return is(value, searchValue); }); + }, - reverse: function reverse() { - return reify(this, reverseFactory(this, true)); - }, + entries: function entries() { + return this.__iterator(ITERATE_ENTRIES); + }, - slice: function slice(begin, end) { - return reify(this, sliceFactory(this, begin, end, true)); - }, + every: function every(predicate, context) { + assertNotInfinite(this.size); + var returnValue = true; + this.__iterate(function (v, k, c) { + if (!predicate.call(context, v, k, c)) { + returnValue = false; + return false; + } + }); + return returnValue; + }, + + filter: function filter(predicate, context) { + return reify(this, filterFactory(this, predicate, context, true)); + }, + + find: function find(predicate, context, notSetValue) { + var entry = this.findEntry(predicate, context); + return entry ? entry[1] : notSetValue; + }, + + forEach: function forEach(sideEffect, context) { + assertNotInfinite(this.size); + return this.__iterate(context ? sideEffect.bind(context) : sideEffect); + }, + + join: function join(separator) { + assertNotInfinite(this.size); + separator = separator !== undefined ? '' + separator : ','; + var joined = ''; + var isFirst = true; + this.__iterate(function (v) { + isFirst ? (isFirst = false) : (joined += separator); + joined += v !== null && v !== undefined ? v.toString() : ''; + }); + return joined; + }, - some: function some(predicate, context) { - return !this.every(not(predicate), context); - }, + keys: function keys() { + return this.__iterator(ITERATE_KEYS); + }, - sort: function sort(comparator) { - return reify(this, sortFactory(this, comparator)); - }, + map: function map(mapper, context) { + return reify(this, mapFactory(this, mapper, context)); + }, - values: function values() { - return this.__iterator(ITERATE_VALUES); - }, + reduce: function reduce$1(reducer, initialReduction, context) { + return reduce( + this, + reducer, + initialReduction, + context, + arguments.length < 2, + false + ); + }, - // ### More sequential methods + reduceRight: function reduceRight(reducer, initialReduction, context) { + return reduce( + this, + reducer, + initialReduction, + context, + arguments.length < 2, + true + ); + }, - butLast: function butLast() { - return this.slice(0, -1); - }, + reverse: function reverse() { + return reify(this, reverseFactory(this, true)); + }, - isEmpty: function isEmpty() { - return this.size !== undefined ? this.size === 0 : !this.some(function () { return true; }); - }, + slice: function slice(begin, end) { + return reify(this, sliceFactory(this, begin, end, true)); + }, - count: function count(predicate, context) { - return ensureSize( - predicate ? this.toSeq().filter(predicate, context) : this - ); - }, + some: function some(predicate, context) { + return !this.every(not(predicate), context); + }, - countBy: function countBy(grouper, context) { - return countByFactory(this, grouper, context); - }, + sort: function sort(comparator) { + return reify(this, sortFactory(this, comparator)); + }, - equals: function equals(other) { - return deepEqual(this, other); - }, + values: function values() { + return this.__iterator(ITERATE_VALUES); + }, - entrySeq: function entrySeq() { - var collection = this; - if (collection._cache) { - // We cache as an entries array, so we can just return the cache! - return new ArraySeq(collection._cache); - } - var entriesSequence = collection - .toSeq() - .map(entryMapper) - .toIndexedSeq(); - entriesSequence.fromEntrySeq = function () { return collection.toSeq(); }; - return entriesSequence; - }, - - filterNot: function filterNot(predicate, context) { - return this.filter(not(predicate), context); - }, - - findEntry: function findEntry(predicate, context, notSetValue) { - var found = notSetValue; - this.__iterate(function (v, k, c) { - if (predicate.call(context, v, k, c)) { - found = [k, v]; - return false; - } - }); - return found; - }, - - findKey: function findKey(predicate, context) { - var entry = this.findEntry(predicate, context); - return entry && entry[0]; - }, - - findLast: function findLast(predicate, context, notSetValue) { - return this.toKeyedSeq() - .reverse() - .find(predicate, context, notSetValue); - }, - - findLastEntry: function findLastEntry(predicate, context, notSetValue) { - return this.toKeyedSeq() - .reverse() - .findEntry(predicate, context, notSetValue); - }, - - findLastKey: function findLastKey(predicate, context) { - return this.toKeyedSeq() - .reverse() - .findKey(predicate, context); - }, - - first: function first() { - return this.find(returnTrue); - }, - - flatMap: function flatMap(mapper, context) { - return reify(this, flatMapFactory(this, mapper, context)); - }, - - flatten: function flatten(depth) { - return reify(this, flattenFactory(this, depth, true)); - }, - - fromEntrySeq: function fromEntrySeq() { - return new FromEntriesSequence(this); - }, - - get: function get(searchKey, notSetValue) { - return this.find(function (_, key) { return is(key, searchKey); }, undefined, notSetValue); - }, - - getIn: getIn$$1, - - groupBy: function groupBy(grouper, context) { - return groupByFactory(this, grouper, context); - }, - - has: function has(searchKey) { - return this.get(searchKey, NOT_SET) !== NOT_SET; - }, - - hasIn: hasIn$$1, - - isSubset: function isSubset(iter) { - iter = typeof iter.includes === 'function' ? iter : Collection(iter); - return this.every(function (value) { return iter.includes(value); }); - }, - - isSuperset: function isSuperset(iter) { - iter = typeof iter.isSubset === 'function' ? iter : Collection(iter); - return iter.isSubset(this); - }, - - keyOf: function keyOf(searchValue) { - return this.findKey(function (value) { return is(value, searchValue); }); - }, - - keySeq: function keySeq() { - return this.toSeq() - .map(keyMapper) - .toIndexedSeq(); - }, - - last: function last() { - return this.toSeq() - .reverse() - .first(); - }, - - lastKeyOf: function lastKeyOf(searchValue) { - return this.toKeyedSeq() - .reverse() - .keyOf(searchValue); - }, - - max: function max(comparator) { - return maxFactory(this, comparator); - }, - - maxBy: function maxBy(mapper, comparator) { - return maxFactory(this, comparator, mapper); - }, - - min: function min(comparator) { - return maxFactory( - this, - comparator ? neg(comparator) : defaultNegComparator - ); - }, + // ### More sequential methods - minBy: function minBy(mapper, comparator) { - return maxFactory( - this, - comparator ? neg(comparator) : defaultNegComparator, - mapper - ); - }, + butLast: function butLast() { + return this.slice(0, -1); + }, - rest: function rest() { - return this.slice(1); - }, + isEmpty: function isEmpty() { + return this.size !== undefined ? this.size === 0 : !this.some(function () { return true; }); + }, - skip: function skip(amount) { - return amount === 0 ? this : this.slice(Math.max(0, amount)); - }, + count: function count(predicate, context) { + return ensureSize( + predicate ? this.toSeq().filter(predicate, context) : this + ); + }, - skipLast: function skipLast(amount) { - return amount === 0 ? this : this.slice(0, -Math.max(0, amount)); - }, + countBy: function countBy(grouper, context) { + return countByFactory(this, grouper, context); + }, - skipWhile: function skipWhile(predicate, context) { - return reify(this, skipWhileFactory(this, predicate, context, true)); - }, + equals: function equals(other) { + return deepEqual(this, other); + }, - skipUntil: function skipUntil(predicate, context) { - return this.skipWhile(not(predicate), context); - }, + entrySeq: function entrySeq() { + var collection = this; + if (collection._cache) { + // We cache as an entries array, so we can just return the cache! + return new ArraySeq(collection._cache); + } + var entriesSequence = collection + .toSeq() + .map(entryMapper) + .toIndexedSeq(); + entriesSequence.fromEntrySeq = function () { return collection.toSeq(); }; + return entriesSequence; + }, + + filterNot: function filterNot(predicate, context) { + return this.filter(not(predicate), context); + }, + + findEntry: function findEntry(predicate, context, notSetValue) { + var found = notSetValue; + this.__iterate(function (v, k, c) { + if (predicate.call(context, v, k, c)) { + found = [k, v]; + return false; + } + }); + return found; + }, + + findKey: function findKey(predicate, context) { + var entry = this.findEntry(predicate, context); + return entry && entry[0]; + }, + + findLast: function findLast(predicate, context, notSetValue) { + return this.toKeyedSeq() + .reverse() + .find(predicate, context, notSetValue); + }, + + findLastEntry: function findLastEntry(predicate, context, notSetValue) { + return this.toKeyedSeq() + .reverse() + .findEntry(predicate, context, notSetValue); + }, + + findLastKey: function findLastKey(predicate, context) { + return this.toKeyedSeq() + .reverse() + .findKey(predicate, context); + }, + + first: function first() { + return this.find(returnTrue); + }, + + flatMap: function flatMap(mapper, context) { + return reify(this, flatMapFactory(this, mapper, context)); + }, + + flatten: function flatten(depth) { + return reify(this, flattenFactory(this, depth, true)); + }, + + fromEntrySeq: function fromEntrySeq() { + return new FromEntriesSequence(this); + }, + + get: function get(searchKey, notSetValue) { + return this.find(function (_, key) { return is(key, searchKey); }, undefined, notSetValue); + }, + + getIn: getIn$1, + + groupBy: function groupBy(grouper, context) { + return groupByFactory(this, grouper, context); + }, + + has: function has(searchKey) { + return this.get(searchKey, NOT_SET) !== NOT_SET; + }, + + hasIn: hasIn$1, + + isSubset: function isSubset(iter) { + iter = typeof iter.includes === 'function' ? iter : Collection(iter); + return this.every(function (value) { return iter.includes(value); }); + }, + + isSuperset: function isSuperset(iter) { + iter = typeof iter.isSubset === 'function' ? iter : Collection(iter); + return iter.isSubset(this); + }, + + keyOf: function keyOf(searchValue) { + return this.findKey(function (value) { return is(value, searchValue); }); + }, + + keySeq: function keySeq() { + return this.toSeq() + .map(keyMapper) + .toIndexedSeq(); + }, + + last: function last() { + return this.toSeq() + .reverse() + .first(); + }, + + lastKeyOf: function lastKeyOf(searchValue) { + return this.toKeyedSeq() + .reverse() + .keyOf(searchValue); + }, + + max: function max(comparator) { + return maxFactory(this, comparator); + }, + + maxBy: function maxBy(mapper, comparator) { + return maxFactory(this, comparator, mapper); + }, + + min: function min(comparator) { + return maxFactory( + this, + comparator ? neg(comparator) : defaultNegComparator + ); + }, - sortBy: function sortBy(mapper, comparator) { - return reify(this, sortFactory(this, comparator, mapper)); - }, + minBy: function minBy(mapper, comparator) { + return maxFactory( + this, + comparator ? neg(comparator) : defaultNegComparator, + mapper + ); + }, - take: function take(amount) { - return this.slice(0, Math.max(0, amount)); - }, + rest: function rest() { + return this.slice(1); + }, - takeLast: function takeLast(amount) { - return this.slice(-Math.max(0, amount)); - }, + skip: function skip(amount) { + return amount === 0 ? this : this.slice(Math.max(0, amount)); + }, - takeWhile: function takeWhile(predicate, context) { - return reify(this, takeWhileFactory(this, predicate, context)); - }, + skipLast: function skipLast(amount) { + return amount === 0 ? this : this.slice(0, -Math.max(0, amount)); + }, - takeUntil: function takeUntil(predicate, context) { - return this.takeWhile(not(predicate), context); - }, + skipWhile: function skipWhile(predicate, context) { + return reify(this, skipWhileFactory(this, predicate, context, true)); + }, - update: function update(fn) { - return fn(this); - }, + skipUntil: function skipUntil(predicate, context) { + return this.skipWhile(not(predicate), context); + }, - valueSeq: function valueSeq() { - return this.toIndexedSeq(); - }, + sortBy: function sortBy(mapper, comparator) { + return reify(this, sortFactory(this, comparator, mapper)); + }, - // ### Hashable Object + take: function take(amount) { + return this.slice(0, Math.max(0, amount)); + }, - hashCode: function hashCode() { - return this.__hash || (this.__hash = hashCollection(this)); - }, + takeLast: function takeLast(amount) { + return this.slice(-Math.max(0, amount)); + }, - // ### Internal + takeWhile: function takeWhile(predicate, context) { + return reify(this, takeWhileFactory(this, predicate, context)); + }, - // abstract __iterate(fn, reverse) + takeUntil: function takeUntil(predicate, context) { + return this.takeWhile(not(predicate), context); + }, - // abstract __iterator(type, reverse) -}); + update: function update(fn) { + return fn(this); + }, -var CollectionPrototype = Collection.prototype; -CollectionPrototype[IS_ITERABLE_SENTINEL] = true; -CollectionPrototype[ITERATOR_SYMBOL] = CollectionPrototype.values; -CollectionPrototype.toJSON = CollectionPrototype.toArray; -CollectionPrototype.__toStringMapper = quoteString; -CollectionPrototype.inspect = CollectionPrototype.toSource = function() { - return this.toString(); -}; -CollectionPrototype.chain = CollectionPrototype.flatMap; -CollectionPrototype.contains = CollectionPrototype.includes; + valueSeq: function valueSeq() { + return this.toIndexedSeq(); + }, -mixin(KeyedCollection, { - // ### More sequential methods + // ### Hashable Object - flip: function flip() { - return reify(this, flipFactory(this)); - }, + hashCode: function hashCode() { + return this.__hash || (this.__hash = hashCollection(this)); + }, - mapEntries: function mapEntries(mapper, context) { - var this$1 = this; + // ### Internal - var iterations = 0; - return reify( - this, - this.toSeq() - .map(function (v, k) { return mapper.call(context, [k, v], iterations++, this$1); }) - .fromEntrySeq() - ); - }, + // abstract __iterate(fn, reverse) - mapKeys: function mapKeys(mapper, context) { - var this$1 = this; + // abstract __iterator(type, reverse) + }); - return reify( - this, - this.toSeq() - .flip() - .map(function (k, v) { return mapper.call(context, k, v, this$1); }) - .flip() - ); - }, -}); - -var KeyedCollectionPrototype = KeyedCollection.prototype; -KeyedCollectionPrototype[IS_KEYED_SENTINEL] = true; -KeyedCollectionPrototype[ITERATOR_SYMBOL] = CollectionPrototype.entries; -KeyedCollectionPrototype.toJSON = toObject; -KeyedCollectionPrototype.__toStringMapper = function (v, k) { return quoteString(k) + ': ' + quoteString(v); }; - -mixin(IndexedCollection, { - // ### Conversion to other types - - toKeyedSeq: function toKeyedSeq() { - return new ToKeyedSequence(this, false); - }, - - // ### ES6 Collection methods (ES6 Array and Map) - - filter: function filter(predicate, context) { - return reify(this, filterFactory(this, predicate, context, false)); - }, - - findIndex: function findIndex(predicate, context) { - var entry = this.findEntry(predicate, context); - return entry ? entry[0] : -1; - }, - - indexOf: function indexOf(searchValue) { - var key = this.keyOf(searchValue); - return key === undefined ? -1 : key; - }, - - lastIndexOf: function lastIndexOf(searchValue) { - var key = this.lastKeyOf(searchValue); - return key === undefined ? -1 : key; - }, - - reverse: function reverse() { - return reify(this, reverseFactory(this, false)); - }, - - slice: function slice(begin, end) { - return reify(this, sliceFactory(this, begin, end, false)); - }, - - splice: function splice(index, removeNum /*, ...values*/) { - var numArgs = arguments.length; - removeNum = Math.max(removeNum || 0, 0); - if (numArgs === 0 || (numArgs === 2 && !removeNum)) { - return this; - } - // If index is negative, it should resolve relative to the size of the - // collection. However size may be expensive to compute if not cached, so - // only call count() if the number is in fact negative. - index = resolveBegin(index, index < 0 ? this.count() : this.size); - var spliced = this.slice(0, index); - return reify( - this, - numArgs === 1 - ? spliced - : spliced.concat(arrCopy(arguments, 2), this.slice(index + removeNum)) - ); - }, + var CollectionPrototype = Collection.prototype; + CollectionPrototype[IS_ITERABLE_SENTINEL] = true; + CollectionPrototype[ITERATOR_SYMBOL] = CollectionPrototype.values; + CollectionPrototype.toJSON = CollectionPrototype.toArray; + CollectionPrototype.__toStringMapper = quoteString; + CollectionPrototype.inspect = CollectionPrototype.toSource = function() { + return this.toString(); + }; + CollectionPrototype.chain = CollectionPrototype.flatMap; + CollectionPrototype.contains = CollectionPrototype.includes; - // ### More collection methods + mixin(KeyedCollection, { + // ### More sequential methods - findLastIndex: function findLastIndex(predicate, context) { - var entry = this.findLastEntry(predicate, context); - return entry ? entry[0] : -1; - }, + flip: function flip() { + return reify(this, flipFactory(this)); + }, - first: function first() { - return this.get(0); - }, + mapEntries: function mapEntries(mapper, context) { + var this$1 = this; - flatten: function flatten(depth) { - return reify(this, flattenFactory(this, depth, false)); - }, + var iterations = 0; + return reify( + this, + this.toSeq() + .map(function (v, k) { return mapper.call(context, [k, v], iterations++, this$1); }) + .fromEntrySeq() + ); + }, - get: function get(index, notSetValue) { - index = wrapIndex(this, index); - return index < 0 || - (this.size === Infinity || (this.size !== undefined && index > this.size)) - ? notSetValue - : this.find(function (_, key) { return key === index; }, undefined, notSetValue); - }, + mapKeys: function mapKeys(mapper, context) { + var this$1 = this; - has: function has(index) { - index = wrapIndex(this, index); - return ( - index >= 0 && - (this.size !== undefined - ? this.size === Infinity || index < this.size - : this.indexOf(index) !== -1) - ); - }, - - interpose: function interpose(separator) { - return reify(this, interposeFactory(this, separator)); - }, - - interleave: function interleave(/*...collections*/) { - var collections = [this].concat(arrCopy(arguments)); - var zipped = zipWithFactory(this.toSeq(), IndexedSeq.of, collections); - var interleaved = zipped.flatten(true); - if (zipped.size) { - interleaved.size = zipped.size * collections.length; - } - return reify(this, interleaved); - }, - - keySeq: function keySeq() { - return Range(0, this.size); - }, - - last: function last() { - return this.get(-1); - }, - - skipWhile: function skipWhile(predicate, context) { - return reify(this, skipWhileFactory(this, predicate, context, false)); - }, - - zip: function zip(/*, ...collections */) { - var collections = [this].concat(arrCopy(arguments)); - return reify(this, zipWithFactory(this, defaultZipper, collections)); - }, - - zipAll: function zipAll(/*, ...collections */) { - var collections = [this].concat(arrCopy(arguments)); - return reify(this, zipWithFactory(this, defaultZipper, collections, true)); - }, - - zipWith: function zipWith(zipper /*, ...collections */) { - var collections = arrCopy(arguments); - collections[0] = this; - return reify(this, zipWithFactory(this, zipper, collections)); - }, -}); - -var IndexedCollectionPrototype = IndexedCollection.prototype; -IndexedCollectionPrototype[IS_INDEXED_SENTINEL] = true; -IndexedCollectionPrototype[IS_ORDERED_SENTINEL] = true; - -mixin(SetCollection, { - // ### ES6 Collection methods (ES6 Array and Map) - - get: function get(value, notSetValue) { - return this.has(value) ? value : notSetValue; - }, - - includes: function includes(value) { - return this.has(value); - }, - - // ### More sequential methods - - keySeq: function keySeq() { - return this.valueSeq(); - }, -}); - -SetCollection.prototype.has = CollectionPrototype.includes; -SetCollection.prototype.contains = SetCollection.prototype.includes; - -// Mixin subclasses - -mixin(KeyedSeq, KeyedCollection.prototype); -mixin(IndexedSeq, IndexedCollection.prototype); -mixin(SetSeq, SetCollection.prototype); - -// #pragma Helper functions - -function reduce(collection, reducer, reduction, context, useFirst, reverse) { - assertNotInfinite(collection.size); - collection.__iterate(function (v, k, c) { - if (useFirst) { - useFirst = false; - reduction = v; - } else { - reduction = reducer.call(context, reduction, v, k, c); - } - }, reverse); - return reduction; -} + return reify( + this, + this.toSeq() + .flip() + .map(function (k, v) { return mapper.call(context, k, v, this$1); }) + .flip() + ); + }, + }); -function keyMapper(v, k) { - return k; -} + var KeyedCollectionPrototype = KeyedCollection.prototype; + KeyedCollectionPrototype[IS_KEYED_SENTINEL] = true; + KeyedCollectionPrototype[ITERATOR_SYMBOL] = CollectionPrototype.entries; + KeyedCollectionPrototype.toJSON = toObject; + KeyedCollectionPrototype.__toStringMapper = function (v, k) { return quoteString(k) + ': ' + quoteString(v); }; + + mixin(IndexedCollection, { + // ### Conversion to other types + + toKeyedSeq: function toKeyedSeq() { + return new ToKeyedSequence(this, false); + }, + + // ### ES6 Collection methods (ES6 Array and Map) + + filter: function filter(predicate, context) { + return reify(this, filterFactory(this, predicate, context, false)); + }, + + findIndex: function findIndex(predicate, context) { + var entry = this.findEntry(predicate, context); + return entry ? entry[0] : -1; + }, + + indexOf: function indexOf(searchValue) { + var key = this.keyOf(searchValue); + return key === undefined ? -1 : key; + }, + + lastIndexOf: function lastIndexOf(searchValue) { + var key = this.lastKeyOf(searchValue); + return key === undefined ? -1 : key; + }, + + reverse: function reverse() { + return reify(this, reverseFactory(this, false)); + }, + + slice: function slice(begin, end) { + return reify(this, sliceFactory(this, begin, end, false)); + }, + + splice: function splice(index, removeNum /*, ...values*/) { + var numArgs = arguments.length; + removeNum = Math.max(removeNum || 0, 0); + if (numArgs === 0 || (numArgs === 2 && !removeNum)) { + return this; + } + // If index is negative, it should resolve relative to the size of the + // collection. However size may be expensive to compute if not cached, so + // only call count() if the number is in fact negative. + index = resolveBegin(index, index < 0 ? this.count() : this.size); + var spliced = this.slice(0, index); + return reify( + this, + numArgs === 1 + ? spliced + : spliced.concat(arrCopy(arguments, 2), this.slice(index + removeNum)) + ); + }, -function entryMapper(v, k) { - return [k, v]; -} + // ### More collection methods -function not(predicate) { - return function() { - return !predicate.apply(this, arguments); - }; -} + findLastIndex: function findLastIndex(predicate, context) { + var entry = this.findLastEntry(predicate, context); + return entry ? entry[0] : -1; + }, -function neg(predicate) { - return function() { - return -predicate.apply(this, arguments); - }; -} - -function defaultZipper() { - return arrCopy(arguments); -} - -function defaultNegComparator(a, b) { - return a < b ? 1 : a > b ? -1 : 0; -} - -function hashCollection(collection) { - if (collection.size === Infinity) { - return 0; - } - var ordered = isOrdered(collection); - var keyed = isKeyed(collection); - var h = ordered ? 1 : 0; - var size = collection.__iterate( - keyed - ? ordered - ? function (v, k) { - h = (31 * h + hashMerge(hash(v), hash(k))) | 0; - } - : function (v, k) { - h = (h + hashMerge(hash(v), hash(k))) | 0; - } - : ordered - ? function (v) { - h = (31 * h + hash(v)) | 0; - } - : function (v) { - h = (h + hash(v)) | 0; - } - ); - return murmurHashOfSize(size, h); -} - -function murmurHashOfSize(size, h) { - h = imul(h, 0xcc9e2d51); - h = imul((h << 15) | (h >>> -15), 0x1b873593); - h = imul((h << 13) | (h >>> -13), 5); - h = ((h + 0xe6546b64) | 0) ^ size; - h = imul(h ^ (h >>> 16), 0x85ebca6b); - h = imul(h ^ (h >>> 13), 0xc2b2ae35); - h = smi(h ^ (h >>> 16)); - return h; -} - -function hashMerge(a, b) { - return (a ^ (b + 0x9e3779b9 + (a << 6) + (a >> 2))) | 0; // int -} - -var OrderedSet = (function (Set$$1) { - function OrderedSet(value) { - return value === null || value === undefined - ? emptyOrderedSet() - : isOrderedSet(value) - ? value - : emptyOrderedSet().withMutations(function (set) { - var iter = SetCollection(value); - assertNotInfinite(iter.size); - iter.forEach(function (v) { return set.add(v); }); - }); - } + first: function first() { + return this.get(0); + }, - if ( Set$$1 ) OrderedSet.__proto__ = Set$$1; - OrderedSet.prototype = Object.create( Set$$1 && Set$$1.prototype ); - OrderedSet.prototype.constructor = OrderedSet; + flatten: function flatten(depth) { + return reify(this, flattenFactory(this, depth, false)); + }, - OrderedSet.of = function of (/*...values*/) { - return this(arguments); - }; + get: function get(index, notSetValue) { + index = wrapIndex(this, index); + return index < 0 || + (this.size === Infinity || (this.size !== undefined && index > this.size)) + ? notSetValue + : this.find(function (_, key) { return key === index; }, undefined, notSetValue); + }, - OrderedSet.fromKeys = function fromKeys (value) { - return this(KeyedCollection(value).keySeq()); - }; + has: function has(index) { + index = wrapIndex(this, index); + return ( + index >= 0 && + (this.size !== undefined + ? this.size === Infinity || index < this.size + : this.indexOf(index) !== -1) + ); + }, + + interpose: function interpose(separator) { + return reify(this, interposeFactory(this, separator)); + }, + + interleave: function interleave(/*...collections*/) { + var collections = [this].concat(arrCopy(arguments)); + var zipped = zipWithFactory(this.toSeq(), IndexedSeq.of, collections); + var interleaved = zipped.flatten(true); + if (zipped.size) { + interleaved.size = zipped.size * collections.length; + } + return reify(this, interleaved); + }, + + keySeq: function keySeq() { + return Range(0, this.size); + }, + + last: function last() { + return this.get(-1); + }, + + skipWhile: function skipWhile(predicate, context) { + return reify(this, skipWhileFactory(this, predicate, context, false)); + }, + + zip: function zip(/*, ...collections */) { + var collections = [this].concat(arrCopy(arguments)); + return reify(this, zipWithFactory(this, defaultZipper, collections)); + }, + + zipAll: function zipAll(/*, ...collections */) { + var collections = [this].concat(arrCopy(arguments)); + return reify(this, zipWithFactory(this, defaultZipper, collections, true)); + }, + + zipWith: function zipWith(zipper /*, ...collections */) { + var collections = arrCopy(arguments); + collections[0] = this; + return reify(this, zipWithFactory(this, zipper, collections)); + }, + }); - OrderedSet.prototype.toString = function toString () { - return this.__toString('OrderedSet {', '}'); - }; + var IndexedCollectionPrototype = IndexedCollection.prototype; + IndexedCollectionPrototype[IS_INDEXED_SENTINEL] = true; + IndexedCollectionPrototype[IS_ORDERED_SENTINEL] = true; - return OrderedSet; -}(Set)); + mixin(SetCollection, { + // ### ES6 Collection methods (ES6 Array and Map) -function isOrderedSet(maybeOrderedSet) { - return isSet(maybeOrderedSet) && isOrdered(maybeOrderedSet); -} + get: function get(value, notSetValue) { + return this.has(value) ? value : notSetValue; + }, -OrderedSet.isOrderedSet = isOrderedSet; + includes: function includes(value) { + return this.has(value); + }, -var OrderedSetPrototype = OrderedSet.prototype; -OrderedSetPrototype[IS_ORDERED_SENTINEL] = true; -OrderedSetPrototype.zip = IndexedCollectionPrototype.zip; -OrderedSetPrototype.zipWith = IndexedCollectionPrototype.zipWith; + // ### More sequential methods -OrderedSetPrototype.__empty = emptyOrderedSet; -OrderedSetPrototype.__make = makeOrderedSet; + keySeq: function keySeq() { + return this.valueSeq(); + }, + }); -function makeOrderedSet(map, ownerID) { - var set = Object.create(OrderedSetPrototype); - set.size = map ? map.size : 0; - set._map = map; - set.__ownerID = ownerID; - return set; -} + SetCollection.prototype.has = CollectionPrototype.includes; + SetCollection.prototype.contains = SetCollection.prototype.includes; -var EMPTY_ORDERED_SET; -function emptyOrderedSet() { - return ( - EMPTY_ORDERED_SET || (EMPTY_ORDERED_SET = makeOrderedSet(emptyOrderedMap())) - ); -} + // Mixin subclasses -var Record = function Record(defaultValues, name) { - var hasInitialized; + mixin(KeyedSeq, KeyedCollection.prototype); + mixin(IndexedSeq, IndexedCollection.prototype); + mixin(SetSeq, SetCollection.prototype); - var RecordType = function Record(values) { - var this$1 = this; + // #pragma Helper functions - if (values instanceof RecordType) { - return values; - } - if (!(this instanceof RecordType)) { - return new RecordType(values); - } - if (!hasInitialized) { - hasInitialized = true; - var keys = Object.keys(defaultValues); - var indices = (RecordTypePrototype._indices = {}); - RecordTypePrototype._name = name; - RecordTypePrototype._keys = keys; - RecordTypePrototype._defaultValues = defaultValues; - for (var i = 0; i < keys.length; i++) { - var propName = keys[i]; - indices[propName] = i; - if (RecordTypePrototype[propName]) { - /* eslint-disable no-console */ - typeof console === 'object' && - console.warn && - console.warn( - 'Cannot define ' + - recordName(this$1) + - ' with property "' + - propName + - '" since that property name is part of the Record API.' - ); - /* eslint-enable no-console */ - } else { - setProp(RecordTypePrototype, propName); - } + function reduce(collection, reducer, reduction, context, useFirst, reverse) { + assertNotInfinite(collection.size); + collection.__iterate(function (v, k, c) { + if (useFirst) { + useFirst = false; + reduction = v; + } else { + reduction = reducer.call(context, reduction, v, k, c); } - } - this.__ownerID = undefined; - this._values = List().withMutations(function (l) { - l.setSize(this$1._keys.length); - KeyedCollection(values).forEach(function (v, k) { - l.set(this$1._indices[k], v === this$1._defaultValues[k] ? undefined : v); - }); - }); - }; + }, reverse); + return reduction; + } - var RecordTypePrototype = (RecordType.prototype = Object.create( - RecordPrototype - )); - RecordTypePrototype.constructor = RecordType; + function keyMapper(v, k) { + return k; + } - return RecordType; -}; + function entryMapper(v, k) { + return [k, v]; + } -Record.prototype.toString = function toString () { - var this$1 = this; + function not(predicate) { + return function() { + return !predicate.apply(this, arguments); + }; + } - var str = recordName(this) + ' { '; - var keys = this._keys; - var k; - for (var i = 0, l = keys.length; i !== l; i++) { - k = keys[i]; - str += (i ? ', ' : '') + k + ': ' + quoteString(this$1.get(k)); - } - return str + ' }'; -}; - -Record.prototype.equals = function equals (other) { - return ( - this === other || - (other && - this._keys === other._keys && - recordSeq(this).equals(recordSeq(other))) - ); -}; - -Record.prototype.hashCode = function hashCode () { - return recordSeq(this).hashCode(); -}; - -// @pragma Access - -Record.prototype.has = function has (k) { - return this._indices.hasOwnProperty(k); -}; - -Record.prototype.get = function get (k, notSetValue) { - if (!this.has(k)) { - return notSetValue; + function neg(predicate) { + return function() { + return -predicate.apply(this, arguments); + }; + } + + function defaultZipper() { + return arrCopy(arguments); } - var index = this._indices[k]; - var value = this._values.get(index); - return value === undefined ? this._defaultValues[k] : value; -}; -// @pragma Modification + function defaultNegComparator(a, b) { + return a < b ? 1 : a > b ? -1 : 0; + } -Record.prototype.set = function set (k, v) { - if (this.has(k)) { - var newValues = this._values.set( - this._indices[k], - v === this._defaultValues[k] ? undefined : v - ); - if (newValues !== this._values && !this.__ownerID) { - return makeRecord(this, newValues); + function hashCollection(collection) { + if (collection.size === Infinity) { + return 0; } + var ordered = isOrdered(collection); + var keyed = isKeyed(collection); + var h = ordered ? 1 : 0; + var size = collection.__iterate( + keyed + ? ordered + ? function (v, k) { + h = (31 * h + hashMerge(hash(v), hash(k))) | 0; + } + : function (v, k) { + h = (h + hashMerge(hash(v), hash(k))) | 0; + } + : ordered + ? function (v) { + h = (31 * h + hash(v)) | 0; + } + : function (v) { + h = (h + hash(v)) | 0; + } + ); + return murmurHashOfSize(size, h); } - return this; -}; -Record.prototype.remove = function remove (k) { - return this.set(k); -}; + function murmurHashOfSize(size, h) { + h = imul(h, 0xcc9e2d51); + h = imul((h << 15) | (h >>> -15), 0x1b873593); + h = imul((h << 13) | (h >>> -13), 5); + h = ((h + 0xe6546b64) | 0) ^ size; + h = imul(h ^ (h >>> 16), 0x85ebca6b); + h = imul(h ^ (h >>> 13), 0xc2b2ae35); + h = smi(h ^ (h >>> 16)); + return h; + } -Record.prototype.clear = function clear () { - var newValues = this._values.clear().setSize(this._keys.length); - return this.__ownerID ? this : makeRecord(this, newValues); -}; + function hashMerge(a, b) { + return (a ^ (b + 0x9e3779b9 + (a << 6) + (a >> 2))) | 0; // int + } -Record.prototype.wasAltered = function wasAltered () { - return this._values.wasAltered(); -}; + var OrderedSet = (function (Set$$1) { + function OrderedSet(value) { + return value === null || value === undefined + ? emptyOrderedSet() + : isOrderedSet(value) + ? value + : emptyOrderedSet().withMutations(function (set) { + var iter = SetCollection(value); + assertNotInfinite(iter.size); + iter.forEach(function (v) { return set.add(v); }); + }); + } -Record.prototype.toSeq = function toSeq () { - return recordSeq(this); -}; + if ( Set$$1 ) OrderedSet.__proto__ = Set$$1; + OrderedSet.prototype = Object.create( Set$$1 && Set$$1.prototype ); + OrderedSet.prototype.constructor = OrderedSet; -Record.prototype.toJS = function toJS$1 () { - return toJS(this); -}; + OrderedSet.of = function of (/*...values*/) { + return this(arguments); + }; -Record.prototype.entries = function entries () { - return this.__iterator(ITERATE_ENTRIES); -}; + OrderedSet.fromKeys = function fromKeys (value) { + return this(KeyedCollection(value).keySeq()); + }; -Record.prototype.__iterator = function __iterator (type, reverse) { - return recordSeq(this).__iterator(type, reverse); -}; + OrderedSet.prototype.toString = function toString () { + return this.__toString('OrderedSet {', '}'); + }; -Record.prototype.__iterate = function __iterate (fn, reverse) { - return recordSeq(this).__iterate(fn, reverse); -}; + return OrderedSet; + }(Set)); -Record.prototype.__ensureOwner = function __ensureOwner (ownerID) { - if (ownerID === this.__ownerID) { - return this; + function isOrderedSet(maybeOrderedSet) { + return isSet(maybeOrderedSet) && isOrdered(maybeOrderedSet); } - var newValues = this._values.__ensureOwner(ownerID); - if (!ownerID) { - this.__ownerID = ownerID; - this._values = newValues; - return this; + + OrderedSet.isOrderedSet = isOrderedSet; + + var OrderedSetPrototype = OrderedSet.prototype; + OrderedSetPrototype[IS_ORDERED_SENTINEL] = true; + OrderedSetPrototype.zip = IndexedCollectionPrototype.zip; + OrderedSetPrototype.zipWith = IndexedCollectionPrototype.zipWith; + + OrderedSetPrototype.__empty = emptyOrderedSet; + OrderedSetPrototype.__make = makeOrderedSet; + + function makeOrderedSet(map, ownerID) { + var set = Object.create(OrderedSetPrototype); + set.size = map ? map.size : 0; + set._map = map; + set.__ownerID = ownerID; + return set; } - return makeRecord(this, newValues, ownerID); -}; - -Record.isRecord = isRecord; -Record.getDescriptiveName = recordName; -var RecordPrototype = Record.prototype; -RecordPrototype[IS_RECORD_SENTINEL] = true; -RecordPrototype[DELETE] = RecordPrototype.remove; -RecordPrototype.deleteIn = RecordPrototype.removeIn = deleteIn; -RecordPrototype.getIn = getIn$$1; -RecordPrototype.hasIn = CollectionPrototype.hasIn; -RecordPrototype.merge = merge; -RecordPrototype.mergeWith = mergeWith; -RecordPrototype.mergeIn = mergeIn; -RecordPrototype.mergeDeep = mergeDeep; -RecordPrototype.mergeDeepWith = mergeDeepWith; -RecordPrototype.mergeDeepIn = mergeDeepIn; -RecordPrototype.setIn = setIn$$1; -RecordPrototype.update = update$$1; -RecordPrototype.updateIn = updateIn$1; -RecordPrototype.withMutations = withMutations; -RecordPrototype.asMutable = asMutable; -RecordPrototype.asImmutable = asImmutable; -RecordPrototype[ITERATOR_SYMBOL] = RecordPrototype.entries; -RecordPrototype.toJSON = RecordPrototype.toObject = - CollectionPrototype.toObject; -RecordPrototype.inspect = RecordPrototype.toSource = function() { - return this.toString(); -}; - -function makeRecord(likeRecord, values, ownerID) { - var record = Object.create(Object.getPrototypeOf(likeRecord)); - record._values = values; - record.__ownerID = ownerID; - return record; -} - -function recordName(record) { - return record._name || record.constructor.name || 'Record'; -} - -function recordSeq(record) { - return keyedSeqFromValue(record._keys.map(function (k) { return [k, record.get(k)]; })); -} - -function setProp(prototype, name) { - try { - Object.defineProperty(prototype, name, { - get: function() { - return this.get(name); - }, - set: function(value) { - invariant(this.__ownerID, 'Cannot set on an immutable record.'); - this.set(name, value); - }, - }); - } catch (error) { - // Object.defineProperty failed. Probably IE8. + + var EMPTY_ORDERED_SET; + function emptyOrderedSet() { + return ( + EMPTY_ORDERED_SET || (EMPTY_ORDERED_SET = makeOrderedSet(emptyOrderedMap())) + ); } -} -/** - * Returns a lazy Seq of `value` repeated `times` times. When `times` is - * undefined, returns an infinite sequence of `value`. - */ -var Repeat = (function (IndexedSeq$$1) { - function Repeat(value, times) { - if (!(this instanceof Repeat)) { - return new Repeat(value, times); - } - this._value = value; - this.size = times === undefined ? Infinity : Math.max(0, times); - if (this.size === 0) { - if (EMPTY_REPEAT) { - return EMPTY_REPEAT; + var Record = function Record(defaultValues, name) { + var hasInitialized; + + var RecordType = function Record(values) { + var this$1 = this; + + if (values instanceof RecordType) { + return values; } - EMPTY_REPEAT = this; - } - } + if (!(this instanceof RecordType)) { + return new RecordType(values); + } + if (!hasInitialized) { + hasInitialized = true; + var keys = Object.keys(defaultValues); + var indices = (RecordTypePrototype._indices = {}); + RecordTypePrototype._name = name; + RecordTypePrototype._keys = keys; + RecordTypePrototype._defaultValues = defaultValues; + for (var i = 0; i < keys.length; i++) { + var propName = keys[i]; + indices[propName] = i; + if (RecordTypePrototype[propName]) { + /* eslint-disable no-console */ + typeof console === 'object' && + console.warn && + console.warn( + 'Cannot define ' + + recordName(this$1) + + ' with property "' + + propName + + '" since that property name is part of the Record API.' + ); + /* eslint-enable no-console */ + } else { + setProp(RecordTypePrototype, propName); + } + } + } + this.__ownerID = undefined; + this._values = List().withMutations(function (l) { + l.setSize(this$1._keys.length); + KeyedCollection(values).forEach(function (v, k) { + l.set(this$1._indices[k], v === this$1._defaultValues[k] ? undefined : v); + }); + }); + }; - if ( IndexedSeq$$1 ) Repeat.__proto__ = IndexedSeq$$1; - Repeat.prototype = Object.create( IndexedSeq$$1 && IndexedSeq$$1.prototype ); - Repeat.prototype.constructor = Repeat; + var RecordTypePrototype = (RecordType.prototype = Object.create( + RecordPrototype + )); + RecordTypePrototype.constructor = RecordType; - Repeat.prototype.toString = function toString () { - if (this.size === 0) { - return 'Repeat []'; - } - return 'Repeat [ ' + this._value + ' ' + this.size + ' times ]'; + return RecordType; }; - Repeat.prototype.get = function get (index, notSetValue) { - return this.has(index) ? this._value : notSetValue; - }; + Record.prototype.toString = function toString () { + var this$1 = this; - Repeat.prototype.includes = function includes (searchValue) { - return is(this._value, searchValue); + var str = recordName(this) + ' { '; + var keys = this._keys; + var k; + for (var i = 0, l = keys.length; i !== l; i++) { + k = keys[i]; + str += (i ? ', ' : '') + k + ': ' + quoteString(this$1.get(k)); + } + return str + ' }'; }; - Repeat.prototype.slice = function slice (begin, end) { - var size = this.size; - return wholeSlice(begin, end, size) - ? this - : new Repeat( - this._value, - resolveEnd(end, size) - resolveBegin(begin, size) - ); + Record.prototype.equals = function equals (other) { + return ( + this === other || + (other && + this._keys === other._keys && + recordSeq(this).equals(recordSeq(other))) + ); }; - Repeat.prototype.reverse = function reverse () { - return this; + Record.prototype.hashCode = function hashCode () { + return recordSeq(this).hashCode(); }; - Repeat.prototype.indexOf = function indexOf (searchValue) { - if (is(this._value, searchValue)) { - return 0; - } - return -1; + // @pragma Access + + Record.prototype.has = function has (k) { + return this._indices.hasOwnProperty(k); }; - Repeat.prototype.lastIndexOf = function lastIndexOf (searchValue) { - if (is(this._value, searchValue)) { - return this.size; + Record.prototype.get = function get (k, notSetValue) { + if (!this.has(k)) { + return notSetValue; } - return -1; + var index = this._indices[k]; + var value = this._values.get(index); + return value === undefined ? this._defaultValues[k] : value; }; - Repeat.prototype.__iterate = function __iterate (fn, reverse) { - var this$1 = this; + // @pragma Modification - var size = this.size; - var i = 0; - while (i !== size) { - if (fn(this$1._value, reverse ? size - ++i : i++, this$1) === false) { - break; + Record.prototype.set = function set (k, v) { + if (this.has(k)) { + var newValues = this._values.set( + this._indices[k], + v === this._defaultValues[k] ? undefined : v + ); + if (newValues !== this._values && !this.__ownerID) { + return makeRecord(this, newValues); } } - return i; + return this; }; - Repeat.prototype.__iterator = function __iterator (type, reverse) { - var this$1 = this; + Record.prototype.remove = function remove (k) { + return this.set(k); + }; - var size = this.size; - var i = 0; - return new Iterator( - function () { return i === size - ? iteratorDone() - : iteratorValue(type, reverse ? size - ++i : i++, this$1._value); } - ); + Record.prototype.clear = function clear () { + var newValues = this._values.clear().setSize(this._keys.length); + return this.__ownerID ? this : makeRecord(this, newValues); + }; + + Record.prototype.wasAltered = function wasAltered () { + return this._values.wasAltered(); }; - Repeat.prototype.equals = function equals (other) { - return other instanceof Repeat - ? is(this._value, other._value) - : deepEqual(other); + Record.prototype.toSeq = function toSeq () { + return recordSeq(this); }; - return Repeat; -}(IndexedSeq)); + Record.prototype.toJS = function toJS$1 () { + return toJS(this); + }; -var EMPTY_REPEAT; + Record.prototype.entries = function entries () { + return this.__iterator(ITERATE_ENTRIES); + }; -function fromJS(value, converter) { - return fromJSWith( - [], - converter || defaultConverter, - value, - '', - converter && converter.length > 2 ? [] : undefined, - { '': value } - ); -} - -function fromJSWith(stack, converter, value, key, keyPath, parentValue) { - var toSeq = Array.isArray(value) - ? IndexedSeq - : isPlainObj(value) - ? KeyedSeq - : null; - if (toSeq) { - if (~stack.indexOf(value)) { - throw new TypeError('Cannot convert circular structure to Immutable'); - } - stack.push(value); - keyPath && key !== '' && keyPath.push(key); - var converted = converter.call( - parentValue, - key, - toSeq(value).map(function (v, k) { return fromJSWith(stack, converter, v, k, keyPath, value); } - ), - keyPath && keyPath.slice() - ); - stack.pop(); - keyPath && keyPath.pop(); - return converted; + Record.prototype.__iterator = function __iterator (type, reverse) { + return recordSeq(this).__iterator(type, reverse); + }; + + Record.prototype.__iterate = function __iterate (fn, reverse) { + return recordSeq(this).__iterate(fn, reverse); + }; + + Record.prototype.__ensureOwner = function __ensureOwner (ownerID) { + if (ownerID === this.__ownerID) { + return this; + } + var newValues = this._values.__ensureOwner(ownerID); + if (!ownerID) { + this.__ownerID = ownerID; + this._values = newValues; + return this; + } + return makeRecord(this, newValues, ownerID); + }; + + Record.isRecord = isRecord; + Record.getDescriptiveName = recordName; + var RecordPrototype = Record.prototype; + RecordPrototype[IS_RECORD_SENTINEL] = true; + RecordPrototype[DELETE] = RecordPrototype.remove; + RecordPrototype.deleteIn = RecordPrototype.removeIn = deleteIn; + RecordPrototype.getIn = getIn$1; + RecordPrototype.hasIn = CollectionPrototype.hasIn; + RecordPrototype.merge = merge; + RecordPrototype.mergeWith = mergeWith; + RecordPrototype.mergeIn = mergeIn; + RecordPrototype.mergeDeep = mergeDeep$1; + RecordPrototype.mergeDeepWith = mergeDeepWith$1; + RecordPrototype.mergeDeepIn = mergeDeepIn; + RecordPrototype.setIn = setIn$1; + RecordPrototype.update = update$1; + RecordPrototype.updateIn = updateIn$1; + RecordPrototype.withMutations = withMutations; + RecordPrototype.asMutable = asMutable; + RecordPrototype.asImmutable = asImmutable; + RecordPrototype[ITERATOR_SYMBOL] = RecordPrototype.entries; + RecordPrototype.toJSON = RecordPrototype.toObject = + CollectionPrototype.toObject; + RecordPrototype.inspect = RecordPrototype.toSource = function() { + return this.toString(); + }; + + function makeRecord(likeRecord, values, ownerID) { + var record = Object.create(Object.getPrototypeOf(likeRecord)); + record._values = values; + record.__ownerID = ownerID; + return record; + } + + function recordName(record) { + return record._name || record.constructor.name || 'Record'; + } + + function recordSeq(record) { + return keyedSeqFromValue(record._keys.map(function (k) { return [k, record.get(k)]; })); + } + + function setProp(prototype, name) { + try { + Object.defineProperty(prototype, name, { + get: function() { + return this.get(name); + }, + set: function(value) { + invariant(this.__ownerID, 'Cannot set on an immutable record.'); + this.set(name, value); + }, + }); + } catch (error) { + // Object.defineProperty failed. Probably IE8. + } } - return value; -} -function defaultConverter(k, v) { - return isKeyed(v) ? v.toMap() : v.toList(); -} + /** + * Returns a lazy Seq of `value` repeated `times` times. When `times` is + * undefined, returns an infinite sequence of `value`. + */ + var Repeat = (function (IndexedSeq$$1) { + function Repeat(value, times) { + if (!(this instanceof Repeat)) { + return new Repeat(value, times); + } + this._value = value; + this.size = times === undefined ? Infinity : Math.max(0, times); + if (this.size === 0) { + if (EMPTY_REPEAT) { + return EMPTY_REPEAT; + } + EMPTY_REPEAT = this; + } + } + + if ( IndexedSeq$$1 ) Repeat.__proto__ = IndexedSeq$$1; + Repeat.prototype = Object.create( IndexedSeq$$1 && IndexedSeq$$1.prototype ); + Repeat.prototype.constructor = Repeat; + + Repeat.prototype.toString = function toString () { + if (this.size === 0) { + return 'Repeat []'; + } + return 'Repeat [ ' + this._value + ' ' + this.size + ' times ]'; + }; + + Repeat.prototype.get = function get (index, notSetValue) { + return this.has(index) ? this._value : notSetValue; + }; + + Repeat.prototype.includes = function includes (searchValue) { + return is(this._value, searchValue); + }; + + Repeat.prototype.slice = function slice (begin, end) { + var size = this.size; + return wholeSlice(begin, end, size) + ? this + : new Repeat( + this._value, + resolveEnd(end, size) - resolveBegin(begin, size) + ); + }; + + Repeat.prototype.reverse = function reverse () { + return this; + }; + + Repeat.prototype.indexOf = function indexOf (searchValue) { + if (is(this._value, searchValue)) { + return 0; + } + return -1; + }; + + Repeat.prototype.lastIndexOf = function lastIndexOf (searchValue) { + if (is(this._value, searchValue)) { + return this.size; + } + return -1; + }; + + Repeat.prototype.__iterate = function __iterate (fn, reverse) { + var this$1 = this; + + var size = this.size; + var i = 0; + while (i !== size) { + if (fn(this$1._value, reverse ? size - ++i : i++, this$1) === false) { + break; + } + } + return i; + }; + + Repeat.prototype.__iterator = function __iterator (type, reverse) { + var this$1 = this; + + var size = this.size; + var i = 0; + return new Iterator( + function () { return i === size + ? iteratorDone() + : iteratorValue(type, reverse ? size - ++i : i++, this$1._value); } + ); + }; + + Repeat.prototype.equals = function equals (other) { + return other instanceof Repeat + ? is(this._value, other._value) + : deepEqual(other); + }; + + return Repeat; + }(IndexedSeq)); -var version = "4.0.0-rc.9"; + var EMPTY_REPEAT; -// Functional read/write API -var Immutable = { - version: version, + function fromJS(value, converter) { + return fromJSWith( + [], + converter || defaultConverter, + value, + '', + converter && converter.length > 2 ? [] : undefined, + { '': value } + ); + } + + function fromJSWith(stack, converter, value, key, keyPath, parentValue) { + var toSeq = Array.isArray(value) + ? IndexedSeq + : isPlainObj(value) + ? KeyedSeq + : null; + if (toSeq) { + if (~stack.indexOf(value)) { + throw new TypeError('Cannot convert circular structure to Immutable'); + } + stack.push(value); + keyPath && key !== '' && keyPath.push(key); + var converted = converter.call( + parentValue, + key, + toSeq(value).map(function (v, k) { return fromJSWith(stack, converter, v, k, keyPath, value); } + ), + keyPath && keyPath.slice() + ); + stack.pop(); + keyPath && keyPath.pop(); + return converted; + } + return value; + } + + function defaultConverter(k, v) { + return isKeyed(v) ? v.toMap() : v.toList(); + } + + var version = "4.0.0-rc.9"; + + var Immutable = { + version: version, + + Collection: Collection, + // Note: Iterable is deprecated + Iterable: Collection, + + Seq: Seq, + Map: Map, + OrderedMap: OrderedMap, + List: List, + Stack: Stack, + Set: Set, + OrderedSet: OrderedSet, + + Record: Record, + Range: Range, + Repeat: Repeat, + + is: is, + fromJS: fromJS, + hash: hash, + + isImmutable: isImmutable, + isCollection: isCollection, + isKeyed: isKeyed, + isIndexed: isIndexed, + isAssociative: isAssociative, + isOrdered: isOrdered, + isValueObject: isValueObject, + + get: get, + getIn: getIn, + has: has, + hasIn: hasIn, + merge: merge$1, + mergeDeep: mergeDeep, + mergeWith: mergeWith$1, + mergeDeepWith: mergeDeepWith, + remove: remove, + removeIn: removeIn, + set: set, + setIn: setIn, + update: update, + updateIn: updateIn, + }; - Collection: Collection, // Note: Iterable is deprecated - Iterable: Collection, - - Seq: Seq, - Map: Map, - OrderedMap: OrderedMap, - List: List, - Stack: Stack, - Set: Set, - OrderedSet: OrderedSet, - - Record: Record, - Range: Range, - Repeat: Repeat, - - is: is, - fromJS: fromJS, - hash: hash, - - isImmutable: isImmutable, - isCollection: isCollection, - isKeyed: isKeyed, - isIndexed: isIndexed, - isAssociative: isAssociative, - isOrdered: isOrdered, - isValueObject: isValueObject, - - get: get, - getIn: getIn$1, - has: has, - hasIn: hasIn$1, - merge: merge$1, - mergeDeep: mergeDeep$1, - mergeWith: mergeWith$1, - mergeDeepWith: mergeDeepWith$1, - remove: remove, - removeIn: removeIn, - set: set, - setIn: setIn$1, - update: update$1, - updateIn: updateIn, -}; - -// Note: Iterable is deprecated -var Iterable = Collection; - -exports['default'] = Immutable; -exports.version = version; -exports.Collection = Collection; -exports.Iterable = Iterable; -exports.Seq = Seq; -exports.Map = Map; -exports.OrderedMap = OrderedMap; -exports.List = List; -exports.Stack = Stack; -exports.Set = Set; -exports.OrderedSet = OrderedSet; -exports.Record = Record; -exports.Range = Range; -exports.Repeat = Repeat; -exports.is = is; -exports.fromJS = fromJS; -exports.hash = hash; -exports.isImmutable = isImmutable; -exports.isCollection = isCollection; -exports.isKeyed = isKeyed; -exports.isIndexed = isIndexed; -exports.isAssociative = isAssociative; -exports.isOrdered = isOrdered; -exports.isValueObject = isValueObject; -exports.get = get; -exports.getIn = getIn$1; -exports.has = has; -exports.hasIn = hasIn$1; -exports.merge = merge$1; -exports.mergeDeep = mergeDeep$1; -exports.mergeWith = mergeWith$1; -exports.mergeDeepWith = mergeDeepWith$1; -exports.remove = remove; -exports.removeIn = removeIn; -exports.set = set; -exports.setIn = setIn$1; -exports.update = update$1; -exports.updateIn = updateIn; - -Object.defineProperty(exports, '__esModule', { value: true }); + var Iterable = Collection; + + exports.default = Immutable; + exports.version = version; + exports.Collection = Collection; + exports.Iterable = Iterable; + exports.Seq = Seq; + exports.Map = Map; + exports.OrderedMap = OrderedMap; + exports.List = List; + exports.Stack = Stack; + exports.Set = Set; + exports.OrderedSet = OrderedSet; + exports.Record = Record; + exports.Range = Range; + exports.Repeat = Repeat; + exports.is = is; + exports.fromJS = fromJS; + exports.hash = hash; + exports.isImmutable = isImmutable; + exports.isCollection = isCollection; + exports.isKeyed = isKeyed; + exports.isIndexed = isIndexed; + exports.isAssociative = isAssociative; + exports.isOrdered = isOrdered; + exports.isValueObject = isValueObject; + exports.get = get; + exports.getIn = getIn; + exports.has = has; + exports.hasIn = hasIn; + exports.merge = merge$1; + exports.mergeDeep = mergeDeep; + exports.mergeWith = mergeWith$1; + exports.mergeDeepWith = mergeDeepWith; + exports.remove = remove; + exports.removeIn = removeIn; + exports.set = set; + exports.setIn = setIn; + exports.update = update; + exports.updateIn = updateIn; + + Object.defineProperty(exports, '__esModule', { value: true }); }))); From 05e463c6087d35155f2e57209e2137807f1af56e Mon Sep 17 00:00:00 2001 From: Travis CI Date: Fri, 18 May 2018 08:15:09 +0000 Subject: [PATCH 109/242] Deploy 6309c8732dbbfe7fe9cacc29dde69ae9efaa9651 to NPM branch --- dist/immutable-nonambient.d.ts | 2 +- dist/immutable.d.ts | 2 +- dist/immutable.js.flow | 16 ++++++++-------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/dist/immutable-nonambient.d.ts b/dist/immutable-nonambient.d.ts index 8872fe1237..28428f5241 100644 --- a/dist/immutable-nonambient.d.ts +++ b/dist/immutable-nonambient.d.ts @@ -1047,7 +1047,7 @@ * Note: `mergeDeepWith` can be used in `withMutations`. */ mergeDeepWith( - merger: (oldVal: V, newVal: V, key: K) => V, + merger: (oldVal: any, newVal: any, key: any) => any, ...collections: Array | {[key: string]: V}> ): this; diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index a330bf4336..0ab0d663d5 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -1047,7 +1047,7 @@ declare module Immutable { * Note: `mergeDeepWith` can be used in `withMutations`. */ mergeDeepWith( - merger: (oldVal: V, newVal: V, key: K) => V, + merger: (oldVal: any, newVal: any, key: any) => any, ...collections: Array | {[key: string]: V}> ): this; diff --git a/dist/immutable.js.flow b/dist/immutable.js.flow index 9904310f83..ee21e0d1f4 100644 --- a/dist/immutable.js.flow +++ b/dist/immutable.js.flow @@ -896,10 +896,10 @@ declare class Map extends KeyedCollection mixins UpdatableInCollect ...collections: (Iterable<[K_, V_]> | PlainObjInput)[] ): Map; - mergeDeepWith( - merger: (oldVal: V, newVal: W, key: K) => X, - ...collections: (Iterable<[K_, W]> | PlainObjInput)[] - ): Map; + mergeDeepWith( + merger: (oldVal: any, newVal: any, key: any) => mixed, + ...collections: (Iterable<[K_, V_]> | PlainObjInput)[] + ): Map; mergeIn( keyPath: Iterable, @@ -982,10 +982,10 @@ declare class OrderedMap extends Map mixins UpdatableInCollection | PlainObjInput)[] ): OrderedMap; - mergeDeepWith( - merger: (oldVal: V, newVal: W, key: K) => X, - ...collections: (Iterable<[K_, W]> | PlainObjInput)[] - ): OrderedMap; + mergeDeepWith( + merger: (oldVal: any, newVal: any, key: any) => mixed, + ...collections: (Iterable<[K_, V_]> | PlainObjInput)[] + ): OrderedMap; mergeIn( keyPath: Iterable, From c7ddde2757011159961160de949a99ad500f94c9 Mon Sep 17 00:00:00 2001 From: Travis CI Date: Fri, 18 May 2018 08:34:14 +0000 Subject: [PATCH 110/242] Deploy c690ca8235cb397ba1b39a4b1f28acc3440dbafc to NPM branch --- README.md | 3 ++- dist/immutable-nonambient.d.ts | 3 +++ dist/immutable.d.ts | 3 +++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 584a3d23bf..edaa12dbd0 100644 --- a/README.md +++ b/README.md @@ -302,7 +302,8 @@ not altered. All Immutable.js Collections can be converted to plain JavaScript Arrays and Objects shallowly with `toArray()` and `toObject()` or deeply with `toJS()`. All Immutable Collections also implement `toJSON()` allowing them to be passed -to `JSON.stringify` directly. +to `JSON.stringify` directly. They also respect the custom `toJSON()` methods of +nested objects. ```js diff --git a/dist/immutable-nonambient.d.ts b/dist/immutable-nonambient.d.ts index 28428f5241..39bdbf0d00 100644 --- a/dist/immutable-nonambient.d.ts +++ b/dist/immutable-nonambient.d.ts @@ -2501,6 +2501,9 @@ /** * Deeply converts this Record to equivalent native JavaScript Object. + * + * Note: This method may not be overridden. Objects with custom + * serialization to plain JS may override toJSON() instead. */ toJS(): { [K in keyof TProps]: any }; diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index 0ab0d663d5..0925cd6869 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -2501,6 +2501,9 @@ declare module Immutable { /** * Deeply converts this Record to equivalent native JavaScript Object. + * + * Note: This method may not be overridden. Objects with custom + * serialization to plain JS may override toJSON() instead. */ toJS(): { [K in keyof TProps]: any }; From 1db9a8895efd3dac633b759131a119fede19e11d Mon Sep 17 00:00:00 2001 From: Travis CI Date: Fri, 18 May 2018 09:33:08 +0000 Subject: [PATCH 111/242] Deploy e65e5af806ea23a32ccf8f56c6fabf39605bac80 to NPM branch --- dist/immutable-nonambient.d.ts | 16 +++++++++++++--- dist/immutable.d.ts | 16 +++++++++++++--- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/dist/immutable-nonambient.d.ts b/dist/immutable-nonambient.d.ts index 39bdbf0d00..1f2f52a5cd 100644 --- a/dist/immutable-nonambient.d.ts +++ b/dist/immutable-nonambient.d.ts @@ -2193,7 +2193,7 @@ * ```js * const { Record } = require('immutable') * const ABRecord = Record({ a: 1, b: 2 }) - * const myRecord = new ABRecord({ b: 3 }) + * const myRecord = ABRecord({ b: 3 }) * ``` * * Records always have a value for the keys they define. `remove`ing a key @@ -2214,7 +2214,7 @@ * ignored for this record. * * ```js - * const myRecord = new ABRecord({ b: 3, x: 10 }) + * const myRecord = ABRecord({ b: 3, x: 10 }) * myRecord.get('x') // undefined * ``` * @@ -2229,10 +2229,20 @@ * myRecord.b = 5 // throws Error * ``` * - * Record Classes can be extended as well, allowing for custom methods on your + * Record Types can be extended as well, allowing for custom methods on your * Record. This is not a common pattern in functional environments, but is in * many JS programs. * + * However Record Types are more restricted than typical JavaScript classes. + * They do not use a class constructor, which also means they cannot use + * class properties (since those are technically part of a constructor). + * + * While Record Types can be syntactically created with the JavaScript `class` + * form, the resulting Record function is actually a factory function, not a + * class constructor. Even though Record Types are not classes, JavaScript + * currently requires the use of `new` when creating new Record instances if + * they are defined as a `class`. + * * ``` * class ABRecord extends Record({ a: 1, b: 2 }) { * getAB() { diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index 0925cd6869..e493a78ba1 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -2193,7 +2193,7 @@ declare module Immutable { * ```js * const { Record } = require('immutable') * const ABRecord = Record({ a: 1, b: 2 }) - * const myRecord = new ABRecord({ b: 3 }) + * const myRecord = ABRecord({ b: 3 }) * ``` * * Records always have a value for the keys they define. `remove`ing a key @@ -2214,7 +2214,7 @@ declare module Immutable { * ignored for this record. * * ```js - * const myRecord = new ABRecord({ b: 3, x: 10 }) + * const myRecord = ABRecord({ b: 3, x: 10 }) * myRecord.get('x') // undefined * ``` * @@ -2229,10 +2229,20 @@ declare module Immutable { * myRecord.b = 5 // throws Error * ``` * - * Record Classes can be extended as well, allowing for custom methods on your + * Record Types can be extended as well, allowing for custom methods on your * Record. This is not a common pattern in functional environments, but is in * many JS programs. * + * However Record Types are more restricted than typical JavaScript classes. + * They do not use a class constructor, which also means they cannot use + * class properties (since those are technically part of a constructor). + * + * While Record Types can be syntactically created with the JavaScript `class` + * form, the resulting Record function is actually a factory function, not a + * class constructor. Even though Record Types are not classes, JavaScript + * currently requires the use of `new` when creating new Record instances if + * they are defined as a `class`. + * * ``` * class ABRecord extends Record({ a: 1, b: 2 }) { * getAB() { From 7af37b7d4aa90505facf2c02c25223813b43ae8c Mon Sep 17 00:00:00 2001 From: Travis CI Date: Tue, 18 Sep 2018 18:23:12 +0000 Subject: [PATCH 112/242] Deploy 8a11e5805af2ab40163ed531b0faccf559bccf82 to NPM branch --- README.md | 2 +- dist/immutable-nonambient.d.ts | 15 +++++-- dist/immutable.d.ts | 15 +++++-- dist/immutable.es.js | 73 +++------------------------------- dist/immutable.js | 73 +++------------------------------- dist/immutable.min.js | 64 ++++++++++++++--------------- 6 files changed, 67 insertions(+), 175 deletions(-) diff --git a/README.md b/README.md index edaa12dbd0..c6f35ca158 100644 --- a/README.md +++ b/README.md @@ -618,7 +618,7 @@ Contribution Use [Github issues](https://github.com/facebook/immutable-js/issues) for requests. -We actively welcome pull requests, learn how to [contribute](./.github/CONTRIBUTING.md). +We actively welcome pull requests, learn how to [contribute](https://github.com/facebook/immutable-js/blob/master/.github/CONTRIBUTING.md). Changelog diff --git a/dist/immutable-nonambient.d.ts b/dist/immutable-nonambient.d.ts index 1f2f52a5cd..22e24b4126 100644 --- a/dist/immutable-nonambient.d.ts +++ b/dist/immutable-nonambient.d.ts @@ -3008,10 +3008,13 @@ * * If a `Seq`, that same `Seq`. * * If an `Collection`, a `Seq` of the same kind (Keyed, Indexed, or Set). * * If an Array-like, an `Seq.Indexed`. - * * If an Object with an Iterator, an `Seq.Indexed`. - * * If an Iterator, an `Seq.Indexed`. + * * If an Iterable Object, an `Seq.Indexed`. * * If an Object, a `Seq.Keyed`. * + * Note: An Iterator itself will be treated as an object, becoming a `Seq.Keyed`, + * which is usually not what you want. You should turn your Iterator Object into + * an iterable object by defining a Symbol.iterator (or @@iterator) method which + * returns `this`. */ export function Seq>(seq: S): S; export function Seq(collection: Collection.Keyed): Seq.Keyed; @@ -3723,13 +3726,17 @@ * * * If an `Collection`, that same `Collection`. * * If an Array-like, an `Collection.Indexed`. - * * If an Object with an Iterator, an `Collection.Indexed`. - * * If an Iterator, an `Collection.Indexed`. + * * If an Object with an Iterator defined, an `Collection.Indexed`. * * If an Object, an `Collection.Keyed`. * * This methods forces the conversion of Objects and Strings to Collections. * If you want to ensure that a Collection of one item is returned, use * `Seq.of`. + * + * Note: An Iterator itself will be treated as an object, becoming a `Seq.Keyed`, + * which is usually not what you want. You should turn your Iterator Object into + * an iterable object by defining a Symbol.iterator (or @@iterator) method which + * returns `this`. */ export function Collection>(collection: I): I; export function Collection(collection: Iterable): Collection.Indexed; diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index e493a78ba1..47e00c7e7a 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -3008,10 +3008,13 @@ declare module Immutable { * * If a `Seq`, that same `Seq`. * * If an `Collection`, a `Seq` of the same kind (Keyed, Indexed, or Set). * * If an Array-like, an `Seq.Indexed`. - * * If an Object with an Iterator, an `Seq.Indexed`. - * * If an Iterator, an `Seq.Indexed`. + * * If an Iterable Object, an `Seq.Indexed`. * * If an Object, a `Seq.Keyed`. * + * Note: An Iterator itself will be treated as an object, becoming a `Seq.Keyed`, + * which is usually not what you want. You should turn your Iterator Object into + * an iterable object by defining a Symbol.iterator (or @@iterator) method which + * returns `this`. */ export function Seq>(seq: S): S; export function Seq(collection: Collection.Keyed): Seq.Keyed; @@ -3723,13 +3726,17 @@ declare module Immutable { * * * If an `Collection`, that same `Collection`. * * If an Array-like, an `Collection.Indexed`. - * * If an Object with an Iterator, an `Collection.Indexed`. - * * If an Iterator, an `Collection.Indexed`. + * * If an Object with an Iterator defined, an `Collection.Indexed`. * * If an Object, an `Collection.Keyed`. * * This methods forces the conversion of Objects and Strings to Collections. * If you want to ensure that a Collection of one item is returned, use * `Seq.of`. + * + * Note: An Iterator itself will be treated as an object, becoming a `Seq.Keyed`, + * which is usually not what you want. You should turn your Iterator Object into + * an iterable object by defining a Symbol.iterator (or @@iterator) method which + * returns `this`. */ export function Collection>(collection: I): I; export function Collection(collection: Iterable): Collection.Indexed; diff --git a/dist/immutable.es.js b/dist/immutable.es.js index 10997a5247..da9276fd36 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -583,63 +583,6 @@ var CollectionSeq = (function (IndexedSeq) { return CollectionSeq; }(IndexedSeq)); -var IteratorSeq = (function (IndexedSeq) { - function IteratorSeq(iterator) { - this._iterator = iterator; - this._iteratorCache = []; - } - - if ( IndexedSeq ) IteratorSeq.__proto__ = IndexedSeq; - IteratorSeq.prototype = Object.create( IndexedSeq && IndexedSeq.prototype ); - IteratorSeq.prototype.constructor = IteratorSeq; - - IteratorSeq.prototype.__iterateUncached = function __iterateUncached (fn, reverse) { - var this$1 = this; - - if (reverse) { - return this.cacheResult().__iterate(fn, reverse); - } - var iterator = this._iterator; - var cache = this._iteratorCache; - var iterations = 0; - while (iterations < cache.length) { - if (fn(cache[iterations], iterations++, this$1) === false) { - return iterations; - } - } - var step; - while (!(step = iterator.next()).done) { - var val = step.value; - cache[iterations] = val; - if (fn(val, iterations++, this$1) === false) { - break; - } - } - return iterations; - }; - - IteratorSeq.prototype.__iteratorUncached = function __iteratorUncached (type, reverse) { - if (reverse) { - return this.cacheResult().__iterator(type, reverse); - } - var iterator = this._iterator; - var cache = this._iteratorCache; - var iterations = 0; - return new Iterator(function () { - if (iterations >= cache.length) { - var step = iterator.next(); - if (step.done) { - return step; - } - cache[iterations] = step.value; - } - return iteratorValue(type, iterations, cache[iterations++]); - }); - }; - - return IteratorSeq; -}(IndexedSeq)); - // # pragma Helper functions function isSeq(maybeSeq) { @@ -655,11 +598,9 @@ function emptySequence() { function keyedSeqFromValue(value) { var seq = Array.isArray(value) ? new ArraySeq(value) - : isIterator(value) - ? new IteratorSeq(value) - : hasIterator(value) - ? new CollectionSeq(value) - : undefined; + : hasIterator(value) + ? new CollectionSeq(value) + : undefined; if (seq) { return seq.fromEntrySeq(); } @@ -698,11 +639,9 @@ function seqFromValue(value) { function maybeIndexedSeqFromValue(value) { return isArrayLike(value) ? new ArraySeq(value) - : isIterator(value) - ? new IteratorSeq(value) - : hasIterator(value) - ? new CollectionSeq(value) - : undefined; + : hasIterator(value) + ? new CollectionSeq(value) + : undefined; } /** diff --git a/dist/immutable.js b/dist/immutable.js index 7ca9e64c5d..35652d94e2 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -589,63 +589,6 @@ return CollectionSeq; }(IndexedSeq)); - var IteratorSeq = (function (IndexedSeq) { - function IteratorSeq(iterator) { - this._iterator = iterator; - this._iteratorCache = []; - } - - if ( IndexedSeq ) IteratorSeq.__proto__ = IndexedSeq; - IteratorSeq.prototype = Object.create( IndexedSeq && IndexedSeq.prototype ); - IteratorSeq.prototype.constructor = IteratorSeq; - - IteratorSeq.prototype.__iterateUncached = function __iterateUncached (fn, reverse) { - var this$1 = this; - - if (reverse) { - return this.cacheResult().__iterate(fn, reverse); - } - var iterator = this._iterator; - var cache = this._iteratorCache; - var iterations = 0; - while (iterations < cache.length) { - if (fn(cache[iterations], iterations++, this$1) === false) { - return iterations; - } - } - var step; - while (!(step = iterator.next()).done) { - var val = step.value; - cache[iterations] = val; - if (fn(val, iterations++, this$1) === false) { - break; - } - } - return iterations; - }; - - IteratorSeq.prototype.__iteratorUncached = function __iteratorUncached (type, reverse) { - if (reverse) { - return this.cacheResult().__iterator(type, reverse); - } - var iterator = this._iterator; - var cache = this._iteratorCache; - var iterations = 0; - return new Iterator(function () { - if (iterations >= cache.length) { - var step = iterator.next(); - if (step.done) { - return step; - } - cache[iterations] = step.value; - } - return iteratorValue(type, iterations, cache[iterations++]); - }); - }; - - return IteratorSeq; - }(IndexedSeq)); - // # pragma Helper functions function isSeq(maybeSeq) { @@ -661,11 +604,9 @@ function keyedSeqFromValue(value) { var seq = Array.isArray(value) ? new ArraySeq(value) - : isIterator(value) - ? new IteratorSeq(value) - : hasIterator(value) - ? new CollectionSeq(value) - : undefined; + : hasIterator(value) + ? new CollectionSeq(value) + : undefined; if (seq) { return seq.fromEntrySeq(); } @@ -704,11 +645,9 @@ function maybeIndexedSeqFromValue(value) { return isArrayLike(value) ? new ArraySeq(value) - : isIterator(value) - ? new IteratorSeq(value) - : hasIterator(value) - ? new CollectionSeq(value) - : undefined; + : hasIterator(value) + ? new CollectionSeq(value) + : undefined; } /** diff --git a/dist/immutable.min.js b/dist/immutable.min.js index b2d18965cf..0a3e4cdf91 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -4,35 +4,35 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ -!function(t,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r(t.Immutable={})}(this,function(t){"use strict";function r(t){return t.value=!1,t}function e(t){t&&(t.value=!0)}function n(){}function i(t){return void 0===t.size&&(t.size=t.__iterate(u)),t.size}function o(t,r){if("number"!=typeof r){var e=r>>>0;if(""+e!==r||4294967295===e)return NaN;r=e}return r<0?i(t)+r:r}function u(){return!0}function s(t,r,e){return(0===t&&!h(t)||void 0!==e&&t<=-e)&&(void 0===r||void 0!==e&&r>=e)}function a(t,r){return f(t,r,0)}function c(t,r){return f(t,r,r)}function f(t,r,e){return void 0===t?e:h(t)?r===1/0?r:0|Math.max(0,r+t):void 0===r||r===t?t:0|Math.min(r,t)}function h(t){return t<0||0===t&&1/t==-(1/0)}function p(t){return _(t)||g(t)}function _(t){return!(!t||!t[he])}function l(t){return!(!t||!t[pe])}function v(t){return!(!t||!t[_e])}function y(t){return l(t)||v(t)}function d(t){return!(!t||!t[le])}function g(t){return!(!t||!t[ve])}function m(t){return!(!t||"function"!=typeof t.equals||"function"!=typeof t.hashCode)}function w(t,r,e,n){var i=0===t?r:1===t?e:[r,e];return n?n.value=i:n={value:i,done:!1},n}function z(){return{value:void 0,done:!0}}function S(t){return!!O(t)}function I(t){return t&&"function"==typeof t.next}function b(t){var r=O(t);return r&&r.call(t)}function O(t){var r=t&&(Ie&&t[Ie]||t[be]);if("function"==typeof r)return r}function E(t){return!(!Array.isArray(t)&&"string"!=typeof t)||t&&"object"==typeof t&&Number.isInteger(t.length)&&t.length>=0&&(0===t.length?1===Object.keys(t).length:t.hasOwnProperty(t.length-1))}function q(t){return!(!t||!t[je])}function M(){return Ue||(Ue=new ke([]))}function D(t){var r=Array.isArray(t)?new ke(t):I(t)?new Ce(t):S(t)?new Te(t):void 0;if(r)return r.fromEntrySeq();if("object"==typeof t)return new Re(t);throw new TypeError("Expected Array or collection object of [k, v] entries, or keyed object: "+t)}function A(t){var r=j(t);if(r)return r -;throw new TypeError("Expected Array or collection object of values: "+t)}function x(t){var r=j(t);if(r)return r;if("object"==typeof t)return new Re(t);throw new TypeError("Expected Array or collection object of values, or keyed object: "+t)}function j(t){return E(t)?new ke(t):I(t)?new Ce(t):S(t)?new Te(t):void 0}function k(t,r){if(t===r||t!==t&&r!==r)return!0;if(!t||!r)return!1;if("function"==typeof t.valueOf&&"function"==typeof r.valueOf){if(t=t.valueOf(),r=r.valueOf(),t===r||t!==t&&r!==r)return!0;if(!t||!r)return!1}return!!(m(t)&&m(r)&&t.equals(r))}function R(t){return t>>>1&1073741824|3221225471&t}function U(t){if(t===!1||null===t||void 0===t)return 0;if("function"==typeof t.valueOf&&((t=t.valueOf())===!1||null===t||void 0===t))return 0;if(t===!0)return 1;var r=typeof t;if("number"===r){if(t!==t||t===1/0)return 0;var e=0|t;for(e!==t&&(e^=4294967295*t);t>4294967295;)t/=4294967295,e^=t;return R(e)}if("string"===r)return t.length>He?K(t):T(t);if("function"==typeof t.hashCode)return R(t.hashCode());if("object"===r||"function"===r)return C(t);if("function"==typeof t.toString)return T(""+t);throw Error("Value type "+r+" cannot be hashed.")}function K(t){var r=Qe[t];return void 0===r&&(r=T(t),Ye===Ve&&(Ye=0,Qe={}),Ye++,Qe[t]=r),r}function T(t){for(var r=0,e=0;e0)switch(t.nodeType){case 1:return t.uniqueID;case 9:return t.documentElement&&t.documentElement.uniqueID}}function B(t){var r=ut(t);return r._iter=t,r.size=t.size,r.flip=function(){return t},r.reverse=function(){var r=t.reverse.apply(this);return r.flip=function(){return t.reverse()},r},r.has=function(r){return t.includes(r)},r.includes=function(r){return t.has(r)},r.cacheResult=st,r.__iterateUncached=function(r,e){var n=this;return t.__iterate(function(t,e){return r(e,t,n)!==!1},e)},r.__iteratorUncached=function(r,e){if(r===Se){var n=t.__iterator(r,e);return new Ee(function(){var t=n.next();if(!t.done){var r=t.value[0];t.value[0]=t.value[1],t.value[1]=r}return t})}return t.__iterator(r===ze?we:ze,e)},r}function W(t,r,e){var n=ut(t);return n.size=t.size,n.has=function(r){return t.has(r)},n.get=function(n,i){var o=t.get(n,ae);return o===ae?i:r.call(e,o,n,t)},n.__iterateUncached=function(n,i){var o=this;return t.__iterate(function(t,i,u){return n(r.call(e,t,i,u),i,o)!==!1},i)},n.__iteratorUncached=function(n,i){var o=t.__iterator(Se,i);return new Ee(function(){var i=o.next();if(i.done)return i;var u=i.value,s=u[0];return w(n,s,r.call(e,u[1],s,t),i)})},n}function N(t,r){var e=this,n=ut(t);return n._iter=t,n.size=t.size,n.reverse=function(){return t},t.flip&&(n.flip=function(){var r=B(t);return r.reverse=function(){return t.flip()},r}),n.get=function(e,n){return t.get(r?e:-1-e,n)},n.has=function(e){return t.has(r?e:-1-e)},n.includes=function(r){return t.includes(r)},n.cacheResult=st,n.__iterate=function(e,n){var o=this,u=0;return n&&i(t),t.__iterate(function(t,i){return e(t,r?i:n?o.size-++u:u++,o)},!n)},n.__iterator=function(n,o){var u=0;o&&i(t);var s=t.__iterator(Se,!o);return new Ee(function(){var t=s.next();if(t.done)return t;var i=t.value;return w(n,r?i[0]:o?e.size-++u:u++,i[1],t)})},n}function P(t,r,e,n){var i=ut(t);return n&&(i.has=function(n){var i=t.get(n,ae) -;return i!==ae&&!!r.call(e,i,n,t)},i.get=function(n,i){var o=t.get(n,ae);return o!==ae&&r.call(e,o,n,t)?o:i}),i.__iterateUncached=function(i,o){var u=this,s=0;return t.__iterate(function(t,o,a){if(r.call(e,t,o,a))return s++,i(t,n?o:s-1,u)},o),s},i.__iteratorUncached=function(i,o){var u=t.__iterator(Se,o),s=0;return new Ee(function(){for(;;){var o=u.next();if(o.done)return o;var a=o.value,c=a[0],f=a[1];if(r.call(e,f,c,t))return w(i,n?c:s++,f,o)}})},i}function J(t,r,e){var n=$e().asMutable();return t.__iterate(function(i,o){n.update(r.call(e,i,o,t),0,function(t){return t+1})}),n.asImmutable()}function H(t,r,e){var n=l(t),i=(d(t)?mn():$e()).asMutable();t.__iterate(function(o,u){i.update(r.call(e,o,u,t),function(t){return t=t||[],t.push(n?[u,o]:o),t})});var o=ot(t);return i.map(function(r){return nt(t,o(r))})}function V(t,r,e,n){var i=t.size;if(s(r,e,i))return t;var u=a(r,i),f=c(e,i);if(u!==u||f!==f)return V(t.toSeq().cacheResult(),r,e,n);var h,p=f-u;p===p&&(h=p<0?0:p);var _=ut(t);return _.size=0===h?h:t.size&&h||void 0,!n&&q(t)&&h>=0&&(_.get=function(r,e){return r=o(this,r),r>=0&&rh)return z();var t=i.next();return n||r===ze||t.done?t:r===we?w(r,s-1,void 0,t):w(r,s-1,t.value[1],t)})},_}function Y(t,r,e){var n=ut(t);return n.__iterateUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterate(n,i);var u=0;return t.__iterate(function(t,i,s){return r.call(e,t,i,s)&&++u&&n(t,i,o)}),u},n.__iteratorUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterator(n,i);var u=t.__iterator(Se,i),s=!0;return new Ee(function(){if(!s)return z();var t=u.next() -;if(t.done)return t;var i=t.value,a=i[0],c=i[1];return r.call(e,c,a,o)?n===Se?t:w(n,a,c,t):(s=!1,z())})},n}function Q(t,r,e,n){var i=ut(t);return i.__iterateUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterate(i,o);var s=!0,a=0;return t.__iterate(function(t,o,c){if(!s||!(s=r.call(e,t,o,c)))return a++,i(t,n?o:a-1,u)}),a},i.__iteratorUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterator(i,o);var s=t.__iterator(Se,o),a=!0,c=0;return new Ee(function(){var t,o,f;do{if(t=s.next(),t.done)return n||i===ze?t:i===we?w(i,c++,void 0,t):w(i,c++,t.value[1],t);var h=t.value;o=h[0],f=h[1],a&&(a=r.call(e,f,o,u))}while(a);return i===Se?t:w(i,o,f,t)})},i}function X(t,r){var e=l(t),n=[t].concat(r).map(function(t){return _(t)?e&&(t=de(t)):t=e?D(t):A(Array.isArray(t)?t:[t]),t}).filter(function(t){return 0!==t.size});if(0===n.length)return t;if(1===n.length){var i=n[0];if(i===t||e&&l(i)||v(t)&&v(i))return i}var o=new ke(n);return e?o=o.toKeyedSeq():v(t)||(o=o.toSetSeq()),o=o.flatten(!0),o.size=n.reduce(function(t,r){if(void 0!==t){var e=r.size;if(void 0!==e)return t+e}},0),o}function F(t,r,e){var n=ut(t);return n.__iterateUncached=function(i,o){function u(t,c){t.__iterate(function(t,o){return(!r||c0}function et(t,r,e,n){var i=ut(t),o=new ke(e).map(function(t){return t.size});return i.size=n?o.max():o.min(),i.__iterate=function(t,r){for(var e,n=this,i=this.__iterator(ze,r),o=0;!(e=i.next()).done&&t(e.value,o++,n)!==!1;);return o},i.__iteratorUncached=function(t,i){var o=e.map(function(t){return t=ye(t),b(i?t.reverse():t)}),u=0,s=!1;return new Ee(function(){var e;return s||(e=o.map(function(t){return t.next()}),s=n?e.every(function(t){return t.done}):e.some(function(t){return t.done})),s?z():w(t,u++,r.apply(null,e.map(function(t){return t.value})))})},i}function nt(t,r){return t===r?t:q(t)?r:t.constructor(r)}function it(t){if(t!==Object(t))throw new TypeError("Expected [K, V] tuple: "+t)}function ot(t){return l(t)?de:v(t)?ge:me}function ut(t){return Object.create((l(t)?De:v(t)?Ae:xe).prototype)}function st(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size,this):Me.prototype.cacheResult.call(this)}function at(t,r){return void 0===t&&void 0===r?0:void 0===t?1:void 0===r?-1:t>r?1:t0;)r[e]=arguments[e+1];return jt(this,r,t)}function jt(t,r,e){for(var n=[],i=0;i0;)r[e]=arguments[e+1];return Ct(t,r)}function Rt(t,r){for(var e=[],n=arguments.length-2;n-- >0;)e[n]=arguments[n+2];return Ct(r,e,t)}function Ut(t){for(var r=[],e=arguments.length-1;e-- >0;)r[e]=arguments[e+1];return Tt(t,r)}function Kt(t,r){for(var e=[],n=arguments.length-2;n-- >0;)e[n]=arguments[n+2];return Tt(r,e,t)}function Tt(t,r,e){return Ct(t,r,Lt(e))}function Ct(t,r,e){if(!lt(t))throw new TypeError("Cannot merge into non-data-structure value: "+t);if(p(t))return t.mergeWith?t.mergeWith.apply(t,[e].concat(r)):t.concat.apply(t,r);for(var n=Array.isArray(t),i=t,o=n?ge:de,u=n?function(r){i===t&&(i=gt(i)),i.push(r)}:function(r,n){var o=qe.call(i,n),u=o&&e?e(i[n],r,n):r;o&&u===i[n]||(i===t&&(i=gt(i)),i[n]=u)},s=0;s0;)r[e]=arguments[e+1];return Tt(this,r,t)}function Nt(t){for(var r=[],e=arguments.length-1;e-- >0;)r[e]=arguments[e+1];return zt(this,t,Zt(),function(t){return Ct(t,r)})}function Pt(t){for(var r=[],e=arguments.length-1;e-- >0;)r[e]=arguments[e+1];return zt(this,t,Zt(),function(t){return Tt(t,r)})}function Jt(t){var r=this.asMutable();return t(r),r.wasAltered()?r.__ensureOwner(this.__ownerID):this}function Ht(){return this.__ownerID?this:this.__ensureOwner(new n)}function Vt(){return this.__ensureOwner()}function Yt(){return this.__altered}function Qt(t){ -return!(!t||!t[tn])}function Xt(t,r){return w(t,r[0],r[1])}function Ft(t,r){return{node:t,index:0,__prev:r}}function Gt(t,r,e,n){var i=Object.create(rn);return i.size=t,i._root=r,i.__ownerID=e,i.__hash=n,i.__altered=!1,i}function Zt(){return an||(an=Gt(0))}function $t(t,e,n){var i,o;if(t._root){var u=r(ce),s=r(fe);if(i=tr(t._root,t.__ownerID,0,void 0,e,n,u,s),!s.value)return t;o=t.size+(u.value?n===ae?-1:1:0)}else{if(n===ae)return t;o=1,i=new en(t.__ownerID,[[e,n]])}return t.__ownerID?(t.size=o,t._root=i,t.__hash=void 0,t.__altered=!0,t):i?Gt(o,i):Zt()}function tr(t,r,n,i,o,u,s,a){return t?t.update(r,n,i,o,u,s,a):u===ae?t:(e(a),e(s),new sn(r,i,[o,u]))}function rr(t){return t.constructor===sn||t.constructor===un}function er(t,r,e,n,i){if(t.keyHash===n)return new un(r,n,[t.entry,i]);var o,u=(0===e?t.keyHash:t.keyHash>>>e)&se,s=(0===e?n:n>>>e)&se;return new nn(r,1<>>=1)u[s]=1&e?r[o++]:void 0;return u[n]=i,new on(t,o+1,u)}function ur(t){return t-=t>>1&1431655765,t=(858993459&t)+(t>>2&858993459),t=t+(t>>4)&252645135,t+=t>>8,127&(t+=t>>16)}function sr(t,r,e,n){var i=n?t:ct(t);return i[r]=e,i}function ar(t,r,e,n){var i=t.length+1;if(n&&r+1===i)return t[r]=e,t;for(var o=Array(i),u=0,s=0;so?0:o-e,c=u-e;return c>ue&&(c=ue),function(){if(i===c)return gn;var t=r?--c:i++;return n&&n[t]}} -function i(t,n,i){var s,a=t&&t.array,c=i>o?0:o-i>>n,f=1+(u-i>>n);return f>ue&&(f=ue),function(){for(;;){if(s){var t=s();if(t!==gn)return t;s=null}if(c===f)return gn;var o=r?--f:c++;s=e(a&&a[o],n-oe,i+(o<=t.size||e<0)return t.withMutations(function(t){e<0?gr(t,e).set(0,n):gr(t,0,e+1).set(e,n)});e+=t._origin;var i=t._tail,u=t._root,s=r(fe);return e>=mr(t._capacity)?i=vr(i,t.__ownerID,0,e,n,s):u=vr(u,t.__ownerID,t._level,e,n,s),s.value?t.__ownerID?(t._root=u,t._tail=i,t.__hash=void 0,t.__altered=!0,t):pr(t._origin,t._capacity,t._level,u,i):t}function vr(t,r,n,i,o,u){var s=i>>>n&se,a=t&&s0){var f=t&&t.array[s],h=vr(f,r,n-oe,i,o,u);return h===f?t:(c=yr(t,r),c.array[s]=h,c)}return a&&t.array[s]===o?t:(e(u),c=yr(t,r),void 0===o&&s===c.array.length-1?c.array.pop():c.array[s]=o,c)}function yr(t,r){return r&&t&&r===t.ownerID?t:new yn(t?t.array.slice():[],r)}function dr(t,r){if(r>=mr(t._capacity))return t._tail;if(r<1<0;)e=e.array[r>>>n&se],n-=oe;return e}}function gr(t,r,e){void 0!==r&&(r|=0),void 0!==e&&(e|=0);var i=t.__ownerID||new n,o=t._origin,u=t._capacity,s=o+r,a=void 0===e?u:e<0?u+e:o+e;if(s===o&&a===u)return t;if(s>=a)return t.clear();for(var c=t._level,f=t._root,h=0;s+h<0;)f=new yn(f&&f.array.length?[void 0,f]:[],i),c+=oe,h+=1<=1<p?new yn([],i):l;if(l&&_>p&&soe;d-=oe){var g=p>>>d&se;y=y.array[g]=yr(y.array[g],i)}y.array[p>>>oe&se]=l}if(a=_)s-=_,a-=_,c=oe,f=null, -v=v&&v.removeBefore(i,0,s);else if(s>o||_>>c&se;if(m!==_>>>c&se)break;m&&(h+=(1<o&&(f=f.removeBefore(i,c,s-h)),f&&_>>oe<=ue&&u.size>=2*o.size?(i=u.filter(function(t,r){return void 0!==t&&s!==r}),n=i.toKeyedSeq().map(function(t){return t[0]}).flip().toMap(),t.__ownerID&&(n.__ownerID=i.__ownerID=t.__ownerID)):(n=o.remove(r),i=s===u.size-1?u.pop():u.set(s,void 0))}else if(a){if(e===u.get(s)[1])return t;n=o,i=u.set(s,[r,e])}else n=o.set(r,u.size),i=u.set(u.size,[r,e]);return t.__ownerID?(t.size=n.size,t._map=n,t._list=i,t.__hash=void 0,t):zr(n,i)}function br(t){return!(!t||!t[Sn])}function Or(t,r,e,n){var i=Object.create(In);return i.size=t,i._head=r,i.__ownerID=e,i.__hash=n,i.__altered=!1,i}function Er(){return bn||(bn=Or(0))}function qr(t,r){if(t===r)return!0;if(!_(r)||void 0!==t.size&&void 0!==r.size&&t.size!==r.size||void 0!==t.__hash&&void 0!==r.__hash&&t.__hash!==r.__hash||l(t)!==l(r)||v(t)!==v(r)||d(t)!==d(r))return!1;if(0===t.size&&0===r.size)return!0;var e=!y(t);if(d(t)){var n=t.entries();return r.every(function(t,r){var i=n.next().value;return i&&k(i[1],t)&&(e||k(i[0],r))})&&n.next().done}var i=!1;if(void 0===t.size)if(void 0===r.size)"function"==typeof t.cacheResult&&t.cacheResult();else{i=!0;var o=t;t=r,r=o}var u=!0,s=r.__iterate(function(r,n){if(e?!t.has(r):i?!k(r,t.get(n,ae)):!k(t.get(n,ae),r))return u=!1,!1});return u&&t.size===s}function Mr(t,r){var e=function(e){t.prototype[e]=r[e]};return Object.keys(r).forEach(e), -Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(r).forEach(e),t}function Dr(t){return lt(t)?Me(t).map(Dr).toJSON():t}function Ar(t){return!(!t||!t[En])}function xr(t,r){return t.__ownerID?(t.size=r.size,t._map=r,t):r===t._map?t:0===r.size?t.__empty():t.__make(r)}function jr(t,r){var e=Object.create(qn);return e.size=t?t.size:0,e._map=t,e.__ownerID=r,e}function kr(){return Mn||(Mn=jr(Zt()))}function Rr(t,r,e){for(var n=pt(r),i=0;i!==n.length;)if((t=dt(t,n[i++],ae))===ae)return e;return t}function Ur(t,r){return Rr(this,t,r)}function Kr(t,r){return Rr(t,r,ae)!==ae}function Tr(t){return Kr(this,t)}function Cr(){ht(this.size);var t={};return this.__iterate(function(r,e){t[e]=r}),t}function Lr(t,r,e,n,i,o){return ht(t.size),t.__iterate(function(t,o,u){i?(i=!1,e=t):e=r.call(n,e,t,o,u)},o),e}function Br(t,r){return r}function Wr(t,r){return[r,t]}function Nr(t){return function(){return!t.apply(this,arguments)}}function Pr(t){return function(){return-t.apply(this,arguments)}}function Jr(){return ct(arguments)}function Hr(t,r){return tr?-1:0}function Vr(t){if(t.size===1/0)return 0;var r=d(t),e=l(t),n=r?1:0;return Yr(t.__iterate(e?r?function(t,r){n=31*n+Qr(U(t),U(r))|0}:function(t,r){n=n+Qr(U(t),U(r))|0}:r?function(t){n=31*n+U(t)|0}:function(t){n=n+U(t)|0}),n)}function Yr(t,r){return r=Le(r,3432918353),r=Le(r<<15|r>>>-15,461845907),r=Le(r<<13|r>>>-13,5),r=(r+3864292196|0)^t,r=Le(r^r>>>16,2246822507),r=Le(r^r>>>13,3266489909),r=R(r^r>>>16)}function Qr(t,r){return t^r+2654435769+(t<<6)+(t>>2)|0}function Xr(t){return Ar(t)&&d(t)}function Fr(t,r){var e=Object.create(Un);return e.size=t?t.size:0,e._map=t,e.__ownerID=r,e}function Gr(){return Kn||(Kn=Fr(Sr()))}function Zr(t,r,e){var n=Object.create(Object.getPrototypeOf(t));return n._values=r,n.__ownerID=e,n}function $r(t){return t._name||t.constructor.name||"Record"}function te(t){return D(t._keys.map(function(r){return[r,t.get(r)]}))}function re(t,r){try{Object.defineProperty(t,r,{get:function(){return this.get(r)},set:function(t){ -ft(this.__ownerID,"Cannot set on an immutable record."),this.set(r,t)}})}catch(t){}}function ee(t,r){return ne([],r||ie,t,"",r&&r.length>2?[]:void 0,{"":t})}function ne(t,r,e,n,i,o){var u=Array.isArray(e)?Ae:_t(e)?De:null;if(u){if(~t.indexOf(e))throw new TypeError("Cannot convert circular structure to Immutable");t.push(e),i&&""!==n&&i.push(n);var s=r.call(o,n,u(e).map(function(n,o){return ne(t,r,n,o,i,e)}),i&&i.slice());return t.pop(),i&&i.pop(),s}return e}function ie(t,r){return l(r)?r.toMap():r.toList()}var oe=5,ue=1<=n.length){var r=e.next();if(r.done)return r;n[i]=r.value}return w(t,i,n[i++])})},r}(Ae),Le="function"==typeof Math.imul&&Math.imul(4294967295,2)===-2?Math.imul:function(t,r){t|=0,r|=0 -;var e=65535&t,n=65535&r;return e*n+((t>>>16)*n+e*(r>>>16)<<16>>>0)|0},Be=Object.isExtensible,We=function(){try{return Object.defineProperty({},"@",{}),!0}catch(t){return!1}}(),Ne="function"==typeof WeakMap;Ne&&(Ke=new WeakMap);var Pe=0,Je="__immutablehash__";"function"==typeof Symbol&&(Je=Symbol(Je));var He=16,Ve=255,Ye=0,Qe={},Xe=function(t){function r(t,r){this._iter=t,this._useKeys=r,this.size=t.size}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.prototype.get=function(t,r){return this._iter.get(t,r)},r.prototype.has=function(t){return this._iter.has(t)},r.prototype.valueSeq=function(){return this._iter.valueSeq()},r.prototype.reverse=function(){var t=this,r=N(this,!0);return this._useKeys||(r.valueSeq=function(){return t._iter.toSeq().reverse()}),r},r.prototype.map=function(t,r){var e=this,n=W(this,t,r);return this._useKeys||(n.valueSeq=function(){return e._iter.toSeq().map(t,r)}),n},r.prototype.__iterate=function(t,r){var e=this;return this._iter.__iterate(function(r,n){return t(r,n,e)},r)},r.prototype.__iterator=function(t,r){return this._iter.__iterator(t,r)},r}(De);Xe.prototype[le]=!0;var Fe=function(t){function r(t){this._iter=t,this.size=t.size}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.prototype.includes=function(t){return this._iter.includes(t)},r.prototype.__iterate=function(t,r){var e=this,n=0;return r&&i(this),this._iter.__iterate(function(i){return t(i,r?e.size-++n:n++,e)},r)},r.prototype.__iterator=function(t,r){var e=this,n=this._iter.__iterator(ze,r),o=0;return r&&i(this),new Ee(function(){var i=n.next();return i.done?i:w(t,r?e.size-++o:o++,i.value,i)})},r}(Ae),Ge=function(t){function r(t){this._iter=t,this.size=t.size}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.prototype.has=function(t){return this._iter.includes(t)},r.prototype.__iterate=function(t,r){var e=this;return this._iter.__iterate(function(r){return t(r,r,e)},r)}, -r.prototype.__iterator=function(t,r){var e=this._iter.__iterator(ze,r);return new Ee(function(){var r=e.next();return r.done?r:w(t,r.value,r.value,r)})},r}(xe),Ze=function(t){function r(t){this._iter=t,this.size=t.size}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.prototype.entrySeq=function(){return this._iter.toSeq()},r.prototype.__iterate=function(t,r){var e=this;return this._iter.__iterate(function(r){if(r){it(r);var n=_(r);return t(n?r.get(1):r[1],n?r.get(0):r[0],e)}},r)},r.prototype.__iterator=function(t,r){var e=this._iter.__iterator(ze,r);return new Ee(function(){for(;;){var r=e.next();if(r.done)return r;var n=r.value;if(n){it(n);var i=_(n);return w(t,i?n.get(0):n[0],i?n.get(1):n[1],r)}}})},r}(De);Fe.prototype.cacheResult=Xe.prototype.cacheResult=Ge.prototype.cacheResult=Ze.prototype.cacheResult=st;var $e=function(t){function r(r){return null===r||void 0===r?Zt():Qt(r)&&!d(r)?r:Zt().withMutations(function(e){var n=t(r);ht(n.size),n.forEach(function(t,r){return e.set(r,t)})})}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.of=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return Zt().withMutations(function(r){for(var e=0;e=t.length)throw Error("Missing value for key: "+t[e]);r.set(t[e],t[e+1])}})},r.prototype.toString=function(){return this.__toString("Map {","}")},r.prototype.get=function(t,r){return this._root?this._root.get(0,void 0,t,r):r},r.prototype.set=function(t,r){return $t(this,t,r)},r.prototype.remove=function(t){return $t(this,t,ae)},r.prototype.deleteAll=function(t){var r=ye(t);return 0===r.size?this:this.withMutations(function(t){r.forEach(function(r){return t.remove(r)})})},r.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):Zt()},r.prototype.sort=function(t){return mn($(this,t))},r.prototype.sortBy=function(t,r){return mn($(this,r,t))}, -r.prototype.map=function(t,r){return this.withMutations(function(e){e.forEach(function(n,i){e.set(i,t.call(r,n,i,e))})})},r.prototype.__iterator=function(t,r){return new cn(this,t,r)},r.prototype.__iterate=function(t,r){var e=this,n=0;return this._root&&this._root.iterate(function(r){return n++,t(r[1],r[0],e)},r),n},r.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Gt(this.size,this._root,t,this.__hash):0===this.size?Zt():(this.__ownerID=t,this.__altered=!1,this)},r}(de);$e.isMap=Qt;var tn="@@__IMMUTABLE_MAP__@@",rn=$e.prototype;rn[tn]=!0,rn.delete=rn.remove,rn.removeAll=rn.deleteAll,rn.setIn=bt,rn.removeIn=rn.deleteIn=Et,rn.update=Mt,rn.updateIn=Dt,rn.merge=rn.concat=At,rn.mergeWith=xt,rn.mergeDeep=Bt,rn.mergeDeepWith=Wt,rn.mergeIn=Nt,rn.mergeDeepIn=Pt,rn.withMutations=Jt,rn.wasAltered=Yt,rn.asImmutable=Vt,rn["@@transducer/init"]=rn.asMutable=Ht,rn["@@transducer/step"]=function(t,r){return t.set(r[0],r[1])},rn["@@transducer/result"]=function(t){return t.asImmutable()};var en=function(t,r){this.ownerID=t,this.entries=r};en.prototype.get=function(t,r,e,n){for(var i=this.entries,o=0,u=i.length;o=fn)return nr(t,c,i,o);var _=t&&t===this.ownerID,l=_?c:ct(c);return p?a?f===h-1?l.pop():l[f]=l.pop():l[f]=[i,o]:l.push([i,o]),_?(this.entries=l,this):new en(t,l)}};var nn=function(t,r,e){this.ownerID=t,this.bitmap=r,this.nodes=e};nn.prototype.get=function(t,r,e,n){void 0===r&&(r=U(e));var i=1<<((0===t?r:r>>>t)&se),o=this.bitmap;return 0==(o&i)?n:this.nodes[ur(o&i-1)].get(t+oe,r,e,n)},nn.prototype.update=function(t,r,e,n,i,o,u){void 0===e&&(e=U(n));var s=(0===r?e:e>>>r)&se,a=1<=hn)return or(t,p,c,s,l);if(f&&!l&&2===p.length&&rr(p[1^h]))return p[1^h];if(f&&l&&1===p.length&&rr(l))return l;var v=t&&t===this.ownerID,y=f?l?c:c^a:c|a,d=f?l?sr(p,h,l,v):cr(p,h,v):ar(p,h,l,v);return v?(this.bitmap=y,this.nodes=d,this):new nn(t,y,d)};var on=function(t,r,e){this.ownerID=t,this.count=r,this.nodes=e};on.prototype.get=function(t,r,e,n){void 0===r&&(r=U(e));var i=(0===t?r:r>>>t)&se,o=this.nodes[i];return o?o.get(t+oe,r,e,n):n},on.prototype.update=function(t,r,e,n,i,o,u){void 0===e&&(e=U(n));var s=(0===r?e:e>>>r)&se,a=i===ae,c=this.nodes,f=c[s];if(a&&!f)return this;var h=tr(f,t,r+oe,e,n,i,o,u);if(h===f)return this;var p=this.count;if(f){if(!h&&--p0&&i=0&&t>>r&se;if(n>=this.array.length)return new yn([],t);var i,o=0===n;if(r>0){var u=this.array[n] -;if((i=u&&u.removeBefore(t,r-oe,e))===u&&o)return this}if(o&&!i)return this;var s=yr(this,t);if(!o)for(var a=0;a>>r&se;if(n>=this.array.length)return this;var i;if(r>0){var o=this.array[n];if((i=o&&o.removeAfter(t,r-oe,e))===o&&n===this.array.length-1)return this}var u=yr(this,t);return u.array.splice(n+1),i&&(u.array[n]=i),u};var dn,gn={},mn=function(t){function r(t){return null===t||void 0===t?Sr():wr(t)?t:Sr().withMutations(function(r){var e=de(t);ht(e.size),e.forEach(function(t,e){return r.set(e,t)})})}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.of=function(){return this(arguments)},r.prototype.toString=function(){return this.__toString("OrderedMap {","}")},r.prototype.get=function(t,r){var e=this._map.get(t);return void 0!==e?this._list.get(e)[1]:r},r.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._map.clear(),this._list.clear(),this):Sr()},r.prototype.set=function(t,r){return Ir(this,t,r)},r.prototype.remove=function(t){return Ir(this,t,ae)},r.prototype.wasAltered=function(){return this._map.wasAltered()||this._list.wasAltered()},r.prototype.__iterate=function(t,r){var e=this;return this._list.__iterate(function(r){return r&&t(r[1],r[0],e)},r)},r.prototype.__iterator=function(t,r){return this._list.fromEntrySeq().__iterator(t,r)},r.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var r=this._map.__ensureOwner(t),e=this._list.__ensureOwner(t);return t?zr(r,e,t,this.__hash):0===this.size?Sr():(this.__ownerID=t,this._map=r,this._list=e,this)},r}($e);mn.isOrderedMap=wr,mn.prototype[le]=!0,mn.prototype.delete=mn.prototype.remove;var wn,zn=function(t){function r(t){return null===t||void 0===t?Er():br(t)?t:Er().pushAll(t)}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.of=function(){ -return this(arguments)},r.prototype.toString=function(){return this.__toString("Stack [","]")},r.prototype.get=function(t,r){var e=this._head;for(t=o(this,t);e&&t--;)e=e.next;return e?e.value:r},r.prototype.peek=function(){return this._head&&this._head.value},r.prototype.push=function(){var t=arguments;if(0===arguments.length)return this;for(var r=this.size+arguments.length,e=this._head,n=arguments.length-1;n>=0;n--)e={value:t[n],next:e};return this.__ownerID?(this.size=r,this._head=e,this.__hash=void 0,this.__altered=!0,this):Or(r,e)},r.prototype.pushAll=function(r){if(r=t(r),0===r.size)return this;if(0===this.size&&br(r))return r;ht(r.size);var e=this.size,n=this._head;return r.__iterate(function(t){e++,n={value:t,next:n}},!0),this.__ownerID?(this.size=e,this._head=n,this.__hash=void 0,this.__altered=!0,this):Or(e,n)},r.prototype.pop=function(){return this.slice(1)},r.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):Er()},r.prototype.slice=function(r,e){if(s(r,e,this.size))return this;var n=a(r,this.size);if(c(e,this.size)!==this.size)return t.prototype.slice.call(this,r,e);for(var i=this.size-n,o=this._head;n--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):Or(i,o)},r.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Or(this.size,this._head,t,this.__hash):0===this.size?Er():(this.__ownerID=t,this.__altered=!1,this)},r.prototype.__iterate=function(t,r){var e=this;if(r)return new ke(this.toArray()).__iterate(function(r,n){return t(r,n,e)},r);for(var n=0,i=this._head;i&&t(i.value,n++,e)!==!1;)i=i.next;return n},r.prototype.__iterator=function(t,r){if(r)return new ke(this.toArray()).__iterator(t,r);var e=0,n=this._head;return new Ee(function(){if(n){var r=n.value;return n=n.next,w(t,e++,r)}return z()})},r}(ge);zn.isStack=br;var Sn="@@__IMMUTABLE_STACK__@@",In=zn.prototype;In[Sn]=!0,In.shift=In.pop,In.unshift=In.push,In.unshiftAll=In.pushAll, -In.withMutations=Jt,In.wasAltered=Yt,In.asImmutable=Vt,In["@@transducer/init"]=In.asMutable=Ht,In["@@transducer/step"]=function(t,r){return t.unshift(r)},In["@@transducer/result"]=function(t){return t.asImmutable()};var bn,On=function(t){function r(r){return null===r||void 0===r?kr():Ar(r)&&!d(r)?r:kr().withMutations(function(e){var n=t(r);ht(n.size),n.forEach(function(t){return e.add(t)})})}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.of=function(){return this(arguments)},r.fromKeys=function(t){return this(de(t).keySeq())},r.intersect=function(t){return t=ye(t).toArray(),t.length?qn.intersect.apply(r(t.pop()),t):kr()},r.union=function(t){return t=ye(t).toArray(),t.length?qn.union.apply(r(t.pop()),t):kr()},r.prototype.toString=function(){return this.__toString("Set {","}")},r.prototype.has=function(t){return this._map.has(t)},r.prototype.add=function(t){return xr(this,this._map.set(t,t))},r.prototype.remove=function(t){return xr(this,this._map.remove(t))},r.prototype.clear=function(){return xr(this,this._map.clear())},r.prototype.map=function(t,r){var e=this;return xr(this,this._map.map(function(r){return t(r,r,e)},r))},r.prototype.union=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];return r=r.filter(function(t){return 0!==t.size}),0===r.length?this:0!==this.size||this.__ownerID||1!==r.length?this.withMutations(function(e){for(var n=0;n=0&&r=0&&ethis.size?r:this.find(function(r,e){return e===t},void 0,r)},has:function(t){return(t=o(this,t))>=0&&(void 0!==this.size?this.size===1/0||t>>0;if(""+e!==r||4294967295===e)return NaN;r=e}return r<0?i(t)+r:r}function u(){return!0}function s(t,r,e){return(0===t&&!h(t)||void 0!==e&&t<=-e)&&(void 0===r||void 0!==e&&r>=e)}function a(t,r){return f(t,r,0)}function c(t,r){return f(t,r,r)}function f(t,r,e){return void 0===t?e:h(t)?r===1/0?r:0|Math.max(0,r+t):void 0===r||r===t?t:0|Math.min(r,t)}function h(t){return t<0||0===t&&1/t==-(1/0)}function p(t){return _(t)||g(t)}function _(t){return!(!t||!t[he])}function l(t){return!(!t||!t[pe])}function v(t){return!(!t||!t[_e])}function y(t){return l(t)||v(t)}function d(t){return!(!t||!t[le])}function g(t){return!(!t||!t[ve])}function m(t){return!(!t||"function"!=typeof t.equals||"function"!=typeof t.hashCode)}function w(t,r,e,n){var i=0===t?r:1===t?e:[r,e];return n?n.value=i:n={value:i,done:!1},n}function z(){return{value:void 0,done:!0}}function S(t){return!!O(t)}function I(t){return t&&"function"==typeof t.next}function b(t){var r=O(t);return r&&r.call(t)}function O(t){var r=t&&(Ie&&t[Ie]||t[be]);if("function"==typeof r)return r}function E(t){return!(!Array.isArray(t)&&"string"!=typeof t)||t&&"object"==typeof t&&Number.isInteger(t.length)&&t.length>=0&&(0===t.length?1===Object.keys(t).length:t.hasOwnProperty(t.length-1))}function q(t){return!(!t||!t[je])}function M(){return Ue||(Ue=new ke([]))}function D(t){var r=Array.isArray(t)?new ke(t):S(t)?new Te(t):void 0;if(r)return r.fromEntrySeq();if("object"==typeof t)return new Re(t);throw new TypeError("Expected Array or collection object of [k, v] entries, or keyed object: "+t)}function A(t){var r=j(t);if(r)return r;throw new TypeError("Expected Array or collection object of values: "+t)} +function x(t){var r=j(t);if(r)return r;if("object"==typeof t)return new Re(t);throw new TypeError("Expected Array or collection object of values, or keyed object: "+t)}function j(t){return E(t)?new ke(t):S(t)?new Te(t):void 0}function k(t,r){if(t===r||t!==t&&r!==r)return!0;if(!t||!r)return!1;if("function"==typeof t.valueOf&&"function"==typeof r.valueOf){if(t=t.valueOf(),r=r.valueOf(),t===r||t!==t&&r!==r)return!0;if(!t||!r)return!1}return!!(m(t)&&m(r)&&t.equals(r))}function R(t){return t>>>1&1073741824|3221225471&t}function U(t){if(t===!1||null===t||void 0===t)return 0;if("function"==typeof t.valueOf&&((t=t.valueOf())===!1||null===t||void 0===t))return 0;if(t===!0)return 1;var r=typeof t;if("number"===r){if(t!==t||t===1/0)return 0;var e=0|t;for(e!==t&&(e^=4294967295*t);t>4294967295;)t/=4294967295,e^=t;return R(e)}if("string"===r)return t.length>Je?K(t):T(t);if("function"==typeof t.hashCode)return R(t.hashCode());if("object"===r||"function"===r)return L(t);if("function"==typeof t.toString)return T(""+t);throw Error("Value type "+r+" cannot be hashed.")}function K(t){var r=Ye[t];return void 0===r&&(r=T(t),Ve===He&&(Ve=0,Ye={}),Ve++,Ye[t]=r),r}function T(t){for(var r=0,e=0;e0)switch(t.nodeType){case 1:return t.uniqueID;case 9:return t.documentElement&&t.documentElement.uniqueID}}function B(t){var r=ut(t);return r._iter=t,r.size=t.size,r.flip=function(){return t},r.reverse=function(){var r=t.reverse.apply(this);return r.flip=function(){return t.reverse()},r},r.has=function(r){return t.includes(r)},r.includes=function(r){return t.has(r)},r.cacheResult=st,r.__iterateUncached=function(r,e){var n=this;return t.__iterate(function(t,e){return r(e,t,n)!==!1},e)},r.__iteratorUncached=function(r,e){if(r===Se){var n=t.__iterator(r,e);return new Ee(function(){var t=n.next();if(!t.done){var r=t.value[0];t.value[0]=t.value[1],t.value[1]=r}return t})}return t.__iterator(r===ze?we:ze,e)},r}function W(t,r,e){var n=ut(t);return n.size=t.size,n.has=function(r){return t.has(r)},n.get=function(n,i){var o=t.get(n,ae);return o===ae?i:r.call(e,o,n,t)},n.__iterateUncached=function(n,i){var o=this;return t.__iterate(function(t,i,u){return n(r.call(e,t,i,u),i,o)!==!1},i)},n.__iteratorUncached=function(n,i){var o=t.__iterator(Se,i);return new Ee(function(){var i=o.next();if(i.done)return i;var u=i.value,s=u[0];return w(n,s,r.call(e,u[1],s,t),i)})},n}function N(t,r){var e=this,n=ut(t);return n._iter=t,n.size=t.size,n.reverse=function(){return t},t.flip&&(n.flip=function(){var r=B(t);return r.reverse=function(){return t.flip()},r}),n.get=function(e,n){return t.get(r?e:-1-e,n)},n.has=function(e){return t.has(r?e:-1-e)},n.includes=function(r){return t.includes(r)},n.cacheResult=st,n.__iterate=function(e,n){var o=this,u=0;return n&&i(t),t.__iterate(function(t,i){return e(t,r?i:n?o.size-++u:u++,o)},!n)},n.__iterator=function(n,o){var u=0;o&&i(t);var s=t.__iterator(Se,!o);return new Ee(function(){var t=s.next();if(t.done)return t;var i=t.value;return w(n,r?i[0]:o?e.size-++u:u++,i[1],t)})},n}function P(t,r,e,n){var i=ut(t);return n&&(i.has=function(n){var i=t.get(n,ae);return i!==ae&&!!r.call(e,i,n,t)},i.get=function(n,i){var o=t.get(n,ae);return o!==ae&&r.call(e,o,n,t)?o:i}), +i.__iterateUncached=function(i,o){var u=this,s=0;return t.__iterate(function(t,o,a){if(r.call(e,t,o,a))return s++,i(t,n?o:s-1,u)},o),s},i.__iteratorUncached=function(i,o){var u=t.__iterator(Se,o),s=0;return new Ee(function(){for(;;){var o=u.next();if(o.done)return o;var a=o.value,c=a[0],f=a[1];if(r.call(e,f,c,t))return w(i,n?c:s++,f,o)}})},i}function J(t,r,e){var n=Ze().asMutable();return t.__iterate(function(i,o){n.update(r.call(e,i,o,t),0,function(t){return t+1})}),n.asImmutable()}function H(t,r,e){var n=l(t),i=(d(t)?gn():Ze()).asMutable();t.__iterate(function(o,u){i.update(r.call(e,o,u,t),function(t){return t=t||[],t.push(n?[u,o]:o),t})});var o=ot(t);return i.map(function(r){return nt(t,o(r))})}function V(t,r,e,n){var i=t.size;if(s(r,e,i))return t;var u=a(r,i),f=c(e,i);if(u!==u||f!==f)return V(t.toSeq().cacheResult(),r,e,n);var h,p=f-u;p===p&&(h=p<0?0:p);var _=ut(t);return _.size=0===h?h:t.size&&h||void 0,!n&&q(t)&&h>=0&&(_.get=function(r,e){return r=o(this,r),r>=0&&rh)return z();var t=i.next();return n||r===ze||t.done?t:r===we?w(r,s-1,void 0,t):w(r,s-1,t.value[1],t)})},_}function Y(t,r,e){var n=ut(t);return n.__iterateUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterate(n,i);var u=0;return t.__iterate(function(t,i,s){return r.call(e,t,i,s)&&++u&&n(t,i,o)}),u},n.__iteratorUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterator(n,i);var u=t.__iterator(Se,i),s=!0;return new Ee(function(){if(!s)return z();var t=u.next();if(t.done)return t;var i=t.value,a=i[0],c=i[1];return r.call(e,c,a,o)?n===Se?t:w(n,a,c,t):(s=!1,z())})},n} +function Q(t,r,e,n){var i=ut(t);return i.__iterateUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterate(i,o);var s=!0,a=0;return t.__iterate(function(t,o,c){if(!s||!(s=r.call(e,t,o,c)))return a++,i(t,n?o:a-1,u)}),a},i.__iteratorUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterator(i,o);var s=t.__iterator(Se,o),a=!0,c=0;return new Ee(function(){var t,o,f;do{if(t=s.next(),t.done)return n||i===ze?t:i===we?w(i,c++,void 0,t):w(i,c++,t.value[1],t);var h=t.value;o=h[0],f=h[1],a&&(a=r.call(e,f,o,u))}while(a);return i===Se?t:w(i,o,f,t)})},i}function X(t,r){var e=l(t),n=[t].concat(r).map(function(t){return _(t)?e&&(t=de(t)):t=e?D(t):A(Array.isArray(t)?t:[t]),t}).filter(function(t){return 0!==t.size});if(0===n.length)return t;if(1===n.length){var i=n[0];if(i===t||e&&l(i)||v(t)&&v(i))return i}var o=new ke(n);return e?o=o.toKeyedSeq():v(t)||(o=o.toSetSeq()),o=o.flatten(!0),o.size=n.reduce(function(t,r){if(void 0!==t){var e=r.size;if(void 0!==e)return t+e}},0),o}function F(t,r,e){var n=ut(t);return n.__iterateUncached=function(i,o){function u(t,c){t.__iterate(function(t,o){return(!r||c0}function et(t,r,e,n){var i=ut(t),o=new ke(e).map(function(t){return t.size});return i.size=n?o.max():o.min(),i.__iterate=function(t,r){for(var e,n=this,i=this.__iterator(ze,r),o=0;!(e=i.next()).done&&t(e.value,o++,n)!==!1;);return o},i.__iteratorUncached=function(t,i){var o=e.map(function(t){return t=ye(t),b(i?t.reverse():t)}),u=0,s=!1;return new Ee(function(){var e;return s||(e=o.map(function(t){return t.next()}),s=n?e.every(function(t){return t.done}):e.some(function(t){return t.done})),s?z():w(t,u++,r.apply(null,e.map(function(t){return t.value})))})},i}function nt(t,r){return t===r?t:q(t)?r:t.constructor(r)}function it(t){if(t!==Object(t))throw new TypeError("Expected [K, V] tuple: "+t)}function ot(t){return l(t)?de:v(t)?ge:me}function ut(t){return Object.create((l(t)?De:v(t)?Ae:xe).prototype)}function st(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size,this):Me.prototype.cacheResult.call(this)}function at(t,r){return void 0===t&&void 0===r?0:void 0===t?1:void 0===r?-1:t>r?1:t0;)r[e]=arguments[e+1];return jt(this,r,t)}function jt(t,r,e){for(var n=[],i=0;i0;)r[e]=arguments[e+1];return Lt(t,r)}function Rt(t,r){for(var e=[],n=arguments.length-2;n-- >0;)e[n]=arguments[n+2];return Lt(r,e,t)}function Ut(t){for(var r=[],e=arguments.length-1;e-- >0;)r[e]=arguments[e+1];return Tt(t,r)}function Kt(t,r){for(var e=[],n=arguments.length-2;n-- >0;)e[n]=arguments[n+2];return Tt(r,e,t)}function Tt(t,r,e){return Lt(t,r,Ct(e))}function Lt(t,r,e){if(!lt(t))throw new TypeError("Cannot merge into non-data-structure value: "+t);if(p(t))return t.mergeWith?t.mergeWith.apply(t,[e].concat(r)):t.concat.apply(t,r);for(var n=Array.isArray(t),i=t,o=n?ge:de,u=n?function(r){i===t&&(i=gt(i)),i.push(r)}:function(r,n){var o=qe.call(i,n),u=o&&e?e(i[n],r,n):r;o&&u===i[n]||(i===t&&(i=gt(i)),i[n]=u)},s=0;s0;)r[e]=arguments[e+1];return Tt(this,r,t)}function Nt(t){for(var r=[],e=arguments.length-1;e-- >0;)r[e]=arguments[e+1];return zt(this,t,Zt(),function(t){return Lt(t,r)})}function Pt(t){for(var r=[],e=arguments.length-1;e-- >0;)r[e]=arguments[e+1];return zt(this,t,Zt(),function(t){return Tt(t,r)})}function Jt(t){var r=this.asMutable();return t(r),r.wasAltered()?r.__ensureOwner(this.__ownerID):this}function Ht(){return this.__ownerID?this:this.__ensureOwner(new n)}function Vt(){return this.__ensureOwner()}function Yt(){return this.__altered}function Qt(t){return!(!t||!t[$e])}function Xt(t,r){return w(t,r[0],r[1])}function Ft(t,r){return{node:t,index:0,__prev:r}}function Gt(t,r,e,n){ +var i=Object.create(tn);return i.size=t,i._root=r,i.__ownerID=e,i.__hash=n,i.__altered=!1,i}function Zt(){return sn||(sn=Gt(0))}function $t(t,e,n){var i,o;if(t._root){var u=r(ce),s=r(fe);if(i=tr(t._root,t.__ownerID,0,void 0,e,n,u,s),!s.value)return t;o=t.size+(u.value?n===ae?-1:1:0)}else{if(n===ae)return t;o=1,i=new rn(t.__ownerID,[[e,n]])}return t.__ownerID?(t.size=o,t._root=i,t.__hash=void 0,t.__altered=!0,t):i?Gt(o,i):Zt()}function tr(t,r,n,i,o,u,s,a){return t?t.update(r,n,i,o,u,s,a):u===ae?t:(e(a),e(s),new un(r,i,[o,u]))}function rr(t){return t.constructor===un||t.constructor===on}function er(t,r,e,n,i){if(t.keyHash===n)return new on(r,n,[t.entry,i]);var o,u=(0===e?t.keyHash:t.keyHash>>>e)&se,s=(0===e?n:n>>>e)&se;return new en(r,1<>>=1)u[s]=1&e?r[o++]:void 0;return u[n]=i,new nn(t,o+1,u)}function ur(t){return t-=t>>1&1431655765,t=(858993459&t)+(t>>2&858993459),t=t+(t>>4)&252645135,t+=t>>8,127&(t+=t>>16)}function sr(t,r,e,n){var i=n?t:ct(t);return i[r]=e,i}function ar(t,r,e,n){var i=t.length+1;if(n&&r+1===i)return t[r]=e,t;for(var o=Array(i),u=0,s=0;so?0:o-e,c=u-e;return c>ue&&(c=ue),function(){if(i===c)return dn;var t=r?--c:i++;return n&&n[t]}}function i(t,n,i){var s,a=t&&t.array,c=i>o?0:o-i>>n,f=1+(u-i>>n);return f>ue&&(f=ue),function(){for(;;){if(s){var t=s() +;if(t!==dn)return t;s=null}if(c===f)return dn;var o=r?--f:c++;s=e(a&&a[o],n-oe,i+(o<=t.size||e<0)return t.withMutations(function(t){e<0?gr(t,e).set(0,n):gr(t,0,e+1).set(e,n)});e+=t._origin;var i=t._tail,u=t._root,s=r(fe);return e>=mr(t._capacity)?i=vr(i,t.__ownerID,0,e,n,s):u=vr(u,t.__ownerID,t._level,e,n,s),s.value?t.__ownerID?(t._root=u,t._tail=i,t.__hash=void 0,t.__altered=!0,t):pr(t._origin,t._capacity,t._level,u,i):t}function vr(t,r,n,i,o,u){var s=i>>>n&se,a=t&&s0){var f=t&&t.array[s],h=vr(f,r,n-oe,i,o,u);return h===f?t:(c=yr(t,r),c.array[s]=h,c)}return a&&t.array[s]===o?t:(e(u),c=yr(t,r),void 0===o&&s===c.array.length-1?c.array.pop():c.array[s]=o,c)}function yr(t,r){return r&&t&&r===t.ownerID?t:new vn(t?t.array.slice():[],r)}function dr(t,r){if(r>=mr(t._capacity))return t._tail;if(r<1<0;)e=e.array[r>>>n&se],n-=oe;return e}}function gr(t,r,e){void 0!==r&&(r|=0),void 0!==e&&(e|=0);var i=t.__ownerID||new n,o=t._origin,u=t._capacity,s=o+r,a=void 0===e?u:e<0?u+e:o+e;if(s===o&&a===u)return t;if(s>=a)return t.clear();for(var c=t._level,f=t._root,h=0;s+h<0;)f=new vn(f&&f.array.length?[void 0,f]:[],i),c+=oe,h+=1<=1<p?new vn([],i):l;if(l&&_>p&&soe;d-=oe){var g=p>>>d&se;y=y.array[g]=yr(y.array[g],i)}y.array[p>>>oe&se]=l}if(a=_)s-=_,a-=_,c=oe,f=null,v=v&&v.removeBefore(i,0,s);else if(s>o||_>>c&se;if(m!==_>>>c&se)break;m&&(h+=(1<o&&(f=f.removeBefore(i,c,s-h)),f&&_>>oe<=ue&&u.size>=2*o.size?(i=u.filter(function(t,r){return void 0!==t&&s!==r}),n=i.toKeyedSeq().map(function(t){return t[0]}).flip().toMap(),t.__ownerID&&(n.__ownerID=i.__ownerID=t.__ownerID)):(n=o.remove(r),i=s===u.size-1?u.pop():u.set(s,void 0))}else if(a){if(e===u.get(s)[1])return t;n=o,i=u.set(s,[r,e])}else n=o.set(r,u.size),i=u.set(u.size,[r,e]);return t.__ownerID?(t.size=n.size,t._map=n,t._list=i,t.__hash=void 0,t):zr(n,i)}function br(t){return!(!t||!t[zn])}function Or(t,r,e,n){var i=Object.create(Sn);return i.size=t,i._head=r,i.__ownerID=e,i.__hash=n,i.__altered=!1,i}function Er(){return In||(In=Or(0))}function qr(t,r){if(t===r)return!0;if(!_(r)||void 0!==t.size&&void 0!==r.size&&t.size!==r.size||void 0!==t.__hash&&void 0!==r.__hash&&t.__hash!==r.__hash||l(t)!==l(r)||v(t)!==v(r)||d(t)!==d(r))return!1;if(0===t.size&&0===r.size)return!0;var e=!y(t);if(d(t)){var n=t.entries();return r.every(function(t,r){var i=n.next().value;return i&&k(i[1],t)&&(e||k(i[0],r))})&&n.next().done}var i=!1;if(void 0===t.size)if(void 0===r.size)"function"==typeof t.cacheResult&&t.cacheResult();else{i=!0;var o=t;t=r,r=o}var u=!0,s=r.__iterate(function(r,n){if(e?!t.has(r):i?!k(r,t.get(n,ae)):!k(t.get(n,ae),r))return u=!1,!1});return u&&t.size===s}function Mr(t,r){var e=function(e){t.prototype[e]=r[e]};return Object.keys(r).forEach(e),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(r).forEach(e),t}function Dr(t){return lt(t)?Me(t).map(Dr).toJSON():t} +function Ar(t){return!(!t||!t[On])}function xr(t,r){return t.__ownerID?(t.size=r.size,t._map=r,t):r===t._map?t:0===r.size?t.__empty():t.__make(r)}function jr(t,r){var e=Object.create(En);return e.size=t?t.size:0,e._map=t,e.__ownerID=r,e}function kr(){return qn||(qn=jr(Zt()))}function Rr(t,r,e){for(var n=pt(r),i=0;i!==n.length;)if((t=dt(t,n[i++],ae))===ae)return e;return t}function Ur(t,r){return Rr(this,t,r)}function Kr(t,r){return Rr(t,r,ae)!==ae}function Tr(t){return Kr(this,t)}function Lr(){ht(this.size);var t={};return this.__iterate(function(r,e){t[e]=r}),t}function Cr(t,r,e,n,i,o){return ht(t.size),t.__iterate(function(t,o,u){i?(i=!1,e=t):e=r.call(n,e,t,o,u)},o),e}function Br(t,r){return r}function Wr(t,r){return[r,t]}function Nr(t){return function(){return!t.apply(this,arguments)}}function Pr(t){return function(){return-t.apply(this,arguments)}}function Jr(){return ct(arguments)}function Hr(t,r){return tr?-1:0}function Vr(t){if(t.size===1/0)return 0;var r=d(t),e=l(t),n=r?1:0;return Yr(t.__iterate(e?r?function(t,r){n=31*n+Qr(U(t),U(r))|0}:function(t,r){n=n+Qr(U(t),U(r))|0}:r?function(t){n=31*n+U(t)|0}:function(t){n=n+U(t)|0}),n)}function Yr(t,r){return r=Le(r,3432918353),r=Le(r<<15|r>>>-15,461845907),r=Le(r<<13|r>>>-13,5),r=(r+3864292196|0)^t,r=Le(r^r>>>16,2246822507),r=Le(r^r>>>13,3266489909),r=R(r^r>>>16)}function Qr(t,r){return t^r+2654435769+(t<<6)+(t>>2)|0}function Xr(t){return Ar(t)&&d(t)}function Fr(t,r){var e=Object.create(Rn);return e.size=t?t.size:0,e._map=t,e.__ownerID=r,e}function Gr(){return Un||(Un=Fr(Sr()))}function Zr(t,r,e){var n=Object.create(Object.getPrototypeOf(t));return n._values=r,n.__ownerID=e,n}function $r(t){return t._name||t.constructor.name||"Record"}function te(t){return D(t._keys.map(function(r){return[r,t.get(r)]}))}function re(t,r){try{Object.defineProperty(t,r,{get:function(){return this.get(r)},set:function(t){ft(this.__ownerID,"Cannot set on an immutable record."),this.set(r,t)}})}catch(t){}}function ee(t,r){return ne([],r||ie,t,"",r&&r.length>2?[]:void 0,{"":t})} +function ne(t,r,e,n,i,o){var u=Array.isArray(e)?Ae:_t(e)?De:null;if(u){if(~t.indexOf(e))throw new TypeError("Cannot convert circular structure to Immutable");t.push(e),i&&""!==n&&i.push(n);var s=r.call(o,n,u(e).map(function(n,o){return ne(t,r,n,o,i,e)}),i&&i.slice());return t.pop(),i&&i.pop(),s}return e}function ie(t,r){return l(r)?r.toMap():r.toList()}var oe=5,ue=1<>>16)*n+e*(r>>>16)<<16>>>0)|0},Ce=Object.isExtensible,Be=function(){try{return Object.defineProperty({},"@",{}),!0}catch(t){return!1}}(),We="function"==typeof WeakMap;We&&(Ke=new WeakMap);var Ne=0,Pe="__immutablehash__";"function"==typeof Symbol&&(Pe=Symbol(Pe));var Je=16,He=255,Ve=0,Ye={},Qe=function(t){function r(t,r){this._iter=t,this._useKeys=r,this.size=t.size}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.prototype.get=function(t,r){return this._iter.get(t,r)},r.prototype.has=function(t){return this._iter.has(t)},r.prototype.valueSeq=function(){return this._iter.valueSeq()},r.prototype.reverse=function(){var t=this,r=N(this,!0);return this._useKeys||(r.valueSeq=function(){return t._iter.toSeq().reverse()}),r},r.prototype.map=function(t,r){ +var e=this,n=W(this,t,r);return this._useKeys||(n.valueSeq=function(){return e._iter.toSeq().map(t,r)}),n},r.prototype.__iterate=function(t,r){var e=this;return this._iter.__iterate(function(r,n){return t(r,n,e)},r)},r.prototype.__iterator=function(t,r){return this._iter.__iterator(t,r)},r}(De);Qe.prototype[le]=!0;var Xe=function(t){function r(t){this._iter=t,this.size=t.size}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.prototype.includes=function(t){return this._iter.includes(t)},r.prototype.__iterate=function(t,r){var e=this,n=0;return r&&i(this),this._iter.__iterate(function(i){return t(i,r?e.size-++n:n++,e)},r)},r.prototype.__iterator=function(t,r){var e=this,n=this._iter.__iterator(ze,r),o=0;return r&&i(this),new Ee(function(){var i=n.next();return i.done?i:w(t,r?e.size-++o:o++,i.value,i)})},r}(Ae),Fe=function(t){function r(t){this._iter=t,this.size=t.size}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.prototype.has=function(t){return this._iter.includes(t)},r.prototype.__iterate=function(t,r){var e=this;return this._iter.__iterate(function(r){return t(r,r,e)},r)},r.prototype.__iterator=function(t,r){var e=this._iter.__iterator(ze,r);return new Ee(function(){var r=e.next();return r.done?r:w(t,r.value,r.value,r)})},r}(xe),Ge=function(t){function r(t){this._iter=t,this.size=t.size}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.prototype.entrySeq=function(){return this._iter.toSeq()},r.prototype.__iterate=function(t,r){var e=this;return this._iter.__iterate(function(r){if(r){it(r);var n=_(r);return t(n?r.get(1):r[1],n?r.get(0):r[0],e)}},r)},r.prototype.__iterator=function(t,r){var e=this._iter.__iterator(ze,r);return new Ee(function(){for(;;){var r=e.next();if(r.done)return r;var n=r.value;if(n){it(n);var i=_(n);return w(t,i?n.get(0):n[0],i?n.get(1):n[1],r)}}})},r}(De) +;Xe.prototype.cacheResult=Qe.prototype.cacheResult=Fe.prototype.cacheResult=Ge.prototype.cacheResult=st;var Ze=function(t){function r(r){return null===r||void 0===r?Zt():Qt(r)&&!d(r)?r:Zt().withMutations(function(e){var n=t(r);ht(n.size),n.forEach(function(t,r){return e.set(r,t)})})}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.of=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return Zt().withMutations(function(r){for(var e=0;e=t.length)throw Error("Missing value for key: "+t[e]);r.set(t[e],t[e+1])}})},r.prototype.toString=function(){return this.__toString("Map {","}")},r.prototype.get=function(t,r){return this._root?this._root.get(0,void 0,t,r):r},r.prototype.set=function(t,r){return $t(this,t,r)},r.prototype.remove=function(t){return $t(this,t,ae)},r.prototype.deleteAll=function(t){var r=ye(t);return 0===r.size?this:this.withMutations(function(t){r.forEach(function(r){return t.remove(r)})})},r.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):Zt()},r.prototype.sort=function(t){return gn($(this,t))},r.prototype.sortBy=function(t,r){return gn($(this,r,t))},r.prototype.map=function(t,r){return this.withMutations(function(e){e.forEach(function(n,i){e.set(i,t.call(r,n,i,e))})})},r.prototype.__iterator=function(t,r){return new an(this,t,r)},r.prototype.__iterate=function(t,r){var e=this,n=0;return this._root&&this._root.iterate(function(r){return n++,t(r[1],r[0],e)},r),n},r.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Gt(this.size,this._root,t,this.__hash):0===this.size?Zt():(this.__ownerID=t,this.__altered=!1,this)},r}(de);Ze.isMap=Qt;var $e="@@__IMMUTABLE_MAP__@@",tn=Ze.prototype;tn[$e]=!0,tn.delete=tn.remove,tn.removeAll=tn.deleteAll,tn.setIn=bt,tn.removeIn=tn.deleteIn=Et,tn.update=Mt,tn.updateIn=Dt,tn.merge=tn.concat=At,tn.mergeWith=xt,tn.mergeDeep=Bt,tn.mergeDeepWith=Wt,tn.mergeIn=Nt,tn.mergeDeepIn=Pt, +tn.withMutations=Jt,tn.wasAltered=Yt,tn.asImmutable=Vt,tn["@@transducer/init"]=tn.asMutable=Ht,tn["@@transducer/step"]=function(t,r){return t.set(r[0],r[1])},tn["@@transducer/result"]=function(t){return t.asImmutable()};var rn=function(t,r){this.ownerID=t,this.entries=r};rn.prototype.get=function(t,r,e,n){for(var i=this.entries,o=0,u=i.length;o=cn)return nr(t,c,i,o);var _=t&&t===this.ownerID,l=_?c:ct(c);return p?a?f===h-1?l.pop():l[f]=l.pop():l[f]=[i,o]:l.push([i,o]),_?(this.entries=l,this):new rn(t,l)}};var en=function(t,r,e){this.ownerID=t,this.bitmap=r,this.nodes=e};en.prototype.get=function(t,r,e,n){void 0===r&&(r=U(e));var i=1<<((0===t?r:r>>>t)&se),o=this.bitmap;return 0==(o&i)?n:this.nodes[ur(o&i-1)].get(t+oe,r,e,n)},en.prototype.update=function(t,r,e,n,i,o,u){void 0===e&&(e=U(n));var s=(0===r?e:e>>>r)&se,a=1<=fn)return or(t,p,c,s,l);if(f&&!l&&2===p.length&&rr(p[1^h]))return p[1^h];if(f&&l&&1===p.length&&rr(l))return l;var v=t&&t===this.ownerID,y=f?l?c:c^a:c|a,d=f?l?sr(p,h,l,v):cr(p,h,v):ar(p,h,l,v);return v?(this.bitmap=y,this.nodes=d,this):new en(t,y,d)};var nn=function(t,r,e){this.ownerID=t,this.count=r,this.nodes=e};nn.prototype.get=function(t,r,e,n){void 0===r&&(r=U(e));var i=(0===t?r:r>>>t)&se,o=this.nodes[i];return o?o.get(t+oe,r,e,n):n},nn.prototype.update=function(t,r,e,n,i,o,u){void 0===e&&(e=U(n));var s=(0===r?e:e>>>r)&se,a=i===ae,c=this.nodes,f=c[s];if(a&&!f)return this;var h=tr(f,t,r+oe,e,n,i,o,u);if(h===f)return this;var p=this.count;if(f){if(!h&&--p0&&i=0&&t>>r&se;if(n>=this.array.length)return new vn([],t);var i,o=0===n;if(r>0){var u=this.array[n];if((i=u&&u.removeBefore(t,r-oe,e))===u&&o)return this}if(o&&!i)return this;var s=yr(this,t);if(!o)for(var a=0;a>>r&se;if(n>=this.array.length)return this;var i;if(r>0){var o=this.array[n];if((i=o&&o.removeAfter(t,r-oe,e))===o&&n===this.array.length-1)return this}var u=yr(this,t);return u.array.splice(n+1),i&&(u.array[n]=i),u};var yn,dn={},gn=function(t){function r(t){return null===t||void 0===t?Sr():wr(t)?t:Sr().withMutations(function(r){var e=de(t);ht(e.size),e.forEach(function(t,e){return r.set(e,t)})})}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.of=function(){return this(arguments)}, +r.prototype.toString=function(){return this.__toString("OrderedMap {","}")},r.prototype.get=function(t,r){var e=this._map.get(t);return void 0!==e?this._list.get(e)[1]:r},r.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._map.clear(),this._list.clear(),this):Sr()},r.prototype.set=function(t,r){return Ir(this,t,r)},r.prototype.remove=function(t){return Ir(this,t,ae)},r.prototype.wasAltered=function(){return this._map.wasAltered()||this._list.wasAltered()},r.prototype.__iterate=function(t,r){var e=this;return this._list.__iterate(function(r){return r&&t(r[1],r[0],e)},r)},r.prototype.__iterator=function(t,r){return this._list.fromEntrySeq().__iterator(t,r)},r.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var r=this._map.__ensureOwner(t),e=this._list.__ensureOwner(t);return t?zr(r,e,t,this.__hash):0===this.size?Sr():(this.__ownerID=t,this._map=r,this._list=e,this)},r}(Ze);gn.isOrderedMap=wr,gn.prototype[le]=!0,gn.prototype.delete=gn.prototype.remove;var mn,wn=function(t){function r(t){return null===t||void 0===t?Er():br(t)?t:Er().pushAll(t)}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.of=function(){return this(arguments)},r.prototype.toString=function(){return this.__toString("Stack [","]")},r.prototype.get=function(t,r){var e=this._head;for(t=o(this,t);e&&t--;)e=e.next;return e?e.value:r},r.prototype.peek=function(){return this._head&&this._head.value},r.prototype.push=function(){var t=arguments;if(0===arguments.length)return this;for(var r=this.size+arguments.length,e=this._head,n=arguments.length-1;n>=0;n--)e={value:t[n],next:e};return this.__ownerID?(this.size=r,this._head=e,this.__hash=void 0,this.__altered=!0,this):Or(r,e)},r.prototype.pushAll=function(r){if(r=t(r),0===r.size)return this;if(0===this.size&&br(r))return r;ht(r.size);var e=this.size,n=this._head;return r.__iterate(function(t){e++,n={value:t,next:n}},!0),this.__ownerID?(this.size=e,this._head=n,this.__hash=void 0,this.__altered=!0, +this):Or(e,n)},r.prototype.pop=function(){return this.slice(1)},r.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):Er()},r.prototype.slice=function(r,e){if(s(r,e,this.size))return this;var n=a(r,this.size);if(c(e,this.size)!==this.size)return t.prototype.slice.call(this,r,e);for(var i=this.size-n,o=this._head;n--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):Or(i,o)},r.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Or(this.size,this._head,t,this.__hash):0===this.size?Er():(this.__ownerID=t,this.__altered=!1,this)},r.prototype.__iterate=function(t,r){var e=this;if(r)return new ke(this.toArray()).__iterate(function(r,n){return t(r,n,e)},r);for(var n=0,i=this._head;i&&t(i.value,n++,e)!==!1;)i=i.next;return n},r.prototype.__iterator=function(t,r){if(r)return new ke(this.toArray()).__iterator(t,r);var e=0,n=this._head;return new Ee(function(){if(n){var r=n.value;return n=n.next,w(t,e++,r)}return z()})},r}(ge);wn.isStack=br;var zn="@@__IMMUTABLE_STACK__@@",Sn=wn.prototype;Sn[zn]=!0,Sn.shift=Sn.pop,Sn.unshift=Sn.push,Sn.unshiftAll=Sn.pushAll,Sn.withMutations=Jt,Sn.wasAltered=Yt,Sn.asImmutable=Vt,Sn["@@transducer/init"]=Sn.asMutable=Ht,Sn["@@transducer/step"]=function(t,r){return t.unshift(r)},Sn["@@transducer/result"]=function(t){return t.asImmutable()};var In,bn=function(t){function r(r){return null===r||void 0===r?kr():Ar(r)&&!d(r)?r:kr().withMutations(function(e){var n=t(r);ht(n.size),n.forEach(function(t){return e.add(t)})})}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.of=function(){return this(arguments)},r.fromKeys=function(t){return this(de(t).keySeq())},r.intersect=function(t){return t=ye(t).toArray(),t.length?En.intersect.apply(r(t.pop()),t):kr()},r.union=function(t){return t=ye(t).toArray(),t.length?En.union.apply(r(t.pop()),t):kr()},r.prototype.toString=function(){ +return this.__toString("Set {","}")},r.prototype.has=function(t){return this._map.has(t)},r.prototype.add=function(t){return xr(this,this._map.set(t,t))},r.prototype.remove=function(t){return xr(this,this._map.remove(t))},r.prototype.clear=function(){return xr(this,this._map.clear())},r.prototype.map=function(t,r){var e=this;return xr(this,this._map.map(function(r){return t(r,r,e)},r))},r.prototype.union=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];return r=r.filter(function(t){return 0!==t.size}),0===r.length?this:0!==this.size||this.__ownerID||1!==r.length?this.withMutations(function(e){for(var n=0;n=0&&r=0&&ethis.size?r:this.find(function(r,e){return e===t},void 0,r)},has:function(t){ +return(t=o(this,t))>=0&&(void 0!==this.size?this.size===1/0||t Date: Tue, 18 Sep 2018 18:23:26 +0000 Subject: [PATCH 113/242] Deploy 7be98d74a9ba57c2d7674001edc3711b87b4494c to NPM branch --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c6f35ca158..edaa12dbd0 100644 --- a/README.md +++ b/README.md @@ -618,7 +618,7 @@ Contribution Use [Github issues](https://github.com/facebook/immutable-js/issues) for requests. -We actively welcome pull requests, learn how to [contribute](https://github.com/facebook/immutable-js/blob/master/.github/CONTRIBUTING.md). +We actively welcome pull requests, learn how to [contribute](./.github/CONTRIBUTING.md). Changelog From 11a28fa92c0b7cf805a7473764c1d5dd9e5022bd Mon Sep 17 00:00:00 2001 From: Travis CI Date: Tue, 18 Sep 2018 18:23:54 +0000 Subject: [PATCH 114/242] Deploy 11588ac18dbecf0563a9afe1132b486686c35235 to NPM branch --- README.md | 2 +- dist/immutable.js.flow | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index edaa12dbd0..c6f35ca158 100644 --- a/README.md +++ b/README.md @@ -618,7 +618,7 @@ Contribution Use [Github issues](https://github.com/facebook/immutable-js/issues) for requests. -We actively welcome pull requests, learn how to [contribute](./.github/CONTRIBUTING.md). +We actively welcome pull requests, learn how to [contribute](https://github.com/facebook/immutable-js/blob/master/.github/CONTRIBUTING.md). Changelog diff --git a/dist/immutable.js.flow b/dist/immutable.js.flow index ee21e0d1f4..c701935822 100644 --- a/dist/immutable.js.flow +++ b/dist/immutable.js.flow @@ -25,7 +25,7 @@ * * takesASeq(someSeq) * - * @flow + * @flow strict */ // Helper type that represents plain objects allowed as arguments to From 4f791d6def90e8ba9316763d261ee655e2fdf99c Mon Sep 17 00:00:00 2001 From: Travis CI Date: Tue, 18 Sep 2018 18:25:43 +0000 Subject: [PATCH 115/242] Deploy 37ae5beef11664371ecb231b422a25ffa11126eb to NPM branch --- dist/immutable-nonambient.d.ts | 15 ++++++++++----- dist/immutable.d.ts | 15 ++++++++++----- dist/immutable.es.js | 16 ++++++++-------- dist/immutable.js | 16 ++++++++-------- dist/immutable.js.flow | 4 ++-- dist/immutable.min.js | 6 +++--- 6 files changed, 41 insertions(+), 31 deletions(-) diff --git a/dist/immutable-nonambient.d.ts b/dist/immutable-nonambient.d.ts index 22e24b4126..1eb58bfcce 100644 --- a/dist/immutable-nonambient.d.ts +++ b/dist/immutable-nonambient.d.ts @@ -3810,15 +3810,20 @@ contains(value: V): boolean; /** - * The first value in the Collection. + * In case the `Collection` is not empty returns the first element of the + * `Collection`. + * In case the `Collection` is empty returns the optional default + * value if provided, if no default value is provided returns undefined. */ - first(): V | undefined; + first(notSetValue?: NSV): V | NSV; /** - * The last value in the Collection. + * In case the `Collection` is not empty returns the last element of the + * `Collection`. + * In case the `Collection` is empty returns the optional default + * value if provided, if no default value is provided returns undefined. */ - last(): V | undefined; - + last(notSetValue?: NSV): V | NSV; // Reading deep values diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index 47e00c7e7a..b32785ccf7 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -3810,15 +3810,20 @@ declare module Immutable { contains(value: V): boolean; /** - * The first value in the Collection. + * In case the `Collection` is not empty returns the first element of the + * `Collection`. + * In case the `Collection` is empty returns the optional default + * value if provided, if no default value is provided returns undefined. */ - first(): V | undefined; + first(notSetValue?: NSV): V | NSV; /** - * The last value in the Collection. + * In case the `Collection` is not empty returns the last element of the + * `Collection`. + * In case the `Collection` is empty returns the optional default + * value if provided, if no default value is provided returns undefined. */ - last(): V | undefined; - + last(notSetValue?: NSV): V | NSV; // Reading deep values diff --git a/dist/immutable.es.js b/dist/immutable.es.js index da9276fd36..7a010ad0c5 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -4852,8 +4852,8 @@ mixin(Collection, { .findKey(predicate, context); }, - first: function first() { - return this.find(returnTrue); + first: function first(notSetValue) { + return this.find(returnTrue, null, notSetValue); }, flatMap: function flatMap(mapper, context) { @@ -4904,10 +4904,10 @@ mixin(Collection, { .toIndexedSeq(); }, - last: function last() { + last: function last(notSetValue) { return this.toSeq() .reverse() - .first(); + .first(notSetValue); }, lastKeyOf: function lastKeyOf(searchValue) { @@ -5111,8 +5111,8 @@ mixin(IndexedCollection, { return entry ? entry[0] : -1; }, - first: function first() { - return this.get(0); + first: function first(notSetValue) { + return this.get(0, notSetValue); }, flatten: function flatten(depth) { @@ -5155,8 +5155,8 @@ mixin(IndexedCollection, { return Range(0, this.size); }, - last: function last() { - return this.get(-1); + last: function last(notSetValue) { + return this.get(-1, notSetValue); }, skipWhile: function skipWhile(predicate, context) { diff --git a/dist/immutable.js b/dist/immutable.js index 35652d94e2..bdd19ad917 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -4858,8 +4858,8 @@ .findKey(predicate, context); }, - first: function first() { - return this.find(returnTrue); + first: function first(notSetValue) { + return this.find(returnTrue, null, notSetValue); }, flatMap: function flatMap(mapper, context) { @@ -4910,10 +4910,10 @@ .toIndexedSeq(); }, - last: function last() { + last: function last(notSetValue) { return this.toSeq() .reverse() - .first(); + .first(notSetValue); }, lastKeyOf: function lastKeyOf(searchValue) { @@ -5117,8 +5117,8 @@ return entry ? entry[0] : -1; }, - first: function first() { - return this.get(0); + first: function first(notSetValue) { + return this.get(0, notSetValue); }, flatten: function flatten(depth) { @@ -5161,8 +5161,8 @@ return Range(0, this.size); }, - last: function last() { - return this.get(-1); + last: function last(notSetValue) { + return this.get(-1, notSetValue); }, skipWhile: function skipWhile(predicate, context) { diff --git a/dist/immutable.js.flow b/dist/immutable.js.flow index c701935822..8f6b4efcae 100644 --- a/dist/immutable.js.flow +++ b/dist/immutable.js.flow @@ -63,8 +63,8 @@ declare class _Collection /*implements ValueObject*/ { has(key: K): boolean; includes(value: V): boolean; contains(value: V): boolean; - first(): V | void; - last(): V | void; + first(notSetValue?: NSV): V | NSV; + last(notSetValue?: NSV): V | NSV; hasIn(keyPath: Iterable): boolean; diff --git a/dist/immutable.min.js b/dist/immutable.min.js index 0a3e4cdf91..b09547fe95 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -30,9 +30,9 @@ this):Or(e,n)},r.prototype.pop=function(){return this.slice(1)},r.prototype.clea return this.__toString("Set {","}")},r.prototype.has=function(t){return this._map.has(t)},r.prototype.add=function(t){return xr(this,this._map.set(t,t))},r.prototype.remove=function(t){return xr(this,this._map.remove(t))},r.prototype.clear=function(){return xr(this,this._map.clear())},r.prototype.map=function(t,r){var e=this;return xr(this,this._map.map(function(r){return t(r,r,e)},r))},r.prototype.union=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];return r=r.filter(function(t){return 0!==t.size}),0===r.length?this:0!==this.size||this.__ownerID||1!==r.length?this.withMutations(function(e){for(var n=0;n=0&&r=0&&ethis.size?r:this.find(function(r,e){return e===t},void 0,r)},has:function(t){ -return(t=o(this,t))>=0&&(void 0!==this.size?this.size===1/0||tthis.size?r:this.find(function(r,e){return e===t},void 0,r)},has:function(t){ +return(t=o(this,t))>=0&&(void 0!==this.size?this.size===1/0||t Date: Tue, 18 Sep 2018 18:42:07 +0000 Subject: [PATCH 116/242] Deploy 5767783cc9c802ada88cfc0749cb7e652c839093 to NPM branch --- dist/immutable.es.js | 4 +++- dist/immutable.js | 4 +++- dist/immutable.min.js | 34 +++++++++++++++++----------------- 3 files changed, 23 insertions(+), 19 deletions(-) diff --git a/dist/immutable.es.js b/dist/immutable.es.js index 7a010ad0c5..12b6572d20 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -1868,7 +1868,9 @@ function coerceKeyPath(keyPath) { function isPlainObj(value) { return ( - value && (value.constructor === Object || value.constructor === undefined) + value && + ((value.constructor && value.constructor.name === 'Object') || + value.constructor === undefined) ); } diff --git a/dist/immutable.js b/dist/immutable.js index bdd19ad917..393c127fcc 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -1874,7 +1874,9 @@ function isPlainObj(value) { return ( - value && (value.constructor === Object || value.constructor === undefined) + value && + ((value.constructor && value.constructor.name === 'Object') || + value.constructor === undefined) ); } diff --git a/dist/immutable.min.js b/dist/immutable.min.js index b09547fe95..99e9d43e4e 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -10,23 +10,23 @@ function C(t){if(t&&t.nodeType>0)switch(t.nodeType){case 1:return t.uniqueID;cas i.__iterateUncached=function(i,o){var u=this,s=0;return t.__iterate(function(t,o,a){if(r.call(e,t,o,a))return s++,i(t,n?o:s-1,u)},o),s},i.__iteratorUncached=function(i,o){var u=t.__iterator(Se,o),s=0;return new Ee(function(){for(;;){var o=u.next();if(o.done)return o;var a=o.value,c=a[0],f=a[1];if(r.call(e,f,c,t))return w(i,n?c:s++,f,o)}})},i}function J(t,r,e){var n=Ze().asMutable();return t.__iterate(function(i,o){n.update(r.call(e,i,o,t),0,function(t){return t+1})}),n.asImmutable()}function H(t,r,e){var n=l(t),i=(d(t)?gn():Ze()).asMutable();t.__iterate(function(o,u){i.update(r.call(e,o,u,t),function(t){return t=t||[],t.push(n?[u,o]:o),t})});var o=ot(t);return i.map(function(r){return nt(t,o(r))})}function V(t,r,e,n){var i=t.size;if(s(r,e,i))return t;var u=a(r,i),f=c(e,i);if(u!==u||f!==f)return V(t.toSeq().cacheResult(),r,e,n);var h,p=f-u;p===p&&(h=p<0?0:p);var _=ut(t);return _.size=0===h?h:t.size&&h||void 0,!n&&q(t)&&h>=0&&(_.get=function(r,e){return r=o(this,r),r>=0&&rh)return z();var t=i.next();return n||r===ze||t.done?t:r===we?w(r,s-1,void 0,t):w(r,s-1,t.value[1],t)})},_}function Y(t,r,e){var n=ut(t);return n.__iterateUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterate(n,i);var u=0;return t.__iterate(function(t,i,s){return r.call(e,t,i,s)&&++u&&n(t,i,o)}),u},n.__iteratorUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterator(n,i);var u=t.__iterator(Se,i),s=!0;return new Ee(function(){if(!s)return z();var t=u.next();if(t.done)return t;var i=t.value,a=i[0],c=i[1];return r.call(e,c,a,o)?n===Se?t:w(n,a,c,t):(s=!1,z())})},n} function Q(t,r,e,n){var i=ut(t);return i.__iterateUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterate(i,o);var s=!0,a=0;return t.__iterate(function(t,o,c){if(!s||!(s=r.call(e,t,o,c)))return a++,i(t,n?o:a-1,u)}),a},i.__iteratorUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterator(i,o);var s=t.__iterator(Se,o),a=!0,c=0;return new Ee(function(){var t,o,f;do{if(t=s.next(),t.done)return n||i===ze?t:i===we?w(i,c++,void 0,t):w(i,c++,t.value[1],t);var h=t.value;o=h[0],f=h[1],a&&(a=r.call(e,f,o,u))}while(a);return i===Se?t:w(i,o,f,t)})},i}function X(t,r){var e=l(t),n=[t].concat(r).map(function(t){return _(t)?e&&(t=de(t)):t=e?D(t):A(Array.isArray(t)?t:[t]),t}).filter(function(t){return 0!==t.size});if(0===n.length)return t;if(1===n.length){var i=n[0];if(i===t||e&&l(i)||v(t)&&v(i))return i}var o=new ke(n);return e?o=o.toKeyedSeq():v(t)||(o=o.toSetSeq()),o=o.flatten(!0),o.size=n.reduce(function(t,r){if(void 0!==t){var e=r.size;if(void 0!==e)return t+e}},0),o}function F(t,r,e){var n=ut(t);return n.__iterateUncached=function(i,o){function u(t,c){t.__iterate(function(t,o){return(!r||c0}function et(t,r,e,n){var i=ut(t),o=new ke(e).map(function(t){return t.size});return i.size=n?o.max():o.min(),i.__iterate=function(t,r){for(var e,n=this,i=this.__iterator(ze,r),o=0;!(e=i.next()).done&&t(e.value,o++,n)!==!1;);return o},i.__iteratorUncached=function(t,i){var o=e.map(function(t){return t=ye(t),b(i?t.reverse():t)}),u=0,s=!1;return new Ee(function(){var e;return s||(e=o.map(function(t){return t.next()}),s=n?e.every(function(t){return t.done}):e.some(function(t){return t.done})),s?z():w(t,u++,r.apply(null,e.map(function(t){return t.value})))})},i}function nt(t,r){return t===r?t:q(t)?r:t.constructor(r)}function it(t){if(t!==Object(t))throw new TypeError("Expected [K, V] tuple: "+t)}function ot(t){return l(t)?de:v(t)?ge:me}function ut(t){return Object.create((l(t)?De:v(t)?Ae:xe).prototype)}function st(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size,this):Me.prototype.cacheResult.call(this)}function at(t,r){return void 0===t&&void 0===r?0:void 0===t?1:void 0===r?-1:t>r?1:t0;)r[e]=arguments[e+1];return jt(this,r,t)}function jt(t,r,e){for(var n=[],i=0;i0;)r[e]=arguments[e+1];return Lt(t,r)}function Rt(t,r){for(var e=[],n=arguments.length-2;n-- >0;)e[n]=arguments[n+2];return Lt(r,e,t)}function Ut(t){for(var r=[],e=arguments.length-1;e-- >0;)r[e]=arguments[e+1];return Tt(t,r)}function Kt(t,r){for(var e=[],n=arguments.length-2;n-- >0;)e[n]=arguments[n+2];return Tt(r,e,t)}function Tt(t,r,e){return Lt(t,r,Ct(e))}function Lt(t,r,e){if(!lt(t))throw new TypeError("Cannot merge into non-data-structure value: "+t);if(p(t))return t.mergeWith?t.mergeWith.apply(t,[e].concat(r)):t.concat.apply(t,r);for(var n=Array.isArray(t),i=t,o=n?ge:de,u=n?function(r){i===t&&(i=gt(i)),i.push(r)}:function(r,n){var o=qe.call(i,n),u=o&&e?e(i[n],r,n):r;o&&u===i[n]||(i===t&&(i=gt(i)),i[n]=u)},s=0;s0;)r[e]=arguments[e+1];return Tt(this,r,t)}function Nt(t){for(var r=[],e=arguments.length-1;e-- >0;)r[e]=arguments[e+1];return zt(this,t,Zt(),function(t){return Lt(t,r)})}function Pt(t){for(var r=[],e=arguments.length-1;e-- >0;)r[e]=arguments[e+1];return zt(this,t,Zt(),function(t){return Tt(t,r)})}function Jt(t){var r=this.asMutable();return t(r),r.wasAltered()?r.__ensureOwner(this.__ownerID):this}function Ht(){return this.__ownerID?this:this.__ensureOwner(new n)}function Vt(){return this.__ensureOwner()}function Yt(){return this.__altered}function Qt(t){return!(!t||!t[$e])}function Xt(t,r){return w(t,r[0],r[1])}function Ft(t,r){return{node:t,index:0,__prev:r}}function Gt(t,r,e,n){ -var i=Object.create(tn);return i.size=t,i._root=r,i.__ownerID=e,i.__hash=n,i.__altered=!1,i}function Zt(){return sn||(sn=Gt(0))}function $t(t,e,n){var i,o;if(t._root){var u=r(ce),s=r(fe);if(i=tr(t._root,t.__ownerID,0,void 0,e,n,u,s),!s.value)return t;o=t.size+(u.value?n===ae?-1:1:0)}else{if(n===ae)return t;o=1,i=new rn(t.__ownerID,[[e,n]])}return t.__ownerID?(t.size=o,t._root=i,t.__hash=void 0,t.__altered=!0,t):i?Gt(o,i):Zt()}function tr(t,r,n,i,o,u,s,a){return t?t.update(r,n,i,o,u,s,a):u===ae?t:(e(a),e(s),new un(r,i,[o,u]))}function rr(t){return t.constructor===un||t.constructor===on}function er(t,r,e,n,i){if(t.keyHash===n)return new on(r,n,[t.entry,i]);var o,u=(0===e?t.keyHash:t.keyHash>>>e)&se,s=(0===e?n:n>>>e)&se;return new en(r,1<>>=1)u[s]=1&e?r[o++]:void 0;return u[n]=i,new nn(t,o+1,u)}function ur(t){return t-=t>>1&1431655765,t=(858993459&t)+(t>>2&858993459),t=t+(t>>4)&252645135,t+=t>>8,127&(t+=t>>16)}function sr(t,r,e,n){var i=n?t:ct(t);return i[r]=e,i}function ar(t,r,e,n){var i=t.length+1;if(n&&r+1===i)return t[r]=e,t;for(var o=Array(i),u=0,s=0;so?0:o-e,c=u-e;return c>ue&&(c=ue),function(){if(i===c)return dn;var t=r?--c:i++;return n&&n[t]}}function i(t,n,i){var s,a=t&&t.array,c=i>o?0:o-i>>n,f=1+(u-i>>n);return f>ue&&(f=ue),function(){for(;;){if(s){var t=s() -;if(t!==dn)return t;s=null}if(c===f)return dn;var o=r?--f:c++;s=e(a&&a[o],n-oe,i+(o<=t.size||e<0)return t.withMutations(function(t){e<0?gr(t,e).set(0,n):gr(t,0,e+1).set(e,n)});e+=t._origin;var i=t._tail,u=t._root,s=r(fe);return e>=mr(t._capacity)?i=vr(i,t.__ownerID,0,e,n,s):u=vr(u,t.__ownerID,t._level,e,n,s),s.value?t.__ownerID?(t._root=u,t._tail=i,t.__hash=void 0,t.__altered=!0,t):pr(t._origin,t._capacity,t._level,u,i):t}function vr(t,r,n,i,o,u){var s=i>>>n&se,a=t&&s0){var f=t&&t.array[s],h=vr(f,r,n-oe,i,o,u);return h===f?t:(c=yr(t,r),c.array[s]=h,c)}return a&&t.array[s]===o?t:(e(u),c=yr(t,r),void 0===o&&s===c.array.length-1?c.array.pop():c.array[s]=o,c)}function yr(t,r){return r&&t&&r===t.ownerID?t:new vn(t?t.array.slice():[],r)}function dr(t,r){if(r>=mr(t._capacity))return t._tail;if(r<1<0;)e=e.array[r>>>n&se],n-=oe;return e}}function gr(t,r,e){void 0!==r&&(r|=0),void 0!==e&&(e|=0);var i=t.__ownerID||new n,o=t._origin,u=t._capacity,s=o+r,a=void 0===e?u:e<0?u+e:o+e;if(s===o&&a===u)return t;if(s>=a)return t.clear();for(var c=t._level,f=t._root,h=0;s+h<0;)f=new vn(f&&f.array.length?[void 0,f]:[],i),c+=oe,h+=1<=1<p?new vn([],i):l;if(l&&_>p&&soe;d-=oe){var g=p>>>d&se;y=y.array[g]=yr(y.array[g],i)}y.array[p>>>oe&se]=l}if(a=_)s-=_,a-=_,c=oe,f=null,v=v&&v.removeBefore(i,0,s);else if(s>o||_>>c&se;if(m!==_>>>c&se)break;m&&(h+=(1<o&&(f=f.removeBefore(i,c,s-h)),f&&_>>oe<=ue&&u.size>=2*o.size?(i=u.filter(function(t,r){return void 0!==t&&s!==r}),n=i.toKeyedSeq().map(function(t){return t[0]}).flip().toMap(),t.__ownerID&&(n.__ownerID=i.__ownerID=t.__ownerID)):(n=o.remove(r),i=s===u.size-1?u.pop():u.set(s,void 0))}else if(a){if(e===u.get(s)[1])return t;n=o,i=u.set(s,[r,e])}else n=o.set(r,u.size),i=u.set(u.size,[r,e]);return t.__ownerID?(t.size=n.size,t._map=n,t._list=i,t.__hash=void 0,t):zr(n,i)}function br(t){return!(!t||!t[zn])}function Or(t,r,e,n){var i=Object.create(Sn);return i.size=t,i._head=r,i.__ownerID=e,i.__hash=n,i.__altered=!1,i}function Er(){return In||(In=Or(0))}function qr(t,r){if(t===r)return!0;if(!_(r)||void 0!==t.size&&void 0!==r.size&&t.size!==r.size||void 0!==t.__hash&&void 0!==r.__hash&&t.__hash!==r.__hash||l(t)!==l(r)||v(t)!==v(r)||d(t)!==d(r))return!1;if(0===t.size&&0===r.size)return!0;var e=!y(t);if(d(t)){var n=t.entries();return r.every(function(t,r){var i=n.next().value;return i&&k(i[1],t)&&(e||k(i[0],r))})&&n.next().done}var i=!1;if(void 0===t.size)if(void 0===r.size)"function"==typeof t.cacheResult&&t.cacheResult();else{i=!0;var o=t;t=r,r=o}var u=!0,s=r.__iterate(function(r,n){if(e?!t.has(r):i?!k(r,t.get(n,ae)):!k(t.get(n,ae),r))return u=!1,!1});return u&&t.size===s}function Mr(t,r){var e=function(e){t.prototype[e]=r[e]};return Object.keys(r).forEach(e),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(r).forEach(e),t}function Dr(t){return lt(t)?Me(t).map(Dr).toJSON():t} -function Ar(t){return!(!t||!t[On])}function xr(t,r){return t.__ownerID?(t.size=r.size,t._map=r,t):r===t._map?t:0===r.size?t.__empty():t.__make(r)}function jr(t,r){var e=Object.create(En);return e.size=t?t.size:0,e._map=t,e.__ownerID=r,e}function kr(){return qn||(qn=jr(Zt()))}function Rr(t,r,e){for(var n=pt(r),i=0;i!==n.length;)if((t=dt(t,n[i++],ae))===ae)return e;return t}function Ur(t,r){return Rr(this,t,r)}function Kr(t,r){return Rr(t,r,ae)!==ae}function Tr(t){return Kr(this,t)}function Lr(){ht(this.size);var t={};return this.__iterate(function(r,e){t[e]=r}),t}function Cr(t,r,e,n,i,o){return ht(t.size),t.__iterate(function(t,o,u){i?(i=!1,e=t):e=r.call(n,e,t,o,u)},o),e}function Br(t,r){return r}function Wr(t,r){return[r,t]}function Nr(t){return function(){return!t.apply(this,arguments)}}function Pr(t){return function(){return-t.apply(this,arguments)}}function Jr(){return ct(arguments)}function Hr(t,r){return tr?-1:0}function Vr(t){if(t.size===1/0)return 0;var r=d(t),e=l(t),n=r?1:0;return Yr(t.__iterate(e?r?function(t,r){n=31*n+Qr(U(t),U(r))|0}:function(t,r){n=n+Qr(U(t),U(r))|0}:r?function(t){n=31*n+U(t)|0}:function(t){n=n+U(t)|0}),n)}function Yr(t,r){return r=Le(r,3432918353),r=Le(r<<15|r>>>-15,461845907),r=Le(r<<13|r>>>-13,5),r=(r+3864292196|0)^t,r=Le(r^r>>>16,2246822507),r=Le(r^r>>>13,3266489909),r=R(r^r>>>16)}function Qr(t,r){return t^r+2654435769+(t<<6)+(t>>2)|0}function Xr(t){return Ar(t)&&d(t)}function Fr(t,r){var e=Object.create(Rn);return e.size=t?t.size:0,e._map=t,e.__ownerID=r,e}function Gr(){return Un||(Un=Fr(Sr()))}function Zr(t,r,e){var n=Object.create(Object.getPrototypeOf(t));return n._values=r,n.__ownerID=e,n}function $r(t){return t._name||t.constructor.name||"Record"}function te(t){return D(t._keys.map(function(r){return[r,t.get(r)]}))}function re(t,r){try{Object.defineProperty(t,r,{get:function(){return this.get(r)},set:function(t){ft(this.__ownerID,"Cannot set on an immutable record."),this.set(r,t)}})}catch(t){}}function ee(t,r){return ne([],r||ie,t,"",r&&r.length>2?[]:void 0,{"":t})} -function ne(t,r,e,n,i,o){var u=Array.isArray(e)?Ae:_t(e)?De:null;if(u){if(~t.indexOf(e))throw new TypeError("Cannot convert circular structure to Immutable");t.push(e),i&&""!==n&&i.push(n);var s=r.call(o,n,u(e).map(function(n,o){return ne(t,r,n,o,i,e)}),i&&i.slice());return t.pop(),i&&i.pop(),s}return e}function ie(t,r){return l(r)?r.toMap():r.toList()}var oe=5,ue=1<>>16)*n+e*(r>>>16)<<16>>>0)|0},Ce=Object.isExtensible,Be=function(){try{return Object.defineProperty({},"@",{}),!0}catch(t){return!1}}(),We="function"==typeof WeakMap;We&&(Ke=new WeakMap);var Ne=0,Pe="__immutablehash__";"function"==typeof Symbol&&(Pe=Symbol(Pe));var Je=16,He=255,Ve=0,Ye={},Qe=function(t){function r(t,r){this._iter=t,this._useKeys=r,this.size=t.size}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.prototype.get=function(t,r){return this._iter.get(t,r)},r.prototype.has=function(t){return this._iter.has(t)},r.prototype.valueSeq=function(){return this._iter.valueSeq()},r.prototype.reverse=function(){var t=this,r=N(this,!0);return this._useKeys||(r.valueSeq=function(){return t._iter.toSeq().reverse()}),r},r.prototype.map=function(t,r){ -var e=this,n=W(this,t,r);return this._useKeys||(n.valueSeq=function(){return e._iter.toSeq().map(t,r)}),n},r.prototype.__iterate=function(t,r){var e=this;return this._iter.__iterate(function(r,n){return t(r,n,e)},r)},r.prototype.__iterator=function(t,r){return this._iter.__iterator(t,r)},r}(De);Qe.prototype[le]=!0;var Xe=function(t){function r(t){this._iter=t,this.size=t.size}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.prototype.includes=function(t){return this._iter.includes(t)},r.prototype.__iterate=function(t,r){var e=this,n=0;return r&&i(this),this._iter.__iterate(function(i){return t(i,r?e.size-++n:n++,e)},r)},r.prototype.__iterator=function(t,r){var e=this,n=this._iter.__iterator(ze,r),o=0;return r&&i(this),new Ee(function(){var i=n.next();return i.done?i:w(t,r?e.size-++o:o++,i.value,i)})},r}(Ae),Fe=function(t){function r(t){this._iter=t,this.size=t.size}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.prototype.has=function(t){return this._iter.includes(t)},r.prototype.__iterate=function(t,r){var e=this;return this._iter.__iterate(function(r){return t(r,r,e)},r)},r.prototype.__iterator=function(t,r){var e=this._iter.__iterator(ze,r);return new Ee(function(){var r=e.next();return r.done?r:w(t,r.value,r.value,r)})},r}(xe),Ge=function(t){function r(t){this._iter=t,this.size=t.size}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.prototype.entrySeq=function(){return this._iter.toSeq()},r.prototype.__iterate=function(t,r){var e=this;return this._iter.__iterate(function(r){if(r){it(r);var n=_(r);return t(n?r.get(1):r[1],n?r.get(0):r[0],e)}},r)},r.prototype.__iterator=function(t,r){var e=this._iter.__iterator(ze,r);return new Ee(function(){for(;;){var r=e.next();if(r.done)return r;var n=r.value;if(n){it(n);var i=_(n);return w(t,i?n.get(0):n[0],i?n.get(1):n[1],r)}}})},r}(De) -;Xe.prototype.cacheResult=Qe.prototype.cacheResult=Fe.prototype.cacheResult=Ge.prototype.cacheResult=st;var Ze=function(t){function r(r){return null===r||void 0===r?Zt():Qt(r)&&!d(r)?r:Zt().withMutations(function(e){var n=t(r);ht(n.size),n.forEach(function(t,r){return e.set(r,t)})})}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.of=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return Zt().withMutations(function(r){for(var e=0;e=t.length)throw Error("Missing value for key: "+t[e]);r.set(t[e],t[e+1])}})},r.prototype.toString=function(){return this.__toString("Map {","}")},r.prototype.get=function(t,r){return this._root?this._root.get(0,void 0,t,r):r},r.prototype.set=function(t,r){return $t(this,t,r)},r.prototype.remove=function(t){return $t(this,t,ae)},r.prototype.deleteAll=function(t){var r=ye(t);return 0===r.size?this:this.withMutations(function(t){r.forEach(function(r){return t.remove(r)})})},r.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):Zt()},r.prototype.sort=function(t){return gn($(this,t))},r.prototype.sortBy=function(t,r){return gn($(this,r,t))},r.prototype.map=function(t,r){return this.withMutations(function(e){e.forEach(function(n,i){e.set(i,t.call(r,n,i,e))})})},r.prototype.__iterator=function(t,r){return new an(this,t,r)},r.prototype.__iterate=function(t,r){var e=this,n=0;return this._root&&this._root.iterate(function(r){return n++,t(r[1],r[0],e)},r),n},r.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Gt(this.size,this._root,t,this.__hash):0===this.size?Zt():(this.__ownerID=t,this.__altered=!1,this)},r}(de);Ze.isMap=Qt;var $e="@@__IMMUTABLE_MAP__@@",tn=Ze.prototype;tn[$e]=!0,tn.delete=tn.remove,tn.removeAll=tn.deleteAll,tn.setIn=bt,tn.removeIn=tn.deleteIn=Et,tn.update=Mt,tn.updateIn=Dt,tn.merge=tn.concat=At,tn.mergeWith=xt,tn.mergeDeep=Bt,tn.mergeDeepWith=Wt,tn.mergeIn=Nt,tn.mergeDeepIn=Pt, -tn.withMutations=Jt,tn.wasAltered=Yt,tn.asImmutable=Vt,tn["@@transducer/init"]=tn.asMutable=Ht,tn["@@transducer/step"]=function(t,r){return t.set(r[0],r[1])},tn["@@transducer/result"]=function(t){return t.asImmutable()};var rn=function(t,r){this.ownerID=t,this.entries=r};rn.prototype.get=function(t,r,e,n){for(var i=this.entries,o=0,u=i.length;o=cn)return nr(t,c,i,o);var _=t&&t===this.ownerID,l=_?c:ct(c);return p?a?f===h-1?l.pop():l[f]=l.pop():l[f]=[i,o]:l.push([i,o]),_?(this.entries=l,this):new rn(t,l)}};var en=function(t,r,e){this.ownerID=t,this.bitmap=r,this.nodes=e};en.prototype.get=function(t,r,e,n){void 0===r&&(r=U(e));var i=1<<((0===t?r:r>>>t)&se),o=this.bitmap;return 0==(o&i)?n:this.nodes[ur(o&i-1)].get(t+oe,r,e,n)},en.prototype.update=function(t,r,e,n,i,o,u){void 0===e&&(e=U(n));var s=(0===r?e:e>>>r)&se,a=1<=fn)return or(t,p,c,s,l);if(f&&!l&&2===p.length&&rr(p[1^h]))return p[1^h];if(f&&l&&1===p.length&&rr(l))return l;var v=t&&t===this.ownerID,y=f?l?c:c^a:c|a,d=f?l?sr(p,h,l,v):cr(p,h,v):ar(p,h,l,v);return v?(this.bitmap=y,this.nodes=d,this):new en(t,y,d)};var nn=function(t,r,e){this.ownerID=t,this.count=r,this.nodes=e};nn.prototype.get=function(t,r,e,n){void 0===r&&(r=U(e));var i=(0===t?r:r>>>t)&se,o=this.nodes[i];return o?o.get(t+oe,r,e,n):n},nn.prototype.update=function(t,r,e,n,i,o,u){void 0===e&&(e=U(n));var s=(0===r?e:e>>>r)&se,a=i===ae,c=this.nodes,f=c[s];if(a&&!f)return this;var h=tr(f,t,r+oe,e,n,i,o,u);if(h===f)return this;var p=this.count;if(f){if(!h&&--p0&&i=0&&t>>r&se;if(n>=this.array.length)return new vn([],t);var i,o=0===n;if(r>0){var u=this.array[n];if((i=u&&u.removeBefore(t,r-oe,e))===u&&o)return this}if(o&&!i)return this;var s=yr(this,t);if(!o)for(var a=0;a>>r&se;if(n>=this.array.length)return this;var i;if(r>0){var o=this.array[n];if((i=o&&o.removeAfter(t,r-oe,e))===o&&n===this.array.length-1)return this}var u=yr(this,t);return u.array.splice(n+1),i&&(u.array[n]=i),u};var yn,dn={},gn=function(t){function r(t){return null===t||void 0===t?Sr():wr(t)?t:Sr().withMutations(function(r){var e=de(t);ht(e.size),e.forEach(function(t,e){return r.set(e,t)})})}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.of=function(){return this(arguments)}, -r.prototype.toString=function(){return this.__toString("OrderedMap {","}")},r.prototype.get=function(t,r){var e=this._map.get(t);return void 0!==e?this._list.get(e)[1]:r},r.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._map.clear(),this._list.clear(),this):Sr()},r.prototype.set=function(t,r){return Ir(this,t,r)},r.prototype.remove=function(t){return Ir(this,t,ae)},r.prototype.wasAltered=function(){return this._map.wasAltered()||this._list.wasAltered()},r.prototype.__iterate=function(t,r){var e=this;return this._list.__iterate(function(r){return r&&t(r[1],r[0],e)},r)},r.prototype.__iterator=function(t,r){return this._list.fromEntrySeq().__iterator(t,r)},r.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var r=this._map.__ensureOwner(t),e=this._list.__ensureOwner(t);return t?zr(r,e,t,this.__hash):0===this.size?Sr():(this.__ownerID=t,this._map=r,this._list=e,this)},r}(Ze);gn.isOrderedMap=wr,gn.prototype[le]=!0,gn.prototype.delete=gn.prototype.remove;var mn,wn=function(t){function r(t){return null===t||void 0===t?Er():br(t)?t:Er().pushAll(t)}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.of=function(){return this(arguments)},r.prototype.toString=function(){return this.__toString("Stack [","]")},r.prototype.get=function(t,r){var e=this._head;for(t=o(this,t);e&&t--;)e=e.next;return e?e.value:r},r.prototype.peek=function(){return this._head&&this._head.value},r.prototype.push=function(){var t=arguments;if(0===arguments.length)return this;for(var r=this.size+arguments.length,e=this._head,n=arguments.length-1;n>=0;n--)e={value:t[n],next:e};return this.__ownerID?(this.size=r,this._head=e,this.__hash=void 0,this.__altered=!0,this):Or(r,e)},r.prototype.pushAll=function(r){if(r=t(r),0===r.size)return this;if(0===this.size&&br(r))return r;ht(r.size);var e=this.size,n=this._head;return r.__iterate(function(t){e++,n={value:t,next:n}},!0),this.__ownerID?(this.size=e,this._head=n,this.__hash=void 0,this.__altered=!0, -this):Or(e,n)},r.prototype.pop=function(){return this.slice(1)},r.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):Er()},r.prototype.slice=function(r,e){if(s(r,e,this.size))return this;var n=a(r,this.size);if(c(e,this.size)!==this.size)return t.prototype.slice.call(this,r,e);for(var i=this.size-n,o=this._head;n--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):Or(i,o)},r.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Or(this.size,this._head,t,this.__hash):0===this.size?Er():(this.__ownerID=t,this.__altered=!1,this)},r.prototype.__iterate=function(t,r){var e=this;if(r)return new ke(this.toArray()).__iterate(function(r,n){return t(r,n,e)},r);for(var n=0,i=this._head;i&&t(i.value,n++,e)!==!1;)i=i.next;return n},r.prototype.__iterator=function(t,r){if(r)return new ke(this.toArray()).__iterator(t,r);var e=0,n=this._head;return new Ee(function(){if(n){var r=n.value;return n=n.next,w(t,e++,r)}return z()})},r}(ge);wn.isStack=br;var zn="@@__IMMUTABLE_STACK__@@",Sn=wn.prototype;Sn[zn]=!0,Sn.shift=Sn.pop,Sn.unshift=Sn.push,Sn.unshiftAll=Sn.pushAll,Sn.withMutations=Jt,Sn.wasAltered=Yt,Sn.asImmutable=Vt,Sn["@@transducer/init"]=Sn.asMutable=Ht,Sn["@@transducer/step"]=function(t,r){return t.unshift(r)},Sn["@@transducer/result"]=function(t){return t.asImmutable()};var In,bn=function(t){function r(r){return null===r||void 0===r?kr():Ar(r)&&!d(r)?r:kr().withMutations(function(e){var n=t(r);ht(n.size),n.forEach(function(t){return e.add(t)})})}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.of=function(){return this(arguments)},r.fromKeys=function(t){return this(de(t).keySeq())},r.intersect=function(t){return t=ye(t).toArray(),t.length?En.intersect.apply(r(t.pop()),t):kr()},r.union=function(t){return t=ye(t).toArray(),t.length?En.union.apply(r(t.pop()),t):kr()},r.prototype.toString=function(){ +function _t(t){return t&&(t.constructor&&"Object"===t.constructor.name||void 0===t.constructor)}function lt(t){return p(t)||Array.isArray(t)||_t(t)}function vt(t){try{return"string"==typeof t?JSON.stringify(t):t+""}catch(r){return JSON.stringify(t)}}function yt(t,r){return p(t)?t.has(r):lt(t)&&qe.call(t,r)}function dt(t,r,e){return p(t)?t.get(r,e):yt(t,r)?"function"==typeof t.get?t.get(r):t[r]:e}function gt(t){if(Array.isArray(t))return ct(t);var r={};for(var e in t)qe.call(t,e)&&(r[e]=t[e]);return r}function mt(t,r){if(!lt(t))throw new TypeError("Cannot update non-data-structure value: "+t);if(p(t)){if(!t.remove)throw new TypeError("Cannot update immutable value without .remove() method: "+t);return t.remove(r)}if(!qe.call(t,r))return t;var e=gt(t);return Array.isArray(e)?e.splice(r,1):delete e[r],e}function wt(t,r,e){if(!lt(t))throw new TypeError("Cannot update non-data-structure value: "+t);if(p(t)){if(!t.set)throw new TypeError("Cannot update immutable value without .set() method: "+t);return t.set(r,e)}if(qe.call(t,r)&&e===t[r])return t;var n=gt(t);return n[r]=e,n}function zt(t,r,e,n){n||(n=e,e=void 0);var i=St(p(t),t,pt(r),0,e,n);return i===ae?e:i}function St(t,r,e,n,i,o){var u=r===ae;if(n===e.length){var s=u?i:r,a=o(s);return a===s?r:a}if(!u&&!lt(r))throw new TypeError("Cannot update within non-data-structure value in path ["+e.slice(0,n).map(vt)+"]: "+r);var c=e[n],f=u?ae:dt(r,c,ae),h=St(f===ae?t:p(f),f,e,n+1,i,o);return h===f?r:h===ae?mt(r,c):wt(u?t?Zt():{}:r,c,h)}function It(t,r,e){return zt(t,r,ae,function(){return e})}function bt(t,r){return It(this,t,r)}function Ot(t,r){return zt(t,r,function(){return ae})}function Et(t){return Ot(this,t)}function qt(t,r,e,n){return zt(t,[r],e,n)}function Mt(t,r,e){return 1===arguments.length?t(this):qt(this,t,r,e)}function Dt(t,r,e){return zt(this,t,r,e)}function At(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return jt(this,t)}function xt(t){for(var r=[],e=arguments.length-1;e-- >0;)r[e]=arguments[e+1];return jt(this,r,t)}function jt(t,r,e){ +for(var n=[],i=0;i0;)r[e]=arguments[e+1];return Lt(t,r)}function Rt(t,r){for(var e=[],n=arguments.length-2;n-- >0;)e[n]=arguments[n+2];return Lt(r,e,t)}function Ut(t){for(var r=[],e=arguments.length-1;e-- >0;)r[e]=arguments[e+1];return Tt(t,r)}function Kt(t,r){for(var e=[],n=arguments.length-2;n-- >0;)e[n]=arguments[n+2];return Tt(r,e,t)}function Tt(t,r,e){return Lt(t,r,Ct(e))}function Lt(t,r,e){if(!lt(t))throw new TypeError("Cannot merge into non-data-structure value: "+t);if(p(t))return t.mergeWith?t.mergeWith.apply(t,[e].concat(r)):t.concat.apply(t,r);for(var n=Array.isArray(t),i=t,o=n?ge:de,u=n?function(r){i===t&&(i=gt(i)),i.push(r)}:function(r,n){var o=qe.call(i,n),u=o&&e?e(i[n],r,n):r;o&&u===i[n]||(i===t&&(i=gt(i)),i[n]=u)},s=0;s0;)r[e]=arguments[e+1];return Tt(this,r,t)}function Nt(t){for(var r=[],e=arguments.length-1;e-- >0;)r[e]=arguments[e+1];return zt(this,t,Zt(),function(t){return Lt(t,r)})}function Pt(t){for(var r=[],e=arguments.length-1;e-- >0;)r[e]=arguments[e+1];return zt(this,t,Zt(),function(t){return Tt(t,r)})}function Jt(t){var r=this.asMutable();return t(r),r.wasAltered()?r.__ensureOwner(this.__ownerID):this}function Ht(){return this.__ownerID?this:this.__ensureOwner(new n)}function Vt(){return this.__ensureOwner()}function Yt(){return this.__altered}function Qt(t){return!(!t||!t[$e])}function Xt(t,r){return w(t,r[0],r[1])}function Ft(t,r){return{node:t,index:0,__prev:r}} +function Gt(t,r,e,n){var i=Object.create(tn);return i.size=t,i._root=r,i.__ownerID=e,i.__hash=n,i.__altered=!1,i}function Zt(){return sn||(sn=Gt(0))}function $t(t,e,n){var i,o;if(t._root){var u=r(ce),s=r(fe);if(i=tr(t._root,t.__ownerID,0,void 0,e,n,u,s),!s.value)return t;o=t.size+(u.value?n===ae?-1:1:0)}else{if(n===ae)return t;o=1,i=new rn(t.__ownerID,[[e,n]])}return t.__ownerID?(t.size=o,t._root=i,t.__hash=void 0,t.__altered=!0,t):i?Gt(o,i):Zt()}function tr(t,r,n,i,o,u,s,a){return t?t.update(r,n,i,o,u,s,a):u===ae?t:(e(a),e(s),new un(r,i,[o,u]))}function rr(t){return t.constructor===un||t.constructor===on}function er(t,r,e,n,i){if(t.keyHash===n)return new on(r,n,[t.entry,i]);var o,u=(0===e?t.keyHash:t.keyHash>>>e)&se,s=(0===e?n:n>>>e)&se;return new en(r,1<>>=1)u[s]=1&e?r[o++]:void 0;return u[n]=i,new nn(t,o+1,u)}function ur(t){return t-=t>>1&1431655765,t=(858993459&t)+(t>>2&858993459),t=t+(t>>4)&252645135,t+=t>>8,127&(t+=t>>16)}function sr(t,r,e,n){var i=n?t:ct(t);return i[r]=e,i}function ar(t,r,e,n){var i=t.length+1;if(n&&r+1===i)return t[r]=e,t;for(var o=Array(i),u=0,s=0;so?0:o-e,c=u-e;return c>ue&&(c=ue),function(){if(i===c)return dn;var t=r?--c:i++;return n&&n[t]}}function i(t,n,i){var s,a=t&&t.array,c=i>o?0:o-i>>n,f=1+(u-i>>n);return f>ue&&(f=ue),function(){for(;;){ +if(s){var t=s();if(t!==dn)return t;s=null}if(c===f)return dn;var o=r?--f:c++;s=e(a&&a[o],n-oe,i+(o<=t.size||e<0)return t.withMutations(function(t){e<0?gr(t,e).set(0,n):gr(t,0,e+1).set(e,n)});e+=t._origin;var i=t._tail,u=t._root,s=r(fe);return e>=mr(t._capacity)?i=vr(i,t.__ownerID,0,e,n,s):u=vr(u,t.__ownerID,t._level,e,n,s),s.value?t.__ownerID?(t._root=u,t._tail=i,t.__hash=void 0,t.__altered=!0,t):pr(t._origin,t._capacity,t._level,u,i):t}function vr(t,r,n,i,o,u){var s=i>>>n&se,a=t&&s0){var f=t&&t.array[s],h=vr(f,r,n-oe,i,o,u);return h===f?t:(c=yr(t,r),c.array[s]=h,c)}return a&&t.array[s]===o?t:(e(u),c=yr(t,r),void 0===o&&s===c.array.length-1?c.array.pop():c.array[s]=o,c)}function yr(t,r){return r&&t&&r===t.ownerID?t:new vn(t?t.array.slice():[],r)}function dr(t,r){if(r>=mr(t._capacity))return t._tail;if(r<1<0;)e=e.array[r>>>n&se],n-=oe;return e}}function gr(t,r,e){void 0!==r&&(r|=0),void 0!==e&&(e|=0);var i=t.__ownerID||new n,o=t._origin,u=t._capacity,s=o+r,a=void 0===e?u:e<0?u+e:o+e;if(s===o&&a===u)return t;if(s>=a)return t.clear();for(var c=t._level,f=t._root,h=0;s+h<0;)f=new vn(f&&f.array.length?[void 0,f]:[],i),c+=oe,h+=1<=1<p?new vn([],i):l;if(l&&_>p&&soe;d-=oe){var g=p>>>d&se;y=y.array[g]=yr(y.array[g],i)}y.array[p>>>oe&se]=l}if(a=_)s-=_,a-=_,c=oe,f=null,v=v&&v.removeBefore(i,0,s);else if(s>o||_>>c&se;if(m!==_>>>c&se)break +;m&&(h+=(1<o&&(f=f.removeBefore(i,c,s-h)),f&&_>>oe<=ue&&u.size>=2*o.size?(i=u.filter(function(t,r){return void 0!==t&&s!==r}),n=i.toKeyedSeq().map(function(t){return t[0]}).flip().toMap(),t.__ownerID&&(n.__ownerID=i.__ownerID=t.__ownerID)):(n=o.remove(r),i=s===u.size-1?u.pop():u.set(s,void 0))}else if(a){if(e===u.get(s)[1])return t;n=o,i=u.set(s,[r,e])}else n=o.set(r,u.size),i=u.set(u.size,[r,e]);return t.__ownerID?(t.size=n.size,t._map=n,t._list=i,t.__hash=void 0,t):zr(n,i)}function br(t){return!(!t||!t[zn])}function Or(t,r,e,n){var i=Object.create(Sn);return i.size=t,i._head=r,i.__ownerID=e,i.__hash=n,i.__altered=!1,i}function Er(){return In||(In=Or(0))}function qr(t,r){if(t===r)return!0;if(!_(r)||void 0!==t.size&&void 0!==r.size&&t.size!==r.size||void 0!==t.__hash&&void 0!==r.__hash&&t.__hash!==r.__hash||l(t)!==l(r)||v(t)!==v(r)||d(t)!==d(r))return!1;if(0===t.size&&0===r.size)return!0;var e=!y(t);if(d(t)){var n=t.entries();return r.every(function(t,r){var i=n.next().value;return i&&k(i[1],t)&&(e||k(i[0],r))})&&n.next().done}var i=!1;if(void 0===t.size)if(void 0===r.size)"function"==typeof t.cacheResult&&t.cacheResult();else{i=!0;var o=t;t=r,r=o}var u=!0,s=r.__iterate(function(r,n){if(e?!t.has(r):i?!k(r,t.get(n,ae)):!k(t.get(n,ae),r))return u=!1,!1});return u&&t.size===s}function Mr(t,r){var e=function(e){t.prototype[e]=r[e]};return Object.keys(r).forEach(e),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(r).forEach(e),t}function Dr(t){ +return lt(t)?Me(t).map(Dr).toJSON():t}function Ar(t){return!(!t||!t[On])}function xr(t,r){return t.__ownerID?(t.size=r.size,t._map=r,t):r===t._map?t:0===r.size?t.__empty():t.__make(r)}function jr(t,r){var e=Object.create(En);return e.size=t?t.size:0,e._map=t,e.__ownerID=r,e}function kr(){return qn||(qn=jr(Zt()))}function Rr(t,r,e){for(var n=pt(r),i=0;i!==n.length;)if((t=dt(t,n[i++],ae))===ae)return e;return t}function Ur(t,r){return Rr(this,t,r)}function Kr(t,r){return Rr(t,r,ae)!==ae}function Tr(t){return Kr(this,t)}function Lr(){ht(this.size);var t={};return this.__iterate(function(r,e){t[e]=r}),t}function Cr(t,r,e,n,i,o){return ht(t.size),t.__iterate(function(t,o,u){i?(i=!1,e=t):e=r.call(n,e,t,o,u)},o),e}function Br(t,r){return r}function Wr(t,r){return[r,t]}function Nr(t){return function(){return!t.apply(this,arguments)}}function Pr(t){return function(){return-t.apply(this,arguments)}}function Jr(){return ct(arguments)}function Hr(t,r){return tr?-1:0}function Vr(t){if(t.size===1/0)return 0;var r=d(t),e=l(t),n=r?1:0;return Yr(t.__iterate(e?r?function(t,r){n=31*n+Qr(U(t),U(r))|0}:function(t,r){n=n+Qr(U(t),U(r))|0}:r?function(t){n=31*n+U(t)|0}:function(t){n=n+U(t)|0}),n)}function Yr(t,r){return r=Le(r,3432918353),r=Le(r<<15|r>>>-15,461845907),r=Le(r<<13|r>>>-13,5),r=(r+3864292196|0)^t,r=Le(r^r>>>16,2246822507),r=Le(r^r>>>13,3266489909),r=R(r^r>>>16)}function Qr(t,r){return t^r+2654435769+(t<<6)+(t>>2)|0}function Xr(t){return Ar(t)&&d(t)}function Fr(t,r){var e=Object.create(Rn);return e.size=t?t.size:0,e._map=t,e.__ownerID=r,e}function Gr(){return Un||(Un=Fr(Sr()))}function Zr(t,r,e){var n=Object.create(Object.getPrototypeOf(t));return n._values=r,n.__ownerID=e,n}function $r(t){return t._name||t.constructor.name||"Record"}function te(t){return D(t._keys.map(function(r){return[r,t.get(r)]}))}function re(t,r){try{Object.defineProperty(t,r,{get:function(){return this.get(r)},set:function(t){ft(this.__ownerID,"Cannot set on an immutable record."),this.set(r,t)}})}catch(t){}}function ee(t,r){ +return ne([],r||ie,t,"",r&&r.length>2?[]:void 0,{"":t})}function ne(t,r,e,n,i,o){var u=Array.isArray(e)?Ae:_t(e)?De:null;if(u){if(~t.indexOf(e))throw new TypeError("Cannot convert circular structure to Immutable");t.push(e),i&&""!==n&&i.push(n);var s=r.call(o,n,u(e).map(function(n,o){return ne(t,r,n,o,i,e)}),i&&i.slice());return t.pop(),i&&i.pop(),s}return e}function ie(t,r){return l(r)?r.toMap():r.toList()}var oe=5,ue=1<>>16)*n+e*(r>>>16)<<16>>>0)|0},Ce=Object.isExtensible,Be=function(){try{return Object.defineProperty({},"@",{}),!0}catch(t){return!1}}(),We="function"==typeof WeakMap;We&&(Ke=new WeakMap);var Ne=0,Pe="__immutablehash__";"function"==typeof Symbol&&(Pe=Symbol(Pe));var Je=16,He=255,Ve=0,Ye={},Qe=function(t){function r(t,r){this._iter=t,this._useKeys=r,this.size=t.size}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.prototype.get=function(t,r){return this._iter.get(t,r)},r.prototype.has=function(t){return this._iter.has(t)},r.prototype.valueSeq=function(){return this._iter.valueSeq()},r.prototype.reverse=function(){var t=this,r=N(this,!0) +;return this._useKeys||(r.valueSeq=function(){return t._iter.toSeq().reverse()}),r},r.prototype.map=function(t,r){var e=this,n=W(this,t,r);return this._useKeys||(n.valueSeq=function(){return e._iter.toSeq().map(t,r)}),n},r.prototype.__iterate=function(t,r){var e=this;return this._iter.__iterate(function(r,n){return t(r,n,e)},r)},r.prototype.__iterator=function(t,r){return this._iter.__iterator(t,r)},r}(De);Qe.prototype[le]=!0;var Xe=function(t){function r(t){this._iter=t,this.size=t.size}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.prototype.includes=function(t){return this._iter.includes(t)},r.prototype.__iterate=function(t,r){var e=this,n=0;return r&&i(this),this._iter.__iterate(function(i){return t(i,r?e.size-++n:n++,e)},r)},r.prototype.__iterator=function(t,r){var e=this,n=this._iter.__iterator(ze,r),o=0;return r&&i(this),new Ee(function(){var i=n.next();return i.done?i:w(t,r?e.size-++o:o++,i.value,i)})},r}(Ae),Fe=function(t){function r(t){this._iter=t,this.size=t.size}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.prototype.has=function(t){return this._iter.includes(t)},r.prototype.__iterate=function(t,r){var e=this;return this._iter.__iterate(function(r){return t(r,r,e)},r)},r.prototype.__iterator=function(t,r){var e=this._iter.__iterator(ze,r);return new Ee(function(){var r=e.next();return r.done?r:w(t,r.value,r.value,r)})},r}(xe),Ge=function(t){function r(t){this._iter=t,this.size=t.size}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.prototype.entrySeq=function(){return this._iter.toSeq()},r.prototype.__iterate=function(t,r){var e=this;return this._iter.__iterate(function(r){if(r){it(r);var n=_(r);return t(n?r.get(1):r[1],n?r.get(0):r[0],e)}},r)},r.prototype.__iterator=function(t,r){var e=this._iter.__iterator(ze,r);return new Ee(function(){for(;;){var r=e.next();if(r.done)return r;var n=r.value;if(n){it(n);var i=_(n) +;return w(t,i?n.get(0):n[0],i?n.get(1):n[1],r)}}})},r}(De);Xe.prototype.cacheResult=Qe.prototype.cacheResult=Fe.prototype.cacheResult=Ge.prototype.cacheResult=st;var Ze=function(t){function r(r){return null===r||void 0===r?Zt():Qt(r)&&!d(r)?r:Zt().withMutations(function(e){var n=t(r);ht(n.size),n.forEach(function(t,r){return e.set(r,t)})})}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.of=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return Zt().withMutations(function(r){for(var e=0;e=t.length)throw Error("Missing value for key: "+t[e]);r.set(t[e],t[e+1])}})},r.prototype.toString=function(){return this.__toString("Map {","}")},r.prototype.get=function(t,r){return this._root?this._root.get(0,void 0,t,r):r},r.prototype.set=function(t,r){return $t(this,t,r)},r.prototype.remove=function(t){return $t(this,t,ae)},r.prototype.deleteAll=function(t){var r=ye(t);return 0===r.size?this:this.withMutations(function(t){r.forEach(function(r){return t.remove(r)})})},r.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):Zt()},r.prototype.sort=function(t){return gn($(this,t))},r.prototype.sortBy=function(t,r){return gn($(this,r,t))},r.prototype.map=function(t,r){return this.withMutations(function(e){e.forEach(function(n,i){e.set(i,t.call(r,n,i,e))})})},r.prototype.__iterator=function(t,r){return new an(this,t,r)},r.prototype.__iterate=function(t,r){var e=this,n=0;return this._root&&this._root.iterate(function(r){return n++,t(r[1],r[0],e)},r),n},r.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Gt(this.size,this._root,t,this.__hash):0===this.size?Zt():(this.__ownerID=t,this.__altered=!1,this)},r}(de);Ze.isMap=Qt;var $e="@@__IMMUTABLE_MAP__@@",tn=Ze.prototype;tn[$e]=!0,tn.delete=tn.remove,tn.removeAll=tn.deleteAll,tn.setIn=bt,tn.removeIn=tn.deleteIn=Et,tn.update=Mt,tn.updateIn=Dt,tn.merge=tn.concat=At,tn.mergeWith=xt,tn.mergeDeep=Bt, +tn.mergeDeepWith=Wt,tn.mergeIn=Nt,tn.mergeDeepIn=Pt,tn.withMutations=Jt,tn.wasAltered=Yt,tn.asImmutable=Vt,tn["@@transducer/init"]=tn.asMutable=Ht,tn["@@transducer/step"]=function(t,r){return t.set(r[0],r[1])},tn["@@transducer/result"]=function(t){return t.asImmutable()};var rn=function(t,r){this.ownerID=t,this.entries=r};rn.prototype.get=function(t,r,e,n){for(var i=this.entries,o=0,u=i.length;o=cn)return nr(t,c,i,o);var _=t&&t===this.ownerID,l=_?c:ct(c);return p?a?f===h-1?l.pop():l[f]=l.pop():l[f]=[i,o]:l.push([i,o]),_?(this.entries=l,this):new rn(t,l)}};var en=function(t,r,e){this.ownerID=t,this.bitmap=r,this.nodes=e};en.prototype.get=function(t,r,e,n){void 0===r&&(r=U(e));var i=1<<((0===t?r:r>>>t)&se),o=this.bitmap;return 0==(o&i)?n:this.nodes[ur(o&i-1)].get(t+oe,r,e,n)},en.prototype.update=function(t,r,e,n,i,o,u){void 0===e&&(e=U(n));var s=(0===r?e:e>>>r)&se,a=1<=fn)return or(t,p,c,s,l);if(f&&!l&&2===p.length&&rr(p[1^h]))return p[1^h];if(f&&l&&1===p.length&&rr(l))return l;var v=t&&t===this.ownerID,y=f?l?c:c^a:c|a,d=f?l?sr(p,h,l,v):cr(p,h,v):ar(p,h,l,v);return v?(this.bitmap=y,this.nodes=d,this):new en(t,y,d)};var nn=function(t,r,e){this.ownerID=t,this.count=r,this.nodes=e};nn.prototype.get=function(t,r,e,n){void 0===r&&(r=U(e));var i=(0===t?r:r>>>t)&se,o=this.nodes[i];return o?o.get(t+oe,r,e,n):n},nn.prototype.update=function(t,r,e,n,i,o,u){void 0===e&&(e=U(n));var s=(0===r?e:e>>>r)&se,a=i===ae,c=this.nodes,f=c[s];if(a&&!f)return this;var h=tr(f,t,r+oe,e,n,i,o,u);if(h===f)return this;var p=this.count;if(f){if(!h&&--p0&&i=0&&t>>r&se;if(n>=this.array.length)return new vn([],t);var i,o=0===n;if(r>0){var u=this.array[n];if((i=u&&u.removeBefore(t,r-oe,e))===u&&o)return this}if(o&&!i)return this;var s=yr(this,t);if(!o)for(var a=0;a>>r&se;if(n>=this.array.length)return this;var i;if(r>0){var o=this.array[n];if((i=o&&o.removeAfter(t,r-oe,e))===o&&n===this.array.length-1)return this}var u=yr(this,t);return u.array.splice(n+1),i&&(u.array[n]=i),u};var yn,dn={},gn=function(t){function r(t){return null===t||void 0===t?Sr():wr(t)?t:Sr().withMutations(function(r){var e=de(t);ht(e.size),e.forEach(function(t,e){return r.set(e,t)})})}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.of=function(){ +return this(arguments)},r.prototype.toString=function(){return this.__toString("OrderedMap {","}")},r.prototype.get=function(t,r){var e=this._map.get(t);return void 0!==e?this._list.get(e)[1]:r},r.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._map.clear(),this._list.clear(),this):Sr()},r.prototype.set=function(t,r){return Ir(this,t,r)},r.prototype.remove=function(t){return Ir(this,t,ae)},r.prototype.wasAltered=function(){return this._map.wasAltered()||this._list.wasAltered()},r.prototype.__iterate=function(t,r){var e=this;return this._list.__iterate(function(r){return r&&t(r[1],r[0],e)},r)},r.prototype.__iterator=function(t,r){return this._list.fromEntrySeq().__iterator(t,r)},r.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var r=this._map.__ensureOwner(t),e=this._list.__ensureOwner(t);return t?zr(r,e,t,this.__hash):0===this.size?Sr():(this.__ownerID=t,this._map=r,this._list=e,this)},r}(Ze);gn.isOrderedMap=wr,gn.prototype[le]=!0,gn.prototype.delete=gn.prototype.remove;var mn,wn=function(t){function r(t){return null===t||void 0===t?Er():br(t)?t:Er().pushAll(t)}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.of=function(){return this(arguments)},r.prototype.toString=function(){return this.__toString("Stack [","]")},r.prototype.get=function(t,r){var e=this._head;for(t=o(this,t);e&&t--;)e=e.next;return e?e.value:r},r.prototype.peek=function(){return this._head&&this._head.value},r.prototype.push=function(){var t=arguments;if(0===arguments.length)return this;for(var r=this.size+arguments.length,e=this._head,n=arguments.length-1;n>=0;n--)e={value:t[n],next:e};return this.__ownerID?(this.size=r,this._head=e,this.__hash=void 0,this.__altered=!0,this):Or(r,e)},r.prototype.pushAll=function(r){if(r=t(r),0===r.size)return this;if(0===this.size&&br(r))return r;ht(r.size);var e=this.size,n=this._head;return r.__iterate(function(t){e++,n={value:t,next:n}},!0),this.__ownerID?(this.size=e,this._head=n,this.__hash=void 0, +this.__altered=!0,this):Or(e,n)},r.prototype.pop=function(){return this.slice(1)},r.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):Er()},r.prototype.slice=function(r,e){if(s(r,e,this.size))return this;var n=a(r,this.size);if(c(e,this.size)!==this.size)return t.prototype.slice.call(this,r,e);for(var i=this.size-n,o=this._head;n--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):Or(i,o)},r.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Or(this.size,this._head,t,this.__hash):0===this.size?Er():(this.__ownerID=t,this.__altered=!1,this)},r.prototype.__iterate=function(t,r){var e=this;if(r)return new ke(this.toArray()).__iterate(function(r,n){return t(r,n,e)},r);for(var n=0,i=this._head;i&&t(i.value,n++,e)!==!1;)i=i.next;return n},r.prototype.__iterator=function(t,r){if(r)return new ke(this.toArray()).__iterator(t,r);var e=0,n=this._head;return new Ee(function(){if(n){var r=n.value;return n=n.next,w(t,e++,r)}return z()})},r}(ge);wn.isStack=br;var zn="@@__IMMUTABLE_STACK__@@",Sn=wn.prototype;Sn[zn]=!0,Sn.shift=Sn.pop,Sn.unshift=Sn.push,Sn.unshiftAll=Sn.pushAll,Sn.withMutations=Jt,Sn.wasAltered=Yt,Sn.asImmutable=Vt,Sn["@@transducer/init"]=Sn.asMutable=Ht,Sn["@@transducer/step"]=function(t,r){return t.unshift(r)},Sn["@@transducer/result"]=function(t){return t.asImmutable()};var In,bn=function(t){function r(r){return null===r||void 0===r?kr():Ar(r)&&!d(r)?r:kr().withMutations(function(e){var n=t(r);ht(n.size),n.forEach(function(t){return e.add(t)})})}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.of=function(){return this(arguments)},r.fromKeys=function(t){return this(de(t).keySeq())},r.intersect=function(t){return t=ye(t).toArray(),t.length?En.intersect.apply(r(t.pop()),t):kr()},r.union=function(t){return t=ye(t).toArray(),t.length?En.union.apply(r(t.pop()),t):kr()},r.prototype.toString=function(){ return this.__toString("Set {","}")},r.prototype.has=function(t){return this._map.has(t)},r.prototype.add=function(t){return xr(this,this._map.set(t,t))},r.prototype.remove=function(t){return xr(this,this._map.remove(t))},r.prototype.clear=function(){return xr(this,this._map.clear())},r.prototype.map=function(t,r){var e=this;return xr(this,this._map.map(function(r){return t(r,r,e)},r))},r.prototype.union=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];return r=r.filter(function(t){return 0!==t.size}),0===r.length?this:0!==this.size||this.__ownerID||1!==r.length?this.withMutations(function(e){for(var n=0;n=0&&r=0&&e Date: Tue, 18 Sep 2018 19:05:21 +0000 Subject: [PATCH 117/242] Deploy af28e9beb3b34859615a811dd1009bf56d19f258 to NPM branch --- dist/immutable.es.js | 9 ++++++-- dist/immutable.js | 9 ++++++-- dist/immutable.min.js | 52 +++++++++++++++++++++---------------------- 3 files changed, 40 insertions(+), 30 deletions(-) diff --git a/dist/immutable.es.js b/dist/immutable.es.js index 12b6572d20..3c6750865f 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -2070,6 +2070,9 @@ function mergeWith(merger) { var iters = [], len = arguments.length - 1; while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; + if (typeof merger !== 'function') { + throw new TypeError('Invalid merger function: ' + merger); + } return mergeIntoKeyedWith(this, iters, merger); } @@ -2149,9 +2152,11 @@ function mergeWithSources(collection, sources, merger) { ); } if (isImmutable(collection)) { - return collection.mergeWith + return typeof merger === 'function' && collection.mergeWith ? collection.mergeWith.apply(collection, [ merger ].concat( sources )) - : collection.concat.apply(collection, sources); + : collection.merge + ? collection.merge.apply(collection, sources) + : collection.concat.apply(collection, sources); } var isArray = Array.isArray(collection); var merged = collection; diff --git a/dist/immutable.js b/dist/immutable.js index 393c127fcc..4a688e0352 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -2076,6 +2076,9 @@ var iters = [], len = arguments.length - 1; while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; + if (typeof merger !== 'function') { + throw new TypeError('Invalid merger function: ' + merger); + } return mergeIntoKeyedWith(this, iters, merger); } @@ -2155,9 +2158,11 @@ ); } if (isImmutable(collection)) { - return collection.mergeWith + return typeof merger === 'function' && collection.mergeWith ? collection.mergeWith.apply(collection, [ merger ].concat( sources )) - : collection.concat.apply(collection, sources); + : collection.merge + ? collection.merge.apply(collection, sources) + : collection.concat.apply(collection, sources); } var isArray = Array.isArray(collection); var merged = collection; diff --git a/dist/immutable.min.js b/dist/immutable.min.js index 99e9d43e4e..68a1229731 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -10,29 +10,29 @@ function C(t){if(t&&t.nodeType>0)switch(t.nodeType){case 1:return t.uniqueID;cas i.__iterateUncached=function(i,o){var u=this,s=0;return t.__iterate(function(t,o,a){if(r.call(e,t,o,a))return s++,i(t,n?o:s-1,u)},o),s},i.__iteratorUncached=function(i,o){var u=t.__iterator(Se,o),s=0;return new Ee(function(){for(;;){var o=u.next();if(o.done)return o;var a=o.value,c=a[0],f=a[1];if(r.call(e,f,c,t))return w(i,n?c:s++,f,o)}})},i}function J(t,r,e){var n=Ze().asMutable();return t.__iterate(function(i,o){n.update(r.call(e,i,o,t),0,function(t){return t+1})}),n.asImmutable()}function H(t,r,e){var n=l(t),i=(d(t)?gn():Ze()).asMutable();t.__iterate(function(o,u){i.update(r.call(e,o,u,t),function(t){return t=t||[],t.push(n?[u,o]:o),t})});var o=ot(t);return i.map(function(r){return nt(t,o(r))})}function V(t,r,e,n){var i=t.size;if(s(r,e,i))return t;var u=a(r,i),f=c(e,i);if(u!==u||f!==f)return V(t.toSeq().cacheResult(),r,e,n);var h,p=f-u;p===p&&(h=p<0?0:p);var _=ut(t);return _.size=0===h?h:t.size&&h||void 0,!n&&q(t)&&h>=0&&(_.get=function(r,e){return r=o(this,r),r>=0&&rh)return z();var t=i.next();return n||r===ze||t.done?t:r===we?w(r,s-1,void 0,t):w(r,s-1,t.value[1],t)})},_}function Y(t,r,e){var n=ut(t);return n.__iterateUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterate(n,i);var u=0;return t.__iterate(function(t,i,s){return r.call(e,t,i,s)&&++u&&n(t,i,o)}),u},n.__iteratorUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterator(n,i);var u=t.__iterator(Se,i),s=!0;return new Ee(function(){if(!s)return z();var t=u.next();if(t.done)return t;var i=t.value,a=i[0],c=i[1];return r.call(e,c,a,o)?n===Se?t:w(n,a,c,t):(s=!1,z())})},n} function Q(t,r,e,n){var i=ut(t);return i.__iterateUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterate(i,o);var s=!0,a=0;return t.__iterate(function(t,o,c){if(!s||!(s=r.call(e,t,o,c)))return a++,i(t,n?o:a-1,u)}),a},i.__iteratorUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterator(i,o);var s=t.__iterator(Se,o),a=!0,c=0;return new Ee(function(){var t,o,f;do{if(t=s.next(),t.done)return n||i===ze?t:i===we?w(i,c++,void 0,t):w(i,c++,t.value[1],t);var h=t.value;o=h[0],f=h[1],a&&(a=r.call(e,f,o,u))}while(a);return i===Se?t:w(i,o,f,t)})},i}function X(t,r){var e=l(t),n=[t].concat(r).map(function(t){return _(t)?e&&(t=de(t)):t=e?D(t):A(Array.isArray(t)?t:[t]),t}).filter(function(t){return 0!==t.size});if(0===n.length)return t;if(1===n.length){var i=n[0];if(i===t||e&&l(i)||v(t)&&v(i))return i}var o=new ke(n);return e?o=o.toKeyedSeq():v(t)||(o=o.toSetSeq()),o=o.flatten(!0),o.size=n.reduce(function(t,r){if(void 0!==t){var e=r.size;if(void 0!==e)return t+e}},0),o}function F(t,r,e){var n=ut(t);return n.__iterateUncached=function(i,o){function u(t,c){t.__iterate(function(t,o){return(!r||c0}function et(t,r,e,n){var i=ut(t),o=new ke(e).map(function(t){return t.size});return i.size=n?o.max():o.min(),i.__iterate=function(t,r){for(var e,n=this,i=this.__iterator(ze,r),o=0;!(e=i.next()).done&&t(e.value,o++,n)!==!1;);return o},i.__iteratorUncached=function(t,i){var o=e.map(function(t){return t=ye(t),b(i?t.reverse():t)}),u=0,s=!1;return new Ee(function(){var e;return s||(e=o.map(function(t){return t.next()}),s=n?e.every(function(t){return t.done}):e.some(function(t){return t.done})),s?z():w(t,u++,r.apply(null,e.map(function(t){return t.value})))})},i}function nt(t,r){return t===r?t:q(t)?r:t.constructor(r)}function it(t){if(t!==Object(t))throw new TypeError("Expected [K, V] tuple: "+t)}function ot(t){return l(t)?de:v(t)?ge:me}function ut(t){return Object.create((l(t)?De:v(t)?Ae:xe).prototype)}function st(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size,this):Me.prototype.cacheResult.call(this)}function at(t,r){return void 0===t&&void 0===r?0:void 0===t?1:void 0===r?-1:t>r?1:t0;)r[e]=arguments[e+1];return jt(this,r,t)}function jt(t,r,e){ -for(var n=[],i=0;i0;)r[e]=arguments[e+1];return Lt(t,r)}function Rt(t,r){for(var e=[],n=arguments.length-2;n-- >0;)e[n]=arguments[n+2];return Lt(r,e,t)}function Ut(t){for(var r=[],e=arguments.length-1;e-- >0;)r[e]=arguments[e+1];return Tt(t,r)}function Kt(t,r){for(var e=[],n=arguments.length-2;n-- >0;)e[n]=arguments[n+2];return Tt(r,e,t)}function Tt(t,r,e){return Lt(t,r,Ct(e))}function Lt(t,r,e){if(!lt(t))throw new TypeError("Cannot merge into non-data-structure value: "+t);if(p(t))return t.mergeWith?t.mergeWith.apply(t,[e].concat(r)):t.concat.apply(t,r);for(var n=Array.isArray(t),i=t,o=n?ge:de,u=n?function(r){i===t&&(i=gt(i)),i.push(r)}:function(r,n){var o=qe.call(i,n),u=o&&e?e(i[n],r,n):r;o&&u===i[n]||(i===t&&(i=gt(i)),i[n]=u)},s=0;s0;)r[e]=arguments[e+1];return Tt(this,r,t)}function Nt(t){for(var r=[],e=arguments.length-1;e-- >0;)r[e]=arguments[e+1];return zt(this,t,Zt(),function(t){return Lt(t,r)})}function Pt(t){for(var r=[],e=arguments.length-1;e-- >0;)r[e]=arguments[e+1];return zt(this,t,Zt(),function(t){return Tt(t,r)})}function Jt(t){var r=this.asMutable();return t(r),r.wasAltered()?r.__ensureOwner(this.__ownerID):this}function Ht(){return this.__ownerID?this:this.__ensureOwner(new n)}function Vt(){return this.__ensureOwner()}function Yt(){return this.__altered}function Qt(t){return!(!t||!t[$e])}function Xt(t,r){return w(t,r[0],r[1])}function Ft(t,r){return{node:t,index:0,__prev:r}} -function Gt(t,r,e,n){var i=Object.create(tn);return i.size=t,i._root=r,i.__ownerID=e,i.__hash=n,i.__altered=!1,i}function Zt(){return sn||(sn=Gt(0))}function $t(t,e,n){var i,o;if(t._root){var u=r(ce),s=r(fe);if(i=tr(t._root,t.__ownerID,0,void 0,e,n,u,s),!s.value)return t;o=t.size+(u.value?n===ae?-1:1:0)}else{if(n===ae)return t;o=1,i=new rn(t.__ownerID,[[e,n]])}return t.__ownerID?(t.size=o,t._root=i,t.__hash=void 0,t.__altered=!0,t):i?Gt(o,i):Zt()}function tr(t,r,n,i,o,u,s,a){return t?t.update(r,n,i,o,u,s,a):u===ae?t:(e(a),e(s),new un(r,i,[o,u]))}function rr(t){return t.constructor===un||t.constructor===on}function er(t,r,e,n,i){if(t.keyHash===n)return new on(r,n,[t.entry,i]);var o,u=(0===e?t.keyHash:t.keyHash>>>e)&se,s=(0===e?n:n>>>e)&se;return new en(r,1<>>=1)u[s]=1&e?r[o++]:void 0;return u[n]=i,new nn(t,o+1,u)}function ur(t){return t-=t>>1&1431655765,t=(858993459&t)+(t>>2&858993459),t=t+(t>>4)&252645135,t+=t>>8,127&(t+=t>>16)}function sr(t,r,e,n){var i=n?t:ct(t);return i[r]=e,i}function ar(t,r,e,n){var i=t.length+1;if(n&&r+1===i)return t[r]=e,t;for(var o=Array(i),u=0,s=0;so?0:o-e,c=u-e;return c>ue&&(c=ue),function(){if(i===c)return dn;var t=r?--c:i++;return n&&n[t]}}function i(t,n,i){var s,a=t&&t.array,c=i>o?0:o-i>>n,f=1+(u-i>>n);return f>ue&&(f=ue),function(){for(;;){ -if(s){var t=s();if(t!==dn)return t;s=null}if(c===f)return dn;var o=r?--f:c++;s=e(a&&a[o],n-oe,i+(o<=t.size||e<0)return t.withMutations(function(t){e<0?gr(t,e).set(0,n):gr(t,0,e+1).set(e,n)});e+=t._origin;var i=t._tail,u=t._root,s=r(fe);return e>=mr(t._capacity)?i=vr(i,t.__ownerID,0,e,n,s):u=vr(u,t.__ownerID,t._level,e,n,s),s.value?t.__ownerID?(t._root=u,t._tail=i,t.__hash=void 0,t.__altered=!0,t):pr(t._origin,t._capacity,t._level,u,i):t}function vr(t,r,n,i,o,u){var s=i>>>n&se,a=t&&s0){var f=t&&t.array[s],h=vr(f,r,n-oe,i,o,u);return h===f?t:(c=yr(t,r),c.array[s]=h,c)}return a&&t.array[s]===o?t:(e(u),c=yr(t,r),void 0===o&&s===c.array.length-1?c.array.pop():c.array[s]=o,c)}function yr(t,r){return r&&t&&r===t.ownerID?t:new vn(t?t.array.slice():[],r)}function dr(t,r){if(r>=mr(t._capacity))return t._tail;if(r<1<0;)e=e.array[r>>>n&se],n-=oe;return e}}function gr(t,r,e){void 0!==r&&(r|=0),void 0!==e&&(e|=0);var i=t.__ownerID||new n,o=t._origin,u=t._capacity,s=o+r,a=void 0===e?u:e<0?u+e:o+e;if(s===o&&a===u)return t;if(s>=a)return t.clear();for(var c=t._level,f=t._root,h=0;s+h<0;)f=new vn(f&&f.array.length?[void 0,f]:[],i),c+=oe,h+=1<=1<p?new vn([],i):l;if(l&&_>p&&soe;d-=oe){var g=p>>>d&se;y=y.array[g]=yr(y.array[g],i)}y.array[p>>>oe&se]=l}if(a=_)s-=_,a-=_,c=oe,f=null,v=v&&v.removeBefore(i,0,s);else if(s>o||_>>c&se;if(m!==_>>>c&se)break -;m&&(h+=(1<o&&(f=f.removeBefore(i,c,s-h)),f&&_>>oe<=ue&&u.size>=2*o.size?(i=u.filter(function(t,r){return void 0!==t&&s!==r}),n=i.toKeyedSeq().map(function(t){return t[0]}).flip().toMap(),t.__ownerID&&(n.__ownerID=i.__ownerID=t.__ownerID)):(n=o.remove(r),i=s===u.size-1?u.pop():u.set(s,void 0))}else if(a){if(e===u.get(s)[1])return t;n=o,i=u.set(s,[r,e])}else n=o.set(r,u.size),i=u.set(u.size,[r,e]);return t.__ownerID?(t.size=n.size,t._map=n,t._list=i,t.__hash=void 0,t):zr(n,i)}function br(t){return!(!t||!t[zn])}function Or(t,r,e,n){var i=Object.create(Sn);return i.size=t,i._head=r,i.__ownerID=e,i.__hash=n,i.__altered=!1,i}function Er(){return In||(In=Or(0))}function qr(t,r){if(t===r)return!0;if(!_(r)||void 0!==t.size&&void 0!==r.size&&t.size!==r.size||void 0!==t.__hash&&void 0!==r.__hash&&t.__hash!==r.__hash||l(t)!==l(r)||v(t)!==v(r)||d(t)!==d(r))return!1;if(0===t.size&&0===r.size)return!0;var e=!y(t);if(d(t)){var n=t.entries();return r.every(function(t,r){var i=n.next().value;return i&&k(i[1],t)&&(e||k(i[0],r))})&&n.next().done}var i=!1;if(void 0===t.size)if(void 0===r.size)"function"==typeof t.cacheResult&&t.cacheResult();else{i=!0;var o=t;t=r,r=o}var u=!0,s=r.__iterate(function(r,n){if(e?!t.has(r):i?!k(r,t.get(n,ae)):!k(t.get(n,ae),r))return u=!1,!1});return u&&t.size===s}function Mr(t,r){var e=function(e){t.prototype[e]=r[e]};return Object.keys(r).forEach(e),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(r).forEach(e),t}function Dr(t){ -return lt(t)?Me(t).map(Dr).toJSON():t}function Ar(t){return!(!t||!t[On])}function xr(t,r){return t.__ownerID?(t.size=r.size,t._map=r,t):r===t._map?t:0===r.size?t.__empty():t.__make(r)}function jr(t,r){var e=Object.create(En);return e.size=t?t.size:0,e._map=t,e.__ownerID=r,e}function kr(){return qn||(qn=jr(Zt()))}function Rr(t,r,e){for(var n=pt(r),i=0;i!==n.length;)if((t=dt(t,n[i++],ae))===ae)return e;return t}function Ur(t,r){return Rr(this,t,r)}function Kr(t,r){return Rr(t,r,ae)!==ae}function Tr(t){return Kr(this,t)}function Lr(){ht(this.size);var t={};return this.__iterate(function(r,e){t[e]=r}),t}function Cr(t,r,e,n,i,o){return ht(t.size),t.__iterate(function(t,o,u){i?(i=!1,e=t):e=r.call(n,e,t,o,u)},o),e}function Br(t,r){return r}function Wr(t,r){return[r,t]}function Nr(t){return function(){return!t.apply(this,arguments)}}function Pr(t){return function(){return-t.apply(this,arguments)}}function Jr(){return ct(arguments)}function Hr(t,r){return tr?-1:0}function Vr(t){if(t.size===1/0)return 0;var r=d(t),e=l(t),n=r?1:0;return Yr(t.__iterate(e?r?function(t,r){n=31*n+Qr(U(t),U(r))|0}:function(t,r){n=n+Qr(U(t),U(r))|0}:r?function(t){n=31*n+U(t)|0}:function(t){n=n+U(t)|0}),n)}function Yr(t,r){return r=Le(r,3432918353),r=Le(r<<15|r>>>-15,461845907),r=Le(r<<13|r>>>-13,5),r=(r+3864292196|0)^t,r=Le(r^r>>>16,2246822507),r=Le(r^r>>>13,3266489909),r=R(r^r>>>16)}function Qr(t,r){return t^r+2654435769+(t<<6)+(t>>2)|0}function Xr(t){return Ar(t)&&d(t)}function Fr(t,r){var e=Object.create(Rn);return e.size=t?t.size:0,e._map=t,e.__ownerID=r,e}function Gr(){return Un||(Un=Fr(Sr()))}function Zr(t,r,e){var n=Object.create(Object.getPrototypeOf(t));return n._values=r,n.__ownerID=e,n}function $r(t){return t._name||t.constructor.name||"Record"}function te(t){return D(t._keys.map(function(r){return[r,t.get(r)]}))}function re(t,r){try{Object.defineProperty(t,r,{get:function(){return this.get(r)},set:function(t){ft(this.__ownerID,"Cannot set on an immutable record."),this.set(r,t)}})}catch(t){}}function ee(t,r){ -return ne([],r||ie,t,"",r&&r.length>2?[]:void 0,{"":t})}function ne(t,r,e,n,i,o){var u=Array.isArray(e)?Ae:_t(e)?De:null;if(u){if(~t.indexOf(e))throw new TypeError("Cannot convert circular structure to Immutable");t.push(e),i&&""!==n&&i.push(n);var s=r.call(o,n,u(e).map(function(n,o){return ne(t,r,n,o,i,e)}),i&&i.slice());return t.pop(),i&&i.pop(),s}return e}function ie(t,r){return l(r)?r.toMap():r.toList()}var oe=5,ue=1<>>16)*n+e*(r>>>16)<<16>>>0)|0},Ce=Object.isExtensible,Be=function(){try{return Object.defineProperty({},"@",{}),!0}catch(t){return!1}}(),We="function"==typeof WeakMap;We&&(Ke=new WeakMap);var Ne=0,Pe="__immutablehash__";"function"==typeof Symbol&&(Pe=Symbol(Pe));var Je=16,He=255,Ve=0,Ye={},Qe=function(t){function r(t,r){this._iter=t,this._useKeys=r,this.size=t.size}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.prototype.get=function(t,r){return this._iter.get(t,r)},r.prototype.has=function(t){return this._iter.has(t)},r.prototype.valueSeq=function(){return this._iter.valueSeq()},r.prototype.reverse=function(){var t=this,r=N(this,!0) -;return this._useKeys||(r.valueSeq=function(){return t._iter.toSeq().reverse()}),r},r.prototype.map=function(t,r){var e=this,n=W(this,t,r);return this._useKeys||(n.valueSeq=function(){return e._iter.toSeq().map(t,r)}),n},r.prototype.__iterate=function(t,r){var e=this;return this._iter.__iterate(function(r,n){return t(r,n,e)},r)},r.prototype.__iterator=function(t,r){return this._iter.__iterator(t,r)},r}(De);Qe.prototype[le]=!0;var Xe=function(t){function r(t){this._iter=t,this.size=t.size}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.prototype.includes=function(t){return this._iter.includes(t)},r.prototype.__iterate=function(t,r){var e=this,n=0;return r&&i(this),this._iter.__iterate(function(i){return t(i,r?e.size-++n:n++,e)},r)},r.prototype.__iterator=function(t,r){var e=this,n=this._iter.__iterator(ze,r),o=0;return r&&i(this),new Ee(function(){var i=n.next();return i.done?i:w(t,r?e.size-++o:o++,i.value,i)})},r}(Ae),Fe=function(t){function r(t){this._iter=t,this.size=t.size}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.prototype.has=function(t){return this._iter.includes(t)},r.prototype.__iterate=function(t,r){var e=this;return this._iter.__iterate(function(r){return t(r,r,e)},r)},r.prototype.__iterator=function(t,r){var e=this._iter.__iterator(ze,r);return new Ee(function(){var r=e.next();return r.done?r:w(t,r.value,r.value,r)})},r}(xe),Ge=function(t){function r(t){this._iter=t,this.size=t.size}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.prototype.entrySeq=function(){return this._iter.toSeq()},r.prototype.__iterate=function(t,r){var e=this;return this._iter.__iterate(function(r){if(r){it(r);var n=_(r);return t(n?r.get(1):r[1],n?r.get(0):r[0],e)}},r)},r.prototype.__iterator=function(t,r){var e=this._iter.__iterator(ze,r);return new Ee(function(){for(;;){var r=e.next();if(r.done)return r;var n=r.value;if(n){it(n);var i=_(n) -;return w(t,i?n.get(0):n[0],i?n.get(1):n[1],r)}}})},r}(De);Xe.prototype.cacheResult=Qe.prototype.cacheResult=Fe.prototype.cacheResult=Ge.prototype.cacheResult=st;var Ze=function(t){function r(r){return null===r||void 0===r?Zt():Qt(r)&&!d(r)?r:Zt().withMutations(function(e){var n=t(r);ht(n.size),n.forEach(function(t,r){return e.set(r,t)})})}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.of=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return Zt().withMutations(function(r){for(var e=0;e=t.length)throw Error("Missing value for key: "+t[e]);r.set(t[e],t[e+1])}})},r.prototype.toString=function(){return this.__toString("Map {","}")},r.prototype.get=function(t,r){return this._root?this._root.get(0,void 0,t,r):r},r.prototype.set=function(t,r){return $t(this,t,r)},r.prototype.remove=function(t){return $t(this,t,ae)},r.prototype.deleteAll=function(t){var r=ye(t);return 0===r.size?this:this.withMutations(function(t){r.forEach(function(r){return t.remove(r)})})},r.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):Zt()},r.prototype.sort=function(t){return gn($(this,t))},r.prototype.sortBy=function(t,r){return gn($(this,r,t))},r.prototype.map=function(t,r){return this.withMutations(function(e){e.forEach(function(n,i){e.set(i,t.call(r,n,i,e))})})},r.prototype.__iterator=function(t,r){return new an(this,t,r)},r.prototype.__iterate=function(t,r){var e=this,n=0;return this._root&&this._root.iterate(function(r){return n++,t(r[1],r[0],e)},r),n},r.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Gt(this.size,this._root,t,this.__hash):0===this.size?Zt():(this.__ownerID=t,this.__altered=!1,this)},r}(de);Ze.isMap=Qt;var $e="@@__IMMUTABLE_MAP__@@",tn=Ze.prototype;tn[$e]=!0,tn.delete=tn.remove,tn.removeAll=tn.deleteAll,tn.setIn=bt,tn.removeIn=tn.deleteIn=Et,tn.update=Mt,tn.updateIn=Dt,tn.merge=tn.concat=At,tn.mergeWith=xt,tn.mergeDeep=Bt, -tn.mergeDeepWith=Wt,tn.mergeIn=Nt,tn.mergeDeepIn=Pt,tn.withMutations=Jt,tn.wasAltered=Yt,tn.asImmutable=Vt,tn["@@transducer/init"]=tn.asMutable=Ht,tn["@@transducer/step"]=function(t,r){return t.set(r[0],r[1])},tn["@@transducer/result"]=function(t){return t.asImmutable()};var rn=function(t,r){this.ownerID=t,this.entries=r};rn.prototype.get=function(t,r,e,n){for(var i=this.entries,o=0,u=i.length;o=cn)return nr(t,c,i,o);var _=t&&t===this.ownerID,l=_?c:ct(c);return p?a?f===h-1?l.pop():l[f]=l.pop():l[f]=[i,o]:l.push([i,o]),_?(this.entries=l,this):new rn(t,l)}};var en=function(t,r,e){this.ownerID=t,this.bitmap=r,this.nodes=e};en.prototype.get=function(t,r,e,n){void 0===r&&(r=U(e));var i=1<<((0===t?r:r>>>t)&se),o=this.bitmap;return 0==(o&i)?n:this.nodes[ur(o&i-1)].get(t+oe,r,e,n)},en.prototype.update=function(t,r,e,n,i,o,u){void 0===e&&(e=U(n));var s=(0===r?e:e>>>r)&se,a=1<=fn)return or(t,p,c,s,l);if(f&&!l&&2===p.length&&rr(p[1^h]))return p[1^h];if(f&&l&&1===p.length&&rr(l))return l;var v=t&&t===this.ownerID,y=f?l?c:c^a:c|a,d=f?l?sr(p,h,l,v):cr(p,h,v):ar(p,h,l,v);return v?(this.bitmap=y,this.nodes=d,this):new en(t,y,d)};var nn=function(t,r,e){this.ownerID=t,this.count=r,this.nodes=e};nn.prototype.get=function(t,r,e,n){void 0===r&&(r=U(e));var i=(0===t?r:r>>>t)&se,o=this.nodes[i];return o?o.get(t+oe,r,e,n):n},nn.prototype.update=function(t,r,e,n,i,o,u){void 0===e&&(e=U(n));var s=(0===r?e:e>>>r)&se,a=i===ae,c=this.nodes,f=c[s];if(a&&!f)return this;var h=tr(f,t,r+oe,e,n,i,o,u);if(h===f)return this;var p=this.count;if(f){if(!h&&--p0&&i=0&&t>>r&se;if(n>=this.array.length)return new vn([],t);var i,o=0===n;if(r>0){var u=this.array[n];if((i=u&&u.removeBefore(t,r-oe,e))===u&&o)return this}if(o&&!i)return this;var s=yr(this,t);if(!o)for(var a=0;a>>r&se;if(n>=this.array.length)return this;var i;if(r>0){var o=this.array[n];if((i=o&&o.removeAfter(t,r-oe,e))===o&&n===this.array.length-1)return this}var u=yr(this,t);return u.array.splice(n+1),i&&(u.array[n]=i),u};var yn,dn={},gn=function(t){function r(t){return null===t||void 0===t?Sr():wr(t)?t:Sr().withMutations(function(r){var e=de(t);ht(e.size),e.forEach(function(t,e){return r.set(e,t)})})}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.of=function(){ -return this(arguments)},r.prototype.toString=function(){return this.__toString("OrderedMap {","}")},r.prototype.get=function(t,r){var e=this._map.get(t);return void 0!==e?this._list.get(e)[1]:r},r.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._map.clear(),this._list.clear(),this):Sr()},r.prototype.set=function(t,r){return Ir(this,t,r)},r.prototype.remove=function(t){return Ir(this,t,ae)},r.prototype.wasAltered=function(){return this._map.wasAltered()||this._list.wasAltered()},r.prototype.__iterate=function(t,r){var e=this;return this._list.__iterate(function(r){return r&&t(r[1],r[0],e)},r)},r.prototype.__iterator=function(t,r){return this._list.fromEntrySeq().__iterator(t,r)},r.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var r=this._map.__ensureOwner(t),e=this._list.__ensureOwner(t);return t?zr(r,e,t,this.__hash):0===this.size?Sr():(this.__ownerID=t,this._map=r,this._list=e,this)},r}(Ze);gn.isOrderedMap=wr,gn.prototype[le]=!0,gn.prototype.delete=gn.prototype.remove;var mn,wn=function(t){function r(t){return null===t||void 0===t?Er():br(t)?t:Er().pushAll(t)}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.of=function(){return this(arguments)},r.prototype.toString=function(){return this.__toString("Stack [","]")},r.prototype.get=function(t,r){var e=this._head;for(t=o(this,t);e&&t--;)e=e.next;return e?e.value:r},r.prototype.peek=function(){return this._head&&this._head.value},r.prototype.push=function(){var t=arguments;if(0===arguments.length)return this;for(var r=this.size+arguments.length,e=this._head,n=arguments.length-1;n>=0;n--)e={value:t[n],next:e};return this.__ownerID?(this.size=r,this._head=e,this.__hash=void 0,this.__altered=!0,this):Or(r,e)},r.prototype.pushAll=function(r){if(r=t(r),0===r.size)return this;if(0===this.size&&br(r))return r;ht(r.size);var e=this.size,n=this._head;return r.__iterate(function(t){e++,n={value:t,next:n}},!0),this.__ownerID?(this.size=e,this._head=n,this.__hash=void 0, -this.__altered=!0,this):Or(e,n)},r.prototype.pop=function(){return this.slice(1)},r.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):Er()},r.prototype.slice=function(r,e){if(s(r,e,this.size))return this;var n=a(r,this.size);if(c(e,this.size)!==this.size)return t.prototype.slice.call(this,r,e);for(var i=this.size-n,o=this._head;n--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):Or(i,o)},r.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Or(this.size,this._head,t,this.__hash):0===this.size?Er():(this.__ownerID=t,this.__altered=!1,this)},r.prototype.__iterate=function(t,r){var e=this;if(r)return new ke(this.toArray()).__iterate(function(r,n){return t(r,n,e)},r);for(var n=0,i=this._head;i&&t(i.value,n++,e)!==!1;)i=i.next;return n},r.prototype.__iterator=function(t,r){if(r)return new ke(this.toArray()).__iterator(t,r);var e=0,n=this._head;return new Ee(function(){if(n){var r=n.value;return n=n.next,w(t,e++,r)}return z()})},r}(ge);wn.isStack=br;var zn="@@__IMMUTABLE_STACK__@@",Sn=wn.prototype;Sn[zn]=!0,Sn.shift=Sn.pop,Sn.unshift=Sn.push,Sn.unshiftAll=Sn.pushAll,Sn.withMutations=Jt,Sn.wasAltered=Yt,Sn.asImmutable=Vt,Sn["@@transducer/init"]=Sn.asMutable=Ht,Sn["@@transducer/step"]=function(t,r){return t.unshift(r)},Sn["@@transducer/result"]=function(t){return t.asImmutable()};var In,bn=function(t){function r(r){return null===r||void 0===r?kr():Ar(r)&&!d(r)?r:kr().withMutations(function(e){var n=t(r);ht(n.size),n.forEach(function(t){return e.add(t)})})}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.of=function(){return this(arguments)},r.fromKeys=function(t){return this(de(t).keySeq())},r.intersect=function(t){return t=ye(t).toArray(),t.length?En.intersect.apply(r(t.pop()),t):kr()},r.union=function(t){return t=ye(t).toArray(),t.length?En.union.apply(r(t.pop()),t):kr()},r.prototype.toString=function(){ -return this.__toString("Set {","}")},r.prototype.has=function(t){return this._map.has(t)},r.prototype.add=function(t){return xr(this,this._map.set(t,t))},r.prototype.remove=function(t){return xr(this,this._map.remove(t))},r.prototype.clear=function(){return xr(this,this._map.clear())},r.prototype.map=function(t,r){var e=this;return xr(this,this._map.map(function(r){return t(r,r,e)},r))},r.prototype.union=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];return r=r.filter(function(t){return 0!==t.size}),0===r.length?this:0!==this.size||this.__ownerID||1!==r.length?this.withMutations(function(e){for(var n=0;n=0&&r=0&&ethis.size?r:this.find(function(r,e){return e===t},void 0,r)},has:function(t){ -return(t=o(this,t))>=0&&(void 0!==this.size?this.size===1/0||t0;)r[e]=arguments[e+1] +;if("function"!=typeof t)throw new TypeError("Invalid merger function: "+t);return jt(this,r,t)}function jt(t,r,e){for(var n=[],i=0;i0;)r[e]=arguments[e+1];return Lt(t,r)}function Rt(t,r){for(var e=[],n=arguments.length-2;n-- >0;)e[n]=arguments[n+2];return Lt(r,e,t)}function Ut(t){for(var r=[],e=arguments.length-1;e-- >0;)r[e]=arguments[e+1];return Tt(t,r)}function Kt(t,r){for(var e=[],n=arguments.length-2;n-- >0;)e[n]=arguments[n+2];return Tt(r,e,t)}function Tt(t,r,e){return Lt(t,r,Ct(e))}function Lt(t,r,e){if(!lt(t))throw new TypeError("Cannot merge into non-data-structure value: "+t);if(p(t))return"function"==typeof e&&t.mergeWith?t.mergeWith.apply(t,[e].concat(r)):t.merge?t.merge.apply(t,r):t.concat.apply(t,r);for(var n=Array.isArray(t),i=t,o=n?ge:de,u=n?function(r){i===t&&(i=gt(i)),i.push(r)}:function(r,n){var o=qe.call(i,n),u=o&&e?e(i[n],r,n):r;o&&u===i[n]||(i===t&&(i=gt(i)),i[n]=u)},s=0;s0;)r[e]=arguments[e+1];return Tt(this,r,t)}function Nt(t){for(var r=[],e=arguments.length-1;e-- >0;)r[e]=arguments[e+1];return zt(this,t,Zt(),function(t){return Lt(t,r)})}function Pt(t){for(var r=[],e=arguments.length-1;e-- >0;)r[e]=arguments[e+1];return zt(this,t,Zt(),function(t){return Tt(t,r)})}function Jt(t){var r=this.asMutable();return t(r),r.wasAltered()?r.__ensureOwner(this.__ownerID):this}function Ht(){return this.__ownerID?this:this.__ensureOwner(new n)}function Vt(){return this.__ensureOwner() +}function Yt(){return this.__altered}function Qt(t){return!(!t||!t[$e])}function Xt(t,r){return w(t,r[0],r[1])}function Ft(t,r){return{node:t,index:0,__prev:r}}function Gt(t,r,e,n){var i=Object.create(tn);return i.size=t,i._root=r,i.__ownerID=e,i.__hash=n,i.__altered=!1,i}function Zt(){return sn||(sn=Gt(0))}function $t(t,e,n){var i,o;if(t._root){var u=r(ce),s=r(fe);if(i=tr(t._root,t.__ownerID,0,void 0,e,n,u,s),!s.value)return t;o=t.size+(u.value?n===ae?-1:1:0)}else{if(n===ae)return t;o=1,i=new rn(t.__ownerID,[[e,n]])}return t.__ownerID?(t.size=o,t._root=i,t.__hash=void 0,t.__altered=!0,t):i?Gt(o,i):Zt()}function tr(t,r,n,i,o,u,s,a){return t?t.update(r,n,i,o,u,s,a):u===ae?t:(e(a),e(s),new un(r,i,[o,u]))}function rr(t){return t.constructor===un||t.constructor===on}function er(t,r,e,n,i){if(t.keyHash===n)return new on(r,n,[t.entry,i]);var o,u=(0===e?t.keyHash:t.keyHash>>>e)&se,s=(0===e?n:n>>>e)&se;return new en(r,1<>>=1)u[s]=1&e?r[o++]:void 0;return u[n]=i,new nn(t,o+1,u)}function ur(t){return t-=t>>1&1431655765,t=(858993459&t)+(t>>2&858993459),t=t+(t>>4)&252645135,t+=t>>8,127&(t+=t>>16)}function sr(t,r,e,n){var i=n?t:ct(t);return i[r]=e,i}function ar(t,r,e,n){var i=t.length+1;if(n&&r+1===i)return t[r]=e,t;for(var o=Array(i),u=0,s=0;so?0:o-e,c=u-e;return c>ue&&(c=ue), +function(){if(i===c)return dn;var t=r?--c:i++;return n&&n[t]}}function i(t,n,i){var s,a=t&&t.array,c=i>o?0:o-i>>n,f=1+(u-i>>n);return f>ue&&(f=ue),function(){for(;;){if(s){var t=s();if(t!==dn)return t;s=null}if(c===f)return dn;var o=r?--f:c++;s=e(a&&a[o],n-oe,i+(o<=t.size||e<0)return t.withMutations(function(t){e<0?gr(t,e).set(0,n):gr(t,0,e+1).set(e,n)});e+=t._origin;var i=t._tail,u=t._root,s=r(fe);return e>=mr(t._capacity)?i=vr(i,t.__ownerID,0,e,n,s):u=vr(u,t.__ownerID,t._level,e,n,s),s.value?t.__ownerID?(t._root=u,t._tail=i,t.__hash=void 0,t.__altered=!0,t):pr(t._origin,t._capacity,t._level,u,i):t}function vr(t,r,n,i,o,u){var s=i>>>n&se,a=t&&s0){var f=t&&t.array[s],h=vr(f,r,n-oe,i,o,u);return h===f?t:(c=yr(t,r),c.array[s]=h,c)}return a&&t.array[s]===o?t:(e(u),c=yr(t,r),void 0===o&&s===c.array.length-1?c.array.pop():c.array[s]=o,c)}function yr(t,r){return r&&t&&r===t.ownerID?t:new vn(t?t.array.slice():[],r)}function dr(t,r){if(r>=mr(t._capacity))return t._tail;if(r<1<0;)e=e.array[r>>>n&se],n-=oe;return e}}function gr(t,r,e){void 0!==r&&(r|=0),void 0!==e&&(e|=0);var i=t.__ownerID||new n,o=t._origin,u=t._capacity,s=o+r,a=void 0===e?u:e<0?u+e:o+e;if(s===o&&a===u)return t;if(s>=a)return t.clear();for(var c=t._level,f=t._root,h=0;s+h<0;)f=new vn(f&&f.array.length?[void 0,f]:[],i),c+=oe,h+=1<=1<p?new vn([],i):l;if(l&&_>p&&soe;d-=oe){var g=p>>>d&se;y=y.array[g]=yr(y.array[g],i)}y.array[p>>>oe&se]=l} +if(a=_)s-=_,a-=_,c=oe,f=null,v=v&&v.removeBefore(i,0,s);else if(s>o||_>>c&se;if(m!==_>>>c&se)break;m&&(h+=(1<o&&(f=f.removeBefore(i,c,s-h)),f&&_>>oe<=ue&&u.size>=2*o.size?(i=u.filter(function(t,r){return void 0!==t&&s!==r}),n=i.toKeyedSeq().map(function(t){return t[0]}).flip().toMap(),t.__ownerID&&(n.__ownerID=i.__ownerID=t.__ownerID)):(n=o.remove(r),i=s===u.size-1?u.pop():u.set(s,void 0))}else if(a){if(e===u.get(s)[1])return t;n=o,i=u.set(s,[r,e])}else n=o.set(r,u.size),i=u.set(u.size,[r,e]);return t.__ownerID?(t.size=n.size,t._map=n,t._list=i,t.__hash=void 0,t):zr(n,i)}function br(t){return!(!t||!t[zn])}function Or(t,r,e,n){var i=Object.create(Sn);return i.size=t,i._head=r,i.__ownerID=e,i.__hash=n,i.__altered=!1,i}function Er(){return In||(In=Or(0))}function qr(t,r){if(t===r)return!0;if(!_(r)||void 0!==t.size&&void 0!==r.size&&t.size!==r.size||void 0!==t.__hash&&void 0!==r.__hash&&t.__hash!==r.__hash||l(t)!==l(r)||v(t)!==v(r)||d(t)!==d(r))return!1;if(0===t.size&&0===r.size)return!0;var e=!y(t);if(d(t)){var n=t.entries();return r.every(function(t,r){var i=n.next().value;return i&&k(i[1],t)&&(e||k(i[0],r))})&&n.next().done}var i=!1;if(void 0===t.size)if(void 0===r.size)"function"==typeof t.cacheResult&&t.cacheResult();else{i=!0;var o=t;t=r,r=o}var u=!0,s=r.__iterate(function(r,n){if(e?!t.has(r):i?!k(r,t.get(n,ae)):!k(t.get(n,ae),r))return u=!1,!1});return u&&t.size===s}function Mr(t,r){var e=function(e){ +t.prototype[e]=r[e]};return Object.keys(r).forEach(e),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(r).forEach(e),t}function Dr(t){return lt(t)?Me(t).map(Dr).toJSON():t}function Ar(t){return!(!t||!t[On])}function xr(t,r){return t.__ownerID?(t.size=r.size,t._map=r,t):r===t._map?t:0===r.size?t.__empty():t.__make(r)}function jr(t,r){var e=Object.create(En);return e.size=t?t.size:0,e._map=t,e.__ownerID=r,e}function kr(){return qn||(qn=jr(Zt()))}function Rr(t,r,e){for(var n=pt(r),i=0;i!==n.length;)if((t=dt(t,n[i++],ae))===ae)return e;return t}function Ur(t,r){return Rr(this,t,r)}function Kr(t,r){return Rr(t,r,ae)!==ae}function Tr(t){return Kr(this,t)}function Lr(){ht(this.size);var t={};return this.__iterate(function(r,e){t[e]=r}),t}function Cr(t,r,e,n,i,o){return ht(t.size),t.__iterate(function(t,o,u){i?(i=!1,e=t):e=r.call(n,e,t,o,u)},o),e}function Br(t,r){return r}function Wr(t,r){return[r,t]}function Nr(t){return function(){return!t.apply(this,arguments)}}function Pr(t){return function(){return-t.apply(this,arguments)}}function Jr(){return ct(arguments)}function Hr(t,r){return tr?-1:0}function Vr(t){if(t.size===1/0)return 0;var r=d(t),e=l(t),n=r?1:0;return Yr(t.__iterate(e?r?function(t,r){n=31*n+Qr(U(t),U(r))|0}:function(t,r){n=n+Qr(U(t),U(r))|0}:r?function(t){n=31*n+U(t)|0}:function(t){n=n+U(t)|0}),n)}function Yr(t,r){return r=Le(r,3432918353),r=Le(r<<15|r>>>-15,461845907),r=Le(r<<13|r>>>-13,5),r=(r+3864292196|0)^t,r=Le(r^r>>>16,2246822507),r=Le(r^r>>>13,3266489909),r=R(r^r>>>16)}function Qr(t,r){return t^r+2654435769+(t<<6)+(t>>2)|0}function Xr(t){return Ar(t)&&d(t)}function Fr(t,r){var e=Object.create(Rn);return e.size=t?t.size:0,e._map=t,e.__ownerID=r,e}function Gr(){return Un||(Un=Fr(Sr()))}function Zr(t,r,e){var n=Object.create(Object.getPrototypeOf(t));return n._values=r,n.__ownerID=e,n}function $r(t){return t._name||t.constructor.name||"Record"}function te(t){return D(t._keys.map(function(r){return[r,t.get(r)]}))}function re(t,r){try{Object.defineProperty(t,r,{get:function(){ +return this.get(r)},set:function(t){ft(this.__ownerID,"Cannot set on an immutable record."),this.set(r,t)}})}catch(t){}}function ee(t,r){return ne([],r||ie,t,"",r&&r.length>2?[]:void 0,{"":t})}function ne(t,r,e,n,i,o){var u=Array.isArray(e)?Ae:_t(e)?De:null;if(u){if(~t.indexOf(e))throw new TypeError("Cannot convert circular structure to Immutable");t.push(e),i&&""!==n&&i.push(n);var s=r.call(o,n,u(e).map(function(n,o){return ne(t,r,n,o,i,e)}),i&&i.slice());return t.pop(),i&&i.pop(),s}return e}function ie(t,r){return l(r)?r.toMap():r.toList()}var oe=5,ue=1<>>16)*n+e*(r>>>16)<<16>>>0)|0},Ce=Object.isExtensible,Be=function(){try{return Object.defineProperty({},"@",{}),!0}catch(t){return!1}}(),We="function"==typeof WeakMap;We&&(Ke=new WeakMap);var Ne=0,Pe="__immutablehash__";"function"==typeof Symbol&&(Pe=Symbol(Pe));var Je=16,He=255,Ve=0,Ye={},Qe=function(t){function r(t,r){this._iter=t,this._useKeys=r,this.size=t.size}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.prototype.get=function(t,r){return this._iter.get(t,r)},r.prototype.has=function(t){ +return this._iter.has(t)},r.prototype.valueSeq=function(){return this._iter.valueSeq()},r.prototype.reverse=function(){var t=this,r=N(this,!0);return this._useKeys||(r.valueSeq=function(){return t._iter.toSeq().reverse()}),r},r.prototype.map=function(t,r){var e=this,n=W(this,t,r);return this._useKeys||(n.valueSeq=function(){return e._iter.toSeq().map(t,r)}),n},r.prototype.__iterate=function(t,r){var e=this;return this._iter.__iterate(function(r,n){return t(r,n,e)},r)},r.prototype.__iterator=function(t,r){return this._iter.__iterator(t,r)},r}(De);Qe.prototype[le]=!0;var Xe=function(t){function r(t){this._iter=t,this.size=t.size}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.prototype.includes=function(t){return this._iter.includes(t)},r.prototype.__iterate=function(t,r){var e=this,n=0;return r&&i(this),this._iter.__iterate(function(i){return t(i,r?e.size-++n:n++,e)},r)},r.prototype.__iterator=function(t,r){var e=this,n=this._iter.__iterator(ze,r),o=0;return r&&i(this),new Ee(function(){var i=n.next();return i.done?i:w(t,r?e.size-++o:o++,i.value,i)})},r}(Ae),Fe=function(t){function r(t){this._iter=t,this.size=t.size}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.prototype.has=function(t){return this._iter.includes(t)},r.prototype.__iterate=function(t,r){var e=this;return this._iter.__iterate(function(r){return t(r,r,e)},r)},r.prototype.__iterator=function(t,r){var e=this._iter.__iterator(ze,r);return new Ee(function(){var r=e.next();return r.done?r:w(t,r.value,r.value,r)})},r}(xe),Ge=function(t){function r(t){this._iter=t,this.size=t.size}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.prototype.entrySeq=function(){return this._iter.toSeq()},r.prototype.__iterate=function(t,r){var e=this;return this._iter.__iterate(function(r){if(r){it(r);var n=_(r);return t(n?r.get(1):r[1],n?r.get(0):r[0],e)}},r)},r.prototype.__iterator=function(t,r){var e=this._iter.__iterator(ze,r) +;return new Ee(function(){for(;;){var r=e.next();if(r.done)return r;var n=r.value;if(n){it(n);var i=_(n);return w(t,i?n.get(0):n[0],i?n.get(1):n[1],r)}}})},r}(De);Xe.prototype.cacheResult=Qe.prototype.cacheResult=Fe.prototype.cacheResult=Ge.prototype.cacheResult=st;var Ze=function(t){function r(r){return null===r||void 0===r?Zt():Qt(r)&&!d(r)?r:Zt().withMutations(function(e){var n=t(r);ht(n.size),n.forEach(function(t,r){return e.set(r,t)})})}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.of=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return Zt().withMutations(function(r){for(var e=0;e=t.length)throw Error("Missing value for key: "+t[e]);r.set(t[e],t[e+1])}})},r.prototype.toString=function(){return this.__toString("Map {","}")},r.prototype.get=function(t,r){return this._root?this._root.get(0,void 0,t,r):r},r.prototype.set=function(t,r){return $t(this,t,r)},r.prototype.remove=function(t){return $t(this,t,ae)},r.prototype.deleteAll=function(t){var r=ye(t);return 0===r.size?this:this.withMutations(function(t){r.forEach(function(r){return t.remove(r)})})},r.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):Zt()},r.prototype.sort=function(t){return gn($(this,t))},r.prototype.sortBy=function(t,r){return gn($(this,r,t))},r.prototype.map=function(t,r){return this.withMutations(function(e){e.forEach(function(n,i){e.set(i,t.call(r,n,i,e))})})},r.prototype.__iterator=function(t,r){return new an(this,t,r)},r.prototype.__iterate=function(t,r){var e=this,n=0;return this._root&&this._root.iterate(function(r){return n++,t(r[1],r[0],e)},r),n},r.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Gt(this.size,this._root,t,this.__hash):0===this.size?Zt():(this.__ownerID=t,this.__altered=!1,this)},r}(de);Ze.isMap=Qt;var $e="@@__IMMUTABLE_MAP__@@",tn=Ze.prototype;tn[$e]=!0,tn.delete=tn.remove,tn.removeAll=tn.deleteAll,tn.setIn=bt, +tn.removeIn=tn.deleteIn=Et,tn.update=Mt,tn.updateIn=Dt,tn.merge=tn.concat=At,tn.mergeWith=xt,tn.mergeDeep=Bt,tn.mergeDeepWith=Wt,tn.mergeIn=Nt,tn.mergeDeepIn=Pt,tn.withMutations=Jt,tn.wasAltered=Yt,tn.asImmutable=Vt,tn["@@transducer/init"]=tn.asMutable=Ht,tn["@@transducer/step"]=function(t,r){return t.set(r[0],r[1])},tn["@@transducer/result"]=function(t){return t.asImmutable()};var rn=function(t,r){this.ownerID=t,this.entries=r};rn.prototype.get=function(t,r,e,n){for(var i=this.entries,o=0,u=i.length;o=cn)return nr(t,c,i,o);var _=t&&t===this.ownerID,l=_?c:ct(c);return p?a?f===h-1?l.pop():l[f]=l.pop():l[f]=[i,o]:l.push([i,o]),_?(this.entries=l,this):new rn(t,l)}};var en=function(t,r,e){this.ownerID=t,this.bitmap=r,this.nodes=e};en.prototype.get=function(t,r,e,n){void 0===r&&(r=U(e));var i=1<<((0===t?r:r>>>t)&se),o=this.bitmap;return 0==(o&i)?n:this.nodes[ur(o&i-1)].get(t+oe,r,e,n)},en.prototype.update=function(t,r,e,n,i,o,u){void 0===e&&(e=U(n));var s=(0===r?e:e>>>r)&se,a=1<=fn)return or(t,p,c,s,l);if(f&&!l&&2===p.length&&rr(p[1^h]))return p[1^h];if(f&&l&&1===p.length&&rr(l))return l;var v=t&&t===this.ownerID,y=f?l?c:c^a:c|a,d=f?l?sr(p,h,l,v):cr(p,h,v):ar(p,h,l,v);return v?(this.bitmap=y,this.nodes=d,this):new en(t,y,d)};var nn=function(t,r,e){this.ownerID=t,this.count=r,this.nodes=e};nn.prototype.get=function(t,r,e,n){void 0===r&&(r=U(e));var i=(0===t?r:r>>>t)&se,o=this.nodes[i];return o?o.get(t+oe,r,e,n):n},nn.prototype.update=function(t,r,e,n,i,o,u){void 0===e&&(e=U(n));var s=(0===r?e:e>>>r)&se,a=i===ae,c=this.nodes,f=c[s];if(a&&!f)return this;var h=tr(f,t,r+oe,e,n,i,o,u) +;if(h===f)return this;var p=this.count;if(f){if(!h&&--p0&&i=0&&t>>r&se;if(n>=this.array.length)return new vn([],t);var i,o=0===n;if(r>0){var u=this.array[n];if((i=u&&u.removeBefore(t,r-oe,e))===u&&o)return this}if(o&&!i)return this;var s=yr(this,t);if(!o)for(var a=0;a>>r&se;if(n>=this.array.length)return this;var i;if(r>0){var o=this.array[n];if((i=o&&o.removeAfter(t,r-oe,e))===o&&n===this.array.length-1)return this}var u=yr(this,t);return u.array.splice(n+1),i&&(u.array[n]=i),u};var yn,dn={},gn=function(t){function r(t){return null===t||void 0===t?Sr():wr(t)?t:Sr().withMutations(function(r){var e=de(t);ht(e.size),e.forEach(function(t,e){return r.set(e,t)})})}return t&&(r.__proto__=t), +r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.of=function(){return this(arguments)},r.prototype.toString=function(){return this.__toString("OrderedMap {","}")},r.prototype.get=function(t,r){var e=this._map.get(t);return void 0!==e?this._list.get(e)[1]:r},r.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._map.clear(),this._list.clear(),this):Sr()},r.prototype.set=function(t,r){return Ir(this,t,r)},r.prototype.remove=function(t){return Ir(this,t,ae)},r.prototype.wasAltered=function(){return this._map.wasAltered()||this._list.wasAltered()},r.prototype.__iterate=function(t,r){var e=this;return this._list.__iterate(function(r){return r&&t(r[1],r[0],e)},r)},r.prototype.__iterator=function(t,r){return this._list.fromEntrySeq().__iterator(t,r)},r.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var r=this._map.__ensureOwner(t),e=this._list.__ensureOwner(t);return t?zr(r,e,t,this.__hash):0===this.size?Sr():(this.__ownerID=t,this._map=r,this._list=e,this)},r}(Ze);gn.isOrderedMap=wr,gn.prototype[le]=!0,gn.prototype.delete=gn.prototype.remove;var mn,wn=function(t){function r(t){return null===t||void 0===t?Er():br(t)?t:Er().pushAll(t)}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.of=function(){return this(arguments)},r.prototype.toString=function(){return this.__toString("Stack [","]")},r.prototype.get=function(t,r){var e=this._head;for(t=o(this,t);e&&t--;)e=e.next;return e?e.value:r},r.prototype.peek=function(){return this._head&&this._head.value},r.prototype.push=function(){var t=arguments;if(0===arguments.length)return this;for(var r=this.size+arguments.length,e=this._head,n=arguments.length-1;n>=0;n--)e={value:t[n],next:e};return this.__ownerID?(this.size=r,this._head=e,this.__hash=void 0,this.__altered=!0,this):Or(r,e)},r.prototype.pushAll=function(r){if(r=t(r),0===r.size)return this;if(0===this.size&&br(r))return r;ht(r.size);var e=this.size,n=this._head;return r.__iterate(function(t){e++, +n={value:t,next:n}},!0),this.__ownerID?(this.size=e,this._head=n,this.__hash=void 0,this.__altered=!0,this):Or(e,n)},r.prototype.pop=function(){return this.slice(1)},r.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):Er()},r.prototype.slice=function(r,e){if(s(r,e,this.size))return this;var n=a(r,this.size);if(c(e,this.size)!==this.size)return t.prototype.slice.call(this,r,e);for(var i=this.size-n,o=this._head;n--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):Or(i,o)},r.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Or(this.size,this._head,t,this.__hash):0===this.size?Er():(this.__ownerID=t,this.__altered=!1,this)},r.prototype.__iterate=function(t,r){var e=this;if(r)return new ke(this.toArray()).__iterate(function(r,n){return t(r,n,e)},r);for(var n=0,i=this._head;i&&t(i.value,n++,e)!==!1;)i=i.next;return n},r.prototype.__iterator=function(t,r){if(r)return new ke(this.toArray()).__iterator(t,r);var e=0,n=this._head;return new Ee(function(){if(n){var r=n.value;return n=n.next,w(t,e++,r)}return z()})},r}(ge);wn.isStack=br;var zn="@@__IMMUTABLE_STACK__@@",Sn=wn.prototype;Sn[zn]=!0,Sn.shift=Sn.pop,Sn.unshift=Sn.push,Sn.unshiftAll=Sn.pushAll,Sn.withMutations=Jt,Sn.wasAltered=Yt,Sn.asImmutable=Vt,Sn["@@transducer/init"]=Sn.asMutable=Ht,Sn["@@transducer/step"]=function(t,r){return t.unshift(r)},Sn["@@transducer/result"]=function(t){return t.asImmutable()};var In,bn=function(t){function r(r){return null===r||void 0===r?kr():Ar(r)&&!d(r)?r:kr().withMutations(function(e){var n=t(r);ht(n.size),n.forEach(function(t){return e.add(t)})})}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.of=function(){return this(arguments)},r.fromKeys=function(t){return this(de(t).keySeq())},r.intersect=function(t){return t=ye(t).toArray(),t.length?En.intersect.apply(r(t.pop()),t):kr()},r.union=function(t){return t=ye(t).toArray(), +t.length?En.union.apply(r(t.pop()),t):kr()},r.prototype.toString=function(){return this.__toString("Set {","}")},r.prototype.has=function(t){return this._map.has(t)},r.prototype.add=function(t){return xr(this,this._map.set(t,t))},r.prototype.remove=function(t){return xr(this,this._map.remove(t))},r.prototype.clear=function(){return xr(this,this._map.clear())},r.prototype.map=function(t,r){var e=this;return xr(this,this._map.map(function(r){return t(r,r,e)},r))},r.prototype.union=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];return r=r.filter(function(t){return 0!==t.size}),0===r.length?this:0!==this.size||this.__ownerID||1!==r.length?this.withMutations(function(e){for(var n=0;n=0&&r=0&&ethis.size?r:this.find(function(r,e){return e===t},void 0,r)},has:function(t){return(t=o(this,t))>=0&&(void 0!==this.size?this.size===1/0||t Date: Tue, 18 Sep 2018 19:07:08 +0000 Subject: [PATCH 118/242] Deploy ca85e75aa595514199eeb325645ce2f582dc145d to NPM branch --- dist/immutable-nonambient.d.ts | 2 +- dist/immutable.d.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/immutable-nonambient.d.ts b/dist/immutable-nonambient.d.ts index 1eb58bfcce..d129c61d85 100644 --- a/dist/immutable-nonambient.d.ts +++ b/dist/immutable-nonambient.d.ts @@ -4807,7 +4807,7 @@ * two values are equivalent and is used to determine how to store those * values. Provided with any value, `hash()` will return a 31-bit integer. * - * When designing Objects which may be equal, it's important than when a + * When designing Objects which may be equal, it's important that when a * `.equals()` method returns true, that both values `.hashCode()` method * return the same value. `hash()` may be used to produce those values. * diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index b32785ccf7..bc0378e6f4 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -4807,7 +4807,7 @@ declare module Immutable { * two values are equivalent and is used to determine how to store those * values. Provided with any value, `hash()` will return a 31-bit integer. * - * When designing Objects which may be equal, it's important than when a + * When designing Objects which may be equal, it's important that when a * `.equals()` method returns true, that both values `.hashCode()` method * return the same value. `hash()` may be used to produce those values. * From dde1fbbfd6b085cf73ee92d4af165da7d9b7352e Mon Sep 17 00:00:00 2001 From: Travis CI Date: Tue, 18 Sep 2018 20:35:55 +0000 Subject: [PATCH 119/242] Deploy 43835aa4da6dfc32188bef8918a0541efcf2f9cc to NPM branch --- dist/immutable.es.js | 31 +++++++++++++++++++++------ dist/immutable.js | 31 +++++++++++++++++++++------ dist/immutable.min.js | 50 +++++++++++++++++++++---------------------- 3 files changed, 75 insertions(+), 37 deletions(-) diff --git a/dist/immutable.es.js b/dist/immutable.es.js index 3c6750865f..6aae02aac6 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -1879,7 +1879,10 @@ function isPlainObj(value) { * provided by Immutable.js or a plain Array or Object. */ function isDataStructure(value) { - return isImmutable(value) || Array.isArray(value) || isPlainObj(value); + return ( + typeof value === 'object' && + (isImmutable(value) || Array.isArray(value) || isPlainObj(value)) + ); } /** @@ -4173,11 +4176,27 @@ function mixin(ctor, methods) { } function toJS(value) { - return isDataStructure(value) - ? Seq(value) - .map(toJS) - .toJSON() - : value; + if (!value || typeof value !== 'object') { + return value; + } + if (!isCollection(value)) { + if (!isDataStructure(value)) { + return value; + } + value = Seq(value); + } + if (isKeyed(value)) { + var result$1 = {}; + value.__iterate(function (v, k) { + result$1[k] = toJS(v); + }); + return result$1; + } + var result = []; + value.__iterate(function (v) { + result.push(toJS(v)); + }); + return result; } var Set = (function (SetCollection$$1) { diff --git a/dist/immutable.js b/dist/immutable.js index 4a688e0352..30aa693160 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -1885,7 +1885,10 @@ * provided by Immutable.js or a plain Array or Object. */ function isDataStructure(value) { - return isImmutable(value) || Array.isArray(value) || isPlainObj(value); + return ( + typeof value === 'object' && + (isImmutable(value) || Array.isArray(value) || isPlainObj(value)) + ); } /** @@ -4179,11 +4182,27 @@ } function toJS(value) { - return isDataStructure(value) - ? Seq(value) - .map(toJS) - .toJSON() - : value; + if (!value || typeof value !== 'object') { + return value; + } + if (!isCollection(value)) { + if (!isDataStructure(value)) { + return value; + } + value = Seq(value); + } + if (isKeyed(value)) { + var result$1 = {}; + value.__iterate(function (v, k) { + result$1[k] = toJS(v); + }); + return result$1; + } + var result = []; + value.__iterate(function (v) { + result.push(toJS(v)); + }); + return result; } var Set = (function (SetCollection$$1) { diff --git a/dist/immutable.min.js b/dist/immutable.min.js index 68a1229731..7706e2fe7b 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -5,34 +5,34 @@ * LICENSE file in the root directory of this source tree. */ !function(t,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r(t.Immutable={})}(this,function(t){"use strict";function r(t){return t.value=!1,t}function e(t){t&&(t.value=!0)}function n(){}function i(t){return void 0===t.size&&(t.size=t.__iterate(u)),t.size}function o(t,r){if("number"!=typeof r){var e=r>>>0;if(""+e!==r||4294967295===e)return NaN;r=e}return r<0?i(t)+r:r}function u(){return!0}function s(t,r,e){return(0===t&&!h(t)||void 0!==e&&t<=-e)&&(void 0===r||void 0!==e&&r>=e)}function a(t,r){return f(t,r,0)}function c(t,r){return f(t,r,r)}function f(t,r,e){return void 0===t?e:h(t)?r===1/0?r:0|Math.max(0,r+t):void 0===r||r===t?t:0|Math.min(r,t)}function h(t){return t<0||0===t&&1/t==-(1/0)}function p(t){return _(t)||g(t)}function _(t){return!(!t||!t[he])}function l(t){return!(!t||!t[pe])}function v(t){return!(!t||!t[_e])}function y(t){return l(t)||v(t)}function d(t){return!(!t||!t[le])}function g(t){return!(!t||!t[ve])}function m(t){return!(!t||"function"!=typeof t.equals||"function"!=typeof t.hashCode)}function w(t,r,e,n){var i=0===t?r:1===t?e:[r,e];return n?n.value=i:n={value:i,done:!1},n}function z(){return{value:void 0,done:!0}}function S(t){return!!O(t)}function I(t){return t&&"function"==typeof t.next}function b(t){var r=O(t);return r&&r.call(t)}function O(t){var r=t&&(Ie&&t[Ie]||t[be]);if("function"==typeof r)return r}function E(t){return!(!Array.isArray(t)&&"string"!=typeof t)||t&&"object"==typeof t&&Number.isInteger(t.length)&&t.length>=0&&(0===t.length?1===Object.keys(t).length:t.hasOwnProperty(t.length-1))}function q(t){return!(!t||!t[je])}function M(){return Ue||(Ue=new ke([]))}function D(t){var r=Array.isArray(t)?new ke(t):S(t)?new Te(t):void 0;if(r)return r.fromEntrySeq();if("object"==typeof t)return new Re(t);throw new TypeError("Expected Array or collection object of [k, v] entries, or keyed object: "+t)}function A(t){var r=j(t);if(r)return r;throw new TypeError("Expected Array or collection object of values: "+t)} -function x(t){var r=j(t);if(r)return r;if("object"==typeof t)return new Re(t);throw new TypeError("Expected Array or collection object of values, or keyed object: "+t)}function j(t){return E(t)?new ke(t):S(t)?new Te(t):void 0}function k(t,r){if(t===r||t!==t&&r!==r)return!0;if(!t||!r)return!1;if("function"==typeof t.valueOf&&"function"==typeof r.valueOf){if(t=t.valueOf(),r=r.valueOf(),t===r||t!==t&&r!==r)return!0;if(!t||!r)return!1}return!!(m(t)&&m(r)&&t.equals(r))}function R(t){return t>>>1&1073741824|3221225471&t}function U(t){if(t===!1||null===t||void 0===t)return 0;if("function"==typeof t.valueOf&&((t=t.valueOf())===!1||null===t||void 0===t))return 0;if(t===!0)return 1;var r=typeof t;if("number"===r){if(t!==t||t===1/0)return 0;var e=0|t;for(e!==t&&(e^=4294967295*t);t>4294967295;)t/=4294967295,e^=t;return R(e)}if("string"===r)return t.length>Je?K(t):T(t);if("function"==typeof t.hashCode)return R(t.hashCode());if("object"===r||"function"===r)return L(t);if("function"==typeof t.toString)return T(""+t);throw Error("Value type "+r+" cannot be hashed.")}function K(t){var r=Ye[t];return void 0===r&&(r=T(t),Ve===He&&(Ve=0,Ye={}),Ve++,Ye[t]=r),r}function T(t){for(var r=0,e=0;e>>1&1073741824|3221225471&t}function U(t){if(t===!1||null===t||void 0===t)return 0;if("function"==typeof t.valueOf&&((t=t.valueOf())===!1||null===t||void 0===t))return 0;if(t===!0)return 1;var r=typeof t;if("number"===r){if(t!==t||t===1/0)return 0;var e=0|t;for(e!==t&&(e^=4294967295*t);t>4294967295;)t/=4294967295,e^=t;return R(e)}if("string"===r)return t.length>He?K(t):T(t);if("function"==typeof t.hashCode)return R(t.hashCode());if("object"===r||"function"===r)return L(t);if("function"==typeof t.toString)return T(""+t);throw Error("Value type "+r+" cannot be hashed.")}function K(t){var r=Ye[t];return void 0===r&&(r=T(t),Ve===Je&&(Ve=0,Ye={}),Ve++,Ye[t]=r),r}function T(t){for(var r=0,e=0;e0)switch(t.nodeType){case 1:return t.uniqueID;case 9:return t.documentElement&&t.documentElement.uniqueID}}function B(t){var r=ut(t);return r._iter=t,r.size=t.size,r.flip=function(){return t},r.reverse=function(){var r=t.reverse.apply(this);return r.flip=function(){return t.reverse()},r},r.has=function(r){return t.includes(r)},r.includes=function(r){return t.has(r)},r.cacheResult=st,r.__iterateUncached=function(r,e){var n=this;return t.__iterate(function(t,e){return r(e,t,n)!==!1},e)},r.__iteratorUncached=function(r,e){if(r===Se){var n=t.__iterator(r,e);return new Ee(function(){var t=n.next();if(!t.done){var r=t.value[0];t.value[0]=t.value[1],t.value[1]=r}return t})}return t.__iterator(r===ze?we:ze,e)},r}function W(t,r,e){var n=ut(t);return n.size=t.size,n.has=function(r){return t.has(r)},n.get=function(n,i){var o=t.get(n,ae);return o===ae?i:r.call(e,o,n,t)},n.__iterateUncached=function(n,i){var o=this;return t.__iterate(function(t,i,u){return n(r.call(e,t,i,u),i,o)!==!1},i)},n.__iteratorUncached=function(n,i){var o=t.__iterator(Se,i);return new Ee(function(){var i=o.next();if(i.done)return i;var u=i.value,s=u[0];return w(n,s,r.call(e,u[1],s,t),i)})},n}function N(t,r){var e=this,n=ut(t);return n._iter=t,n.size=t.size,n.reverse=function(){return t},t.flip&&(n.flip=function(){var r=B(t);return r.reverse=function(){return t.flip()},r}),n.get=function(e,n){return t.get(r?e:-1-e,n)},n.has=function(e){return t.has(r?e:-1-e)},n.includes=function(r){return t.includes(r)},n.cacheResult=st,n.__iterate=function(e,n){var o=this,u=0;return n&&i(t),t.__iterate(function(t,i){return e(t,r?i:n?o.size-++u:u++,o)},!n)},n.__iterator=function(n,o){var u=0;o&&i(t);var s=t.__iterator(Se,!o);return new Ee(function(){var t=s.next();if(t.done)return t;var i=t.value;return w(n,r?i[0]:o?e.size-++u:u++,i[1],t)})},n}function P(t,r,e,n){var i=ut(t);return n&&(i.has=function(n){var i=t.get(n,ae);return i!==ae&&!!r.call(e,i,n,t)},i.get=function(n,i){var o=t.get(n,ae);return o!==ae&&r.call(e,o,n,t)?o:i}), -i.__iterateUncached=function(i,o){var u=this,s=0;return t.__iterate(function(t,o,a){if(r.call(e,t,o,a))return s++,i(t,n?o:s-1,u)},o),s},i.__iteratorUncached=function(i,o){var u=t.__iterator(Se,o),s=0;return new Ee(function(){for(;;){var o=u.next();if(o.done)return o;var a=o.value,c=a[0],f=a[1];if(r.call(e,f,c,t))return w(i,n?c:s++,f,o)}})},i}function J(t,r,e){var n=Ze().asMutable();return t.__iterate(function(i,o){n.update(r.call(e,i,o,t),0,function(t){return t+1})}),n.asImmutable()}function H(t,r,e){var n=l(t),i=(d(t)?gn():Ze()).asMutable();t.__iterate(function(o,u){i.update(r.call(e,o,u,t),function(t){return t=t||[],t.push(n?[u,o]:o),t})});var o=ot(t);return i.map(function(r){return nt(t,o(r))})}function V(t,r,e,n){var i=t.size;if(s(r,e,i))return t;var u=a(r,i),f=c(e,i);if(u!==u||f!==f)return V(t.toSeq().cacheResult(),r,e,n);var h,p=f-u;p===p&&(h=p<0?0:p);var _=ut(t);return _.size=0===h?h:t.size&&h||void 0,!n&&q(t)&&h>=0&&(_.get=function(r,e){return r=o(this,r),r>=0&&rh)return z();var t=i.next();return n||r===ze||t.done?t:r===we?w(r,s-1,void 0,t):w(r,s-1,t.value[1],t)})},_}function Y(t,r,e){var n=ut(t);return n.__iterateUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterate(n,i);var u=0;return t.__iterate(function(t,i,s){return r.call(e,t,i,s)&&++u&&n(t,i,o)}),u},n.__iteratorUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterator(n,i);var u=t.__iterator(Se,i),s=!0;return new Ee(function(){if(!s)return z();var t=u.next();if(t.done)return t;var i=t.value,a=i[0],c=i[1];return r.call(e,c,a,o)?n===Se?t:w(n,a,c,t):(s=!1,z())})},n} +i.__iterateUncached=function(i,o){var u=this,s=0;return t.__iterate(function(t,o,a){if(r.call(e,t,o,a))return s++,i(t,n?o:s-1,u)},o),s},i.__iteratorUncached=function(i,o){var u=t.__iterator(Se,o),s=0;return new Ee(function(){for(;;){var o=u.next();if(o.done)return o;var a=o.value,c=a[0],f=a[1];if(r.call(e,f,c,t))return w(i,n?c:s++,f,o)}})},i}function H(t,r,e){var n=Ze().asMutable();return t.__iterate(function(i,o){n.update(r.call(e,i,o,t),0,function(t){return t+1})}),n.asImmutable()}function J(t,r,e){var n=l(t),i=(d(t)?gn():Ze()).asMutable();t.__iterate(function(o,u){i.update(r.call(e,o,u,t),function(t){return t=t||[],t.push(n?[u,o]:o),t})});var o=ot(t);return i.map(function(r){return nt(t,o(r))})}function V(t,r,e,n){var i=t.size;if(s(r,e,i))return t;var u=a(r,i),f=c(e,i);if(u!==u||f!==f)return V(t.toSeq().cacheResult(),r,e,n);var h,p=f-u;p===p&&(h=p<0?0:p);var _=ut(t);return _.size=0===h?h:t.size&&h||void 0,!n&&q(t)&&h>=0&&(_.get=function(r,e){return r=o(this,r),r>=0&&rh)return z();var t=i.next();return n||r===ze||t.done?t:r===we?w(r,s-1,void 0,t):w(r,s-1,t.value[1],t)})},_}function Y(t,r,e){var n=ut(t);return n.__iterateUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterate(n,i);var u=0;return t.__iterate(function(t,i,s){return r.call(e,t,i,s)&&++u&&n(t,i,o)}),u},n.__iteratorUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterator(n,i);var u=t.__iterator(Se,i),s=!0;return new Ee(function(){if(!s)return z();var t=u.next();if(t.done)return t;var i=t.value,a=i[0],c=i[1];return r.call(e,c,a,o)?n===Se?t:w(n,a,c,t):(s=!1,z())})},n} function Q(t,r,e,n){var i=ut(t);return i.__iterateUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterate(i,o);var s=!0,a=0;return t.__iterate(function(t,o,c){if(!s||!(s=r.call(e,t,o,c)))return a++,i(t,n?o:a-1,u)}),a},i.__iteratorUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterator(i,o);var s=t.__iterator(Se,o),a=!0,c=0;return new Ee(function(){var t,o,f;do{if(t=s.next(),t.done)return n||i===ze?t:i===we?w(i,c++,void 0,t):w(i,c++,t.value[1],t);var h=t.value;o=h[0],f=h[1],a&&(a=r.call(e,f,o,u))}while(a);return i===Se?t:w(i,o,f,t)})},i}function X(t,r){var e=l(t),n=[t].concat(r).map(function(t){return _(t)?e&&(t=de(t)):t=e?D(t):A(Array.isArray(t)?t:[t]),t}).filter(function(t){return 0!==t.size});if(0===n.length)return t;if(1===n.length){var i=n[0];if(i===t||e&&l(i)||v(t)&&v(i))return i}var o=new ke(n);return e?o=o.toKeyedSeq():v(t)||(o=o.toSetSeq()),o=o.flatten(!0),o.size=n.reduce(function(t,r){if(void 0!==t){var e=r.size;if(void 0!==e)return t+e}},0),o}function F(t,r,e){var n=ut(t);return n.__iterateUncached=function(i,o){function u(t,c){t.__iterate(function(t,o){return(!r||c0}function et(t,r,e,n){var i=ut(t),o=new ke(e).map(function(t){return t.size});return i.size=n?o.max():o.min(),i.__iterate=function(t,r){for(var e,n=this,i=this.__iterator(ze,r),o=0;!(e=i.next()).done&&t(e.value,o++,n)!==!1;);return o},i.__iteratorUncached=function(t,i){var o=e.map(function(t){return t=ye(t),b(i?t.reverse():t)}),u=0,s=!1;return new Ee(function(){var e;return s||(e=o.map(function(t){return t.next()}),s=n?e.every(function(t){return t.done}):e.some(function(t){return t.done})),s?z():w(t,u++,r.apply(null,e.map(function(t){return t.value})))})},i}function nt(t,r){return t===r?t:q(t)?r:t.constructor(r)}function it(t){if(t!==Object(t))throw new TypeError("Expected [K, V] tuple: "+t)}function ot(t){return l(t)?de:v(t)?ge:me}function ut(t){return Object.create((l(t)?De:v(t)?Ae:xe).prototype)}function st(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size,this):Me.prototype.cacheResult.call(this)}function at(t,r){return void 0===t&&void 0===r?0:void 0===t?1:void 0===r?-1:t>r?1:t0;)r[e]=arguments[e+1] -;if("function"!=typeof t)throw new TypeError("Invalid merger function: "+t);return jt(this,r,t)}function jt(t,r,e){for(var n=[],i=0;i0;)r[e]=arguments[e+1];return Lt(t,r)}function Rt(t,r){for(var e=[],n=arguments.length-2;n-- >0;)e[n]=arguments[n+2];return Lt(r,e,t)}function Ut(t){for(var r=[],e=arguments.length-1;e-- >0;)r[e]=arguments[e+1];return Tt(t,r)}function Kt(t,r){for(var e=[],n=arguments.length-2;n-- >0;)e[n]=arguments[n+2];return Tt(r,e,t)}function Tt(t,r,e){return Lt(t,r,Ct(e))}function Lt(t,r,e){if(!lt(t))throw new TypeError("Cannot merge into non-data-structure value: "+t);if(p(t))return"function"==typeof e&&t.mergeWith?t.mergeWith.apply(t,[e].concat(r)):t.merge?t.merge.apply(t,r):t.concat.apply(t,r);for(var n=Array.isArray(t),i=t,o=n?ge:de,u=n?function(r){i===t&&(i=gt(i)),i.push(r)}:function(r,n){var o=qe.call(i,n),u=o&&e?e(i[n],r,n):r;o&&u===i[n]||(i===t&&(i=gt(i)),i[n]=u)},s=0;s0;)r[e]=arguments[e+1];return Tt(this,r,t)}function Nt(t){for(var r=[],e=arguments.length-1;e-- >0;)r[e]=arguments[e+1];return zt(this,t,Zt(),function(t){return Lt(t,r)})}function Pt(t){for(var r=[],e=arguments.length-1;e-- >0;)r[e]=arguments[e+1];return zt(this,t,Zt(),function(t){return Tt(t,r)})}function Jt(t){var r=this.asMutable();return t(r),r.wasAltered()?r.__ensureOwner(this.__ownerID):this}function Ht(){return this.__ownerID?this:this.__ensureOwner(new n)}function Vt(){return this.__ensureOwner() +function _t(t){return t&&(t.constructor&&"Object"===t.constructor.name||void 0===t.constructor)}function lt(t){return"object"==typeof t&&(p(t)||Array.isArray(t)||_t(t))}function vt(t){try{return"string"==typeof t?JSON.stringify(t):t+""}catch(r){return JSON.stringify(t)}}function yt(t,r){return p(t)?t.has(r):lt(t)&&qe.call(t,r)}function dt(t,r,e){return p(t)?t.get(r,e):yt(t,r)?"function"==typeof t.get?t.get(r):t[r]:e}function gt(t){if(Array.isArray(t))return ct(t);var r={};for(var e in t)qe.call(t,e)&&(r[e]=t[e]);return r}function mt(t,r){if(!lt(t))throw new TypeError("Cannot update non-data-structure value: "+t);if(p(t)){if(!t.remove)throw new TypeError("Cannot update immutable value without .remove() method: "+t);return t.remove(r)}if(!qe.call(t,r))return t;var e=gt(t);return Array.isArray(e)?e.splice(r,1):delete e[r],e}function wt(t,r,e){if(!lt(t))throw new TypeError("Cannot update non-data-structure value: "+t);if(p(t)){if(!t.set)throw new TypeError("Cannot update immutable value without .set() method: "+t);return t.set(r,e)}if(qe.call(t,r)&&e===t[r])return t;var n=gt(t);return n[r]=e,n}function zt(t,r,e,n){n||(n=e,e=void 0);var i=St(p(t),t,pt(r),0,e,n);return i===ae?e:i}function St(t,r,e,n,i,o){var u=r===ae;if(n===e.length){var s=u?i:r,a=o(s);return a===s?r:a}if(!u&&!lt(r))throw new TypeError("Cannot update within non-data-structure value in path ["+e.slice(0,n).map(vt)+"]: "+r);var c=e[n],f=u?ae:dt(r,c,ae),h=St(f===ae?t:p(f),f,e,n+1,i,o);return h===f?r:h===ae?mt(r,c):wt(u?t?Zt():{}:r,c,h)}function It(t,r,e){return zt(t,r,ae,function(){return e})}function bt(t,r){return It(this,t,r)}function Ot(t,r){return zt(t,r,function(){return ae})}function Et(t){return Ot(this,t)}function qt(t,r,e,n){return zt(t,[r],e,n)}function Mt(t,r,e){return 1===arguments.length?t(this):qt(this,t,r,e)}function Dt(t,r,e){return zt(this,t,r,e)}function At(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return jt(this,t)}function xt(t){for(var r=[],e=arguments.length-1;e-- >0;)r[e]=arguments[e+1] +;if("function"!=typeof t)throw new TypeError("Invalid merger function: "+t);return jt(this,r,t)}function jt(t,r,e){for(var n=[],i=0;i0;)r[e]=arguments[e+1];return Lt(t,r)}function Rt(t,r){for(var e=[],n=arguments.length-2;n-- >0;)e[n]=arguments[n+2];return Lt(r,e,t)}function Ut(t){for(var r=[],e=arguments.length-1;e-- >0;)r[e]=arguments[e+1];return Tt(t,r)}function Kt(t,r){for(var e=[],n=arguments.length-2;n-- >0;)e[n]=arguments[n+2];return Tt(r,e,t)}function Tt(t,r,e){return Lt(t,r,Ct(e))}function Lt(t,r,e){if(!lt(t))throw new TypeError("Cannot merge into non-data-structure value: "+t);if(p(t))return"function"==typeof e&&t.mergeWith?t.mergeWith.apply(t,[e].concat(r)):t.merge?t.merge.apply(t,r):t.concat.apply(t,r);for(var n=Array.isArray(t),i=t,o=n?ge:de,u=n?function(r){i===t&&(i=gt(i)),i.push(r)}:function(r,n){var o=qe.call(i,n),u=o&&e?e(i[n],r,n):r;o&&u===i[n]||(i===t&&(i=gt(i)),i[n]=u)},s=0;s0;)r[e]=arguments[e+1];return Tt(this,r,t)}function Nt(t){for(var r=[],e=arguments.length-1;e-- >0;)r[e]=arguments[e+1];return zt(this,t,Zt(),function(t){return Lt(t,r)})}function Pt(t){for(var r=[],e=arguments.length-1;e-- >0;)r[e]=arguments[e+1];return zt(this,t,Zt(),function(t){return Tt(t,r)})}function Ht(t){var r=this.asMutable();return t(r),r.wasAltered()?r.__ensureOwner(this.__ownerID):this}function Jt(){return this.__ownerID?this:this.__ensureOwner(new n)}function Vt(){return this.__ensureOwner() }function Yt(){return this.__altered}function Qt(t){return!(!t||!t[$e])}function Xt(t,r){return w(t,r[0],r[1])}function Ft(t,r){return{node:t,index:0,__prev:r}}function Gt(t,r,e,n){var i=Object.create(tn);return i.size=t,i._root=r,i.__ownerID=e,i.__hash=n,i.__altered=!1,i}function Zt(){return sn||(sn=Gt(0))}function $t(t,e,n){var i,o;if(t._root){var u=r(ce),s=r(fe);if(i=tr(t._root,t.__ownerID,0,void 0,e,n,u,s),!s.value)return t;o=t.size+(u.value?n===ae?-1:1:0)}else{if(n===ae)return t;o=1,i=new rn(t.__ownerID,[[e,n]])}return t.__ownerID?(t.size=o,t._root=i,t.__hash=void 0,t.__altered=!0,t):i?Gt(o,i):Zt()}function tr(t,r,n,i,o,u,s,a){return t?t.update(r,n,i,o,u,s,a):u===ae?t:(e(a),e(s),new un(r,i,[o,u]))}function rr(t){return t.constructor===un||t.constructor===on}function er(t,r,e,n,i){if(t.keyHash===n)return new on(r,n,[t.entry,i]);var o,u=(0===e?t.keyHash:t.keyHash>>>e)&se,s=(0===e?n:n>>>e)&se;return new en(r,1<>>=1)u[s]=1&e?r[o++]:void 0;return u[n]=i,new nn(t,o+1,u)}function ur(t){return t-=t>>1&1431655765,t=(858993459&t)+(t>>2&858993459),t=t+(t>>4)&252645135,t+=t>>8,127&(t+=t>>16)}function sr(t,r,e,n){var i=n?t:ct(t);return i[r]=e,i}function ar(t,r,e,n){var i=t.length+1;if(n&&r+1===i)return t[r]=e,t;for(var o=Array(i),u=0,s=0;so?0:o-e,c=u-e;return c>ue&&(c=ue), function(){if(i===c)return dn;var t=r?--c:i++;return n&&n[t]}}function i(t,n,i){var s,a=t&&t.array,c=i>o?0:o-i>>n,f=1+(u-i>>n);return f>ue&&(f=ue),function(){for(;;){if(s){var t=s();if(t!==dn)return t;s=null}if(c===f)return dn;var o=r?--f:c++;s=e(a&&a[o],n-oe,i+(o<=t.size||e<0)return t.withMutations(function(t){e<0?gr(t,e).set(0,n):gr(t,0,e+1).set(e,n)});e+=t._origin;var i=t._tail,u=t._root,s=r(fe);return e>=mr(t._capacity)?i=vr(i,t.__ownerID,0,e,n,s):u=vr(u,t.__ownerID,t._level,e,n,s),s.value?t.__ownerID?(t._root=u,t._tail=i,t.__hash=void 0,t.__altered=!0,t):pr(t._origin,t._capacity,t._level,u,i):t}function vr(t,r,n,i,o,u){var s=i>>>n&se,a=t&&s0){var f=t&&t.array[s],h=vr(f,r,n-oe,i,o,u);return h===f?t:(c=yr(t,r),c.array[s]=h,c)}return a&&t.array[s]===o?t:(e(u),c=yr(t,r),void 0===o&&s===c.array.length-1?c.array.pop():c.array[s]=o,c)}function yr(t,r){return r&&t&&r===t.ownerID?t:new vn(t?t.array.slice():[],r)}function dr(t,r){if(r>=mr(t._capacity))return t._tail;if(r<1<0;)e=e.array[r>>>n&se],n-=oe;return e}}function gr(t,r,e){void 0!==r&&(r|=0),void 0!==e&&(e|=0);var i=t.__ownerID||new n,o=t._origin,u=t._capacity,s=o+r,a=void 0===e?u:e<0?u+e:o+e;if(s===o&&a===u)return t;if(s>=a)return t.clear();for(var c=t._level,f=t._root,h=0;s+h<0;)f=new vn(f&&f.array.length?[void 0,f]:[],i),c+=oe,h+=1<=1<p?new vn([],i):l;if(l&&_>p&&soe;d-=oe){var g=p>>>d&se;y=y.array[g]=yr(y.array[g],i)}y.array[p>>>oe&se]=l} if(a=_)s-=_,a-=_,c=oe,f=null,v=v&&v.removeBefore(i,0,s);else if(s>o||_>>c&se;if(m!==_>>>c&se)break;m&&(h+=(1<o&&(f=f.removeBefore(i,c,s-h)),f&&_>>oe<=ue&&u.size>=2*o.size?(i=u.filter(function(t,r){return void 0!==t&&s!==r}),n=i.toKeyedSeq().map(function(t){return t[0]}).flip().toMap(),t.__ownerID&&(n.__ownerID=i.__ownerID=t.__ownerID)):(n=o.remove(r),i=s===u.size-1?u.pop():u.set(s,void 0))}else if(a){if(e===u.get(s)[1])return t;n=o,i=u.set(s,[r,e])}else n=o.set(r,u.size),i=u.set(u.size,[r,e]);return t.__ownerID?(t.size=n.size,t._map=n,t._list=i,t.__hash=void 0,t):zr(n,i)}function br(t){return!(!t||!t[zn])}function Or(t,r,e,n){var i=Object.create(Sn);return i.size=t,i._head=r,i.__ownerID=e,i.__hash=n,i.__altered=!1,i}function Er(){return In||(In=Or(0))}function qr(t,r){if(t===r)return!0;if(!_(r)||void 0!==t.size&&void 0!==r.size&&t.size!==r.size||void 0!==t.__hash&&void 0!==r.__hash&&t.__hash!==r.__hash||l(t)!==l(r)||v(t)!==v(r)||d(t)!==d(r))return!1;if(0===t.size&&0===r.size)return!0;var e=!y(t);if(d(t)){var n=t.entries();return r.every(function(t,r){var i=n.next().value;return i&&k(i[1],t)&&(e||k(i[0],r))})&&n.next().done}var i=!1;if(void 0===t.size)if(void 0===r.size)"function"==typeof t.cacheResult&&t.cacheResult();else{i=!0;var o=t;t=r,r=o}var u=!0,s=r.__iterate(function(r,n){if(e?!t.has(r):i?!k(r,t.get(n,ae)):!k(t.get(n,ae),r))return u=!1,!1});return u&&t.size===s}function Mr(t,r){var e=function(e){ -t.prototype[e]=r[e]};return Object.keys(r).forEach(e),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(r).forEach(e),t}function Dr(t){return lt(t)?Me(t).map(Dr).toJSON():t}function Ar(t){return!(!t||!t[On])}function xr(t,r){return t.__ownerID?(t.size=r.size,t._map=r,t):r===t._map?t:0===r.size?t.__empty():t.__make(r)}function jr(t,r){var e=Object.create(En);return e.size=t?t.size:0,e._map=t,e.__ownerID=r,e}function kr(){return qn||(qn=jr(Zt()))}function Rr(t,r,e){for(var n=pt(r),i=0;i!==n.length;)if((t=dt(t,n[i++],ae))===ae)return e;return t}function Ur(t,r){return Rr(this,t,r)}function Kr(t,r){return Rr(t,r,ae)!==ae}function Tr(t){return Kr(this,t)}function Lr(){ht(this.size);var t={};return this.__iterate(function(r,e){t[e]=r}),t}function Cr(t,r,e,n,i,o){return ht(t.size),t.__iterate(function(t,o,u){i?(i=!1,e=t):e=r.call(n,e,t,o,u)},o),e}function Br(t,r){return r}function Wr(t,r){return[r,t]}function Nr(t){return function(){return!t.apply(this,arguments)}}function Pr(t){return function(){return-t.apply(this,arguments)}}function Jr(){return ct(arguments)}function Hr(t,r){return tr?-1:0}function Vr(t){if(t.size===1/0)return 0;var r=d(t),e=l(t),n=r?1:0;return Yr(t.__iterate(e?r?function(t,r){n=31*n+Qr(U(t),U(r))|0}:function(t,r){n=n+Qr(U(t),U(r))|0}:r?function(t){n=31*n+U(t)|0}:function(t){n=n+U(t)|0}),n)}function Yr(t,r){return r=Le(r,3432918353),r=Le(r<<15|r>>>-15,461845907),r=Le(r<<13|r>>>-13,5),r=(r+3864292196|0)^t,r=Le(r^r>>>16,2246822507),r=Le(r^r>>>13,3266489909),r=R(r^r>>>16)}function Qr(t,r){return t^r+2654435769+(t<<6)+(t>>2)|0}function Xr(t){return Ar(t)&&d(t)}function Fr(t,r){var e=Object.create(Rn);return e.size=t?t.size:0,e._map=t,e.__ownerID=r,e}function Gr(){return Un||(Un=Fr(Sr()))}function Zr(t,r,e){var n=Object.create(Object.getPrototypeOf(t));return n._values=r,n.__ownerID=e,n}function $r(t){return t._name||t.constructor.name||"Record"}function te(t){return D(t._keys.map(function(r){return[r,t.get(r)]}))}function re(t,r){try{Object.defineProperty(t,r,{get:function(){ -return this.get(r)},set:function(t){ft(this.__ownerID,"Cannot set on an immutable record."),this.set(r,t)}})}catch(t){}}function ee(t,r){return ne([],r||ie,t,"",r&&r.length>2?[]:void 0,{"":t})}function ne(t,r,e,n,i,o){var u=Array.isArray(e)?Ae:_t(e)?De:null;if(u){if(~t.indexOf(e))throw new TypeError("Cannot convert circular structure to Immutable");t.push(e),i&&""!==n&&i.push(n);var s=r.call(o,n,u(e).map(function(n,o){return ne(t,r,n,o,i,e)}),i&&i.slice());return t.pop(),i&&i.pop(),s}return e}function ie(t,r){return l(r)?r.toMap():r.toList()}var oe=5,ue=1<>>16)*n+e*(r>>>16)<<16>>>0)|0},Ce=Object.isExtensible,Be=function(){try{return Object.defineProperty({},"@",{}),!0}catch(t){return!1}}(),We="function"==typeof WeakMap;We&&(Ke=new WeakMap);var Ne=0,Pe="__immutablehash__";"function"==typeof Symbol&&(Pe=Symbol(Pe));var Je=16,He=255,Ve=0,Ye={},Qe=function(t){function r(t,r){this._iter=t,this._useKeys=r,this.size=t.size}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.prototype.get=function(t,r){return this._iter.get(t,r)},r.prototype.has=function(t){ -return this._iter.has(t)},r.prototype.valueSeq=function(){return this._iter.valueSeq()},r.prototype.reverse=function(){var t=this,r=N(this,!0);return this._useKeys||(r.valueSeq=function(){return t._iter.toSeq().reverse()}),r},r.prototype.map=function(t,r){var e=this,n=W(this,t,r);return this._useKeys||(n.valueSeq=function(){return e._iter.toSeq().map(t,r)}),n},r.prototype.__iterate=function(t,r){var e=this;return this._iter.__iterate(function(r,n){return t(r,n,e)},r)},r.prototype.__iterator=function(t,r){return this._iter.__iterator(t,r)},r}(De);Qe.prototype[le]=!0;var Xe=function(t){function r(t){this._iter=t,this.size=t.size}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.prototype.includes=function(t){return this._iter.includes(t)},r.prototype.__iterate=function(t,r){var e=this,n=0;return r&&i(this),this._iter.__iterate(function(i){return t(i,r?e.size-++n:n++,e)},r)},r.prototype.__iterator=function(t,r){var e=this,n=this._iter.__iterator(ze,r),o=0;return r&&i(this),new Ee(function(){var i=n.next();return i.done?i:w(t,r?e.size-++o:o++,i.value,i)})},r}(Ae),Fe=function(t){function r(t){this._iter=t,this.size=t.size}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.prototype.has=function(t){return this._iter.includes(t)},r.prototype.__iterate=function(t,r){var e=this;return this._iter.__iterate(function(r){return t(r,r,e)},r)},r.prototype.__iterator=function(t,r){var e=this._iter.__iterator(ze,r);return new Ee(function(){var r=e.next();return r.done?r:w(t,r.value,r.value,r)})},r}(xe),Ge=function(t){function r(t){this._iter=t,this.size=t.size}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.prototype.entrySeq=function(){return this._iter.toSeq()},r.prototype.__iterate=function(t,r){var e=this;return this._iter.__iterate(function(r){if(r){it(r);var n=_(r);return t(n?r.get(1):r[1],n?r.get(0):r[0],e)}},r)},r.prototype.__iterator=function(t,r){var e=this._iter.__iterator(ze,r) -;return new Ee(function(){for(;;){var r=e.next();if(r.done)return r;var n=r.value;if(n){it(n);var i=_(n);return w(t,i?n.get(0):n[0],i?n.get(1):n[1],r)}}})},r}(De);Xe.prototype.cacheResult=Qe.prototype.cacheResult=Fe.prototype.cacheResult=Ge.prototype.cacheResult=st;var Ze=function(t){function r(r){return null===r||void 0===r?Zt():Qt(r)&&!d(r)?r:Zt().withMutations(function(e){var n=t(r);ht(n.size),n.forEach(function(t,r){return e.set(r,t)})})}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.of=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return Zt().withMutations(function(r){for(var e=0;e=t.length)throw Error("Missing value for key: "+t[e]);r.set(t[e],t[e+1])}})},r.prototype.toString=function(){return this.__toString("Map {","}")},r.prototype.get=function(t,r){return this._root?this._root.get(0,void 0,t,r):r},r.prototype.set=function(t,r){return $t(this,t,r)},r.prototype.remove=function(t){return $t(this,t,ae)},r.prototype.deleteAll=function(t){var r=ye(t);return 0===r.size?this:this.withMutations(function(t){r.forEach(function(r){return t.remove(r)})})},r.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):Zt()},r.prototype.sort=function(t){return gn($(this,t))},r.prototype.sortBy=function(t,r){return gn($(this,r,t))},r.prototype.map=function(t,r){return this.withMutations(function(e){e.forEach(function(n,i){e.set(i,t.call(r,n,i,e))})})},r.prototype.__iterator=function(t,r){return new an(this,t,r)},r.prototype.__iterate=function(t,r){var e=this,n=0;return this._root&&this._root.iterate(function(r){return n++,t(r[1],r[0],e)},r),n},r.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Gt(this.size,this._root,t,this.__hash):0===this.size?Zt():(this.__ownerID=t,this.__altered=!1,this)},r}(de);Ze.isMap=Qt;var $e="@@__IMMUTABLE_MAP__@@",tn=Ze.prototype;tn[$e]=!0,tn.delete=tn.remove,tn.removeAll=tn.deleteAll,tn.setIn=bt, -tn.removeIn=tn.deleteIn=Et,tn.update=Mt,tn.updateIn=Dt,tn.merge=tn.concat=At,tn.mergeWith=xt,tn.mergeDeep=Bt,tn.mergeDeepWith=Wt,tn.mergeIn=Nt,tn.mergeDeepIn=Pt,tn.withMutations=Jt,tn.wasAltered=Yt,tn.asImmutable=Vt,tn["@@transducer/init"]=tn.asMutable=Ht,tn["@@transducer/step"]=function(t,r){return t.set(r[0],r[1])},tn["@@transducer/result"]=function(t){return t.asImmutable()};var rn=function(t,r){this.ownerID=t,this.entries=r};rn.prototype.get=function(t,r,e,n){for(var i=this.entries,o=0,u=i.length;o=cn)return nr(t,c,i,o);var _=t&&t===this.ownerID,l=_?c:ct(c);return p?a?f===h-1?l.pop():l[f]=l.pop():l[f]=[i,o]:l.push([i,o]),_?(this.entries=l,this):new rn(t,l)}};var en=function(t,r,e){this.ownerID=t,this.bitmap=r,this.nodes=e};en.prototype.get=function(t,r,e,n){void 0===r&&(r=U(e));var i=1<<((0===t?r:r>>>t)&se),o=this.bitmap;return 0==(o&i)?n:this.nodes[ur(o&i-1)].get(t+oe,r,e,n)},en.prototype.update=function(t,r,e,n,i,o,u){void 0===e&&(e=U(n));var s=(0===r?e:e>>>r)&se,a=1<=fn)return or(t,p,c,s,l);if(f&&!l&&2===p.length&&rr(p[1^h]))return p[1^h];if(f&&l&&1===p.length&&rr(l))return l;var v=t&&t===this.ownerID,y=f?l?c:c^a:c|a,d=f?l?sr(p,h,l,v):cr(p,h,v):ar(p,h,l,v);return v?(this.bitmap=y,this.nodes=d,this):new en(t,y,d)};var nn=function(t,r,e){this.ownerID=t,this.count=r,this.nodes=e};nn.prototype.get=function(t,r,e,n){void 0===r&&(r=U(e));var i=(0===t?r:r>>>t)&se,o=this.nodes[i];return o?o.get(t+oe,r,e,n):n},nn.prototype.update=function(t,r,e,n,i,o,u){void 0===e&&(e=U(n));var s=(0===r?e:e>>>r)&se,a=i===ae,c=this.nodes,f=c[s];if(a&&!f)return this;var h=tr(f,t,r+oe,e,n,i,o,u) -;if(h===f)return this;var p=this.count;if(f){if(!h&&--p0&&i=0&&t>>r&se;if(n>=this.array.length)return new vn([],t);var i,o=0===n;if(r>0){var u=this.array[n];if((i=u&&u.removeBefore(t,r-oe,e))===u&&o)return this}if(o&&!i)return this;var s=yr(this,t);if(!o)for(var a=0;a>>r&se;if(n>=this.array.length)return this;var i;if(r>0){var o=this.array[n];if((i=o&&o.removeAfter(t,r-oe,e))===o&&n===this.array.length-1)return this}var u=yr(this,t);return u.array.splice(n+1),i&&(u.array[n]=i),u};var yn,dn={},gn=function(t){function r(t){return null===t||void 0===t?Sr():wr(t)?t:Sr().withMutations(function(r){var e=de(t);ht(e.size),e.forEach(function(t,e){return r.set(e,t)})})}return t&&(r.__proto__=t), -r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.of=function(){return this(arguments)},r.prototype.toString=function(){return this.__toString("OrderedMap {","}")},r.prototype.get=function(t,r){var e=this._map.get(t);return void 0!==e?this._list.get(e)[1]:r},r.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._map.clear(),this._list.clear(),this):Sr()},r.prototype.set=function(t,r){return Ir(this,t,r)},r.prototype.remove=function(t){return Ir(this,t,ae)},r.prototype.wasAltered=function(){return this._map.wasAltered()||this._list.wasAltered()},r.prototype.__iterate=function(t,r){var e=this;return this._list.__iterate(function(r){return r&&t(r[1],r[0],e)},r)},r.prototype.__iterator=function(t,r){return this._list.fromEntrySeq().__iterator(t,r)},r.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var r=this._map.__ensureOwner(t),e=this._list.__ensureOwner(t);return t?zr(r,e,t,this.__hash):0===this.size?Sr():(this.__ownerID=t,this._map=r,this._list=e,this)},r}(Ze);gn.isOrderedMap=wr,gn.prototype[le]=!0,gn.prototype.delete=gn.prototype.remove;var mn,wn=function(t){function r(t){return null===t||void 0===t?Er():br(t)?t:Er().pushAll(t)}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.of=function(){return this(arguments)},r.prototype.toString=function(){return this.__toString("Stack [","]")},r.prototype.get=function(t,r){var e=this._head;for(t=o(this,t);e&&t--;)e=e.next;return e?e.value:r},r.prototype.peek=function(){return this._head&&this._head.value},r.prototype.push=function(){var t=arguments;if(0===arguments.length)return this;for(var r=this.size+arguments.length,e=this._head,n=arguments.length-1;n>=0;n--)e={value:t[n],next:e};return this.__ownerID?(this.size=r,this._head=e,this.__hash=void 0,this.__altered=!0,this):Or(r,e)},r.prototype.pushAll=function(r){if(r=t(r),0===r.size)return this;if(0===this.size&&br(r))return r;ht(r.size);var e=this.size,n=this._head;return r.__iterate(function(t){e++, -n={value:t,next:n}},!0),this.__ownerID?(this.size=e,this._head=n,this.__hash=void 0,this.__altered=!0,this):Or(e,n)},r.prototype.pop=function(){return this.slice(1)},r.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):Er()},r.prototype.slice=function(r,e){if(s(r,e,this.size))return this;var n=a(r,this.size);if(c(e,this.size)!==this.size)return t.prototype.slice.call(this,r,e);for(var i=this.size-n,o=this._head;n--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):Or(i,o)},r.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Or(this.size,this._head,t,this.__hash):0===this.size?Er():(this.__ownerID=t,this.__altered=!1,this)},r.prototype.__iterate=function(t,r){var e=this;if(r)return new ke(this.toArray()).__iterate(function(r,n){return t(r,n,e)},r);for(var n=0,i=this._head;i&&t(i.value,n++,e)!==!1;)i=i.next;return n},r.prototype.__iterator=function(t,r){if(r)return new ke(this.toArray()).__iterator(t,r);var e=0,n=this._head;return new Ee(function(){if(n){var r=n.value;return n=n.next,w(t,e++,r)}return z()})},r}(ge);wn.isStack=br;var zn="@@__IMMUTABLE_STACK__@@",Sn=wn.prototype;Sn[zn]=!0,Sn.shift=Sn.pop,Sn.unshift=Sn.push,Sn.unshiftAll=Sn.pushAll,Sn.withMutations=Jt,Sn.wasAltered=Yt,Sn.asImmutable=Vt,Sn["@@transducer/init"]=Sn.asMutable=Ht,Sn["@@transducer/step"]=function(t,r){return t.unshift(r)},Sn["@@transducer/result"]=function(t){return t.asImmutable()};var In,bn=function(t){function r(r){return null===r||void 0===r?kr():Ar(r)&&!d(r)?r:kr().withMutations(function(e){var n=t(r);ht(n.size),n.forEach(function(t){return e.add(t)})})}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.of=function(){return this(arguments)},r.fromKeys=function(t){return this(de(t).keySeq())},r.intersect=function(t){return t=ye(t).toArray(),t.length?En.intersect.apply(r(t.pop()),t):kr()},r.union=function(t){return t=ye(t).toArray(), -t.length?En.union.apply(r(t.pop()),t):kr()},r.prototype.toString=function(){return this.__toString("Set {","}")},r.prototype.has=function(t){return this._map.has(t)},r.prototype.add=function(t){return xr(this,this._map.set(t,t))},r.prototype.remove=function(t){return xr(this,this._map.remove(t))},r.prototype.clear=function(){return xr(this,this._map.clear())},r.prototype.map=function(t,r){var e=this;return xr(this,this._map.map(function(r){return t(r,r,e)},r))},r.prototype.union=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];return r=r.filter(function(t){return 0!==t.size}),0===r.length?this:0!==this.size||this.__ownerID||1!==r.length?this.withMutations(function(e){for(var n=0;n=0&&r=0&&ethis.size?r:this.find(function(r,e){return e===t},void 0,r)},has:function(t){return(t=o(this,t))>=0&&(void 0!==this.size?this.size===1/0||tr?-1:0}function Vr(t){if(t.size===1/0)return 0;var r=d(t),e=l(t),n=r?1:0;return Yr(t.__iterate(e?r?function(t,r){n=31*n+Qr(U(t),U(r))|0}:function(t,r){n=n+Qr(U(t),U(r))|0}:r?function(t){n=31*n+U(t)|0}:function(t){n=n+U(t)|0}),n)}function Yr(t,r){return r=Le(r,3432918353),r=Le(r<<15|r>>>-15,461845907),r=Le(r<<13|r>>>-13,5),r=(r+3864292196|0)^t,r=Le(r^r>>>16,2246822507),r=Le(r^r>>>13,3266489909),r=R(r^r>>>16)}function Qr(t,r){return t^r+2654435769+(t<<6)+(t>>2)|0}function Xr(t){return Ar(t)&&d(t)}function Fr(t,r){var e=Object.create(Rn);return e.size=t?t.size:0,e._map=t,e.__ownerID=r,e}function Gr(){return Un||(Un=Fr(Sr()))}function Zr(t,r,e){var n=Object.create(Object.getPrototypeOf(t));return n._values=r,n.__ownerID=e,n}function $r(t){ +return t._name||t.constructor.name||"Record"}function te(t){return D(t._keys.map(function(r){return[r,t.get(r)]}))}function re(t,r){try{Object.defineProperty(t,r,{get:function(){return this.get(r)},set:function(t){ft(this.__ownerID,"Cannot set on an immutable record."),this.set(r,t)}})}catch(t){}}function ee(t,r){return ne([],r||ie,t,"",r&&r.length>2?[]:void 0,{"":t})}function ne(t,r,e,n,i,o){var u=Array.isArray(e)?Ae:_t(e)?De:null;if(u){if(~t.indexOf(e))throw new TypeError("Cannot convert circular structure to Immutable");t.push(e),i&&""!==n&&i.push(n);var s=r.call(o,n,u(e).map(function(n,o){return ne(t,r,n,o,i,e)}),i&&i.slice());return t.pop(),i&&i.pop(),s}return e}function ie(t,r){return l(r)?r.toMap():r.toList()}var oe=5,ue=1<>>16)*n+e*(r>>>16)<<16>>>0)|0},Ce=Object.isExtensible,Be=function(){try{return Object.defineProperty({},"@",{}),!0}catch(t){return!1}}(),We="function"==typeof WeakMap;We&&(Ke=new WeakMap);var Ne=0,Pe="__immutablehash__";"function"==typeof Symbol&&(Pe=Symbol(Pe));var He=16,Je=255,Ve=0,Ye={},Qe=function(t){function r(t,r){this._iter=t,this._useKeys=r,this.size=t.size}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype), +r.prototype.constructor=r,r.prototype.get=function(t,r){return this._iter.get(t,r)},r.prototype.has=function(t){return this._iter.has(t)},r.prototype.valueSeq=function(){return this._iter.valueSeq()},r.prototype.reverse=function(){var t=this,r=N(this,!0);return this._useKeys||(r.valueSeq=function(){return t._iter.toSeq().reverse()}),r},r.prototype.map=function(t,r){var e=this,n=W(this,t,r);return this._useKeys||(n.valueSeq=function(){return e._iter.toSeq().map(t,r)}),n},r.prototype.__iterate=function(t,r){var e=this;return this._iter.__iterate(function(r,n){return t(r,n,e)},r)},r.prototype.__iterator=function(t,r){return this._iter.__iterator(t,r)},r}(De);Qe.prototype[le]=!0;var Xe=function(t){function r(t){this._iter=t,this.size=t.size}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.prototype.includes=function(t){return this._iter.includes(t)},r.prototype.__iterate=function(t,r){var e=this,n=0;return r&&i(this),this._iter.__iterate(function(i){return t(i,r?e.size-++n:n++,e)},r)},r.prototype.__iterator=function(t,r){var e=this,n=this._iter.__iterator(ze,r),o=0;return r&&i(this),new Ee(function(){var i=n.next();return i.done?i:w(t,r?e.size-++o:o++,i.value,i)})},r}(Ae),Fe=function(t){function r(t){this._iter=t,this.size=t.size}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.prototype.has=function(t){return this._iter.includes(t)},r.prototype.__iterate=function(t,r){var e=this;return this._iter.__iterate(function(r){return t(r,r,e)},r)},r.prototype.__iterator=function(t,r){var e=this._iter.__iterator(ze,r);return new Ee(function(){var r=e.next();return r.done?r:w(t,r.value,r.value,r)})},r}(xe),Ge=function(t){function r(t){this._iter=t,this.size=t.size}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.prototype.entrySeq=function(){return this._iter.toSeq()},r.prototype.__iterate=function(t,r){var e=this;return this._iter.__iterate(function(r){if(r){it(r);var n=_(r) +;return t(n?r.get(1):r[1],n?r.get(0):r[0],e)}},r)},r.prototype.__iterator=function(t,r){var e=this._iter.__iterator(ze,r);return new Ee(function(){for(;;){var r=e.next();if(r.done)return r;var n=r.value;if(n){it(n);var i=_(n);return w(t,i?n.get(0):n[0],i?n.get(1):n[1],r)}}})},r}(De);Xe.prototype.cacheResult=Qe.prototype.cacheResult=Fe.prototype.cacheResult=Ge.prototype.cacheResult=st;var Ze=function(t){function r(r){return null===r||void 0===r?Zt():Qt(r)&&!d(r)?r:Zt().withMutations(function(e){var n=t(r);ht(n.size),n.forEach(function(t,r){return e.set(r,t)})})}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.of=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return Zt().withMutations(function(r){for(var e=0;e=t.length)throw Error("Missing value for key: "+t[e]);r.set(t[e],t[e+1])}})},r.prototype.toString=function(){return this.__toString("Map {","}")},r.prototype.get=function(t,r){return this._root?this._root.get(0,void 0,t,r):r},r.prototype.set=function(t,r){return $t(this,t,r)},r.prototype.remove=function(t){return $t(this,t,ae)},r.prototype.deleteAll=function(t){var r=ye(t);return 0===r.size?this:this.withMutations(function(t){r.forEach(function(r){return t.remove(r)})})},r.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):Zt()},r.prototype.sort=function(t){return gn($(this,t))},r.prototype.sortBy=function(t,r){return gn($(this,r,t))},r.prototype.map=function(t,r){return this.withMutations(function(e){e.forEach(function(n,i){e.set(i,t.call(r,n,i,e))})})},r.prototype.__iterator=function(t,r){return new an(this,t,r)},r.prototype.__iterate=function(t,r){var e=this,n=0;return this._root&&this._root.iterate(function(r){return n++,t(r[1],r[0],e)},r),n},r.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Gt(this.size,this._root,t,this.__hash):0===this.size?Zt():(this.__ownerID=t,this.__altered=!1,this)},r}(de);Ze.isMap=Qt +;var $e="@@__IMMUTABLE_MAP__@@",tn=Ze.prototype;tn[$e]=!0,tn.delete=tn.remove,tn.removeAll=tn.deleteAll,tn.setIn=bt,tn.removeIn=tn.deleteIn=Et,tn.update=Mt,tn.updateIn=Dt,tn.merge=tn.concat=At,tn.mergeWith=xt,tn.mergeDeep=Bt,tn.mergeDeepWith=Wt,tn.mergeIn=Nt,tn.mergeDeepIn=Pt,tn.withMutations=Ht,tn.wasAltered=Yt,tn.asImmutable=Vt,tn["@@transducer/init"]=tn.asMutable=Jt,tn["@@transducer/step"]=function(t,r){return t.set(r[0],r[1])},tn["@@transducer/result"]=function(t){return t.asImmutable()};var rn=function(t,r){this.ownerID=t,this.entries=r};rn.prototype.get=function(t,r,e,n){for(var i=this.entries,o=0,u=i.length;o=cn)return nr(t,c,i,o);var _=t&&t===this.ownerID,l=_?c:ct(c);return p?a?f===h-1?l.pop():l[f]=l.pop():l[f]=[i,o]:l.push([i,o]),_?(this.entries=l,this):new rn(t,l)}};var en=function(t,r,e){this.ownerID=t,this.bitmap=r,this.nodes=e};en.prototype.get=function(t,r,e,n){void 0===r&&(r=U(e));var i=1<<((0===t?r:r>>>t)&se),o=this.bitmap;return 0==(o&i)?n:this.nodes[ur(o&i-1)].get(t+oe,r,e,n)},en.prototype.update=function(t,r,e,n,i,o,u){void 0===e&&(e=U(n));var s=(0===r?e:e>>>r)&se,a=1<=fn)return or(t,p,c,s,l);if(f&&!l&&2===p.length&&rr(p[1^h]))return p[1^h];if(f&&l&&1===p.length&&rr(l))return l;var v=t&&t===this.ownerID,y=f?l?c:c^a:c|a,d=f?l?sr(p,h,l,v):cr(p,h,v):ar(p,h,l,v);return v?(this.bitmap=y,this.nodes=d,this):new en(t,y,d)};var nn=function(t,r,e){this.ownerID=t,this.count=r,this.nodes=e};nn.prototype.get=function(t,r,e,n){void 0===r&&(r=U(e));var i=(0===t?r:r>>>t)&se,o=this.nodes[i];return o?o.get(t+oe,r,e,n):n},nn.prototype.update=function(t,r,e,n,i,o,u){void 0===e&&(e=U(n)) +;var s=(0===r?e:e>>>r)&se,a=i===ae,c=this.nodes,f=c[s];if(a&&!f)return this;var h=tr(f,t,r+oe,e,n,i,o,u);if(h===f)return this;var p=this.count;if(f){if(!h&&--p0&&i=0&&t>>r&se;if(n>=this.array.length)return new vn([],t);var i,o=0===n;if(r>0){var u=this.array[n];if((i=u&&u.removeBefore(t,r-oe,e))===u&&o)return this}if(o&&!i)return this;var s=yr(this,t);if(!o)for(var a=0;a>>r&se;if(n>=this.array.length)return this;var i;if(r>0){var o=this.array[n];if((i=o&&o.removeAfter(t,r-oe,e))===o&&n===this.array.length-1)return this}var u=yr(this,t);return u.array.splice(n+1),i&&(u.array[n]=i),u};var yn,dn={},gn=function(t){function r(t){ +return null===t||void 0===t?Sr():wr(t)?t:Sr().withMutations(function(r){var e=de(t);ht(e.size),e.forEach(function(t,e){return r.set(e,t)})})}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.of=function(){return this(arguments)},r.prototype.toString=function(){return this.__toString("OrderedMap {","}")},r.prototype.get=function(t,r){var e=this._map.get(t);return void 0!==e?this._list.get(e)[1]:r},r.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._map.clear(),this._list.clear(),this):Sr()},r.prototype.set=function(t,r){return Ir(this,t,r)},r.prototype.remove=function(t){return Ir(this,t,ae)},r.prototype.wasAltered=function(){return this._map.wasAltered()||this._list.wasAltered()},r.prototype.__iterate=function(t,r){var e=this;return this._list.__iterate(function(r){return r&&t(r[1],r[0],e)},r)},r.prototype.__iterator=function(t,r){return this._list.fromEntrySeq().__iterator(t,r)},r.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var r=this._map.__ensureOwner(t),e=this._list.__ensureOwner(t);return t?zr(r,e,t,this.__hash):0===this.size?Sr():(this.__ownerID=t,this._map=r,this._list=e,this)},r}(Ze);gn.isOrderedMap=wr,gn.prototype[le]=!0,gn.prototype.delete=gn.prototype.remove;var mn,wn=function(t){function r(t){return null===t||void 0===t?Er():br(t)?t:Er().pushAll(t)}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.of=function(){return this(arguments)},r.prototype.toString=function(){return this.__toString("Stack [","]")},r.prototype.get=function(t,r){var e=this._head;for(t=o(this,t);e&&t--;)e=e.next;return e?e.value:r},r.prototype.peek=function(){return this._head&&this._head.value},r.prototype.push=function(){var t=arguments;if(0===arguments.length)return this;for(var r=this.size+arguments.length,e=this._head,n=arguments.length-1;n>=0;n--)e={value:t[n],next:e};return this.__ownerID?(this.size=r,this._head=e,this.__hash=void 0,this.__altered=!0,this):Or(r,e)}, +r.prototype.pushAll=function(r){if(r=t(r),0===r.size)return this;if(0===this.size&&br(r))return r;ht(r.size);var e=this.size,n=this._head;return r.__iterate(function(t){e++,n={value:t,next:n}},!0),this.__ownerID?(this.size=e,this._head=n,this.__hash=void 0,this.__altered=!0,this):Or(e,n)},r.prototype.pop=function(){return this.slice(1)},r.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):Er()},r.prototype.slice=function(r,e){if(s(r,e,this.size))return this;var n=a(r,this.size);if(c(e,this.size)!==this.size)return t.prototype.slice.call(this,r,e);for(var i=this.size-n,o=this._head;n--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):Or(i,o)},r.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Or(this.size,this._head,t,this.__hash):0===this.size?Er():(this.__ownerID=t,this.__altered=!1,this)},r.prototype.__iterate=function(t,r){var e=this;if(r)return new ke(this.toArray()).__iterate(function(r,n){return t(r,n,e)},r);for(var n=0,i=this._head;i&&t(i.value,n++,e)!==!1;)i=i.next;return n},r.prototype.__iterator=function(t,r){if(r)return new ke(this.toArray()).__iterator(t,r);var e=0,n=this._head;return new Ee(function(){if(n){var r=n.value;return n=n.next,w(t,e++,r)}return z()})},r}(ge);wn.isStack=br;var zn="@@__IMMUTABLE_STACK__@@",Sn=wn.prototype;Sn[zn]=!0,Sn.shift=Sn.pop,Sn.unshift=Sn.push,Sn.unshiftAll=Sn.pushAll,Sn.withMutations=Ht,Sn.wasAltered=Yt,Sn.asImmutable=Vt,Sn["@@transducer/init"]=Sn.asMutable=Jt,Sn["@@transducer/step"]=function(t,r){return t.unshift(r)},Sn["@@transducer/result"]=function(t){return t.asImmutable()};var In,bn=function(t){function r(r){return null===r||void 0===r?kr():Ar(r)&&!d(r)?r:kr().withMutations(function(e){var n=t(r);ht(n.size),n.forEach(function(t){return e.add(t)})})}return t&&(r.__proto__=t),r.prototype=Object.create(t&&t.prototype),r.prototype.constructor=r,r.of=function(){return this(arguments)},r.fromKeys=function(t){ +return this(de(t).keySeq())},r.intersect=function(t){return t=ye(t).toArray(),t.length?En.intersect.apply(r(t.pop()),t):kr()},r.union=function(t){return t=ye(t).toArray(),t.length?En.union.apply(r(t.pop()),t):kr()},r.prototype.toString=function(){return this.__toString("Set {","}")},r.prototype.has=function(t){return this._map.has(t)},r.prototype.add=function(t){return xr(this,this._map.set(t,t))},r.prototype.remove=function(t){return xr(this,this._map.remove(t))},r.prototype.clear=function(){return xr(this,this._map.clear())},r.prototype.map=function(t,r){var e=this;return xr(this,this._map.map(function(r){return t(r,r,e)},r))},r.prototype.union=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];return r=r.filter(function(t){return 0!==t.size}),0===r.length?this:0!==this.size||this.__ownerID||1!==r.length?this.withMutations(function(e){for(var n=0;n=0&&r=0&&ethis.size?r:this.find(function(r,e){return e===t},void 0,r)},has:function(t){return(t=o(this,t))>=0&&(void 0!==this.size?this.size===1/0||t Date: Tue, 18 Sep 2018 20:36:26 +0000 Subject: [PATCH 120/242] Deploy 31420c436edbc10b982dcdfeb0d1752b99c4ce62 to NPM branch --- README.md | 178 ++++++++++++++++----------------- dist/immutable-nonambient.d.ts | 9 ++ dist/immutable.d.ts | 9 ++ 3 files changed, 107 insertions(+), 89 deletions(-) diff --git a/README.md b/README.md index c6f35ca158..fcdeb7504d 100644 --- a/README.md +++ b/README.md @@ -43,10 +43,10 @@ Then require it into any module. ```js -const { Map } = require('immutable') -const map1 = Map({ a: 1, b: 2, c: 3 }) -const map2 = map1.set('b', 50) -map1.get('b') + " vs. " + map2.get('b') // 2 vs. 50 +const { Map } = require('immutable'); +const map1 = Map({ a: 1, b: 2, c: 3 }); +const map2 = map1.set('b', 50); +map1.get('b') + " vs. " + map2.get('b'); // 2 vs. 50 ``` ### Browser @@ -68,7 +68,7 @@ Use a script tag to directly add `Immutable` to the global scope: ```html ``` -Or use an AMD-style loader (such as [RequireJS](http://requirejs.org/)): +Or use an AMD-style loader (such as [RequireJS](https://requirejs.org/)): ```js require(['./immutable.min.js'], function (Immutable) { @@ -89,7 +89,7 @@ require(['./immutable.min.js'], function (Immutable) { ### Flow & TypeScript Use these Immutable collections and sequences as you would use native -collections in your [Flowtype](https://flowtype.org/) or [TypeScript](http://typescriptlang.org) programs while still taking +collections in your [Flowtype](https://flowtype.org/) or [TypeScript](https://typescriptlang.org) programs while still taking advantage of type generics, error detection, and auto-complete in your IDE. Installing `immutable` via npm brings with it type definitions for Flow (v0.55.0 or higher) @@ -348,8 +348,8 @@ not always be well defined, as is the case for the `Map` and `Set`. [Iterators]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/The_Iterator_protocol [Arrow Functions]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions -[Classes]: http://wiki.ecmascript.org/doku.php?id=strawman:maximally_minimal_classes -[Modules]: http://www.2ality.com/2014/09/es6-modules-final.html +[Classes]: https://wiki.ecmascript.org/doku.php?id=strawman:maximally_minimal_classes +[Modules]: https://www.2ality.com/2014/09/es6-modules-final.html Nested Structures @@ -598,7 +598,7 @@ Range(1, Infinity) Documentation ------------- -[Read the docs](http://immutable-js.com) and eat your vegetables. +[Read the docs](https://immutable-js.com) and eat your vegetables. Docs are automatically generated from [Immutable.d.ts](https://github.com/immutable-js/immutable-js/blob/main/type-definitions/Immutable.d.ts). Please contribute! @@ -610,7 +610,7 @@ contains articles on specific topics. Can't find something? Open an [issue](http Testing ------- -If you are using the [Chai Assertion Library](http://chaijs.com/), [Chai Immutable](https://github.com/astorije/chai-immutable) provides a set of assertions to use against Immutable.js collections. +If you are using the [Chai Assertion Library](https://chaijs.com/), [Chai Immutable](https://github.com/astorije/chai-immutable) provides a set of assertions to use against Immutable.js collections. Contribution diff --git a/dist/immutable-nonambient.d.ts b/dist/immutable-nonambient.d.ts index c3610f4ad6..c2da68cbd7 100644 --- a/dist/immutable-nonambient.d.ts +++ b/dist/immutable-nonambient.d.ts @@ -85,7 +85,7 @@ * ``` * * [ES2015]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/New_in_JavaScript/ECMAScript_6_support_in_Mozilla - * [TypeScript]: http://www.typescriptlang.org/ + * [TypeScript]: https://www.typescriptlang.org/ * [Flow]: https://flowtype.org/ * [Iterable]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols */ @@ -3833,7 +3833,7 @@ * to be equal][Hash Collision]. If two values have different `hashCode`s, * they must not be equal. * - * [Hash Collision]: http://en.wikipedia.org/wiki/Collision_(computer_science) + * [Hash Collision]: https://en.wikipedia.org/wiki/Collision_(computer_science) */ hashCode(): number; @@ -4751,7 +4751,7 @@ * organize their internal data structures, while all Immutable.js * collections use equality during lookups. * - * [Hash Collision]: http://en.wikipedia.org/wiki/Collision_(computer_science) + * [Hash Collision]: https://en.wikipedia.org/wiki/Collision_(computer_science) */ hashCode(): number; } diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index 43b042a1aa..bfb81f66b5 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -85,7 +85,7 @@ * ``` * * [ES2015]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/New_in_JavaScript/ECMAScript_6_support_in_Mozilla - * [TypeScript]: http://www.typescriptlang.org/ + * [TypeScript]: https://www.typescriptlang.org/ * [Flow]: https://flowtype.org/ * [Iterable]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols */ @@ -3833,7 +3833,7 @@ declare module Immutable { * to be equal][Hash Collision]. If two values have different `hashCode`s, * they must not be equal. * - * [Hash Collision]: http://en.wikipedia.org/wiki/Collision_(computer_science) + * [Hash Collision]: https://en.wikipedia.org/wiki/Collision_(computer_science) */ hashCode(): number; @@ -4751,7 +4751,7 @@ declare module Immutable { * organize their internal data structures, while all Immutable.js * collections use equality during lookups. * - * [Hash Collision]: http://en.wikipedia.org/wiki/Collision_(computer_science) + * [Hash Collision]: https://en.wikipedia.org/wiki/Collision_(computer_science) */ hashCode(): number; } From fd51664dc775142cfaebf288a6f70e65e3012f89 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 18 Jun 2021 18:16:47 +0000 Subject: [PATCH 147/242] deploy: 7bfd3ee70fe3d8dd1e12d0361dd7f8e5883f9be0 --- dist/immutable-nonambient.d.ts | 30 +++++++++++++++--------------- dist/immutable.d.ts | 30 +++++++++++++++--------------- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/dist/immutable-nonambient.d.ts b/dist/immutable-nonambient.d.ts index c2da68cbd7..083fe18e09 100644 --- a/dist/immutable-nonambient.d.ts +++ b/dist/immutable-nonambient.d.ts @@ -173,9 +173,9 @@ * listFromPlainSet.equals(listFromPlainArray) // true * ``` */ - export function List(): List; - export function List(): List; export function List(collection: Iterable): List; + export function List(): List; + export function List(): List; export interface List extends Collection.Indexed { @@ -1603,9 +1603,9 @@ * Note: `Set` is a factory function and not a class, and does not use the * `new` keyword during construction. */ - export function Set(): Set; - export function Set(): Set; export function Set(collection: Iterable): Set; + export function Set(): Set; + export function Set(): Set; export interface Set extends Collection.Set { @@ -1787,9 +1787,9 @@ * Note: `OrderedSet` is a factory function and not a class, and does not use * the `new` keyword during construction. */ - export function OrderedSet(): OrderedSet; - export function OrderedSet(): OrderedSet; export function OrderedSet(collection: Iterable): OrderedSet; + export function OrderedSet(): OrderedSet; + export function OrderedSet(): OrderedSet; export interface OrderedSet extends Set { @@ -1947,9 +1947,9 @@ * Note: `Stack` is a factory function and not a class, and does not use the * `new` keyword during construction. */ - export function Stack(): Stack; - export function Stack(): Stack; export function Stack(collection: Iterable): Stack; + export function Stack(): Stack; + export function Stack(): Stack; export interface Stack extends Collection.Indexed { @@ -2382,7 +2382,7 @@ * Record.getDescriptiveName(me) // "Person" * ``` */ - export function getDescriptiveName(record: Record<{}>): string; + export function getDescriptiveName(record: Record): string; /** * A Record.Factory is created by the `Record()` function. Record instances @@ -2697,7 +2697,7 @@ * * Converts keys to Strings. */ - toJS(): Object; + toJS(): { [key: string]: unknown }; /** * Shallowly converts this Keyed Seq to equivalent native JavaScript Object. @@ -2810,9 +2810,9 @@ * Note: `Seq.Indexed` is a conversion function and not a class, and does * not use the `new` keyword during construction. */ - export function Indexed(): Seq.Indexed; - export function Indexed(): Seq.Indexed; export function Indexed(collection: Iterable): Seq.Indexed; + export function Indexed(): Seq.Indexed; + export function Indexed(): Seq.Indexed; export interface Indexed extends Seq, Collection.Indexed { /** @@ -2962,9 +2962,9 @@ * Note: `Seq.Set` is a conversion function and not a class, and does not * use the `new` keyword during construction. */ - export function Set(): Seq.Set; - export function Set(): Seq.Set; export function Set(collection: Iterable): Seq.Set; + export function Set(): Seq.Set; + export function Set(): Seq.Set; export interface Set extends Seq, Collection.Set { /** @@ -3248,7 +3248,7 @@ * * Converts keys to Strings. */ - toJS(): Object; + toJS(): { [key: string]: unknown }; /** * Shallowly converts this Keyed collection to equivalent native JavaScript Object. diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index bfb81f66b5..f039e816d9 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -173,9 +173,9 @@ declare module Immutable { * listFromPlainSet.equals(listFromPlainArray) // true * ``` */ - export function List(): List; - export function List(): List; export function List(collection: Iterable): List; + export function List(): List; + export function List(): List; export interface List extends Collection.Indexed { @@ -1603,9 +1603,9 @@ declare module Immutable { * Note: `Set` is a factory function and not a class, and does not use the * `new` keyword during construction. */ - export function Set(): Set; - export function Set(): Set; export function Set(collection: Iterable): Set; + export function Set(): Set; + export function Set(): Set; export interface Set extends Collection.Set { @@ -1787,9 +1787,9 @@ declare module Immutable { * Note: `OrderedSet` is a factory function and not a class, and does not use * the `new` keyword during construction. */ - export function OrderedSet(): OrderedSet; - export function OrderedSet(): OrderedSet; export function OrderedSet(collection: Iterable): OrderedSet; + export function OrderedSet(): OrderedSet; + export function OrderedSet(): OrderedSet; export interface OrderedSet extends Set { @@ -1947,9 +1947,9 @@ declare module Immutable { * Note: `Stack` is a factory function and not a class, and does not use the * `new` keyword during construction. */ - export function Stack(): Stack; - export function Stack(): Stack; export function Stack(collection: Iterable): Stack; + export function Stack(): Stack; + export function Stack(): Stack; export interface Stack extends Collection.Indexed { @@ -2382,7 +2382,7 @@ declare module Immutable { * Record.getDescriptiveName(me) // "Person" * ``` */ - export function getDescriptiveName(record: Record<{}>): string; + export function getDescriptiveName(record: Record): string; /** * A Record.Factory is created by the `Record()` function. Record instances @@ -2697,7 +2697,7 @@ declare module Immutable { * * Converts keys to Strings. */ - toJS(): Object; + toJS(): { [key: string]: unknown }; /** * Shallowly converts this Keyed Seq to equivalent native JavaScript Object. @@ -2810,9 +2810,9 @@ declare module Immutable { * Note: `Seq.Indexed` is a conversion function and not a class, and does * not use the `new` keyword during construction. */ - export function Indexed(): Seq.Indexed; - export function Indexed(): Seq.Indexed; export function Indexed(collection: Iterable): Seq.Indexed; + export function Indexed(): Seq.Indexed; + export function Indexed(): Seq.Indexed; export interface Indexed extends Seq, Collection.Indexed { /** @@ -2962,9 +2962,9 @@ declare module Immutable { * Note: `Seq.Set` is a conversion function and not a class, and does not * use the `new` keyword during construction. */ - export function Set(): Seq.Set; - export function Set(): Seq.Set; export function Set(collection: Iterable): Seq.Set; + export function Set(): Seq.Set; + export function Set(): Seq.Set; export interface Set extends Seq, Collection.Set { /** @@ -3248,7 +3248,7 @@ declare module Immutable { * * Converts keys to Strings. */ - toJS(): Object; + toJS(): { [key: string]: unknown }; /** * Shallowly converts this Keyed collection to equivalent native JavaScript Object. From b45b2f7c0ddca40e95d382b5e36171aa2322290b Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 5 Jul 2021 06:50:40 +0000 Subject: [PATCH 148/242] deploy: cb534f07b4187c1c32cd1a166dec257f55f28c51 --- README.md | 164 ++-- bower.json | 1 - contrib/cursor/README.md | 43 - contrib/cursor/__tests__/Cursor.ts.skip | 388 -------- contrib/cursor/index.d.ts | 280 ------ contrib/cursor/index.js | 353 ------- dist/immutable-nonambient.d.ts | 636 ++++++++---- dist/immutable.d.ts | 640 ++++++++---- dist/immutable.es.js | 439 +++++---- dist/immutable.js | 464 +++++---- dist/immutable.js.flow | 1183 ++++++++++++++++++----- dist/immutable.min.js | 55 ++ package.json | 1 - 13 files changed, 2496 insertions(+), 2151 deletions(-) delete mode 100644 contrib/cursor/README.md delete mode 100644 contrib/cursor/__tests__/Cursor.ts.skip delete mode 100644 contrib/cursor/index.d.ts delete mode 100644 contrib/cursor/index.js create mode 100644 dist/immutable.min.js diff --git a/README.md b/README.md index b8c448c3aa..1f5b3e0d93 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ -Immutable collections for JavaScript -==================================== +# Immutable collections for JavaScript -[![Build Status](https://github.com/immutable-js/immutable-js/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/immutable-js/immutable-js/actions/workflows/ci.yml?query=branch%3Amain) [![Join the chat at https://gitter.im/immutable-js/Lobby](https://badges.gitter.im/immutable-js/Lobby.svg)](https://gitter.im/immutable-js/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +[![Build Status](https://github.com/immutable-js/immutable-js/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/immutable-js/immutable-js/actions/workflows/ci.yml?query=branch%3Amain) [Chat on slack](https://immutable-js.slack.com) [Immutable][] data cannot be changed once created, leading to much simpler application development, no defensive copying, and enabling advanced memoization @@ -29,9 +28,7 @@ Want to hear more? Watch the presentation about Immutable.js: [hash maps tries]: https://en.wikipedia.org/wiki/Hash_array_mapped_trie [vector tries]: https://hypirion.com/musings/understanding-persistent-vector-pt-1 - -Getting started ---------------- +## Getting started Install `immutable` using npm. @@ -39,14 +36,21 @@ Install `immutable` using npm. npm install immutable ``` +Or install using yarn. + +```shell +yarn add immutable +``` + Then require it into any module. + ```js const { Map } = require('immutable'); const map1 = Map({ a: 1, b: 2, c: 3 }); const map2 = map1.set('b', 50); -map1.get('b') + " vs. " + map2.get('b'); // 2 vs. 50 +map1.get('b') + ' vs. ' + map2.get('b'); // 2 vs. 50 ``` ### Browser @@ -104,11 +108,12 @@ lib. Include either `"target": "es2015"` or `"lib": "es2015"` in your `tsc` command. + ```js -const { Map } = require("immutable"); +const { Map } = require('immutable'); const map1 = Map({ a: 1, b: 2, c: 3 }); const map2 = map1.set('b', 50); -map1.get('b') + " vs. " + map2.get('b'); // 2 vs. 50 +map1.get('b') + ' vs. ' + map2.get('b'); // 2 vs. 50 ``` #### Using TypeScript with Immutable.js v3 and earlier: @@ -126,9 +131,7 @@ map1.get('b'); // 2 map2.get('b'); // 50 ``` - -The case for Immutability -------------------------- +## The case for Immutability Much of what makes application development difficult is tracking mutation and maintaining state. Developing with immutable data encourages you to think @@ -147,15 +150,16 @@ and especially well with an application designed using the ideas of [Flux][]. When data is passed from above rather than being subscribed to, and you're only interested in doing work when something has changed, you can use equality. -Immutable collections should be treated as *values* rather than *objects*. While +Immutable collections should be treated as _values_ rather than _objects_. While objects represent some thing which could change over time, a value represents the state of that thing at a particular instance of time. This principle is most important to understanding the appropriate use of immutable data. In order to treat Immutable.js collections as values, it's important to use the -`Immutable.is()` function or `.equals()` method to determine *value equality* -instead of the `===` operator which determines object *reference identity*. +`Immutable.is()` function or `.equals()` method to determine _value equality_ +instead of the `===` operator which determines object _reference identity_. + ```js const { Map } = require('immutable'); const map1 = Map({ a: 1, b: 2, c: 3 }); @@ -173,6 +177,7 @@ potentially be more costly. The `===` equality check is also used internally by `Immutable.is` and `.equals()` as a performance optimization. + ```js const { Map } = require('immutable'); const map1 = Map({ a: 1, b: 2, c: 3 }); @@ -186,6 +191,7 @@ than the object itself, this results in memory savings and a potential boost in execution speed for programs which rely on copies (such as an undo-stack). + ```js const { Map } = require('immutable'); const map = Map({ a: 1, b: 2, c: 3 }); @@ -196,18 +202,17 @@ const mapCopy = map; // Look, "copies" are free! [Flux]: https://facebook.github.io/flux/docs/in-depth-overview/ -JavaScript-first API --------------------- +## JavaScript-first API While Immutable.js is inspired by Clojure, Scala, Haskell and other functional programming environments, it's designed to bring these powerful concepts to JavaScript, and therefore has an Object-Oriented API that closely mirrors that of [ES2015][] [Array][], [Map][], and [Set][]. -[ES2015]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/New_in_JavaScript/ECMAScript_6_support_in_Mozilla -[Array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array -[Map]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map -[Set]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set +[es2015]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/New_in_JavaScript/ECMAScript_6_support_in_Mozilla +[array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array +[map]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map +[set]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set The difference for the immutable collections is that methods which would mutate the collection, like `push`, `set`, `unshift` or `splice`, instead return a new @@ -215,9 +220,10 @@ immutable collection. Methods which return new arrays, like `slice` or `concat`, instead return new immutable collections. + ```js const { List } = require('immutable'); -const list1 = List([ 1, 2 ]); +const list1 = List([1, 2]); const list2 = list1.push(3, 4, 5); const list3 = list2.unshift(0); const list4 = list1.concat(list2, list3); @@ -234,6 +240,7 @@ found on `Immutable.Set`, including collection operations like `forEach()` and `map()`. + ```js const { Map } = require('immutable'); const alpha = Map({ a: 1, b: 2, c: 3, d: 4 }); @@ -248,6 +255,7 @@ accepts plain JavaScript Arrays and Objects anywhere a method expects a `Collection`. + ```js const { Map, List } = require('immutable'); const map1 = Map({ a: 1, b: 2, c: 3, d: 4 }); @@ -255,9 +263,9 @@ const map2 = Map({ c: 10, a: 20, t: 30 }); const obj = { d: 100, o: 200, g: 300 }; const map3 = map1.merge(map2, obj); // Map { a: 20, b: 2, c: 10, d: 100, t: 30, o: 200, g: 300 } -const list1 = List([ 1, 2, 3 ]); -const list2 = List([ 4, 5, 6 ]); -const array = [ 7, 8, 9 ]; +const list1 = List([1, 2, 3]); +const list2 = List([4, 5, 6]); +const array = [7, 8, 9]; const list3 = list1.concat(list2, array); // List [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ] ``` @@ -269,10 +277,13 @@ native API. Because Seq evaluates lazily and does not cache intermediate results, these operations can be extremely efficient. + ```js const { Seq } = require('immutable'); const myObject = { a: 1, b: 2, c: 3 }; -Seq(myObject).map(x => x * x).toObject(); +Seq(myObject) + .map(x => x * x) + .toObject(); // { a: 1, b: 4, c: 9 } ``` @@ -281,22 +292,22 @@ JavaScript Object properties are always strings, even if written in a quote-less shorthand, while Immutable Maps accept keys of any type. + ```js const { fromJS } = require('immutable'); -const obj = { 1: "one" }; +const obj = { 1: 'one' }; console.log(Object.keys(obj)); // [ "1" ] -console.log(obj["1"], obj[1]); // "one", "one" +console.log(obj['1'], obj[1]); // "one", "one" const map = fromJS(obj); -console.log(map.get("1"), map.get(1)); // "one", undefined +console.log(map.get('1'), map.get(1)); // "one", undefined ``` Property access for JavaScript Objects first converts the key to a string, but since Immutable Map keys can be of any type the argument to `get()` is not altered. - ### Converts back to raw JavaScript objects. All Immutable.js Collections can be converted to plain JavaScript Arrays and @@ -306,9 +317,10 @@ to `JSON.stringify` directly. They also respect the custom `toJSON()` methods of nested objects. + ```js const { Map, List } = require('immutable'); -const deep = Map({ a: 1, b: 2, c: List([ 3, 4, 5 ]) }); +const deep = Map({ a: 1, b: 2, c: List([3, 4, 5]) }); console.log(deep.toObject()); // { a: 1, b: 2, c: List [ 3, 4, 5 ] } console.log(deep.toArray()); // [ 1, 2, List [ 3, 4, 5 ] ] console.log(deep.toJS()); // { a: 1, b: 2, c: [ 3, 4, 5 ] } @@ -318,7 +330,7 @@ JSON.stringify(deep); // '{"a":1,"b":2,"c":[3,4,5]}' ### Embraces ES2015 Immutable.js supports all JavaScript environments, including legacy -browsers (even IE8). However it also takes advantage of features added to +browsers (even IE11). However it also takes advantage of features added to JavaScript in [ES2015][], the latest standard version of JavaScript, including [Iterators][], [Arrow Functions][], [Classes][], and [Modules][]. It's inspired by the native [Map][] and [Set][] collections added to ES2015. @@ -330,17 +342,20 @@ browsers, they need to be translated to ES5. // ES2015 const mapped = foo.map(x => x * x); // ES5 -var mapped = foo.map(function (x) { return x * x; }); +var mapped = foo.map(function (x) { + return x * x; +}); ``` -All Immutable.js collections are [Iterable][Iterators], which allows them to be +All Immutable.js collections are [Iterable][iterators], which allows them to be used anywhere an Iterable is expected, such as when spreading into an Array. + ```js const { List } = require('immutable'); -const aList = List([ 1, 2, 3 ]); -const anArray = [ 0, ...aList, 4, 5 ]; // [ 0, 1, 2, 3, 4, 5 ] +const aList = List([1, 2, 3]); +const anArray = [0, ...aList, 4, 5]; // [ 0, 1, 2, 3, 4, 5 ] ``` Note: A Collection is always iterated in the same order, however that order may @@ -352,16 +367,16 @@ not always be well defined, as is the case for the `Map` and `Set`. [Modules]: https://www.2ality.com/2014/09/es6-modules-final.html -Nested Structures ------------------ +## Nested Structures The collections in Immutable.js are intended to be nested, allowing for deep trees of data, similar to JSON. + ```js const { fromJS } = require('immutable'); -const nested = fromJS({ a: { b: { c: [ 3, 4, 5 ] } } }); +const nested = fromJS({ a: { b: { c: [3, 4, 5] } } }); // Map { a: Map { b: Map { c: List [ 3, 4, 5 ] } } } ``` @@ -370,37 +385,37 @@ most useful are `mergeDeep`, `getIn`, `setIn`, and `updateIn`, found on `List`, `Map` and `OrderedMap`. + ```js const { fromJS } = require('immutable'); -const nested = fromJS({ a: { b: { c: [ 3, 4, 5 ] } } }); +const nested = fromJS({ a: { b: { c: [3, 4, 5] } } }); const nested2 = nested.mergeDeep({ a: { b: { d: 6 } } }); // Map { a: Map { b: Map { c: List [ 3, 4, 5 ], d: 6 } } } -console.log(nested2.getIn([ 'a', 'b', 'd' ])); // 6 +console.log(nested2.getIn(['a', 'b', 'd'])); // 6 -const nested3 = nested2.updateIn([ 'a', 'b', 'd' ], value => value + 1); +const nested3 = nested2.updateIn(['a', 'b', 'd'], value => value + 1); console.log(nested3); // Map { a: Map { b: Map { c: List [ 3, 4, 5 ], d: 7 } } } -const nested4 = nested3.updateIn([ 'a', 'b', 'c' ], list => list.push(6)); +const nested4 = nested3.updateIn(['a', 'b', 'c'], list => list.push(6)); // Map { a: Map { b: Map { c: List [ 3, 4, 5, 6 ], d: 7 } } } ``` +## Equality treats Collections as Values -Equality treats Collections as Values -------------------------------------- - -Immutable.js collections are treated as pure data *values*. Two immutable -collections are considered *value equal* (via `.equals()` or `is()`) if they +Immutable.js collections are treated as pure data _values_. Two immutable +collections are considered _value equal_ (via `.equals()` or `is()`) if they represent the same collection of values. This differs from JavaScript's typical -*reference equal* (via `===` or `==`) for Objects and Arrays which only +_reference equal_ (via `===` or `==`) for Objects and Arrays which only determines if two variables represent references to the same object instance. Consider the example below where two identical `Map` instances are not -*reference equal* but are *value equal*. +_reference equal_ but are _value equal_. + ```js // First consider: const obj1 = { a: 1, b: 2, c: 3 }; @@ -419,6 +434,7 @@ Value equality allows Immutable.js collections to be used as keys in Maps or values in Sets, and retrieved with different but equivalent collections: + ```js const { Map, Set } = require('immutable'); const map1 = Map({ a: 1, b: 2, c: 3 }); @@ -432,7 +448,7 @@ strings and numbers, but uses value equality for Immutable collections, determining if both are immutable and all keys and values are equal using the same measure of equality. -[Object.is]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is +[object.is]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is #### Performance tradeoffs @@ -454,10 +470,11 @@ out the possibility that they may be value-equal. #### Return self on no-op optimization When possible, Immutable.js avoids creating new objects for updates where no -change in *value* occurred, to allow for efficient *reference equality* checking +change in _value_ occurred, to allow for efficient _reference equality_ checking to quickly determine if no change occurred. + ```js const { Map } = require('immutable'); const originalMap = Map({ a: 1, b: 2, c: 3 }); @@ -470,6 +487,7 @@ of these operations occur independently, so two similar updates will not return the same reference: + ```js const { Map } = require('immutable'); const originalMap = Map({ a: 1, b: 2, c: 3 }); @@ -483,8 +501,7 @@ anotherUpdatedMap !== updatedMap; anotherUpdatedMap.equals(updatedMap); ``` -Batching Mutations ------------------- +## Batching Mutations > If a tree falls in the woods, does it make a sound? > @@ -498,15 +515,16 @@ which can add up to a minor performance penalty. If you need to apply a series of mutations locally before returning, Immutable.js gives you the ability to create a temporary mutable (transient) copy of a collection and apply a batch of mutations in a performant manner by using `withMutations`. In fact, this is -exactly how Immutable.js applies complex mutations itself. +exactly how Immutable.js applies complex mutations itself. As an example, building `list2` results in the creation of 1, not 3, new immutable Lists. + ```js const { List } = require('immutable'); -const list1 = List([ 1, 2, 3 ]); +const list1 = List([1, 2, 3]); const list2 = list1.withMutations(function (list) { list.push(4).push(5).push(6); }); @@ -518,15 +536,13 @@ Note: Immutable.js also provides `asMutable` and `asImmutable`, but only encourages their use when `withMutations` will not suffice. Use caution to not return a mutable copy, which could result in undesired behavior. -*Important!*: Only a select few methods can be used in `withMutations` including +_Important!_: Only a select few methods can be used in `withMutations` including `set`, `push` and `pop`. These methods can be applied directly against a persistent data-structure where other methods like `map`, `filter`, `sort`, and `splice` will always return new immutable data-structures and never mutate a mutable collection. - -Lazy Seq --------- +## Lazy Seq `Seq` describes a lazy operation, allowing them to efficiently chain use of all the higher-order collection methods (such as `map` and `filter`) @@ -546,7 +562,7 @@ For example, the following performs no work, because the resulting ```js const { Seq } = require('immutable'); -const oddSquares = Seq([ 1, 2, 3, 4, 5, 6, 7, 8 ]) +const oddSquares = Seq([1, 2, 3, 4, 5, 6, 7, 8]) .filter(x => x % 2 !== 0) .map(x => x * x); ``` @@ -562,6 +578,7 @@ oddSquares.get(1); // 9 Any collection can be converted to a lazy Seq with `Seq()`. + ```js const { Map, Seq } = require('immutable'); const map = Map({ a: 1, b: 2, c: 3 }); @@ -583,6 +600,7 @@ As well as expressing logic that would otherwise seem memory or time limited, for example `Range` is a special kind of Lazy sequence. + ```js const { Range } = require('immutable'); Range(1, Infinity) @@ -594,9 +612,9 @@ Range(1, Infinity) // 1006008 ``` +## Documentation -Documentation -------------- +## Documentation [Read the docs](https://immutable-js.com) and eat your vegetables. @@ -606,15 +624,13 @@ Please contribute! Also, don't miss the [Wiki](https://github.com/immutable-js/immutable-js/wiki) which contains articles on specific topics. Can't find something? Open an [issue](https://github.com/immutable-js/immutable-js/issues). - -Testing -------- +## Testing If you are using the [Chai Assertion Library](https://chaijs.com/), [Chai Immutable](https://github.com/astorije/chai-immutable) provides a set of assertions to use against Immutable.js collections. +## Contribution -Contribution ------------- +## Contribution Use [Github issues](https://github.com/immutable-js/immutable-js/issues) for requests. @@ -622,15 +638,13 @@ We actively welcome pull requests, learn how to [contribute](https://github.com/ Immutable.js is maintained within the [Contributor Covenant's Code of Conduct](https://www.contributor-covenant.org/version/2/0/code_of_conduct/). +We actively welcome pull requests, learn how to [contribute](https://github.com/immutable-js/immutable-js/blob/main/.github/CONTRIBUTING.md). -Changelog ---------- +## Changelog Changes are tracked as [Github releases](https://github.com/immutable-js/immutable-js/releases). - -Thanks ------- +## Thanks [Phil Bagwell](https://www.youtube.com/watch?v=K2NYwP90bNs), for his inspiration and research in persistent data structures. @@ -638,8 +652,6 @@ and research in persistent data structures. [Hugh Jackson](https://github.com/hughfdjackson/), for providing the npm package name. If you're looking for his unsupported package, see [this repository](https://github.com/hughfdjackson/immutable). - -License -------- +## License Immutable.js is [MIT-licensed](./LICENSE). diff --git a/bower.json b/bower.json index 66c3e1a950..b2c7e9c03d 100644 --- a/bower.json +++ b/bower.json @@ -23,7 +23,6 @@ }, "files": [ "dist", - "contrib", "README.md", "LICENSE" ], diff --git a/contrib/cursor/README.md b/contrib/cursor/README.md deleted file mode 100644 index 40871ca436..0000000000 --- a/contrib/cursor/README.md +++ /dev/null @@ -1,43 +0,0 @@ -# DEPRECATED - -The Cursor API is deprecated and will be removed in a future major release. - -It is strongly suggested that you use the excellent `immutable-cursor` module -which has an extremely similar API but is much higher quality. - -https://github.com/redbadger/immutable-cursor - - -Cursors -------- - -Cursors allow you to hold a reference to a path in a nested immutable data -structure, allowing you to pass smaller sections of a larger nested -collection to portions of your application while maintaining a central point -aware of changes to the entire data structure: an `onChange` function which is -called whenever a cursor or sub-cursor calls `update`. - -This is particularly useful when used in conjunction with component-based UI -libraries like [React](https://reactjs.org/) or to simulate -"state" throughout an application while maintaining a single flow of logic. - - -```javascript -var Immutable = require('immutable'); -var Cursor = require('immutable/contrib/cursor'); - -var data = Immutable.fromJS({ a: { b: { c: 1 } } }); -var cursor = Cursor.from(data, ['a', 'b'], newData => { - data = newData; -}); - -// ... elsewhere ... - -cursor.get('c'); // 1 -cursor = cursor.update('c', x => x + 1); -cursor.get('c'); // 2 - -// ... back to data ... - -data.getIn(['a', 'b', 'c']); // 2 -``` diff --git a/contrib/cursor/__tests__/Cursor.ts.skip b/contrib/cursor/__tests__/Cursor.ts.skip deleted file mode 100644 index 0a1892386c..0000000000 --- a/contrib/cursor/__tests__/Cursor.ts.skip +++ /dev/null @@ -1,388 +0,0 @@ -/// - -import * as Immutable from '../../../'; -import * as Cursor from '../'; - -describe('Cursor', () => { - - beforeEach(function () { - jasmine.addMatchers({ - toValueEqual: function(actual, expected) { - var passed = Immutable.is(actual, expected); - return { - pass: passed, - message: 'Expected ' + actual + (passed ? '' : ' not') + ' to equal ' + expected - }; - } - }); - }); - - var json = { a: { b: { c: 1 } } }; - - it('gets from its path', () => { - var data = Immutable.fromJS(json); - var cursor = Cursor.from(data); - - expect(cursor.deref()).toBe(data); - - var deepCursor = cursor.cursor(['a', 'b']); - expect(deepCursor.deref().toJS()).toEqual(json.a.b); - expect(deepCursor.deref()).toBe(data.getIn(['a', 'b'])); - expect(deepCursor.get('c')).toBe(1); - - var leafCursor = deepCursor.cursor('c'); - expect(leafCursor.deref()).toBe(1); - - var missCursor = leafCursor.cursor('d'); - expect(missCursor.deref()).toBe(undefined); - }); - - it('gets return new cursors', () => { - var data = Immutable.fromJS(json); - var cursor = Cursor.from(data); - var deepCursor = cursor.getIn(['a', 'b']); - expect(deepCursor.deref()).toBe(data.getIn(['a', 'b'])); - }); - - it('gets return new cursors using List', () => { - var data = Immutable.fromJS(json); - var cursor = Cursor.from(data); - var deepCursor = cursor.getIn(Immutable.fromJS(['a', 'b'])); - expect(deepCursor.deref()).toBe(data.getIn(Immutable.fromJS(['a', 'b']))); - }); - - it('cursor return new cursors of correct type', () => { - var data = Immutable.fromJS({ a: [1, 2, 3] }); - var cursor = Cursor.from(data); - var deepCursor = cursor.cursor('a'); - expect(deepCursor.findIndex).toBeDefined(); - }); - - it('can be treated as a value', () => { - var data = Immutable.fromJS(json); - var cursor = Cursor.from(data, ['a', 'b']); - expect(cursor.toJS()).toEqual(json.a.b); - expect(cursor).toValueEqual(data.getIn(['a', 'b'])); - expect(cursor.size).toBe(1); - expect(cursor.get('c')).toBe(1); - }); - - it('can be value compared to a primitive', () => { - var data = Immutable.Map({ a: 'A' }); - var aCursor = Cursor.from(data, 'a'); - expect(aCursor.size).toBe(undefined); - expect(aCursor.deref()).toBe('A'); - expect(Immutable.is(aCursor, 'A')).toBe(true); - }); - - it('updates at its path', () => { - var onChange = jest.genMockFunction(); - - var data = Immutable.fromJS(json); - var aCursor = Cursor.from(data, 'a', onChange); - - var deepCursor = aCursor.cursor(['b', 'c']); - expect(deepCursor.deref()).toBe(1); - - // cursor edits return new cursors: - var newDeepCursor = deepCursor.update(x => x + 1); - expect(newDeepCursor.deref()).toBe(2); - var call1 = onChange.mock.calls[0]; - expect(call1[0]).toValueEqual(Immutable.fromJS({a:{b:{c:2}}})); - expect(call1[1]).toBe(data); - expect(call1[2]).toEqual(['a', 'b', 'c']); - - var newestDeepCursor = newDeepCursor.update(x => x + 1); - expect(newestDeepCursor.deref()).toBe(3); - var call2 = onChange.mock.calls[1]; - expect(call2[0]).toValueEqual(Immutable.fromJS({a:{b:{c:3}}})); - expect(call2[1]).toValueEqual(Immutable.fromJS({a:{b:{c:2}}})); - expect(call2[2]).toEqual(['a', 'b', 'c']); - - // meanwhile, data is still immutable: - expect(data.toJS()).toEqual(json); - - // as is the original cursor. - expect(deepCursor.deref()).toBe(1); - var otherNewDeepCursor = deepCursor.update(x => x + 10); - expect(otherNewDeepCursor.deref()).toBe(11); - var call3 = onChange.mock.calls[2]; - expect(call3[0]).toValueEqual(Immutable.fromJS({a:{b:{c:11}}})); - expect(call3[1]).toBe(data); - expect(call3[2]).toEqual(['a', 'b', 'c']); - - // and update has been called exactly thrice. - expect(onChange.mock.calls.length).toBe(3); - }); - - it('updates with the return value of onChange', () => { - var onChange = jest.genMockFunction(); - - var data = Immutable.fromJS(json); - var deepCursor = Cursor.from(data, ['a', 'b', 'c'], onChange); - - onChange.mockReturnValueOnce(undefined); - // onChange returning undefined has no effect - var newCursor = deepCursor.update(x => x + 1); - expect(newCursor.deref()).toBe(2); - var call1 = onChange.mock.calls[0]; - expect(call1[0]).toValueEqual(Immutable.fromJS({a:{b:{c:2}}})); - expect(call1[1]).toBe(data); - expect(call1[2]).toEqual(['a', 'b', 'c']); - - onChange.mockReturnValueOnce(Immutable.fromJS({a:{b:{c:11}}})); - // onChange returning something else has an effect - newCursor = newCursor.update(x => 999); - expect(newCursor.deref()).toBe(11); - var call2 = onChange.mock.calls[1]; - expect(call2[0]).toValueEqual(Immutable.fromJS({a:{b:{c:999}}})); - expect(call2[1]).toValueEqual(Immutable.fromJS({a:{b:{c:2}}})); - expect(call2[2]).toEqual(['a', 'b', 'c']); - - // and update has been called exactly twice - expect(onChange.mock.calls.length).toBe(2); - }); - - it('has map API for update shorthand', () => { - var onChange = jest.genMockFunction(); - - var data = Immutable.fromJS(json); - var aCursor = Cursor.from(data, 'a', onChange); - var bCursor = aCursor.cursor('b'); - var cCursor = bCursor.cursor('c'); - - expect(bCursor.set('c', 10).deref()).toValueEqual( - Immutable.fromJS({ c: 10 }) - ); - - var call1 = onChange.mock.calls[0]; - expect(call1[0]).toValueEqual(Immutable.fromJS({a:{b:{c:10}}})); - expect(call1[1]).toBe(data); - expect(call1[2]).toEqual(['a', 'b', 'c']); - }); - - it('creates maps as necessary', () => { - var data = Immutable.Map(); - var cursor = Cursor.from(data, ['a', 'b', 'c']); - expect(cursor.deref()).toBe(undefined); - cursor = cursor.set('d', 3); - expect(cursor.deref()).toValueEqual(Immutable.Map({d: 3})); - }); - - it('can set undefined', () => { - var data = Immutable.Map(); - var cursor = Cursor.from(data, ['a', 'b', 'c']); - expect(cursor.deref()).toBe(undefined); - cursor = cursor.set('d', undefined); - expect(cursor.toJS()).toEqual({d: undefined}); - }); - - it('has the sequence API', () => { - var data = Immutable.Map({a: 1, b: 2, c: 3}); - var cursor = Cursor.from(data); - expect(cursor.map((x: number) => x * x)).toValueEqual(Immutable.Map({a: 1, b: 4, c: 9})); - }); - - it('can push values on a List', () => { - var onChange = jest.genMockFunction(); - var data = Immutable.fromJS({a: {b: [0, 1, 2]}}); - var cursor = Cursor.from(data, ['a', 'b'], onChange); - - expect(cursor.push(3,4)).toValueEqual(Immutable.List([0, 1, 2, 3, 4])); - - var call = onChange.mock.calls[0]; - expect(call[0]).toValueEqual(Immutable.fromJS({a: {b: [0, 1, 2, 3, 4]}})); - expect(call[1]).toBe(data); - expect(call[2]).toEqual(['a', 'b']); - }); - - it('can pop values of a List', () => { - var onChange = jest.genMockFunction(); - var data = Immutable.fromJS({a: {b: [0, 1, 2]}}); - var cursor = Cursor.from(data, ['a', 'b'], onChange); - - expect(cursor.pop()).toValueEqual(Immutable.List([0, 1])); - - var call = onChange.mock.calls[0]; - expect(call[0]).toValueEqual(Immutable.fromJS({a: {b: [0, 1]}})); - expect(call[1]).toBe(data); - expect(call[2]).toEqual(['a', 'b']); - }); - - it('can unshift values on a List', () => { - var onChange = jest.genMockFunction(); - var data = Immutable.fromJS({a: {b: [0, 1, 2]}}); - var cursor = Cursor.from(data, ['a', 'b'], onChange); - - expect(cursor.unshift(-2, -1)).toValueEqual(Immutable.List([-2, -1, 0, 1, 2])); - - var call = onChange.mock.calls[0]; - expect(call[0]).toValueEqual(Immutable.fromJS({a: {b: [-2, -1, 0, 1, 2]}})); - expect(call[1]).toBe(data); - expect(call[2]).toEqual(['a', 'b']); - }); - - it('can shift values of a List', () => { - var onChange = jest.genMockFunction(); - var data = Immutable.fromJS({a: {b: [0, 1, 2]}}); - var cursor = Cursor.from(data, ['a', 'b'], onChange); - - expect(cursor.shift()).toValueEqual(Immutable.List([1, 2])); - - var call = onChange.mock.calls[0]; - expect(call[0]).toValueEqual(Immutable.fromJS({a: {b: [1, 2]}})); - expect(call[1]).toBe(data); - expect(call[2]).toEqual(['a', 'b']); - }); - - - it('returns wrapped values for sequence API', () => { - var data = Immutable.fromJS({a: {v: 1}, b: {v: 2}, c: {v: 3}}); - var onChange = jest.genMockFunction(); - var cursor = Cursor.from(data, onChange); - - var found = cursor.find(map => map.get('v') === 2); - expect(typeof found.deref).toBe('function'); // is a cursor! - found = found.set('v', 20); - - var call = onChange.mock.calls[0]; - expect(call[0]).toValueEqual(Immutable.fromJS({a: {v: 1}, b: {v: 20}, c: {v: 3}})); - expect(call[1]).toBe(data); - expect(call[2]).toEqual(['b', 'v']); - }); - - it('returns wrapped values for iteration API', () => { - var jsData = [{val: 0}, {val: 1}, {val: 2}]; - var data = Immutable.fromJS(jsData); - var cursor = Cursor.from(data); - cursor.forEach(function (c, i) { - expect(typeof c.deref).toBe('function'); // is a cursor! - expect(c.get('val')).toBe(i); - }); - }); - - it('can map over values to get subcursors', () => { - var data = Immutable.fromJS({a: {v: 1}, b: {v: 2}, c: {v: 3}}); - var cursor = Cursor.from(data); - - var mapped = cursor.map(val => { - expect(typeof val.deref).toBe('function'); // mapped values are cursors. - return val; - }).toMap(); - // Mapped is not a cursor, but it is a sequence of cursors. - expect(typeof (mapped).deref).not.toBe('function'); - expect(typeof (mapped.get('a')).deref).toBe('function'); - - // Same for indexed cursors - var data2 = Immutable.fromJS({x: [{v: 1}, {v: 2}, {v: 3}]}); - var cursor2 = Cursor.from(data2); - - var mapped2 = cursor2.get('x').map(val => { - expect(typeof val.deref).toBe('function'); // mapped values are cursors. - return val; - }).toList(); - // Mapped is not a cursor, but it is a sequence of cursors. - expect(typeof mapped2.deref).not.toBe('function'); - expect(typeof mapped2.get(0).deref).toBe('function'); - }); - - it('can have mutations apply with a single callback', () => { - var onChange = jest.genMockFunction(); - var data = Immutable.fromJS({'a': 1}); - - var c1 = Cursor.from(data, onChange); - var c2 = c1.withMutations(m => m.set('b', 2).set('c', 3).set('d', 4)); - - expect(c1.deref().toObject()).toEqual({'a': 1}); - expect(c2.deref().toObject()).toEqual({'a': 1, 'b': 2, 'c': 3, 'd': 4}); - expect(onChange.mock.calls.length).toBe(1); - }); - - it('can use withMutations on an unfulfilled cursor', () => { - var onChange = jest.genMockFunction(); - var data = Immutable.fromJS({}); - - var c1 = Cursor.from(data, ['a', 'b', 'c'], onChange); - var c2 = c1.withMutations(m => m.set('x', 1).set('y', 2).set('z', 3)); - - expect(c1.deref()).toEqual(undefined); - expect(c2.deref()).toValueEqual(Immutable.fromJS( - { x: 1, y: 2, z: 3 } - )); - expect(onChange.mock.calls.length).toBe(1); - }); - - it('maintains indexed sequences', () => { - var data = Immutable.fromJS([]); - var c = Cursor.from(data); - expect(c.toJS()).toEqual([]); - }); - - it('properly acts as an iterable', () => { - var data = Immutable.fromJS({key: {val: 1}}); - var c = Cursor.from(data).values(); - var c1 = c.next().value.get('val'); - expect(c1).toBe(1); - }); - - it('can update deeply', () => { - var onChange = jest.genMockFunction(); - var data = Immutable.fromJS({a:{b:{c:1}}}); - var c = Cursor.from(data, ['a'], onChange); - var c1 = c.updateIn(['b', 'c'], x => x * 10); - expect(c1.getIn(['b', 'c'])).toBe(10); - - var call = onChange.mock.calls[0]; - expect(call[0]).toValueEqual(Immutable.fromJS({a:{b:{c:10}}})); - expect(call[1]).toBe(data); - expect(call[2]).toEqual(['a', 'b', 'c']); - }); - - it('can set deeply', () => { - var onChange = jest.genMockFunction(); - var data = Immutable.fromJS({a:{b:{c:1}}}); - var c = Cursor.from(data, ['a'], onChange); - var c1 = c.setIn(['b', 'c'], 10); - expect(c1.getIn(['b', 'c'])).toBe(10); - - var call = onChange.mock.calls[0]; - expect(call[0]).toValueEqual(Immutable.fromJS({a:{b:{c:10}}})); - expect(call[1]).toBe(data); - expect(call[2]).toEqual(['a', 'b', 'c']); - }); - - it('can get Record value as a property', () => { - var User = Immutable.Record({ name: 'John' }); - var users = Immutable.List.of(new User()); - var data = Immutable.Map({'users': users}); - var cursor = Cursor.from(data, ['users']); - expect(cursor.first().name).toBe('John'); - }); - - it('can set value of a cursor directly', () => { - var onChange = jest.genMockFunction(); - var data = Immutable.fromJS({a:1}); - var c = Cursor.from(data, ['a'], onChange); - var c1 = c.set(2); - expect(c1.deref()).toBe(2); - - var call = onChange.mock.calls[0]; - expect(call[0]).toValueEqual(Immutable.fromJS({a:2})); - expect(call[1]).toBe(data); - expect(call[2]).toEqual(['a']); - }); - - it('can set value of a cursor to undefined directly', () => { - var onChange = jest.genMockFunction(); - var data = Immutable.fromJS({a:1}); - var c = Cursor.from(data, ['a'], onChange); - var c1 = c.set(undefined); - expect(c1.deref()).toBe(undefined); - - var call = onChange.mock.calls[0]; - expect(call[0]).toValueEqual(Immutable.fromJS({a:undefined})); - expect(call[1]).toBe(data); - expect(call[2]).toEqual(['a']); - }); - -}); diff --git a/contrib/cursor/index.d.ts b/contrib/cursor/index.d.ts deleted file mode 100644 index d290fe4be0..0000000000 --- a/contrib/cursor/index.d.ts +++ /dev/null @@ -1,280 +0,0 @@ -/** - * Cursors - * ------- - * - * Cursors allow you to hold a reference to a path in a nested immutable data - * structure, allowing you to pass smaller sections of a larger nested - * collection to portions of your application while maintaining a central point - * aware of changes to the entire data structure. - * - * This is particularly useful when used in conjunction with component-based UI - * libraries like [React](https://reactjs.org/) or to simulate - * "state" throughout an application while maintaining a single flow of logic. - * - * Cursors provide a simple API for getting the value at that path - * (the equivalent of `this.getIn(keyPath)`), updating the value at that path - * (the equivalent of `this.updateIn(keyPath)`), and getting a sub-cursor - * starting from that path. - * - * When updated, a new root collection is created and provided to the `onChange` - * function provided to the first call to `Cursor(map, onChange)`. - * - * When this cursor's (or any of its sub-cursors') `update` method is called, - * the resulting new data structure will be provided to the `onChange` - * function. Use this callback to keep track of the most current value or - * update the rest of your application. - */ - -import * as Immutable from '../../'; - -export function from( - collection: Immutable.Collection, - onChange?: (newValue: any, oldValue?: any, keyPath?: Array) => any -): Cursor; -export function from( - collection: Immutable.Collection, - keyPath: Array, - onChange?: (newValue: any, oldValue?: any, keyPath?: Array) => any -): Cursor; -export function from( - collection: Immutable.Collection, - key: any, - onChange?: (newValue: any, oldValue?: any, keyPath?: Array) => any -): Cursor; - - -export interface Cursor extends Immutable.Iterable, Immutable.Seq { - - /** - * Returns a sub-cursor following the key-path starting from this cursor. - */ - cursor(subKeyPath: Array): Cursor; - cursor(subKey: any): Cursor; - - /** - * Returns the value at the cursor, if the cursor path does not yet exist, - * returns `notSetValue`. - */ - deref(notSetValue?: any): any; - - /** - * Returns the value at the `key` in the cursor, or `notSetValue` if it - * does not exist. - * - * If the key would return a collection, a new Cursor is returned. - */ - get(key: any, notSetValue?: any): any; - - /** - * Returns the value at the `keyPath` in the cursor, or `notSetValue` if it - * does not exist. - * - * If the keyPath would return a collection, a new Cursor is returned. - */ - getIn(keyPath: Array, notSetValue?: any): any; - getIn(keyPath: Immutable.Iterable, notSetValue?: any): any; - - /** - * Sets `value` at `key` in the cursor, returning a new cursor to the same - * point in the new data. - * - * If only one parameter is provided, it is set directly as the cursor's value. - */ - set(key: any, value: any): Cursor; - set(value: any): Cursor; - - /** - * Deletes `key` from the cursor, returning a new cursor to the same - * point in the new data. - * - * Note: `delete` cannot be safely used in IE8 - * @alias remove - */ - delete(key: any): Cursor; - remove(key: any): Cursor; - - /** - * Clears the value at this cursor, returning a new cursor to the same - * point in the new data. - */ - clear(): Cursor; - - /** - * Updates the value in the data this cursor points to, triggering the - * callback for the root cursor and returning a new cursor pointing to the - * new data. - */ - update(updater: (value: any) => any): Cursor; - update(key: any, updater: (value: any) => any): Cursor; - update(key: any, notSetValue: any, updater: (value: any) => any): Cursor; - - /** - * @see `Map#merge` - */ - merge(...iterables: Immutable.Iterable[]): Cursor; - merge(...iterables: {[key: string]: any}[]): Cursor; - - /** - * @see `Map#mergeWith` - */ - mergeWith( - merger: (previous?: any, next?: any) => any, - ...iterables: Immutable.Iterable[] - ): Cursor; - mergeWith( - merger: (previous?: any, next?: any) => any, - ...iterables: {[key: string]: any}[] - ): Cursor; - - /** - * @see `Map#mergeDeep` - */ - mergeDeep(...iterables: Immutable.Iterable[]): Cursor; - mergeDeep(...iterables: {[key: string]: any}[]): Cursor; - - /** - * @see `Map#mergeDeepWith` - */ - mergeDeepWith( - merger: (previous?: any, next?: any) => any, - ...iterables: Immutable.Iterable[] - ): Cursor; - mergeDeepWith( - merger: (previous?: any, next?: any) => any, - ...iterables: {[key: string]: any}[] - ): Cursor; - - // Deep persistent changes - - /** - * Returns a new Cursor having set `value` at this `keyPath`. If any keys in - * `keyPath` do not exist, a new immutable Map will be created at that key. - */ - setIn(keyPath: Array, value: any): Cursor; - setIn(keyPath: Immutable.Iterable, value: any): Cursor; - - /** - * Returns a new Cursor with provided `values` appended - */ - push(...values: Array): Cursor; - - /** - * Returns a new Cursor with a size ones less than this Cursor, - * excluding the last index in this Cursor. - */ - pop(): Cursor; - - /** - * Returns a new Cursor with the provided `values` prepended, - * shifting other values ahead to higher indices. - */ - unshift(...values: Array): Cursor; - - /** - * Returns a new Cursor with a size ones less than this Cursor, excluding - * the first index in this Cursor, shifting all other values to a lower index. - */ - shift(): Cursor; - - /** - * Returns a new Cursor having removed the value at this `keyPath`. - * - * @alias removeIn - */ - deleteIn(keyPath: Array): Cursor; - deleteIn(keyPath: Immutable.Iterable): Cursor; - removeIn(keyPath: Array): Cursor; - removeIn(keyPath: Immutable.Iterable): Cursor; - - /** - * Returns a new Cursor having applied the `updater` to the value found at - * the keyPath. - * - * If any keys in `keyPath` do not exist, new Immutable `Map`s will - * be created at those keys. If the `keyPath` does not already contain a - * value, the `updater` function will be called with `notSetValue`, if - * provided, otherwise `undefined`. - * - * If the `updater` function returns the same value it was called with, then - * no change will occur. This is still true if `notSetValue` is provided. - */ - updateIn( - keyPath: Array, - updater: (value: any) => any - ): Cursor; - updateIn( - keyPath: Array, - notSetValue: any, - updater: (value: any) => any - ): Cursor; - updateIn( - keyPath: Immutable.Iterable, - updater: (value: any) => any - ): Cursor; - updateIn( - keyPath: Immutable.Iterable, - notSetValue: any, - updater: (value: any) => any - ): Cursor; - - /** - * A combination of `updateIn` and `merge`, returning a new Cursor, but - * performing the merge at a point arrived at by following the keyPath. - * In other words, these two lines are equivalent: - * - * x.updateIn(['a', 'b', 'c'], abc => abc.merge(y)); - * x.mergeIn(['a', 'b', 'c'], y); - * - */ - mergeIn( - keyPath: Immutable.Iterable, - ...iterables: Immutable.Iterable[] - ): Cursor; - mergeIn( - keyPath: Array, - ...iterables: Immutable.Iterable[] - ): Cursor; - mergeIn( - keyPath: Array, - ...iterables: {[key: string]: any}[] - ): Cursor; - - /** - * A combination of `updateIn` and `mergeDeep`, returning a new Cursor, but - * performing the deep merge at a point arrived at by following the keyPath. - * In other words, these two lines are equivalent: - * - * x.updateIn(['a', 'b', 'c'], abc => abc.mergeDeep(y)); - * x.mergeDeepIn(['a', 'b', 'c'], y); - * - */ - mergeDeepIn( - keyPath: Immutable.Iterable, - ...iterables: Immutable.Iterable[] - ): Cursor; - mergeDeepIn( - keyPath: Array, - ...iterables: Immutable.Iterable[] - ): Cursor; - mergeDeepIn( - keyPath: Array, - ...iterables: {[key: string]: any}[] - ): Cursor; - - // Transient changes - - /** - * Every time you call one of the above functions, a new immutable value is - * created and the callback is triggered. If you need to apply a series of - * mutations to a Cursor without triggering the callback repeatedly, - * `withMutations()` creates a temporary mutable copy of the value which - * can apply mutations in a highly performant manner. Afterwards the - * callback is triggered with the final value. - */ - withMutations(mutator: (mutable: any) => any): Cursor; - - /** - * @ignore - */ - map(fn: (v: any, k: any, c: this) => any): this; -} diff --git a/contrib/cursor/index.js b/contrib/cursor/index.js deleted file mode 100644 index 38e9b1fde1..0000000000 --- a/contrib/cursor/index.js +++ /dev/null @@ -1,353 +0,0 @@ -/** - * DEPRECATED - * - * The Cursor API is deprecated and will be removed in a future major release. - * - * It is strongly suggested that you use the excellent `immutable-cursor` module - * which has an extremely similar API but is much higher quality. - * - * https://github.com/redbadger/immutable-cursor - */ -typeof console === 'object' && console.warn && console.warn( - 'The Cursor API is deprecated and will be removed in a future major release.\n' + - '\n' + - 'It is strongly suggested that you use the excellent `immutable-cursor` module\n' + - 'which has an extremely similar API but is much higher quality.\n' + - '\n' + - 'https://github.com/redbadger/immutable-cursor\n' + -); - -/** - * Cursor is expected to be required in a node or other CommonJS context: - * - * var Cursor = require('immutable/contrib/cursor'); - * - * If you wish to use it in the browser, please check out Browserify or WebPack! - */ - -var Immutable = require('../../'); -var Iterable = Immutable.Iterable; -var Iterator = Iterable.Iterator; -var Seq = Immutable.Seq; -var Map = Immutable.Map; -var Record = Immutable.Record; - - -function cursorFrom(rootData, keyPath, onChange) { - if (arguments.length === 1) { - keyPath = []; - } else if (typeof keyPath === 'function') { - onChange = keyPath; - keyPath = []; - } else { - keyPath = valToKeyPath(keyPath); - } - return makeCursor(rootData, keyPath, onChange); -} - - -var KeyedCursorPrototype = Object.create(Seq.Keyed.prototype); -var IndexedCursorPrototype = Object.create(Seq.Indexed.prototype); - -function KeyedCursor(rootData, keyPath, onChange, size) { - this.size = size; - this._rootData = rootData; - this._keyPath = keyPath; - this._onChange = onChange; -} -KeyedCursorPrototype.constructor = KeyedCursor; - -function IndexedCursor(rootData, keyPath, onChange, size) { - this.size = size; - this._rootData = rootData; - this._keyPath = keyPath; - this._onChange = onChange; -} -IndexedCursorPrototype.constructor = IndexedCursor; - -KeyedCursorPrototype.toString = function() { - return this.__toString('Cursor {', '}'); -} -IndexedCursorPrototype.toString = function() { - return this.__toString('Cursor [', ']'); -} - -KeyedCursorPrototype.deref = -KeyedCursorPrototype.valueOf = -IndexedCursorPrototype.deref = -IndexedCursorPrototype.valueOf = function(notSetValue) { - return this._rootData.getIn(this._keyPath, notSetValue); -} - -KeyedCursorPrototype.get = -IndexedCursorPrototype.get = function(key, notSetValue) { - return this.getIn([key], notSetValue); -} - -KeyedCursorPrototype.getIn = -IndexedCursorPrototype.getIn = function(keyPath, notSetValue) { - keyPath = listToKeyPath(keyPath); - if (keyPath.length === 0) { - return this; - } - var value = this._rootData.getIn(newKeyPath(this._keyPath, keyPath), NOT_SET); - return value === NOT_SET ? notSetValue : wrappedValue(this, keyPath, value); -} - -IndexedCursorPrototype.set = -KeyedCursorPrototype.set = function(key, value) { - if(arguments.length === 1) { - return updateCursor(this, function() { return key; }, []); - } else { - return updateCursor(this, function (m) { return m.set(key, value); }, [key]); - } -} - -IndexedCursorPrototype.push = function(/* values */) { - var args = arguments; - return updateCursor(this, function (m) { - return m.push.apply(m, args); - }); -} - -IndexedCursorPrototype.pop = function() { - return updateCursor(this, function (m) { - return m.pop(); - }); -} - -IndexedCursorPrototype.unshift = function(/* values */) { - var args = arguments; - return updateCursor(this, function (m) { - return m.unshift.apply(m, args); - }); -} - -IndexedCursorPrototype.shift = function() { - return updateCursor(this, function (m) { - return m.shift(); - }); -} - -IndexedCursorPrototype.setIn = -KeyedCursorPrototype.setIn = Map.prototype.setIn; - -KeyedCursorPrototype.remove = -KeyedCursorPrototype['delete'] = -IndexedCursorPrototype.remove = -IndexedCursorPrototype['delete'] = function(key) { - return updateCursor(this, function (m) { return m.remove(key); }, [key]); -} - -IndexedCursorPrototype.removeIn = -IndexedCursorPrototype.deleteIn = -KeyedCursorPrototype.removeIn = -KeyedCursorPrototype.deleteIn = Map.prototype.deleteIn; - -KeyedCursorPrototype.clear = -IndexedCursorPrototype.clear = function() { - return updateCursor(this, function (m) { return m.clear(); }); -} - -IndexedCursorPrototype.update = -KeyedCursorPrototype.update = function(keyOrFn, notSetValue, updater) { - return arguments.length === 1 ? - updateCursor(this, keyOrFn) : - this.updateIn([keyOrFn], notSetValue, updater); -} - -IndexedCursorPrototype.updateIn = -KeyedCursorPrototype.updateIn = function(keyPath, notSetValue, updater) { - return updateCursor(this, function (m) { - return m.updateIn(keyPath, notSetValue, updater); - }, keyPath); -} - -IndexedCursorPrototype.merge = -KeyedCursorPrototype.merge = function(/*...iters*/) { - var args = arguments; - return updateCursor(this, function (m) { - return m.merge.apply(m, args); - }); -} - -IndexedCursorPrototype.mergeWith = -KeyedCursorPrototype.mergeWith = function(merger/*, ...iters*/) { - var args = arguments; - return updateCursor(this, function (m) { - return m.mergeWith.apply(m, args); - }); -} - -IndexedCursorPrototype.mergeIn = -KeyedCursorPrototype.mergeIn = Map.prototype.mergeIn; - -IndexedCursorPrototype.mergeDeep = -KeyedCursorPrototype.mergeDeep = function(/*...iters*/) { - var args = arguments; - return updateCursor(this, function (m) { - return m.mergeDeep.apply(m, args); - }); -} - -IndexedCursorPrototype.mergeDeepWith = -KeyedCursorPrototype.mergeDeepWith = function(merger/*, ...iters*/) { - var args = arguments; - return updateCursor(this, function (m) { - return m.mergeDeepWith.apply(m, args); - }); -} - -IndexedCursorPrototype.mergeDeepIn = -KeyedCursorPrototype.mergeDeepIn = Map.prototype.mergeDeepIn; - -KeyedCursorPrototype.withMutations = -IndexedCursorPrototype.withMutations = function(fn) { - return updateCursor(this, function (m) { - return (m || Map()).withMutations(fn); - }); -} - -KeyedCursorPrototype.cursor = -IndexedCursorPrototype.cursor = function(subKeyPath) { - subKeyPath = valToKeyPath(subKeyPath); - return subKeyPath.length === 0 ? this : subCursor(this, subKeyPath); -} - -/** - * All iterables need to implement __iterate - */ -KeyedCursorPrototype.__iterate = -IndexedCursorPrototype.__iterate = function(fn, reverse) { - var cursor = this; - var deref = cursor.deref(); - return deref && deref.__iterate ? deref.__iterate( - function (v, k) { return fn(wrappedValue(cursor, [k], v), k, cursor); }, - reverse - ) : 0; -} - -/** - * All iterables need to implement __iterator - */ -KeyedCursorPrototype.__iterator = -IndexedCursorPrototype.__iterator = function(type, reverse) { - var deref = this.deref(); - var cursor = this; - var iterator = deref && deref.__iterator && - deref.__iterator(Iterator.ENTRIES, reverse); - return new Iterator(function () { - if (!iterator) { - return { value: undefined, done: true }; - } - var step = iterator.next(); - if (step.done) { - return step; - } - var entry = step.value; - var k = entry[0]; - var v = wrappedValue(cursor, [k], entry[1]); - return { - value: type === Iterator.KEYS ? k : type === Iterator.VALUES ? v : [k, v], - done: false - }; - }); -} - -KeyedCursor.prototype = KeyedCursorPrototype; -IndexedCursor.prototype = IndexedCursorPrototype; - - -var NOT_SET = {}; // Sentinel value - -function makeCursor(rootData, keyPath, onChange, value) { - if (arguments.length < 4) { - value = rootData.getIn(keyPath); - } - var size = value && value.size; - var CursorClass = Iterable.isIndexed(value) ? IndexedCursor : KeyedCursor; - var cursor = new CursorClass(rootData, keyPath, onChange, size); - - if (value instanceof Record) { - defineRecordProperties(cursor, value); - } - - return cursor; -} - -function defineRecordProperties(cursor, value) { - try { - value._keys.forEach(setProp.bind(undefined, cursor)); - } catch (error) { - // Object.defineProperty failed. Probably IE8. - } -} - -function setProp(prototype, name) { - Object.defineProperty(prototype, name, { - get: function() { - return this.get(name); - }, - set: function(value) { - if (!this.__ownerID) { - throw new Error('Cannot set on an immutable record.'); - } - } - }); -} - -function wrappedValue(cursor, keyPath, value) { - return Iterable.isIterable(value) ? subCursor(cursor, keyPath, value) : value; -} - -function subCursor(cursor, keyPath, value) { - if (arguments.length < 3) { - return makeCursor( // call without value - cursor._rootData, - newKeyPath(cursor._keyPath, keyPath), - cursor._onChange - ); - } - return makeCursor( - cursor._rootData, - newKeyPath(cursor._keyPath, keyPath), - cursor._onChange, - value - ); -} - -function updateCursor(cursor, changeFn, changeKeyPath) { - var deepChange = arguments.length > 2; - var newRootData = cursor._rootData.updateIn( - cursor._keyPath, - deepChange ? Map() : undefined, - changeFn - ); - var keyPath = cursor._keyPath || []; - var result = cursor._onChange && cursor._onChange.call( - undefined, - newRootData, - cursor._rootData, - deepChange ? newKeyPath(keyPath, changeKeyPath) : keyPath - ); - if (result !== undefined) { - newRootData = result; - } - return makeCursor(newRootData, cursor._keyPath, cursor._onChange); -} - -function newKeyPath(head, tail) { - return head.concat(listToKeyPath(tail)); -} - -function listToKeyPath(list) { - return Array.isArray(list) ? list : Immutable.Iterable(list).toArray(); -} - -function valToKeyPath(val) { - return Array.isArray(val) ? val : - Iterable.isIterable(val) ? val.toArray() : - [val]; -} - -exports.from = cursorFrom; diff --git a/dist/immutable-nonambient.d.ts b/dist/immutable-nonambient.d.ts index 083fe18e09..bd983bb072 100644 --- a/dist/immutable-nonambient.d.ts +++ b/dist/immutable-nonambient.d.ts @@ -91,7 +91,6 @@ */ - /** * Lists are ordered indexed dense collections, much like a JavaScript * Array. @@ -107,7 +106,6 @@ * indices from 0 to size, regardless of whether they were explicitly defined. */ export module List { - /** * True if the provided value is a List * @@ -178,7 +176,6 @@ export function List(): List; export interface List extends Collection.Indexed { - /** * The number of items in this List. */ @@ -410,7 +407,6 @@ */ setSize(size: number): List; - // Deep persistent changes /** @@ -480,8 +476,15 @@ * * @see `Map#updateIn` */ - updateIn(keyPath: Iterable, notSetValue: unknown, updater: (value: unknown) => unknown): this; - updateIn(keyPath: Iterable, updater: (value: unknown) => unknown): this; + updateIn( + keyPath: Iterable, + notSetValue: unknown, + updater: (value: unknown) => unknown + ): this; + updateIn( + keyPath: Iterable, + updater: (value: unknown) => unknown + ): this; /** * Note: `mergeIn` can be used in `withMutations`. @@ -495,7 +498,10 @@ * * @see `Map#mergeDeepIn` */ - mergeDeepIn(keyPath: Iterable, ...collections: Array): this; + mergeDeepIn( + keyPath: Iterable, + ...collections: Array + ): this; // Transient changes @@ -598,8 +604,11 @@ * const c = a.zip(b); // List [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] * ``` */ - zip(other: Collection): List<[T,U]>; - zip(other: Collection, other2: Collection): List<[T,U,V]>; + zip(other: Collection): List<[T, U]>; + zip( + other: Collection, + other2: Collection + ): List<[T, U, V]>; zip(...collections: Array>): List; /** @@ -621,8 +630,11 @@ * input, some results may contain undefined values. TypeScript cannot * account for these without cases (as of v2.5). */ - zipAll(other: Collection): List<[T,U]>; - zipAll(other: Collection, other2: Collection): List<[T,U,V]>; + zipAll(other: Collection): List<[T, U]>; + zipAll( + other: Collection, + other2: Collection + ): List<[T, U, V]>; zipAll(...collections: Array>): List; /** @@ -654,7 +666,6 @@ ): List; } - /** * Immutable Map is an unordered Collection.Keyed of (key, value) pairs with * `O(log32 N)` gets and `O(log32 N)` persistent sets. @@ -683,7 +694,6 @@ * Implemented by a hash-array mapped trie. */ export module Map { - /** * True if the provided value is a Map * @@ -751,13 +761,12 @@ * but since Immutable Map keys can be of any type the argument to `get()` is * not altered. */ - export function Map(collection: Iterable<[K, V]>): Map; - export function Map(obj: {[key: string]: V}): Map; - export function Map(): Map; export function Map(): Map; + export function Map(): Map; + export function Map(collection: Iterable<[K, V]>): Map; + export function Map(obj: { [key: string]: V }): Map; export interface Map extends Collection.Keyed { - /** * The number of entries in this Map. */ @@ -972,10 +981,18 @@ * * @alias concat */ - merge(...collections: Array>): Map; - merge(...collections: Array<{[key: string]: C}>): Map; - concat(...collections: Array>): Map; - concat(...collections: Array<{[key: string]: C}>): Map; + merge( + ...collections: Array> + ): Map; + merge( + ...collections: Array<{ [key: string]: C }> + ): Map; + concat( + ...collections: Array> + ): Map; + concat( + ...collections: Array<{ [key: string]: C }> + ): Map; /** * Like `merge()`, `mergeWith()` returns a new Map resulting from merging @@ -997,7 +1014,7 @@ */ mergeWith( merger: (oldVal: V, newVal: V, key: K) => V, - ...collections: Array | {[key: string]: V}> + ...collections: Array | { [key: string]: V }> ): this; /** @@ -1023,7 +1040,9 @@ * * Note: `mergeDeep` can be used in `withMutations`. */ - mergeDeep(...collections: Array | {[key: string]: V}>): this; + mergeDeep( + ...collections: Array | { [key: string]: V }> + ): this; /** * Like `mergeDeep()`, but when two non-Collections conflict, it uses the @@ -1046,10 +1065,9 @@ */ mergeDeepWith( merger: (oldVal: unknown, newVal: unknown, key: unknown) => unknown, - ...collections: Array | {[key: string]: V}> + ...collections: Array | { [key: string]: V }> ): this; - // Deep persistent changes /** @@ -1207,8 +1225,15 @@ * * Note: `updateIn` can be used in `withMutations`. */ - updateIn(keyPath: Iterable, notSetValue: unknown, updater: (value: unknown) => unknown): this; - updateIn(keyPath: Iterable, updater: (value: unknown) => unknown): this; + updateIn( + keyPath: Iterable, + notSetValue: unknown, + updater: (value: unknown) => unknown + ): this; + updateIn( + keyPath: Iterable, + updater: (value: unknown) => unknown + ): this; /** * A combination of `updateIn` and `merge`, returning a new Map, but @@ -1236,7 +1261,10 @@ * * Note: `mergeDeepIn` can be used in `withMutations`. */ - mergeDeepIn(keyPath: Iterable, ...collections: Array): this; + mergeDeepIn( + keyPath: Iterable, + ...collections: Array + ): this; // Transient changes @@ -1374,7 +1402,6 @@ flip(): Map; } - /** * A type of Map that has the additional guarantee that the iteration order of * entries will be the order in which they were set(). @@ -1388,11 +1415,12 @@ */ export module OrderedMap { - /** * True if the provided value is an OrderedMap. */ - function isOrderedMap(maybeOrderedMap: unknown): maybeOrderedMap is OrderedMap; + function isOrderedMap( + maybeOrderedMap: unknown + ): maybeOrderedMap is OrderedMap; } /** @@ -1410,13 +1438,16 @@ * Note: `OrderedMap` is a factory function and not a class, and does not use * the `new` keyword during construction. */ - export function OrderedMap(collection: Iterable<[K, V]>): OrderedMap; - export function OrderedMap(obj: {[key: string]: V}): OrderedMap; - export function OrderedMap(): OrderedMap; export function OrderedMap(): OrderedMap; + export function OrderedMap(): OrderedMap; + export function OrderedMap( + collection: Iterable<[K, V]> + ): OrderedMap; + export function OrderedMap(obj: { + [key: string]: V; + }): OrderedMap; export interface OrderedMap extends Map { - /** * The number of entries in this OrderedMap. */ @@ -1464,10 +1495,18 @@ * * @alias concat */ - merge(...collections: Array>): OrderedMap; - merge(...collections: Array<{[key: string]: C}>): OrderedMap; - concat(...collections: Array>): OrderedMap; - concat(...collections: Array<{[key: string]: C}>): OrderedMap; + merge( + ...collections: Array> + ): OrderedMap; + merge( + ...collections: Array<{ [key: string]: C }> + ): OrderedMap; + concat( + ...collections: Array> + ): OrderedMap; + concat( + ...collections: Array<{ [key: string]: C }> + ): OrderedMap; // Sequence algorithms @@ -1534,7 +1573,6 @@ flip(): OrderedMap; } - /** * A Collection of unique values with `O(log32 N)` adds and has. * @@ -1547,7 +1585,6 @@ * collections, custom value types, and NaN. */ export module Set { - /** * True if the provided value is a Set */ @@ -1563,7 +1600,7 @@ * this Collection or JavaScript Object. */ function fromKeys(iter: Collection): Set; - function fromKeys(obj: {[key: string]: unknown}): Set; + function fromKeys(obj: { [key: string]: unknown }): Set; /** * `Set.intersect()` creates a new immutable Set that is the intersection of @@ -1608,7 +1645,6 @@ export function Set(): Set; export interface Set extends Collection.Set { - /** * The number of items in this Set. */ @@ -1677,7 +1713,6 @@ */ subtract(...collections: Array>): this; - // Transient changes /** @@ -1749,7 +1784,6 @@ ): this; } - /** * A type of Set that has the additional guarantee that the iteration order of * values will be the order in which they were `add`ed. @@ -1761,7 +1795,6 @@ * stable. */ export module OrderedSet { - /** * True if the provided value is an OrderedSet. */ @@ -1777,7 +1810,7 @@ * the keys from this Collection or JavaScript Object. */ function fromKeys(iter: Collection): OrderedSet; - function fromKeys(obj: {[key: string]: unknown}): OrderedSet; + function fromKeys(obj: { [key: string]: unknown }): OrderedSet; } /** @@ -1792,7 +1825,6 @@ export function OrderedSet(): OrderedSet; export interface OrderedSet extends Set { - /** * The number of items in this OrderedSet. */ @@ -1863,9 +1895,14 @@ * // OrderedSet [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] * ``` */ - zip(other: Collection): OrderedSet<[T,U]>; - zip(other1: Collection, other2: Collection): OrderedSet<[T,U,V]>; - zip(...collections: Array>): OrderedSet; + zip(other: Collection): OrderedSet<[T, U]>; + zip( + other1: Collection, + other2: Collection + ): OrderedSet<[T, U, V]>; + zip( + ...collections: Array> + ): OrderedSet; /** * Returns a OrderedSet of the same type "zipped" with the provided @@ -1884,9 +1921,14 @@ * input, some results may contain undefined values. TypeScript cannot * account for these without cases (as of v2.5). */ - zipAll(other: Collection): OrderedSet<[T,U]>; - zipAll(other1: Collection, other2: Collection): OrderedSet<[T,U,V]>; - zipAll(...collections: Array>): OrderedSet; + zipAll(other: Collection): OrderedSet<[T, U]>; + zipAll( + other1: Collection, + other2: Collection + ): OrderedSet<[T, U, V]>; + zipAll( + ...collections: Array> + ): OrderedSet; /** * Returns an OrderedSet of the same type "zipped" with the provided @@ -1907,10 +1949,8 @@ zipper: (...any: Array) => Z, ...collections: Array> ): OrderedSet; - } - /** * Stacks are indexed collections which support very efficient O(1) addition * and removal from the front using `unshift(v)` and `shift()`. @@ -1925,7 +1965,6 @@ * Stack is implemented with a Single-Linked List. */ export module Stack { - /** * True if the provided value is a Stack */ @@ -1952,7 +1991,6 @@ export function Stack(): Stack; export interface Stack extends Collection.Indexed { - /** * The number of items in this Stack. */ @@ -1965,7 +2003,6 @@ */ peek(): T | undefined; - // Persistent changes /** @@ -2019,7 +2056,6 @@ */ pop(): Stack; - // Transient changes /** @@ -2109,8 +2145,11 @@ * const c = a.zip(b); // Stack [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] * ``` */ - zip(other: Collection): Stack<[T,U]>; - zip(other: Collection, other2: Collection): Stack<[T,U,V]>; + zip(other: Collection): Stack<[T, U]>; + zip( + other: Collection, + other2: Collection + ): Stack<[T, U, V]>; zip(...collections: Array>): Stack; /** @@ -2129,8 +2168,11 @@ * input, some results may contain undefined values. TypeScript cannot * account for these without cases (as of v2.5). */ - zipAll(other: Collection): Stack<[T,U]>; - zipAll(other: Collection, other2: Collection): Stack<[T,U,V]>; + zipAll(other: Collection): Stack<[T, U]>; + zipAll( + other: Collection, + other2: Collection + ): Stack<[T, U, V]>; zipAll(...collections: Array>): Stack; /** @@ -2159,7 +2201,6 @@ ): Stack; } - /** * Returns a Seq.Indexed of numbers from `start` (inclusive) to `end` * (exclusive), by `step`, where `start` defaults to 0, `step` to 1, and `end` to @@ -2178,8 +2219,11 @@ * Range(30, 30, 5) // [] * ``` */ - export function Range(start?: number, end?: number, step?: number): Seq.Indexed; - + export function Range( + start?: number, + end?: number, + step?: number + ): Seq.Indexed; /** * Returns a Seq.Indexed of `value` repeated `times` times. When `times` is @@ -2196,7 +2240,6 @@ */ export function Repeat(value: T, times?: number): Seq.Indexed; - /** * A record is similar to a JS object, but enforces a specific set of allowed * string keys, and has default values. @@ -2214,12 +2257,10 @@ * from a record simply resets it to the default value for that key. * * ```js - * myRecord.size // 2 * myRecord.get('a') // 1 * myRecord.get('b') // 3 * const myRecordWithoutB = myRecord.remove('b') * myRecordWithoutB.get('b') // 2 - * myRecordWithoutB.size // 2 * ``` * * Values provided to the constructor not found in the Record type will @@ -2359,7 +2400,6 @@ * consider sticking with plain objects to begin with. */ export module Record { - /** * True if `maybeRecord` is an instance of a Record. */ @@ -2435,8 +2475,12 @@ export module Factory {} export interface Factory { - (values?: Partial | Iterable<[string, unknown]>): Record & Readonly; - new (values?: Partial | Iterable<[string, unknown]>): Record & Readonly; + (values?: Partial | Iterable<[string, unknown]>): Record & + Readonly; + new (values?: Partial | Iterable<[string, unknown]>): Record< + TProps + > & + Readonly; /** * The name provided to `Record(values, name)` can be accessed with @@ -2445,7 +2489,9 @@ displayName: string; } - export function Factory(values?: Partial | Iterable<[string, unknown]>): Record & Readonly; + export function Factory( + values?: Partial | Iterable<[string, unknown]> + ): Record & Readonly; } /** @@ -2457,10 +2503,12 @@ * Note: `Record` is a factory function and not a class, and does not use the * `new` keyword during construction. */ - export function Record(defaultValues: TProps, name?: string): Record.Factory; + export function Record( + defaultValues: TProps, + name?: string + ): Record.Factory; export interface Record { - // Reading values has(key: string): key is keyof TProps & string; @@ -2489,9 +2537,16 @@ // Persistent changes set(key: K, value: TProps[K]): this; - update(key: K, updater: (value: TProps[K]) => TProps[K]): this; - merge(...collections: Array | Iterable<[string, unknown]>>): this; - mergeDeep(...collections: Array | Iterable<[string, unknown]>>): this; + update( + key: K, + updater: (value: TProps[K]) => TProps[K] + ): this; + merge( + ...collections: Array | Iterable<[string, unknown]>> + ): this; + mergeDeep( + ...collections: Array | Iterable<[string, unknown]>> + ): this; mergeWith( merger: (oldVal: unknown, newVal: unknown, key: keyof TProps) => unknown, @@ -2520,9 +2575,15 @@ // Deep persistent changes setIn(keyPath: Iterable, value: unknown): this; - updateIn(keyPath: Iterable, updater: (value: unknown) => unknown): this; + updateIn( + keyPath: Iterable, + updater: (value: unknown) => unknown + ): this; mergeIn(keyPath: Iterable, ...collections: Array): this; - mergeDeepIn(keyPath: Iterable, ...collections: Array): this; + mergeDeepIn( + keyPath: Iterable, + ...collections: Array + ): this; /** * @alias removeIn @@ -2671,8 +2732,12 @@ * True if `maybeSeq` is a Seq, it is not backed by a concrete * structure such as Map, List, or Set. */ - function isSeq(maybeSeq: unknown): maybeSeq is Seq.Indexed | Seq.Keyed | Seq.Set; - + function isSeq( + maybeSeq: unknown + ): maybeSeq is + | Seq.Indexed + | Seq.Keyed + | Seq.Set; /** * `Seq` which represents key-value pairs. @@ -2687,7 +2752,7 @@ * use the `new` keyword during construction. */ export function Keyed(collection: Iterable<[K, V]>): Seq.Keyed; - export function Keyed(obj: {[key: string]: V}): Seq.Keyed; + export function Keyed(obj: { [key: string]: V }): Seq.Keyed; export function Keyed(): Seq.Keyed; export function Keyed(): Seq.Keyed; @@ -2722,8 +2787,12 @@ * All entries will be present in the resulting Seq, even if they * have the same key. */ - concat(...collections: Array>): Seq.Keyed; - concat(...collections: Array<{[key: string]: C}>): Seq.Keyed; + concat( + ...collections: Array> + ): Seq.Keyed; + concat( + ...collections: Array<{ [key: string]: C }> + ): Seq.Keyed; /** * Returns a new Seq.Keyed with values passed through a @@ -2791,12 +2860,10 @@ flip(): Seq.Keyed; } - /** * `Seq` which represents an ordered indexed list of values. */ module Indexed { - /** * Provides an Seq.Indexed of the values provided. */ @@ -2833,12 +2900,14 @@ /** * Returns itself */ - toSeq(): this + toSeq(): this; /** * Returns a new Seq with other collections concatenated to this one. */ - concat(...valuesOrCollections: Array | C>): Seq.Indexed; + concat( + ...valuesOrCollections: Array | C> + ): Seq.Indexed; /** * Returns a new Seq.Indexed with values passed through a @@ -2895,9 +2964,14 @@ * const c = a.zip(b); // Seq [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] * ``` */ - zip(other: Collection): Seq.Indexed<[T,U]>; - zip(other: Collection, other2: Collection): Seq.Indexed<[T,U,V]>; - zip(...collections: Array>): Seq.Indexed; + zip(other: Collection): Seq.Indexed<[T, U]>; + zip( + other: Collection, + other2: Collection + ): Seq.Indexed<[T, U, V]>; + zip( + ...collections: Array> + ): Seq.Indexed; /** * Returns a Seq "zipped" with the provided collections. @@ -2911,9 +2985,14 @@ * const c = a.zipAll(b); // Seq [ [ 1, 3 ], [ 2, 4 ], [ undefined, 5 ] ] * ``` */ - zipAll(other: Collection): Seq.Indexed<[T,U]>; - zipAll(other: Collection, other2: Collection): Seq.Indexed<[T,U,V]>; - zipAll(...collections: Array>): Seq.Indexed; + zipAll(other: Collection): Seq.Indexed<[T, U]>; + zipAll( + other: Collection, + other2: Collection + ): Seq.Indexed<[T, U, V]>; + zipAll( + ...collections: Array> + ): Seq.Indexed; /** * Returns a Seq "zipped" with the provided collections by using a @@ -2941,7 +3020,6 @@ ): Seq.Indexed; } - /** * `Seq` which represents a set of values. * @@ -2949,7 +3027,6 @@ * of value uniqueness as the concrete `Set`. */ export module Set { - /** * Returns a Seq.Set of the provided values */ @@ -2985,7 +3062,7 @@ /** * Returns itself */ - toSeq(): this + toSeq(): this; /** * Returns a new Seq with other collections concatenated to this one. @@ -3038,7 +3115,6 @@ context?: unknown ): this; } - } /** @@ -3061,15 +3137,16 @@ * `new` keyword during construction. */ export function Seq>(seq: S): S; - export function Seq(collection: Collection.Keyed): Seq.Keyed; + export function Seq( + collection: Collection.Keyed + ): Seq.Keyed; export function Seq(collection: Collection.Indexed): Seq.Indexed; export function Seq(collection: Collection.Set): Seq.Set; export function Seq(collection: Iterable): Seq.Indexed; - export function Seq(obj: {[key: string]: V}): Seq.Keyed; + export function Seq(obj: { [key: string]: V }): Seq.Keyed; export function Seq(): Seq; export interface Seq extends Collection { - /** * Some Seqs can describe their size lazily. When this is the case, * size will be an integer. Otherwise it will be undefined. @@ -3082,7 +3159,6 @@ */ readonly size: number | undefined; - // Force evaluation /** @@ -3199,28 +3275,34 @@ * `Collection.Indexed`, or `Collection.Set`. */ export module Collection { - /** * @deprecated use `const { isKeyed } = require('immutable')` */ - function isKeyed(maybeKeyed: unknown): maybeKeyed is Collection.Keyed; + function isKeyed( + maybeKeyed: unknown + ): maybeKeyed is Collection.Keyed; /** * @deprecated use `const { isIndexed } = require('immutable')` */ - function isIndexed(maybeIndexed: unknown): maybeIndexed is Collection.Indexed; + function isIndexed( + maybeIndexed: unknown + ): maybeIndexed is Collection.Indexed; /** * @deprecated use `const { isAssociative } = require('immutable')` */ - function isAssociative(maybeAssociative: unknown): maybeAssociative is Collection.Keyed | Collection.Indexed; + function isAssociative( + maybeAssociative: unknown + ): maybeAssociative is + | Collection.Keyed + | Collection.Indexed; /** * @deprecated use `const { isOrdered } = require('immutable')` */ function isOrdered(maybeOrdered: unknown): boolean; - /** * Keyed Collections have discrete keys tied to each value. * @@ -3239,8 +3321,12 @@ * Note: `Collection.Keyed` is a conversion function and not a class, and * does not use the `new` keyword during construction. */ - export function Keyed(collection: Iterable<[K, V]>): Collection.Keyed; - export function Keyed(obj: {[key: string]: V}): Collection.Keyed; + export function Keyed( + collection: Iterable<[K, V]> + ): Collection.Keyed; + export function Keyed(obj: { + [key: string]: V; + }): Collection.Keyed; export interface Keyed extends Collection { /** @@ -3268,7 +3354,6 @@ */ toSeq(): Seq.Keyed; - // Sequence functions /** @@ -3287,8 +3372,12 @@ /** * Returns a new Collection with other collections concatenated to this one. */ - concat(...collections: Array>): Collection.Keyed; - concat(...collections: Array<{[key: string]: C}>): Collection.Keyed; + concat( + ...collections: Array> + ): Collection.Keyed; + concat( + ...collections: Array<{ [key: string]: C }> + ): Collection.Keyed; /** * Returns a new Collection.Keyed with values passed through a @@ -3376,7 +3465,6 @@ [Symbol.iterator](): IterableIterator<[K, V]>; } - /** * Indexed Collections have incrementing numeric keys. They exhibit * slightly different behavior than `Collection.Keyed` for some methods in order @@ -3430,7 +3518,6 @@ get(index: number, notSetValue: NSV): T | NSV; get(index: number): T | undefined; - // Conversion to Seq /** @@ -3445,7 +3532,6 @@ */ fromEntrySeq(): Seq.Keyed; - // Combination /** @@ -3510,11 +3596,7 @@ * * Note: `splice` *cannot* be used in `withMutations`. */ - splice( - index: number, - removeNum: number, - ...values: Array - ): this; + splice(index: number, removeNum: number, ...values: Array): this; /** * Returns a Collection of the same type "zipped" with the provided @@ -3532,9 +3614,14 @@ * const c = a.zip(b); // List [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] * ``` */ - zip(other: Collection): Collection.Indexed<[T,U]>; - zip(other: Collection, other2: Collection): Collection.Indexed<[T,U,V]>; - zip(...collections: Array>): Collection.Indexed; + zip(other: Collection): Collection.Indexed<[T, U]>; + zip( + other: Collection, + other2: Collection + ): Collection.Indexed<[T, U, V]>; + zip( + ...collections: Array> + ): Collection.Indexed; /** * Returns a Collection "zipped" with the provided collections. @@ -3548,9 +3635,14 @@ * const c = a.zipAll(b); // List [ [ 1, 3 ], [ 2, 4 ], [ undefined, 5 ] ] * ``` */ - zipAll(other: Collection): Collection.Indexed<[T,U]>; - zipAll(other: Collection, other2: Collection): Collection.Indexed<[T,U,V]>; - zipAll(...collections: Array>): Collection.Indexed; + zipAll(other: Collection): Collection.Indexed<[T, U]>; + zipAll( + other: Collection, + other2: Collection + ): Collection.Indexed<[T, U, V]>; + zipAll( + ...collections: Array> + ): Collection.Indexed; /** * Returns a Collection of the same type "zipped" with the provided @@ -3580,7 +3672,6 @@ ...collections: Array> ): Collection.Indexed; - // Search for value /** @@ -3618,7 +3709,9 @@ /** * Returns a new Collection with other collections concatenated to this one. */ - concat(...valuesOrCollections: Array | C>): Collection.Indexed; + concat( + ...valuesOrCollections: Array | C> + ): Collection.Indexed; /** * Returns a new Collection.Indexed with values passed through a @@ -3667,7 +3760,6 @@ [Symbol.iterator](): IterableIterator; } - /** * Set Collections only represent values. They have no associated keys or * indices. Duplicate values are possible in the lazy `Seq.Set`s, however @@ -3769,7 +3861,6 @@ [Symbol.iterator](): IterableIterator; } - } /** @@ -3794,12 +3885,15 @@ * Note: `Collection` is a conversion function and not a class, and does not * use the `new` keyword during construction. */ - export function Collection>(collection: I): I; + export function Collection>( + collection: I + ): I; export function Collection(collection: Iterable): Collection.Indexed; - export function Collection(obj: {[key: string]: V}): Collection.Keyed; + export function Collection(obj: { + [key: string]: V; + }): Collection.Keyed; export interface Collection extends ValueObject { - // Value equality /** @@ -3837,7 +3931,6 @@ */ hashCode(): number; - // Reading values /** @@ -3937,7 +4030,6 @@ */ update(updater: (value: this) => R): R; - // Conversion to JavaScript types /** @@ -3971,7 +4063,6 @@ */ toObject(): { [key: string]: V }; - // Conversion to Collections /** @@ -4035,7 +4126,6 @@ */ toStack(): Stack; - // Conversion to Seq /** @@ -4078,7 +4168,6 @@ */ toSetSeq(): Seq.Set; - // Iterators /** @@ -4108,7 +4197,6 @@ */ entries(): IterableIterator<[K, V]>; - // Collections (Seq) /** @@ -4127,7 +4215,6 @@ */ entrySeq(): Seq.Indexed<[K, V]>; - // Sequence algorithms /** @@ -4282,8 +4369,7 @@ groupBy( grouper: (value: V, key: K, iter: this) => G, context?: unknown - ): /*Map*/Seq.Keyed>; - + ): /*Map*/ Seq.Keyed>; // Side effects @@ -4299,7 +4385,6 @@ context?: unknown ): number; - // Creating subsets /** @@ -4424,7 +4509,6 @@ context?: unknown ): this; - // Combination /** @@ -4434,7 +4518,9 @@ * For Seqs, all entries will be present in the resulting Seq, even if they * have the same key. */ - concat(...valuesOrCollections: Array): Collection; + concat( + ...valuesOrCollections: Array + ): Collection; /** * Flattens nested Collections. @@ -4565,7 +4651,6 @@ context?: unknown ): Map; - // Search for value /** @@ -4695,7 +4780,6 @@ comparator?: (valueA: C, valueB: C) => number ): V | undefined; - // Comparison /** @@ -4898,7 +4982,9 @@ * isImmutable(Map().asMutable()); // true * ``` */ - export function isImmutable(maybeImmutable: unknown): maybeImmutable is Collection; + export function isImmutable( + maybeImmutable: unknown + ): maybeImmutable is Collection; /** * True if `maybeCollection` is a Collection, or any of its subclasses. @@ -4913,7 +4999,9 @@ * isCollection(Stack()); // true * ``` */ - export function isCollection(maybeCollection: unknown): maybeCollection is Collection; + export function isCollection( + maybeCollection: unknown + ): maybeCollection is Collection; /** * True if `maybeKeyed` is a Collection.Keyed, or any of its subclasses. @@ -4928,7 +5016,9 @@ * isKeyed(Stack()); // false * ``` */ - export function isKeyed(maybeKeyed: unknown): maybeKeyed is Collection.Keyed; + export function isKeyed( + maybeKeyed: unknown + ): maybeKeyed is Collection.Keyed; /** * True if `maybeIndexed` is a Collection.Indexed, or any of its subclasses. @@ -4944,7 +5034,9 @@ * isIndexed(Set()); // false * ``` */ - export function isIndexed(maybeIndexed: unknown): maybeIndexed is Collection.Indexed; + export function isIndexed( + maybeIndexed: unknown + ): maybeIndexed is Collection.Indexed; /** * True if `maybeAssociative` is either a Keyed or Indexed Collection. @@ -4960,7 +5052,11 @@ * isAssociative(Set()); // false * ``` */ - export function isAssociative(maybeAssociative: unknown): maybeAssociative is Collection.Keyed | Collection.Indexed; + export function isAssociative( + maybeAssociative: unknown + ): maybeAssociative is + | Collection.Keyed + | Collection.Indexed; /** * True if `maybeOrdered` is a Collection where iteration order is well @@ -4988,11 +5084,15 @@ */ export function isValueObject(maybeValue: unknown): maybeValue is ValueObject; - /** * True if `maybeSeq` is a Seq. */ - export function isSeq(maybeSeq: unknown): maybeSeq is Seq.Indexed | Seq.Keyed | Seq.Set; + export function isSeq( + maybeSeq: unknown + ): maybeSeq is + | Seq.Indexed + | Seq.Keyed + | Seq.Set; /** * True if `maybeList` is a List. @@ -5009,7 +5109,9 @@ /** * True if `maybeOrderedMap` is an OrderedMap. */ - export function isOrderedMap(maybeOrderedMap: unknown): maybeOrderedMap is OrderedMap; + export function isOrderedMap( + maybeOrderedMap: unknown + ): maybeOrderedMap is OrderedMap; /** * True if `maybeStack` is a Stack. @@ -5026,15 +5128,15 @@ /** * True if `maybeOrderedSet` is an OrderedSet. */ - export function isOrderedSet(maybeOrderedSet: unknown): maybeOrderedSet is OrderedSet; + export function isOrderedSet( + maybeOrderedSet: unknown + ): maybeOrderedSet is OrderedSet; /** * True if `maybeRecord` is a Record. */ export function isRecord(maybeRecord: unknown): maybeRecord is Record<{}>; - - /** * Returns the value within the provided collection associated with the * provided key, or notSetValue if the key is not defined in the collection. @@ -5050,14 +5152,40 @@ * get({ x: 123, y: 456 }, 'z', 'ifNotSet') // 'ifNotSet' * ``` */ - export function get(collection: Collection, key: K): V | undefined; - export function get(collection: Collection, key: K, notSetValue: NSV): V | NSV; - export function get(record: Record, key: K, notSetValue: unknown): TProps[K]; + export function get( + collection: Collection, + key: K + ): V | undefined; + export function get( + collection: Collection, + key: K, + notSetValue: NSV + ): V | NSV; + export function get( + record: Record, + key: K, + notSetValue: unknown + ): TProps[K]; export function get(collection: Array, key: number): V | undefined; - export function get(collection: Array, key: number, notSetValue: NSV): V | NSV; - export function get(object: C, key: K, notSetValue: unknown): C[K]; - export function get(collection: {[key: string]: V}, key: string): V | undefined; - export function get(collection: {[key: string]: V}, key: string, notSetValue: NSV): V | NSV; + export function get( + collection: Array, + key: number, + notSetValue: NSV + ): V | NSV; + export function get( + object: C, + key: K, + notSetValue: unknown + ): C[K]; + export function get( + collection: { [key: string]: V }, + key: string + ): V | undefined; + export function get( + collection: { [key: string]: V }, + key: string, + notSetValue: NSV + ): V | NSV; /** * Returns true if the key is defined in the provided collection. @@ -5095,11 +5223,24 @@ * console.log(originalObject) // { x: 123, y: 456 } * ``` */ - export function remove>(collection: C, key: K): C; - export function remove, K extends keyof TProps>(collection: C, key: K): C; - export function remove>(collection: C, key: number): C; + export function remove>( + collection: C, + key: K + ): C; + export function remove< + TProps, + C extends Record, + K extends keyof TProps + >(collection: C, key: K): C; + export function remove>( + collection: C, + key: number + ): C; export function remove(collection: C, key: K): C; - export function remove(collection: C, key: K): C; + export function remove< + C extends { [key: string]: unknown }, + K extends keyof C + >(collection: C, key: K): C; /** * Returns a copy of the collection with the value at key set to the provided @@ -5120,11 +5261,27 @@ * console.log(originalObject) // { x: 123, y: 456 } * ``` */ - export function set>(collection: C, key: K, value: V): C; - export function set, K extends keyof TProps>(record: C, key: K, value: TProps[K]): C; - export function set>(collection: C, key: number, value: V): C; + export function set>( + collection: C, + key: K, + value: V + ): C; + export function set, K extends keyof TProps>( + record: C, + key: K, + value: TProps[K] + ): C; + export function set>( + collection: C, + key: number, + value: V + ): C; export function set(object: C, key: K, value: C[K]): C; - export function set(collection: C, key: string, value: V): C; + export function set( + collection: C, + key: string, + value: V + ): C; /** * Returns a copy of the collection with the value at key set to the result of @@ -5145,16 +5302,71 @@ * console.log(originalObject) // { x: 123, y: 456 } * ``` */ - export function update>(collection: C, key: K, updater: (value: V) => V): C; - export function update, NSV>(collection: C, key: K, notSetValue: NSV, updater: (value: V | NSV) => V): C; - export function update, K extends keyof TProps>(record: C, key: K, updater: (value: TProps[K]) => TProps[K]): C; - export function update, K extends keyof TProps, NSV>(record: C, key: K, notSetValue: NSV, updater: (value: TProps[K] | NSV) => TProps[K]): C; - export function update(collection: Array, key: number, updater: (value: V) => V): Array; - export function update(collection: Array, key: number, notSetValue: NSV, updater: (value: V | NSV) => V): Array; - export function update(object: C, key: K, updater: (value: C[K]) => C[K]): C; - export function update(object: C, key: K, notSetValue: NSV, updater: (value: C[K] | NSV) => C[K]): C; - export function update(collection: C, key: K, updater: (value: V) => V): {[key: string]: V}; - export function update(collection: C, key: K, notSetValue: NSV, updater: (value: V | NSV) => V): {[key: string]: V}; + export function update>( + collection: C, + key: K, + updater: (value: V) => V + ): C; + export function update, NSV>( + collection: C, + key: K, + notSetValue: NSV, + updater: (value: V | NSV) => V + ): C; + export function update< + TProps, + C extends Record, + K extends keyof TProps + >(record: C, key: K, updater: (value: TProps[K]) => TProps[K]): C; + export function update< + TProps, + C extends Record, + K extends keyof TProps, + NSV + >( + record: C, + key: K, + notSetValue: NSV, + updater: (value: TProps[K] | NSV) => TProps[K] + ): C; + export function update( + collection: Array, + key: number, + updater: (value: V) => V + ): Array; + export function update( + collection: Array, + key: number, + notSetValue: NSV, + updater: (value: V | NSV) => V + ): Array; + export function update( + object: C, + key: K, + updater: (value: C[K]) => C[K] + ): C; + export function update( + object: C, + key: K, + notSetValue: NSV, + updater: (value: C[K] | NSV) => C[K] + ): C; + export function update( + collection: C, + key: K, + updater: (value: V) => V + ): { [key: string]: V }; + export function update< + V, + C extends { [key: string]: V }, + K extends keyof C, + NSV + >( + collection: C, + key: K, + notSetValue: NSV, + updater: (value: V | NSV) => V + ): { [key: string]: V }; /** * Returns the value at the provided key path starting at the provided @@ -5170,7 +5382,11 @@ * getIn({ x: { y: { z: 123 }}}, ['x', 'q', 'p'], 'ifNotSet') // 'ifNotSet' * ``` */ - export function getIn(collection: unknown, keyPath: Iterable, notSetValue: unknown): unknown; + export function getIn( + collection: unknown, + keyPath: Iterable, + notSetValue: unknown + ): unknown; /** * Returns true if the key path is defined in the provided collection. @@ -5185,7 +5401,10 @@ * hasIn({ x: { y: { z: 123 }}}, ['x', 'q', 'p']) // false * ``` */ - export function hasIn(collection: unknown, keyPath: Iterable): boolean; + export function hasIn( + collection: unknown, + keyPath: Iterable + ): boolean; /** * Returns a copy of the collection with the value at the key path removed. @@ -5218,7 +5437,11 @@ * console.log(original) // { x: { y: { z: 123 }}} * ``` */ - export function setIn(collection: C, keyPath: Iterable, value: unknown): C; + export function setIn( + collection: C, + keyPath: Iterable, + value: unknown + ): C; /** * Returns a copy of the collection with the value at key path set to the @@ -5235,8 +5458,17 @@ * console.log(original) // { x: { y: { z: 123 }}} * ``` */ - export function updateIn(collection: C, keyPath: Iterable, updater: (value: unknown) => unknown): C; - export function updateIn(collection: C, keyPath: Iterable, notSetValue: unknown, updater: (value: unknown) => unknown): C; + export function updateIn( + collection: C, + keyPath: Iterable, + updater: (value: unknown) => unknown + ): C; + export function updateIn( + collection: C, + keyPath: Iterable, + notSetValue: unknown, + updater: (value: unknown) => unknown + ): C; /** * Returns a copy of the collection with the remaining collections merged in. @@ -5254,7 +5486,11 @@ */ export function merge( collection: C, - ...collections: Array | Iterable<[unknown, unknown]> | {[key: string]: unknown}> + ...collections: Array< + | Iterable + | Iterable<[unknown, unknown]> + | { [key: string]: unknown } + > ): C; /** @@ -5279,7 +5515,11 @@ export function mergeWith( merger: (oldVal: unknown, newVal: unknown, key: unknown) => unknown, collection: C, - ...collections: Array | Iterable<[unknown, unknown]> | {[key: string]: unknown}> + ...collections: Array< + | Iterable + | Iterable<[unknown, unknown]> + | { [key: string]: unknown } + > ): C; /** @@ -5299,7 +5539,11 @@ */ export function mergeDeep( collection: C, - ...collections: Array | Iterable<[unknown, unknown]> | {[key: string]: unknown}> + ...collections: Array< + | Iterable + | Iterable<[unknown, unknown]> + | { [key: string]: unknown } + > ): C; /** @@ -5325,6 +5569,10 @@ export function mergeDeepWith( merger: (oldVal: unknown, newVal: unknown, key: unknown) => unknown, collection: C, - ...collections: Array | Iterable<[unknown, unknown]> | {[key: string]: unknown}> + ...collections: Array< + | Iterable + | Iterable<[unknown, unknown]> + | { [key: string]: unknown } + > ): C; diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index f039e816d9..801b115e7b 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -91,7 +91,6 @@ */ declare module Immutable { - /** * Lists are ordered indexed dense collections, much like a JavaScript * Array. @@ -107,7 +106,6 @@ declare module Immutable { * indices from 0 to size, regardless of whether they were explicitly defined. */ export module List { - /** * True if the provided value is a List * @@ -178,7 +176,6 @@ declare module Immutable { export function List(): List; export interface List extends Collection.Indexed { - /** * The number of items in this List. */ @@ -410,7 +407,6 @@ declare module Immutable { */ setSize(size: number): List; - // Deep persistent changes /** @@ -480,8 +476,15 @@ declare module Immutable { * * @see `Map#updateIn` */ - updateIn(keyPath: Iterable, notSetValue: unknown, updater: (value: unknown) => unknown): this; - updateIn(keyPath: Iterable, updater: (value: unknown) => unknown): this; + updateIn( + keyPath: Iterable, + notSetValue: unknown, + updater: (value: unknown) => unknown + ): this; + updateIn( + keyPath: Iterable, + updater: (value: unknown) => unknown + ): this; /** * Note: `mergeIn` can be used in `withMutations`. @@ -495,7 +498,10 @@ declare module Immutable { * * @see `Map#mergeDeepIn` */ - mergeDeepIn(keyPath: Iterable, ...collections: Array): this; + mergeDeepIn( + keyPath: Iterable, + ...collections: Array + ): this; // Transient changes @@ -598,8 +604,11 @@ declare module Immutable { * const c = a.zip(b); // List [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] * ``` */ - zip(other: Collection): List<[T,U]>; - zip(other: Collection, other2: Collection): List<[T,U,V]>; + zip(other: Collection): List<[T, U]>; + zip( + other: Collection, + other2: Collection + ): List<[T, U, V]>; zip(...collections: Array>): List; /** @@ -621,8 +630,11 @@ declare module Immutable { * input, some results may contain undefined values. TypeScript cannot * account for these without cases (as of v2.5). */ - zipAll(other: Collection): List<[T,U]>; - zipAll(other: Collection, other2: Collection): List<[T,U,V]>; + zipAll(other: Collection): List<[T, U]>; + zipAll( + other: Collection, + other2: Collection + ): List<[T, U, V]>; zipAll(...collections: Array>): List; /** @@ -654,7 +666,6 @@ declare module Immutable { ): List; } - /** * Immutable Map is an unordered Collection.Keyed of (key, value) pairs with * `O(log32 N)` gets and `O(log32 N)` persistent sets. @@ -683,7 +694,6 @@ declare module Immutable { * Implemented by a hash-array mapped trie. */ export module Map { - /** * True if the provided value is a Map * @@ -751,13 +761,12 @@ declare module Immutable { * but since Immutable Map keys can be of any type the argument to `get()` is * not altered. */ - export function Map(collection: Iterable<[K, V]>): Map; - export function Map(obj: {[key: string]: V}): Map; - export function Map(): Map; export function Map(): Map; + export function Map(): Map; + export function Map(collection: Iterable<[K, V]>): Map; + export function Map(obj: { [key: string]: V }): Map; export interface Map extends Collection.Keyed { - /** * The number of entries in this Map. */ @@ -972,10 +981,18 @@ declare module Immutable { * * @alias concat */ - merge(...collections: Array>): Map; - merge(...collections: Array<{[key: string]: C}>): Map; - concat(...collections: Array>): Map; - concat(...collections: Array<{[key: string]: C}>): Map; + merge( + ...collections: Array> + ): Map; + merge( + ...collections: Array<{ [key: string]: C }> + ): Map; + concat( + ...collections: Array> + ): Map; + concat( + ...collections: Array<{ [key: string]: C }> + ): Map; /** * Like `merge()`, `mergeWith()` returns a new Map resulting from merging @@ -997,7 +1014,7 @@ declare module Immutable { */ mergeWith( merger: (oldVal: V, newVal: V, key: K) => V, - ...collections: Array | {[key: string]: V}> + ...collections: Array | { [key: string]: V }> ): this; /** @@ -1023,7 +1040,9 @@ declare module Immutable { * * Note: `mergeDeep` can be used in `withMutations`. */ - mergeDeep(...collections: Array | {[key: string]: V}>): this; + mergeDeep( + ...collections: Array | { [key: string]: V }> + ): this; /** * Like `mergeDeep()`, but when two non-Collections conflict, it uses the @@ -1046,10 +1065,9 @@ declare module Immutable { */ mergeDeepWith( merger: (oldVal: unknown, newVal: unknown, key: unknown) => unknown, - ...collections: Array | {[key: string]: V}> + ...collections: Array | { [key: string]: V }> ): this; - // Deep persistent changes /** @@ -1207,8 +1225,15 @@ declare module Immutable { * * Note: `updateIn` can be used in `withMutations`. */ - updateIn(keyPath: Iterable, notSetValue: unknown, updater: (value: unknown) => unknown): this; - updateIn(keyPath: Iterable, updater: (value: unknown) => unknown): this; + updateIn( + keyPath: Iterable, + notSetValue: unknown, + updater: (value: unknown) => unknown + ): this; + updateIn( + keyPath: Iterable, + updater: (value: unknown) => unknown + ): this; /** * A combination of `updateIn` and `merge`, returning a new Map, but @@ -1236,7 +1261,10 @@ declare module Immutable { * * Note: `mergeDeepIn` can be used in `withMutations`. */ - mergeDeepIn(keyPath: Iterable, ...collections: Array): this; + mergeDeepIn( + keyPath: Iterable, + ...collections: Array + ): this; // Transient changes @@ -1374,7 +1402,6 @@ declare module Immutable { flip(): Map; } - /** * A type of Map that has the additional guarantee that the iteration order of * entries will be the order in which they were set(). @@ -1388,11 +1415,12 @@ declare module Immutable { */ export module OrderedMap { - /** * True if the provided value is an OrderedMap. */ - function isOrderedMap(maybeOrderedMap: unknown): maybeOrderedMap is OrderedMap; + function isOrderedMap( + maybeOrderedMap: unknown + ): maybeOrderedMap is OrderedMap; } /** @@ -1410,13 +1438,16 @@ declare module Immutable { * Note: `OrderedMap` is a factory function and not a class, and does not use * the `new` keyword during construction. */ - export function OrderedMap(collection: Iterable<[K, V]>): OrderedMap; - export function OrderedMap(obj: {[key: string]: V}): OrderedMap; - export function OrderedMap(): OrderedMap; export function OrderedMap(): OrderedMap; + export function OrderedMap(): OrderedMap; + export function OrderedMap( + collection: Iterable<[K, V]> + ): OrderedMap; + export function OrderedMap(obj: { + [key: string]: V; + }): OrderedMap; export interface OrderedMap extends Map { - /** * The number of entries in this OrderedMap. */ @@ -1464,10 +1495,18 @@ declare module Immutable { * * @alias concat */ - merge(...collections: Array>): OrderedMap; - merge(...collections: Array<{[key: string]: C}>): OrderedMap; - concat(...collections: Array>): OrderedMap; - concat(...collections: Array<{[key: string]: C}>): OrderedMap; + merge( + ...collections: Array> + ): OrderedMap; + merge( + ...collections: Array<{ [key: string]: C }> + ): OrderedMap; + concat( + ...collections: Array> + ): OrderedMap; + concat( + ...collections: Array<{ [key: string]: C }> + ): OrderedMap; // Sequence algorithms @@ -1534,7 +1573,6 @@ declare module Immutable { flip(): OrderedMap; } - /** * A Collection of unique values with `O(log32 N)` adds and has. * @@ -1547,7 +1585,6 @@ declare module Immutable { * collections, custom value types, and NaN. */ export module Set { - /** * True if the provided value is a Set */ @@ -1563,7 +1600,7 @@ declare module Immutable { * this Collection or JavaScript Object. */ function fromKeys(iter: Collection): Set; - function fromKeys(obj: {[key: string]: unknown}): Set; + function fromKeys(obj: { [key: string]: unknown }): Set; /** * `Set.intersect()` creates a new immutable Set that is the intersection of @@ -1608,7 +1645,6 @@ declare module Immutable { export function Set(): Set; export interface Set extends Collection.Set { - /** * The number of items in this Set. */ @@ -1677,7 +1713,6 @@ declare module Immutable { */ subtract(...collections: Array>): this; - // Transient changes /** @@ -1749,7 +1784,6 @@ declare module Immutable { ): this; } - /** * A type of Set that has the additional guarantee that the iteration order of * values will be the order in which they were `add`ed. @@ -1761,7 +1795,6 @@ declare module Immutable { * stable. */ export module OrderedSet { - /** * True if the provided value is an OrderedSet. */ @@ -1777,7 +1810,7 @@ declare module Immutable { * the keys from this Collection or JavaScript Object. */ function fromKeys(iter: Collection): OrderedSet; - function fromKeys(obj: {[key: string]: unknown}): OrderedSet; + function fromKeys(obj: { [key: string]: unknown }): OrderedSet; } /** @@ -1792,7 +1825,6 @@ declare module Immutable { export function OrderedSet(): OrderedSet; export interface OrderedSet extends Set { - /** * The number of items in this OrderedSet. */ @@ -1863,9 +1895,14 @@ declare module Immutable { * // OrderedSet [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] * ``` */ - zip(other: Collection): OrderedSet<[T,U]>; - zip(other1: Collection, other2: Collection): OrderedSet<[T,U,V]>; - zip(...collections: Array>): OrderedSet; + zip(other: Collection): OrderedSet<[T, U]>; + zip( + other1: Collection, + other2: Collection + ): OrderedSet<[T, U, V]>; + zip( + ...collections: Array> + ): OrderedSet; /** * Returns a OrderedSet of the same type "zipped" with the provided @@ -1884,9 +1921,14 @@ declare module Immutable { * input, some results may contain undefined values. TypeScript cannot * account for these without cases (as of v2.5). */ - zipAll(other: Collection): OrderedSet<[T,U]>; - zipAll(other1: Collection, other2: Collection): OrderedSet<[T,U,V]>; - zipAll(...collections: Array>): OrderedSet; + zipAll(other: Collection): OrderedSet<[T, U]>; + zipAll( + other1: Collection, + other2: Collection + ): OrderedSet<[T, U, V]>; + zipAll( + ...collections: Array> + ): OrderedSet; /** * Returns an OrderedSet of the same type "zipped" with the provided @@ -1907,10 +1949,8 @@ declare module Immutable { zipper: (...any: Array) => Z, ...collections: Array> ): OrderedSet; - } - /** * Stacks are indexed collections which support very efficient O(1) addition * and removal from the front using `unshift(v)` and `shift()`. @@ -1925,7 +1965,6 @@ declare module Immutable { * Stack is implemented with a Single-Linked List. */ export module Stack { - /** * True if the provided value is a Stack */ @@ -1952,7 +1991,6 @@ declare module Immutable { export function Stack(): Stack; export interface Stack extends Collection.Indexed { - /** * The number of items in this Stack. */ @@ -1965,7 +2003,6 @@ declare module Immutable { */ peek(): T | undefined; - // Persistent changes /** @@ -2019,7 +2056,6 @@ declare module Immutable { */ pop(): Stack; - // Transient changes /** @@ -2109,8 +2145,11 @@ declare module Immutable { * const c = a.zip(b); // Stack [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] * ``` */ - zip(other: Collection): Stack<[T,U]>; - zip(other: Collection, other2: Collection): Stack<[T,U,V]>; + zip(other: Collection): Stack<[T, U]>; + zip( + other: Collection, + other2: Collection + ): Stack<[T, U, V]>; zip(...collections: Array>): Stack; /** @@ -2129,8 +2168,11 @@ declare module Immutable { * input, some results may contain undefined values. TypeScript cannot * account for these without cases (as of v2.5). */ - zipAll(other: Collection): Stack<[T,U]>; - zipAll(other: Collection, other2: Collection): Stack<[T,U,V]>; + zipAll(other: Collection): Stack<[T, U]>; + zipAll( + other: Collection, + other2: Collection + ): Stack<[T, U, V]>; zipAll(...collections: Array>): Stack; /** @@ -2159,7 +2201,6 @@ declare module Immutable { ): Stack; } - /** * Returns a Seq.Indexed of numbers from `start` (inclusive) to `end` * (exclusive), by `step`, where `start` defaults to 0, `step` to 1, and `end` to @@ -2178,8 +2219,11 @@ declare module Immutable { * Range(30, 30, 5) // [] * ``` */ - export function Range(start?: number, end?: number, step?: number): Seq.Indexed; - + export function Range( + start?: number, + end?: number, + step?: number + ): Seq.Indexed; /** * Returns a Seq.Indexed of `value` repeated `times` times. When `times` is @@ -2196,7 +2240,6 @@ declare module Immutable { */ export function Repeat(value: T, times?: number): Seq.Indexed; - /** * A record is similar to a JS object, but enforces a specific set of allowed * string keys, and has default values. @@ -2214,12 +2257,10 @@ declare module Immutable { * from a record simply resets it to the default value for that key. * * ```js - * myRecord.size // 2 * myRecord.get('a') // 1 * myRecord.get('b') // 3 * const myRecordWithoutB = myRecord.remove('b') * myRecordWithoutB.get('b') // 2 - * myRecordWithoutB.size // 2 * ``` * * Values provided to the constructor not found in the Record type will @@ -2359,7 +2400,6 @@ declare module Immutable { * consider sticking with plain objects to begin with. */ export module Record { - /** * True if `maybeRecord` is an instance of a Record. */ @@ -2435,8 +2475,12 @@ declare module Immutable { export module Factory {} export interface Factory { - (values?: Partial | Iterable<[string, unknown]>): Record & Readonly; - new (values?: Partial | Iterable<[string, unknown]>): Record & Readonly; + (values?: Partial | Iterable<[string, unknown]>): Record & + Readonly; + new (values?: Partial | Iterable<[string, unknown]>): Record< + TProps + > & + Readonly; /** * The name provided to `Record(values, name)` can be accessed with @@ -2445,7 +2489,9 @@ declare module Immutable { displayName: string; } - export function Factory(values?: Partial | Iterable<[string, unknown]>): Record & Readonly; + export function Factory( + values?: Partial | Iterable<[string, unknown]> + ): Record & Readonly; } /** @@ -2457,10 +2503,12 @@ declare module Immutable { * Note: `Record` is a factory function and not a class, and does not use the * `new` keyword during construction. */ - export function Record(defaultValues: TProps, name?: string): Record.Factory; + export function Record( + defaultValues: TProps, + name?: string + ): Record.Factory; export interface Record { - // Reading values has(key: string): key is keyof TProps & string; @@ -2489,9 +2537,16 @@ declare module Immutable { // Persistent changes set(key: K, value: TProps[K]): this; - update(key: K, updater: (value: TProps[K]) => TProps[K]): this; - merge(...collections: Array | Iterable<[string, unknown]>>): this; - mergeDeep(...collections: Array | Iterable<[string, unknown]>>): this; + update( + key: K, + updater: (value: TProps[K]) => TProps[K] + ): this; + merge( + ...collections: Array | Iterable<[string, unknown]>> + ): this; + mergeDeep( + ...collections: Array | Iterable<[string, unknown]>> + ): this; mergeWith( merger: (oldVal: unknown, newVal: unknown, key: keyof TProps) => unknown, @@ -2520,9 +2575,15 @@ declare module Immutable { // Deep persistent changes setIn(keyPath: Iterable, value: unknown): this; - updateIn(keyPath: Iterable, updater: (value: unknown) => unknown): this; + updateIn( + keyPath: Iterable, + updater: (value: unknown) => unknown + ): this; mergeIn(keyPath: Iterable, ...collections: Array): this; - mergeDeepIn(keyPath: Iterable, ...collections: Array): this; + mergeDeepIn( + keyPath: Iterable, + ...collections: Array + ): this; /** * @alias removeIn @@ -2671,8 +2732,12 @@ declare module Immutable { * True if `maybeSeq` is a Seq, it is not backed by a concrete * structure such as Map, List, or Set. */ - function isSeq(maybeSeq: unknown): maybeSeq is Seq.Indexed | Seq.Keyed | Seq.Set; - + function isSeq( + maybeSeq: unknown + ): maybeSeq is + | Seq.Indexed + | Seq.Keyed + | Seq.Set; /** * `Seq` which represents key-value pairs. @@ -2687,7 +2752,7 @@ declare module Immutable { * use the `new` keyword during construction. */ export function Keyed(collection: Iterable<[K, V]>): Seq.Keyed; - export function Keyed(obj: {[key: string]: V}): Seq.Keyed; + export function Keyed(obj: { [key: string]: V }): Seq.Keyed; export function Keyed(): Seq.Keyed; export function Keyed(): Seq.Keyed; @@ -2722,8 +2787,12 @@ declare module Immutable { * All entries will be present in the resulting Seq, even if they * have the same key. */ - concat(...collections: Array>): Seq.Keyed; - concat(...collections: Array<{[key: string]: C}>): Seq.Keyed; + concat( + ...collections: Array> + ): Seq.Keyed; + concat( + ...collections: Array<{ [key: string]: C }> + ): Seq.Keyed; /** * Returns a new Seq.Keyed with values passed through a @@ -2791,12 +2860,10 @@ declare module Immutable { flip(): Seq.Keyed; } - /** * `Seq` which represents an ordered indexed list of values. */ module Indexed { - /** * Provides an Seq.Indexed of the values provided. */ @@ -2833,12 +2900,14 @@ declare module Immutable { /** * Returns itself */ - toSeq(): this + toSeq(): this; /** * Returns a new Seq with other collections concatenated to this one. */ - concat(...valuesOrCollections: Array | C>): Seq.Indexed; + concat( + ...valuesOrCollections: Array | C> + ): Seq.Indexed; /** * Returns a new Seq.Indexed with values passed through a @@ -2895,9 +2964,14 @@ declare module Immutable { * const c = a.zip(b); // Seq [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] * ``` */ - zip(other: Collection): Seq.Indexed<[T,U]>; - zip(other: Collection, other2: Collection): Seq.Indexed<[T,U,V]>; - zip(...collections: Array>): Seq.Indexed; + zip(other: Collection): Seq.Indexed<[T, U]>; + zip( + other: Collection, + other2: Collection + ): Seq.Indexed<[T, U, V]>; + zip( + ...collections: Array> + ): Seq.Indexed; /** * Returns a Seq "zipped" with the provided collections. @@ -2911,9 +2985,14 @@ declare module Immutable { * const c = a.zipAll(b); // Seq [ [ 1, 3 ], [ 2, 4 ], [ undefined, 5 ] ] * ``` */ - zipAll(other: Collection): Seq.Indexed<[T,U]>; - zipAll(other: Collection, other2: Collection): Seq.Indexed<[T,U,V]>; - zipAll(...collections: Array>): Seq.Indexed; + zipAll(other: Collection): Seq.Indexed<[T, U]>; + zipAll( + other: Collection, + other2: Collection + ): Seq.Indexed<[T, U, V]>; + zipAll( + ...collections: Array> + ): Seq.Indexed; /** * Returns a Seq "zipped" with the provided collections by using a @@ -2941,7 +3020,6 @@ declare module Immutable { ): Seq.Indexed; } - /** * `Seq` which represents a set of values. * @@ -2949,7 +3027,6 @@ declare module Immutable { * of value uniqueness as the concrete `Set`. */ export module Set { - /** * Returns a Seq.Set of the provided values */ @@ -2985,7 +3062,7 @@ declare module Immutable { /** * Returns itself */ - toSeq(): this + toSeq(): this; /** * Returns a new Seq with other collections concatenated to this one. @@ -3038,7 +3115,6 @@ declare module Immutable { context?: unknown ): this; } - } /** @@ -3061,15 +3137,16 @@ declare module Immutable { * `new` keyword during construction. */ export function Seq>(seq: S): S; - export function Seq(collection: Collection.Keyed): Seq.Keyed; + export function Seq( + collection: Collection.Keyed + ): Seq.Keyed; export function Seq(collection: Collection.Indexed): Seq.Indexed; export function Seq(collection: Collection.Set): Seq.Set; export function Seq(collection: Iterable): Seq.Indexed; - export function Seq(obj: {[key: string]: V}): Seq.Keyed; + export function Seq(obj: { [key: string]: V }): Seq.Keyed; export function Seq(): Seq; export interface Seq extends Collection { - /** * Some Seqs can describe their size lazily. When this is the case, * size will be an integer. Otherwise it will be undefined. @@ -3082,7 +3159,6 @@ declare module Immutable { */ readonly size: number | undefined; - // Force evaluation /** @@ -3199,28 +3275,34 @@ declare module Immutable { * `Collection.Indexed`, or `Collection.Set`. */ export module Collection { - /** * @deprecated use `const { isKeyed } = require('immutable')` */ - function isKeyed(maybeKeyed: unknown): maybeKeyed is Collection.Keyed; + function isKeyed( + maybeKeyed: unknown + ): maybeKeyed is Collection.Keyed; /** * @deprecated use `const { isIndexed } = require('immutable')` */ - function isIndexed(maybeIndexed: unknown): maybeIndexed is Collection.Indexed; + function isIndexed( + maybeIndexed: unknown + ): maybeIndexed is Collection.Indexed; /** * @deprecated use `const { isAssociative } = require('immutable')` */ - function isAssociative(maybeAssociative: unknown): maybeAssociative is Collection.Keyed | Collection.Indexed; + function isAssociative( + maybeAssociative: unknown + ): maybeAssociative is + | Collection.Keyed + | Collection.Indexed; /** * @deprecated use `const { isOrdered } = require('immutable')` */ function isOrdered(maybeOrdered: unknown): boolean; - /** * Keyed Collections have discrete keys tied to each value. * @@ -3239,8 +3321,12 @@ declare module Immutable { * Note: `Collection.Keyed` is a conversion function and not a class, and * does not use the `new` keyword during construction. */ - export function Keyed(collection: Iterable<[K, V]>): Collection.Keyed; - export function Keyed(obj: {[key: string]: V}): Collection.Keyed; + export function Keyed( + collection: Iterable<[K, V]> + ): Collection.Keyed; + export function Keyed(obj: { + [key: string]: V; + }): Collection.Keyed; export interface Keyed extends Collection { /** @@ -3268,7 +3354,6 @@ declare module Immutable { */ toSeq(): Seq.Keyed; - // Sequence functions /** @@ -3287,8 +3372,12 @@ declare module Immutable { /** * Returns a new Collection with other collections concatenated to this one. */ - concat(...collections: Array>): Collection.Keyed; - concat(...collections: Array<{[key: string]: C}>): Collection.Keyed; + concat( + ...collections: Array> + ): Collection.Keyed; + concat( + ...collections: Array<{ [key: string]: C }> + ): Collection.Keyed; /** * Returns a new Collection.Keyed with values passed through a @@ -3376,7 +3465,6 @@ declare module Immutable { [Symbol.iterator](): IterableIterator<[K, V]>; } - /** * Indexed Collections have incrementing numeric keys. They exhibit * slightly different behavior than `Collection.Keyed` for some methods in order @@ -3430,7 +3518,6 @@ declare module Immutable { get(index: number, notSetValue: NSV): T | NSV; get(index: number): T | undefined; - // Conversion to Seq /** @@ -3445,7 +3532,6 @@ declare module Immutable { */ fromEntrySeq(): Seq.Keyed; - // Combination /** @@ -3510,11 +3596,7 @@ declare module Immutable { * * Note: `splice` *cannot* be used in `withMutations`. */ - splice( - index: number, - removeNum: number, - ...values: Array - ): this; + splice(index: number, removeNum: number, ...values: Array): this; /** * Returns a Collection of the same type "zipped" with the provided @@ -3532,9 +3614,14 @@ declare module Immutable { * const c = a.zip(b); // List [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] * ``` */ - zip(other: Collection): Collection.Indexed<[T,U]>; - zip(other: Collection, other2: Collection): Collection.Indexed<[T,U,V]>; - zip(...collections: Array>): Collection.Indexed; + zip(other: Collection): Collection.Indexed<[T, U]>; + zip( + other: Collection, + other2: Collection + ): Collection.Indexed<[T, U, V]>; + zip( + ...collections: Array> + ): Collection.Indexed; /** * Returns a Collection "zipped" with the provided collections. @@ -3548,9 +3635,14 @@ declare module Immutable { * const c = a.zipAll(b); // List [ [ 1, 3 ], [ 2, 4 ], [ undefined, 5 ] ] * ``` */ - zipAll(other: Collection): Collection.Indexed<[T,U]>; - zipAll(other: Collection, other2: Collection): Collection.Indexed<[T,U,V]>; - zipAll(...collections: Array>): Collection.Indexed; + zipAll(other: Collection): Collection.Indexed<[T, U]>; + zipAll( + other: Collection, + other2: Collection + ): Collection.Indexed<[T, U, V]>; + zipAll( + ...collections: Array> + ): Collection.Indexed; /** * Returns a Collection of the same type "zipped" with the provided @@ -3580,7 +3672,6 @@ declare module Immutable { ...collections: Array> ): Collection.Indexed; - // Search for value /** @@ -3618,7 +3709,9 @@ declare module Immutable { /** * Returns a new Collection with other collections concatenated to this one. */ - concat(...valuesOrCollections: Array | C>): Collection.Indexed; + concat( + ...valuesOrCollections: Array | C> + ): Collection.Indexed; /** * Returns a new Collection.Indexed with values passed through a @@ -3667,7 +3760,6 @@ declare module Immutable { [Symbol.iterator](): IterableIterator; } - /** * Set Collections only represent values. They have no associated keys or * indices. Duplicate values are possible in the lazy `Seq.Set`s, however @@ -3769,7 +3861,6 @@ declare module Immutable { [Symbol.iterator](): IterableIterator; } - } /** @@ -3794,12 +3885,15 @@ declare module Immutable { * Note: `Collection` is a conversion function and not a class, and does not * use the `new` keyword during construction. */ - export function Collection>(collection: I): I; + export function Collection>( + collection: I + ): I; export function Collection(collection: Iterable): Collection.Indexed; - export function Collection(obj: {[key: string]: V}): Collection.Keyed; + export function Collection(obj: { + [key: string]: V; + }): Collection.Keyed; export interface Collection extends ValueObject { - // Value equality /** @@ -3837,7 +3931,6 @@ declare module Immutable { */ hashCode(): number; - // Reading values /** @@ -3937,7 +4030,6 @@ declare module Immutable { */ update(updater: (value: this) => R): R; - // Conversion to JavaScript types /** @@ -3971,7 +4063,6 @@ declare module Immutable { */ toObject(): { [key: string]: V }; - // Conversion to Collections /** @@ -4035,7 +4126,6 @@ declare module Immutable { */ toStack(): Stack; - // Conversion to Seq /** @@ -4078,7 +4168,6 @@ declare module Immutable { */ toSetSeq(): Seq.Set; - // Iterators /** @@ -4108,7 +4197,6 @@ declare module Immutable { */ entries(): IterableIterator<[K, V]>; - // Collections (Seq) /** @@ -4127,7 +4215,6 @@ declare module Immutable { */ entrySeq(): Seq.Indexed<[K, V]>; - // Sequence algorithms /** @@ -4282,8 +4369,7 @@ declare module Immutable { groupBy( grouper: (value: V, key: K, iter: this) => G, context?: unknown - ): /*Map*/Seq.Keyed>; - + ): /*Map*/ Seq.Keyed>; // Side effects @@ -4299,7 +4385,6 @@ declare module Immutable { context?: unknown ): number; - // Creating subsets /** @@ -4424,7 +4509,6 @@ declare module Immutable { context?: unknown ): this; - // Combination /** @@ -4434,7 +4518,9 @@ declare module Immutable { * For Seqs, all entries will be present in the resulting Seq, even if they * have the same key. */ - concat(...valuesOrCollections: Array): Collection; + concat( + ...valuesOrCollections: Array + ): Collection; /** * Flattens nested Collections. @@ -4565,7 +4651,6 @@ declare module Immutable { context?: unknown ): Map; - // Search for value /** @@ -4695,7 +4780,6 @@ declare module Immutable { comparator?: (valueA: C, valueB: C) => number ): V | undefined; - // Comparison /** @@ -4898,7 +4982,9 @@ declare module Immutable { * isImmutable(Map().asMutable()); // true * ``` */ - export function isImmutable(maybeImmutable: unknown): maybeImmutable is Collection; + export function isImmutable( + maybeImmutable: unknown + ): maybeImmutable is Collection; /** * True if `maybeCollection` is a Collection, or any of its subclasses. @@ -4913,7 +4999,9 @@ declare module Immutable { * isCollection(Stack()); // true * ``` */ - export function isCollection(maybeCollection: unknown): maybeCollection is Collection; + export function isCollection( + maybeCollection: unknown + ): maybeCollection is Collection; /** * True if `maybeKeyed` is a Collection.Keyed, or any of its subclasses. @@ -4928,7 +5016,9 @@ declare module Immutable { * isKeyed(Stack()); // false * ``` */ - export function isKeyed(maybeKeyed: unknown): maybeKeyed is Collection.Keyed; + export function isKeyed( + maybeKeyed: unknown + ): maybeKeyed is Collection.Keyed; /** * True if `maybeIndexed` is a Collection.Indexed, or any of its subclasses. @@ -4944,7 +5034,9 @@ declare module Immutable { * isIndexed(Set()); // false * ``` */ - export function isIndexed(maybeIndexed: unknown): maybeIndexed is Collection.Indexed; + export function isIndexed( + maybeIndexed: unknown + ): maybeIndexed is Collection.Indexed; /** * True if `maybeAssociative` is either a Keyed or Indexed Collection. @@ -4960,7 +5052,11 @@ declare module Immutable { * isAssociative(Set()); // false * ``` */ - export function isAssociative(maybeAssociative: unknown): maybeAssociative is Collection.Keyed | Collection.Indexed; + export function isAssociative( + maybeAssociative: unknown + ): maybeAssociative is + | Collection.Keyed + | Collection.Indexed; /** * True if `maybeOrdered` is a Collection where iteration order is well @@ -4988,11 +5084,15 @@ declare module Immutable { */ export function isValueObject(maybeValue: unknown): maybeValue is ValueObject; - /** * True if `maybeSeq` is a Seq. */ - export function isSeq(maybeSeq: unknown): maybeSeq is Seq.Indexed | Seq.Keyed | Seq.Set; + export function isSeq( + maybeSeq: unknown + ): maybeSeq is + | Seq.Indexed + | Seq.Keyed + | Seq.Set; /** * True if `maybeList` is a List. @@ -5009,7 +5109,9 @@ declare module Immutable { /** * True if `maybeOrderedMap` is an OrderedMap. */ - export function isOrderedMap(maybeOrderedMap: unknown): maybeOrderedMap is OrderedMap; + export function isOrderedMap( + maybeOrderedMap: unknown + ): maybeOrderedMap is OrderedMap; /** * True if `maybeStack` is a Stack. @@ -5026,15 +5128,15 @@ declare module Immutable { /** * True if `maybeOrderedSet` is an OrderedSet. */ - export function isOrderedSet(maybeOrderedSet: unknown): maybeOrderedSet is OrderedSet; + export function isOrderedSet( + maybeOrderedSet: unknown + ): maybeOrderedSet is OrderedSet; /** * True if `maybeRecord` is a Record. */ export function isRecord(maybeRecord: unknown): maybeRecord is Record<{}>; - - /** * Returns the value within the provided collection associated with the * provided key, or notSetValue if the key is not defined in the collection. @@ -5050,14 +5152,40 @@ declare module Immutable { * get({ x: 123, y: 456 }, 'z', 'ifNotSet') // 'ifNotSet' * ``` */ - export function get(collection: Collection, key: K): V | undefined; - export function get(collection: Collection, key: K, notSetValue: NSV): V | NSV; - export function get(record: Record, key: K, notSetValue: unknown): TProps[K]; + export function get( + collection: Collection, + key: K + ): V | undefined; + export function get( + collection: Collection, + key: K, + notSetValue: NSV + ): V | NSV; + export function get( + record: Record, + key: K, + notSetValue: unknown + ): TProps[K]; export function get(collection: Array, key: number): V | undefined; - export function get(collection: Array, key: number, notSetValue: NSV): V | NSV; - export function get(object: C, key: K, notSetValue: unknown): C[K]; - export function get(collection: {[key: string]: V}, key: string): V | undefined; - export function get(collection: {[key: string]: V}, key: string, notSetValue: NSV): V | NSV; + export function get( + collection: Array, + key: number, + notSetValue: NSV + ): V | NSV; + export function get( + object: C, + key: K, + notSetValue: unknown + ): C[K]; + export function get( + collection: { [key: string]: V }, + key: string + ): V | undefined; + export function get( + collection: { [key: string]: V }, + key: string, + notSetValue: NSV + ): V | NSV; /** * Returns true if the key is defined in the provided collection. @@ -5095,11 +5223,24 @@ declare module Immutable { * console.log(originalObject) // { x: 123, y: 456 } * ``` */ - export function remove>(collection: C, key: K): C; - export function remove, K extends keyof TProps>(collection: C, key: K): C; - export function remove>(collection: C, key: number): C; + export function remove>( + collection: C, + key: K + ): C; + export function remove< + TProps, + C extends Record, + K extends keyof TProps + >(collection: C, key: K): C; + export function remove>( + collection: C, + key: number + ): C; export function remove(collection: C, key: K): C; - export function remove(collection: C, key: K): C; + export function remove< + C extends { [key: string]: unknown }, + K extends keyof C + >(collection: C, key: K): C; /** * Returns a copy of the collection with the value at key set to the provided @@ -5120,11 +5261,27 @@ declare module Immutable { * console.log(originalObject) // { x: 123, y: 456 } * ``` */ - export function set>(collection: C, key: K, value: V): C; - export function set, K extends keyof TProps>(record: C, key: K, value: TProps[K]): C; - export function set>(collection: C, key: number, value: V): C; + export function set>( + collection: C, + key: K, + value: V + ): C; + export function set, K extends keyof TProps>( + record: C, + key: K, + value: TProps[K] + ): C; + export function set>( + collection: C, + key: number, + value: V + ): C; export function set(object: C, key: K, value: C[K]): C; - export function set(collection: C, key: string, value: V): C; + export function set( + collection: C, + key: string, + value: V + ): C; /** * Returns a copy of the collection with the value at key set to the result of @@ -5145,16 +5302,71 @@ declare module Immutable { * console.log(originalObject) // { x: 123, y: 456 } * ``` */ - export function update>(collection: C, key: K, updater: (value: V) => V): C; - export function update, NSV>(collection: C, key: K, notSetValue: NSV, updater: (value: V | NSV) => V): C; - export function update, K extends keyof TProps>(record: C, key: K, updater: (value: TProps[K]) => TProps[K]): C; - export function update, K extends keyof TProps, NSV>(record: C, key: K, notSetValue: NSV, updater: (value: TProps[K] | NSV) => TProps[K]): C; - export function update(collection: Array, key: number, updater: (value: V) => V): Array; - export function update(collection: Array, key: number, notSetValue: NSV, updater: (value: V | NSV) => V): Array; - export function update(object: C, key: K, updater: (value: C[K]) => C[K]): C; - export function update(object: C, key: K, notSetValue: NSV, updater: (value: C[K] | NSV) => C[K]): C; - export function update(collection: C, key: K, updater: (value: V) => V): {[key: string]: V}; - export function update(collection: C, key: K, notSetValue: NSV, updater: (value: V | NSV) => V): {[key: string]: V}; + export function update>( + collection: C, + key: K, + updater: (value: V) => V + ): C; + export function update, NSV>( + collection: C, + key: K, + notSetValue: NSV, + updater: (value: V | NSV) => V + ): C; + export function update< + TProps, + C extends Record, + K extends keyof TProps + >(record: C, key: K, updater: (value: TProps[K]) => TProps[K]): C; + export function update< + TProps, + C extends Record, + K extends keyof TProps, + NSV + >( + record: C, + key: K, + notSetValue: NSV, + updater: (value: TProps[K] | NSV) => TProps[K] + ): C; + export function update( + collection: Array, + key: number, + updater: (value: V) => V + ): Array; + export function update( + collection: Array, + key: number, + notSetValue: NSV, + updater: (value: V | NSV) => V + ): Array; + export function update( + object: C, + key: K, + updater: (value: C[K]) => C[K] + ): C; + export function update( + object: C, + key: K, + notSetValue: NSV, + updater: (value: C[K] | NSV) => C[K] + ): C; + export function update( + collection: C, + key: K, + updater: (value: V) => V + ): { [key: string]: V }; + export function update< + V, + C extends { [key: string]: V }, + K extends keyof C, + NSV + >( + collection: C, + key: K, + notSetValue: NSV, + updater: (value: V | NSV) => V + ): { [key: string]: V }; /** * Returns the value at the provided key path starting at the provided @@ -5170,7 +5382,11 @@ declare module Immutable { * getIn({ x: { y: { z: 123 }}}, ['x', 'q', 'p'], 'ifNotSet') // 'ifNotSet' * ``` */ - export function getIn(collection: unknown, keyPath: Iterable, notSetValue: unknown): unknown; + export function getIn( + collection: unknown, + keyPath: Iterable, + notSetValue: unknown + ): unknown; /** * Returns true if the key path is defined in the provided collection. @@ -5185,7 +5401,10 @@ declare module Immutable { * hasIn({ x: { y: { z: 123 }}}, ['x', 'q', 'p']) // false * ``` */ - export function hasIn(collection: unknown, keyPath: Iterable): boolean; + export function hasIn( + collection: unknown, + keyPath: Iterable + ): boolean; /** * Returns a copy of the collection with the value at the key path removed. @@ -5218,7 +5437,11 @@ declare module Immutable { * console.log(original) // { x: { y: { z: 123 }}} * ``` */ - export function setIn(collection: C, keyPath: Iterable, value: unknown): C; + export function setIn( + collection: C, + keyPath: Iterable, + value: unknown + ): C; /** * Returns a copy of the collection with the value at key path set to the @@ -5235,8 +5458,17 @@ declare module Immutable { * console.log(original) // { x: { y: { z: 123 }}} * ``` */ - export function updateIn(collection: C, keyPath: Iterable, updater: (value: unknown) => unknown): C; - export function updateIn(collection: C, keyPath: Iterable, notSetValue: unknown, updater: (value: unknown) => unknown): C; + export function updateIn( + collection: C, + keyPath: Iterable, + updater: (value: unknown) => unknown + ): C; + export function updateIn( + collection: C, + keyPath: Iterable, + notSetValue: unknown, + updater: (value: unknown) => unknown + ): C; /** * Returns a copy of the collection with the remaining collections merged in. @@ -5254,7 +5486,11 @@ declare module Immutable { */ export function merge( collection: C, - ...collections: Array | Iterable<[unknown, unknown]> | {[key: string]: unknown}> + ...collections: Array< + | Iterable + | Iterable<[unknown, unknown]> + | { [key: string]: unknown } + > ): C; /** @@ -5279,7 +5515,11 @@ declare module Immutable { export function mergeWith( merger: (oldVal: unknown, newVal: unknown, key: unknown) => unknown, collection: C, - ...collections: Array | Iterable<[unknown, unknown]> | {[key: string]: unknown}> + ...collections: Array< + | Iterable + | Iterable<[unknown, unknown]> + | { [key: string]: unknown } + > ): C; /** @@ -5299,7 +5539,11 @@ declare module Immutable { */ export function mergeDeep( collection: C, - ...collections: Array | Iterable<[unknown, unknown]> | {[key: string]: unknown}> + ...collections: Array< + | Iterable + | Iterable<[unknown, unknown]> + | { [key: string]: unknown } + > ): C; /** @@ -5325,10 +5569,14 @@ declare module Immutable { export function mergeDeepWith( merger: (oldVal: unknown, newVal: unknown, key: unknown) => unknown, collection: C, - ...collections: Array | Iterable<[unknown, unknown]> | {[key: string]: unknown}> + ...collections: Array< + | Iterable + | Iterable<[unknown, unknown]> + | { [key: string]: unknown } + > ): C; } -declare module "immutable" { - export = Immutable +declare module 'immutable' { + export = Immutable; } diff --git a/dist/immutable.es.js b/dist/immutable.es.js index e397b90d9d..be31f20742 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -766,41 +766,50 @@ function smi(i32) { var defaultValueOf = Object.prototype.valueOf; function hash(o) { - switch (typeof o) { + if (o == null) { + return hashNullish(o); + } + + if (typeof o.hashCode === 'function') { + // Drop any high bits from accidentally long hash codes. + return smi(o.hashCode(o)); + } + + var v = valueOf(o); + + if (v == null) { + return hashNullish(v); + } + + switch (typeof v) { case 'boolean': // The hash values for built-in constants are a 1 value for each 5-byte // shift region expect for the first, which encodes the value. This // reduces the odds of a hash collision for these common values. - return o ? 0x42108421 : 0x42108420; + return v ? 0x42108421 : 0x42108420; case 'number': - return hashNumber(o); + return hashNumber(v); case 'string': - return o.length > STRING_HASH_CACHE_MIN_STRLEN - ? cachedHashString(o) - : hashString(o); + return v.length > STRING_HASH_CACHE_MIN_STRLEN + ? cachedHashString(v) + : hashString(v); case 'object': case 'function': - if (o === null) { - return 0x42108422; - } - if (typeof o.hashCode === 'function') { - // Drop any high bits from accidentally long hash codes. - return smi(o.hashCode(o)); - } - if (o.valueOf !== defaultValueOf && typeof o.valueOf === 'function') { - o = o.valueOf(o); - } - return hashJSObj(o); - case 'undefined': - return 0x42108423; + return hashJSObj(v); + case 'symbol': + return hashSymbol(v); default: - if (typeof o.toString === 'function') { - return hashString(o.toString()); + if (typeof v.toString === 'function') { + return hashString(v.toString()); } - throw new Error('Value type ' + typeof o + ' cannot be hashed.'); + throw new Error('Value type ' + typeof v + ' cannot be hashed.'); } } +function hashNullish(nullish) { + return nullish === null ? 0x42108422 : /* undefined */ 0x42108423; +} + // Compress arbitrarily large numbers into smi hashes. function hashNumber(n) { if (n !== n || n === Infinity) { @@ -846,6 +855,19 @@ function hashString(string) { return smi(hashed); } +function hashSymbol(sym) { + var hashed = symbolMap[sym]; + if (hashed !== undefined) { + return hashed; + } + + hashed = nextHash(); + + symbolMap[sym] = hashed; + + return hashed; +} + function hashJSObj(obj) { var hashed; if (usingWeakMap) { @@ -872,10 +894,7 @@ function hashJSObj(obj) { } } - hashed = ++objHashUID; - if (objHashUID & 0x40000000) { - objHashUID = 0; - } + hashed = nextHash(); if (usingWeakMap) { weakMap.set(obj, hashed); @@ -942,6 +961,20 @@ function getIENodeHash(node) { } } +function valueOf(obj) { + return obj.valueOf !== defaultValueOf && typeof obj.valueOf === 'function' + ? obj.valueOf(obj) + : obj; +} + +function nextHash() { + var nextHash = ++_objHashUID; + if (_objHashUID & 0x40000000) { + _objHashUID = 0; + } + return nextHash; +} + // If possible, use a WeakMap. var usingWeakMap = typeof WeakMap === 'function'; var weakMap; @@ -949,7 +982,9 @@ if (usingWeakMap) { weakMap = new WeakMap(); } -var objHashUID = 0; +var symbolMap = Object.create(null); + +var _objHashUID = 0; var UID_HASH_KEY = '__immutablehash__'; if (typeof Symbol === 'function') { @@ -985,29 +1020,29 @@ var ToKeyedSequence = /*@__PURE__*/(function (KeyedSeq) { }; ToKeyedSequence.prototype.reverse = function reverse () { - var this$1 = this; + var this$1$1 = this; var reversedSequence = reverseFactory(this, true); if (!this._useKeys) { - reversedSequence.valueSeq = function () { return this$1._iter.toSeq().reverse(); }; + reversedSequence.valueSeq = function () { return this$1$1._iter.toSeq().reverse(); }; } return reversedSequence; }; ToKeyedSequence.prototype.map = function map (mapper, context) { - var this$1 = this; + var this$1$1 = this; var mappedSequence = mapFactory(this, mapper, context); if (!this._useKeys) { - mappedSequence.valueSeq = function () { return this$1._iter.toSeq().map(mapper, context); }; + mappedSequence.valueSeq = function () { return this$1$1._iter.toSeq().map(mapper, context); }; } return mappedSequence; }; ToKeyedSequence.prototype.__iterate = function __iterate (fn, reverse) { - var this$1 = this; + var this$1$1 = this; - return this._iter.__iterate(function (v, k) { return fn(v, k, this$1); }, reverse); + return this._iter.__iterate(function (v, k) { return fn(v, k, this$1$1); }, reverse); }; ToKeyedSequence.prototype.__iterator = function __iterator (type, reverse) { @@ -1033,18 +1068,18 @@ var ToIndexedSequence = /*@__PURE__*/(function (IndexedSeq) { }; ToIndexedSequence.prototype.__iterate = function __iterate (fn, reverse) { - var this$1 = this; + var this$1$1 = this; var i = 0; reverse && ensureSize(this); return this._iter.__iterate( - function (v) { return fn(v, reverse ? this$1.size - ++i : i++, this$1); }, + function (v) { return fn(v, reverse ? this$1$1.size - ++i : i++, this$1$1); }, reverse ); }; ToIndexedSequence.prototype.__iterator = function __iterator (type, reverse) { - var this$1 = this; + var this$1$1 = this; var iterator = this._iter.__iterator(ITERATE_VALUES, reverse); var i = 0; @@ -1055,7 +1090,7 @@ var ToIndexedSequence = /*@__PURE__*/(function (IndexedSeq) { ? step : iteratorValue( type, - reverse ? this$1.size - ++i : i++, + reverse ? this$1$1.size - ++i : i++, step.value, step ); @@ -1080,9 +1115,9 @@ var ToSetSequence = /*@__PURE__*/(function (SetSeq) { }; ToSetSequence.prototype.__iterate = function __iterate (fn, reverse) { - var this$1 = this; + var this$1$1 = this; - return this._iter.__iterate(function (v) { return fn(v, v, this$1); }, reverse); + return this._iter.__iterate(function (v) { return fn(v, v, this$1$1); }, reverse); }; ToSetSequence.prototype.__iterator = function __iterator (type, reverse) { @@ -1113,7 +1148,7 @@ var FromEntriesSequence = /*@__PURE__*/(function (KeyedSeq) { }; FromEntriesSequence.prototype.__iterate = function __iterate (fn, reverse) { - var this$1 = this; + var this$1$1 = this; return this._iter.__iterate(function (entry) { // Check if entry exists first so array access doesn't throw for holes @@ -1124,7 +1159,7 @@ var FromEntriesSequence = /*@__PURE__*/(function (KeyedSeq) { return fn( indexedCollection ? entry.get(1) : entry[1], indexedCollection ? entry.get(0) : entry[0], - this$1 + this$1$1 ); } }, reverse); @@ -1178,9 +1213,9 @@ function flipFactory(collection) { flipSequence.includes = function (key) { return collection.has(key); }; flipSequence.cacheResult = cacheResultThrough; flipSequence.__iterateUncached = function (fn, reverse) { - var this$1 = this; + var this$1$1 = this; - return collection.__iterate(function (v, k) { return fn(k, v, this$1) !== false; }, reverse); + return collection.__iterate(function (v, k) { return fn(k, v, this$1$1) !== false; }, reverse); }; flipSequence.__iteratorUncached = function (type, reverse) { if (type === ITERATE_ENTRIES) { @@ -1214,10 +1249,10 @@ function mapFactory(collection, mapper, context) { : mapper.call(context, v, key, collection); }; mappedSequence.__iterateUncached = function (fn, reverse) { - var this$1 = this; + var this$1$1 = this; return collection.__iterate( - function (v, k, c) { return fn(mapper.call(context, v, k, c), k, this$1) !== false; }, + function (v, k, c) { return fn(mapper.call(context, v, k, c), k, this$1$1) !== false; }, reverse ); }; @@ -1242,7 +1277,7 @@ function mapFactory(collection, mapper, context) { } function reverseFactory(collection, useKeys) { - var this$1 = this; + var this$1$1 = this; var reversedSequence = makeSequence(collection); reversedSequence._iter = collection; @@ -1260,12 +1295,12 @@ function reverseFactory(collection, useKeys) { reversedSequence.includes = function (value) { return collection.includes(value); }; reversedSequence.cacheResult = cacheResultThrough; reversedSequence.__iterate = function (fn, reverse) { - var this$1 = this; + var this$1$1 = this; var i = 0; reverse && ensureSize(collection); return collection.__iterate( - function (v, k) { return fn(v, useKeys ? k : reverse ? this$1.size - ++i : i++, this$1); }, + function (v, k) { return fn(v, useKeys ? k : reverse ? this$1$1.size - ++i : i++, this$1$1); }, !reverse ); }; @@ -1281,7 +1316,7 @@ function reverseFactory(collection, useKeys) { var entry = step.value; return iteratorValue( type, - useKeys ? entry[0] : reverse ? this$1.size - ++i : i++, + useKeys ? entry[0] : reverse ? this$1$1.size - ++i : i++, entry[1], step ); @@ -1305,13 +1340,13 @@ function filterFactory(collection, predicate, context, useKeys) { }; } filterSequence.__iterateUncached = function (fn, reverse) { - var this$1 = this; + var this$1$1 = this; var iterations = 0; collection.__iterate(function (v, k, c) { if (predicate.call(context, v, k, c)) { iterations++; - return fn(v, useKeys ? k : iterations - 1, this$1); + return fn(v, useKeys ? k : iterations - 1, this$1$1); } }, reverse); return iterations; @@ -1402,7 +1437,7 @@ function sliceFactory(collection, begin, end, useKeys) { } sliceSeq.__iterateUncached = function (fn, reverse) { - var this$1 = this; + var this$1$1 = this; if (sliceSize === 0) { return 0; @@ -1417,7 +1452,7 @@ function sliceFactory(collection, begin, end, useKeys) { if (!(isSkipping && (isSkipping = skipped++ < resolvedBegin))) { iterations++; return ( - fn(v, useKeys ? k : iterations - 1, this$1) !== false && + fn(v, useKeys ? k : iterations - 1, this$1$1) !== false && iterations !== sliceSize ); } @@ -1460,19 +1495,19 @@ function sliceFactory(collection, begin, end, useKeys) { function takeWhileFactory(collection, predicate, context) { var takeSequence = makeSequence(collection); takeSequence.__iterateUncached = function (fn, reverse) { - var this$1 = this; + var this$1$1 = this; if (reverse) { return this.cacheResult().__iterate(fn, reverse); } var iterations = 0; collection.__iterate( - function (v, k, c) { return predicate.call(context, v, k, c) && ++iterations && fn(v, k, this$1); } + function (v, k, c) { return predicate.call(context, v, k, c) && ++iterations && fn(v, k, this$1$1); } ); return iterations; }; takeSequence.__iteratorUncached = function (type, reverse) { - var this$1 = this; + var this$1$1 = this; if (reverse) { return this.cacheResult().__iterator(type, reverse); @@ -1490,7 +1525,7 @@ function takeWhileFactory(collection, predicate, context) { var entry = step.value; var k = entry[0]; var v = entry[1]; - if (!predicate.call(context, v, k, this$1)) { + if (!predicate.call(context, v, k, this$1$1)) { iterating = false; return iteratorDone(); } @@ -1503,7 +1538,7 @@ function takeWhileFactory(collection, predicate, context) { function skipWhileFactory(collection, predicate, context, useKeys) { var skipSequence = makeSequence(collection); skipSequence.__iterateUncached = function (fn, reverse) { - var this$1 = this; + var this$1$1 = this; if (reverse) { return this.cacheResult().__iterate(fn, reverse); @@ -1513,13 +1548,13 @@ function skipWhileFactory(collection, predicate, context, useKeys) { collection.__iterate(function (v, k, c) { if (!(isSkipping && (isSkipping = predicate.call(context, v, k, c)))) { iterations++; - return fn(v, useKeys ? k : iterations - 1, this$1); + return fn(v, useKeys ? k : iterations - 1, this$1$1); } }); return iterations; }; skipSequence.__iteratorUncached = function (type, reverse) { - var this$1 = this; + var this$1$1 = this; if (reverse) { return this.cacheResult().__iterator(type, reverse); @@ -1545,7 +1580,7 @@ function skipWhileFactory(collection, predicate, context, useKeys) { var entry = step.value; k = entry[0]; v = entry[1]; - skipping && (skipping = predicate.call(context, v, k, this$1)); + skipping && (skipping = predicate.call(context, v, k, this$1$1)); } while (skipping); return type === ITERATE_ENTRIES ? step : iteratorValue(type, k, v, step); }); @@ -1669,12 +1704,12 @@ function interposeFactory(collection, separator) { var interposedSequence = makeSequence(collection); interposedSequence.size = collection.size && collection.size * 2 - 1; interposedSequence.__iterateUncached = function (fn, reverse) { - var this$1 = this; + var this$1$1 = this; var iterations = 0; collection.__iterate( - function (v) { return (!iterations || fn(separator, iterations++, this$1) !== false) && - fn(v, iterations++, this$1) !== false; }, + function (v) { return (!iterations || fn(separator, iterations++, this$1$1) !== false) && + fn(v, iterations++, this$1$1) !== false; }, reverse ); return iterations; @@ -1898,12 +1933,31 @@ function coerceKeyPath(keyPath) { ); } -function isPlainObj(value) { - return ( - value && - (typeof value.constructor !== 'function' || - value.constructor.name === 'Object') - ); +var toString = Object.prototype.toString; + +function isPlainObject(value) { + // The base prototype's toString deals with Argument objects and native namespaces like Math + if ( + !value || + typeof value !== 'object' || + toString.call(value) !== '[object Object]' + ) { + return false; + } + + var proto = Object.getPrototypeOf(value); + if (proto === null) { + return true; + } + + // Iteratively going up the prototype chain is needed for cross-realm environments (differing contexts, iframes, etc) + var parentProto = proto; + var nextProto = Object.getPrototypeOf(proto); + while (nextProto !== null) { + parentProto = nextProto; + nextProto = Object.getPrototypeOf(parentProto); + } + return parentProto === proto; } /** @@ -1913,7 +1967,7 @@ function isPlainObj(value) { function isDataStructure(value) { return ( typeof value === 'object' && - (isImmutable(value) || Array.isArray(value) || isPlainObj(value)) + (isImmutable(value) || Array.isArray(value) || isPlainObject(value)) ); } @@ -2002,7 +2056,7 @@ function set(collection, key, value) { return collectionCopy; } -function updateIn(collection, keyPath, notSetValue, updater) { +function updateIn$1(collection, keyPath, notSetValue, updater) { if (!updater) { updater = notSetValue; notSetValue = undefined; @@ -2061,44 +2115,44 @@ function updateInDeeply( ); } -function setIn(collection, keyPath, value) { - return updateIn(collection, keyPath, NOT_SET, function () { return value; }); +function setIn$1(collection, keyPath, value) { + return updateIn$1(collection, keyPath, NOT_SET, function () { return value; }); } -function setIn$1(keyPath, v) { - return setIn(this, keyPath, v); +function setIn(keyPath, v) { + return setIn$1(this, keyPath, v); } function removeIn(collection, keyPath) { - return updateIn(collection, keyPath, function () { return NOT_SET; }); + return updateIn$1(collection, keyPath, function () { return NOT_SET; }); } function deleteIn(keyPath) { return removeIn(this, keyPath); } -function update(collection, key, notSetValue, updater) { - return updateIn(collection, [key], notSetValue, updater); +function update$1(collection, key, notSetValue, updater) { + return updateIn$1(collection, [key], notSetValue, updater); } -function update$1(key, notSetValue, updater) { +function update(key, notSetValue, updater) { return arguments.length === 1 ? key(this) - : update(this, key, notSetValue, updater); + : update$1(this, key, notSetValue, updater); } -function updateIn$1(keyPath, notSetValue, updater) { - return updateIn(this, keyPath, notSetValue, updater); +function updateIn(keyPath, notSetValue, updater) { + return updateIn$1(this, keyPath, notSetValue, updater); } -function merge() { +function merge$1() { var iters = [], len = arguments.length; while ( len-- ) iters[ len ] = arguments[ len ]; return mergeIntoKeyedWith(this, iters); } -function mergeWith(merger) { +function mergeWith$1(merger) { var iters = [], len = arguments.length - 1; while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; @@ -2129,7 +2183,7 @@ function mergeIntoKeyedWith(collection, collections, merger) { return collection.withMutations(function (collection) { var mergeIntoCollection = merger ? function (value, key) { - update(collection, key, NOT_SET, function (oldVal) { return oldVal === NOT_SET ? value : merger(oldVal, value, key); } + update$1(collection, key, NOT_SET, function (oldVal) { return oldVal === NOT_SET ? value : merger(oldVal, value, key); } ); } : function (value, key) { @@ -2141,28 +2195,28 @@ function mergeIntoKeyedWith(collection, collections, merger) { }); } -function merge$1(collection) { +function merge(collection) { var sources = [], len = arguments.length - 1; while ( len-- > 0 ) sources[ len ] = arguments[ len + 1 ]; return mergeWithSources(collection, sources); } -function mergeWith$1(merger, collection) { +function mergeWith(merger, collection) { var sources = [], len = arguments.length - 2; while ( len-- > 0 ) sources[ len ] = arguments[ len + 2 ]; return mergeWithSources(collection, sources, merger); } -function mergeDeep(collection) { +function mergeDeep$1(collection) { var sources = [], len = arguments.length - 1; while ( len-- > 0 ) sources[ len ] = arguments[ len + 1 ]; return mergeDeepWithSources(collection, sources); } -function mergeDeepWith(merger, collection) { +function mergeDeepWith$1(merger, collection) { var sources = [], len = arguments.length - 2; while ( len-- > 0 ) sources[ len ] = arguments[ len + 2 ]; @@ -2226,14 +2280,14 @@ function deepMergerWith(merger) { return deepMerger; } -function mergeDeep$1() { +function mergeDeep() { var iters = [], len = arguments.length; while ( len-- ) iters[ len ] = arguments[ len ]; return mergeDeepWithSources(this, iters); } -function mergeDeepWith$1(merger) { +function mergeDeepWith(merger) { var iters = [], len = arguments.length - 1; while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; @@ -2244,14 +2298,14 @@ function mergeIn(keyPath) { var iters = [], len = arguments.length - 1; while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; - return updateIn(this, keyPath, emptyMap(), function (m) { return mergeWithSources(m, iters); }); + return updateIn$1(this, keyPath, emptyMap(), function (m) { return mergeWithSources(m, iters); }); } function mergeDeepIn(keyPath) { var iters = [], len = arguments.length - 1; while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; - return updateIn(this, keyPath, emptyMap(), function (m) { return mergeDeepWithSources(m, iters); } + return updateIn$1(this, keyPath, emptyMap(), function (m) { return mergeDeepWithSources(m, iters); } ); } @@ -2365,9 +2419,11 @@ var Map = /*@__PURE__*/(function (KeyedCollection) { }; Map.prototype.map = function map (mapper, context) { + var this$1$1 = this; + return this.withMutations(function (map) { map.forEach(function (value, key) { - map.set(key, mapper.call(context, value, key, map)); + map.set(key, mapper.call(context, value, key, this$1$1)); }); }); }; @@ -2379,13 +2435,13 @@ var Map = /*@__PURE__*/(function (KeyedCollection) { }; Map.prototype.__iterate = function __iterate (fn, reverse) { - var this$1 = this; + var this$1$1 = this; var iterations = 0; this._root && this._root.iterate(function (entry) { iterations++; - return fn(entry[1], entry[0], this$1); + return fn(entry[1], entry[0], this$1$1); }, reverse); return iterations; }; @@ -2414,14 +2470,14 @@ var MapPrototype = Map.prototype; MapPrototype[IS_MAP_SYMBOL] = true; MapPrototype[DELETE] = MapPrototype.remove; MapPrototype.removeAll = MapPrototype.deleteAll; -MapPrototype.setIn = setIn$1; +MapPrototype.setIn = setIn; MapPrototype.removeIn = MapPrototype.deleteIn = deleteIn; -MapPrototype.update = update$1; -MapPrototype.updateIn = updateIn$1; -MapPrototype.merge = MapPrototype.concat = merge; -MapPrototype.mergeWith = mergeWith; -MapPrototype.mergeDeep = mergeDeep$1; -MapPrototype.mergeDeepWith = mergeDeepWith$1; +MapPrototype.update = update; +MapPrototype.updateIn = updateIn; +MapPrototype.merge = MapPrototype.concat = merge$1; +MapPrototype.mergeWith = mergeWith$1; +MapPrototype.mergeDeep = mergeDeep; +MapPrototype.mergeDeepWith = mergeDeepWith; MapPrototype.mergeIn = mergeIn; MapPrototype.mergeDeepIn = mergeDeepIn; MapPrototype.withMutations = withMutations; @@ -3136,8 +3192,7 @@ var List = /*@__PURE__*/(function (IndexedCollection) { if (this.__ownerID) { this.size = this._origin = this._capacity = 0; this._level = SHIFT; - this._root = this._tail = null; - this.__hash = undefined; + this._root = this._tail = this.__hash = undefined; this.__altered = true; return this; } @@ -3206,11 +3261,11 @@ var List = /*@__PURE__*/(function (IndexedCollection) { }; List.prototype.map = function map (mapper, context) { - var this$1 = this; + var this$1$1 = this; return this.withMutations(function (list) { - for (var i = 0; i < this$1.size; i++) { - list.set(i, mapper.call(context, list.get(i), i, list)); + for (var i = 0; i < this$1$1.size; i++) { + list.set(i, mapper.call(context, list.get(i), i, this$1$1)); } }); }; @@ -3284,10 +3339,10 @@ var ListPrototype = List.prototype; ListPrototype[IS_LIST_SYMBOL] = true; ListPrototype[DELETE] = ListPrototype.remove; ListPrototype.merge = ListPrototype.concat; -ListPrototype.setIn = setIn$1; +ListPrototype.setIn = setIn; ListPrototype.deleteIn = ListPrototype.removeIn = deleteIn; -ListPrototype.update = update$1; -ListPrototype.updateIn = updateIn$1; +ListPrototype.update = update; +ListPrototype.updateIn = updateIn; ListPrototype.mergeIn = mergeIn; ListPrototype.mergeDeepIn = mergeDeepIn; ListPrototype.withMutations = withMutations; @@ -3309,7 +3364,7 @@ var VNode = function VNode(array, ownerID) { // TODO: seems like these methods are very similar VNode.prototype.removeBefore = function removeBefore (ownerID, level, index) { - if (index === level ? 1 << level : this.array.length === 0) { + if (index === level ? 1 << level : this.array.length === 0) { return this; } var originIndex = (index >>> level) & MASK; @@ -3755,6 +3810,7 @@ var OrderedMap = /*@__PURE__*/(function (Map) { this.size = 0; this._map.clear(); this._list.clear(); + this.__altered = true; return this; } return emptyOrderedMap(); @@ -3768,15 +3824,11 @@ var OrderedMap = /*@__PURE__*/(function (Map) { return updateOrderedMap(this, k, NOT_SET); }; - OrderedMap.prototype.wasAltered = function wasAltered () { - return this._map.wasAltered() || this._list.wasAltered(); - }; - OrderedMap.prototype.__iterate = function __iterate (fn, reverse) { - var this$1 = this; + var this$1$1 = this; return this._list.__iterate( - function (entry) { return entry && fn(entry[1], entry[0], this$1); }, + function (entry) { return entry && fn(entry[1], entry[0], this$1$1); }, reverse ); }; @@ -3796,6 +3848,7 @@ var OrderedMap = /*@__PURE__*/(function (Map) { return emptyOrderedMap(); } this.__ownerID = ownerID; + this.__altered = false; this._map = newMap; this._list = newList; return this; @@ -3818,6 +3871,7 @@ function makeOrderedMap(map, list, ownerID, hash) { omap._list = list; omap.__ownerID = ownerID; omap.__hash = hash; + omap.__altered = false; return omap; } @@ -3870,6 +3924,7 @@ function updateOrderedMap(omap, k, v) { omap._map = newMap; omap._list = newList; omap.__hash = undefined; + omap.__altered = true; return omap; } return makeOrderedMap(newMap, newList); @@ -4034,11 +4089,11 @@ var Stack = /*@__PURE__*/(function (IndexedCollection) { // @pragma Iteration Stack.prototype.__iterate = function __iterate (fn, reverse) { - var this$1 = this; + var this$1$1 = this; if (reverse) { return new ArraySeq(this.toArray()).__iterate( - function (v, k) { return fn(v, k, this$1); }, + function (v, k) { return fn(v, k, this$1$1); }, reverse ); } @@ -4281,21 +4336,27 @@ var Set = /*@__PURE__*/(function (SetCollection) { // @pragma Composition Set.prototype.map = function map (mapper, context) { - var this$1 = this; + var this$1$1 = this; - var removes = []; - var adds = []; - this.forEach(function (value) { - var mapped = mapper.call(context, value, value, this$1); - if (mapped !== value) { - removes.push(value); - adds.push(mapped); - } - }); - return this.withMutations(function (set) { - removes.forEach(function (value) { return set.remove(value); }); - adds.forEach(function (value) { return set.add(value); }); - }); + // keep track if the set is altered by the map function + var didChanges = false; + + var newMap = updateSet( + this, + this._map.mapEntries(function (ref) { + var v = ref[1]; + + var mapped = mapper.call(context, v, v, this$1$1); + + if (mapped !== v) { + didChanges = true; + } + + return [mapped, mapped]; + }, context) + ); + + return didChanges ? newMap : this; }; Set.prototype.union = function union () { @@ -4373,9 +4434,9 @@ var Set = /*@__PURE__*/(function (SetCollection) { }; Set.prototype.__iterate = function __iterate (fn, reverse) { - var this$1 = this; + var this$1$1 = this; - return this._map.__iterate(function (k) { return fn(k, k, this$1); }, reverse); + return this._map.__iterate(function (k) { return fn(k, k, this$1$1); }, reverse); }; Set.prototype.__iterator = function __iterator (type, reverse) { @@ -4583,7 +4644,7 @@ var Range = /*@__PURE__*/(function (IndexedSeq) { var EMPTY_RANGE; -function getIn(collection, searchKeyPath, notSetValue) { +function getIn$1(collection, searchKeyPath, notSetValue) { var keyPath = coerceKeyPath(searchKeyPath); var i = 0; while (i !== keyPath.length) { @@ -4595,16 +4656,16 @@ function getIn(collection, searchKeyPath, notSetValue) { return collection; } -function getIn$1(searchKeyPath, notSetValue) { - return getIn(this, searchKeyPath, notSetValue); +function getIn(searchKeyPath, notSetValue) { + return getIn$1(this, searchKeyPath, notSetValue); } -function hasIn(collection, keyPath) { - return getIn(collection, keyPath, NOT_SET) !== NOT_SET; +function hasIn$1(collection, keyPath) { + return getIn$1(collection, keyPath, NOT_SET) !== NOT_SET; } -function hasIn$1(searchKeyPath) { - return hasIn(this, searchKeyPath); +function hasIn(searchKeyPath) { + return hasIn$1(this, searchKeyPath); } function toObject() { @@ -4909,7 +4970,7 @@ mixin(Collection, { return this.find(function (_, key) { return is(key, searchKey); }, undefined, notSetValue); }, - getIn: getIn$1, + getIn: getIn, groupBy: function groupBy(grouper, context) { return groupByFactory(this, grouper, context); @@ -4919,7 +4980,7 @@ mixin(Collection, { return this.get(searchKey, NOT_SET) !== NOT_SET; }, - hasIn: hasIn$1, + hasIn: hasIn, isSubset: function isSubset(iter) { iter = typeof iter.includes === 'function' ? iter : Collection(iter); @@ -5050,25 +5111,25 @@ mixin(KeyedCollection, { }, mapEntries: function mapEntries(mapper, context) { - var this$1 = this; + var this$1$1 = this; var iterations = 0; return reify( this, this.toSeq() - .map(function (v, k) { return mapper.call(context, [k, v], iterations++, this$1); }) + .map(function (v, k) { return mapper.call(context, [k, v], iterations++, this$1$1); }) .fromEntrySeq() ); }, mapKeys: function mapKeys(mapper, context) { - var this$1 = this; + var this$1$1 = this; return reify( this, this.toSeq() .flip() - .map(function (k, v) { return mapper.call(context, k, v, this$1); }) + .map(function (k, v) { return mapper.call(context, k, v, this$1$1); }) .flip() ); }, @@ -5385,11 +5446,33 @@ function emptyOrderedSet() { ); } +function throwOnInvalidDefaultValues(defaultValues) { + if (isRecord(defaultValues)) { + throw new Error( + 'Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.' + ); + } + + if (isImmutable(defaultValues)) { + throw new Error( + 'Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.' + ); + } + + if (defaultValues === null || typeof defaultValues !== 'object') { + throw new Error( + 'Can not call `Record` with a non-object as default values. Use a plain javascript object instead.' + ); + } +} + var Record = function Record(defaultValues, name) { var hasInitialized; + throwOnInvalidDefaultValues(defaultValues); + var RecordType = function Record(values) { - var this$1 = this; + var this$1$1 = this; if (values instanceof RecordType) { return values; @@ -5429,11 +5512,12 @@ var Record = function Record(defaultValues, name) { } this.__ownerID = undefined; this._values = List().withMutations(function (l) { - l.setSize(this$1._keys.length); + l.setSize(this$1$1._keys.length); KeyedCollection(values).forEach(function (v, k) { - l.set(this$1._indices[k], v === this$1._defaultValues[k] ? undefined : v); + l.set(this$1$1._indices[k], v === this$1$1._defaultValues[k] ? undefined : v); }); }); + return this; }; var RecordTypePrototype = (RecordType.prototype = @@ -5460,10 +5544,7 @@ Record.prototype.toString = function toString () { Record.prototype.equals = function equals (other) { return ( - this === other || - (other && - this._keys === other._keys && - recordSeq(this).equals(recordSeq(other))) + this === other || (other && recordSeq(this).equals(recordSeq(other))) ); }; @@ -5507,6 +5588,7 @@ Record.prototype.remove = function remove (k) { Record.prototype.clear = function clear () { var newValues = this._values.clear().setSize(this._keys.length); + return this.__ownerID ? this : makeRecord(this, newValues); }; @@ -5553,17 +5635,17 @@ var RecordPrototype = Record.prototype; RecordPrototype[IS_RECORD_SYMBOL] = true; RecordPrototype[DELETE] = RecordPrototype.remove; RecordPrototype.deleteIn = RecordPrototype.removeIn = deleteIn; -RecordPrototype.getIn = getIn$1; +RecordPrototype.getIn = getIn; RecordPrototype.hasIn = CollectionPrototype.hasIn; -RecordPrototype.merge = merge; -RecordPrototype.mergeWith = mergeWith; +RecordPrototype.merge = merge$1; +RecordPrototype.mergeWith = mergeWith$1; RecordPrototype.mergeIn = mergeIn; -RecordPrototype.mergeDeep = mergeDeep$1; -RecordPrototype.mergeDeepWith = mergeDeepWith$1; +RecordPrototype.mergeDeep = mergeDeep; +RecordPrototype.mergeDeepWith = mergeDeepWith; RecordPrototype.mergeDeepIn = mergeDeepIn; -RecordPrototype.setIn = setIn$1; -RecordPrototype.update = update$1; -RecordPrototype.updateIn = updateIn$1; +RecordPrototype.setIn = setIn; +RecordPrototype.update = update; +RecordPrototype.updateIn = updateIn; RecordPrototype.withMutations = withMutations; RecordPrototype.asMutable = asMutable; RecordPrototype.asImmutable = asImmutable; @@ -5683,13 +5765,13 @@ var Repeat = /*@__PURE__*/(function (IndexedSeq) { }; Repeat.prototype.__iterator = function __iterator (type, reverse) { - var this$1 = this; + var this$1$1 = this; var size = this.size; var i = 0; return new Iterator(function () { return i === size ? iteratorDone() - : iteratorValue(type, reverse ? size - ++i : i++, this$1._value); } + : iteratorValue(type, reverse ? size - ++i : i++, this$1$1._value); } ); }; @@ -5718,7 +5800,7 @@ function fromJS(value, converter) { function fromJSWith(stack, converter, value, key, keyPath, parentValue) { var toSeq = Array.isArray(value) ? IndexedSeq - : isPlainObj(value) + : isPlainObject(value) ? KeyedSeq : null; if (toSeq) { @@ -5777,6 +5859,7 @@ var Immutable = { isAssociative: isAssociative, isOrdered: isOrdered, isValueObject: isValueObject, + isPlainObject: isPlainObject, isSeq: isSeq, isList: isList, isMap: isMap, @@ -5787,23 +5870,23 @@ var Immutable = { isRecord: isRecord, get: get, - getIn: getIn, + getIn: getIn$1, has: has, - hasIn: hasIn, - merge: merge$1, - mergeDeep: mergeDeep, - mergeWith: mergeWith$1, - mergeDeepWith: mergeDeepWith, + hasIn: hasIn$1, + merge: merge, + mergeDeep: mergeDeep$1, + mergeWith: mergeWith, + mergeDeepWith: mergeDeepWith$1, remove: remove, removeIn: removeIn, set: set, - setIn: setIn, - update: update, - updateIn: updateIn, + setIn: setIn$1, + update: update$1, + updateIn: updateIn$1, }; // Note: Iterable is deprecated var Iterable = Collection; export default Immutable; -export { Collection, Iterable, List, Map, OrderedMap, OrderedSet, Range, Record, Repeat, Seq, Set, Stack, fromJS, get, getIn, has, hasIn, hash, is, isAssociative, isCollection, isImmutable, isIndexed, isKeyed, isOrdered, isValueObject, merge$1 as merge, mergeDeep, mergeDeepWith, mergeWith$1 as mergeWith, remove, removeIn, set, setIn, update, updateIn, version }; +export { Collection, Iterable, List, Map, OrderedMap, OrderedSet, Range, Record, Repeat, Seq, Set, Stack, fromJS, get, getIn$1 as getIn, has, hasIn$1 as hasIn, hash, is, isAssociative, isCollection, isImmutable, isIndexed, isKeyed, isList, isMap, isOrdered, isOrderedMap, isOrderedSet, isPlainObject, isRecord, isSeq, isSet, isStack, isValueObject, merge, mergeDeep$1 as mergeDeep, mergeDeepWith$1 as mergeDeepWith, mergeWith, remove, removeIn, set, setIn$1 as setIn, update$1 as update, updateIn$1 as updateIn, version }; diff --git a/dist/immutable.js b/dist/immutable.js index 11c192643a..3bae33adb6 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -772,41 +772,50 @@ var defaultValueOf = Object.prototype.valueOf; function hash(o) { - switch (typeof o) { + if (o == null) { + return hashNullish(o); + } + + if (typeof o.hashCode === 'function') { + // Drop any high bits from accidentally long hash codes. + return smi(o.hashCode(o)); + } + + var v = valueOf(o); + + if (v == null) { + return hashNullish(v); + } + + switch (typeof v) { case 'boolean': // The hash values for built-in constants are a 1 value for each 5-byte // shift region expect for the first, which encodes the value. This // reduces the odds of a hash collision for these common values. - return o ? 0x42108421 : 0x42108420; + return v ? 0x42108421 : 0x42108420; case 'number': - return hashNumber(o); + return hashNumber(v); case 'string': - return o.length > STRING_HASH_CACHE_MIN_STRLEN - ? cachedHashString(o) - : hashString(o); + return v.length > STRING_HASH_CACHE_MIN_STRLEN + ? cachedHashString(v) + : hashString(v); case 'object': case 'function': - if (o === null) { - return 0x42108422; - } - if (typeof o.hashCode === 'function') { - // Drop any high bits from accidentally long hash codes. - return smi(o.hashCode(o)); - } - if (o.valueOf !== defaultValueOf && typeof o.valueOf === 'function') { - o = o.valueOf(o); - } - return hashJSObj(o); - case 'undefined': - return 0x42108423; + return hashJSObj(v); + case 'symbol': + return hashSymbol(v); default: - if (typeof o.toString === 'function') { - return hashString(o.toString()); + if (typeof v.toString === 'function') { + return hashString(v.toString()); } - throw new Error('Value type ' + typeof o + ' cannot be hashed.'); + throw new Error('Value type ' + typeof v + ' cannot be hashed.'); } } + function hashNullish(nullish) { + return nullish === null ? 0x42108422 : /* undefined */ 0x42108423; + } + // Compress arbitrarily large numbers into smi hashes. function hashNumber(n) { if (n !== n || n === Infinity) { @@ -852,6 +861,19 @@ return smi(hashed); } + function hashSymbol(sym) { + var hashed = symbolMap[sym]; + if (hashed !== undefined) { + return hashed; + } + + hashed = nextHash(); + + symbolMap[sym] = hashed; + + return hashed; + } + function hashJSObj(obj) { var hashed; if (usingWeakMap) { @@ -878,10 +900,7 @@ } } - hashed = ++objHashUID; - if (objHashUID & 0x40000000) { - objHashUID = 0; - } + hashed = nextHash(); if (usingWeakMap) { weakMap.set(obj, hashed); @@ -948,6 +967,20 @@ } } + function valueOf(obj) { + return obj.valueOf !== defaultValueOf && typeof obj.valueOf === 'function' + ? obj.valueOf(obj) + : obj; + } + + function nextHash() { + var nextHash = ++_objHashUID; + if (_objHashUID & 0x40000000) { + _objHashUID = 0; + } + return nextHash; + } + // If possible, use a WeakMap. var usingWeakMap = typeof WeakMap === 'function'; var weakMap; @@ -955,7 +988,9 @@ weakMap = new WeakMap(); } - var objHashUID = 0; + var symbolMap = Object.create(null); + + var _objHashUID = 0; var UID_HASH_KEY = '__immutablehash__'; if (typeof Symbol === 'function') { @@ -991,29 +1026,29 @@ }; ToKeyedSequence.prototype.reverse = function reverse () { - var this$1 = this; + var this$1$1 = this; var reversedSequence = reverseFactory(this, true); if (!this._useKeys) { - reversedSequence.valueSeq = function () { return this$1._iter.toSeq().reverse(); }; + reversedSequence.valueSeq = function () { return this$1$1._iter.toSeq().reverse(); }; } return reversedSequence; }; ToKeyedSequence.prototype.map = function map (mapper, context) { - var this$1 = this; + var this$1$1 = this; var mappedSequence = mapFactory(this, mapper, context); if (!this._useKeys) { - mappedSequence.valueSeq = function () { return this$1._iter.toSeq().map(mapper, context); }; + mappedSequence.valueSeq = function () { return this$1$1._iter.toSeq().map(mapper, context); }; } return mappedSequence; }; ToKeyedSequence.prototype.__iterate = function __iterate (fn, reverse) { - var this$1 = this; + var this$1$1 = this; - return this._iter.__iterate(function (v, k) { return fn(v, k, this$1); }, reverse); + return this._iter.__iterate(function (v, k) { return fn(v, k, this$1$1); }, reverse); }; ToKeyedSequence.prototype.__iterator = function __iterator (type, reverse) { @@ -1039,18 +1074,18 @@ }; ToIndexedSequence.prototype.__iterate = function __iterate (fn, reverse) { - var this$1 = this; + var this$1$1 = this; var i = 0; reverse && ensureSize(this); return this._iter.__iterate( - function (v) { return fn(v, reverse ? this$1.size - ++i : i++, this$1); }, + function (v) { return fn(v, reverse ? this$1$1.size - ++i : i++, this$1$1); }, reverse ); }; ToIndexedSequence.prototype.__iterator = function __iterator (type, reverse) { - var this$1 = this; + var this$1$1 = this; var iterator = this._iter.__iterator(ITERATE_VALUES, reverse); var i = 0; @@ -1061,7 +1096,7 @@ ? step : iteratorValue( type, - reverse ? this$1.size - ++i : i++, + reverse ? this$1$1.size - ++i : i++, step.value, step ); @@ -1086,9 +1121,9 @@ }; ToSetSequence.prototype.__iterate = function __iterate (fn, reverse) { - var this$1 = this; + var this$1$1 = this; - return this._iter.__iterate(function (v) { return fn(v, v, this$1); }, reverse); + return this._iter.__iterate(function (v) { return fn(v, v, this$1$1); }, reverse); }; ToSetSequence.prototype.__iterator = function __iterator (type, reverse) { @@ -1119,7 +1154,7 @@ }; FromEntriesSequence.prototype.__iterate = function __iterate (fn, reverse) { - var this$1 = this; + var this$1$1 = this; return this._iter.__iterate(function (entry) { // Check if entry exists first so array access doesn't throw for holes @@ -1130,7 +1165,7 @@ return fn( indexedCollection ? entry.get(1) : entry[1], indexedCollection ? entry.get(0) : entry[0], - this$1 + this$1$1 ); } }, reverse); @@ -1184,9 +1219,9 @@ flipSequence.includes = function (key) { return collection.has(key); }; flipSequence.cacheResult = cacheResultThrough; flipSequence.__iterateUncached = function (fn, reverse) { - var this$1 = this; + var this$1$1 = this; - return collection.__iterate(function (v, k) { return fn(k, v, this$1) !== false; }, reverse); + return collection.__iterate(function (v, k) { return fn(k, v, this$1$1) !== false; }, reverse); }; flipSequence.__iteratorUncached = function (type, reverse) { if (type === ITERATE_ENTRIES) { @@ -1220,10 +1255,10 @@ : mapper.call(context, v, key, collection); }; mappedSequence.__iterateUncached = function (fn, reverse) { - var this$1 = this; + var this$1$1 = this; return collection.__iterate( - function (v, k, c) { return fn(mapper.call(context, v, k, c), k, this$1) !== false; }, + function (v, k, c) { return fn(mapper.call(context, v, k, c), k, this$1$1) !== false; }, reverse ); }; @@ -1248,7 +1283,7 @@ } function reverseFactory(collection, useKeys) { - var this$1 = this; + var this$1$1 = this; var reversedSequence = makeSequence(collection); reversedSequence._iter = collection; @@ -1266,12 +1301,12 @@ reversedSequence.includes = function (value) { return collection.includes(value); }; reversedSequence.cacheResult = cacheResultThrough; reversedSequence.__iterate = function (fn, reverse) { - var this$1 = this; + var this$1$1 = this; var i = 0; reverse && ensureSize(collection); return collection.__iterate( - function (v, k) { return fn(v, useKeys ? k : reverse ? this$1.size - ++i : i++, this$1); }, + function (v, k) { return fn(v, useKeys ? k : reverse ? this$1$1.size - ++i : i++, this$1$1); }, !reverse ); }; @@ -1287,7 +1322,7 @@ var entry = step.value; return iteratorValue( type, - useKeys ? entry[0] : reverse ? this$1.size - ++i : i++, + useKeys ? entry[0] : reverse ? this$1$1.size - ++i : i++, entry[1], step ); @@ -1311,13 +1346,13 @@ }; } filterSequence.__iterateUncached = function (fn, reverse) { - var this$1 = this; + var this$1$1 = this; var iterations = 0; collection.__iterate(function (v, k, c) { if (predicate.call(context, v, k, c)) { iterations++; - return fn(v, useKeys ? k : iterations - 1, this$1); + return fn(v, useKeys ? k : iterations - 1, this$1$1); } }, reverse); return iterations; @@ -1408,7 +1443,7 @@ } sliceSeq.__iterateUncached = function (fn, reverse) { - var this$1 = this; + var this$1$1 = this; if (sliceSize === 0) { return 0; @@ -1423,7 +1458,7 @@ if (!(isSkipping && (isSkipping = skipped++ < resolvedBegin))) { iterations++; return ( - fn(v, useKeys ? k : iterations - 1, this$1) !== false && + fn(v, useKeys ? k : iterations - 1, this$1$1) !== false && iterations !== sliceSize ); } @@ -1466,19 +1501,19 @@ function takeWhileFactory(collection, predicate, context) { var takeSequence = makeSequence(collection); takeSequence.__iterateUncached = function (fn, reverse) { - var this$1 = this; + var this$1$1 = this; if (reverse) { return this.cacheResult().__iterate(fn, reverse); } var iterations = 0; collection.__iterate( - function (v, k, c) { return predicate.call(context, v, k, c) && ++iterations && fn(v, k, this$1); } + function (v, k, c) { return predicate.call(context, v, k, c) && ++iterations && fn(v, k, this$1$1); } ); return iterations; }; takeSequence.__iteratorUncached = function (type, reverse) { - var this$1 = this; + var this$1$1 = this; if (reverse) { return this.cacheResult().__iterator(type, reverse); @@ -1496,7 +1531,7 @@ var entry = step.value; var k = entry[0]; var v = entry[1]; - if (!predicate.call(context, v, k, this$1)) { + if (!predicate.call(context, v, k, this$1$1)) { iterating = false; return iteratorDone(); } @@ -1509,7 +1544,7 @@ function skipWhileFactory(collection, predicate, context, useKeys) { var skipSequence = makeSequence(collection); skipSequence.__iterateUncached = function (fn, reverse) { - var this$1 = this; + var this$1$1 = this; if (reverse) { return this.cacheResult().__iterate(fn, reverse); @@ -1519,13 +1554,13 @@ collection.__iterate(function (v, k, c) { if (!(isSkipping && (isSkipping = predicate.call(context, v, k, c)))) { iterations++; - return fn(v, useKeys ? k : iterations - 1, this$1); + return fn(v, useKeys ? k : iterations - 1, this$1$1); } }); return iterations; }; skipSequence.__iteratorUncached = function (type, reverse) { - var this$1 = this; + var this$1$1 = this; if (reverse) { return this.cacheResult().__iterator(type, reverse); @@ -1551,7 +1586,7 @@ var entry = step.value; k = entry[0]; v = entry[1]; - skipping && (skipping = predicate.call(context, v, k, this$1)); + skipping && (skipping = predicate.call(context, v, k, this$1$1)); } while (skipping); return type === ITERATE_ENTRIES ? step : iteratorValue(type, k, v, step); }); @@ -1675,12 +1710,12 @@ var interposedSequence = makeSequence(collection); interposedSequence.size = collection.size && collection.size * 2 - 1; interposedSequence.__iterateUncached = function (fn, reverse) { - var this$1 = this; + var this$1$1 = this; var iterations = 0; collection.__iterate( - function (v) { return (!iterations || fn(separator, iterations++, this$1) !== false) && - fn(v, iterations++, this$1) !== false; }, + function (v) { return (!iterations || fn(separator, iterations++, this$1$1) !== false) && + fn(v, iterations++, this$1$1) !== false; }, reverse ); return iterations; @@ -1904,12 +1939,31 @@ ); } - function isPlainObj(value) { - return ( - value && - (typeof value.constructor !== 'function' || - value.constructor.name === 'Object') - ); + var toString = Object.prototype.toString; + + function isPlainObject(value) { + // The base prototype's toString deals with Argument objects and native namespaces like Math + if ( + !value || + typeof value !== 'object' || + toString.call(value) !== '[object Object]' + ) { + return false; + } + + var proto = Object.getPrototypeOf(value); + if (proto === null) { + return true; + } + + // Iteratively going up the prototype chain is needed for cross-realm environments (differing contexts, iframes, etc) + var parentProto = proto; + var nextProto = Object.getPrototypeOf(proto); + while (nextProto !== null) { + parentProto = nextProto; + nextProto = Object.getPrototypeOf(parentProto); + } + return parentProto === proto; } /** @@ -1919,7 +1973,7 @@ function isDataStructure(value) { return ( typeof value === 'object' && - (isImmutable(value) || Array.isArray(value) || isPlainObj(value)) + (isImmutable(value) || Array.isArray(value) || isPlainObject(value)) ); } @@ -2008,7 +2062,7 @@ return collectionCopy; } - function updateIn(collection, keyPath, notSetValue, updater) { + function updateIn$1(collection, keyPath, notSetValue, updater) { if (!updater) { updater = notSetValue; notSetValue = undefined; @@ -2067,44 +2121,44 @@ ); } - function setIn(collection, keyPath, value) { - return updateIn(collection, keyPath, NOT_SET, function () { return value; }); + function setIn$1(collection, keyPath, value) { + return updateIn$1(collection, keyPath, NOT_SET, function () { return value; }); } - function setIn$1(keyPath, v) { - return setIn(this, keyPath, v); + function setIn(keyPath, v) { + return setIn$1(this, keyPath, v); } function removeIn(collection, keyPath) { - return updateIn(collection, keyPath, function () { return NOT_SET; }); + return updateIn$1(collection, keyPath, function () { return NOT_SET; }); } function deleteIn(keyPath) { return removeIn(this, keyPath); } - function update(collection, key, notSetValue, updater) { - return updateIn(collection, [key], notSetValue, updater); + function update$1(collection, key, notSetValue, updater) { + return updateIn$1(collection, [key], notSetValue, updater); } - function update$1(key, notSetValue, updater) { + function update(key, notSetValue, updater) { return arguments.length === 1 ? key(this) - : update(this, key, notSetValue, updater); + : update$1(this, key, notSetValue, updater); } - function updateIn$1(keyPath, notSetValue, updater) { - return updateIn(this, keyPath, notSetValue, updater); + function updateIn(keyPath, notSetValue, updater) { + return updateIn$1(this, keyPath, notSetValue, updater); } - function merge() { + function merge$1() { var iters = [], len = arguments.length; while ( len-- ) iters[ len ] = arguments[ len ]; return mergeIntoKeyedWith(this, iters); } - function mergeWith(merger) { + function mergeWith$1(merger) { var iters = [], len = arguments.length - 1; while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; @@ -2135,7 +2189,7 @@ return collection.withMutations(function (collection) { var mergeIntoCollection = merger ? function (value, key) { - update(collection, key, NOT_SET, function (oldVal) { return oldVal === NOT_SET ? value : merger(oldVal, value, key); } + update$1(collection, key, NOT_SET, function (oldVal) { return oldVal === NOT_SET ? value : merger(oldVal, value, key); } ); } : function (value, key) { @@ -2147,28 +2201,28 @@ }); } - function merge$1(collection) { + function merge(collection) { var sources = [], len = arguments.length - 1; while ( len-- > 0 ) sources[ len ] = arguments[ len + 1 ]; return mergeWithSources(collection, sources); } - function mergeWith$1(merger, collection) { + function mergeWith(merger, collection) { var sources = [], len = arguments.length - 2; while ( len-- > 0 ) sources[ len ] = arguments[ len + 2 ]; return mergeWithSources(collection, sources, merger); } - function mergeDeep(collection) { + function mergeDeep$1(collection) { var sources = [], len = arguments.length - 1; while ( len-- > 0 ) sources[ len ] = arguments[ len + 1 ]; return mergeDeepWithSources(collection, sources); } - function mergeDeepWith(merger, collection) { + function mergeDeepWith$1(merger, collection) { var sources = [], len = arguments.length - 2; while ( len-- > 0 ) sources[ len ] = arguments[ len + 2 ]; @@ -2232,14 +2286,14 @@ return deepMerger; } - function mergeDeep$1() { + function mergeDeep() { var iters = [], len = arguments.length; while ( len-- ) iters[ len ] = arguments[ len ]; return mergeDeepWithSources(this, iters); } - function mergeDeepWith$1(merger) { + function mergeDeepWith(merger) { var iters = [], len = arguments.length - 1; while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; @@ -2250,14 +2304,14 @@ var iters = [], len = arguments.length - 1; while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; - return updateIn(this, keyPath, emptyMap(), function (m) { return mergeWithSources(m, iters); }); + return updateIn$1(this, keyPath, emptyMap(), function (m) { return mergeWithSources(m, iters); }); } function mergeDeepIn(keyPath) { var iters = [], len = arguments.length - 1; while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; - return updateIn(this, keyPath, emptyMap(), function (m) { return mergeDeepWithSources(m, iters); } + return updateIn$1(this, keyPath, emptyMap(), function (m) { return mergeDeepWithSources(m, iters); } ); } @@ -2371,9 +2425,11 @@ }; Map.prototype.map = function map (mapper, context) { + var this$1$1 = this; + return this.withMutations(function (map) { map.forEach(function (value, key) { - map.set(key, mapper.call(context, value, key, map)); + map.set(key, mapper.call(context, value, key, this$1$1)); }); }); }; @@ -2385,13 +2441,13 @@ }; Map.prototype.__iterate = function __iterate (fn, reverse) { - var this$1 = this; + var this$1$1 = this; var iterations = 0; this._root && this._root.iterate(function (entry) { iterations++; - return fn(entry[1], entry[0], this$1); + return fn(entry[1], entry[0], this$1$1); }, reverse); return iterations; }; @@ -2420,14 +2476,14 @@ MapPrototype[IS_MAP_SYMBOL] = true; MapPrototype[DELETE] = MapPrototype.remove; MapPrototype.removeAll = MapPrototype.deleteAll; - MapPrototype.setIn = setIn$1; + MapPrototype.setIn = setIn; MapPrototype.removeIn = MapPrototype.deleteIn = deleteIn; - MapPrototype.update = update$1; - MapPrototype.updateIn = updateIn$1; - MapPrototype.merge = MapPrototype.concat = merge; - MapPrototype.mergeWith = mergeWith; - MapPrototype.mergeDeep = mergeDeep$1; - MapPrototype.mergeDeepWith = mergeDeepWith$1; + MapPrototype.update = update; + MapPrototype.updateIn = updateIn; + MapPrototype.merge = MapPrototype.concat = merge$1; + MapPrototype.mergeWith = mergeWith$1; + MapPrototype.mergeDeep = mergeDeep; + MapPrototype.mergeDeepWith = mergeDeepWith; MapPrototype.mergeIn = mergeIn; MapPrototype.mergeDeepIn = mergeDeepIn; MapPrototype.withMutations = withMutations; @@ -3142,8 +3198,7 @@ if (this.__ownerID) { this.size = this._origin = this._capacity = 0; this._level = SHIFT; - this._root = this._tail = null; - this.__hash = undefined; + this._root = this._tail = this.__hash = undefined; this.__altered = true; return this; } @@ -3212,11 +3267,11 @@ }; List.prototype.map = function map (mapper, context) { - var this$1 = this; + var this$1$1 = this; return this.withMutations(function (list) { - for (var i = 0; i < this$1.size; i++) { - list.set(i, mapper.call(context, list.get(i), i, list)); + for (var i = 0; i < this$1$1.size; i++) { + list.set(i, mapper.call(context, list.get(i), i, this$1$1)); } }); }; @@ -3290,10 +3345,10 @@ ListPrototype[IS_LIST_SYMBOL] = true; ListPrototype[DELETE] = ListPrototype.remove; ListPrototype.merge = ListPrototype.concat; - ListPrototype.setIn = setIn$1; + ListPrototype.setIn = setIn; ListPrototype.deleteIn = ListPrototype.removeIn = deleteIn; - ListPrototype.update = update$1; - ListPrototype.updateIn = updateIn$1; + ListPrototype.update = update; + ListPrototype.updateIn = updateIn; ListPrototype.mergeIn = mergeIn; ListPrototype.mergeDeepIn = mergeDeepIn; ListPrototype.withMutations = withMutations; @@ -3315,7 +3370,7 @@ // TODO: seems like these methods are very similar VNode.prototype.removeBefore = function removeBefore (ownerID, level, index) { - if (index === level ? 1 << level : this.array.length === 0) { + if (index === level ? 1 << level : this.array.length === 0) { return this; } var originIndex = (index >>> level) & MASK; @@ -3761,6 +3816,7 @@ this.size = 0; this._map.clear(); this._list.clear(); + this.__altered = true; return this; } return emptyOrderedMap(); @@ -3774,15 +3830,11 @@ return updateOrderedMap(this, k, NOT_SET); }; - OrderedMap.prototype.wasAltered = function wasAltered () { - return this._map.wasAltered() || this._list.wasAltered(); - }; - OrderedMap.prototype.__iterate = function __iterate (fn, reverse) { - var this$1 = this; + var this$1$1 = this; return this._list.__iterate( - function (entry) { return entry && fn(entry[1], entry[0], this$1); }, + function (entry) { return entry && fn(entry[1], entry[0], this$1$1); }, reverse ); }; @@ -3802,6 +3854,7 @@ return emptyOrderedMap(); } this.__ownerID = ownerID; + this.__altered = false; this._map = newMap; this._list = newList; return this; @@ -3824,6 +3877,7 @@ omap._list = list; omap.__ownerID = ownerID; omap.__hash = hash; + omap.__altered = false; return omap; } @@ -3876,6 +3930,7 @@ omap._map = newMap; omap._list = newList; omap.__hash = undefined; + omap.__altered = true; return omap; } return makeOrderedMap(newMap, newList); @@ -4040,11 +4095,11 @@ // @pragma Iteration Stack.prototype.__iterate = function __iterate (fn, reverse) { - var this$1 = this; + var this$1$1 = this; if (reverse) { return new ArraySeq(this.toArray()).__iterate( - function (v, k) { return fn(v, k, this$1); }, + function (v, k) { return fn(v, k, this$1$1); }, reverse ); } @@ -4287,21 +4342,27 @@ // @pragma Composition Set.prototype.map = function map (mapper, context) { - var this$1 = this; + var this$1$1 = this; - var removes = []; - var adds = []; - this.forEach(function (value) { - var mapped = mapper.call(context, value, value, this$1); - if (mapped !== value) { - removes.push(value); - adds.push(mapped); - } - }); - return this.withMutations(function (set) { - removes.forEach(function (value) { return set.remove(value); }); - adds.forEach(function (value) { return set.add(value); }); - }); + // keep track if the set is altered by the map function + var didChanges = false; + + var newMap = updateSet( + this, + this._map.mapEntries(function (ref) { + var v = ref[1]; + + var mapped = mapper.call(context, v, v, this$1$1); + + if (mapped !== v) { + didChanges = true; + } + + return [mapped, mapped]; + }, context) + ); + + return didChanges ? newMap : this; }; Set.prototype.union = function union () { @@ -4379,9 +4440,9 @@ }; Set.prototype.__iterate = function __iterate (fn, reverse) { - var this$1 = this; + var this$1$1 = this; - return this._map.__iterate(function (k) { return fn(k, k, this$1); }, reverse); + return this._map.__iterate(function (k) { return fn(k, k, this$1$1); }, reverse); }; Set.prototype.__iterator = function __iterator (type, reverse) { @@ -4589,7 +4650,7 @@ var EMPTY_RANGE; - function getIn(collection, searchKeyPath, notSetValue) { + function getIn$1(collection, searchKeyPath, notSetValue) { var keyPath = coerceKeyPath(searchKeyPath); var i = 0; while (i !== keyPath.length) { @@ -4601,16 +4662,16 @@ return collection; } - function getIn$1(searchKeyPath, notSetValue) { - return getIn(this, searchKeyPath, notSetValue); + function getIn(searchKeyPath, notSetValue) { + return getIn$1(this, searchKeyPath, notSetValue); } - function hasIn(collection, keyPath) { - return getIn(collection, keyPath, NOT_SET) !== NOT_SET; + function hasIn$1(collection, keyPath) { + return getIn$1(collection, keyPath, NOT_SET) !== NOT_SET; } - function hasIn$1(searchKeyPath) { - return hasIn(this, searchKeyPath); + function hasIn(searchKeyPath) { + return hasIn$1(this, searchKeyPath); } function toObject() { @@ -4915,7 +4976,7 @@ return this.find(function (_, key) { return is(key, searchKey); }, undefined, notSetValue); }, - getIn: getIn$1, + getIn: getIn, groupBy: function groupBy(grouper, context) { return groupByFactory(this, grouper, context); @@ -4925,7 +4986,7 @@ return this.get(searchKey, NOT_SET) !== NOT_SET; }, - hasIn: hasIn$1, + hasIn: hasIn, isSubset: function isSubset(iter) { iter = typeof iter.includes === 'function' ? iter : Collection(iter); @@ -5056,25 +5117,25 @@ }, mapEntries: function mapEntries(mapper, context) { - var this$1 = this; + var this$1$1 = this; var iterations = 0; return reify( this, this.toSeq() - .map(function (v, k) { return mapper.call(context, [k, v], iterations++, this$1); }) + .map(function (v, k) { return mapper.call(context, [k, v], iterations++, this$1$1); }) .fromEntrySeq() ); }, mapKeys: function mapKeys(mapper, context) { - var this$1 = this; + var this$1$1 = this; return reify( this, this.toSeq() .flip() - .map(function (k, v) { return mapper.call(context, k, v, this$1); }) + .map(function (k, v) { return mapper.call(context, k, v, this$1$1); }) .flip() ); }, @@ -5391,11 +5452,33 @@ ); } + function throwOnInvalidDefaultValues(defaultValues) { + if (isRecord(defaultValues)) { + throw new Error( + 'Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.' + ); + } + + if (isImmutable(defaultValues)) { + throw new Error( + 'Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.' + ); + } + + if (defaultValues === null || typeof defaultValues !== 'object') { + throw new Error( + 'Can not call `Record` with a non-object as default values. Use a plain javascript object instead.' + ); + } + } + var Record = function Record(defaultValues, name) { var hasInitialized; + throwOnInvalidDefaultValues(defaultValues); + var RecordType = function Record(values) { - var this$1 = this; + var this$1$1 = this; if (values instanceof RecordType) { return values; @@ -5435,11 +5518,12 @@ } this.__ownerID = undefined; this._values = List().withMutations(function (l) { - l.setSize(this$1._keys.length); + l.setSize(this$1$1._keys.length); KeyedCollection(values).forEach(function (v, k) { - l.set(this$1._indices[k], v === this$1._defaultValues[k] ? undefined : v); + l.set(this$1$1._indices[k], v === this$1$1._defaultValues[k] ? undefined : v); }); }); + return this; }; var RecordTypePrototype = (RecordType.prototype = @@ -5466,10 +5550,7 @@ Record.prototype.equals = function equals (other) { return ( - this === other || - (other && - this._keys === other._keys && - recordSeq(this).equals(recordSeq(other))) + this === other || (other && recordSeq(this).equals(recordSeq(other))) ); }; @@ -5513,6 +5594,7 @@ Record.prototype.clear = function clear () { var newValues = this._values.clear().setSize(this._keys.length); + return this.__ownerID ? this : makeRecord(this, newValues); }; @@ -5559,17 +5641,17 @@ RecordPrototype[IS_RECORD_SYMBOL] = true; RecordPrototype[DELETE] = RecordPrototype.remove; RecordPrototype.deleteIn = RecordPrototype.removeIn = deleteIn; - RecordPrototype.getIn = getIn$1; + RecordPrototype.getIn = getIn; RecordPrototype.hasIn = CollectionPrototype.hasIn; - RecordPrototype.merge = merge; - RecordPrototype.mergeWith = mergeWith; + RecordPrototype.merge = merge$1; + RecordPrototype.mergeWith = mergeWith$1; RecordPrototype.mergeIn = mergeIn; - RecordPrototype.mergeDeep = mergeDeep$1; - RecordPrototype.mergeDeepWith = mergeDeepWith$1; + RecordPrototype.mergeDeep = mergeDeep; + RecordPrototype.mergeDeepWith = mergeDeepWith; RecordPrototype.mergeDeepIn = mergeDeepIn; - RecordPrototype.setIn = setIn$1; - RecordPrototype.update = update$1; - RecordPrototype.updateIn = updateIn$1; + RecordPrototype.setIn = setIn; + RecordPrototype.update = update; + RecordPrototype.updateIn = updateIn; RecordPrototype.withMutations = withMutations; RecordPrototype.asMutable = asMutable; RecordPrototype.asImmutable = asImmutable; @@ -5689,13 +5771,13 @@ }; Repeat.prototype.__iterator = function __iterator (type, reverse) { - var this$1 = this; + var this$1$1 = this; var size = this.size; var i = 0; return new Iterator(function () { return i === size ? iteratorDone() - : iteratorValue(type, reverse ? size - ++i : i++, this$1._value); } + : iteratorValue(type, reverse ? size - ++i : i++, this$1$1._value); } ); }; @@ -5724,7 +5806,7 @@ function fromJSWith(stack, converter, value, key, keyPath, parentValue) { var toSeq = Array.isArray(value) ? IndexedSeq - : isPlainObj(value) + : isPlainObject(value) ? KeyedSeq : null; if (toSeq) { @@ -5783,6 +5865,7 @@ isAssociative: isAssociative, isOrdered: isOrdered, isValueObject: isValueObject, + isPlainObject: isPlainObject, isSeq: isSeq, isList: isList, isMap: isMap, @@ -5793,19 +5876,19 @@ isRecord: isRecord, get: get, - getIn: getIn, + getIn: getIn$1, has: has, - hasIn: hasIn, - merge: merge$1, - mergeDeep: mergeDeep, - mergeWith: mergeWith$1, - mergeDeepWith: mergeDeepWith, + hasIn: hasIn$1, + merge: merge, + mergeDeep: mergeDeep$1, + mergeWith: mergeWith, + mergeDeepWith: mergeDeepWith$1, remove: remove, removeIn: removeIn, set: set, - setIn: setIn, - update: update, - updateIn: updateIn, + setIn: setIn$1, + update: update$1, + updateIn: updateIn$1, }; // Note: Iterable is deprecated @@ -5826,9 +5909,9 @@ exports.default = Immutable; exports.fromJS = fromJS; exports.get = get; - exports.getIn = getIn; + exports.getIn = getIn$1; exports.has = has; - exports.hasIn = hasIn; + exports.hasIn = hasIn$1; exports.hash = hash; exports.is = is; exports.isAssociative = isAssociative; @@ -5836,18 +5919,27 @@ exports.isImmutable = isImmutable; exports.isIndexed = isIndexed; exports.isKeyed = isKeyed; + exports.isList = isList; + exports.isMap = isMap; exports.isOrdered = isOrdered; + exports.isOrderedMap = isOrderedMap; + exports.isOrderedSet = isOrderedSet; + exports.isPlainObject = isPlainObject; + exports.isRecord = isRecord; + exports.isSeq = isSeq; + exports.isSet = isSet; + exports.isStack = isStack; exports.isValueObject = isValueObject; - exports.merge = merge$1; - exports.mergeDeep = mergeDeep; - exports.mergeDeepWith = mergeDeepWith; - exports.mergeWith = mergeWith$1; + exports.merge = merge; + exports.mergeDeep = mergeDeep$1; + exports.mergeDeepWith = mergeDeepWith$1; + exports.mergeWith = mergeWith; exports.remove = remove; exports.removeIn = removeIn; exports.set = set; - exports.setIn = setIn; - exports.update = update; - exports.updateIn = updateIn; + exports.setIn = setIn$1; + exports.update = update$1; + exports.updateIn = updateIn$1; exports.version = version; Object.defineProperty(exports, '__esModule', { value: true }); diff --git a/dist/immutable.js.flow b/dist/immutable.js.flow index b97b36277b..b790e590dc 100644 --- a/dist/immutable.js.flow +++ b/dist/immutable.js.flow @@ -23,28 +23,37 @@ // Helper type that represents plain objects allowed as arguments to // some constructors and functions. -type PlainObjInput = {+[key: K]: V, __proto__: null}; +type PlainObjInput = { +[key: K]: V, __proto__: null }; // Helper types to extract the "keys" and "values" use by the *In() methods. type $KeyOf = $Call< - & ((?_Collection) => K) - & ((?$ReadOnlyArray) => number) - & ((?RecordInstance | T) => $Keys), + ((?_Collection) => K) & + ((?$ReadOnlyArray) => number) & + ((?RecordInstance | T) => $Keys), C >; type $ValOf> = $Call< - & ((?_Collection) => V) - & ((?$ReadOnlyArray) => T) - & (>(?RecordInstance | T, K) => $ElementType) - & ((?{[any]: V}) => V), + ((?_Collection) => V) & + ((?$ReadOnlyArray) => T) & + (>(?RecordInstance | T, K) => $ElementType) & + ((?{ [any]: V }) => V), C, K >; type $IterableOf = $Call< - & ( | IndexedCollection | SetCollection>(V) => Iterable<$ValOf>) - & ( | RecordInstance | PlainObjInput>(V) => Iterable<[$KeyOf, $ValOf]>), + ( | IndexedCollection | SetCollection>( + V + ) => Iterable<$ValOf>) & + (< + V: + | KeyedCollection + | RecordInstance + | PlainObjInput + >( + V + ) => Iterable<[$KeyOf, $ValOf]>), C >; @@ -63,16 +72,39 @@ declare class _Collection implements ValueObject { getIn(keyPath: [], notSetValue?: mixed): this; getIn(keyPath: [K], notSetValue: NSV): V | NSV; - getIn>(keyPath: [K, K2], notSetValue: NSV): $ValOf | NSV; - getIn, K3: $KeyOf<$ValOf>>(keyPath: [K, K2, K3], notSetValue: NSV): $ValOf<$ValOf, K3> | NSV; - getIn, K3: $KeyOf<$ValOf>, K4: $KeyOf<$ValOf<$ValOf, K3>>>(keyPath: [K, K2, K3, K4], notSetValue: NSV): $ValOf<$ValOf<$ValOf, K3>, K4> | NSV; - getIn, K3: $KeyOf<$ValOf>, K4: $KeyOf<$ValOf<$ValOf, K3>>, K5: $KeyOf<$ValOf<$ValOf<$ValOf, K3>, K4>>>(keyPath: [K, K2, K3, K4, K5], notSetValue: NSV): $ValOf<$ValOf<$ValOf<$ValOf, K3>, K4>, K5> | NSV; + getIn>( + keyPath: [K, K2], + notSetValue: NSV + ): $ValOf | NSV; + getIn, K3: $KeyOf<$ValOf>>( + keyPath: [K, K2, K3], + notSetValue: NSV + ): $ValOf<$ValOf, K3> | NSV; + getIn< + NSV, + K2: $KeyOf, + K3: $KeyOf<$ValOf>, + K4: $KeyOf<$ValOf<$ValOf, K3>> + >( + keyPath: [K, K2, K3, K4], + notSetValue: NSV + ): $ValOf<$ValOf<$ValOf, K3>, K4> | NSV; + getIn< + NSV, + K2: $KeyOf, + K3: $KeyOf<$ValOf>, + K4: $KeyOf<$ValOf<$ValOf, K3>>, + K5: $KeyOf<$ValOf<$ValOf<$ValOf, K3>, K4>> + >( + keyPath: [K, K2, K3, K4, K5], + notSetValue: NSV + ): $ValOf<$ValOf<$ValOf<$ValOf, K3>, K4>, K5> | NSV; update(updater: (value: this) => U): U; toJS(): Array | { [key: string]: mixed }; toJSON(): Array | { [key: string]: V }; - toArray(): Array | Array<[K,V]>; + toArray(): Array | Array<[K, V]>; toObject(): { [key: string]: V }; toMap(): Map; toOrderedMap(): OrderedMap; @@ -116,12 +148,24 @@ declare class _Collection implements ValueObject { butLast(): this; skip(amount: number): this; skipLast(amount: number): this; - skipWhile(predicate: (value: V, key: K, iter: this) => mixed, context?: mixed): this; - skipUntil(predicate: (value: V, key: K, iter: this) => mixed, context?: mixed): this; + skipWhile( + predicate: (value: V, key: K, iter: this) => mixed, + context?: mixed + ): this; + skipUntil( + predicate: (value: V, key: K, iter: this) => mixed, + context?: mixed + ): this; take(amount: number): this; takeLast(amount: number): this; - takeWhile(predicate: (value: V, key: K, iter: this) => mixed, context?: mixed): this; - takeUntil(predicate: (value: V, key: K, iter: this) => mixed, context?: mixed): this; + takeWhile( + predicate: (value: V, key: K, iter: this) => mixed, + context?: mixed + ): this; + takeUntil( + predicate: (value: V, key: K, iter: this) => mixed, + context?: mixed + ): this; filterNot( predicate: (value: V, key: K, iter: this) => mixed, @@ -131,27 +175,37 @@ declare class _Collection implements ValueObject { reduce( reducer: (reduction: R, value: V, key: K, iter: this) => R, initialReduction: R, - context?: mixed, - ): R; - reduce( - reducer: (reduction: V | R, value: V, key: K, iter: this) => R + context?: mixed ): R; + reduce(reducer: (reduction: V | R, value: V, key: K, iter: this) => R): R; reduceRight( reducer: (reduction: R, value: V, key: K, iter: this) => R, initialReduction: R, - context?: mixed, + context?: mixed ): R; reduceRight( reducer: (reduction: V | R, value: V, key: K, iter: this) => R ): R; - every(predicate: (value: V, key: K, iter: this) => mixed, context?: mixed): boolean; - some(predicate: (value: V, key: K, iter: this) => mixed, context?: mixed): boolean; + every( + predicate: (value: V, key: K, iter: this) => mixed, + context?: mixed + ): boolean; + some( + predicate: (value: V, key: K, iter: this) => mixed, + context?: mixed + ): boolean; join(separator?: string): string; isEmpty(): boolean; - count(predicate?: (value: V, key: K, iter: this) => mixed, context?: mixed): number; - countBy(grouper: (value: V, key: K, iter: this) => G, context?: mixed): Map; + count( + predicate?: (value: V, key: K, iter: this) => mixed, + context?: mixed + ): number; + countBy( + grouper: (value: V, key: K, iter: this) => G, + context?: mixed + ): Map; find( predicate: (value: V, key: K, iter: this) => mixed, @@ -165,10 +219,18 @@ declare class _Collection implements ValueObject { ): V | NSV; findEntry(predicate: (value: V, key: K, iter: this) => mixed): [K, V] | void; - findLastEntry(predicate: (value: V, key: K, iter: this) => mixed): [K, V] | void; + findLastEntry( + predicate: (value: V, key: K, iter: this) => mixed + ): [K, V] | void; - findKey(predicate: (value: V, key: K, iter: this) => mixed, context?: mixed): K | void; - findLastKey(predicate: (value: V, key: K, iter: this) => mixed, context?: mixed): K | void; + findKey( + predicate: (value: V, key: K, iter: this) => mixed, + context?: mixed + ): K | void; + findLastKey( + predicate: (value: V, key: K, iter: this) => mixed, + context?: mixed + ): K | void; keyOf(searchValue: V): K | void; lastKeyOf(searchValue: V): K | void; @@ -188,29 +250,45 @@ declare class _Collection implements ValueObject { isSuperset(iter: Iterable): boolean; } -declare function isImmutable(maybeImmutable: mixed): boolean %checks(maybeImmutable instanceof Collection); -declare function isCollection(maybeCollection: mixed): boolean %checks(maybeCollection instanceof Collection); -declare function isKeyed(maybeKeyed: mixed): boolean %checks(maybeKeyed instanceof KeyedCollection); -declare function isIndexed(maybeIndexed: mixed): boolean %checks(maybeIndexed instanceof IndexedCollection); -declare function isAssociative(maybeAssociative: mixed): boolean %checks( - maybeAssociative instanceof KeyedCollection || - maybeAssociative instanceof IndexedCollection -); -declare function isOrdered(maybeOrdered: mixed): boolean %checks( - maybeOrdered instanceof IndexedCollection || +declare function isImmutable( + maybeImmutable: mixed +): boolean %checks(maybeImmutable instanceof Collection); +declare function isCollection( + maybeCollection: mixed +): boolean %checks(maybeCollection instanceof Collection); +declare function isKeyed( + maybeKeyed: mixed +): boolean %checks(maybeKeyed instanceof KeyedCollection); +declare function isIndexed( + maybeIndexed: mixed +): boolean %checks(maybeIndexed instanceof IndexedCollection); +declare function isAssociative( + maybeAssociative: mixed +): boolean %checks(maybeAssociative instanceof KeyedCollection || + maybeAssociative instanceof IndexedCollection); +declare function isOrdered( + maybeOrdered: mixed +): boolean %checks(maybeOrdered instanceof IndexedCollection || maybeOrdered instanceof OrderedMap || - maybeOrdered instanceof OrderedSet -); + maybeOrdered instanceof OrderedSet); declare function isValueObject(maybeValue: mixed): boolean; declare function isSeq(maybeSeq: any): boolean %checks(maybeSeq instanceof Seq); -declare function isList(maybeList: any): boolean %checks(maybeList instanceof List); +declare function isList(maybeList: any): boolean %checks(maybeList instanceof + List); declare function isMap(maybeMap: any): boolean %checks(maybeMap instanceof Map); -declare function isOrderedMap(maybeOrderedMap: any): boolean %checks(maybeOrderedMap instanceof OrderedMap); -declare function isStack(maybeStack: any): boolean %checks(maybeStack instanceof Stack); +declare function isOrderedMap( + maybeOrderedMap: any +): boolean %checks(maybeOrderedMap instanceof OrderedMap); +declare function isStack(maybeStack: any): boolean %checks(maybeStack instanceof + Stack); declare function isSet(maybeSet: any): boolean %checks(maybeSet instanceof Set); -declare function isOrderedSet(maybeOrderedSet: any): boolean %checks(maybeOrderedSet instanceof OrderedSet); -declare function isRecord(maybeRecord: any): boolean %checks(maybeRecord instanceof Record); +declare function isOrderedSet( + maybeOrderedSet: any +): boolean %checks(maybeOrderedSet instanceof OrderedSet); +declare function isRecord( + maybeRecord: any +): boolean %checks(maybeRecord instanceof Record); declare interface ValueObject { equals(other: mixed): boolean; @@ -230,7 +308,9 @@ declare class Collection extends _Collection { } declare class KeyedCollection extends Collection { - static (values?: Iterable<[K, V]> | PlainObjInput): KeyedCollection; + static ( + values?: Iterable<[K, V]> | PlainObjInput + ): KeyedCollection; toJS(): { [key: string]: mixed }; toJSON(): { [key: string]: V }; @@ -239,7 +319,9 @@ declare class KeyedCollection extends Collection { toSeq(): KeyedSeq; flip(): KeyedCollection; - concat(...iters: Array | PlainObjInput>): KeyedCollection; + concat( + ...iters: Array | PlainObjInput> + ): KeyedCollection; filter(predicate: typeof Boolean): KeyedCollection>; filter( @@ -271,7 +353,7 @@ declare class KeyedCollection extends Collection { flatten(shallow?: boolean): KeyedCollection; } -Collection.Keyed = KeyedCollection +Collection.Keyed = KeyedCollection; declare class IndexedCollection<+T> extends Collection { static (iter?: Iterable): IndexedCollection; @@ -284,16 +366,9 @@ declare class IndexedCollection<+T> extends Collection { fromEntrySeq(): KeyedSeq; interpose(separator: T): this; interleave(...collections: Iterable[]): this; - splice( - index: number, - removeNum: number, - ...values: T[] - ): this; + splice(index: number, removeNum: number, ...values: T[]): this; - zip( - a: Iterable, - ..._: [] - ): IndexedCollection<[T, A]>; + zip(a: Iterable, ..._: []): IndexedCollection<[T, A]>; zip( a: Iterable, b: Iterable, @@ -321,28 +396,25 @@ declare class IndexedCollection<+T> extends Collection { ..._: [] ): IndexedCollection<[T, A, B, C, D, E]>; - zipAll( - a: Iterable, - ..._: [] - ): IndexedCollection<[T|void, A|void]>; + zipAll(a: Iterable, ..._: []): IndexedCollection<[T | void, A | void]>; zipAll( a: Iterable, b: Iterable, ..._: [] - ): IndexedCollection<[T|void, A|void, B|void]>; + ): IndexedCollection<[T | void, A | void, B | void]>; zipAll( a: Iterable, b: Iterable, c: Iterable, ..._: [] - ): IndexedCollection<[T|void, A|void, B|void, C|void]>; + ): IndexedCollection<[T | void, A | void, B | void, C | void]>; zipAll( a: Iterable, b: Iterable, c: Iterable, d: Iterable, ..._: [] - ): IndexedCollection<[T|void, A|void, B|void, C|void, D|void]>; + ): IndexedCollection<[T | void, A | void, B | void, C | void, D | void]>; zipAll( a: Iterable, b: Iterable, @@ -350,7 +422,9 @@ declare class IndexedCollection<+T> extends Collection { d: Iterable, e: Iterable, ..._: [] - ): IndexedCollection<[T|void, A|void, B|void, C|void, D|void, E|void]>; + ): IndexedCollection< + [T | void, A | void, B | void, C | void, D | void, E | void] + >; zipWith( zipper: (value: T, a: A) => R, @@ -456,7 +530,8 @@ declare class SetCollection<+T> extends Collection { flatten(shallow?: boolean): SetCollection; } -declare function isSeq(maybeSeq: mixed): boolean %checks(maybeSeq instanceof Seq); +declare function isSeq(maybeSeq: mixed): boolean %checks(maybeSeq instanceof + Seq); declare class Seq extends _Collection { static Keyed: typeof KeyedSeq; static Indexed: typeof IndexedSeq; @@ -475,12 +550,16 @@ declare class Seq extends _Collection { } declare class KeyedSeq extends Seq mixins KeyedCollection { - static (values?: Iterable<[K, V]> | PlainObjInput): KeyedSeq; + static ( + values?: Iterable<[K, V]> | PlainObjInput + ): KeyedSeq; // Override specialized return types flip(): KeyedSeq; - concat(...iters: Array | PlainObjInput>): KeyedSeq; + concat( + ...iters: Array | PlainObjInput> + ): KeyedSeq; filter(predicate: typeof Boolean): KeyedSeq>; filter( @@ -512,7 +591,9 @@ declare class KeyedSeq extends Seq mixins KeyedCollection { flatten(shallow?: boolean): KeyedSeq; } -declare class IndexedSeq<+T> extends Seq mixins IndexedCollection { +declare class IndexedSeq<+T> + extends Seq + mixins IndexedCollection { static (values?: Iterable): IndexedSeq; static of(...values: T[]): IndexedSeq; @@ -540,15 +621,8 @@ declare class IndexedSeq<+T> extends Seq mixins IndexedCollection flatten(depth?: number): IndexedSeq; flatten(shallow?: boolean): IndexedSeq; - zip( - a: Iterable, - ..._: [] - ): IndexedSeq<[T, A]>; - zip( - a: Iterable, - b: Iterable, - ..._: [] - ): IndexedSeq<[T, A, B]>; + zip(a: Iterable, ..._: []): IndexedSeq<[T, A]>; + zip(a: Iterable, b: Iterable, ..._: []): IndexedSeq<[T, A, B]>; zip( a: Iterable, b: Iterable, @@ -571,28 +645,25 @@ declare class IndexedSeq<+T> extends Seq mixins IndexedCollection ..._: [] ): IndexedSeq<[T, A, B, C, D, E]>; - zipAll( - a: Iterable, - ..._: [] - ): IndexedSeq<[T|void, A|void]>; + zipAll(a: Iterable, ..._: []): IndexedSeq<[T | void, A | void]>; zipAll( a: Iterable, b: Iterable, ..._: [] - ): IndexedSeq<[T|void, A|void, B|void]>; + ): IndexedSeq<[T | void, A | void, B | void]>; zipAll( a: Iterable, b: Iterable, c: Iterable, ..._: [] - ): IndexedSeq<[T|void, A|void, B|void, C|void]>; + ): IndexedSeq<[T | void, A | void, B | void, C | void]>; zipAll( a: Iterable, b: Iterable, c: Iterable, d: Iterable, ..._: [] - ): IndexedSeq<[T|void, A|void, B|void, C|void, D|void]>; + ): IndexedSeq<[T | void, A | void, B | void, C | void, D | void]>; zipAll( a: Iterable, b: Iterable, @@ -600,7 +671,7 @@ declare class IndexedSeq<+T> extends Seq mixins IndexedCollection d: Iterable, e: Iterable, ..._: [] - ): IndexedSeq<[T|void, A|void, B|void, C|void, D|void, E|void]>; + ): IndexedSeq<[T | void, A | void, B | void, C | void, D | void, E | void]>; zipWith( zipper: (value: T, a: A) => R, @@ -672,40 +743,156 @@ declare class UpdatableInCollection { setIn(keyPath: [], value: S): S; setIn(keyPath: [K], value: V): this; setIn, S: $ValOf>(keyPath: [K, K2], value: S): this; - setIn, K3: $KeyOf<$ValOf>, S: $ValOf<$ValOf, K3>>(keyPath: [K, K2, K3], value: S): this; - setIn, K3: $KeyOf<$ValOf>, K4: $KeyOf<$ValOf<$ValOf, K3>>, S: $ValOf<$ValOf<$ValOf, K3>, K4>>(keyPath: [K, K2, K3, K4], value: S): this; - setIn, K3: $KeyOf<$ValOf>, K4: $KeyOf<$ValOf<$ValOf, K3>>, K5: $KeyOf<$ValOf<$ValOf<$ValOf, K3>, K4>>, S: $ValOf<$ValOf<$ValOf<$ValOf, K3>, K4>, K5>>(keyPath: [K, K2, K3, K4, K5], value: S): this; + setIn, K3: $KeyOf<$ValOf>, S: $ValOf<$ValOf, K3>>( + keyPath: [K, K2, K3], + value: S + ): this; + setIn< + K2: $KeyOf, + K3: $KeyOf<$ValOf>, + K4: $KeyOf<$ValOf<$ValOf, K3>>, + S: $ValOf<$ValOf<$ValOf, K3>, K4> + >( + keyPath: [K, K2, K3, K4], + value: S + ): this; + setIn< + K2: $KeyOf, + K3: $KeyOf<$ValOf>, + K4: $KeyOf<$ValOf<$ValOf, K3>>, + K5: $KeyOf<$ValOf<$ValOf<$ValOf, K3>, K4>>, + S: $ValOf<$ValOf<$ValOf<$ValOf, K3>, K4>, K5> + >( + keyPath: [K, K2, K3, K4, K5], + value: S + ): this; deleteIn(keyPath: []): void; deleteIn(keyPath: [K]): this; deleteIn>(keyPath: [K, K2]): this; - deleteIn, K3: $KeyOf<$ValOf>>(keyPath: [K, K2, K3]): this; - deleteIn, K3: $KeyOf<$ValOf>, K4: $KeyOf<$ValOf<$ValOf, K3>>>(keyPath: [K, K2, K3, K4]): this; - deleteIn, K3: $KeyOf<$ValOf>, K4: $KeyOf<$ValOf<$ValOf, K3>>, K5: $KeyOf<$ValOf<$ValOf<$ValOf, K3>, K4>>>(keyPath: [K, K2, K3, K4, K5]): this; + deleteIn, K3: $KeyOf<$ValOf>>( + keyPath: [K, K2, K3] + ): this; + deleteIn< + K2: $KeyOf, + K3: $KeyOf<$ValOf>, + K4: $KeyOf<$ValOf<$ValOf, K3>> + >( + keyPath: [K, K2, K3, K4] + ): this; + deleteIn< + K2: $KeyOf, + K3: $KeyOf<$ValOf>, + K4: $KeyOf<$ValOf<$ValOf, K3>>, + K5: $KeyOf<$ValOf<$ValOf<$ValOf, K3>, K4>> + >( + keyPath: [K, K2, K3, K4, K5] + ): this; removeIn(keyPath: []): void; removeIn(keyPath: [K]): this; removeIn>(keyPath: [K, K2]): this; - removeIn, K3: $KeyOf<$ValOf>>(keyPath: [K, K2, K3]): this; - removeIn, K3: $KeyOf<$ValOf>, K4: $KeyOf<$ValOf<$ValOf, K3>>>(keyPath: [K, K2, K3, K4]): this; - removeIn, K3: $KeyOf<$ValOf>, K4: $KeyOf<$ValOf<$ValOf, K3>>, K5: $KeyOf<$ValOf<$ValOf<$ValOf, K3>, K4>>>(keyPath: [K, K2, K3, K4, K5]): this; + removeIn, K3: $KeyOf<$ValOf>>( + keyPath: [K, K2, K3] + ): this; + removeIn< + K2: $KeyOf, + K3: $KeyOf<$ValOf>, + K4: $KeyOf<$ValOf<$ValOf, K3>> + >( + keyPath: [K, K2, K3, K4] + ): this; + removeIn< + K2: $KeyOf, + K3: $KeyOf<$ValOf>, + K4: $KeyOf<$ValOf<$ValOf, K3>>, + K5: $KeyOf<$ValOf<$ValOf<$ValOf, K3>, K4>> + >( + keyPath: [K, K2, K3, K4, K5] + ): this; updateIn(keyPath: [], notSetValue: mixed, updater: (value: this) => U): U; updateIn(keyPath: [], updater: (value: this) => U): U; updateIn(keyPath: [K], notSetValue: NSV, updater: (value: V) => V): this; updateIn(keyPath: [K], updater: (value: V) => V): this; - updateIn, S: $ValOf>(keyPath: [K, K2], notSetValue: NSV, updater: (value: $ValOf | NSV) => S): this; - updateIn, S: $ValOf>(keyPath: [K, K2], updater: (value: $ValOf) => S): this; - updateIn, K3: $KeyOf<$ValOf>, S: $ValOf<$ValOf, K3>>(keyPath: [K, K2, K3], notSetValue: NSV, updater: (value: $ValOf<$ValOf, K3> | NSV) => S): this; - updateIn, K3: $KeyOf<$ValOf>, S: $ValOf<$ValOf, K3>>(keyPath: [K, K2, K3], updater: (value: $ValOf<$ValOf, K3>) => S): this; - updateIn, K3: $KeyOf<$ValOf>, K4: $KeyOf<$ValOf<$ValOf, K3>>, S: $ValOf<$ValOf<$ValOf, K3>, K4>>(keyPath: [K, K2, K3, K4], notSetValue: NSV, updater: (value: $ValOf<$ValOf<$ValOf, K3>, K4> | NSV) => S): this; - updateIn, K3: $KeyOf<$ValOf>, K4: $KeyOf<$ValOf<$ValOf, K3>>, S: $ValOf<$ValOf<$ValOf, K3>, K4>>(keyPath: [K, K2, K3, K4], updater: (value: $ValOf<$ValOf<$ValOf, K3>, K4>) => S): this; - updateIn, K3: $KeyOf<$ValOf>, K4: $KeyOf<$ValOf<$ValOf, K3>>, K5: $KeyOf<$ValOf<$ValOf<$ValOf, K3>, K4>>, S: $ValOf<$ValOf<$ValOf<$ValOf, K3>, K4>, K5>>(keyPath: [K, K2, K3, K4, K5], notSetValue: NSV, updater: (value: $ValOf<$ValOf<$ValOf<$ValOf, K3>, K4>, K5> | NSV) => S): this; - updateIn, K3: $KeyOf<$ValOf>, K4: $KeyOf<$ValOf<$ValOf, K3>>, K5: $KeyOf<$ValOf<$ValOf<$ValOf, K3>, K4>>, S: $ValOf<$ValOf<$ValOf<$ValOf, K3>, K4>, K5>>(keyPath: [K, K2, K3, K4, K5], updater: (value: $ValOf<$ValOf<$ValOf<$ValOf, K3>, K4>, K5>) => S): this; + updateIn, S: $ValOf>( + keyPath: [K, K2], + notSetValue: NSV, + updater: (value: $ValOf | NSV) => S + ): this; + updateIn, S: $ValOf>( + keyPath: [K, K2], + updater: (value: $ValOf) => S + ): this; + updateIn< + NSV, + K2: $KeyOf, + K3: $KeyOf<$ValOf>, + S: $ValOf<$ValOf, K3> + >( + keyPath: [K, K2, K3], + notSetValue: NSV, + updater: (value: $ValOf<$ValOf, K3> | NSV) => S + ): this; + updateIn< + K2: $KeyOf, + K3: $KeyOf<$ValOf>, + S: $ValOf<$ValOf, K3> + >( + keyPath: [K, K2, K3], + updater: (value: $ValOf<$ValOf, K3>) => S + ): this; + updateIn< + NSV, + K2: $KeyOf, + K3: $KeyOf<$ValOf>, + K4: $KeyOf<$ValOf<$ValOf, K3>>, + S: $ValOf<$ValOf<$ValOf, K3>, K4> + >( + keyPath: [K, K2, K3, K4], + notSetValue: NSV, + updater: (value: $ValOf<$ValOf<$ValOf, K3>, K4> | NSV) => S + ): this; + updateIn< + K2: $KeyOf, + K3: $KeyOf<$ValOf>, + K4: $KeyOf<$ValOf<$ValOf, K3>>, + S: $ValOf<$ValOf<$ValOf, K3>, K4> + >( + keyPath: [K, K2, K3, K4], + updater: (value: $ValOf<$ValOf<$ValOf, K3>, K4>) => S + ): this; + updateIn< + NSV, + K2: $KeyOf, + K3: $KeyOf<$ValOf>, + K4: $KeyOf<$ValOf<$ValOf, K3>>, + K5: $KeyOf<$ValOf<$ValOf<$ValOf, K3>, K4>>, + S: $ValOf<$ValOf<$ValOf<$ValOf, K3>, K4>, K5> + >( + keyPath: [K, K2, K3, K4, K5], + notSetValue: NSV, + updater: ( + value: $ValOf<$ValOf<$ValOf<$ValOf, K3>, K4>, K5> | NSV + ) => S + ): this; + updateIn< + K2: $KeyOf, + K3: $KeyOf<$ValOf>, + K4: $KeyOf<$ValOf<$ValOf, K3>>, + K5: $KeyOf<$ValOf<$ValOf<$ValOf, K3>, K4>>, + S: $ValOf<$ValOf<$ValOf<$ValOf, K3>, K4>, K5> + >( + keyPath: [K, K2, K3, K4, K5], + updater: (value: $ValOf<$ValOf<$ValOf<$ValOf, K3>, K4>, K5>) => S + ): this; } -declare function isList(maybeList: mixed): boolean %checks(maybeList instanceof List); -declare class List<+T> extends IndexedCollection mixins UpdatableInCollection { +declare function isList(maybeList: mixed): boolean %checks(maybeList instanceof + List); +declare class List<+T> + extends IndexedCollection + mixins UpdatableInCollection { static (collection?: Iterable): List; static of(...values: T[]): List; @@ -726,14 +913,21 @@ declare class List<+T> extends IndexedCollection mixins UpdatableInCollection update(updater: (value: this) => U): U; update(index: number, updater: (value: T) => U): List; - update(index: number, notSetValue: U, updater: (value: T) => U): List; + update( + index: number, + notSetValue: U, + updater: (value: T) => U + ): List; merge(...collections: Iterable[]): List; setSize(size: number): this; mergeIn(keyPath: Iterable, ...collections: Iterable[]): this; - mergeDeepIn(keyPath: Iterable, ...collections: Iterable[]): this; + mergeDeepIn( + keyPath: Iterable, + ...collections: Iterable[] + ): this; withMutations(mutator: (mutable: this) => mixed): this; asMutable(): this; @@ -763,15 +957,8 @@ declare class List<+T> extends IndexedCollection mixins UpdatableInCollection flatten(depth?: number): List; flatten(shallow?: boolean): List; - zip( - a: Iterable, - ..._: [] - ): List<[T, A]>; - zip( - a: Iterable, - b: Iterable, - ..._: [] - ): List<[T, A, B]>; + zip(a: Iterable, ..._: []): List<[T, A]>; + zip(a: Iterable, b: Iterable, ..._: []): List<[T, A, B]>; zip( a: Iterable, b: Iterable, @@ -794,28 +981,25 @@ declare class List<+T> extends IndexedCollection mixins UpdatableInCollection ..._: [] ): List<[T, A, B, C, D, E]>; - zipAll( - a: Iterable, - ..._: [] - ): List<[T|void, A|void]>; + zipAll(a: Iterable, ..._: []): List<[T | void, A | void]>; zipAll( a: Iterable, b: Iterable, ..._: [] - ): List<[T|void, A|void, B|void]>; + ): List<[T | void, A | void, B | void]>; zipAll( a: Iterable, b: Iterable, c: Iterable, ..._: [] - ): List<[T|void, A|void, B|void, C|void]>; + ): List<[T | void, A | void, B | void, C | void]>; zipAll( a: Iterable, b: Iterable, c: Iterable, d: Iterable, ..._: [] - ): List<[T|void, A|void, B|void, C|void, D|void]>; + ): List<[T | void, A | void, B | void, C | void, D | void]>; zipAll( a: Iterable, b: Iterable, @@ -823,7 +1007,7 @@ declare class List<+T> extends IndexedCollection mixins UpdatableInCollection d: Iterable, e: Iterable, ..._: [] - ): List<[T|void, A|void, B|void, C|void, D|void, E|void]>; + ): List<[T | void, A | void, B | void, C | void, D | void, E | void]>; zipWith( zipper: (value: T, a: A) => R, @@ -862,8 +1046,11 @@ declare class List<+T> extends IndexedCollection mixins UpdatableInCollection ): List; } -declare function isMap(maybeMap: mixed): boolean %checks(maybeMap instanceof Map); -declare class Map extends KeyedCollection mixins UpdatableInCollection { +declare function isMap(maybeMap: mixed): boolean %checks(maybeMap instanceof + Map); +declare class Map + extends KeyedCollection + mixins UpdatableInCollection { static (values?: Iterable<[K, V]> | PlainObjInput): Map; static isMap: typeof isMap; @@ -880,7 +1067,11 @@ declare class Map extends KeyedCollection mixins UpdatableInCollect update(updater: (value: this) => U): U; update(key: K, updater: (value: V) => V_): Map; - update(key: K, notSetValue: V_, updater: (value: V) => V_): Map; + update( + key: K, + notSetValue: V_, + updater: (value: V) => V_ + ): Map; merge( ...collections: (Iterable<[K_, V_]> | PlainObjInput)[] @@ -951,9 +1142,15 @@ declare class Map extends KeyedCollection mixins UpdatableInCollect flatten(shallow?: boolean): Map; } -declare function isOrderedMap(maybeOrderedMap: mixed): boolean %checks(maybeOrderedMap instanceof OrderedMap); -declare class OrderedMap extends Map mixins UpdatableInCollection { - static (values?: Iterable<[K, V]> | PlainObjInput): OrderedMap; +declare function isOrderedMap( + maybeOrderedMap: mixed +): boolean %checks(maybeOrderedMap instanceof OrderedMap); +declare class OrderedMap + extends Map + mixins UpdatableInCollection { + static ( + values?: Iterable<[K, V]> | PlainObjInput + ): OrderedMap; static isOrderedMap: typeof isOrderedMap; @@ -966,7 +1163,11 @@ declare class OrderedMap extends Map mixins UpdatableInCollection(updater: (value: this) => U): U; update(key: K, updater: (value: V) => V_): OrderedMap; - update(key: K, notSetValue: V_, updater: (value: V) => V_): OrderedMap; + update( + key: K, + notSetValue: V_, + updater: (value: V) => V_ + ): OrderedMap; merge( ...collections: (Iterable<[K_, V_]> | PlainObjInput)[] @@ -1037,12 +1238,15 @@ declare class OrderedMap extends Map mixins UpdatableInCollection; } -declare function isSet(maybeSet: mixed): boolean %checks(maybeSet instanceof Set); +declare function isSet(maybeSet: mixed): boolean %checks(maybeSet instanceof + Set); declare class Set<+T> extends SetCollection { static (values?: Iterable): Set; static of(...values: T[]): Set; - static fromKeys(values: Iterable<[T, mixed]> | PlainObjInput): Set; + static fromKeys( + values: Iterable<[T, mixed]> | PlainObjInput + ): Set; static intersect(sets: Iterable>): Set; static union(sets: Iterable>): Set; @@ -1089,12 +1293,16 @@ declare class Set<+T> extends SetCollection { } // Overrides except for `isOrderedSet` are for specialized return types -declare function isOrderedSet(maybeOrderedSet: mixed): boolean %checks(maybeOrderedSet instanceof OrderedSet); +declare function isOrderedSet( + maybeOrderedSet: mixed +): boolean %checks(maybeOrderedSet instanceof OrderedSet); declare class OrderedSet<+T> extends Set { static (values?: Iterable): OrderedSet; static of(...values: T[]): OrderedSet; - static fromKeys(values: Iterable<[T, mixed]> | PlainObjInput): OrderedSet; + static fromKeys( + values: Iterable<[T, mixed]> | PlainObjInput + ): OrderedSet; static isOrderedSet: typeof isOrderedSet; @@ -1125,15 +1333,8 @@ declare class OrderedSet<+T> extends Set { flatten(depth?: number): OrderedSet; flatten(shallow?: boolean): OrderedSet; - zip( - a: Iterable, - ..._: [] - ): OrderedSet<[T, A]>; - zip( - a: Iterable, - b: Iterable, - ..._: [] - ): OrderedSet<[T, A, B]>; + zip(a: Iterable, ..._: []): OrderedSet<[T, A]>; + zip(a: Iterable, b: Iterable, ..._: []): OrderedSet<[T, A, B]>; zip( a: Iterable, b: Iterable, @@ -1156,28 +1357,25 @@ declare class OrderedSet<+T> extends Set { ..._: [] ): OrderedSet<[T, A, B, C, D, E]>; - zipAll( - a: Iterable, - ..._: [] - ): OrderedSet<[T|void, A|void]>; + zipAll(a: Iterable, ..._: []): OrderedSet<[T | void, A | void]>; zipAll( a: Iterable, b: Iterable, ..._: [] - ): OrderedSet<[T|void, A|void, B|void]>; + ): OrderedSet<[T | void, A | void, B | void]>; zipAll( a: Iterable, b: Iterable, c: Iterable, ..._: [] - ): OrderedSet<[T|void, A|void, B|void, C|void]>; + ): OrderedSet<[T | void, A | void, B | void, C | void]>; zipAll( a: Iterable, b: Iterable, c: Iterable, d: Iterable, ..._: [] - ): OrderedSet<[T|void, A|void, B|void, C|void, D|void]>; + ): OrderedSet<[T | void, A | void, B | void, C | void, D | void]>; zipAll( a: Iterable, b: Iterable, @@ -1185,7 +1383,7 @@ declare class OrderedSet<+T> extends Set { d: Iterable, e: Iterable, ..._: [] - ): OrderedSet<[T|void, A|void, B|void, C|void, D|void, E|void]>; + ): OrderedSet<[T | void, A | void, B | void, C | void, D | void, E | void]>; zipWith( zipper: (value: T, a: A) => R, @@ -1224,7 +1422,9 @@ declare class OrderedSet<+T> extends Set { ): OrderedSet; } -declare function isStack(maybeStack: mixed): boolean %checks(maybeStack instanceof Stack); +declare function isStack( + maybeStack: mixed +): boolean %checks(maybeStack instanceof Stack); declare class Stack<+T> extends IndexedCollection { static (collection?: Iterable): Stack; @@ -1272,15 +1472,8 @@ declare class Stack<+T> extends IndexedCollection { flatten(depth?: number): Stack; flatten(shallow?: boolean): Stack; - zip( - a: Iterable, - ..._: [] - ): Stack<[T, A]>; - zip( - a: Iterable, - b: Iterable, - ..._: [] - ): Stack<[T, A, B]>; + zip(a: Iterable, ..._: []): Stack<[T, A]>; + zip(a: Iterable, b: Iterable, ..._: []): Stack<[T, A, B]>; zip( a: Iterable, b: Iterable, @@ -1303,28 +1496,25 @@ declare class Stack<+T> extends IndexedCollection { ..._: [] ): Stack<[T, A, B, C, D, E]>; - zipAll( - a: Iterable, - ..._: [] - ): Stack<[T|void, A|void]>; + zipAll(a: Iterable, ..._: []): Stack<[T | void, A | void]>; zipAll( a: Iterable, b: Iterable, ..._: [] - ): Stack<[T|void, A|void, B|void]>; + ): Stack<[T | void, A | void, B | void]>; zipAll( a: Iterable, b: Iterable, c: Iterable, ..._: [] - ): Stack<[T|void, A|void, B|void, C|void]>; + ): Stack<[T | void, A | void, B | void, C | void]>; zipAll( a: Iterable, b: Iterable, c: Iterable, d: Iterable, ..._: [] - ): Stack<[T|void, A|void, B|void, C|void, D|void]>; + ): Stack<[T | void, A | void, B | void, C | void, D | void]>; zipAll( a: Iterable, b: Iterable, @@ -1332,7 +1522,7 @@ declare class Stack<+T> extends IndexedCollection { d: Iterable, e: Iterable, ..._: [] - ): Stack<[T|void, A|void, B|void, C|void, D|void, E|void]>; + ): Stack<[T | void, A | void, B | void, C | void, D | void, E | void]>; zipWith( zipper: (value: T, a: A) => R, @@ -1371,7 +1561,11 @@ declare class Stack<+T> extends IndexedCollection { ): Stack; } -declare function Range(start?: number, end?: number, step?: number): IndexedSeq; +declare function Range( + start?: number, + end?: number, + step?: number +): IndexedSeq; declare function Repeat(value: T, times?: number): IndexedSeq; // The type of a Record factory function. @@ -1384,10 +1578,15 @@ type RecordOf = RecordInstance & $ReadOnly; type _RecordValues | T> = R; type RecordValues = _RecordValues<*, R>; -declare function isRecord(maybeRecord: any): boolean %checks(maybeRecord instanceof RecordInstance); +declare function isRecord( + maybeRecord: any +): boolean %checks(maybeRecord instanceof RecordInstance); declare class Record { static (spec: Values, name?: string): typeof RecordInstance; - constructor(spec: Values, name?: string): typeof RecordInstance; + constructor( + spec: Values, + name?: string + ): typeof RecordInstance; static isRecord: typeof isRecord; @@ -1398,7 +1597,7 @@ declare class RecordInstance { static (values?: Iterable<[$Keys, $ValOf]> | $Shape): RecordOf; // Note: a constructor can only create an instance of RecordInstance, // it's encouraged to not use `new` when creating Records. - constructor (values?: Iterable<[$Keys, $ValOf]> | $Shape): void; + constructor(values?: Iterable<[$Keys, $ValOf]> | $Shape): void; size: number; @@ -1411,18 +1610,55 @@ declare class RecordInstance { getIn(keyPath: [], notSetValue?: mixed): this & $ReadOnly; getIn>(keyPath: [K], notSetValue?: mixed): $ElementType; - getIn, K2: $KeyOf<$ValOf>>(keyPath: [K, K2], notSetValue: NSV): $ValOf<$ValOf, K2> | NSV; - getIn, K2: $KeyOf<$ValOf>, K3: $KeyOf<$ValOf<$ValOf, K2>>>(keyPath: [K, K2, K3], notSetValue: NSV): $ValOf<$ValOf<$ValOf, K2>, K3> | NSV; - getIn, K2: $KeyOf<$ValOf>, K3: $KeyOf<$ValOf<$ValOf, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>>>(keyPath: [K, K2, K3, K4], notSetValue: NSV): $ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4> | NSV; - getIn, K2: $KeyOf<$ValOf>, K3: $KeyOf<$ValOf<$ValOf, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>>, K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>>>(keyPath: [K, K2, K3, K4, K5], notSetValue: NSV): $ValOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>, K5> | NSV; + getIn, K2: $KeyOf<$ValOf>>( + keyPath: [K, K2], + notSetValue: NSV + ): $ValOf<$ValOf, K2> | NSV; + getIn< + NSV, + K: $Keys, + K2: $KeyOf<$ValOf>, + K3: $KeyOf<$ValOf<$ValOf, K2>> + >( + keyPath: [K, K2, K3], + notSetValue: NSV + ): $ValOf<$ValOf<$ValOf, K2>, K3> | NSV; + getIn< + NSV, + K: $Keys, + K2: $KeyOf<$ValOf>, + K3: $KeyOf<$ValOf<$ValOf, K2>>, + K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>> + >( + keyPath: [K, K2, K3, K4], + notSetValue: NSV + ): $ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4> | NSV; + getIn< + NSV, + K: $Keys, + K2: $KeyOf<$ValOf>, + K3: $KeyOf<$ValOf<$ValOf, K2>>, + K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>>, + K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>> + >( + keyPath: [K, K2, K3, K4, K5], + notSetValue: NSV + ): $ValOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>, K5> | NSV; equals(other: any): boolean; hashCode(): number; set>(key: K, value: $ElementType): this & $ReadOnly; - update>(key: K, updater: (value: $ElementType) => $ElementType): this & $ReadOnly; - merge(...collections: Array, $ValOf]> | $Shape>): this & $ReadOnly; - mergeDeep(...collections: Array, $ValOf]> | $Shape>): this & $ReadOnly; + update>( + key: K, + updater: (value: $ElementType) => $ElementType + ): this & $ReadOnly; + merge( + ...collections: Array, $ValOf]> | $Shape> + ): this & $ReadOnly; + mergeDeep( + ...collections: Array, $ValOf]> | $Shape> + ): this & $ReadOnly; mergeWith( merger: (oldVal: $ValOf, newVal: $ValOf, key: $Keys) => $ValOf, @@ -1438,41 +1674,215 @@ declare class RecordInstance { clear(): this & $ReadOnly; setIn(keyPath: [], value: S): S; - setIn, S: $ValOf>(keyPath: [K], value: S): this & $ReadOnly; - setIn, K2: $KeyOf<$ValOf>, S: $ValOf<$ValOf, K2>>(keyPath: [K, K2], value: S): this & $ReadOnly; - setIn, K2: $KeyOf<$ValOf>, K3: $KeyOf<$ValOf<$ValOf, K2>>, S: $ValOf<$ValOf<$ValOf, K2>, K3>>(keyPath: [K, K2, K3], value: S): this & $ReadOnly; - setIn, K2: $KeyOf<$ValOf>, K3: $KeyOf<$ValOf<$ValOf, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>>, S: $ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>>(keyPath: [K, K2, K3, K4], value: S): this & $ReadOnly; - setIn, K2: $KeyOf<$ValOf>, K3: $KeyOf<$ValOf<$ValOf, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>>, K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>>, S: $ValOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>, K5>>(keyPath: [K, K2, K3, K4, K5], value: S): this & $ReadOnly; + setIn, S: $ValOf>( + keyPath: [K], + value: S + ): this & $ReadOnly; + setIn, K2: $KeyOf<$ValOf>, S: $ValOf<$ValOf, K2>>( + keyPath: [K, K2], + value: S + ): this & $ReadOnly; + setIn< + K: $Keys, + K2: $KeyOf<$ValOf>, + K3: $KeyOf<$ValOf<$ValOf, K2>>, + S: $ValOf<$ValOf<$ValOf, K2>, K3> + >( + keyPath: [K, K2, K3], + value: S + ): this & $ReadOnly; + setIn< + K: $Keys, + K2: $KeyOf<$ValOf>, + K3: $KeyOf<$ValOf<$ValOf, K2>>, + K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>>, + S: $ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4> + >( + keyPath: [K, K2, K3, K4], + value: S + ): this & $ReadOnly; + setIn< + K: $Keys, + K2: $KeyOf<$ValOf>, + K3: $KeyOf<$ValOf<$ValOf, K2>>, + K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>>, + K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>>, + S: $ValOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>, K5> + >( + keyPath: [K, K2, K3, K4, K5], + value: S + ): this & $ReadOnly; deleteIn(keyPath: []): void; deleteIn>(keyPath: [K]): this & $ReadOnly; - deleteIn, K2: $KeyOf<$ValOf>>(keyPath: [K, K2]): this & $ReadOnly; - deleteIn, K2: $KeyOf<$ValOf>, K3: $KeyOf<$ValOf<$ValOf, K2>>>(keyPath: [K, K2, K3]): this & $ReadOnly; - deleteIn, K2: $KeyOf<$ValOf>, K3: $KeyOf<$ValOf<$ValOf, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>>>(keyPath: [K, K2, K3, K4]): this & $ReadOnly; - deleteIn, K2: $KeyOf<$ValOf>, K3: $KeyOf<$ValOf<$ValOf, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>>, K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>>>(keyPath: [K, K2, K3, K4, K5]): this & $ReadOnly; + deleteIn, K2: $KeyOf<$ValOf>>( + keyPath: [K, K2] + ): this & $ReadOnly; + deleteIn< + K: $Keys, + K2: $KeyOf<$ValOf>, + K3: $KeyOf<$ValOf<$ValOf, K2>> + >( + keyPath: [K, K2, K3] + ): this & $ReadOnly; + deleteIn< + K: $Keys, + K2: $KeyOf<$ValOf>, + K3: $KeyOf<$ValOf<$ValOf, K2>>, + K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>> + >( + keyPath: [K, K2, K3, K4] + ): this & $ReadOnly; + deleteIn< + K: $Keys, + K2: $KeyOf<$ValOf>, + K3: $KeyOf<$ValOf<$ValOf, K2>>, + K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>>, + K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>> + >( + keyPath: [K, K2, K3, K4, K5] + ): this & $ReadOnly; removeIn(keyPath: []): void; removeIn>(keyPath: [K]): this & $ReadOnly; - removeIn, K2: $KeyOf<$ValOf>>(keyPath: [K, K2]): this & $ReadOnly; - removeIn, K2: $KeyOf<$ValOf>, K3: $KeyOf<$ValOf<$ValOf, K2>>>(keyPath: [K, K2, K3]): this & $ReadOnly; - removeIn, K2: $KeyOf<$ValOf>, K3: $KeyOf<$ValOf<$ValOf, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>>>(keyPath: [K, K2, K3, K4]): this & $ReadOnly; - removeIn, K2: $KeyOf<$ValOf>, K3: $KeyOf<$ValOf<$ValOf, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>>, K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>>>(keyPath: [K, K2, K3, K4, K5]): this & $ReadOnly; + removeIn, K2: $KeyOf<$ValOf>>( + keyPath: [K, K2] + ): this & $ReadOnly; + removeIn< + K: $Keys, + K2: $KeyOf<$ValOf>, + K3: $KeyOf<$ValOf<$ValOf, K2>> + >( + keyPath: [K, K2, K3] + ): this & $ReadOnly; + removeIn< + K: $Keys, + K2: $KeyOf<$ValOf>, + K3: $KeyOf<$ValOf<$ValOf, K2>>, + K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>> + >( + keyPath: [K, K2, K3, K4] + ): this & $ReadOnly; + removeIn< + K: $Keys, + K2: $KeyOf<$ValOf>, + K3: $KeyOf<$ValOf<$ValOf, K2>>, + K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>>, + K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>> + >( + keyPath: [K, K2, K3, K4, K5] + ): this & $ReadOnly; - updateIn(keyPath: [], notSetValue: mixed, updater: (value: this & T) => U): U; + updateIn( + keyPath: [], + notSetValue: mixed, + updater: (value: this & T) => U + ): U; updateIn(keyPath: [], updater: (value: this & T) => U): U; - updateIn, S: $ValOf>(keyPath: [K], notSetValue: NSV, updater: (value: $ValOf) => S): this & $ReadOnly; - updateIn, S: $ValOf>(keyPath: [K], updater: (value: $ValOf) => S): this & $ReadOnly; - updateIn, K2: $KeyOf<$ValOf>, S: $ValOf<$ValOf, K2>>(keyPath: [K, K2], notSetValue: NSV, updater: (value: $ValOf<$ValOf, K2> | NSV) => S): this & $ReadOnly; - updateIn, K2: $KeyOf<$ValOf>, S: $ValOf<$ValOf, K2>>(keyPath: [K, K2], updater: (value: $ValOf<$ValOf, K2>) => S): this & $ReadOnly; - updateIn, K2: $KeyOf<$ValOf>, K3: $KeyOf<$ValOf<$ValOf, K2>>, S: $ValOf<$ValOf<$ValOf, K2>, K3>>(keyPath: [K, K2, K3], notSetValue: NSV, updater: (value: $ValOf<$ValOf<$ValOf, K2>, K3> | NSV) => S): this & $ReadOnly; - updateIn, K2: $KeyOf<$ValOf>, K3: $KeyOf<$ValOf<$ValOf, K2>>, S: $ValOf<$ValOf<$ValOf, K2>, K3>>(keyPath: [K, K2, K3], updater: (value: $ValOf<$ValOf<$ValOf, K2>, K3>) => S): this & $ReadOnly; - updateIn, K2: $KeyOf<$ValOf>, K3: $KeyOf<$ValOf<$ValOf, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>>, S: $ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>>(keyPath: [K, K2, K3, K4], notSetValue: NSV, updater: (value: $ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4> | NSV) => S): this & $ReadOnly; - updateIn, K2: $KeyOf<$ValOf>, K3: $KeyOf<$ValOf<$ValOf, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>>, S: $ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>>(keyPath: [K, K2, K3, K4], updater: (value: $ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>) => S): this & $ReadOnly; - updateIn, K2: $KeyOf<$ValOf>, K3: $KeyOf<$ValOf<$ValOf, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>>, K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>>, S: $ValOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>, K5>>(keyPath: [K, K2, K3, K4, K5], notSetValue: NSV, updater: (value: $ValOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>, K5> | NSV) => S): this & $ReadOnly; - updateIn, K2: $KeyOf<$ValOf>, K3: $KeyOf<$ValOf<$ValOf, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>>, K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>>, S: $ValOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>, K5>>(keyPath: [K, K2, K3, K4, K5], updater: (value: $ValOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>, K5>) => S): this & $ReadOnly; - - mergeIn(keyPath: Iterable, ...collections: Array): this & $ReadOnly; - mergeDeepIn(keyPath: Iterable, ...collections: Array): this & $ReadOnly; + updateIn, S: $ValOf>( + keyPath: [K], + notSetValue: NSV, + updater: (value: $ValOf) => S + ): this & $ReadOnly; + updateIn, S: $ValOf>( + keyPath: [K], + updater: (value: $ValOf) => S + ): this & $ReadOnly; + updateIn< + NSV, + K: $Keys, + K2: $KeyOf<$ValOf>, + S: $ValOf<$ValOf, K2> + >( + keyPath: [K, K2], + notSetValue: NSV, + updater: (value: $ValOf<$ValOf, K2> | NSV) => S + ): this & $ReadOnly; + updateIn, K2: $KeyOf<$ValOf>, S: $ValOf<$ValOf, K2>>( + keyPath: [K, K2], + updater: (value: $ValOf<$ValOf, K2>) => S + ): this & $ReadOnly; + updateIn< + NSV, + K: $Keys, + K2: $KeyOf<$ValOf>, + K3: $KeyOf<$ValOf<$ValOf, K2>>, + S: $ValOf<$ValOf<$ValOf, K2>, K3> + >( + keyPath: [K, K2, K3], + notSetValue: NSV, + updater: (value: $ValOf<$ValOf<$ValOf, K2>, K3> | NSV) => S + ): this & $ReadOnly; + updateIn< + K: $Keys, + K2: $KeyOf<$ValOf>, + K3: $KeyOf<$ValOf<$ValOf, K2>>, + S: $ValOf<$ValOf<$ValOf, K2>, K3> + >( + keyPath: [K, K2, K3], + updater: (value: $ValOf<$ValOf<$ValOf, K2>, K3>) => S + ): this & $ReadOnly; + updateIn< + NSV, + K: $Keys, + K2: $KeyOf<$ValOf>, + K3: $KeyOf<$ValOf<$ValOf, K2>>, + K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>>, + S: $ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4> + >( + keyPath: [K, K2, K3, K4], + notSetValue: NSV, + updater: ( + value: $ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4> | NSV + ) => S + ): this & $ReadOnly; + updateIn< + K: $Keys, + K2: $KeyOf<$ValOf>, + K3: $KeyOf<$ValOf<$ValOf, K2>>, + K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>>, + S: $ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4> + >( + keyPath: [K, K2, K3, K4], + updater: (value: $ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>) => S + ): this & $ReadOnly; + updateIn< + NSV, + K: $Keys, + K2: $KeyOf<$ValOf>, + K3: $KeyOf<$ValOf<$ValOf, K2>>, + K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>>, + K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>>, + S: $ValOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>, K5> + >( + keyPath: [K, K2, K3, K4, K5], + notSetValue: NSV, + updater: ( + value: $ValOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>, K5> | NSV + ) => S + ): this & $ReadOnly; + updateIn< + K: $Keys, + K2: $KeyOf<$ValOf>, + K3: $KeyOf<$ValOf<$ValOf, K2>>, + K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>>, + K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>>, + S: $ValOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>, K5> + >( + keyPath: [K, K2, K3, K4, K5], + updater: ( + value: $ValOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>, K5> + ) => S + ): this & $ReadOnly; + + mergeIn( + keyPath: Iterable, + ...collections: Array + ): this & $ReadOnly; + mergeDeepIn( + keyPath: Iterable, + ...collections: Array + ): this & $ReadOnly; toSeq(): KeyedSeq<$Keys, any>; @@ -1500,74 +1910,341 @@ declare function fromJS( declare function is(first: mixed, second: mixed): boolean; declare function hash(value: mixed): number; -declare function get>(collection: C, key: K, notSetValue: mixed): $ValOf; -declare function get, NSV>(collection: C, key: K, notSetValue: NSV): $ValOf | NSV; +declare function get>( + collection: C, + key: K, + notSetValue: mixed +): $ValOf; +declare function get, NSV>( + collection: C, + key: K, + notSetValue: NSV +): $ValOf | NSV; declare function has(collection: Object, key: mixed): boolean; declare function remove(collection: C, key: $KeyOf): C; -declare function set, V: $ValOf>(collection: C, key: K, value: V): C; -declare function update, V: $ValOf, NSV>(collection: C, key: K, notSetValue: NSV, updater: ($ValOf | NSV) => V): C; -declare function update, V: $ValOf>(collection: C, key: K, updater: ($ValOf) => V): C; +declare function set, V: $ValOf>( + collection: C, + key: K, + value: V +): C; +declare function update, V: $ValOf, NSV>( + collection: C, + key: K, + notSetValue: NSV, + updater: ($ValOf | NSV) => V +): C; +declare function update, V: $ValOf>( + collection: C, + key: K, + updater: ($ValOf) => V +): C; declare function getIn(collection: C, keyPath: [], notSetValue?: mixed): C; -declare function getIn, NSV>(collection: C, keyPath: [K], notSetValue: NSV): $ValOf | NSV; -declare function getIn, K2: $KeyOf<$ValOf>, NSV>(collection: C, keyPath: [K, K2], notSetValue: NSV): $ValOf<$ValOf, K2> | NSV; -declare function getIn, K2: $KeyOf<$ValOf>, K3: $KeyOf<$ValOf<$ValOf, K2>>, NSV>(collection: C, keyPath: [K, K2, K3], notSetValue: NSV): $ValOf<$ValOf<$ValOf, K2>, K3> | NSV; -declare function getIn, K2: $KeyOf<$ValOf>, K3: $KeyOf<$ValOf<$ValOf, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>>, NSV>(collection: C, keyPath: [K, K2, K3, K4], notSetValue: NSV): $ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4> | NSV; -declare function getIn, K2: $KeyOf<$ValOf>, K3: $KeyOf<$ValOf<$ValOf, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>>, K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>>, NSV>(collection: C, keyPath: [K, K2, K3, K4, K5], notSetValue: NSV): $ValOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>, K5> | NSV; +declare function getIn, NSV>( + collection: C, + keyPath: [K], + notSetValue: NSV +): $ValOf | NSV; +declare function getIn, K2: $KeyOf<$ValOf>, NSV>( + collection: C, + keyPath: [K, K2], + notSetValue: NSV +): $ValOf<$ValOf, K2> | NSV; +declare function getIn< + C, + K: $KeyOf, + K2: $KeyOf<$ValOf>, + K3: $KeyOf<$ValOf<$ValOf, K2>>, + NSV +>( + collection: C, + keyPath: [K, K2, K3], + notSetValue: NSV +): $ValOf<$ValOf<$ValOf, K2>, K3> | NSV; +declare function getIn< + C, + K: $KeyOf, + K2: $KeyOf<$ValOf>, + K3: $KeyOf<$ValOf<$ValOf, K2>>, + K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>>, + NSV +>( + collection: C, + keyPath: [K, K2, K3, K4], + notSetValue: NSV +): $ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4> | NSV; +declare function getIn< + C, + K: $KeyOf, + K2: $KeyOf<$ValOf>, + K3: $KeyOf<$ValOf<$ValOf, K2>>, + K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>>, + K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>>, + NSV +>( + collection: C, + keyPath: [K, K2, K3, K4, K5], + notSetValue: NSV +): $ValOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>, K5> | NSV; declare function hasIn(collection: Object, keyPath: Iterable): boolean; declare function removeIn(collection: C, keyPath: []): void; declare function removeIn>(collection: C, keyPath: [K]): C; -declare function removeIn, K2: $KeyOf<$ValOf>>(collection: C, keyPath: [K, K2]): C; -declare function removeIn, K2: $KeyOf<$ValOf>, K3: $KeyOf<$ValOf<$ValOf, K2>>>(collection: C, keyPath: [K, K2, K3]): C; -declare function removeIn, K2: $KeyOf<$ValOf>, K3: $KeyOf<$ValOf<$ValOf, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>>>(collection: C, keyPath: [K, K2, K3, K4]): C; -declare function removeIn, K2: $KeyOf<$ValOf>, K3: $KeyOf<$ValOf<$ValOf, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>>, K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>>>(collection: C, keyPath: [K, K2, K3, K4, K5]): C; +declare function removeIn, K2: $KeyOf<$ValOf>>( + collection: C, + keyPath: [K, K2] +): C; +declare function removeIn< + C, + K: $KeyOf, + K2: $KeyOf<$ValOf>, + K3: $KeyOf<$ValOf<$ValOf, K2>> +>( + collection: C, + keyPath: [K, K2, K3] +): C; +declare function removeIn< + C, + K: $KeyOf, + K2: $KeyOf<$ValOf>, + K3: $KeyOf<$ValOf<$ValOf, K2>>, + K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>> +>( + collection: C, + keyPath: [K, K2, K3, K4] +): C; +declare function removeIn< + C, + K: $KeyOf, + K2: $KeyOf<$ValOf>, + K3: $KeyOf<$ValOf<$ValOf, K2>>, + K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>>, + K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>> +>( + collection: C, + keyPath: [K, K2, K3, K4, K5] +): C; declare function setIn(collection: Object, keyPath: [], value: S): S; -declare function setIn, S: $ValOf>(collection: C, keyPath: [K], value: S): C; -declare function setIn, K2: $KeyOf<$ValOf>, S: $ValOf<$ValOf, K2>>(collection: C, keyPath: [K, K2], value: S): C; -declare function setIn, K2: $KeyOf<$ValOf>, K3: $KeyOf<$ValOf<$ValOf, K2>>, S: $ValOf<$ValOf<$ValOf, K2>, K3>>(collection: C, keyPath: [K, K2, K3], value: S): C; -declare function setIn, K2: $KeyOf<$ValOf>, K3: $KeyOf<$ValOf<$ValOf, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>>, S: $ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>>(collection: C, keyPath: [K, K2, K3, K4], value: S): C; -declare function setIn, K2: $KeyOf<$ValOf>, K3: $KeyOf<$ValOf<$ValOf, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>>, K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>>, S: $ValOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>, K5>>(collection: C, keyPath: [K, K2, K3, K4, K5], value: S): C; - -declare function updateIn(collection: C, keyPath: [], notSetValue: mixed, updater: (value: C) => S): S; -declare function updateIn(collection: C, keyPath: [], updater: (value: C) => S): S; -declare function updateIn, S: $ValOf, NSV>(collection: C, keyPath: [K], notSetValue: NSV, updater: (value: $ValOf | NSV) => S): C; -declare function updateIn, S: $ValOf>(collection: C, keyPath: [K], updater: (value: $ValOf) => S): C; -declare function updateIn, K2: $KeyOf<$ValOf>, S: $ValOf<$ValOf, K2>, NSV>(collection: C, keyPath: [K, K2], notSetValue: NSV, updater: (value: $ValOf<$ValOf, K2> | NSV) => S): C; -declare function updateIn, K2: $KeyOf<$ValOf>, S: $ValOf<$ValOf, K2>>(collection: C, keyPath: [K, K2], updater: (value: $ValOf<$ValOf, K2>) => S): C; -declare function updateIn, K2: $KeyOf<$ValOf>, K3: $KeyOf<$ValOf<$ValOf, K2>>, S: $ValOf<$ValOf<$ValOf, K2>, K3>, NSV>(collection: C, keyPath: [K, K2, K3], notSetValue: NSV, updater: (value: $ValOf<$ValOf<$ValOf, K2>, K3> | NSV) => S): C; -declare function updateIn, K2: $KeyOf<$ValOf>, K3: $KeyOf<$ValOf<$ValOf, K2>>, S: $ValOf<$ValOf<$ValOf, K2>, K3>>(collection: C, keyPath: [K, K2, K3], updater: (value: $ValOf<$ValOf<$ValOf, K2>, K3>) => S): C; -declare function updateIn, K2: $KeyOf<$ValOf>, K3: $KeyOf<$ValOf<$ValOf, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>>, S: $ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>, NSV>(collection: C, keyPath: [K, K2, K3, K4], notSetValue: NSV, updater: (value: $ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4> | NSV) => S): C; -declare function updateIn, K2: $KeyOf<$ValOf>, K3: $KeyOf<$ValOf<$ValOf, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>>, S: $ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>>(collection: C, keyPath: [K, K2, K3, K4], updater: (value: $ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>) => S): C; -declare function updateIn, K2: $KeyOf<$ValOf>, K3: $KeyOf<$ValOf<$ValOf, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>>, K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>>, S: $ValOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>, K5>, NSV>(collection: C, keyPath: [K, K2, K3, K4, K5], notSetValue: NSV, updater: (value: $ValOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>, K5> | NSV) => S): C; -declare function updateIn, K2: $KeyOf<$ValOf>, K3: $KeyOf<$ValOf<$ValOf, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>>, K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>>, S: $ValOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>, K5>>(collection: C, keyPath: [K, K2, K3, K4, K5], updater: (value: $ValOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>, K5>) => S): C; +declare function setIn, S: $ValOf>( + collection: C, + keyPath: [K], + value: S +): C; +declare function setIn< + C, + K: $KeyOf, + K2: $KeyOf<$ValOf>, + S: $ValOf<$ValOf, K2> +>( + collection: C, + keyPath: [K, K2], + value: S +): C; +declare function setIn< + C, + K: $KeyOf, + K2: $KeyOf<$ValOf>, + K3: $KeyOf<$ValOf<$ValOf, K2>>, + S: $ValOf<$ValOf<$ValOf, K2>, K3> +>( + collection: C, + keyPath: [K, K2, K3], + value: S +): C; +declare function setIn< + C, + K: $KeyOf, + K2: $KeyOf<$ValOf>, + K3: $KeyOf<$ValOf<$ValOf, K2>>, + K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>>, + S: $ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4> +>( + collection: C, + keyPath: [K, K2, K3, K4], + value: S +): C; +declare function setIn< + C, + K: $KeyOf, + K2: $KeyOf<$ValOf>, + K3: $KeyOf<$ValOf<$ValOf, K2>>, + K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>>, + K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>>, + S: $ValOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>, K5> +>( + collection: C, + keyPath: [K, K2, K3, K4, K5], + value: S +): C; + +declare function updateIn( + collection: C, + keyPath: [], + notSetValue: mixed, + updater: (value: C) => S +): S; +declare function updateIn( + collection: C, + keyPath: [], + updater: (value: C) => S +): S; +declare function updateIn, S: $ValOf, NSV>( + collection: C, + keyPath: [K], + notSetValue: NSV, + updater: (value: $ValOf | NSV) => S +): C; +declare function updateIn, S: $ValOf>( + collection: C, + keyPath: [K], + updater: (value: $ValOf) => S +): C; +declare function updateIn< + C, + K: $KeyOf, + K2: $KeyOf<$ValOf>, + S: $ValOf<$ValOf, K2>, + NSV +>( + collection: C, + keyPath: [K, K2], + notSetValue: NSV, + updater: (value: $ValOf<$ValOf, K2> | NSV) => S +): C; +declare function updateIn< + C, + K: $KeyOf, + K2: $KeyOf<$ValOf>, + S: $ValOf<$ValOf, K2> +>( + collection: C, + keyPath: [K, K2], + updater: (value: $ValOf<$ValOf, K2>) => S +): C; +declare function updateIn< + C, + K: $KeyOf, + K2: $KeyOf<$ValOf>, + K3: $KeyOf<$ValOf<$ValOf, K2>>, + S: $ValOf<$ValOf<$ValOf, K2>, K3>, + NSV +>( + collection: C, + keyPath: [K, K2, K3], + notSetValue: NSV, + updater: (value: $ValOf<$ValOf<$ValOf, K2>, K3> | NSV) => S +): C; +declare function updateIn< + C, + K: $KeyOf, + K2: $KeyOf<$ValOf>, + K3: $KeyOf<$ValOf<$ValOf, K2>>, + S: $ValOf<$ValOf<$ValOf, K2>, K3> +>( + collection: C, + keyPath: [K, K2, K3], + updater: (value: $ValOf<$ValOf<$ValOf, K2>, K3>) => S +): C; +declare function updateIn< + C, + K: $KeyOf, + K2: $KeyOf<$ValOf>, + K3: $KeyOf<$ValOf<$ValOf, K2>>, + K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>>, + S: $ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>, + NSV +>( + collection: C, + keyPath: [K, K2, K3, K4], + notSetValue: NSV, + updater: (value: $ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4> | NSV) => S +): C; +declare function updateIn< + C, + K: $KeyOf, + K2: $KeyOf<$ValOf>, + K3: $KeyOf<$ValOf<$ValOf, K2>>, + K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>>, + S: $ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4> +>( + collection: C, + keyPath: [K, K2, K3, K4], + updater: (value: $ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>) => S +): C; +declare function updateIn< + C, + K: $KeyOf, + K2: $KeyOf<$ValOf>, + K3: $KeyOf<$ValOf<$ValOf, K2>>, + K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>>, + K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>>, + S: $ValOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>, K5>, + NSV +>( + collection: C, + keyPath: [K, K2, K3, K4, K5], + notSetValue: NSV, + updater: ( + value: $ValOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>, K5> | NSV + ) => S +): C; +declare function updateIn< + C, + K: $KeyOf, + K2: $KeyOf<$ValOf>, + K3: $KeyOf<$ValOf<$ValOf, K2>>, + K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>>, + K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>>, + S: $ValOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>, K5> +>( + collection: C, + keyPath: [K, K2, K3, K4, K5], + updater: ( + value: $ValOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>, K5> + ) => S +): C; declare function merge( collection: C, - ...collections: Array<$IterableOf | $Shape> | PlainObjInput<$KeyOf, $ValOf>> + ...collections: Array< + | $IterableOf + | $Shape> + | PlainObjInput<$KeyOf, $ValOf> + > ): C; declare function mergeWith( merger: (oldVal: $ValOf, newVal: $ValOf, key: $KeyOf) => $ValOf, collection: C, - ...collections: Array<$IterableOf | $Shape> | PlainObjInput<$KeyOf, $ValOf>> + ...collections: Array< + | $IterableOf + | $Shape> + | PlainObjInput<$KeyOf, $ValOf> + > ): C; declare function mergeDeep( collection: C, - ...collections: Array<$IterableOf | $Shape> | PlainObjInput<$KeyOf, $ValOf>> + ...collections: Array< + | $IterableOf + | $Shape> + | PlainObjInput<$KeyOf, $ValOf> + > ): C; declare function mergeDeepWith( merger: (oldVal: any, newVal: any, key: any) => mixed, collection: C, - ...collections: Array<$IterableOf | $Shape> | PlainObjInput<$KeyOf, $ValOf>> + ...collections: Array< + | $IterableOf + | $Shape> + | PlainObjInput<$KeyOf, $ValOf> + > ): C; export { Collection, Seq, - List, Map, OrderedMap, @@ -1577,11 +2254,9 @@ export { Record, Set, Stack, - fromJS, is, hash, - isImmutable, isCollection, isKeyed, @@ -1590,7 +2265,6 @@ export { isOrdered, isRecord, isValueObject, - get, has, remove, @@ -1605,7 +2279,7 @@ export { mergeWith, mergeDeep, mergeDeepWith, -} +}; export default { Collection, @@ -1648,7 +2322,7 @@ export default { mergeWith, mergeDeep, mergeDeepWith, -} +}; export type { KeyedCollection, @@ -1661,7 +2335,6 @@ export type { RecordOf, RecordInstance, ValueObject, - $KeyOf, $ValOf, -} +}; diff --git a/dist/immutable.min.js b/dist/immutable.min.js new file mode 100644 index 0000000000..a36c8ac152 --- /dev/null +++ b/dist/immutable.min.js @@ -0,0 +1,55 @@ +/** + * MIT License + * + * Copyright (c) 2014-present, Lee Byron and other contributors. + * + * 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: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).Immutable={})}(this,function(t){"use strict";var e="delete",d=5,l=1<>>0;if(""+r!==e||4294967295==r)return NaN;e=r}return e<0?c(t)+e:e}function r(){return!0}function p(t,e,r){return(0===t&&!i(t)||void 0!==r&&t<=-r)&&(void 0===e||void 0!==r&&r<=e)}function y(t,e){return n(t,e,0)}function w(t,e){return n(t,e,e)}function n(t,e,r){return void 0===t?r:i(t)?e===1/0?e:0|Math.max(0,e+t):void 0===e||e===t?t:0|Math.min(e,t)}function i(t){return t<0||0===t&&1/t==-1/0}var o="@@__IMMUTABLE_ITERABLE__@@";function f(t){return!(!t||!t[o])}var s="@@__IMMUTABLE_KEYED__@@";function a(t){return!(!t||!t[s])}var z="@@__IMMUTABLE_INDEXED__@@";function S(t){return!(!t||!t[z])}function b(t){return a(t)||S(t)}function I(t){return f(t)?t:F(t)}var O=function(t){function e(t){return a(t)?t:G(t)}return e.__proto__=t,(e.prototype=Object.create(t.prototype)).constructor=e}(I),E=function(t){function e(t){return S(t)?t:Z(t)}return e.__proto__=t,(e.prototype=Object.create(t.prototype)).constructor=e}(I),M=function(t){function e(t){return f(t)&&!b(t)?t:$(t)}return e.__proto__=t,(e.prototype=Object.create(t.prototype)).constructor=e}(I);I.Keyed=O,I.Indexed=E,I.Set=M;var j="@@__IMMUTABLE_SEQ__@@";function q(t){return!(!t||!t[j])}var D="@@__IMMUTABLE_RECORD__@@";function x(t){return!(!t||!t[D])}function A(t){return f(t)||x(t)}var k="@@__IMMUTABLE_ORDERED__@@";function R(t){return!(!t||!t[k])}var U=0,K=1,T=2,C="function"==typeof Symbol&&Symbol.iterator,L="@@iterator",B=C||L,W=function(t){this.next=t};function P(t,e,r,n){r=0===t?e:1===t?r:[e,r];return n?n.value=r:n={value:r,done:!1},n}function N(){return{value:void 0,done:!0}}function H(t){return Y(t)}function J( +t){return t&&"function"==typeof t.next}function V(t){var e=Y(t);return e&&e.call(t)}function Y(t){t=t&&(C&&t[C]||t[L]);if("function"==typeof t)return t}W.prototype.toString=function(){return"[Iterator]"},W.KEYS=U,W.VALUES=K,W.ENTRIES=T,W.prototype.inspect=W.prototype.toSource=function(){return""+this},W.prototype[B]=function(){return this};var Q=Object.prototype.hasOwnProperty;function X(t){return Array.isArray(t)||"string"==typeof t||t&&"object"==typeof t&&Number.isInteger(t.length)&&0<=t.length&&(0===t.length?1===Object.keys(t).length:t.hasOwnProperty(t.length-1))}var F=function(t){function e(t){return null==t?it():A(t)?t.toSeq():function(t){var e=st(t);if(e)return e;if("object"!=typeof t)throw new TypeError("Expected Array or collection object of values, or keyed object: "+t);return new et(t)}(t)}return e.__proto__=t,((e.prototype=Object.create(t.prototype)).constructor=e).prototype.toSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq {","}")},e.prototype.cacheResult=function(){return!this._cache&&this.__iterateUncached&&(this._cache=this.entrySeq().toArray(),this.size=this._cache.length),this},e.prototype.__iterate=function(t,e){var r=this._cache;if(r){for(var n=r.length,i=0;i!==n;){var o=r[e?n-++i:i++];if(!1===t(o[1],o[0],this))break}return i}return this.__iterateUncached(t,e)},e.prototype.__iterator=function(e,r){var n=this._cache;if(n){var i=n.length,o=0;return new W(function(){if(o===i)return N();var t=n[r?i-++o:o++];return P(e,t[0],t[1])})}return this.__iteratorUncached(e,r)},e}(I),G=function(t){function e(t){return null==t?it().toKeyedSeq():f(t)?a(t)?t.toSeq():t.fromEntrySeq():x(t)?t.toSeq():ot(t)}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).prototype.toKeyedSeq=function(){return this},e}(F),Z=function(t){function e(t){return null==t?it():f(t)?a(t)?t.entrySeq():t.toIndexedSeq():x(t)?t.toSeq().entrySeq():ut(t)}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).of=function(){return e(arguments) +},e.prototype.toIndexedSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq [","]")},e}(F),$=function(t){function e(t){return(f(t)&&!b(t)?t:Z(t)).toSetSeq()}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).of=function(){return e(arguments)},e.prototype.toSetSeq=function(){return this},e}(F);F.isSeq=q,F.Keyed=G,F.Set=$,F.Indexed=Z,F.prototype[j]=!0;var tt=function(t){function e(t){this._array=t,this.size=t.length}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).prototype.get=function(t,e){return this.has(t)?this._array[h(this,t)]:e},e.prototype.__iterate=function(t,e){for(var r=this._array,n=r.length,i=0;i!==n;){var o=e?n-++i:i++;if(!1===t(r[o],o,this))break}return i},e.prototype.__iterator=function(e,r){var n=this._array,i=n.length,o=0;return new W(function(){if(o===i)return N();var t=r?i-++o:o++;return P(e,t,n[t])})},e}(Z),et=function(t){function e(t){var e=Object.keys(t);this._object=t,this._keys=e,this.size=e.length}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).prototype.get=function(t,e){return void 0===e||this.has(t)?this._object[t]:e},e.prototype.has=function(t){return Q.call(this._object,t)},e.prototype.__iterate=function(t,e){for(var r=this._object,n=this._keys,i=n.length,o=0;o!==i;){var u=n[e?i-++o:o++];if(!1===t(r[u],u,this))break}return o},e.prototype.__iterator=function(e,r){var n=this._object,i=this._keys,o=i.length,u=0;return new W(function(){if(u===o)return N();var t=i[r?o-++u:u++];return P(e,t,n[t])})},e}(G);et.prototype[k]=!0;var rt,nt=function(t){function e(t){this._collection=t,this.size=t.length||t.size}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).prototype.__iterateUncached=function(t,e){if(e)return this.cacheResult().__iterate(t,e);var r,n=V(this._collection),i=0;if(J(n))for(;!(r=n.next()).done&&!1!==t(r.value,i++,this););return i},e.prototype.__iteratorUncached=function(e,t){if(t)return this.cacheResult( +).__iterator(e,t);var r=V(this._collection);if(!J(r))return new W(N);var n=0;return new W(function(){var t=r.next();return t.done?t:P(e,n++,t.value)})},e}(Z);function it(){return rt=rt||new tt([])}function ot(t){var e=Array.isArray(t)?new tt(t):H(t)?new nt(t):void 0;if(e)return e.fromEntrySeq();if("object"==typeof t)return new et(t);throw new TypeError("Expected Array or collection object of [k, v] entries, or keyed object: "+t)}function ut(t){var e=st(t);if(e)return e;throw new TypeError("Expected Array or collection object of values: "+t)}function st(t){return X(t)?new tt(t):H(t)?new nt(t):void 0}var at="@@__IMMUTABLE_MAP__@@";function ct(t){return!(!t||!t[at])}function ft(t){return ct(t)&&R(t)}function ht(t){return!(!t||"function"!=typeof t.equals||"function"!=typeof t.hashCode)}function _t(t,e){if(t===e||t!=t&&e!=e)return!0;if(!t||!e)return!1;if("function"==typeof t.valueOf&&"function"==typeof e.valueOf){if((t=t.valueOf())===(e=e.valueOf())||t!=t&&e!=e)return!0;if(!t||!e)return!1}return!!(ht(t)&&ht(e)&&t.equals(e))}var pt="function"==typeof Math.imul&&-2==Math.imul(4294967295,2)?Math.imul:function(t,e){var r=65535&(t|=0),n=65535&(e|=0);return r*n+((t>>>16)*n+r*(e>>>16)<<16>>>0)|0};function lt(t){return t>>>1&1073741824|3221225471&t}var vt=Object.prototype.valueOf;function yt(t){if(null==t)return dt(t);if("function"==typeof t.hashCode)return lt(t.hashCode(t));var e,r=(e=t).valueOf!==vt&&"function"==typeof e.valueOf?e.valueOf(e):e;if(null==r)return dt(r);switch(typeof r){case"boolean":return r?1108378657:1108378656;case"number":return function(t){if(t!=t||t===1/0)return 0;var e=0|t;e!==t&&(e^=4294967295*t);for(;4294967295f)return N();var t=r.next();return a||e===K||t.done?t:P(e,i-1,e===U?void 0:t.value[1],t)})},r}function Bt(e,c,f,h){var t=Xt(e);return t.__iterateUncached=function(n,t){var i=this;if(t)return this.cacheResult().__iterate(n,t);var o=!0,u=0;return e.__iterate(function(t,e,r){if(!(o=o&&c.call(f,t,e,r)))return u++,n(t,h?e:u-1,i)}),u},t.__iteratorUncached=function(i,t){var o=this;if(t)return this.cacheResult().__iterator(i,t);var u=e.__iterator(T,t),s=!0,a=0;return new W(function(){var t;do{if((t=u.next()).done)return h||i===K?t:P(i,a++,i===U?void 0:t.value[1],t);var e=t.value,r=e[0],n=e[1];s=s&&c.call(f,n,r,o)}while(s);return i===T?t:P(i,r,n,t)})},t}function Wt(t,s,a){var c=Xt(t);return c.__iterateUncached=function(i,e){if(e)return this.cacheResult().__iterate(i,e);var o=0,u=!1;return function r(t,n){t.__iterate(function(t,e){return(!s||n>>t)&g),o=this.bitmap;return 0==(o&i)?n:this.nodes[$e(o&i-1)].get(t+d,e,r,n)},Le.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=yt(n));var s=(0===e?r:r>>>e)&g,a=1<>>=1)u[s]=1&r?e[o++]:void 0;return u[n]=i,new Be(t,o+1,u)}(t,_,c,s,u);if(f&&!u&&2===_.length&&Ge(_[1^h]))return _[1^h];if(f&&u&&1===_.length&&Ge(u))return u;s=t&&t===this.ownerID,a=f?u?c:c^a:c|a,u=f?u?tr(_,h,u,s):function(t,e,r){var n=t.length-1;if(r&&e===n)return t.pop(),t;for(var i=Array(n),o=0,u=0;u>>t)&g];return i?i.get(t+d,e,r,n):n},Be.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=yt(n));var s=(0===e?r:r>>>e)&g, +a=this.nodes,c=a[s];if(i===v&&!c)return this;o=Fe(c,t,e+d,r,n,i,o,u);if(o===c)return this;u=this.count;if(c){if(!o&&--u>>r)&g,u=(0===r?n:n>>>r)&g,t=o==u?[Ze(t,e,r+d,n,i)]:(i=new Pe(e,n,i),o>1&1431655765))+(t>>2&858993459))+(t>>4)&252645135,t+=t>>8,127&(t+=t>>16)}function tr(t,e,r,n){t=n?t:Zt(t);return t[e]=r,t}var er=l/4,rr=l/2,nr=l/4,ir="@@__IMMUTABLE_LIST__@@";function or(t){return!(!t||!t[ir])}var ur=function(o){function t(t){var e=pr();if(null==t)return e;if(or(t))return t;var n=o(t),i=n.size;return 0===i?e:(te(i),0=gr(t._capacity)?n=lr(n,t.__ownerID,0,e,r,o):i=lr(i,t.__ownerID,t._level,e,r,o);if(!o.value)return t;if(t.__ownerID)return t._root=i,t._tail=n,t.__hash=void 0,t.__altered=!0,t;return _r(t._origin,t._capacity,t._level,i,n)}(this,t,e)},t.prototype.remove=function(t){return this.has(t)?0===t?this.shift():t===this.size-1?this.pop():this.splice(t,1):this},t.prototype.insert=function(t,e){return this.splice(t,0,e)},t.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=this._origin=this._capacity=0,this._level=d,this._root=this._tail=this.__hash=void 0,this.__altered=!0,this):pr()},t.prototype.push=function(){var r=arguments,n=this.size;return this.withMutations(function(t){dr(t,0,n+r.length);for(var e=0;e>>e&g;if(this.array.length<=n)return new ar([],t);var i=0==n;if(0>>e&g;if(this.array.length<=n)return this;if(0>e,u=1+(c-r>>e);l>>r&g,a=t&&s=gr(t._capacity))return t._tail;if(e<1<>>n&g],n-=d;return r}}function dr(t,e,r){void 0!==e&&(e|=0),void 0!==r&&(r|=0);var n=t.__ownerID||new m,i=t._origin,o=t._capacity,u=i+e,s=void 0===r?o:r<0?o+r:i+r;if(u===i&&s===o)return t;if(s<=u)return t.clear();for(var a=t._level,c=t._root,f=0;u+f<0;)c=new ar(c&&c.array.length?[void 0,c]:[],n),f+=1<<(a+=d);f&&(u+=f,i+=f,s+=f,o+=f);for(var h=gr(o),_=gr(s);1<>>l&g,p=p.array[v]=vr(p.array[v],n);p.array[h>>>d&g]=e}if(s>>a&g;if(y!=_>>>a&g)break;y&&(f+=(1<>>d<>>-15,461845907),e=pt(e<<13|e>>>-13,5),e=pt((e=(e+3864292196|0)^t)^e>>>16,2246822507),e=lt((e=pt(e^e>>>13,3266489909))^e>>>16)}(t.__iterate(r?e?function(t,e){n=31*n+un(yt(t),yt(e))|0}:function(t,e){n=n+un(yt(t),yt(e))|0}:e?function(t){n=31*n+yt(t)|0}:function(t){n=n+yt(t)|0}),n)}(this))}});var Xr=I.prototype;Xr[o]=!0,Xr[B]=Xr.values,Xr.toJSON=Xr.toArray,Xr.__toStringMapper=oe,Xr.inspect=Xr.toSource=function(){return""+this},Xr.chain=Xr.flatMap,Xr.contains=Xr.includes,Ur(O,{flip:function(){return Vt(this,Ut(this))},mapEntries:function(r,n){var i=this,o=0;return Vt(this,this.toSeq().map(function(t,e){return r.call(n,[e,t],o++,i)}).fromEntrySeq())},mapKeys:function(r,n){var i=this;return Vt(this,this.toSeq().flip().map(function(t,e){return r.call(n,t,e,i)}).flip())}});var Fr=O.prototype;Fr[s]=!0,Fr[B]=Xr.entries,Fr.toJSON=Qr,Fr.__toStringMapper=function(t,e){return oe(e)+": "+oe(t)},Ur(E,{toKeyedSeq:function(){return new xt(this,!1)},filter:function(t,e){return Vt(this,Ct(this,t,e,!1))},findIndex:function(t,e){e=this.findEntry(t,e);return e?e[0]:-1},indexOf:function(t){t=this.keyOf(t);return void 0===t?-1:t},lastIndexOf:function(t){t=this.lastKeyOf(t);return void 0===t?-1:t},reverse:function(){return Vt(this,Tt(this,!1))},slice:function(t,e){return Vt(this,Lt(this,t,e,!1))},splice:function(t,e){var r=arguments.length;if(e=Math.max(e||0,0),0===r||2===r&&!e)return this;t=y(t,t<0?this.count():this.size);var n=this.slice(0,t);return Vt(this,1===r?n:n.concat(Zt(arguments,2),this.slice(t+e)))},findLastIndex:function(t,e){e=this.findLastEntry(t,e);return e?e[0]:-1},first:function(t){return this.get(0,t)},flatten:function(t){return Vt(this,Wt(this,t,!1))},get:function(r,t){return(r=h(this,r))<0||this.size===1/0||void 0!==this.size&&this.size>2)|0}Gr[z]=!0,Gr[k]=!0,Ur(M,{get:function(t,e){return this.has(t)?t:e},includes:function(t){return this.has(t)},keySeq:function(){return this.valueSeq()}}),M.prototype.has=Xr.includes,M.prototype.contains=M.prototype.includes,Ur(G,O.prototype),Ur(Z,E.prototype),Ur($,M.prototype);var sn=function(t){function e(r){return null==r?hn():kr(r)?r:hn().withMutations(function(e){var t=M(r);te(t.size),t.forEach(function(t){return e.add(t)})})}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).of=function(){return this(arguments)},e.fromKeys=function(t){return this(O(t).keySeq())},e.prototype.toString=function(){return this.__toString("OrderedSet {","}")},e}(Tr);sn.isOrderedSet=kr;var an,cn=sn.prototype;function fn(t,e){ +var r=Object.create(cn);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function hn(){return an=an||fn(Sr())}cn[k]=!0,cn.zip=Gr.zip,cn.zipWith=Gr.zipWith,cn.__empty=hn,cn.__make=fn;Fr=function(u,s){var a;!function(t){if(x(t))throw Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(A(t))throw Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(null===t||"object"!=typeof t)throw Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}(u);var c=function(t){var n=this;if(t instanceof c)return t;if(!(this instanceof c))return new c(t);if(!a){a=!0;var e=Object.keys(u),r=f._indices={};f._name=s,f._keys=e,f._defaultValues=u;for(var i=0;i Date: Mon, 5 Jul 2021 06:52:14 +0000 Subject: [PATCH 149/242] deploy: 0e7d75024820e8da8d47a7ac061345b88bb7e1f6 --- bower.json | 2 +- dist/immutable.es.js | 2 +- dist/immutable.js | 2 +- dist/immutable.min.js | 2 +- package.json | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/bower.json b/bower.json index b2c7e9c03d..255e875132 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "immutable", - "version": "4.0.0-rc.12", + "version": "4.0.0-rc.13", "description": "Immutable Data Collections", "license": "MIT", "homepage": "https://immutable-js.com", diff --git a/dist/immutable.es.js b/dist/immutable.es.js index be31f20742..df2b9c0993 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -5827,7 +5827,7 @@ function defaultConverter(k, v) { return isKeyed(v) ? v.toMap() : v.toList(); } -var version = "4.0.0-rc.12"; +var version = "4.0.0-rc.13"; var Immutable = { version: version, diff --git a/dist/immutable.js b/dist/immutable.js index 3bae33adb6..b7f91c9efb 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -5833,7 +5833,7 @@ return isKeyed(v) ? v.toMap() : v.toList(); } - var version = "4.0.0-rc.12"; + var version = "4.0.0-rc.13"; var Immutable = { version: version, diff --git a/dist/immutable.min.js b/dist/immutable.min.js index a36c8ac152..d5eb5330fa 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -51,5 +51,5 @@ return e=pt(e,3432918353),e=pt(e<<15|e>>>-15,461845907),e=pt(e<<13|e>>>-13,5),e= t.__iterateUncached=function(e,t){var r=this,n=0;return o.__iterate(function(t){return(!n||!1!==e(u,n++,r))&&!1!==e(t,n++,r)},t),n},t.__iteratorUncached=function(t,e){var r,n=o.__iterator(K,e),i=0;return new W(function(){return(!r||i%2)&&(r=n.next()).done?r:i%2?P(t,i++,u):P(t,i++,r.value,r)})},t));var o,u},interleave:function(){var t=[this].concat(Zt(arguments)),e=Jt(this.toSeq(),Z.of,t),r=e.flatten(!0);return e.size&&(r.size=e.size*t.length),Vt(this,r)},keySeq:function(){return Hr(0,this.size)},last:function(t){return this.get(-1,t)},skipWhile:function(t,e){return Vt(this,Bt(this,t,e,!1))},zip:function(){var t=[this].concat(Zt(arguments));return Vt(this,Jt(this,nn,t))},zipAll:function(){var t=[this].concat(Zt(arguments));return Vt(this,Jt(this,nn,t,!0))},zipWith:function(t){var e=Zt(arguments);return Vt(e[0]=this,Jt(this,t,e))}});var Gr=E.prototype;function Zr(t,n,i,o,u,e){return te(t.size),t.__iterate(function(t,e,r){i=u?(u=!1,t):n.call(o,i,t,e,r)},e),i}function $r(t,e){return e}function tn(t,e){return[e,t]}function en(t){return function(){return!t.apply(this,arguments)}}function rn(t){return function(){return-t.apply(this,arguments)}}function nn(){return Zt(arguments)}function on(t,e){return t>2)|0}Gr[z]=!0,Gr[k]=!0,Ur(M,{get:function(t,e){return this.has(t)?t:e},includes:function(t){return this.has(t)},keySeq:function(){return this.valueSeq()}}),M.prototype.has=Xr.includes,M.prototype.contains=M.prototype.includes,Ur(G,O.prototype),Ur(Z,E.prototype),Ur($,M.prototype);var sn=function(t){function e(r){return null==r?hn():kr(r)?r:hn().withMutations(function(e){var t=M(r);te(t.size),t.forEach(function(t){return e.add(t)})})}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).of=function(){return this(arguments)},e.fromKeys=function(t){return this(O(t).keySeq())},e.prototype.toString=function(){return this.__toString("OrderedSet {","}")},e}(Tr);sn.isOrderedSet=kr;var an,cn=sn.prototype;function fn(t,e){ var r=Object.create(cn);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function hn(){return an=an||fn(Sr())}cn[k]=!0,cn.zip=Gr.zip,cn.zipWith=Gr.zipWith,cn.__empty=hn,cn.__make=fn;Fr=function(u,s){var a;!function(t){if(x(t))throw Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(A(t))throw Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(null===t||"object"!=typeof t)throw Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}(u);var c=function(t){var n=this;if(t instanceof c)return t;if(!(this instanceof c))return new c(t);if(!a){a=!0;var e=Object.keys(u),r=f._indices={};f._name=s,f._keys=e,f._defaultValues=u;for(var i=0;i Date: Tue, 6 Jul 2021 12:43:35 +0000 Subject: [PATCH 150/242] deploy: ffb5aa80872ba416f190b31813c7fc709a21d238 --- dist/immutable.es.js | 1 + dist/immutable.js | 1 + dist/immutable.min.js | 36 ++++++++++++++++++------------------ 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/dist/immutable.es.js b/dist/immutable.es.js index df2b9c0993..bb469c0e62 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -5427,6 +5427,7 @@ var OrderedSetPrototype = OrderedSet.prototype; OrderedSetPrototype[IS_ORDERED_SYMBOL] = true; OrderedSetPrototype.zip = IndexedCollectionPrototype.zip; OrderedSetPrototype.zipWith = IndexedCollectionPrototype.zipWith; +OrderedSetPrototype.zipAll = IndexedCollectionPrototype.zipAll; OrderedSetPrototype.__empty = emptyOrderedSet; OrderedSetPrototype.__make = makeOrderedSet; diff --git a/dist/immutable.js b/dist/immutable.js index b7f91c9efb..aff0fddaf7 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -5433,6 +5433,7 @@ OrderedSetPrototype[IS_ORDERED_SYMBOL] = true; OrderedSetPrototype.zip = IndexedCollectionPrototype.zip; OrderedSetPrototype.zipWith = IndexedCollectionPrototype.zipWith; + OrderedSetPrototype.zipAll = IndexedCollectionPrototype.zipAll; OrderedSetPrototype.__empty = emptyOrderedSet; OrderedSetPrototype.__make = makeOrderedSet; diff --git a/dist/immutable.min.js b/dist/immutable.min.js index d5eb5330fa..5d6d75a9a9 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -21,35 +21,35 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).Immutable={})}(this,function(t){"use strict";var e="delete",d=5,l=1<>>0;if(""+r!==e||4294967295==r)return NaN;e=r}return e<0?c(t)+e:e}function r(){return!0}function p(t,e,r){return(0===t&&!i(t)||void 0!==r&&t<=-r)&&(void 0===e||void 0!==r&&r<=e)}function y(t,e){return n(t,e,0)}function w(t,e){return n(t,e,e)}function n(t,e,r){return void 0===t?r:i(t)?e===1/0?e:0|Math.max(0,e+t):void 0===e||e===t?t:0|Math.min(e,t)}function i(t){return t<0||0===t&&1/t==-1/0}var o="@@__IMMUTABLE_ITERABLE__@@";function f(t){return!(!t||!t[o])}var s="@@__IMMUTABLE_KEYED__@@";function a(t){return!(!t||!t[s])}var z="@@__IMMUTABLE_INDEXED__@@";function S(t){return!(!t||!t[z])}function b(t){return a(t)||S(t)}function I(t){return f(t)?t:F(t)}var O=function(t){function e(t){return a(t)?t:G(t)}return e.__proto__=t,(e.prototype=Object.create(t.prototype)).constructor=e}(I),E=function(t){function e(t){return S(t)?t:Z(t)}return e.__proto__=t,(e.prototype=Object.create(t.prototype)).constructor=e}(I),M=function(t){function e(t){return f(t)&&!b(t)?t:$(t)}return e.__proto__=t,(e.prototype=Object.create(t.prototype)).constructor=e}(I);I.Keyed=O,I.Indexed=E,I.Set=M;var j="@@__IMMUTABLE_SEQ__@@";function q(t){return!(!t||!t[j])}var D="@@__IMMUTABLE_RECORD__@@";function x(t){return!(!t||!t[D])}function A(t){return f(t)||x(t)}var k="@@__IMMUTABLE_ORDERED__@@";function R(t){return!(!t||!t[k])}var U=0,K=1,T=2,C="function"==typeof Symbol&&Symbol.iterator,L="@@iterator",B=C||L,W=function(t){this.next=t};function P(t,e,r,n){r=0===t?e:1===t?r:[e,r];return n?n.value=r:n={value:r,done:!1},n}function N(){return{value:void 0,done:!0}}function H(t){return Y(t)}function J( -t){return t&&"function"==typeof t.next}function V(t){var e=Y(t);return e&&e.call(t)}function Y(t){t=t&&(C&&t[C]||t[L]);if("function"==typeof t)return t}W.prototype.toString=function(){return"[Iterator]"},W.KEYS=U,W.VALUES=K,W.ENTRIES=T,W.prototype.inspect=W.prototype.toSource=function(){return""+this},W.prototype[B]=function(){return this};var Q=Object.prototype.hasOwnProperty;function X(t){return Array.isArray(t)||"string"==typeof t||t&&"object"==typeof t&&Number.isInteger(t.length)&&0<=t.length&&(0===t.length?1===Object.keys(t).length:t.hasOwnProperty(t.length-1))}var F=function(t){function e(t){return null==t?it():A(t)?t.toSeq():function(t){var e=st(t);if(e)return e;if("object"!=typeof t)throw new TypeError("Expected Array or collection object of values, or keyed object: "+t);return new et(t)}(t)}return e.__proto__=t,((e.prototype=Object.create(t.prototype)).constructor=e).prototype.toSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq {","}")},e.prototype.cacheResult=function(){return!this._cache&&this.__iterateUncached&&(this._cache=this.entrySeq().toArray(),this.size=this._cache.length),this},e.prototype.__iterate=function(t,e){var r=this._cache;if(r){for(var n=r.length,i=0;i!==n;){var o=r[e?n-++i:i++];if(!1===t(o[1],o[0],this))break}return i}return this.__iterateUncached(t,e)},e.prototype.__iterator=function(e,r){var n=this._cache;if(n){var i=n.length,o=0;return new W(function(){if(o===i)return N();var t=n[r?i-++o:o++];return P(e,t[0],t[1])})}return this.__iteratorUncached(e,r)},e}(I),G=function(t){function e(t){return null==t?it().toKeyedSeq():f(t)?a(t)?t.toSeq():t.fromEntrySeq():x(t)?t.toSeq():ot(t)}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).prototype.toKeyedSeq=function(){return this},e}(F),Z=function(t){function e(t){return null==t?it():f(t)?a(t)?t.entrySeq():t.toIndexedSeq():x(t)?t.toSeq().entrySeq():ut(t)}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).of=function(){return e(arguments) +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).Immutable={})}(this,function(t){"use strict";var e="delete",d=5,l=1<>>0;if(""+r!==e||4294967295==r)return NaN;e=r}return e<0?c(t)+e:e}function r(){return!0}function p(t,e,r){return(0===t&&!i(t)||void 0!==r&&t<=-r)&&(void 0===e||void 0!==r&&r<=e)}function y(t,e){return n(t,e,0)}function w(t,e){return n(t,e,e)}function n(t,e,r){return void 0===t?r:i(t)?e===1/0?e:0|Math.max(0,e+t):void 0===e||e===t?t:0|Math.min(e,t)}function i(t){return t<0||0===t&&1/t==-1/0}var o="@@__IMMUTABLE_ITERABLE__@@";function f(t){return!(!t||!t[o])}var s="@@__IMMUTABLE_KEYED__@@";function a(t){return!(!t||!t[s])}var z="@@__IMMUTABLE_INDEXED__@@";function S(t){return!(!t||!t[z])}function b(t){return a(t)||S(t)}function I(t){return f(t)?t:F(t)}var O=function(t){function e(t){return a(t)?t:G(t)}return e.__proto__=t,(e.prototype=Object.create(t.prototype)).constructor=e}(I),E=function(t){function e(t){return S(t)?t:Z(t)}return e.__proto__=t,(e.prototype=Object.create(t.prototype)).constructor=e}(I),M=function(t){function e(t){return f(t)&&!b(t)?t:$(t)}return e.__proto__=t,(e.prototype=Object.create(t.prototype)).constructor=e}(I);I.Keyed=O,I.Indexed=E,I.Set=M;var j="@@__IMMUTABLE_SEQ__@@";function q(t){return!(!t||!t[j])}var D="@@__IMMUTABLE_RECORD__@@";function A(t){return!(!t||!t[D])}function x(t){return f(t)||A(t)}var k="@@__IMMUTABLE_ORDERED__@@";function R(t){return!(!t||!t[k])}var U=0,K=1,T=2,C="function"==typeof Symbol&&Symbol.iterator,L="@@iterator",B=C||L,W=function(t){this.next=t};function P(t,e,r,n){r=0===t?e:1===t?r:[e,r];return n?n.value=r:n={value:r,done:!1},n}function N(){return{value:void 0,done:!0}}function H(t){return Y(t)}function J( +t){return t&&"function"==typeof t.next}function V(t){var e=Y(t);return e&&e.call(t)}function Y(t){t=t&&(C&&t[C]||t[L]);if("function"==typeof t)return t}W.prototype.toString=function(){return"[Iterator]"},W.KEYS=U,W.VALUES=K,W.ENTRIES=T,W.prototype.inspect=W.prototype.toSource=function(){return""+this},W.prototype[B]=function(){return this};var Q=Object.prototype.hasOwnProperty;function X(t){return Array.isArray(t)||"string"==typeof t||t&&"object"==typeof t&&Number.isInteger(t.length)&&0<=t.length&&(0===t.length?1===Object.keys(t).length:t.hasOwnProperty(t.length-1))}var F=function(t){function e(t){return null==t?it():x(t)?t.toSeq():function(t){var e=st(t);if(e)return e;if("object"!=typeof t)throw new TypeError("Expected Array or collection object of values, or keyed object: "+t);return new et(t)}(t)}return e.__proto__=t,((e.prototype=Object.create(t.prototype)).constructor=e).prototype.toSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq {","}")},e.prototype.cacheResult=function(){return!this._cache&&this.__iterateUncached&&(this._cache=this.entrySeq().toArray(),this.size=this._cache.length),this},e.prototype.__iterate=function(t,e){var r=this._cache;if(r){for(var n=r.length,i=0;i!==n;){var o=r[e?n-++i:i++];if(!1===t(o[1],o[0],this))break}return i}return this.__iterateUncached(t,e)},e.prototype.__iterator=function(e,r){var n=this._cache;if(n){var i=n.length,o=0;return new W(function(){if(o===i)return N();var t=n[r?i-++o:o++];return P(e,t[0],t[1])})}return this.__iteratorUncached(e,r)},e}(I),G=function(t){function e(t){return null==t?it().toKeyedSeq():f(t)?a(t)?t.toSeq():t.fromEntrySeq():A(t)?t.toSeq():ot(t)}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).prototype.toKeyedSeq=function(){return this},e}(F),Z=function(t){function e(t){return null==t?it():f(t)?a(t)?t.entrySeq():t.toIndexedSeq():A(t)?t.toSeq().entrySeq():ut(t)}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).of=function(){return e(arguments) },e.prototype.toIndexedSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq [","]")},e}(F),$=function(t){function e(t){return(f(t)&&!b(t)?t:Z(t)).toSetSeq()}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).of=function(){return e(arguments)},e.prototype.toSetSeq=function(){return this},e}(F);F.isSeq=q,F.Keyed=G,F.Set=$,F.Indexed=Z,F.prototype[j]=!0;var tt=function(t){function e(t){this._array=t,this.size=t.length}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).prototype.get=function(t,e){return this.has(t)?this._array[h(this,t)]:e},e.prototype.__iterate=function(t,e){for(var r=this._array,n=r.length,i=0;i!==n;){var o=e?n-++i:i++;if(!1===t(r[o],o,this))break}return i},e.prototype.__iterator=function(e,r){var n=this._array,i=n.length,o=0;return new W(function(){if(o===i)return N();var t=r?i-++o:o++;return P(e,t,n[t])})},e}(Z),et=function(t){function e(t){var e=Object.keys(t);this._object=t,this._keys=e,this.size=e.length}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).prototype.get=function(t,e){return void 0===e||this.has(t)?this._object[t]:e},e.prototype.has=function(t){return Q.call(this._object,t)},e.prototype.__iterate=function(t,e){for(var r=this._object,n=this._keys,i=n.length,o=0;o!==i;){var u=n[e?i-++o:o++];if(!1===t(r[u],u,this))break}return o},e.prototype.__iterator=function(e,r){var n=this._object,i=this._keys,o=i.length,u=0;return new W(function(){if(u===o)return N();var t=i[r?o-++u:u++];return P(e,t,n[t])})},e}(G);et.prototype[k]=!0;var rt,nt=function(t){function e(t){this._collection=t,this.size=t.length||t.size}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).prototype.__iterateUncached=function(t,e){if(e)return this.cacheResult().__iterate(t,e);var r,n=V(this._collection),i=0;if(J(n))for(;!(r=n.next()).done&&!1!==t(r.value,i++,this););return i},e.prototype.__iteratorUncached=function(e,t){if(t)return this.cacheResult( ).__iterator(e,t);var r=V(this._collection);if(!J(r))return new W(N);var n=0;return new W(function(){var t=r.next();return t.done?t:P(e,n++,t.value)})},e}(Z);function it(){return rt=rt||new tt([])}function ot(t){var e=Array.isArray(t)?new tt(t):H(t)?new nt(t):void 0;if(e)return e.fromEntrySeq();if("object"==typeof t)return new et(t);throw new TypeError("Expected Array or collection object of [k, v] entries, or keyed object: "+t)}function ut(t){var e=st(t);if(e)return e;throw new TypeError("Expected Array or collection object of values: "+t)}function st(t){return X(t)?new tt(t):H(t)?new nt(t):void 0}var at="@@__IMMUTABLE_MAP__@@";function ct(t){return!(!t||!t[at])}function ft(t){return ct(t)&&R(t)}function ht(t){return!(!t||"function"!=typeof t.equals||"function"!=typeof t.hashCode)}function _t(t,e){if(t===e||t!=t&&e!=e)return!0;if(!t||!e)return!1;if("function"==typeof t.valueOf&&"function"==typeof e.valueOf){if((t=t.valueOf())===(e=e.valueOf())||t!=t&&e!=e)return!0;if(!t||!e)return!1}return!!(ht(t)&&ht(e)&&t.equals(e))}var pt="function"==typeof Math.imul&&-2==Math.imul(4294967295,2)?Math.imul:function(t,e){var r=65535&(t|=0),n=65535&(e|=0);return r*n+((t>>>16)*n+r*(e>>>16)<<16>>>0)|0};function lt(t){return t>>>1&1073741824|3221225471&t}var vt=Object.prototype.valueOf;function yt(t){if(null==t)return dt(t);if("function"==typeof t.hashCode)return lt(t.hashCode(t));var e,r=(e=t).valueOf!==vt&&"function"==typeof e.valueOf?e.valueOf(e):e;if(null==r)return dt(r);switch(typeof r){case"boolean":return r?1108378657:1108378656;case"number":return function(t){if(t!=t||t===1/0)return 0;var e=0|t;e!==t&&(e^=4294967295*t);for(;4294967295f)return N();var t=r.next();return a||e===K||t.done?t:P(e,i-1,e===U?void 0:t.value[1],t)})},r}function Bt(e,c,f,h){var t=Xt(e);return t.__iterateUncached=function(n,t){var i=this;if(t)return this.cacheResult().__iterate(n,t);var o=!0,u=0;return e.__iterate(function(t,e,r){if(!(o=o&&c.call(f,t,e,r)))return u++,n(t,h?e:u-1,i)}),u},t.__iteratorUncached=function(i,t){var o=this;if(t)return this.cacheResult().__iterator(i,t);var u=e.__iterator(T,t),s=!0,a=0;return new W(function(){var t;do{if((t=u.next()).done)return h||i===K?t:P(i,a++,i===U?void 0:t.value[1],t);var e=t.value,r=e[0],n=e[1];s=s&&c.call(f,n,r,o)}while(s);return i===T?t:P(i,r,n,t)})},t}function Wt(t,s,a){var c=Xt(t);return c.__iterateUncached=function(i,e){if(e)return this.cacheResult().__iterate(i,e);var o=0,u=!1;return function r(t,n){t.__iterate(function(t,e){return(!s||n>>t)&g),o=this.bitmap;return 0==(o&i)?n:this.nodes[$e(o&i-1)].get(t+d,e,r,n)},Le.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=yt(n));var s=(0===e?r:r>>>e)&g,a=1<>>=1)u[s]=1&r?e[o++]:void 0;return u[n]=i,new Be(t,o+1,u)}(t,_,c,s,u);if(f&&!u&&2===_.length&&Ge(_[1^h]))return _[1^h];if(f&&u&&1===_.length&&Ge(u))return u;s=t&&t===this.ownerID,a=f?u?c:c^a:c|a,u=f?u?tr(_,h,u,s):function(t,e,r){var n=t.length-1;if(r&&e===n)return t.pop(),t;for(var i=Array(n),o=0,u=0;u>>t)&g];return i?i.get(t+d,e,r,n):n},Be.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=yt(n));var s=(0===e?r:r>>>e)&g, a=this.nodes,c=a[s];if(i===v&&!c)return this;o=Fe(c,t,e+d,r,n,i,o,u);if(o===c)return this;u=this.count;if(c){if(!o&&--u>>r)&g,u=(0===r?n:n>>>r)&g,t=o==u?[Ze(t,e,r+d,n,i)]:(i=new Pe(e,n,i),o>1&1431655765))+(t>>2&858993459))+(t>>4)&252645135,t+=t>>8,127&(t+=t>>16)}function tr(t,e,r,n){t=n?t:Zt(t);return t[e]=r,t}var er=l/4,rr=l/2,nr=l/4,ir="@@__IMMUTABLE_LIST__@@";function or(t){return!(!t||!t[ir])}var ur=function(o){function t(t){var e=pr();if(null==t)return e;if(or(t))return t;var n=o(t),i=n.size;return 0===i?e:(te(i),0=gr(t._capacity)?n=lr(n,t.__ownerID,0,e,r,o):i=lr(i,t.__ownerID,t._level,e,r,o);if(!o.value)return t;if(t.__ownerID)return t._root=i,t._tail=n,t.__hash=void 0,t.__altered=!0,t;return _r(t._origin,t._capacity,t._level,i,n)}(this,t,e)},t.prototype.remove=function(t){return this.has(t)?0===t?this.shift():t===this.size-1?this.pop():this.splice(t,1):this},t.prototype.insert=function(t,e){return this.splice(t,0,e)},t.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=this._origin=this._capacity=0,this._level=d,this._root=this._tail=this.__hash=void 0,this.__altered=!0,this):pr()},t.prototype.push=function(){var r=arguments,n=this.size;return this.withMutations(function(t){dr(t,0,n+r.length);for(var e=0;e>>e&g;if(this.array.length<=n)return new ar([],t);var i=0==n;if(0>>e&g;if(this.array.length<=n)return this;if(0>e,u=1+(c-r>>e);l>>e&g;if(this.array.length<=n)return new ar([],t);var i=0==n;if(0>>e&g;if(this.array.length<=n)return this;if(0>e,u=1+(c-r>>e);l>>r&g,a=t&&s=gr(t._capacity))return t._tail;if(e<1<>>n&g],n-=d;return r}}function dr(t,e,r){void 0!==e&&(e|=0),void 0!==r&&(r|=0);var n=t.__ownerID||new m,i=t._origin,o=t._capacity,u=i+e,s=void 0===r?o:r<0?o+r:i+r;if(u===i&&s===o)return t;if(s<=u)return t.clear();for(var a=t._level,c=t._root,f=0;u+f<0;)c=new ar(c&&c.array.length?[void 0,c]:[],n),f+=1<<(a+=d);f&&(u+=f,i+=f,s+=f,o+=f);for(var h=gr(o),_=gr(s);1<>>l&g,p=p.array[v]=vr(p.array[v],n);p.array[h>>>d&g]=e}if(s>>a&g;if(y!=_>>>a&g)break;y&&(f+=(1<>>d<>>-15,461845907),e=pt(e<<13|e>>>-13,5),e=pt((e=(e+3864292196|0)^t)^e>>>16,2246822507),e=lt((e=pt(e^e>>>13,3266489909))^e>>>16)}(t.__iterate(r?e?function(t,e){n=31*n+un(yt(t),yt(e))|0}:function(t,e){n=n+un(yt(t),yt(e))|0}:e?function(t){n=31*n+yt(t)|0}:function(t){n=n+yt(t)|0}),n)}(this))}});var Xr=I.prototype;Xr[o]=!0,Xr[B]=Xr.values,Xr.toJSON=Xr.toArray,Xr.__toStringMapper=oe,Xr.inspect=Xr.toSource=function(){return""+this},Xr.chain=Xr.flatMap,Xr.contains=Xr.includes,Ur(O,{flip:function(){return Vt(this,Ut(this))},mapEntries:function(r,n){var i=this,o=0;return Vt(this,this.toSeq().map(function(t,e){return r.call(n,[e,t],o++,i)}).fromEntrySeq())},mapKeys:function(r,n){var i=this;return Vt(this,this.toSeq().flip().map(function(t,e){return r.call(n,t,e,i)}).flip())}});var Fr=O.prototype;Fr[s]=!0,Fr[B]=Xr.entries,Fr.toJSON=Qr,Fr.__toStringMapper=function(t,e){return oe(e)+": "+oe(t)},Ur(E,{toKeyedSeq:function(){return new xt(this,!1)},filter:function(t,e){return Vt(this,Ct(this,t,e,!1))},findIndex:function(t,e){e=this.findEntry(t,e);return e?e[0]:-1},indexOf:function(t){t=this.keyOf(t);return void 0===t?-1:t},lastIndexOf:function(t){t=this.lastKeyOf(t);return void 0===t?-1:t},reverse:function(){return Vt(this,Tt(this,!1))},slice:function(t,e){return Vt(this,Lt(this,t,e,!1))},splice:function(t,e){var r=arguments.length;if(e=Math.max(e||0,0),0===r||2===r&&!e)return this;t=y(t,t<0?this.count():this.size);var n=this.slice(0,t);return Vt(this,1===r?n:n.concat(Zt(arguments,2),this.slice(t+e)))},findLastIndex:function(t,e){e=this.findLastEntry(t,e);return e?e[0]:-1},first:function(t){return this.get(0,t)},flatten:function(t){return Vt(this,Wt(this,t,!1))},get:function(r,t){return(r=h(this,r))<0||this.size===1/0||void 0!==this.size&&this.size>>-15,461845907),e=pt(e<<13|e>>>-13,5),e=pt((e=(e+3864292196|0)^t)^e>>>16,2246822507),e=lt((e=pt(e^e>>>13,3266489909))^e>>>16)}(t.__iterate(r?e?function(t,e){n=31*n+un(yt(t),yt(e))|0}:function(t,e){n=n+un(yt(t),yt(e))|0}:e?function(t){n=31*n+yt(t)|0}:function(t){n=n+yt(t)|0}),n)}(this))}});var Xr=I.prototype;Xr[o]=!0,Xr[B]=Xr.values,Xr.toJSON=Xr.toArray,Xr.__toStringMapper=oe,Xr.inspect=Xr.toSource=function(){return""+this},Xr.chain=Xr.flatMap,Xr.contains=Xr.includes,Ur(O,{flip:function(){return Vt(this,Ut(this))},mapEntries:function(r,n){var i=this,o=0;return Vt(this,this.toSeq().map(function(t,e){return r.call(n,[e,t],o++,i)}).fromEntrySeq())},mapKeys:function(r,n){var i=this;return Vt(this,this.toSeq().flip().map(function(t,e){return r.call(n,t,e,i)}).flip())}});var Fr=O.prototype;Fr[s]=!0,Fr[B]=Xr.entries,Fr.toJSON=Qr,Fr.__toStringMapper=function(t,e){return oe(e)+": "+oe(t)},Ur(E,{toKeyedSeq:function(){return new At(this,!1)},filter:function(t,e){return Vt(this,Ct(this,t,e,!1))},findIndex:function(t,e){e=this.findEntry(t,e);return e?e[0]:-1},indexOf:function(t){t=this.keyOf(t);return void 0===t?-1:t},lastIndexOf:function(t){t=this.lastKeyOf(t);return void 0===t?-1:t},reverse:function(){return Vt(this,Tt(this,!1))},slice:function(t,e){return Vt(this,Lt(this,t,e,!1))},splice:function(t,e){var r=arguments.length;if(e=Math.max(e||0,0),0===r||2===r&&!e)return this;t=y(t,t<0?this.count():this.size);var n=this.slice(0,t);return Vt(this,1===r?n:n.concat(Zt(arguments,2),this.slice(t+e)))},findLastIndex:function(t,e){e=this.findLastEntry(t,e);return e?e[0]:-1},first:function(t){return this.get(0,t)},flatten:function(t){return Vt(this,Wt(this,t,!1))},get:function(r,t){return(r=h(this,r))<0||this.size===1/0||void 0!==this.size&&this.size>2)|0}Gr[z]=!0,Gr[k]=!0,Ur(M,{get:function(t,e){return this.has(t)?t:e},includes:function(t){return this.has(t)},keySeq:function(){return this.valueSeq()}}),M.prototype.has=Xr.includes,M.prototype.contains=M.prototype.includes,Ur(G,O.prototype),Ur(Z,E.prototype),Ur($,M.prototype);var sn=function(t){function e(r){return null==r?hn():kr(r)?r:hn().withMutations(function(e){var t=M(r);te(t.size),t.forEach(function(t){return e.add(t)})})}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).of=function(){return this(arguments)},e.fromKeys=function(t){return this(O(t).keySeq())},e.prototype.toString=function(){return this.__toString("OrderedSet {","}")},e}(Tr);sn.isOrderedSet=kr;var an,cn=sn.prototype;function fn(t,e){ -var r=Object.create(cn);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function hn(){return an=an||fn(Sr())}cn[k]=!0,cn.zip=Gr.zip,cn.zipWith=Gr.zipWith,cn.__empty=hn,cn.__make=fn;Fr=function(u,s){var a;!function(t){if(x(t))throw Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(A(t))throw Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(null===t||"object"!=typeof t)throw Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}(u);var c=function(t){var n=this;if(t instanceof c)return t;if(!(this instanceof c))return new c(t);if(!a){a=!0;var e=Object.keys(u),r=f._indices={};f._name=s,f._keys=e,f._defaultValues=u;for(var i=0;i Date: Wed, 7 Jul 2021 06:58:38 +0000 Subject: [PATCH 151/242] deploy: 79f90971a8879788a676e3f3665c4fd63966bb61 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1f5b3e0d93..407885d239 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ intermediate representations. Create some `Seq` with `Range` and `Repeat`. Want to hear more? Watch the presentation about Immutable.js: - +[![Immutable Data and React](/resources/Immutable-Data-and-React-YouTube.png)](https://youtu.be/I7IdS-PbEgI) [Persistent]: https://en.wikipedia.org/wiki/Persistent_data_structure [Immutable]: https://en.wikipedia.org/wiki/Immutable_object From 6a79c785d9e716de782882a23d25128465ff9920 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 7 Jul 2021 09:24:03 +0000 Subject: [PATCH 152/242] deploy: dd1f515f5a77187e2c62aec45cf417c9ce8ab001 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 407885d239..c0d6bdf5ff 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ intermediate representations. Create some `Seq` with `Range` and `Repeat`. Want to hear more? Watch the presentation about Immutable.js: -[![Immutable Data and React](/resources/Immutable-Data-and-React-YouTube.png)](https://youtu.be/I7IdS-PbEgI) +[![Immutable Data and React](website/public/Immutable-Data-and-React-YouTube.png)](https://youtu.be/I7IdS-PbEgI) [Persistent]: https://en.wikipedia.org/wiki/Persistent_data_structure [Immutable]: https://en.wikipedia.org/wiki/Immutable_object From b31a0d58afd39bd02e7c7679855443b7207582c4 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 7 Jul 2021 23:03:56 +0000 Subject: [PATCH 153/242] deploy: c02df927d19998003c60611d50a8044fe416901b --- dist/immutable-nonambient.d.ts | 40 ++++++++++++++++++++++++++++------ dist/immutable.d.ts | 40 ++++++++++++++++++++++++++++------ 2 files changed, 66 insertions(+), 14 deletions(-) diff --git a/dist/immutable-nonambient.d.ts b/dist/immutable-nonambient.d.ts index bd983bb072..7665a56ef9 100644 --- a/dist/immutable-nonambient.d.ts +++ b/dist/immutable-nonambient.d.ts @@ -4330,7 +4330,17 @@ * Like `sort`, but also accepts a `comparatorValueMapper` which allows for * sorting by more sophisticated means: * - * hitters.sortBy(hitter => hitter.avgHits) + * + * ```js + * const { Map } = require('immutable') + * const beattles = Map({ + * John: { name: "Lennon" }, + * Paul: { name: "McCartney" }, + * George: { name: "Harrison" }, + * Ringo: { name: "Starr" }, + * }); + * beattles.sortBy(member => member.name); + * ``` * * Note: `sortBy()` Always returns a new instance, even if the original was * already sorted. @@ -4742,9 +4752,17 @@ /** * Like `max`, but also accepts a `comparatorValueMapper` which allows for * comparing by more sophisticated means: - * - * hitters.maxBy(hitter => hitter.avgHits); - * + * + * + * ```js + * const { List, } = require('immutable'); + * const l = List([ + * { name: 'Bob', avgHit: 1 }, + * { name: 'Max', avgHit: 3 }, + * { name: 'Lili', avgHit: 2 } , + * ]); + * l.maxBy(i => i.avgHit); // will output { name: 'Max', avgHit: 3 } + * ``` */ maxBy( comparatorValueMapper: (value: V, key: K, iter: this) => C, @@ -4771,9 +4789,17 @@ /** * Like `min`, but also accepts a `comparatorValueMapper` which allows for * comparing by more sophisticated means: - * - * hitters.minBy(hitter => hitter.avgHits); - * + * + * + * ```js + * const { List, } = require('immutable'); + * const l = List([ + * { name: 'Bob', avgHit: 1 }, + * { name: 'Max', avgHit: 3 }, + * { name: 'Lili', avgHit: 2 } , + * ]); + * l.minBy(i => i.avgHit); // will output { name: 'Bob', avgHit: 1 } + * ``` */ minBy( comparatorValueMapper: (value: V, key: K, iter: this) => C, diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index 801b115e7b..91d658f411 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -4330,7 +4330,17 @@ declare module Immutable { * Like `sort`, but also accepts a `comparatorValueMapper` which allows for * sorting by more sophisticated means: * - * hitters.sortBy(hitter => hitter.avgHits) + * + * ```js + * const { Map } = require('immutable') + * const beattles = Map({ + * John: { name: "Lennon" }, + * Paul: { name: "McCartney" }, + * George: { name: "Harrison" }, + * Ringo: { name: "Starr" }, + * }); + * beattles.sortBy(member => member.name); + * ``` * * Note: `sortBy()` Always returns a new instance, even if the original was * already sorted. @@ -4742,9 +4752,17 @@ declare module Immutable { /** * Like `max`, but also accepts a `comparatorValueMapper` which allows for * comparing by more sophisticated means: - * - * hitters.maxBy(hitter => hitter.avgHits); - * + * + * + * ```js + * const { List, } = require('immutable'); + * const l = List([ + * { name: 'Bob', avgHit: 1 }, + * { name: 'Max', avgHit: 3 }, + * { name: 'Lili', avgHit: 2 } , + * ]); + * l.maxBy(i => i.avgHit); // will output { name: 'Max', avgHit: 3 } + * ``` */ maxBy( comparatorValueMapper: (value: V, key: K, iter: this) => C, @@ -4771,9 +4789,17 @@ declare module Immutable { /** * Like `min`, but also accepts a `comparatorValueMapper` which allows for * comparing by more sophisticated means: - * - * hitters.minBy(hitter => hitter.avgHits); - * + * + * + * ```js + * const { List, } = require('immutable'); + * const l = List([ + * { name: 'Bob', avgHit: 1 }, + * { name: 'Max', avgHit: 3 }, + * { name: 'Lili', avgHit: 2 } , + * ]); + * l.minBy(i => i.avgHit); // will output { name: 'Bob', avgHit: 1 } + * ``` */ minBy( comparatorValueMapper: (value: V, key: K, iter: this) => C, From eb38f876c5e43dc1938dce64a0a6475ed65be28d Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 7 Jul 2021 23:05:30 +0000 Subject: [PATCH 154/242] deploy: 88af849336061b73e4c3e87a030ff4fa90cc5e66 --- dist/immutable-nonambient.d.ts | 1 + dist/immutable.d.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/dist/immutable-nonambient.d.ts b/dist/immutable-nonambient.d.ts index 7665a56ef9..931845756d 100644 --- a/dist/immutable-nonambient.d.ts +++ b/dist/immutable-nonambient.d.ts @@ -765,6 +765,7 @@ export function Map(): Map; export function Map(collection: Iterable<[K, V]>): Map; export function Map(obj: { [key: string]: V }): Map; + export function Map(obj: { [P in K]?: V }): Map; export interface Map extends Collection.Keyed { /** diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index 91d658f411..9efc21ed23 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -765,6 +765,7 @@ declare module Immutable { export function Map(): Map; export function Map(collection: Iterable<[K, V]>): Map; export function Map(obj: { [key: string]: V }): Map; + export function Map(obj: { [P in K]?: V }): Map; export interface Map extends Collection.Keyed { /** From 9dc1a45e57bea626c7557bc7998d9cf60cbaab45 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 7 Jul 2021 23:49:53 +0000 Subject: [PATCH 155/242] deploy: 027f4d0d35ecd3515d32af5fc0462c778c045264 --- dist/immutable-nonambient.d.ts | 20 +++++++++++--------- dist/immutable.d.ts | 20 +++++++++++--------- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/dist/immutable-nonambient.d.ts b/dist/immutable-nonambient.d.ts index 931845756d..6d3a9e4b4b 100644 --- a/dist/immutable-nonambient.d.ts +++ b/dist/immutable-nonambient.d.ts @@ -392,7 +392,7 @@ * @see `Map#update` */ update(index: number, notSetValue: T, updater: (value: T) => T): this; - update(index: number, updater: (value: T) => T): this; + update(index: number, updater: (value: T | undefined) => T): this; update(updater: (value: this) => R): R; /** @@ -958,7 +958,7 @@ * Note: `update(key)` can be used in `withMutations`. */ update(key: K, notSetValue: V, updater: (value: V) => V): this; - update(key: K, updater: (value: V) => V): this; + update(key: K, updater: (value: V | undefined) => V): this; update(updater: (value: this) => R): R; /** @@ -1367,7 +1367,7 @@ * @see Collection.Keyed.mapEntries */ mapEntries( - mapper: (entry: [K, V], index: number, iter: this) => [KM, VM], + mapper: (entry: [K, V], index: number, iter: this) => [KM, VM] | undefined, context?: unknown ): Map; @@ -1538,7 +1538,7 @@ * @see Collection.Keyed.mapEntries */ mapEntries( - mapper: (entry: [K, V], index: number, iter: this) => [KM, VM], + mapper: (entry: [K, V], index: number, iter: this) => [KM, VM] | undefined, context?: unknown ): OrderedMap; @@ -2825,7 +2825,7 @@ * @see Collection.Keyed.mapEntries */ mapEntries( - mapper: (entry: [K, V], index: number, iter: this) => [KM, VM], + mapper: (entry: [K, V], index: number, iter: this) => [KM, VM] | undefined, context?: unknown ): Seq.Keyed; @@ -3431,9 +3431,11 @@ * * Note: `mapEntries()` always returns a new instance, even if it produced * the same entry at every step. + * + * If the mapper function returns `undefined`, then the entry will be filtered */ mapEntries( - mapper: (entry: [K, V], index: number, iter: this) => [KM, VM], + mapper: (entry: [K, V], index: number, iter: this) => [KM, VM] | undefined, context?: unknown ): Collection.Keyed; @@ -4753,7 +4755,7 @@ /** * Like `max`, but also accepts a `comparatorValueMapper` which allows for * comparing by more sophisticated means: - * + * * * ```js * const { List, } = require('immutable'); @@ -4790,7 +4792,7 @@ /** * Like `min`, but also accepts a `comparatorValueMapper` which allows for * comparing by more sophisticated means: - * + * * * ```js * const { List, } = require('immutable'); @@ -5332,7 +5334,7 @@ export function update>( collection: C, key: K, - updater: (value: V) => V + updater: (value: V | undefined) => V ): C; export function update, NSV>( collection: C, diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index 9efc21ed23..6c5ab1cc22 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -392,7 +392,7 @@ declare module Immutable { * @see `Map#update` */ update(index: number, notSetValue: T, updater: (value: T) => T): this; - update(index: number, updater: (value: T) => T): this; + update(index: number, updater: (value: T | undefined) => T): this; update(updater: (value: this) => R): R; /** @@ -958,7 +958,7 @@ declare module Immutable { * Note: `update(key)` can be used in `withMutations`. */ update(key: K, notSetValue: V, updater: (value: V) => V): this; - update(key: K, updater: (value: V) => V): this; + update(key: K, updater: (value: V | undefined) => V): this; update(updater: (value: this) => R): R; /** @@ -1367,7 +1367,7 @@ declare module Immutable { * @see Collection.Keyed.mapEntries */ mapEntries( - mapper: (entry: [K, V], index: number, iter: this) => [KM, VM], + mapper: (entry: [K, V], index: number, iter: this) => [KM, VM] | undefined, context?: unknown ): Map; @@ -1538,7 +1538,7 @@ declare module Immutable { * @see Collection.Keyed.mapEntries */ mapEntries( - mapper: (entry: [K, V], index: number, iter: this) => [KM, VM], + mapper: (entry: [K, V], index: number, iter: this) => [KM, VM] | undefined, context?: unknown ): OrderedMap; @@ -2825,7 +2825,7 @@ declare module Immutable { * @see Collection.Keyed.mapEntries */ mapEntries( - mapper: (entry: [K, V], index: number, iter: this) => [KM, VM], + mapper: (entry: [K, V], index: number, iter: this) => [KM, VM] | undefined, context?: unknown ): Seq.Keyed; @@ -3431,9 +3431,11 @@ declare module Immutable { * * Note: `mapEntries()` always returns a new instance, even if it produced * the same entry at every step. + * + * If the mapper function returns `undefined`, then the entry will be filtered */ mapEntries( - mapper: (entry: [K, V], index: number, iter: this) => [KM, VM], + mapper: (entry: [K, V], index: number, iter: this) => [KM, VM] | undefined, context?: unknown ): Collection.Keyed; @@ -4753,7 +4755,7 @@ declare module Immutable { /** * Like `max`, but also accepts a `comparatorValueMapper` which allows for * comparing by more sophisticated means: - * + * * * ```js * const { List, } = require('immutable'); @@ -4790,7 +4792,7 @@ declare module Immutable { /** * Like `min`, but also accepts a `comparatorValueMapper` which allows for * comparing by more sophisticated means: - * + * * * ```js * const { List, } = require('immutable'); @@ -5332,7 +5334,7 @@ declare module Immutable { export function update>( collection: C, key: K, - updater: (value: V) => V + updater: (value: V | undefined) => V ): C; export function update, NSV>( collection: C, From 5dbfc47d932d1b3f2a3ef2a0148b6a3be878e3cc Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 7 Jul 2021 23:51:31 +0000 Subject: [PATCH 156/242] deploy: 8afe18652ffb88dd20a5fa6c9c2fff932ff21a44 --- bower.json | 2 +- dist/immutable.es.js | 2 +- dist/immutable.js | 2 +- dist/immutable.min.js | 2 +- package.json | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/bower.json b/bower.json index 255e875132..9ae14f7824 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "immutable", - "version": "4.0.0-rc.13", + "version": "4.0.0-rc.14", "description": "Immutable Data Collections", "license": "MIT", "homepage": "https://immutable-js.com", diff --git a/dist/immutable.es.js b/dist/immutable.es.js index bb469c0e62..3be761f0f0 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -5828,7 +5828,7 @@ function defaultConverter(k, v) { return isKeyed(v) ? v.toMap() : v.toList(); } -var version = "4.0.0-rc.13"; +var version = "4.0.0-rc.14"; var Immutable = { version: version, diff --git a/dist/immutable.js b/dist/immutable.js index aff0fddaf7..bbc1c40ede 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -5834,7 +5834,7 @@ return isKeyed(v) ? v.toMap() : v.toList(); } - var version = "4.0.0-rc.13"; + var version = "4.0.0-rc.14"; var Immutable = { version: version, diff --git a/dist/immutable.min.js b/dist/immutable.min.js index 5d6d75a9a9..bd273ae4c2 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -51,5 +51,5 @@ return e=pt(e,3432918353),e=pt(e<<15|e>>>-15,461845907),e=pt(e<<13|e>>>-13,5),e= t.__iterateUncached=function(e,t){var r=this,n=0;return o.__iterate(function(t){return(!n||!1!==e(u,n++,r))&&!1!==e(t,n++,r)},t),n},t.__iteratorUncached=function(t,e){var r,n=o.__iterator(K,e),i=0;return new W(function(){return(!r||i%2)&&(r=n.next()).done?r:i%2?P(t,i++,u):P(t,i++,r.value,r)})},t));var o,u},interleave:function(){var t=[this].concat(Zt(arguments)),e=Jt(this.toSeq(),Z.of,t),r=e.flatten(!0);return e.size&&(r.size=e.size*t.length),Vt(this,r)},keySeq:function(){return Hr(0,this.size)},last:function(t){return this.get(-1,t)},skipWhile:function(t,e){return Vt(this,Bt(this,t,e,!1))},zip:function(){var t=[this].concat(Zt(arguments));return Vt(this,Jt(this,nn,t))},zipAll:function(){var t=[this].concat(Zt(arguments));return Vt(this,Jt(this,nn,t,!0))},zipWith:function(t){var e=Zt(arguments);return Vt(e[0]=this,Jt(this,t,e))}});var Gr=E.prototype;function Zr(t,n,i,o,u,e){return te(t.size),t.__iterate(function(t,e,r){i=u?(u=!1,t):n.call(o,i,t,e,r)},e),i}function $r(t,e){return e}function tn(t,e){return[e,t]}function en(t){return function(){return!t.apply(this,arguments)}}function rn(t){return function(){return-t.apply(this,arguments)}}function nn(){return Zt(arguments)}function on(t,e){return t>2)|0}Gr[z]=!0,Gr[k]=!0,Ur(M,{get:function(t,e){return this.has(t)?t:e},includes:function(t){return this.has(t)},keySeq:function(){return this.valueSeq()}}),M.prototype.has=Xr.includes,M.prototype.contains=M.prototype.includes,Ur(G,O.prototype),Ur(Z,E.prototype),Ur($,M.prototype);var sn=function(t){function e(r){return null==r?hn():kr(r)?r:hn().withMutations(function(e){var t=M(r);te(t.size),t.forEach(function(t){return e.add(t)})})}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).of=function(){return this(arguments)},e.fromKeys=function(t){return this(O(t).keySeq())},e.prototype.toString=function(){return this.__toString("OrderedSet {","}")},e}(Tr);sn.isOrderedSet=kr;var an,cn=sn.prototype;function fn(t,e){ var r=Object.create(cn);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function hn(){return an=an||fn(Sr())}cn[k]=!0,cn.zip=Gr.zip,cn.zipWith=Gr.zipWith,cn.zipAll=Gr.zipAll,cn.__empty=hn,cn.__make=fn;Fr=function(u,s){var a;!function(t){if(A(t))throw Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(x(t))throw Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(null===t||"object"!=typeof t)throw Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}(u);var c=function(t){var n=this;if(t instanceof c)return t;if(!(this instanceof c))return new c(t);if(!a){a=!0;var e=Object.keys(u),r=f._indices={};f._name=s,f._keys=e,f._defaultValues=u;for(var i=0;i Date: Thu, 8 Jul 2021 23:42:04 +0000 Subject: [PATCH 157/242] deploy: 858f4fde482259185a92c74a5aec106c6ef59103 --- dist/immutable-nonambient.d.ts | 34 +++++++++++++++++++++------------- dist/immutable.d.ts | 34 +++++++++++++++++++++------------- dist/immutable.js.flow | 2 +- 3 files changed, 43 insertions(+), 27 deletions(-) diff --git a/dist/immutable-nonambient.d.ts b/dist/immutable-nonambient.d.ts index 6d3a9e4b4b..66fa69cae5 100644 --- a/dist/immutable-nonambient.d.ts +++ b/dist/immutable-nonambient.d.ts @@ -171,7 +171,7 @@ * listFromPlainSet.equals(listFromPlainArray) // true * ``` */ - export function List(collection: Iterable): List; + export function List(collection: Iterable | ArrayLike): List; export function List(): List; export function List(): List; @@ -1641,7 +1641,7 @@ * Note: `Set` is a factory function and not a class, and does not use the * `new` keyword during construction. */ - export function Set(collection: Iterable): Set; + export function Set(collection: Iterable | ArrayLike): Set; export function Set(): Set; export function Set(): Set; @@ -1821,7 +1821,7 @@ * Note: `OrderedSet` is a factory function and not a class, and does not use * the `new` keyword during construction. */ - export function OrderedSet(collection: Iterable): OrderedSet; + export function OrderedSet(collection: Iterable | ArrayLike): OrderedSet; export function OrderedSet(): OrderedSet; export function OrderedSet(): OrderedSet; @@ -1987,7 +1987,7 @@ * Note: `Stack` is a factory function and not a class, and does not use the * `new` keyword during construction. */ - export function Stack(collection: Iterable): Stack; + export function Stack(collection: Iterable | ArrayLike): Stack; export function Stack(): Stack; export function Stack(): Stack; @@ -2859,6 +2859,8 @@ * @see Collection.Keyed.flip */ flip(): Seq.Keyed; + + [Symbol.iterator](): IterableIterator<[K, V]>; } /** @@ -2878,7 +2880,7 @@ * Note: `Seq.Indexed` is a conversion function and not a class, and does * not use the `new` keyword during construction. */ - export function Indexed(collection: Iterable): Seq.Indexed; + export function Indexed(collection: Iterable | ArrayLike): Seq.Indexed; export function Indexed(): Seq.Indexed; export function Indexed(): Seq.Indexed; @@ -3019,6 +3021,8 @@ zipper: (...any: Array) => Z, ...collections: Array> ): Seq.Indexed; + + [Symbol.iterator](): IterableIterator; } /** @@ -3040,7 +3044,7 @@ * Note: `Seq.Set` is a conversion function and not a class, and does not * use the `new` keyword during construction. */ - export function Set(collection: Iterable): Seq.Set; + export function Set(collection: Iterable | ArrayLike): Seq.Set; export function Set(): Seq.Set; export function Set(): Seq.Set; @@ -3115,6 +3119,8 @@ predicate: (value: T, key: T, iter: this) => unknown, context?: unknown ): this; + + [Symbol.iterator](): IterableIterator; } } @@ -3143,7 +3149,7 @@ ): Seq.Keyed; export function Seq(collection: Collection.Indexed): Seq.Indexed; export function Seq(collection: Collection.Set): Seq.Set; - export function Seq(collection: Iterable): Seq.Indexed; + export function Seq(collection: Iterable | ArrayLike): Seq.Indexed; export function Seq(obj: { [key: string]: V }): Seq.Keyed; export function Seq(): Seq; @@ -3431,7 +3437,7 @@ * * Note: `mapEntries()` always returns a new instance, even if it produced * the same entry at every step. - * + * * If the mapper function returns `undefined`, then the entry will be filtered */ mapEntries( @@ -3491,7 +3497,7 @@ * Note: `Collection.Indexed` is a conversion function and not a class, and * does not use the `new` keyword during construction. */ - export function Indexed(collection: Iterable): Collection.Indexed; + export function Indexed(collection: Iterable | ArrayLike): Collection.Indexed; export interface Indexed extends Collection { /** @@ -3788,7 +3794,7 @@ * Note: `Collection.Set` is a factory function and not a class, and does * not use the `new` keyword during construction. */ - export function Set(collection: Iterable): Collection.Set; + export function Set(collection: Iterable | ArrayLike): Collection.Set; export interface Set extends Collection { /** @@ -3891,7 +3897,7 @@ export function Collection>( collection: I ): I; - export function Collection(collection: Iterable): Collection.Indexed; + export function Collection(collection: Iterable | ArrayLike): Collection.Indexed; export function Collection(obj: { [key: string]: V; }): Collection.Keyed; @@ -4200,6 +4206,8 @@ */ entries(): IterableIterator<[K, V]>; + [Symbol.iterator](): IterableIterator; + // Collections (Seq) /** @@ -4942,7 +4950,7 @@ sequence: Collection.Keyed | Collection.Indexed, path?: Array ) => unknown - ): unknown; + ): Collection; /** * Value equality check with semantics similar to `Object.is`, but treats @@ -5414,7 +5422,7 @@ export function getIn( collection: unknown, keyPath: Iterable, - notSetValue: unknown + notSetValue?: unknown ): unknown; /** diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index 6c5ab1cc22..2020b6461f 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -171,7 +171,7 @@ declare module Immutable { * listFromPlainSet.equals(listFromPlainArray) // true * ``` */ - export function List(collection: Iterable): List; + export function List(collection: Iterable | ArrayLike): List; export function List(): List; export function List(): List; @@ -1641,7 +1641,7 @@ declare module Immutable { * Note: `Set` is a factory function and not a class, and does not use the * `new` keyword during construction. */ - export function Set(collection: Iterable): Set; + export function Set(collection: Iterable | ArrayLike): Set; export function Set(): Set; export function Set(): Set; @@ -1821,7 +1821,7 @@ declare module Immutable { * Note: `OrderedSet` is a factory function and not a class, and does not use * the `new` keyword during construction. */ - export function OrderedSet(collection: Iterable): OrderedSet; + export function OrderedSet(collection: Iterable | ArrayLike): OrderedSet; export function OrderedSet(): OrderedSet; export function OrderedSet(): OrderedSet; @@ -1987,7 +1987,7 @@ declare module Immutable { * Note: `Stack` is a factory function and not a class, and does not use the * `new` keyword during construction. */ - export function Stack(collection: Iterable): Stack; + export function Stack(collection: Iterable | ArrayLike): Stack; export function Stack(): Stack; export function Stack(): Stack; @@ -2859,6 +2859,8 @@ declare module Immutable { * @see Collection.Keyed.flip */ flip(): Seq.Keyed; + + [Symbol.iterator](): IterableIterator<[K, V]>; } /** @@ -2878,7 +2880,7 @@ declare module Immutable { * Note: `Seq.Indexed` is a conversion function and not a class, and does * not use the `new` keyword during construction. */ - export function Indexed(collection: Iterable): Seq.Indexed; + export function Indexed(collection: Iterable | ArrayLike): Seq.Indexed; export function Indexed(): Seq.Indexed; export function Indexed(): Seq.Indexed; @@ -3019,6 +3021,8 @@ declare module Immutable { zipper: (...any: Array) => Z, ...collections: Array> ): Seq.Indexed; + + [Symbol.iterator](): IterableIterator; } /** @@ -3040,7 +3044,7 @@ declare module Immutable { * Note: `Seq.Set` is a conversion function and not a class, and does not * use the `new` keyword during construction. */ - export function Set(collection: Iterable): Seq.Set; + export function Set(collection: Iterable | ArrayLike): Seq.Set; export function Set(): Seq.Set; export function Set(): Seq.Set; @@ -3115,6 +3119,8 @@ declare module Immutable { predicate: (value: T, key: T, iter: this) => unknown, context?: unknown ): this; + + [Symbol.iterator](): IterableIterator; } } @@ -3143,7 +3149,7 @@ declare module Immutable { ): Seq.Keyed; export function Seq(collection: Collection.Indexed): Seq.Indexed; export function Seq(collection: Collection.Set): Seq.Set; - export function Seq(collection: Iterable): Seq.Indexed; + export function Seq(collection: Iterable | ArrayLike): Seq.Indexed; export function Seq(obj: { [key: string]: V }): Seq.Keyed; export function Seq(): Seq; @@ -3431,7 +3437,7 @@ declare module Immutable { * * Note: `mapEntries()` always returns a new instance, even if it produced * the same entry at every step. - * + * * If the mapper function returns `undefined`, then the entry will be filtered */ mapEntries( @@ -3491,7 +3497,7 @@ declare module Immutable { * Note: `Collection.Indexed` is a conversion function and not a class, and * does not use the `new` keyword during construction. */ - export function Indexed(collection: Iterable): Collection.Indexed; + export function Indexed(collection: Iterable | ArrayLike): Collection.Indexed; export interface Indexed extends Collection { /** @@ -3788,7 +3794,7 @@ declare module Immutable { * Note: `Collection.Set` is a factory function and not a class, and does * not use the `new` keyword during construction. */ - export function Set(collection: Iterable): Collection.Set; + export function Set(collection: Iterable | ArrayLike): Collection.Set; export interface Set extends Collection { /** @@ -3891,7 +3897,7 @@ declare module Immutable { export function Collection>( collection: I ): I; - export function Collection(collection: Iterable): Collection.Indexed; + export function Collection(collection: Iterable | ArrayLike): Collection.Indexed; export function Collection(obj: { [key: string]: V; }): Collection.Keyed; @@ -4200,6 +4206,8 @@ declare module Immutable { */ entries(): IterableIterator<[K, V]>; + [Symbol.iterator](): IterableIterator; + // Collections (Seq) /** @@ -4942,7 +4950,7 @@ declare module Immutable { sequence: Collection.Keyed | Collection.Indexed, path?: Array ) => unknown - ): unknown; + ): Collection; /** * Value equality check with semantics similar to `Object.is`, but treats @@ -5414,7 +5422,7 @@ declare module Immutable { export function getIn( collection: unknown, keyPath: Iterable, - notSetValue: unknown + notSetValue?: unknown ): unknown; /** diff --git a/dist/immutable.js.flow b/dist/immutable.js.flow index b790e590dc..955b7dd5e6 100644 --- a/dist/immutable.js.flow +++ b/dist/immutable.js.flow @@ -1905,7 +1905,7 @@ declare function fromJS( sequence: KeyedCollection | IndexedCollection, path?: Array ) => mixed -): mixed; +): Collection; declare function is(first: mixed, second: mixed): boolean; declare function hash(value: mixed): number; From 493e5f446e5ff39af4fab49caacb88bae77f9495 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 15 Jul 2021 09:27:57 +0000 Subject: [PATCH 158/242] deploy: cc52cd75921ef06fc8585d9fc215a1f7eaf22d61 --- dist/immutable.es.js | 5 ++++ dist/immutable.js | 5 ++++ dist/immutable.min.js | 64 +++++++++++++++++++++---------------------- 3 files changed, 42 insertions(+), 32 deletions(-) diff --git a/dist/immutable.es.js b/dist/immutable.es.js index 3be761f0f0..ab99cd42b5 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -244,6 +244,11 @@ function iteratorDone() { } function hasIterator(maybeIterable) { + if (Array.isArray(maybeIterable)) { + // IE11 trick as it does not support `Symbol.iterator` + return true; + } + return !!getIteratorFn(maybeIterable); } diff --git a/dist/immutable.js b/dist/immutable.js index bbc1c40ede..51ede4d175 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -250,6 +250,11 @@ } function hasIterator(maybeIterable) { + if (Array.isArray(maybeIterable)) { + // IE11 trick as it does not support `Symbol.iterator` + return true; + } + return !!getIteratorFn(maybeIterable); } diff --git a/dist/immutable.min.js b/dist/immutable.min.js index bd273ae4c2..c03cacb84a 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -21,35 +21,35 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).Immutable={})}(this,function(t){"use strict";var e="delete",d=5,l=1<>>0;if(""+r!==e||4294967295==r)return NaN;e=r}return e<0?c(t)+e:e}function r(){return!0}function p(t,e,r){return(0===t&&!i(t)||void 0!==r&&t<=-r)&&(void 0===e||void 0!==r&&r<=e)}function y(t,e){return n(t,e,0)}function w(t,e){return n(t,e,e)}function n(t,e,r){return void 0===t?r:i(t)?e===1/0?e:0|Math.max(0,e+t):void 0===e||e===t?t:0|Math.min(e,t)}function i(t){return t<0||0===t&&1/t==-1/0}var o="@@__IMMUTABLE_ITERABLE__@@";function f(t){return!(!t||!t[o])}var s="@@__IMMUTABLE_KEYED__@@";function a(t){return!(!t||!t[s])}var z="@@__IMMUTABLE_INDEXED__@@";function S(t){return!(!t||!t[z])}function b(t){return a(t)||S(t)}function I(t){return f(t)?t:F(t)}var O=function(t){function e(t){return a(t)?t:G(t)}return e.__proto__=t,(e.prototype=Object.create(t.prototype)).constructor=e}(I),E=function(t){function e(t){return S(t)?t:Z(t)}return e.__proto__=t,(e.prototype=Object.create(t.prototype)).constructor=e}(I),M=function(t){function e(t){return f(t)&&!b(t)?t:$(t)}return e.__proto__=t,(e.prototype=Object.create(t.prototype)).constructor=e}(I);I.Keyed=O,I.Indexed=E,I.Set=M;var j="@@__IMMUTABLE_SEQ__@@";function q(t){return!(!t||!t[j])}var D="@@__IMMUTABLE_RECORD__@@";function A(t){return!(!t||!t[D])}function x(t){return f(t)||A(t)}var k="@@__IMMUTABLE_ORDERED__@@";function R(t){return!(!t||!t[k])}var U=0,K=1,T=2,C="function"==typeof Symbol&&Symbol.iterator,L="@@iterator",B=C||L,W=function(t){this.next=t};function P(t,e,r,n){r=0===t?e:1===t?r:[e,r];return n?n.value=r:n={value:r,done:!1},n}function N(){return{value:void 0,done:!0}}function H(t){return Y(t)}function J( -t){return t&&"function"==typeof t.next}function V(t){var e=Y(t);return e&&e.call(t)}function Y(t){t=t&&(C&&t[C]||t[L]);if("function"==typeof t)return t}W.prototype.toString=function(){return"[Iterator]"},W.KEYS=U,W.VALUES=K,W.ENTRIES=T,W.prototype.inspect=W.prototype.toSource=function(){return""+this},W.prototype[B]=function(){return this};var Q=Object.prototype.hasOwnProperty;function X(t){return Array.isArray(t)||"string"==typeof t||t&&"object"==typeof t&&Number.isInteger(t.length)&&0<=t.length&&(0===t.length?1===Object.keys(t).length:t.hasOwnProperty(t.length-1))}var F=function(t){function e(t){return null==t?it():x(t)?t.toSeq():function(t){var e=st(t);if(e)return e;if("object"!=typeof t)throw new TypeError("Expected Array or collection object of values, or keyed object: "+t);return new et(t)}(t)}return e.__proto__=t,((e.prototype=Object.create(t.prototype)).constructor=e).prototype.toSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq {","}")},e.prototype.cacheResult=function(){return!this._cache&&this.__iterateUncached&&(this._cache=this.entrySeq().toArray(),this.size=this._cache.length),this},e.prototype.__iterate=function(t,e){var r=this._cache;if(r){for(var n=r.length,i=0;i!==n;){var o=r[e?n-++i:i++];if(!1===t(o[1],o[0],this))break}return i}return this.__iterateUncached(t,e)},e.prototype.__iterator=function(e,r){var n=this._cache;if(n){var i=n.length,o=0;return new W(function(){if(o===i)return N();var t=n[r?i-++o:o++];return P(e,t[0],t[1])})}return this.__iteratorUncached(e,r)},e}(I),G=function(t){function e(t){return null==t?it().toKeyedSeq():f(t)?a(t)?t.toSeq():t.fromEntrySeq():A(t)?t.toSeq():ot(t)}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).prototype.toKeyedSeq=function(){return this},e}(F),Z=function(t){function e(t){return null==t?it():f(t)?a(t)?t.entrySeq():t.toIndexedSeq():A(t)?t.toSeq().entrySeq():ut(t)}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).of=function(){return e(arguments) -},e.prototype.toIndexedSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq [","]")},e}(F),$=function(t){function e(t){return(f(t)&&!b(t)?t:Z(t)).toSetSeq()}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).of=function(){return e(arguments)},e.prototype.toSetSeq=function(){return this},e}(F);F.isSeq=q,F.Keyed=G,F.Set=$,F.Indexed=Z,F.prototype[j]=!0;var tt=function(t){function e(t){this._array=t,this.size=t.length}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).prototype.get=function(t,e){return this.has(t)?this._array[h(this,t)]:e},e.prototype.__iterate=function(t,e){for(var r=this._array,n=r.length,i=0;i!==n;){var o=e?n-++i:i++;if(!1===t(r[o],o,this))break}return i},e.prototype.__iterator=function(e,r){var n=this._array,i=n.length,o=0;return new W(function(){if(o===i)return N();var t=r?i-++o:o++;return P(e,t,n[t])})},e}(Z),et=function(t){function e(t){var e=Object.keys(t);this._object=t,this._keys=e,this.size=e.length}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).prototype.get=function(t,e){return void 0===e||this.has(t)?this._object[t]:e},e.prototype.has=function(t){return Q.call(this._object,t)},e.prototype.__iterate=function(t,e){for(var r=this._object,n=this._keys,i=n.length,o=0;o!==i;){var u=n[e?i-++o:o++];if(!1===t(r[u],u,this))break}return o},e.prototype.__iterator=function(e,r){var n=this._object,i=this._keys,o=i.length,u=0;return new W(function(){if(u===o)return N();var t=i[r?o-++u:u++];return P(e,t,n[t])})},e}(G);et.prototype[k]=!0;var rt,nt=function(t){function e(t){this._collection=t,this.size=t.length||t.size}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).prototype.__iterateUncached=function(t,e){if(e)return this.cacheResult().__iterate(t,e);var r,n=V(this._collection),i=0;if(J(n))for(;!(r=n.next()).done&&!1!==t(r.value,i++,this););return i},e.prototype.__iteratorUncached=function(e,t){if(t)return this.cacheResult( -).__iterator(e,t);var r=V(this._collection);if(!J(r))return new W(N);var n=0;return new W(function(){var t=r.next();return t.done?t:P(e,n++,t.value)})},e}(Z);function it(){return rt=rt||new tt([])}function ot(t){var e=Array.isArray(t)?new tt(t):H(t)?new nt(t):void 0;if(e)return e.fromEntrySeq();if("object"==typeof t)return new et(t);throw new TypeError("Expected Array or collection object of [k, v] entries, or keyed object: "+t)}function ut(t){var e=st(t);if(e)return e;throw new TypeError("Expected Array or collection object of values: "+t)}function st(t){return X(t)?new tt(t):H(t)?new nt(t):void 0}var at="@@__IMMUTABLE_MAP__@@";function ct(t){return!(!t||!t[at])}function ft(t){return ct(t)&&R(t)}function ht(t){return!(!t||"function"!=typeof t.equals||"function"!=typeof t.hashCode)}function _t(t,e){if(t===e||t!=t&&e!=e)return!0;if(!t||!e)return!1;if("function"==typeof t.valueOf&&"function"==typeof e.valueOf){if((t=t.valueOf())===(e=e.valueOf())||t!=t&&e!=e)return!0;if(!t||!e)return!1}return!!(ht(t)&&ht(e)&&t.equals(e))}var pt="function"==typeof Math.imul&&-2==Math.imul(4294967295,2)?Math.imul:function(t,e){var r=65535&(t|=0),n=65535&(e|=0);return r*n+((t>>>16)*n+r*(e>>>16)<<16>>>0)|0};function lt(t){return t>>>1&1073741824|3221225471&t}var vt=Object.prototype.valueOf;function yt(t){if(null==t)return dt(t);if("function"==typeof t.hashCode)return lt(t.hashCode(t));var e,r=(e=t).valueOf!==vt&&"function"==typeof e.valueOf?e.valueOf(e):e;if(null==r)return dt(r);switch(typeof r){case"boolean":return r?1108378657:1108378656;case"number":return function(t){if(t!=t||t===1/0)return 0;var e=0|t;e!==t&&(e^=4294967295*t);for(;4294967295f)return N();var t=r.next();return a||e===K||t.done?t:P(e,i-1,e===U?void 0:t.value[1],t)})},r}function Bt(e,c,f,h){var t=Xt(e);return t.__iterateUncached=function(n,t){var i=this;if(t)return this.cacheResult().__iterate(n,t);var o=!0,u=0;return e.__iterate(function(t,e,r){if(!(o=o&&c.call(f,t,e,r)))return u++,n(t,h?e:u-1,i)}),u},t.__iteratorUncached=function(i,t){var o=this;if(t)return this.cacheResult().__iterator(i,t);var u=e.__iterator(T,t),s=!0,a=0;return new W(function(){var t;do{if((t=u.next()).done)return h||i===K?t:P(i,a++,i===U?void 0:t.value[1],t);var e=t.value,r=e[0],n=e[1];s=s&&c.call(f,n,r,o)}while(s);return i===T?t:P(i,r,n,t)})},t}function Wt(t,s,a){var c=Xt(t);return c.__iterateUncached=function(i,e){if(e)return this.cacheResult().__iterate(i,e);var o=0,u=!1;return function r(t,n){t.__iterate(function(t,e){return(!s||n>>t)&g),o=this.bitmap;return 0==(o&i)?n:this.nodes[$e(o&i-1)].get(t+d,e,r,n)},Le.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=yt(n));var s=(0===e?r:r>>>e)&g,a=1<>>=1)u[s]=1&r?e[o++]:void 0;return u[n]=i,new Be(t,o+1,u)}(t,_,c,s,u);if(f&&!u&&2===_.length&&Ge(_[1^h]))return _[1^h];if(f&&u&&1===_.length&&Ge(u))return u;s=t&&t===this.ownerID,a=f?u?c:c^a:c|a,u=f?u?tr(_,h,u,s):function(t,e,r){var n=t.length-1;if(r&&e===n)return t.pop(),t;for(var i=Array(n),o=0,u=0;u>>t)&g];return i?i.get(t+d,e,r,n):n},Be.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=yt(n));var s=(0===e?r:r>>>e)&g, -a=this.nodes,c=a[s];if(i===v&&!c)return this;o=Fe(c,t,e+d,r,n,i,o,u);if(o===c)return this;u=this.count;if(c){if(!o&&--u>>r)&g,u=(0===r?n:n>>>r)&g,t=o==u?[Ze(t,e,r+d,n,i)]:(i=new Pe(e,n,i),o>1&1431655765))+(t>>2&858993459))+(t>>4)&252645135,t+=t>>8,127&(t+=t>>16)}function tr(t,e,r,n){t=n?t:Zt(t);return t[e]=r,t}var er=l/4,rr=l/2,nr=l/4,ir="@@__IMMUTABLE_LIST__@@";function or(t){return!(!t||!t[ir])}var ur=function(o){function t(t){var e=pr();if(null==t)return e;if(or(t))return t;var n=o(t),i=n.size;return 0===i?e:(te(i),0=gr(t._capacity)?n=lr(n,t.__ownerID,0,e,r,o):i=lr(i,t.__ownerID,t._level,e,r,o);if(!o.value)return t;if(t.__ownerID)return t._root=i,t._tail=n,t.__hash=void 0,t.__altered=!0,t;return _r(t._origin,t._capacity,t._level,i,n)}(this,t,e)},t.prototype.remove=function(t){return this.has(t)?0===t?this.shift():t===this.size-1?this.pop():this.splice(t,1):this},t.prototype.insert=function(t,e){return this.splice(t,0,e)},t.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=this._origin=this._capacity=0,this._level=d,this._root=this._tail=this.__hash=void 0,this.__altered=!0,this):pr()},t.prototype.push=function(){var r=arguments,n=this.size;return this.withMutations(function(t){dr(t,0,n+r.length);for(var e=0;e>>e&g;if(this.array.length<=n)return new ar([],t);var i=0==n;if(0>>e&g;if(this.array.length<=n)return this;if(0>e,u=1+(c-r>>e);l>>r&g,a=t&&s=gr(t._capacity))return t._tail;if(e<1<>>n&g],n-=d;return r}}function dr(t,e,r){void 0!==e&&(e|=0),void 0!==r&&(r|=0);var n=t.__ownerID||new m,i=t._origin,o=t._capacity,u=i+e,s=void 0===r?o:r<0?o+r:i+r;if(u===i&&s===o)return t;if(s<=u)return t.clear();for(var a=t._level,c=t._root,f=0;u+f<0;)c=new ar(c&&c.array.length?[void 0,c]:[],n),f+=1<<(a+=d);f&&(u+=f,i+=f,s+=f,o+=f);for(var h=gr(o),_=gr(s);1<>>l&g,p=p.array[v]=vr(p.array[v],n);p.array[h>>>d&g]=e}if(s>>a&g;if(y!=_>>>a&g)break;y&&(f+=(1<>>d<>>-15,461845907),e=pt(e<<13|e>>>-13,5),e=pt((e=(e+3864292196|0)^t)^e>>>16,2246822507),e=lt((e=pt(e^e>>>13,3266489909))^e>>>16)}(t.__iterate(r?e?function(t,e){n=31*n+un(yt(t),yt(e))|0}:function(t,e){n=n+un(yt(t),yt(e))|0}:e?function(t){n=31*n+yt(t)|0}:function(t){n=n+yt(t)|0}),n)}(this))}});var Xr=I.prototype;Xr[o]=!0,Xr[B]=Xr.values,Xr.toJSON=Xr.toArray,Xr.__toStringMapper=oe,Xr.inspect=Xr.toSource=function(){return""+this},Xr.chain=Xr.flatMap,Xr.contains=Xr.includes,Ur(O,{flip:function(){return Vt(this,Ut(this))},mapEntries:function(r,n){var i=this,o=0;return Vt(this,this.toSeq().map(function(t,e){return r.call(n,[e,t],o++,i)}).fromEntrySeq())},mapKeys:function(r,n){var i=this;return Vt(this,this.toSeq().flip().map(function(t,e){return r.call(n,t,e,i)}).flip())}});var Fr=O.prototype;Fr[s]=!0,Fr[B]=Xr.entries,Fr.toJSON=Qr,Fr.__toStringMapper=function(t,e){return oe(e)+": "+oe(t)},Ur(E,{toKeyedSeq:function(){return new At(this,!1)},filter:function(t,e){return Vt(this,Ct(this,t,e,!1))},findIndex:function(t,e){e=this.findEntry(t,e);return e?e[0]:-1},indexOf:function(t){t=this.keyOf(t);return void 0===t?-1:t},lastIndexOf:function(t){t=this.lastKeyOf(t);return void 0===t?-1:t},reverse:function(){return Vt(this,Tt(this,!1))},slice:function(t,e){return Vt(this,Lt(this,t,e,!1))},splice:function(t,e){var r=arguments.length;if(e=Math.max(e||0,0),0===r||2===r&&!e)return this;t=y(t,t<0?this.count():this.size);var n=this.slice(0,t);return Vt(this,1===r?n:n.concat(Zt(arguments,2),this.slice(t+e)))},findLastIndex:function(t,e){e=this.findLastEntry(t,e);return e?e[0]:-1},first:function(t){return this.get(0,t)},flatten:function(t){return Vt(this,Wt(this,t,!1))},get:function(r,t){return(r=h(this,r))<0||this.size===1/0||void 0!==this.size&&this.size>2)|0}Gr[z]=!0,Gr[k]=!0,Ur(M,{get:function(t,e){return this.has(t)?t:e},includes:function(t){return this.has(t)},keySeq:function(){return this.valueSeq()}}),M.prototype.has=Xr.includes,M.prototype.contains=M.prototype.includes,Ur(G,O.prototype),Ur(Z,E.prototype),Ur($,M.prototype);var sn=function(t){function e(r){return null==r?hn():kr(r)?r:hn().withMutations(function(e){var t=M(r);te(t.size),t.forEach(function(t){return e.add(t)})})}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).of=function(){return this(arguments)},e.fromKeys=function(t){return this(O(t).keySeq())},e.prototype.toString=function(){return this.__toString("OrderedSet {","}")},e}(Tr);sn.isOrderedSet=kr;var an,cn=sn.prototype;function fn(t,e){ -var r=Object.create(cn);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function hn(){return an=an||fn(Sr())}cn[k]=!0,cn.zip=Gr.zip,cn.zipWith=Gr.zipWith,cn.zipAll=Gr.zipAll,cn.__empty=hn,cn.__make=fn;Fr=function(u,s){var a;!function(t){if(A(t))throw Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(x(t))throw Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(null===t||"object"!=typeof t)throw Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}(u);var c=function(t){var n=this;if(t instanceof c)return t;if(!(this instanceof c))return new c(t);if(!a){a=!0;var e=Object.keys(u),r=f._indices={};f._name=s,f._keys=e,f._defaultValues=u;for(var i=0;i>>0;if(""+r!==e||4294967295==r)return NaN;e=r}return e<0?c(t)+e:e}function r(){return!0}function p(t,e,r){return(0===t&&!i(t)||void 0!==r&&t<=-r)&&(void 0===e||void 0!==r&&r<=e)}function y(t,e){return n(t,e,0)}function w(t,e){return n(t,e,e)}function n(t,e,r){return void 0===t?r:i(t)?e===1/0?e:0|Math.max(0,e+t):void 0===e||e===t?t:0|Math.min(e,t)}function i(t){return t<0||0===t&&1/t==-1/0}var o="@@__IMMUTABLE_ITERABLE__@@";function f(t){return!(!t||!t[o])}var s="@@__IMMUTABLE_KEYED__@@";function a(t){return!(!t||!t[s])}var z="@@__IMMUTABLE_INDEXED__@@";function S(t){return!(!t||!t[z])}function b(t){return a(t)||S(t)}function I(t){return f(t)?t:F(t)}var O=function(t){function e(t){return a(t)?t:G(t)}return e.__proto__=t,(e.prototype=Object.create(t.prototype)).constructor=e}(I),E=function(t){function e(t){return S(t)?t:Z(t)}return e.__proto__=t,(e.prototype=Object.create(t.prototype)).constructor=e}(I),M=function(t){function e(t){return f(t)&&!b(t)?t:$(t)}return e.__proto__=t,(e.prototype=Object.create(t.prototype)).constructor=e}(I);I.Keyed=O,I.Indexed=E,I.Set=M;var j="@@__IMMUTABLE_SEQ__@@";function q(t){return!(!t||!t[j])}var D="@@__IMMUTABLE_RECORD__@@";function A(t){return!(!t||!t[D])}function x(t){return f(t)||A(t)}var k="@@__IMMUTABLE_ORDERED__@@";function R(t){return!(!t||!t[k])}var U=0,K=1,T=2,C="function"==typeof Symbol&&Symbol.iterator,L="@@iterator",B=C||L,W=function(t){this.next=t};function P(t,e,r,n){r=0===t?e:1===t?r:[e,r];return n?n.value=r:n={value:r,done:!1},n}function N(){return{value:void 0,done:!0}}function H(t){return Array.isArray(t +)||Y(t)}function J(t){return t&&"function"==typeof t.next}function V(t){var e=Y(t);return e&&e.call(t)}function Y(t){t=t&&(C&&t[C]||t[L]);if("function"==typeof t)return t}W.prototype.toString=function(){return"[Iterator]"},W.KEYS=U,W.VALUES=K,W.ENTRIES=T,W.prototype.inspect=W.prototype.toSource=function(){return""+this},W.prototype[B]=function(){return this};var Q=Object.prototype.hasOwnProperty;function X(t){return Array.isArray(t)||"string"==typeof t||t&&"object"==typeof t&&Number.isInteger(t.length)&&0<=t.length&&(0===t.length?1===Object.keys(t).length:t.hasOwnProperty(t.length-1))}var F=function(t){function e(t){return null==t?it():x(t)?t.toSeq():function(t){var e=st(t);if(e)return e;if("object"!=typeof t)throw new TypeError("Expected Array or collection object of values, or keyed object: "+t);return new et(t)}(t)}return e.__proto__=t,((e.prototype=Object.create(t.prototype)).constructor=e).prototype.toSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq {","}")},e.prototype.cacheResult=function(){return!this._cache&&this.__iterateUncached&&(this._cache=this.entrySeq().toArray(),this.size=this._cache.length),this},e.prototype.__iterate=function(t,e){var r=this._cache;if(r){for(var n=r.length,i=0;i!==n;){var o=r[e?n-++i:i++];if(!1===t(o[1],o[0],this))break}return i}return this.__iterateUncached(t,e)},e.prototype.__iterator=function(e,r){var n=this._cache;if(n){var i=n.length,o=0;return new W(function(){if(o===i)return N();var t=n[r?i-++o:o++];return P(e,t[0],t[1])})}return this.__iteratorUncached(e,r)},e}(I),G=function(t){function e(t){return null==t?it().toKeyedSeq():f(t)?a(t)?t.toSeq():t.fromEntrySeq():A(t)?t.toSeq():ot(t)}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).prototype.toKeyedSeq=function(){return this},e}(F),Z=function(t){function e(t){return null==t?it():f(t)?a(t)?t.entrySeq():t.toIndexedSeq():A(t)?t.toSeq().entrySeq():ut(t)}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).of=function(){ +return e(arguments)},e.prototype.toIndexedSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq [","]")},e}(F),$=function(t){function e(t){return(f(t)&&!b(t)?t:Z(t)).toSetSeq()}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).of=function(){return e(arguments)},e.prototype.toSetSeq=function(){return this},e}(F);F.isSeq=q,F.Keyed=G,F.Set=$,F.Indexed=Z,F.prototype[j]=!0;var tt=function(t){function e(t){this._array=t,this.size=t.length}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).prototype.get=function(t,e){return this.has(t)?this._array[h(this,t)]:e},e.prototype.__iterate=function(t,e){for(var r=this._array,n=r.length,i=0;i!==n;){var o=e?n-++i:i++;if(!1===t(r[o],o,this))break}return i},e.prototype.__iterator=function(e,r){var n=this._array,i=n.length,o=0;return new W(function(){if(o===i)return N();var t=r?i-++o:o++;return P(e,t,n[t])})},e}(Z),et=function(t){function e(t){var e=Object.keys(t);this._object=t,this._keys=e,this.size=e.length}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).prototype.get=function(t,e){return void 0===e||this.has(t)?this._object[t]:e},e.prototype.has=function(t){return Q.call(this._object,t)},e.prototype.__iterate=function(t,e){for(var r=this._object,n=this._keys,i=n.length,o=0;o!==i;){var u=n[e?i-++o:o++];if(!1===t(r[u],u,this))break}return o},e.prototype.__iterator=function(e,r){var n=this._object,i=this._keys,o=i.length,u=0;return new W(function(){if(u===o)return N();var t=i[r?o-++u:u++];return P(e,t,n[t])})},e}(G);et.prototype[k]=!0;var rt,nt=function(t){function e(t){this._collection=t,this.size=t.length||t.size}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).prototype.__iterateUncached=function(t,e){if(e)return this.cacheResult().__iterate(t,e);var r,n=V(this._collection),i=0;if(J(n))for(;!(r=n.next()).done&&!1!==t(r.value,i++,this););return i},e.prototype.__iteratorUncached=function(e,t){if(t +)return this.cacheResult().__iterator(e,t);var r=V(this._collection);if(!J(r))return new W(N);var n=0;return new W(function(){var t=r.next();return t.done?t:P(e,n++,t.value)})},e}(Z);function it(){return rt=rt||new tt([])}function ot(t){var e=Array.isArray(t)?new tt(t):H(t)?new nt(t):void 0;if(e)return e.fromEntrySeq();if("object"==typeof t)return new et(t);throw new TypeError("Expected Array or collection object of [k, v] entries, or keyed object: "+t)}function ut(t){var e=st(t);if(e)return e;throw new TypeError("Expected Array or collection object of values: "+t)}function st(t){return X(t)?new tt(t):H(t)?new nt(t):void 0}var at="@@__IMMUTABLE_MAP__@@";function ct(t){return!(!t||!t[at])}function ft(t){return ct(t)&&R(t)}function ht(t){return!(!t||"function"!=typeof t.equals||"function"!=typeof t.hashCode)}function _t(t,e){if(t===e||t!=t&&e!=e)return!0;if(!t||!e)return!1;if("function"==typeof t.valueOf&&"function"==typeof e.valueOf){if((t=t.valueOf())===(e=e.valueOf())||t!=t&&e!=e)return!0;if(!t||!e)return!1}return!!(ht(t)&&ht(e)&&t.equals(e))}var pt="function"==typeof Math.imul&&-2==Math.imul(4294967295,2)?Math.imul:function(t,e){var r=65535&(t|=0),n=65535&(e|=0);return r*n+((t>>>16)*n+r*(e>>>16)<<16>>>0)|0};function lt(t){return t>>>1&1073741824|3221225471&t}var vt=Object.prototype.valueOf;function yt(t){if(null==t)return dt(t);if("function"==typeof t.hashCode)return lt(t.hashCode(t));var e,r=(e=t).valueOf!==vt&&"function"==typeof e.valueOf?e.valueOf(e):e;if(null==r)return dt(r);switch(typeof r){case"boolean":return r?1108378657:1108378656;case"number":return function(t){if(t!=t||t===1/0)return 0;var e=0|t;e!==t&&(e^=4294967295*t);for(;4294967295f)return N();var t=r.next();return a||e===K||t.done?t:P(e,i-1,e===U?void 0:t.value[1],t)})},r}function Bt(e,c,f,h){var t=Xt(e);return t.__iterateUncached=function(n,t){var i=this;if(t)return this.cacheResult().__iterate(n,t);var o=!0,u=0;return e.__iterate(function(t,e,r){if(!(o=o&&c.call(f,t,e,r)))return u++,n(t,h?e:u-1,i)}),u},t.__iteratorUncached=function(i,t){var o=this;if(t)return this.cacheResult().__iterator(i,t);var u=e.__iterator(T,t),s=!0,a=0;return new W(function(){var t;do{if((t=u.next()).done)return h||i===K?t:P(i,a++,i===U?void 0:t.value[1],t);var e=t.value,r=e[0],n=e[1];s=s&&c.call(f,n,r,o)}while(s);return i===T?t:P(i,r,n,t)})},t}function Wt(t,s,a){var c=Xt(t);return c.__iterateUncached=function(i,e){if(e)return this.cacheResult().__iterate(i,e);var o=0,u=!1;return function r(t,n){t.__iterate(function(t,e){return(!s||n>>t)&g),o=this.bitmap;return 0==(o&i)?n:this.nodes[$e(o&i-1)].get(t+d,e,r,n)},Le.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=yt(n));var s=(0===e?r:r>>>e)&g,a=1<>>=1)u[s]=1&r?e[o++]:void 0;return u[n]=i,new Be(t,o+1,u)}(t,_,c,s,u);if(f&&!u&&2===_.length&&Ge(_[1^h]))return _[1^h];if(f&&u&&1===_.length&&Ge(u))return u;s=t&&t===this.ownerID,a=f?u?c:c^a:c|a,u=f?u?tr(_,h,u,s):function(t,e,r){var n=t.length-1;if(r&&e===n)return t.pop(),t;for(var i=Array(n),o=0,u=0;u>>t)&g];return i?i.get(t+d,e,r,n):n}, +Be.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=yt(n));var s=(0===e?r:r>>>e)&g,a=this.nodes,c=a[s];if(i===v&&!c)return this;o=Fe(c,t,e+d,r,n,i,o,u);if(o===c)return this;u=this.count;if(c){if(!o&&--u>>r)&g,u=(0===r?n:n>>>r)&g,t=o==u?[Ze(t,e,r+d,n,i)]:(i=new Pe(e,n,i),o>1&1431655765))+(t>>2&858993459))+(t>>4)&252645135,t+=t>>8,127&(t+=t>>16)}function tr(t,e,r,n){t=n?t:Zt(t);return t[e]=r,t}var er=l/4,rr=l/2,nr=l/4,ir="@@__IMMUTABLE_LIST__@@";function or(t){return!(!t||!t[ir])}var ur=function(o){function t(t){var e=pr();if(null==t)return e;if(or(t))return t;var n=o(t),i=n.size;return 0===i?e:(te(i),0=gr(t._capacity)?n=lr(n,t.__ownerID,0,e,r,o):i=lr(i,t.__ownerID,t._level,e,r,o);if(!o.value)return t;if(t.__ownerID)return t._root=i,t._tail=n,t.__hash=void 0,t.__altered=!0,t;return _r(t._origin,t._capacity,t._level,i,n)}(this,t,e)},t.prototype.remove=function(t){return this.has(t)?0===t?this.shift():t===this.size-1?this.pop():this.splice(t,1):this},t.prototype.insert=function(t,e){return this.splice(t,0,e)},t.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=this._origin=this._capacity=0,this._level=d,this._root=this._tail=this.__hash=void 0,this.__altered=!0,this):pr()},t.prototype.push=function(){var r=arguments,n=this.size;return this.withMutations(function(t){dr(t,0,n+r.length);for(var e=0;e>>e&g;if(this.array.length<=n)return new ar([],t);var i=0==n;if(0>>e&g;if(this.array.length<=n)return this;if(0>e,u=1+(c-r>>e);l>>r&g,a=t&&s=gr(t._capacity))return t._tail;if(e<1<>>n&g],n-=d;return r}}function dr(t,e,r){void 0!==e&&(e|=0),void 0!==r&&(r|=0);var n=t.__ownerID||new m,i=t._origin,o=t._capacity,u=i+e,s=void 0===r?o:r<0?o+r:i+r;if(u===i&&s===o)return t;if(s<=u)return t.clear();for(var a=t._level,c=t._root,f=0;u+f<0;)c=new ar(c&&c.array.length?[void 0,c]:[],n),f+=1<<(a+=d);f&&(u+=f,i+=f,s+=f,o+=f);for(var h=gr(o),_=gr(s);1<>>l&g,p=p.array[v]=vr(p.array[v],n);p.array[h>>>d&g]=e}if(s>>a&g;if(y!=_>>>a&g)break;y&&(f+=(1<>>d<>>-15,461845907),e=pt(e<<13|e>>>-13,5),e=pt((e=(e+3864292196|0)^t)^e>>>16,2246822507),e=lt((e=pt(e^e>>>13,3266489909))^e>>>16)}(t.__iterate(r?e?function(t,e){n=31*n+un(yt(t),yt(e))|0}:function(t,e){n=n+un(yt(t),yt(e))|0}:e?function(t){n=31*n+yt(t)|0}:function(t){n=n+yt(t)|0}),n)}(this))}});var Xr=I.prototype;Xr[o]=!0,Xr[B]=Xr.values,Xr.toJSON=Xr.toArray,Xr.__toStringMapper=oe,Xr.inspect=Xr.toSource=function(){return""+this},Xr.chain=Xr.flatMap,Xr.contains=Xr.includes,Ur(O,{flip:function(){return Vt(this,Ut(this))},mapEntries:function(r,n){var i=this,o=0;return Vt(this,this.toSeq().map(function(t,e){return r.call(n,[e,t],o++,i)}).fromEntrySeq())},mapKeys:function(r,n){var i=this;return Vt(this,this.toSeq().flip().map(function(t,e){return r.call(n,t,e,i)}).flip())}});var Fr=O.prototype;Fr[s]=!0,Fr[B]=Xr.entries,Fr.toJSON=Qr,Fr.__toStringMapper=function(t,e){return oe(e)+": "+oe(t)},Ur(E,{toKeyedSeq:function(){return new At(this,!1)},filter:function(t,e){return Vt(this,Ct(this,t,e,!1))},findIndex:function(t,e){e=this.findEntry(t,e);return e?e[0]:-1},indexOf:function(t){t=this.keyOf(t);return void 0===t?-1:t},lastIndexOf:function(t){t=this.lastKeyOf(t);return void 0===t?-1:t},reverse:function(){return Vt(this,Tt(this,!1))},slice:function(t,e){return Vt(this,Lt(this,t,e,!1))},splice:function(t,e){var r=arguments.length;if(e=Math.max(e||0,0),0===r||2===r&&!e)return this;t=y(t,t<0?this.count():this.size);var n=this.slice(0,t);return Vt(this,1===r?n:n.concat(Zt(arguments,2),this.slice(t+e)))},findLastIndex:function(t,e){e=this.findLastEntry(t,e);return e?e[0]:-1},first:function(t){return this.get(0,t)},flatten:function(t){return Vt(this,Wt(this,t,!1))},get:function(r,t){return(r=h(this,r))<0||this.size===1/0||void 0!==this.size&&this.size>2)|0}Gr[z]=!0,Gr[k]=!0,Ur(M,{get:function(t,e){return this.has(t)?t:e},includes:function(t){return this.has(t)},keySeq:function(){return this.valueSeq()}}),M.prototype.has=Xr.includes,M.prototype.contains=M.prototype.includes,Ur(G,O.prototype),Ur(Z,E.prototype),Ur($,M.prototype);var sn=function(t){function e(r){return null==r?hn():kr(r)?r:hn().withMutations(function(e){var t=M(r);te(t.size),t.forEach(function(t){return e.add(t)})})}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).of=function(){return this(arguments)},e.fromKeys=function(t){return this(O(t).keySeq())}, +e.prototype.toString=function(){return this.__toString("OrderedSet {","}")},e}(Tr);sn.isOrderedSet=kr;var an,cn=sn.prototype;function fn(t,e){var r=Object.create(cn);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function hn(){return an=an||fn(Sr())}cn[k]=!0,cn.zip=Gr.zip,cn.zipWith=Gr.zipWith,cn.zipAll=Gr.zipAll,cn.__empty=hn,cn.__make=fn;Fr=function(u,s){var a;!function(t){if(A(t))throw Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(x(t))throw Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(null===t||"object"!=typeof t)throw Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}(u);var c=function(t){var n=this;if(t instanceof c)return t;if(!(this instanceof c))return new c(t);if(!a){a=!0;var e=Object.keys(u),r=f._indices={};f._name=s,f._keys=e,f._defaultValues=u;for(var i=0;i Date: Fri, 16 Jul 2021 05:15:21 +0000 Subject: [PATCH 159/242] deploy: d2f9729b9e6e61eaf53eebb4b1db393c65bfe2e4 --- bower.json | 1 + package.json | 1 + 2 files changed, 2 insertions(+) diff --git a/bower.json b/bower.json index 9ae14f7824..e211c49c3e 100644 --- a/bower.json +++ b/bower.json @@ -17,6 +17,7 @@ }, "main": "dist/immutable.js", "module": "dist/immutable.es.js", + "sideEffects": false, "typings": "dist/immutable-nonambient.d.ts", "typescript": { "definition": "dist/immutable.d.ts" diff --git a/package.json b/package.json index 9ae14f7824..e211c49c3e 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ }, "main": "dist/immutable.js", "module": "dist/immutable.es.js", + "sideEffects": false, "typings": "dist/immutable-nonambient.d.ts", "typescript": { "definition": "dist/immutable.d.ts" From 317c460b9b5fd84288852b3336c376660e315508 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 16 Jul 2021 07:06:19 +0000 Subject: [PATCH 160/242] deploy: e80d8fae2b6a14079aaec05ed9a28b4efa862583 --- dist/immutable-nonambient.d.ts | 165 +++++++++++++++++--------------- dist/immutable.d.ts | 167 +++++++++++++++++---------------- dist/immutable.js.flow | 12 ++- 3 files changed, 183 insertions(+), 161 deletions(-) diff --git a/dist/immutable-nonambient.d.ts b/dist/immutable-nonambient.d.ts index 66fa69cae5..77af25075c 100644 --- a/dist/immutable-nonambient.d.ts +++ b/dist/immutable-nonambient.d.ts @@ -105,7 +105,7 @@ * "unset" index and an index set to `undefined`. `List#forEach` visits all * indices from 0 to size, regardless of whether they were explicitly defined. */ - export module List { + export namespace List { /** * True if the provided value is a List * @@ -171,9 +171,7 @@ * listFromPlainSet.equals(listFromPlainArray) // true * ``` */ - export function List(collection: Iterable | ArrayLike): List; - export function List(): List; - export function List(): List; + export function List(collection?: Iterable | ArrayLike): List; export interface List extends Collection.Indexed { /** @@ -661,7 +659,7 @@ thirdCollection: Collection ): List; zipWith( - zipper: (...any: Array) => Z, + zipper: (...values: Array) => Z, ...collections: Array> ): List; } @@ -693,7 +691,7 @@ * * Implemented by a hash-array mapped trie. */ - export module Map { + export namespace Map { /** * True if the provided value is a Map * @@ -761,9 +759,7 @@ * but since Immutable Map keys can be of any type the argument to `get()` is * not altered. */ - export function Map(): Map; - export function Map(): Map; - export function Map(collection: Iterable<[K, V]>): Map; + export function Map(collection?: Iterable<[K, V]>): Map; export function Map(obj: { [key: string]: V }): Map; export function Map(obj: { [P in K]?: V }): Map; @@ -1061,7 +1057,7 @@ * // "c": Map { "z": 3 } * // } * ``` - + * * Note: `mergeDeepWith` can be used in `withMutations`. */ mergeDeepWith( @@ -1367,7 +1363,11 @@ * @see Collection.Keyed.mapEntries */ mapEntries( - mapper: (entry: [K, V], index: number, iter: this) => [KM, VM] | undefined, + mapper: ( + entry: [K, V], + index: number, + iter: this + ) => [KM, VM] | undefined, context?: unknown ): Map; @@ -1415,7 +1415,7 @@ * stable. */ - export module OrderedMap { + export namespace OrderedMap { /** * True if the provided value is an OrderedMap. */ @@ -1439,10 +1439,8 @@ * Note: `OrderedMap` is a factory function and not a class, and does not use * the `new` keyword during construction. */ - export function OrderedMap(): OrderedMap; - export function OrderedMap(): OrderedMap; export function OrderedMap( - collection: Iterable<[K, V]> + collection?: Iterable<[K, V]> ): OrderedMap; export function OrderedMap(obj: { [key: string]: V; @@ -1538,7 +1536,11 @@ * @see Collection.Keyed.mapEntries */ mapEntries( - mapper: (entry: [K, V], index: number, iter: this) => [KM, VM] | undefined, + mapper: ( + entry: [K, V], + index: number, + iter: this + ) => [KM, VM] | undefined, context?: unknown ): OrderedMap; @@ -1585,7 +1587,7 @@ * `Immutable.is`, enabling Sets to uniquely include other Immutable * collections, custom value types, and NaN. */ - export module Set { + export namespace Set { /** * True if the provided value is a Set */ @@ -1641,9 +1643,7 @@ * Note: `Set` is a factory function and not a class, and does not use the * `new` keyword during construction. */ - export function Set(collection: Iterable | ArrayLike): Set; - export function Set(): Set; - export function Set(): Set; + export function Set(collection?: Iterable | ArrayLike): Set; export interface Set extends Collection.Set { /** @@ -1795,7 +1795,7 @@ * consume more memory. `OrderedSet#add` is amortized O(log32 N), but not * stable. */ - export module OrderedSet { + export namespace OrderedSet { /** * True if the provided value is an OrderedSet. */ @@ -1821,9 +1821,9 @@ * Note: `OrderedSet` is a factory function and not a class, and does not use * the `new` keyword during construction. */ - export function OrderedSet(collection: Iterable | ArrayLike): OrderedSet; - export function OrderedSet(): OrderedSet; - export function OrderedSet(): OrderedSet; + export function OrderedSet( + collection?: Iterable | ArrayLike + ): OrderedSet; export interface OrderedSet extends Set { /** @@ -1947,7 +1947,7 @@ thirdCollection: Collection ): OrderedSet; zipWith( - zipper: (...any: Array) => Z, + zipper: (...values: Array) => Z, ...collections: Array> ): OrderedSet; } @@ -1965,7 +1965,7 @@ * * Stack is implemented with a Single-Linked List. */ - export module Stack { + export namespace Stack { /** * True if the provided value is a Stack */ @@ -1987,9 +1987,7 @@ * Note: `Stack` is a factory function and not a class, and does not use the * `new` keyword during construction. */ - export function Stack(collection: Iterable | ArrayLike): Stack; - export function Stack(): Stack; - export function Stack(): Stack; + export function Stack(collection?: Iterable | ArrayLike): Stack; export interface Stack extends Collection.Indexed { /** @@ -2197,7 +2195,7 @@ thirdCollection: Collection ): Stack; zipWith( - zipper: (...any: Array) => Z, + zipper: (...values: Array) => Z, ...collections: Array> ): Stack; } @@ -2400,7 +2398,7 @@ * form isn't free. If converting Records to plain objects is common, * consider sticking with plain objects to begin with. */ - export module Record { + export namespace Record { /** * True if `maybeRecord` is an instance of a Record. */ @@ -2473,15 +2471,14 @@ * const alan: Person = makePerson({ name: 'Alan' }); * ``` */ - export module Factory {} + export namespace Factory {} - export interface Factory { + export interface Factory { (values?: Partial | Iterable<[string, unknown]>): Record & Readonly; - new (values?: Partial | Iterable<[string, unknown]>): Record< - TProps - > & - Readonly; + new ( + values?: Partial | Iterable<[string, unknown]> + ): Record & Readonly; /** * The name provided to `Record(values, name)` can be accessed with @@ -2490,7 +2487,7 @@ displayName: string; } - export function Factory( + export function Factory( values?: Partial | Iterable<[string, unknown]> ): Record & Readonly; } @@ -2504,12 +2501,12 @@ * Note: `Record` is a factory function and not a class, and does not use the * `new` keyword during construction. */ - export function Record( + export function Record( defaultValues: TProps, name?: string ): Record.Factory; - export interface Record { + export interface Record { // Reading values has(key: string): key is keyof TProps & string; @@ -2650,7 +2647,7 @@ * * This is equivalent to an instance of a record created by a Record Factory. */ - export type RecordOf = Record & + export type RecordOf = Record & Readonly; /** @@ -2728,7 +2725,7 @@ * ``` */ - export module Seq { + export namespace Seq { /** * True if `maybeSeq` is a Seq, it is not backed by a concrete * structure such as Map, List, or Set. @@ -2743,7 +2740,7 @@ /** * `Seq` which represents key-value pairs. */ - export module Keyed {} + export namespace Keyed {} /** * Always returns a Seq.Keyed, if input is not keyed, expects an @@ -2752,10 +2749,8 @@ * Note: `Seq.Keyed` is a conversion function and not a class, and does not * use the `new` keyword during construction. */ - export function Keyed(collection: Iterable<[K, V]>): Seq.Keyed; + export function Keyed(collection?: Iterable<[K, V]>): Seq.Keyed; export function Keyed(obj: { [key: string]: V }): Seq.Keyed; - export function Keyed(): Seq.Keyed; - export function Keyed(): Seq.Keyed; export interface Keyed extends Seq, Collection.Keyed { /** @@ -2825,7 +2820,11 @@ * @see Collection.Keyed.mapEntries */ mapEntries( - mapper: (entry: [K, V], index: number, iter: this) => [KM, VM] | undefined, + mapper: ( + entry: [K, V], + index: number, + iter: this + ) => [KM, VM] | undefined, context?: unknown ): Seq.Keyed; @@ -2866,7 +2865,7 @@ /** * `Seq` which represents an ordered indexed list of values. */ - module Indexed { + namespace Indexed { /** * Provides an Seq.Indexed of the values provided. */ @@ -2880,9 +2879,9 @@ * Note: `Seq.Indexed` is a conversion function and not a class, and does * not use the `new` keyword during construction. */ - export function Indexed(collection: Iterable | ArrayLike): Seq.Indexed; - export function Indexed(): Seq.Indexed; - export function Indexed(): Seq.Indexed; + export function Indexed( + collection: Iterable | ArrayLike + ): Seq.Indexed; export interface Indexed extends Seq, Collection.Indexed { /** @@ -3018,7 +3017,7 @@ thirdCollection: Collection ): Seq.Indexed; zipWith( - zipper: (...any: Array) => Z, + zipper: (...values: Array) => Z, ...collections: Array> ): Seq.Indexed; @@ -3031,7 +3030,7 @@ * Because `Seq` are often lazy, `Seq.Set` does not provide the same guarantee * of value uniqueness as the concrete `Set`. */ - export module Set { + export namespace Set { /** * Returns a Seq.Set of the provided values */ @@ -3045,8 +3044,6 @@ * use the `new` keyword during construction. */ export function Set(collection: Iterable | ArrayLike): Seq.Set; - export function Set(): Seq.Set; - export function Set(): Seq.Set; export interface Set extends Seq, Collection.Set { /** @@ -3147,9 +3144,10 @@ export function Seq( collection: Collection.Keyed ): Seq.Keyed; - export function Seq(collection: Collection.Indexed): Seq.Indexed; export function Seq(collection: Collection.Set): Seq.Set; - export function Seq(collection: Iterable | ArrayLike): Seq.Indexed; + export function Seq( + collection: Collection.Indexed | Iterable | ArrayLike + ): Seq.Indexed; export function Seq(obj: { [key: string]: V }): Seq.Keyed; export function Seq(): Seq; @@ -3281,7 +3279,7 @@ * Implementations should extend one of the subclasses, `Collection.Keyed`, * `Collection.Indexed`, or `Collection.Set`. */ - export module Collection { + export namespace Collection { /** * @deprecated use `const { isKeyed } = require('immutable')` */ @@ -3317,7 +3315,7 @@ * tuple, in other words, `Collection#entries` is the default iterator for * Keyed Collections. */ - export module Keyed {} + export namespace Keyed {} /** * Creates a Collection.Keyed @@ -3441,7 +3439,11 @@ * If the mapper function returns `undefined`, then the entry will be filtered */ mapEntries( - mapper: (entry: [K, V], index: number, iter: this) => [KM, VM] | undefined, + mapper: ( + entry: [K, V], + index: number, + iter: this + ) => [KM, VM] | undefined, context?: unknown ): Collection.Keyed; @@ -3489,7 +3491,7 @@ * preserve indices, using them as keys, convert to a Collection.Keyed by * calling `toKeyedSeq`. */ - export module Indexed {} + export namespace Indexed {} /** * Creates a new Collection.Indexed. @@ -3497,7 +3499,9 @@ * Note: `Collection.Indexed` is a conversion function and not a class, and * does not use the `new` keyword during construction. */ - export function Indexed(collection: Iterable | ArrayLike): Collection.Indexed; + export function Indexed( + collection: Iterable | ArrayLike + ): Collection.Indexed; export interface Indexed extends Collection { /** @@ -3677,7 +3681,7 @@ thirdCollection: Collection ): Collection.Indexed; zipWith( - zipper: (...any: Array) => Z, + zipper: (...values: Array) => Z, ...collections: Array> ): Collection.Indexed; @@ -3786,7 +3790,7 @@ * ) * ``` */ - export module Set {} + export namespace Set {} /** * Similar to `Collection()`, but always returns a Collection.Set. @@ -3794,7 +3798,9 @@ * Note: `Collection.Set` is a factory function and not a class, and does * not use the `new` keyword during construction. */ - export function Set(collection: Iterable | ArrayLike): Collection.Set; + export function Set( + collection: Iterable | ArrayLike + ): Collection.Set; export interface Set extends Collection { /** @@ -3897,7 +3903,9 @@ export function Collection>( collection: I ): I; - export function Collection(collection: Iterable | ArrayLike): Collection.Indexed; + export function Collection( + collection: Iterable | ArrayLike + ): Collection.Indexed; export function Collection(obj: { [key: string]: V; }): Collection.Keyed; @@ -4253,7 +4261,7 @@ * * @ignore */ - map(...args: never[]): unknown; + map(...args: Array): unknown; /** * Returns a new Collection of the same type with only the entries for which @@ -4557,6 +4565,7 @@ * returns Collection */ flatten(depth?: number): Collection; + // tslint:disable-next-line unified-signatures flatten(shallow?: boolean): Collection; /** @@ -5198,7 +5207,7 @@ key: K, notSetValue: NSV ): V | NSV; - export function get( + export function get( record: Record, key: K, notSetValue: unknown @@ -5209,7 +5218,7 @@ key: number, notSetValue: NSV ): V | NSV; - export function get( + export function get( object: C, key: K, notSetValue: unknown @@ -5240,7 +5249,7 @@ * has({ x: 123, y: 456 }, 'z') // false * ``` */ - export function has(collection: Object, key: unknown): boolean; + export function has(collection: object, key: unknown): boolean; /** * Returns a copy of the collection with the value at key removed. @@ -5265,7 +5274,7 @@ key: K ): C; export function remove< - TProps, + TProps extends object, C extends Record, K extends keyof TProps >(collection: C, key: K): C; @@ -5303,11 +5312,11 @@ key: K, value: V ): C; - export function set, K extends keyof TProps>( - record: C, - key: K, - value: TProps[K] - ): C; + export function set< + TProps extends object, + C extends Record, + K extends keyof TProps + >(record: C, key: K, value: TProps[K]): C; export function set>( collection: C, key: number, @@ -5351,12 +5360,12 @@ updater: (value: V | NSV) => V ): C; export function update< - TProps, + TProps extends object, C extends Record, K extends keyof TProps >(record: C, key: K, updater: (value: TProps[K]) => TProps[K]): C; export function update< - TProps, + TProps extends object, C extends Record, K extends keyof TProps, NSV diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index 2020b6461f..dffc2d414c 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -90,7 +90,7 @@ * [Iterable]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols */ -declare module Immutable { +declare namespace Immutable { /** * Lists are ordered indexed dense collections, much like a JavaScript * Array. @@ -105,7 +105,7 @@ declare module Immutable { * "unset" index and an index set to `undefined`. `List#forEach` visits all * indices from 0 to size, regardless of whether they were explicitly defined. */ - export module List { + export namespace List { /** * True if the provided value is a List * @@ -171,9 +171,7 @@ declare module Immutable { * listFromPlainSet.equals(listFromPlainArray) // true * ``` */ - export function List(collection: Iterable | ArrayLike): List; - export function List(): List; - export function List(): List; + export function List(collection?: Iterable | ArrayLike): List; export interface List extends Collection.Indexed { /** @@ -661,7 +659,7 @@ declare module Immutable { thirdCollection: Collection ): List; zipWith( - zipper: (...any: Array) => Z, + zipper: (...values: Array) => Z, ...collections: Array> ): List; } @@ -693,7 +691,7 @@ declare module Immutable { * * Implemented by a hash-array mapped trie. */ - export module Map { + export namespace Map { /** * True if the provided value is a Map * @@ -761,9 +759,7 @@ declare module Immutable { * but since Immutable Map keys can be of any type the argument to `get()` is * not altered. */ - export function Map(): Map; - export function Map(): Map; - export function Map(collection: Iterable<[K, V]>): Map; + export function Map(collection?: Iterable<[K, V]>): Map; export function Map(obj: { [key: string]: V }): Map; export function Map(obj: { [P in K]?: V }): Map; @@ -1061,7 +1057,7 @@ declare module Immutable { * // "c": Map { "z": 3 } * // } * ``` - + * * Note: `mergeDeepWith` can be used in `withMutations`. */ mergeDeepWith( @@ -1367,7 +1363,11 @@ declare module Immutable { * @see Collection.Keyed.mapEntries */ mapEntries( - mapper: (entry: [K, V], index: number, iter: this) => [KM, VM] | undefined, + mapper: ( + entry: [K, V], + index: number, + iter: this + ) => [KM, VM] | undefined, context?: unknown ): Map; @@ -1415,7 +1415,7 @@ declare module Immutable { * stable. */ - export module OrderedMap { + export namespace OrderedMap { /** * True if the provided value is an OrderedMap. */ @@ -1439,10 +1439,8 @@ declare module Immutable { * Note: `OrderedMap` is a factory function and not a class, and does not use * the `new` keyword during construction. */ - export function OrderedMap(): OrderedMap; - export function OrderedMap(): OrderedMap; export function OrderedMap( - collection: Iterable<[K, V]> + collection?: Iterable<[K, V]> ): OrderedMap; export function OrderedMap(obj: { [key: string]: V; @@ -1538,7 +1536,11 @@ declare module Immutable { * @see Collection.Keyed.mapEntries */ mapEntries( - mapper: (entry: [K, V], index: number, iter: this) => [KM, VM] | undefined, + mapper: ( + entry: [K, V], + index: number, + iter: this + ) => [KM, VM] | undefined, context?: unknown ): OrderedMap; @@ -1585,7 +1587,7 @@ declare module Immutable { * `Immutable.is`, enabling Sets to uniquely include other Immutable * collections, custom value types, and NaN. */ - export module Set { + export namespace Set { /** * True if the provided value is a Set */ @@ -1641,9 +1643,7 @@ declare module Immutable { * Note: `Set` is a factory function and not a class, and does not use the * `new` keyword during construction. */ - export function Set(collection: Iterable | ArrayLike): Set; - export function Set(): Set; - export function Set(): Set; + export function Set(collection?: Iterable | ArrayLike): Set; export interface Set extends Collection.Set { /** @@ -1795,7 +1795,7 @@ declare module Immutable { * consume more memory. `OrderedSet#add` is amortized O(log32 N), but not * stable. */ - export module OrderedSet { + export namespace OrderedSet { /** * True if the provided value is an OrderedSet. */ @@ -1821,9 +1821,9 @@ declare module Immutable { * Note: `OrderedSet` is a factory function and not a class, and does not use * the `new` keyword during construction. */ - export function OrderedSet(collection: Iterable | ArrayLike): OrderedSet; - export function OrderedSet(): OrderedSet; - export function OrderedSet(): OrderedSet; + export function OrderedSet( + collection?: Iterable | ArrayLike + ): OrderedSet; export interface OrderedSet extends Set { /** @@ -1947,7 +1947,7 @@ declare module Immutable { thirdCollection: Collection ): OrderedSet; zipWith( - zipper: (...any: Array) => Z, + zipper: (...values: Array) => Z, ...collections: Array> ): OrderedSet; } @@ -1965,7 +1965,7 @@ declare module Immutable { * * Stack is implemented with a Single-Linked List. */ - export module Stack { + export namespace Stack { /** * True if the provided value is a Stack */ @@ -1987,9 +1987,7 @@ declare module Immutable { * Note: `Stack` is a factory function and not a class, and does not use the * `new` keyword during construction. */ - export function Stack(collection: Iterable | ArrayLike): Stack; - export function Stack(): Stack; - export function Stack(): Stack; + export function Stack(collection?: Iterable | ArrayLike): Stack; export interface Stack extends Collection.Indexed { /** @@ -2197,7 +2195,7 @@ declare module Immutable { thirdCollection: Collection ): Stack; zipWith( - zipper: (...any: Array) => Z, + zipper: (...values: Array) => Z, ...collections: Array> ): Stack; } @@ -2400,7 +2398,7 @@ declare module Immutable { * form isn't free. If converting Records to plain objects is common, * consider sticking with plain objects to begin with. */ - export module Record { + export namespace Record { /** * True if `maybeRecord` is an instance of a Record. */ @@ -2473,15 +2471,14 @@ declare module Immutable { * const alan: Person = makePerson({ name: 'Alan' }); * ``` */ - export module Factory {} + export namespace Factory {} - export interface Factory { + export interface Factory { (values?: Partial | Iterable<[string, unknown]>): Record & Readonly; - new (values?: Partial | Iterable<[string, unknown]>): Record< - TProps - > & - Readonly; + new ( + values?: Partial | Iterable<[string, unknown]> + ): Record & Readonly; /** * The name provided to `Record(values, name)` can be accessed with @@ -2490,7 +2487,7 @@ declare module Immutable { displayName: string; } - export function Factory( + export function Factory( values?: Partial | Iterable<[string, unknown]> ): Record & Readonly; } @@ -2504,12 +2501,12 @@ declare module Immutable { * Note: `Record` is a factory function and not a class, and does not use the * `new` keyword during construction. */ - export function Record( + export function Record( defaultValues: TProps, name?: string ): Record.Factory; - export interface Record { + export interface Record { // Reading values has(key: string): key is keyof TProps & string; @@ -2650,7 +2647,7 @@ declare module Immutable { * * This is equivalent to an instance of a record created by a Record Factory. */ - export type RecordOf = Record & + export type RecordOf = Record & Readonly; /** @@ -2728,7 +2725,7 @@ declare module Immutable { * ``` */ - export module Seq { + export namespace Seq { /** * True if `maybeSeq` is a Seq, it is not backed by a concrete * structure such as Map, List, or Set. @@ -2743,7 +2740,7 @@ declare module Immutable { /** * `Seq` which represents key-value pairs. */ - export module Keyed {} + export namespace Keyed {} /** * Always returns a Seq.Keyed, if input is not keyed, expects an @@ -2752,10 +2749,8 @@ declare module Immutable { * Note: `Seq.Keyed` is a conversion function and not a class, and does not * use the `new` keyword during construction. */ - export function Keyed(collection: Iterable<[K, V]>): Seq.Keyed; + export function Keyed(collection?: Iterable<[K, V]>): Seq.Keyed; export function Keyed(obj: { [key: string]: V }): Seq.Keyed; - export function Keyed(): Seq.Keyed; - export function Keyed(): Seq.Keyed; export interface Keyed extends Seq, Collection.Keyed { /** @@ -2825,7 +2820,11 @@ declare module Immutable { * @see Collection.Keyed.mapEntries */ mapEntries( - mapper: (entry: [K, V], index: number, iter: this) => [KM, VM] | undefined, + mapper: ( + entry: [K, V], + index: number, + iter: this + ) => [KM, VM] | undefined, context?: unknown ): Seq.Keyed; @@ -2866,7 +2865,7 @@ declare module Immutable { /** * `Seq` which represents an ordered indexed list of values. */ - module Indexed { + namespace Indexed { /** * Provides an Seq.Indexed of the values provided. */ @@ -2880,9 +2879,9 @@ declare module Immutable { * Note: `Seq.Indexed` is a conversion function and not a class, and does * not use the `new` keyword during construction. */ - export function Indexed(collection: Iterable | ArrayLike): Seq.Indexed; - export function Indexed(): Seq.Indexed; - export function Indexed(): Seq.Indexed; + export function Indexed( + collection: Iterable | ArrayLike + ): Seq.Indexed; export interface Indexed extends Seq, Collection.Indexed { /** @@ -3018,7 +3017,7 @@ declare module Immutable { thirdCollection: Collection ): Seq.Indexed; zipWith( - zipper: (...any: Array) => Z, + zipper: (...values: Array) => Z, ...collections: Array> ): Seq.Indexed; @@ -3031,7 +3030,7 @@ declare module Immutable { * Because `Seq` are often lazy, `Seq.Set` does not provide the same guarantee * of value uniqueness as the concrete `Set`. */ - export module Set { + export namespace Set { /** * Returns a Seq.Set of the provided values */ @@ -3045,8 +3044,6 @@ declare module Immutable { * use the `new` keyword during construction. */ export function Set(collection: Iterable | ArrayLike): Seq.Set; - export function Set(): Seq.Set; - export function Set(): Seq.Set; export interface Set extends Seq, Collection.Set { /** @@ -3147,9 +3144,10 @@ declare module Immutable { export function Seq( collection: Collection.Keyed ): Seq.Keyed; - export function Seq(collection: Collection.Indexed): Seq.Indexed; export function Seq(collection: Collection.Set): Seq.Set; - export function Seq(collection: Iterable | ArrayLike): Seq.Indexed; + export function Seq( + collection: Collection.Indexed | Iterable | ArrayLike + ): Seq.Indexed; export function Seq(obj: { [key: string]: V }): Seq.Keyed; export function Seq(): Seq; @@ -3281,7 +3279,7 @@ declare module Immutable { * Implementations should extend one of the subclasses, `Collection.Keyed`, * `Collection.Indexed`, or `Collection.Set`. */ - export module Collection { + export namespace Collection { /** * @deprecated use `const { isKeyed } = require('immutable')` */ @@ -3317,7 +3315,7 @@ declare module Immutable { * tuple, in other words, `Collection#entries` is the default iterator for * Keyed Collections. */ - export module Keyed {} + export namespace Keyed {} /** * Creates a Collection.Keyed @@ -3441,7 +3439,11 @@ declare module Immutable { * If the mapper function returns `undefined`, then the entry will be filtered */ mapEntries( - mapper: (entry: [K, V], index: number, iter: this) => [KM, VM] | undefined, + mapper: ( + entry: [K, V], + index: number, + iter: this + ) => [KM, VM] | undefined, context?: unknown ): Collection.Keyed; @@ -3489,7 +3491,7 @@ declare module Immutable { * preserve indices, using them as keys, convert to a Collection.Keyed by * calling `toKeyedSeq`. */ - export module Indexed {} + export namespace Indexed {} /** * Creates a new Collection.Indexed. @@ -3497,7 +3499,9 @@ declare module Immutable { * Note: `Collection.Indexed` is a conversion function and not a class, and * does not use the `new` keyword during construction. */ - export function Indexed(collection: Iterable | ArrayLike): Collection.Indexed; + export function Indexed( + collection: Iterable | ArrayLike + ): Collection.Indexed; export interface Indexed extends Collection { /** @@ -3677,7 +3681,7 @@ declare module Immutable { thirdCollection: Collection ): Collection.Indexed; zipWith( - zipper: (...any: Array) => Z, + zipper: (...values: Array) => Z, ...collections: Array> ): Collection.Indexed; @@ -3786,7 +3790,7 @@ declare module Immutable { * ) * ``` */ - export module Set {} + export namespace Set {} /** * Similar to `Collection()`, but always returns a Collection.Set. @@ -3794,7 +3798,9 @@ declare module Immutable { * Note: `Collection.Set` is a factory function and not a class, and does * not use the `new` keyword during construction. */ - export function Set(collection: Iterable | ArrayLike): Collection.Set; + export function Set( + collection: Iterable | ArrayLike + ): Collection.Set; export interface Set extends Collection { /** @@ -3897,7 +3903,9 @@ declare module Immutable { export function Collection>( collection: I ): I; - export function Collection(collection: Iterable | ArrayLike): Collection.Indexed; + export function Collection( + collection: Iterable | ArrayLike + ): Collection.Indexed; export function Collection(obj: { [key: string]: V; }): Collection.Keyed; @@ -4253,7 +4261,7 @@ declare module Immutable { * * @ignore */ - map(...args: never[]): unknown; + map(...args: Array): unknown; /** * Returns a new Collection of the same type with only the entries for which @@ -4557,6 +4565,7 @@ declare module Immutable { * returns Collection */ flatten(depth?: number): Collection; + // tslint:disable-next-line unified-signatures flatten(shallow?: boolean): Collection; /** @@ -5198,7 +5207,7 @@ declare module Immutable { key: K, notSetValue: NSV ): V | NSV; - export function get( + export function get( record: Record, key: K, notSetValue: unknown @@ -5209,7 +5218,7 @@ declare module Immutable { key: number, notSetValue: NSV ): V | NSV; - export function get( + export function get( object: C, key: K, notSetValue: unknown @@ -5240,7 +5249,7 @@ declare module Immutable { * has({ x: 123, y: 456 }, 'z') // false * ``` */ - export function has(collection: Object, key: unknown): boolean; + export function has(collection: object, key: unknown): boolean; /** * Returns a copy of the collection with the value at key removed. @@ -5265,7 +5274,7 @@ declare module Immutable { key: K ): C; export function remove< - TProps, + TProps extends object, C extends Record, K extends keyof TProps >(collection: C, key: K): C; @@ -5303,11 +5312,11 @@ declare module Immutable { key: K, value: V ): C; - export function set, K extends keyof TProps>( - record: C, - key: K, - value: TProps[K] - ): C; + export function set< + TProps extends object, + C extends Record, + K extends keyof TProps + >(record: C, key: K, value: TProps[K]): C; export function set>( collection: C, key: number, @@ -5351,12 +5360,12 @@ declare module Immutable { updater: (value: V | NSV) => V ): C; export function update< - TProps, + TProps extends object, C extends Record, K extends keyof TProps >(record: C, key: K, updater: (value: TProps[K]) => TProps[K]): C; export function update< - TProps, + TProps extends object, C extends Record, K extends keyof TProps, NSV diff --git a/dist/immutable.js.flow b/dist/immutable.js.flow index 955b7dd5e6..fde4bba0f7 100644 --- a/dist/immutable.js.flow +++ b/dist/immutable.js.flow @@ -593,7 +593,8 @@ declare class KeyedSeq extends Seq mixins KeyedCollection { declare class IndexedSeq<+T> extends Seq - mixins IndexedCollection { + mixins IndexedCollection +{ static (values?: Iterable): IndexedSeq; static of(...values: T[]): IndexedSeq; @@ -892,7 +893,8 @@ declare function isList(maybeList: mixed): boolean %checks(maybeList instanceof List); declare class List<+T> extends IndexedCollection - mixins UpdatableInCollection { + mixins UpdatableInCollection +{ static (collection?: Iterable): List; static of(...values: T[]): List; @@ -1050,7 +1052,8 @@ declare function isMap(maybeMap: mixed): boolean %checks(maybeMap instanceof Map); declare class Map extends KeyedCollection - mixins UpdatableInCollection { + mixins UpdatableInCollection +{ static (values?: Iterable<[K, V]> | PlainObjInput): Map; static isMap: typeof isMap; @@ -1147,7 +1150,8 @@ declare function isOrderedMap( ): boolean %checks(maybeOrderedMap instanceof OrderedMap); declare class OrderedMap extends Map - mixins UpdatableInCollection { + mixins UpdatableInCollection +{ static ( values?: Iterable<[K, V]> | PlainObjInput ): OrderedMap; From c773d432e89f5b07b9cb07722580dccef5daa8ba Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 20 Jul 2021 18:22:15 +0000 Subject: [PATCH 161/242] deploy: 351f9e65de1c5241562fd6e5f1a24f30af37d896 --- README.md | 2 +- bower.json | 5 +- dist/immutable-nonambient.d.ts | 5624 -------------------------------- dist/immutable.d.ts | 311 +- package.json | 5 +- 5 files changed, 149 insertions(+), 5798 deletions(-) delete mode 100644 dist/immutable-nonambient.d.ts diff --git a/README.md b/README.md index c0d6bdf5ff..fa89e1a7d9 100644 --- a/README.md +++ b/README.md @@ -618,7 +618,7 @@ Range(1, Infinity) [Read the docs](https://immutable-js.com) and eat your vegetables. -Docs are automatically generated from [Immutable.d.ts](https://github.com/immutable-js/immutable-js/blob/main/type-definitions/Immutable.d.ts). +Docs are automatically generated from [immutable.d.ts](https://github.com/immutable-js/immutable-js/blob/main/type-definitions/immutable.d.ts). Please contribute! Also, don't miss the [Wiki](https://github.com/immutable-js/immutable-js/wiki) which diff --git a/bower.json b/bower.json index e211c49c3e..ae9ce141d6 100644 --- a/bower.json +++ b/bower.json @@ -18,10 +18,7 @@ "main": "dist/immutable.js", "module": "dist/immutable.es.js", "sideEffects": false, - "typings": "dist/immutable-nonambient.d.ts", - "typescript": { - "definition": "dist/immutable.d.ts" - }, + "types": "dist/immutable.d.ts", "files": [ "dist", "README.md", diff --git a/dist/immutable-nonambient.d.ts b/dist/immutable-nonambient.d.ts deleted file mode 100644 index 77af25075c..0000000000 --- a/dist/immutable-nonambient.d.ts +++ /dev/null @@ -1,5624 +0,0 @@ -/** - * Immutable data encourages pure functions (data-in, data-out) and lends itself - * to much simpler application development and enabling techniques from - * functional programming such as lazy evaluation. - * - * While designed to bring these powerful functional concepts to JavaScript, it - * presents an Object-Oriented API familiar to Javascript engineers and closely - * mirroring that of Array, Map, and Set. It is easy and efficient to convert to - * and from plain Javascript types. - * - * ## How to read these docs - * - * In order to better explain what kinds of values the Immutable.js API expects - * and produces, this documentation is presented in a statically typed dialect of - * JavaScript (like [Flow][] or [TypeScript][]). You *don't need* to use these - * type checking tools in order to use Immutable.js, however becoming familiar - * with their syntax will help you get a deeper understanding of this API. - * - * **A few examples and how to read them.** - * - * All methods describe the kinds of data they accept and the kinds of data - * they return. For example a function which accepts two numbers and returns - * a number would look like this: - * - * ```js - * sum(first: number, second: number): number - * ``` - * - * Sometimes, methods can accept different kinds of data or return different - * kinds of data, and this is described with a *type variable*, which is - * typically in all-caps. For example, a function which always returns the same - * kind of data it was provided would look like this: - * - * ```js - * identity(value: T): T - * ``` - * - * Type variables are defined with classes and referred to in methods. For - * example, a class that holds onto a value for you might look like this: - * - * ```js - * class Box { - * constructor(value: T) - * getValue(): T - * } - * ``` - * - * In order to manipulate Immutable data, methods that we're used to affecting - * a Collection instead return a new Collection of the same type. The type - * `this` refers to the same kind of class. For example, a List which returns - * new Lists when you `push` a value onto it might look like: - * - * ```js - * class List { - * push(value: T): this - * } - * ``` - * - * Many methods in Immutable.js accept values which implement the JavaScript - * [Iterable][] protocol, and might appear like `Iterable` for something - * which represents sequence of strings. Typically in JavaScript we use plain - * Arrays (`[]`) when an Iterable is expected, but also all of the Immutable.js - * collections are iterable themselves! - * - * For example, to get a value deep within a structure of data, we might use - * `getIn` which expects an `Iterable` path: - * - * ``` - * getIn(path: Iterable): unknown - * ``` - * - * To use this method, we could pass an array: `data.getIn([ "key", 2 ])`. - * - * - * Note: All examples are presented in the modern [ES2015][] version of - * JavaScript. Use tools like Babel to support older browsers. - * - * For example: - * - * ```js - * // ES2015 - * const mappedFoo = foo.map(x => x * x); - * // ES5 - * var mappedFoo = foo.map(function (x) { return x * x; }); - * ``` - * - * [ES2015]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/New_in_JavaScript/ECMAScript_6_support_in_Mozilla - * [TypeScript]: https://www.typescriptlang.org/ - * [Flow]: https://flowtype.org/ - * [Iterable]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols - */ - - - /** - * Lists are ordered indexed dense collections, much like a JavaScript - * Array. - * - * Lists are immutable and fully persistent with O(log32 N) gets and sets, - * and O(1) push and pop. - * - * Lists implement Deque, with efficient addition and removal from both the - * end (`push`, `pop`) and beginning (`unshift`, `shift`). - * - * Unlike a JavaScript Array, there is no distinction between an - * "unset" index and an index set to `undefined`. `List#forEach` visits all - * indices from 0 to size, regardless of whether they were explicitly defined. - */ - export namespace List { - /** - * True if the provided value is a List - * - * - * ```js - * const { List } = require('immutable'); - * List.isList([]); // false - * List.isList(List()); // true - * ``` - */ - function isList(maybeList: unknown): maybeList is List; - - /** - * Creates a new List containing `values`. - * - * - * ```js - * const { List } = require('immutable'); - * List.of(1, 2, 3, 4) - * // List [ 1, 2, 3, 4 ] - * ``` - * - * Note: Values are not altered or converted in any way. - * - * - * ```js - * const { List } = require('immutable'); - * List.of({x:1}, 2, [3], 4) - * // List [ { x: 1 }, 2, [ 3 ], 4 ] - * ``` - */ - function of(...values: Array): List; - } - - /** - * Create a new immutable List containing the values of the provided - * collection-like. - * - * Note: `List` is a factory function and not a class, and does not use the - * `new` keyword during construction. - * - * - * ```js - * const { List, Set } = require('immutable') - * - * const emptyList = List() - * // List [] - * - * const plainArray = [ 1, 2, 3, 4 ] - * const listFromPlainArray = List(plainArray) - * // List [ 1, 2, 3, 4 ] - * - * const plainSet = Set([ 1, 2, 3, 4 ]) - * const listFromPlainSet = List(plainSet) - * // List [ 1, 2, 3, 4 ] - * - * const arrayIterator = plainArray[Symbol.iterator]() - * const listFromCollectionArray = List(arrayIterator) - * // List [ 1, 2, 3, 4 ] - * - * listFromPlainArray.equals(listFromCollectionArray) // true - * listFromPlainSet.equals(listFromCollectionArray) // true - * listFromPlainSet.equals(listFromPlainArray) // true - * ``` - */ - export function List(collection?: Iterable | ArrayLike): List; - - export interface List extends Collection.Indexed { - /** - * The number of items in this List. - */ - readonly size: number; - - // Persistent changes - - /** - * Returns a new List which includes `value` at `index`. If `index` already - * exists in this List, it will be replaced. - * - * `index` may be a negative number, which indexes back from the end of the - * List. `v.set(-1, "value")` sets the last item in the List. - * - * If `index` larger than `size`, the returned List's `size` will be large - * enough to include the `index`. - * - * - * ```js - * const originalList = List([ 0 ]); - * // List [ 0 ] - * originalList.set(1, 1); - * // List [ 0, 1 ] - * originalList.set(0, 'overwritten'); - * // List [ "overwritten" ] - * originalList.set(2, 2); - * // List [ 0, undefined, 2 ] - * - * List().set(50000, 'value').size; - * // 50001 - * ``` - * - * Note: `set` can be used in `withMutations`. - */ - set(index: number, value: T): List; - - /** - * Returns a new List which excludes this `index` and with a size 1 less - * than this List. Values at indices above `index` are shifted down by 1 to - * fill the position. - * - * This is synonymous with `list.splice(index, 1)`. - * - * `index` may be a negative number, which indexes back from the end of the - * List. `v.delete(-1)` deletes the last item in the List. - * - * Note: `delete` cannot be safely used in IE8 - * - * - * ```js - * List([ 0, 1, 2, 3, 4 ]).delete(0); - * // List [ 1, 2, 3, 4 ] - * ``` - * - * Since `delete()` re-indexes values, it produces a complete copy, which - * has `O(N)` complexity. - * - * Note: `delete` *cannot* be used in `withMutations`. - * - * @alias remove - */ - delete(index: number): List; - remove(index: number): List; - - /** - * Returns a new List with `value` at `index` with a size 1 more than this - * List. Values at indices above `index` are shifted over by 1. - * - * This is synonymous with `list.splice(index, 0, value)`. - * - * - * ```js - * List([ 0, 1, 2, 3, 4 ]).insert(6, 5) - * // List [ 0, 1, 2, 3, 4, 5 ] - * ``` - * - * Since `insert()` re-indexes values, it produces a complete copy, which - * has `O(N)` complexity. - * - * Note: `insert` *cannot* be used in `withMutations`. - */ - insert(index: number, value: T): List; - - /** - * Returns a new List with 0 size and no values in constant time. - * - * - * ```js - * List([ 1, 2, 3, 4 ]).clear() - * // List [] - * ``` - * - * Note: `clear` can be used in `withMutations`. - */ - clear(): List; - - /** - * Returns a new List with the provided `values` appended, starting at this - * List's `size`. - * - * - * ```js - * List([ 1, 2, 3, 4 ]).push(5) - * // List [ 1, 2, 3, 4, 5 ] - * ``` - * - * Note: `push` can be used in `withMutations`. - */ - push(...values: Array): List; - - /** - * Returns a new List with a size ones less than this List, excluding - * the last index in this List. - * - * Note: this differs from `Array#pop` because it returns a new - * List rather than the removed value. Use `last()` to get the last value - * in this List. - * - * ```js - * List([ 1, 2, 3, 4 ]).pop() - * // List[ 1, 2, 3 ] - * ``` - * - * Note: `pop` can be used in `withMutations`. - */ - pop(): List; - - /** - * Returns a new List with the provided `values` prepended, shifting other - * values ahead to higher indices. - * - * - * ```js - * List([ 2, 3, 4]).unshift(1); - * // List [ 1, 2, 3, 4 ] - * ``` - * - * Note: `unshift` can be used in `withMutations`. - */ - unshift(...values: Array): List; - - /** - * Returns a new List with a size ones less than this List, excluding - * the first index in this List, shifting all other values to a lower index. - * - * Note: this differs from `Array#shift` because it returns a new - * List rather than the removed value. Use `first()` to get the first - * value in this List. - * - * - * ```js - * List([ 0, 1, 2, 3, 4 ]).shift(); - * // List [ 1, 2, 3, 4 ] - * ``` - * - * Note: `shift` can be used in `withMutations`. - */ - shift(): List; - - /** - * Returns a new List with an updated value at `index` with the return - * value of calling `updater` with the existing value, or `notSetValue` if - * `index` was not set. If called with a single argument, `updater` is - * called with the List itself. - * - * `index` may be a negative number, which indexes back from the end of the - * List. `v.update(-1)` updates the last item in the List. - * - * - * ```js - * const list = List([ 'a', 'b', 'c' ]) - * const result = list.update(2, val => val.toUpperCase()) - * // List [ "a", "b", "C" ] - * ``` - * - * This can be very useful as a way to "chain" a normal function into a - * sequence of methods. RxJS calls this "let" and lodash calls it "thru". - * - * For example, to sum a List after mapping and filtering: - * - * - * ```js - * function sum(collection) { - * return collection.reduce((sum, x) => sum + x, 0) - * } - * - * List([ 1, 2, 3 ]) - * .map(x => x + 1) - * .filter(x => x % 2 === 0) - * .update(sum) - * // 6 - * ``` - * - * Note: `update(index)` can be used in `withMutations`. - * - * @see `Map#update` - */ - update(index: number, notSetValue: T, updater: (value: T) => T): this; - update(index: number, updater: (value: T | undefined) => T): this; - update(updater: (value: this) => R): R; - - /** - * Returns a new List with size `size`. If `size` is less than this - * List's size, the new List will exclude values at the higher indices. - * If `size` is greater than this List's size, the new List will have - * undefined values for the newly available indices. - * - * When building a new List and the final size is known up front, `setSize` - * used in conjunction with `withMutations` may result in the more - * performant construction. - */ - setSize(size: number): List; - - // Deep persistent changes - - /** - * Returns a new List having set `value` at this `keyPath`. If any keys in - * `keyPath` do not exist, a new immutable Map will be created at that key. - * - * Index numbers are used as keys to determine the path to follow in - * the List. - * - * - * ```js - * const { List } = require('immutable') - * const list = List([ 0, 1, 2, List([ 3, 4 ])]) - * list.setIn([3, 0], 999); - * // List [ 0, 1, 2, List [ 999, 4 ] ] - * ``` - * - * Plain JavaScript Object or Arrays may be nested within an Immutable.js - * Collection, and setIn() can update those values as well, treating them - * immutably by creating new copies of those values with the changes applied. - * - * - * ```js - * const { List } = require('immutable') - * const list = List([ 0, 1, 2, { plain: 'object' }]) - * list.setIn([3, 'plain'], 'value'); - * // List([ 0, 1, 2, { plain: 'value' }]) - * ``` - * - * Note: `setIn` can be used in `withMutations`. - */ - setIn(keyPath: Iterable, value: unknown): this; - - /** - * Returns a new List having removed the value at this `keyPath`. If any - * keys in `keyPath` do not exist, no change will occur. - * - * - * ```js - * const { List } = require('immutable') - * const list = List([ 0, 1, 2, List([ 3, 4 ])]) - * list.deleteIn([3, 0]); - * // List [ 0, 1, 2, List [ 4 ] ] - * ``` - * - * Plain JavaScript Object or Arrays may be nested within an Immutable.js - * Collection, and removeIn() can update those values as well, treating them - * immutably by creating new copies of those values with the changes applied. - * - * - * ```js - * const { List } = require('immutable') - * const list = List([ 0, 1, 2, { plain: 'object' }]) - * list.removeIn([3, 'plain']); - * // List([ 0, 1, 2, {}]) - * ``` - * - * Note: `deleteIn` *cannot* be safely used in `withMutations`. - * - * @alias removeIn - */ - deleteIn(keyPath: Iterable): this; - removeIn(keyPath: Iterable): this; - - /** - * Note: `updateIn` can be used in `withMutations`. - * - * @see `Map#updateIn` - */ - updateIn( - keyPath: Iterable, - notSetValue: unknown, - updater: (value: unknown) => unknown - ): this; - updateIn( - keyPath: Iterable, - updater: (value: unknown) => unknown - ): this; - - /** - * Note: `mergeIn` can be used in `withMutations`. - * - * @see `Map#mergeIn` - */ - mergeIn(keyPath: Iterable, ...collections: Array): this; - - /** - * Note: `mergeDeepIn` can be used in `withMutations`. - * - * @see `Map#mergeDeepIn` - */ - mergeDeepIn( - keyPath: Iterable, - ...collections: Array - ): this; - - // Transient changes - - /** - * Note: Not all methods can be safely used on a mutable collection or within - * `withMutations`! Check the documentation for each method to see if it - * allows being used in `withMutations`. - * - * @see `Map#withMutations` - */ - withMutations(mutator: (mutable: this) => unknown): this; - - /** - * An alternative API for withMutations() - * - * Note: Not all methods can be safely used on a mutable collection or within - * `withMutations`! Check the documentation for each method to see if it - * allows being used in `withMutations`. - * - * @see `Map#asMutable` - */ - asMutable(): this; - - /** - * @see `Map#wasAltered` - */ - wasAltered(): boolean; - - /** - * @see `Map#asImmutable` - */ - asImmutable(): this; - - // Sequence algorithms - - /** - * Returns a new List with other values or collections concatenated to this one. - * - * Note: `concat` can be used in `withMutations`. - * - * @alias merge - */ - concat(...valuesOrCollections: Array | C>): List; - merge(...collections: Array>): List; - - /** - * Returns a new List with values passed through a - * `mapper` function. - * - * - * ```js - * List([ 1, 2 ]).map(x => 10 * x) - * // List [ 10, 20 ] - * ``` - */ - map( - mapper: (value: T, key: number, iter: this) => M, - context?: unknown - ): List; - - /** - * Flat-maps the List, returning a new List. - * - * Similar to `list.map(...).flatten(true)`. - */ - flatMap( - mapper: (value: T, key: number, iter: this) => Iterable, - context?: unknown - ): List; - - /** - * Returns a new List with only the values for which the `predicate` - * function returns true. - * - * Note: `filter()` always returns a new instance, even if it results in - * not filtering out any values. - */ - filter( - predicate: (value: T, index: number, iter: this) => value is F, - context?: unknown - ): List; - filter( - predicate: (value: T, index: number, iter: this) => unknown, - context?: unknown - ): this; - - /** - * Returns a List "zipped" with the provided collection. - * - * Like `zipWith`, but using the default `zipper`: creating an `Array`. - * - * - * ```js - * const a = List([ 1, 2, 3 ]); - * const b = List([ 4, 5, 6 ]); - * const c = a.zip(b); // List [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] - * ``` - */ - zip(other: Collection): List<[T, U]>; - zip( - other: Collection, - other2: Collection - ): List<[T, U, V]>; - zip(...collections: Array>): List; - - /** - * Returns a List "zipped" with the provided collections. - * - * Unlike `zip`, `zipAll` continues zipping until the longest collection is - * exhausted. Missing values from shorter collections are filled with `undefined`. - * - * - * ```js - * const a = List([ 1, 2 ]); - * const b = List([ 3, 4, 5 ]); - * const c = a.zipAll(b); // List [ [ 1, 3 ], [ 2, 4 ], [ undefined, 5 ] ] - * ``` - * - * Note: Since zipAll will return a collection as large as the largest - * input, some results may contain undefined values. TypeScript cannot - * account for these without cases (as of v2.5). - */ - zipAll(other: Collection): List<[T, U]>; - zipAll( - other: Collection, - other2: Collection - ): List<[T, U, V]>; - zipAll(...collections: Array>): List; - - /** - * Returns a List "zipped" with the provided collections by using a - * custom `zipper` function. - * - * - * ```js - * const a = List([ 1, 2, 3 ]); - * const b = List([ 4, 5, 6 ]); - * const c = a.zipWith((a, b) => a + b, b); - * // List [ 5, 7, 9 ] - * ``` - */ - zipWith( - zipper: (value: T, otherValue: U) => Z, - otherCollection: Collection - ): List; - zipWith( - zipper: (value: T, otherValue: U, thirdValue: V) => Z, - otherCollection: Collection, - thirdCollection: Collection - ): List; - zipWith( - zipper: (...values: Array) => Z, - ...collections: Array> - ): List; - } - - /** - * Immutable Map is an unordered Collection.Keyed of (key, value) pairs with - * `O(log32 N)` gets and `O(log32 N)` persistent sets. - * - * Iteration order of a Map is undefined, however is stable. Multiple - * iterations of the same Map will iterate in the same order. - * - * Map's keys can be of any type, and use `Immutable.is` to determine key - * equality. This allows the use of any value (including NaN) as a key. - * - * Because `Immutable.is` returns equality based on value semantics, and - * Immutable collections are treated as values, any Immutable collection may - * be used as a key. - * - * - * ```js - * const { Map, List } = require('immutable'); - * Map().set(List([ 1 ]), 'listofone').get(List([ 1 ])); - * // 'listofone' - * ``` - * - * Any JavaScript object may be used as a key, however strict identity is used - * to evaluate key equality. Two similar looking objects will represent two - * different keys. - * - * Implemented by a hash-array mapped trie. - */ - export namespace Map { - /** - * True if the provided value is a Map - * - * - * ```js - * const { Map } = require('immutable') - * Map.isMap({}) // false - * Map.isMap(Map()) // true - * ``` - */ - function isMap(maybeMap: unknown): maybeMap is Map; - - /** - * Creates a new Map from alternating keys and values - * - * - * ```js - * const { Map } = require('immutable') - * Map.of( - * 'key', 'value', - * 'numerical value', 3, - * 0, 'numerical key' - * ) - * // Map { 0: "numerical key", "key": "value", "numerical value": 3 } - * ``` - * - * @deprecated Use Map([ [ 'k', 'v' ] ]) or Map({ k: 'v' }) - */ - function of(...keyValues: Array): Map; - } - - /** - * Creates a new Immutable Map. - * - * Created with the same key value pairs as the provided Collection.Keyed or - * JavaScript Object or expects a Collection of [K, V] tuple entries. - * - * Note: `Map` is a factory function and not a class, and does not use the - * `new` keyword during construction. - * - * - * ```js - * const { Map } = require('immutable') - * Map({ key: "value" }) - * Map([ [ "key", "value" ] ]) - * ``` - * - * Keep in mind, when using JS objects to construct Immutable Maps, that - * JavaScript Object properties are always strings, even if written in a - * quote-less shorthand, while Immutable Maps accept keys of any type. - * - * - * ```js - * let obj = { 1: "one" } - * Object.keys(obj) // [ "1" ] - * assert.equal(obj["1"], obj[1]) // "one" === "one" - * - * let map = Map(obj) - * assert.notEqual(map.get("1"), map.get(1)) // "one" !== undefined - * ``` - * - * Property access for JavaScript Objects first converts the key to a string, - * but since Immutable Map keys can be of any type the argument to `get()` is - * not altered. - */ - export function Map(collection?: Iterable<[K, V]>): Map; - export function Map(obj: { [key: string]: V }): Map; - export function Map(obj: { [P in K]?: V }): Map; - - export interface Map extends Collection.Keyed { - /** - * The number of entries in this Map. - */ - readonly size: number; - - // Persistent changes - - /** - * Returns a new Map also containing the new key, value pair. If an equivalent - * key already exists in this Map, it will be replaced. - * - * - * ```js - * const { Map } = require('immutable') - * const originalMap = Map() - * const newerMap = originalMap.set('key', 'value') - * const newestMap = newerMap.set('key', 'newer value') - * - * originalMap - * // Map {} - * newerMap - * // Map { "key": "value" } - * newestMap - * // Map { "key": "newer value" } - * ``` - * - * Note: `set` can be used in `withMutations`. - */ - set(key: K, value: V): this; - - /** - * Returns a new Map which excludes this `key`. - * - * Note: `delete` cannot be safely used in IE8, but is provided to mirror - * the ES6 collection API. - * - * - * ```js - * const { Map } = require('immutable') - * const originalMap = Map({ - * key: 'value', - * otherKey: 'other value' - * }) - * // Map { "key": "value", "otherKey": "other value" } - * originalMap.delete('otherKey') - * // Map { "key": "value" } - * ``` - * - * Note: `delete` can be used in `withMutations`. - * - * @alias remove - */ - delete(key: K): this; - remove(key: K): this; - - /** - * Returns a new Map which excludes the provided `keys`. - * - * - * ```js - * const { Map } = require('immutable') - * const names = Map({ a: "Aaron", b: "Barry", c: "Connor" }) - * names.deleteAll([ 'a', 'c' ]) - * // Map { "b": "Barry" } - * ``` - * - * Note: `deleteAll` can be used in `withMutations`. - * - * @alias removeAll - */ - deleteAll(keys: Iterable): this; - removeAll(keys: Iterable): this; - - /** - * Returns a new Map containing no keys or values. - * - * - * ```js - * const { Map } = require('immutable') - * Map({ key: 'value' }).clear() - * // Map {} - * ``` - * - * Note: `clear` can be used in `withMutations`. - */ - clear(): this; - - /** - * Returns a new Map having updated the value at this `key` with the return - * value of calling `updater` with the existing value. - * - * Similar to: `map.set(key, updater(map.get(key)))`. - * - * - * ```js - * const { Map } = require('immutable') - * const aMap = Map({ key: 'value' }) - * const newMap = aMap.update('key', value => value + value) - * // Map { "key": "valuevalue" } - * ``` - * - * This is most commonly used to call methods on collections within a - * structure of data. For example, in order to `.push()` onto a nested `List`, - * `update` and `push` can be used together: - * - * - * ```js - * const aMap = Map({ nestedList: List([ 1, 2, 3 ]) }) - * const newMap = aMap.update('nestedList', list => list.push(4)) - * // Map { "nestedList": List [ 1, 2, 3, 4 ] } - * ``` - * - * When a `notSetValue` is provided, it is provided to the `updater` - * function when the value at the key does not exist in the Map. - * - * - * ```js - * const aMap = Map({ key: 'value' }) - * const newMap = aMap.update('noKey', 'no value', value => value + value) - * // Map { "key": "value", "noKey": "no valueno value" } - * ``` - * - * However, if the `updater` function returns the same value it was called - * with, then no change will occur. This is still true if `notSetValue` - * is provided. - * - * - * ```js - * const aMap = Map({ apples: 10 }) - * const newMap = aMap.update('oranges', 0, val => val) - * // Map { "apples": 10 } - * assert.strictEqual(newMap, map); - * ``` - * - * For code using ES2015 or later, using `notSetValue` is discourged in - * favor of function parameter default values. This helps to avoid any - * potential confusion with identify functions as described above. - * - * The previous example behaves differently when written with default values: - * - * - * ```js - * const aMap = Map({ apples: 10 }) - * const newMap = aMap.update('oranges', (val = 0) => val) - * // Map { "apples": 10, "oranges": 0 } - * ``` - * - * If no key is provided, then the `updater` function return value is - * returned as well. - * - * - * ```js - * const aMap = Map({ key: 'value' }) - * const result = aMap.update(aMap => aMap.get('key')) - * // "value" - * ``` - * - * This can be very useful as a way to "chain" a normal function into a - * sequence of methods. RxJS calls this "let" and lodash calls it "thru". - * - * For example, to sum the values in a Map - * - * - * ```js - * function sum(collection) { - * return collection.reduce((sum, x) => sum + x, 0) - * } - * - * Map({ x: 1, y: 2, z: 3 }) - * .map(x => x + 1) - * .filter(x => x % 2 === 0) - * .update(sum) - * // 6 - * ``` - * - * Note: `update(key)` can be used in `withMutations`. - */ - update(key: K, notSetValue: V, updater: (value: V) => V): this; - update(key: K, updater: (value: V | undefined) => V): this; - update(updater: (value: this) => R): R; - - /** - * Returns a new Map resulting from merging the provided Collections - * (or JS objects) into this Map. In other words, this takes each entry of - * each collection and sets it on this Map. - * - * Note: Values provided to `merge` are shallowly converted before being - * merged. No nested values are altered. - * - * - * ```js - * const { Map } = require('immutable') - * const one = Map({ a: 10, b: 20, c: 30 }) - * const two = Map({ b: 40, a: 50, d: 60 }) - * one.merge(two) // Map { "a": 50, "b": 40, "c": 30, "d": 60 } - * two.merge(one) // Map { "b": 20, "a": 10, "d": 60, "c": 30 } - * ``` - * - * Note: `merge` can be used in `withMutations`. - * - * @alias concat - */ - merge( - ...collections: Array> - ): Map; - merge( - ...collections: Array<{ [key: string]: C }> - ): Map; - concat( - ...collections: Array> - ): Map; - concat( - ...collections: Array<{ [key: string]: C }> - ): Map; - - /** - * Like `merge()`, `mergeWith()` returns a new Map resulting from merging - * the provided Collections (or JS objects) into this Map, but uses the - * `merger` function for dealing with conflicts. - * - * - * ```js - * const { Map } = require('immutable') - * const one = Map({ a: 10, b: 20, c: 30 }) - * const two = Map({ b: 40, a: 50, d: 60 }) - * one.mergeWith((oldVal, newVal) => oldVal / newVal, two) - * // { "a": 0.2, "b": 0.5, "c": 30, "d": 60 } - * two.mergeWith((oldVal, newVal) => oldVal / newVal, one) - * // { "b": 2, "a": 5, "d": 60, "c": 30 } - * ``` - * - * Note: `mergeWith` can be used in `withMutations`. - */ - mergeWith( - merger: (oldVal: V, newVal: V, key: K) => V, - ...collections: Array | { [key: string]: V }> - ): this; - - /** - * Like `merge()`, but when two Collections conflict, it merges them as well, - * recursing deeply through the nested data. - * - * Note: Values provided to `merge` are shallowly converted before being - * merged. No nested values are altered unless they will also be merged at - * a deeper level. - * - * - * ```js - * const { Map } = require('immutable') - * const one = Map({ a: Map({ x: 10, y: 10 }), b: Map({ x: 20, y: 50 }) }) - * const two = Map({ a: Map({ x: 2 }), b: Map({ y: 5 }), c: Map({ z: 3 }) }) - * one.mergeDeep(two) - * // Map { - * // "a": Map { "x": 2, "y": 10 }, - * // "b": Map { "x": 20, "y": 5 }, - * // "c": Map { "z": 3 } - * // } - * ``` - * - * Note: `mergeDeep` can be used in `withMutations`. - */ - mergeDeep( - ...collections: Array | { [key: string]: V }> - ): this; - - /** - * Like `mergeDeep()`, but when two non-Collections conflict, it uses the - * `merger` function to determine the resulting value. - * - * - * ```js - * const { Map } = require('immutable') - * const one = Map({ a: Map({ x: 10, y: 10 }), b: Map({ x: 20, y: 50 }) }) - * const two = Map({ a: Map({ x: 2 }), b: Map({ y: 5 }), c: Map({ z: 3 }) }) - * one.mergeDeepWith((oldVal, newVal) => oldVal / newVal, two) - * // Map { - * // "a": Map { "x": 5, "y": 10 }, - * // "b": Map { "x": 20, "y": 10 }, - * // "c": Map { "z": 3 } - * // } - * ``` - * - * Note: `mergeDeepWith` can be used in `withMutations`. - */ - mergeDeepWith( - merger: (oldVal: unknown, newVal: unknown, key: unknown) => unknown, - ...collections: Array | { [key: string]: V }> - ): this; - - // Deep persistent changes - - /** - * Returns a new Map having set `value` at this `keyPath`. If any keys in - * `keyPath` do not exist, a new immutable Map will be created at that key. - * - * - * ```js - * const { Map } = require('immutable') - * const originalMap = Map({ - * subObject: Map({ - * subKey: 'subvalue', - * subSubObject: Map({ - * subSubKey: 'subSubValue' - * }) - * }) - * }) - * - * const newMap = originalMap.setIn(['subObject', 'subKey'], 'ha ha!') - * // Map { - * // "subObject": Map { - * // "subKey": "ha ha!", - * // "subSubObject": Map { "subSubKey": "subSubValue" } - * // } - * // } - * - * const newerMap = originalMap.setIn( - * ['subObject', 'subSubObject', 'subSubKey'], - * 'ha ha ha!' - * ) - * // Map { - * // "subObject": Map { - * // "subKey": "subvalue", - * // "subSubObject": Map { "subSubKey": "ha ha ha!" } - * // } - * // } - * ``` - * - * Plain JavaScript Object or Arrays may be nested within an Immutable.js - * Collection, and setIn() can update those values as well, treating them - * immutably by creating new copies of those values with the changes applied. - * - * - * ```js - * const { Map } = require('immutable') - * const originalMap = Map({ - * subObject: { - * subKey: 'subvalue', - * subSubObject: { - * subSubKey: 'subSubValue' - * } - * } - * }) - * - * originalMap.setIn(['subObject', 'subKey'], 'ha ha!') - * // Map { - * // "subObject": { - * // subKey: "ha ha!", - * // subSubObject: { subSubKey: "subSubValue" } - * // } - * // } - * ``` - * - * If any key in the path exists but cannot be updated (such as a primitive - * like number or a custom Object like Date), an error will be thrown. - * - * Note: `setIn` can be used in `withMutations`. - */ - setIn(keyPath: Iterable, value: unknown): this; - - /** - * Returns a new Map having removed the value at this `keyPath`. If any keys - * in `keyPath` do not exist, no change will occur. - * - * Note: `deleteIn` can be used in `withMutations`. - * - * @alias removeIn - */ - deleteIn(keyPath: Iterable): this; - removeIn(keyPath: Iterable): this; - - /** - * Returns a new Map having applied the `updater` to the entry found at the - * keyPath. - * - * This is most commonly used to call methods on collections nested within a - * structure of data. For example, in order to `.push()` onto a nested `List`, - * `updateIn` and `push` can be used together: - * - * - * ```js - * const { Map, List } = require('immutable') - * const map = Map({ inMap: Map({ inList: List([ 1, 2, 3 ]) }) }) - * const newMap = map.updateIn(['inMap', 'inList'], list => list.push(4)) - * // Map { "inMap": Map { "inList": List [ 1, 2, 3, 4 ] } } - * ``` - * - * If any keys in `keyPath` do not exist, new Immutable `Map`s will - * be created at those keys. If the `keyPath` does not already contain a - * value, the `updater` function will be called with `notSetValue`, if - * provided, otherwise `undefined`. - * - * - * ```js - * const map = Map({ a: Map({ b: Map({ c: 10 }) }) }) - * const newMap = map.updateIn(['a', 'b', 'c'], val => val * 2) - * // Map { "a": Map { "b": Map { "c": 20 } } } - * ``` - * - * If the `updater` function returns the same value it was called with, then - * no change will occur. This is still true if `notSetValue` is provided. - * - * - * ```js - * const map = Map({ a: Map({ b: Map({ c: 10 }) }) }) - * const newMap = map.updateIn(['a', 'b', 'x'], 100, val => val) - * // Map { "a": Map { "b": Map { "c": 10 } } } - * assert.strictEqual(newMap, aMap) - * ``` - * - * For code using ES2015 or later, using `notSetValue` is discourged in - * favor of function parameter default values. This helps to avoid any - * potential confusion with identify functions as described above. - * - * The previous example behaves differently when written with default values: - * - * - * ```js - * const map = Map({ a: Map({ b: Map({ c: 10 }) }) }) - * const newMap = map.updateIn(['a', 'b', 'x'], (val = 100) => val) - * // Map { "a": Map { "b": Map { "c": 10, "x": 100 } } } - * ``` - * - * Plain JavaScript Object or Arrays may be nested within an Immutable.js - * Collection, and updateIn() can update those values as well, treating them - * immutably by creating new copies of those values with the changes applied. - * - * - * ```js - * const map = Map({ a: { b: { c: 10 } } }) - * const newMap = map.updateIn(['a', 'b', 'c'], val => val * 2) - * // Map { "a": { b: { c: 20 } } } - * ``` - * - * If any key in the path exists but cannot be updated (such as a primitive - * like number or a custom Object like Date), an error will be thrown. - * - * Note: `updateIn` can be used in `withMutations`. - */ - updateIn( - keyPath: Iterable, - notSetValue: unknown, - updater: (value: unknown) => unknown - ): this; - updateIn( - keyPath: Iterable, - updater: (value: unknown) => unknown - ): this; - - /** - * A combination of `updateIn` and `merge`, returning a new Map, but - * performing the merge at a point arrived at by following the keyPath. - * In other words, these two lines are equivalent: - * - * ```js - * map.updateIn(['a', 'b', 'c'], abc => abc.merge(y)) - * map.mergeIn(['a', 'b', 'c'], y) - * ``` - * - * Note: `mergeIn` can be used in `withMutations`. - */ - mergeIn(keyPath: Iterable, ...collections: Array): this; - - /** - * A combination of `updateIn` and `mergeDeep`, returning a new Map, but - * performing the deep merge at a point arrived at by following the keyPath. - * In other words, these two lines are equivalent: - * - * ```js - * map.updateIn(['a', 'b', 'c'], abc => abc.mergeDeep(y)) - * map.mergeDeepIn(['a', 'b', 'c'], y) - * ``` - * - * Note: `mergeDeepIn` can be used in `withMutations`. - */ - mergeDeepIn( - keyPath: Iterable, - ...collections: Array - ): this; - - // Transient changes - - /** - * Every time you call one of the above functions, a new immutable Map is - * created. If a pure function calls a number of these to produce a final - * return value, then a penalty on performance and memory has been paid by - * creating all of the intermediate immutable Maps. - * - * If you need to apply a series of mutations to produce a new immutable - * Map, `withMutations()` creates a temporary mutable copy of the Map which - * can apply mutations in a highly performant manner. In fact, this is - * exactly how complex mutations like `merge` are done. - * - * As an example, this results in the creation of 2, not 4, new Maps: - * - * - * ```js - * const { Map } = require('immutable') - * const map1 = Map() - * const map2 = map1.withMutations(map => { - * map.set('a', 1).set('b', 2).set('c', 3) - * }) - * assert.equal(map1.size, 0) - * assert.equal(map2.size, 3) - * ``` - * - * Note: Not all methods can be used on a mutable collection or within - * `withMutations`! Read the documentation for each method to see if it - * is safe to use in `withMutations`. - */ - withMutations(mutator: (mutable: this) => unknown): this; - - /** - * Another way to avoid creation of intermediate Immutable maps is to create - * a mutable copy of this collection. Mutable copies *always* return `this`, - * and thus shouldn't be used for equality. Your function should never return - * a mutable copy of a collection, only use it internally to create a new - * collection. - * - * If possible, use `withMutations` to work with temporary mutable copies as - * it provides an easier to use API and considers many common optimizations. - * - * Note: if the collection is already mutable, `asMutable` returns itself. - * - * Note: Not all methods can be used on a mutable collection or within - * `withMutations`! Read the documentation for each method to see if it - * is safe to use in `withMutations`. - * - * @see `Map#asImmutable` - */ - asMutable(): this; - - /** - * Returns true if this is a mutable copy (see `asMutable()`) and mutative - * alterations have been applied. - * - * @see `Map#asMutable` - */ - wasAltered(): boolean; - - /** - * The yin to `asMutable`'s yang. Because it applies to mutable collections, - * this operation is *mutable* and may return itself (though may not - * return itself, i.e. if the result is an empty collection). Once - * performed, the original mutable copy must no longer be mutated since it - * may be the immutable result. - * - * If possible, use `withMutations` to work with temporary mutable copies as - * it provides an easier to use API and considers many common optimizations. - * - * @see `Map#asMutable` - */ - asImmutable(): this; - - // Sequence algorithms - - /** - * Returns a new Map with values passed through a - * `mapper` function. - * - * Map({ a: 1, b: 2 }).map(x => 10 * x) - * // Map { a: 10, b: 20 } - */ - map( - mapper: (value: V, key: K, iter: this) => M, - context?: unknown - ): Map; - - /** - * @see Collection.Keyed.mapKeys - */ - mapKeys( - mapper: (key: K, value: V, iter: this) => M, - context?: unknown - ): Map; - - /** - * @see Collection.Keyed.mapEntries - */ - mapEntries( - mapper: ( - entry: [K, V], - index: number, - iter: this - ) => [KM, VM] | undefined, - context?: unknown - ): Map; - - /** - * Flat-maps the Map, returning a new Map. - * - * Similar to `data.map(...).flatten(true)`. - */ - flatMap( - mapper: (value: V, key: K, iter: this) => Iterable<[KM, VM]>, - context?: unknown - ): Map; - - /** - * Returns a new Map with only the entries for which the `predicate` - * function returns true. - * - * Note: `filter()` always returns a new instance, even if it results in - * not filtering out any values. - */ - filter( - predicate: (value: V, key: K, iter: this) => value is F, - context?: unknown - ): Map; - filter( - predicate: (value: V, key: K, iter: this) => unknown, - context?: unknown - ): this; - - /** - * @see Collection.Keyed.flip - */ - flip(): Map; - } - - /** - * A type of Map that has the additional guarantee that the iteration order of - * entries will be the order in which they were set(). - * - * The iteration behavior of OrderedMap is the same as native ES6 Map and - * JavaScript Object. - * - * Note that `OrderedMap` are more expensive than non-ordered `Map` and may - * consume more memory. `OrderedMap#set` is amortized O(log32 N), but not - * stable. - */ - - export namespace OrderedMap { - /** - * True if the provided value is an OrderedMap. - */ - function isOrderedMap( - maybeOrderedMap: unknown - ): maybeOrderedMap is OrderedMap; - } - - /** - * Creates a new Immutable OrderedMap. - * - * Created with the same key value pairs as the provided Collection.Keyed or - * JavaScript Object or expects a Collection of [K, V] tuple entries. - * - * The iteration order of key-value pairs provided to this constructor will - * be preserved in the OrderedMap. - * - * let newOrderedMap = OrderedMap({key: "value"}) - * let newOrderedMap = OrderedMap([["key", "value"]]) - * - * Note: `OrderedMap` is a factory function and not a class, and does not use - * the `new` keyword during construction. - */ - export function OrderedMap( - collection?: Iterable<[K, V]> - ): OrderedMap; - export function OrderedMap(obj: { - [key: string]: V; - }): OrderedMap; - - export interface OrderedMap extends Map { - /** - * The number of entries in this OrderedMap. - */ - readonly size: number; - - /** - * Returns a new OrderedMap also containing the new key, value pair. If an - * equivalent key already exists in this OrderedMap, it will be replaced - * while maintaining the existing order. - * - * - * ```js - * const { OrderedMap } = require('immutable') - * const originalMap = OrderedMap({a:1, b:1, c:1}) - * const updatedMap = originalMap.set('b', 2) - * - * originalMap - * // OrderedMap {a: 1, b: 1, c: 1} - * updatedMap - * // OrderedMap {a: 1, b: 2, c: 1} - * ``` - * - * Note: `set` can be used in `withMutations`. - */ - set(key: K, value: V): this; - - /** - * Returns a new OrderedMap resulting from merging the provided Collections - * (or JS objects) into this OrderedMap. In other words, this takes each - * entry of each collection and sets it on this OrderedMap. - * - * Note: Values provided to `merge` are shallowly converted before being - * merged. No nested values are altered. - * - * - * ```js - * const { OrderedMap } = require('immutable') - * const one = OrderedMap({ a: 10, b: 20, c: 30 }) - * const two = OrderedMap({ b: 40, a: 50, d: 60 }) - * one.merge(two) // OrderedMap { "a": 50, "b": 40, "c": 30, "d": 60 } - * two.merge(one) // OrderedMap { "b": 20, "a": 10, "d": 60, "c": 30 } - * ``` - * - * Note: `merge` can be used in `withMutations`. - * - * @alias concat - */ - merge( - ...collections: Array> - ): OrderedMap; - merge( - ...collections: Array<{ [key: string]: C }> - ): OrderedMap; - concat( - ...collections: Array> - ): OrderedMap; - concat( - ...collections: Array<{ [key: string]: C }> - ): OrderedMap; - - // Sequence algorithms - - /** - * Returns a new OrderedMap with values passed through a - * `mapper` function. - * - * OrderedMap({ a: 1, b: 2 }).map(x => 10 * x) - * // OrderedMap { "a": 10, "b": 20 } - * - * Note: `map()` always returns a new instance, even if it produced the same - * value at every step. - */ - map( - mapper: (value: V, key: K, iter: this) => M, - context?: unknown - ): OrderedMap; - - /** - * @see Collection.Keyed.mapKeys - */ - mapKeys( - mapper: (key: K, value: V, iter: this) => M, - context?: unknown - ): OrderedMap; - - /** - * @see Collection.Keyed.mapEntries - */ - mapEntries( - mapper: ( - entry: [K, V], - index: number, - iter: this - ) => [KM, VM] | undefined, - context?: unknown - ): OrderedMap; - - /** - * Flat-maps the OrderedMap, returning a new OrderedMap. - * - * Similar to `data.map(...).flatten(true)`. - */ - flatMap( - mapper: (value: V, key: K, iter: this) => Iterable<[KM, VM]>, - context?: unknown - ): OrderedMap; - - /** - * Returns a new OrderedMap with only the entries for which the `predicate` - * function returns true. - * - * Note: `filter()` always returns a new instance, even if it results in - * not filtering out any values. - */ - filter( - predicate: (value: V, key: K, iter: this) => value is F, - context?: unknown - ): OrderedMap; - filter( - predicate: (value: V, key: K, iter: this) => unknown, - context?: unknown - ): this; - - /** - * @see Collection.Keyed.flip - */ - flip(): OrderedMap; - } - - /** - * A Collection of unique values with `O(log32 N)` adds and has. - * - * When iterating a Set, the entries will be (value, value) pairs. Iteration - * order of a Set is undefined, however is stable. Multiple iterations of the - * same Set will iterate in the same order. - * - * Set values, like Map keys, may be of any type. Equality is determined using - * `Immutable.is`, enabling Sets to uniquely include other Immutable - * collections, custom value types, and NaN. - */ - export namespace Set { - /** - * True if the provided value is a Set - */ - function isSet(maybeSet: unknown): maybeSet is Set; - - /** - * Creates a new Set containing `values`. - */ - function of(...values: Array): Set; - - /** - * `Set.fromKeys()` creates a new immutable Set containing the keys from - * this Collection or JavaScript Object. - */ - function fromKeys(iter: Collection): Set; - function fromKeys(obj: { [key: string]: unknown }): Set; - - /** - * `Set.intersect()` creates a new immutable Set that is the intersection of - * a collection of other sets. - * - * ```js - * const { Set } = require('immutable') - * const intersected = Set.intersect([ - * Set([ 'a', 'b', 'c' ]) - * Set([ 'c', 'a', 't' ]) - * ]) - * // Set [ "a", "c" ] - * ``` - */ - function intersect(sets: Iterable>): Set; - - /** - * `Set.union()` creates a new immutable Set that is the union of a - * collection of other sets. - * - * ```js - * const { Set } = require('immutable') - * const unioned = Set.union([ - * Set([ 'a', 'b', 'c' ]) - * Set([ 'c', 'a', 't' ]) - * ]) - * // Set [ "a", "b", "c", "t" ] - * ``` - */ - function union(sets: Iterable>): Set; - } - - /** - * Create a new immutable Set containing the values of the provided - * collection-like. - * - * Note: `Set` is a factory function and not a class, and does not use the - * `new` keyword during construction. - */ - export function Set(collection?: Iterable | ArrayLike): Set; - - export interface Set extends Collection.Set { - /** - * The number of items in this Set. - */ - readonly size: number; - - // Persistent changes - - /** - * Returns a new Set which also includes this value. - * - * Note: `add` can be used in `withMutations`. - */ - add(value: T): this; - - /** - * Returns a new Set which excludes this value. - * - * Note: `delete` can be used in `withMutations`. - * - * Note: `delete` **cannot** be safely used in IE8, use `remove` if - * supporting old browsers. - * - * @alias remove - */ - delete(value: T): this; - remove(value: T): this; - - /** - * Returns a new Set containing no values. - * - * Note: `clear` can be used in `withMutations`. - */ - clear(): this; - - /** - * Returns a Set including any value from `collections` that does not already - * exist in this Set. - * - * Note: `union` can be used in `withMutations`. - * @alias merge - * @alias concat - */ - union(...collections: Array>): Set; - merge(...collections: Array>): Set; - concat(...collections: Array>): Set; - - /** - * Returns a Set which has removed any values not also contained - * within `collections`. - * - * Note: `intersect` can be used in `withMutations`. - */ - intersect(...collections: Array>): this; - - /** - * Returns a Set excluding any values contained within `collections`. - * - * - * ```js - * const { OrderedSet } = require('immutable') - * OrderedSet([ 1, 2, 3 ]).subtract([1, 3]) - * // OrderedSet [2] - * ``` - * - * Note: `subtract` can be used in `withMutations`. - */ - subtract(...collections: Array>): this; - - // Transient changes - - /** - * Note: Not all methods can be used on a mutable collection or within - * `withMutations`! Check the documentation for each method to see if it - * mentions being safe to use in `withMutations`. - * - * @see `Map#withMutations` - */ - withMutations(mutator: (mutable: this) => unknown): this; - - /** - * Note: Not all methods can be used on a mutable collection or within - * `withMutations`! Check the documentation for each method to see if it - * mentions being safe to use in `withMutations`. - * - * @see `Map#asMutable` - */ - asMutable(): this; - - /** - * @see `Map#wasAltered` - */ - wasAltered(): boolean; - - /** - * @see `Map#asImmutable` - */ - asImmutable(): this; - - // Sequence algorithms - - /** - * Returns a new Set with values passed through a - * `mapper` function. - * - * Set([1,2]).map(x => 10 * x) - * // Set [10,20] - */ - map( - mapper: (value: T, key: T, iter: this) => M, - context?: unknown - ): Set; - - /** - * Flat-maps the Set, returning a new Set. - * - * Similar to `set.map(...).flatten(true)`. - */ - flatMap( - mapper: (value: T, key: T, iter: this) => Iterable, - context?: unknown - ): Set; - - /** - * Returns a new Set with only the values for which the `predicate` - * function returns true. - * - * Note: `filter()` always returns a new instance, even if it results in - * not filtering out any values. - */ - filter( - predicate: (value: T, key: T, iter: this) => value is F, - context?: unknown - ): Set; - filter( - predicate: (value: T, key: T, iter: this) => unknown, - context?: unknown - ): this; - } - - /** - * A type of Set that has the additional guarantee that the iteration order of - * values will be the order in which they were `add`ed. - * - * The iteration behavior of OrderedSet is the same as native ES6 Set. - * - * Note that `OrderedSet` are more expensive than non-ordered `Set` and may - * consume more memory. `OrderedSet#add` is amortized O(log32 N), but not - * stable. - */ - export namespace OrderedSet { - /** - * True if the provided value is an OrderedSet. - */ - function isOrderedSet(maybeOrderedSet: unknown): boolean; - - /** - * Creates a new OrderedSet containing `values`. - */ - function of(...values: Array): OrderedSet; - - /** - * `OrderedSet.fromKeys()` creates a new immutable OrderedSet containing - * the keys from this Collection or JavaScript Object. - */ - function fromKeys(iter: Collection): OrderedSet; - function fromKeys(obj: { [key: string]: unknown }): OrderedSet; - } - - /** - * Create a new immutable OrderedSet containing the values of the provided - * collection-like. - * - * Note: `OrderedSet` is a factory function and not a class, and does not use - * the `new` keyword during construction. - */ - export function OrderedSet( - collection?: Iterable | ArrayLike - ): OrderedSet; - - export interface OrderedSet extends Set { - /** - * The number of items in this OrderedSet. - */ - readonly size: number; - - /** - * Returns an OrderedSet including any value from `collections` that does - * not already exist in this OrderedSet. - * - * Note: `union` can be used in `withMutations`. - * @alias merge - * @alias concat - */ - union(...collections: Array>): OrderedSet; - merge(...collections: Array>): OrderedSet; - concat(...collections: Array>): OrderedSet; - - // Sequence algorithms - - /** - * Returns a new Set with values passed through a - * `mapper` function. - * - * OrderedSet([ 1, 2 ]).map(x => 10 * x) - * // OrderedSet [10, 20] - */ - map( - mapper: (value: T, key: T, iter: this) => M, - context?: unknown - ): OrderedSet; - - /** - * Flat-maps the OrderedSet, returning a new OrderedSet. - * - * Similar to `set.map(...).flatten(true)`. - */ - flatMap( - mapper: (value: T, key: T, iter: this) => Iterable, - context?: unknown - ): OrderedSet; - - /** - * Returns a new OrderedSet with only the values for which the `predicate` - * function returns true. - * - * Note: `filter()` always returns a new instance, even if it results in - * not filtering out any values. - */ - filter( - predicate: (value: T, key: T, iter: this) => value is F, - context?: unknown - ): OrderedSet; - filter( - predicate: (value: T, key: T, iter: this) => unknown, - context?: unknown - ): this; - - /** - * Returns an OrderedSet of the same type "zipped" with the provided - * collections. - * - * Like `zipWith`, but using the default `zipper`: creating an `Array`. - * - * ```js - * const a = OrderedSet([ 1, 2, 3 ]) - * const b = OrderedSet([ 4, 5, 6 ]) - * const c = a.zip(b) - * // OrderedSet [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] - * ``` - */ - zip(other: Collection): OrderedSet<[T, U]>; - zip( - other1: Collection, - other2: Collection - ): OrderedSet<[T, U, V]>; - zip( - ...collections: Array> - ): OrderedSet; - - /** - * Returns a OrderedSet of the same type "zipped" with the provided - * collections. - * - * Unlike `zip`, `zipAll` continues zipping until the longest collection is - * exhausted. Missing values from shorter collections are filled with `undefined`. - * - * ```js - * const a = OrderedSet([ 1, 2 ]); - * const b = OrderedSet([ 3, 4, 5 ]); - * const c = a.zipAll(b); // OrderedSet [ [ 1, 3 ], [ 2, 4 ], [ undefined, 5 ] ] - * ``` - * - * Note: Since zipAll will return a collection as large as the largest - * input, some results may contain undefined values. TypeScript cannot - * account for these without cases (as of v2.5). - */ - zipAll(other: Collection): OrderedSet<[T, U]>; - zipAll( - other1: Collection, - other2: Collection - ): OrderedSet<[T, U, V]>; - zipAll( - ...collections: Array> - ): OrderedSet; - - /** - * Returns an OrderedSet of the same type "zipped" with the provided - * collections by using a custom `zipper` function. - * - * @see Seq.Indexed.zipWith - */ - zipWith( - zipper: (value: T, otherValue: U) => Z, - otherCollection: Collection - ): OrderedSet; - zipWith( - zipper: (value: T, otherValue: U, thirdValue: V) => Z, - otherCollection: Collection, - thirdCollection: Collection - ): OrderedSet; - zipWith( - zipper: (...values: Array) => Z, - ...collections: Array> - ): OrderedSet; - } - - /** - * Stacks are indexed collections which support very efficient O(1) addition - * and removal from the front using `unshift(v)` and `shift()`. - * - * For familiarity, Stack also provides `push(v)`, `pop()`, and `peek()`, but - * be aware that they also operate on the front of the list, unlike List or - * a JavaScript Array. - * - * Note: `reverse()` or any inherent reverse traversal (`reduceRight`, - * `lastIndexOf`, etc.) is not efficient with a Stack. - * - * Stack is implemented with a Single-Linked List. - */ - export namespace Stack { - /** - * True if the provided value is a Stack - */ - function isStack(maybeStack: unknown): maybeStack is Stack; - - /** - * Creates a new Stack containing `values`. - */ - function of(...values: Array): Stack; - } - - /** - * Create a new immutable Stack containing the values of the provided - * collection-like. - * - * The iteration order of the provided collection is preserved in the - * resulting `Stack`. - * - * Note: `Stack` is a factory function and not a class, and does not use the - * `new` keyword during construction. - */ - export function Stack(collection?: Iterable | ArrayLike): Stack; - - export interface Stack extends Collection.Indexed { - /** - * The number of items in this Stack. - */ - readonly size: number; - - // Reading values - - /** - * Alias for `Stack.first()`. - */ - peek(): T | undefined; - - // Persistent changes - - /** - * Returns a new Stack with 0 size and no values. - * - * Note: `clear` can be used in `withMutations`. - */ - clear(): Stack; - - /** - * Returns a new Stack with the provided `values` prepended, shifting other - * values ahead to higher indices. - * - * This is very efficient for Stack. - * - * Note: `unshift` can be used in `withMutations`. - */ - unshift(...values: Array): Stack; - - /** - * Like `Stack#unshift`, but accepts a collection rather than varargs. - * - * Note: `unshiftAll` can be used in `withMutations`. - */ - unshiftAll(iter: Iterable): Stack; - - /** - * Returns a new Stack with a size ones less than this Stack, excluding - * the first item in this Stack, shifting all other values to a lower index. - * - * Note: this differs from `Array#shift` because it returns a new - * Stack rather than the removed value. Use `first()` or `peek()` to get the - * first value in this Stack. - * - * Note: `shift` can be used in `withMutations`. - */ - shift(): Stack; - - /** - * Alias for `Stack#unshift` and is not equivalent to `List#push`. - */ - push(...values: Array): Stack; - - /** - * Alias for `Stack#unshiftAll`. - */ - pushAll(iter: Iterable): Stack; - - /** - * Alias for `Stack#shift` and is not equivalent to `List#pop`. - */ - pop(): Stack; - - // Transient changes - - /** - * Note: Not all methods can be used on a mutable collection or within - * `withMutations`! Check the documentation for each method to see if it - * mentions being safe to use in `withMutations`. - * - * @see `Map#withMutations` - */ - withMutations(mutator: (mutable: this) => unknown): this; - - /** - * Note: Not all methods can be used on a mutable collection or within - * `withMutations`! Check the documentation for each method to see if it - * mentions being safe to use in `withMutations`. - * - * @see `Map#asMutable` - */ - asMutable(): this; - - /** - * @see `Map#wasAltered` - */ - wasAltered(): boolean; - - /** - * @see `Map#asImmutable` - */ - asImmutable(): this; - - // Sequence algorithms - - /** - * Returns a new Stack with other collections concatenated to this one. - */ - concat(...valuesOrCollections: Array | C>): Stack; - - /** - * Returns a new Stack with values passed through a - * `mapper` function. - * - * Stack([ 1, 2 ]).map(x => 10 * x) - * // Stack [ 10, 20 ] - * - * Note: `map()` always returns a new instance, even if it produced the same - * value at every step. - */ - map( - mapper: (value: T, key: number, iter: this) => M, - context?: unknown - ): Stack; - - /** - * Flat-maps the Stack, returning a new Stack. - * - * Similar to `stack.map(...).flatten(true)`. - */ - flatMap( - mapper: (value: T, key: number, iter: this) => Iterable, - context?: unknown - ): Stack; - - /** - * Returns a new Set with only the values for which the `predicate` - * function returns true. - * - * Note: `filter()` always returns a new instance, even if it results in - * not filtering out any values. - */ - filter( - predicate: (value: T, index: number, iter: this) => value is F, - context?: unknown - ): Set; - filter( - predicate: (value: T, index: number, iter: this) => unknown, - context?: unknown - ): this; - - /** - * Returns a Stack "zipped" with the provided collections. - * - * Like `zipWith`, but using the default `zipper`: creating an `Array`. - * - * ```js - * const a = Stack([ 1, 2, 3 ]); - * const b = Stack([ 4, 5, 6 ]); - * const c = a.zip(b); // Stack [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] - * ``` - */ - zip(other: Collection): Stack<[T, U]>; - zip( - other: Collection, - other2: Collection - ): Stack<[T, U, V]>; - zip(...collections: Array>): Stack; - - /** - * Returns a Stack "zipped" with the provided collections. - * - * Unlike `zip`, `zipAll` continues zipping until the longest collection is - * exhausted. Missing values from shorter collections are filled with `undefined`. - * - * ```js - * const a = Stack([ 1, 2 ]); - * const b = Stack([ 3, 4, 5 ]); - * const c = a.zipAll(b); // Stack [ [ 1, 3 ], [ 2, 4 ], [ undefined, 5 ] ] - * ``` - * - * Note: Since zipAll will return a collection as large as the largest - * input, some results may contain undefined values. TypeScript cannot - * account for these without cases (as of v2.5). - */ - zipAll(other: Collection): Stack<[T, U]>; - zipAll( - other: Collection, - other2: Collection - ): Stack<[T, U, V]>; - zipAll(...collections: Array>): Stack; - - /** - * Returns a Stack "zipped" with the provided collections by using a - * custom `zipper` function. - * - * ```js - * const a = Stack([ 1, 2, 3 ]); - * const b = Stack([ 4, 5, 6 ]); - * const c = a.zipWith((a, b) => a + b, b); - * // Stack [ 5, 7, 9 ] - * ``` - */ - zipWith( - zipper: (value: T, otherValue: U) => Z, - otherCollection: Collection - ): Stack; - zipWith( - zipper: (value: T, otherValue: U, thirdValue: V) => Z, - otherCollection: Collection, - thirdCollection: Collection - ): Stack; - zipWith( - zipper: (...values: Array) => Z, - ...collections: Array> - ): Stack; - } - - /** - * Returns a Seq.Indexed of numbers from `start` (inclusive) to `end` - * (exclusive), by `step`, where `start` defaults to 0, `step` to 1, and `end` to - * infinity. When `start` is equal to `end`, returns empty range. - * - * Note: `Range` is a factory function and not a class, and does not use the - * `new` keyword during construction. - * - * ```js - * const { Range } = require('immutable') - * Range() // [ 0, 1, 2, 3, ... ] - * Range(10) // [ 10, 11, 12, 13, ... ] - * Range(10, 15) // [ 10, 11, 12, 13, 14 ] - * Range(10, 30, 5) // [ 10, 15, 20, 25 ] - * Range(30, 10, 5) // [ 30, 25, 20, 15 ] - * Range(30, 30, 5) // [] - * ``` - */ - export function Range( - start?: number, - end?: number, - step?: number - ): Seq.Indexed; - - /** - * Returns a Seq.Indexed of `value` repeated `times` times. When `times` is - * not defined, returns an infinite `Seq` of `value`. - * - * Note: `Repeat` is a factory function and not a class, and does not use the - * `new` keyword during construction. - * - * ```js - * const { Repeat } = require('immutable') - * Repeat('foo') // [ 'foo', 'foo', 'foo', ... ] - * Repeat('bar', 4) // [ 'bar', 'bar', 'bar', 'bar' ] - * ``` - */ - export function Repeat(value: T, times?: number): Seq.Indexed; - - /** - * A record is similar to a JS object, but enforces a specific set of allowed - * string keys, and has default values. - * - * The `Record()` function produces new Record Factories, which when called - * create Record instances. - * - * ```js - * const { Record } = require('immutable') - * const ABRecord = Record({ a: 1, b: 2 }) - * const myRecord = ABRecord({ b: 3 }) - * ``` - * - * Records always have a value for the keys they define. `remove`ing a key - * from a record simply resets it to the default value for that key. - * - * ```js - * myRecord.get('a') // 1 - * myRecord.get('b') // 3 - * const myRecordWithoutB = myRecord.remove('b') - * myRecordWithoutB.get('b') // 2 - * ``` - * - * Values provided to the constructor not found in the Record type will - * be ignored. For example, in this case, ABRecord is provided a key "x" even - * though only "a" and "b" have been defined. The value for "x" will be - * ignored for this record. - * - * ```js - * const myRecord = ABRecord({ b: 3, x: 10 }) - * myRecord.get('x') // undefined - * ``` - * - * Because Records have a known set of string keys, property get access works - * as expected, however property sets will throw an Error. - * - * Note: IE8 does not support property access. Only use `get()` when - * supporting IE8. - * - * ```js - * myRecord.b // 3 - * myRecord.b = 5 // throws Error - * ``` - * - * Record Types can be extended as well, allowing for custom methods on your - * Record. This is not a common pattern in functional environments, but is in - * many JS programs. - * - * However Record Types are more restricted than typical JavaScript classes. - * They do not use a class constructor, which also means they cannot use - * class properties (since those are technically part of a constructor). - * - * While Record Types can be syntactically created with the JavaScript `class` - * form, the resulting Record function is actually a factory function, not a - * class constructor. Even though Record Types are not classes, JavaScript - * currently requires the use of `new` when creating new Record instances if - * they are defined as a `class`. - * - * ``` - * class ABRecord extends Record({ a: 1, b: 2 }) { - * getAB() { - * return this.a + this.b; - * } - * } - * - * var myRecord = new ABRecord({b: 3}) - * myRecord.getAB() // 4 - * ``` - * - * - * **Flow Typing Records:** - * - * Immutable.js exports two Flow types designed to make it easier to use - * Records with flow typed code, `RecordOf` and `RecordFactory`. - * - * When defining a new kind of Record factory function, use a flow type that - * describes the values the record contains along with `RecordFactory`. - * To type instances of the Record (which the factory function returns), - * use `RecordOf`. - * - * Typically, new Record definitions will export both the Record factory - * function as well as the Record instance type for use in other code. - * - * ```js - * import type { RecordFactory, RecordOf } from 'immutable'; - * - * // Use RecordFactory for defining new Record factory functions. - * type Point3DProps = { x: number, y: number, z: number }; - * const defaultValues: Point3DProps = { x: 0, y: 0, z: 0 }; - * const makePoint3D: RecordFactory = Record(defaultValues); - * export makePoint3D; - * - * // Use RecordOf for defining new instances of that Record. - * export type Point3D = RecordOf; - * const some3DPoint: Point3D = makePoint3D({ x: 10, y: 20, z: 30 }); - * ``` - * - * **Flow Typing Record Subclasses:** - * - * Records can be subclassed as a means to add additional methods to Record - * instances. This is generally discouraged in favor of a more functional API, - * since Subclasses have some minor overhead. However the ability to create - * a rich API on Record types can be quite valuable. - * - * When using Flow to type Subclasses, do not use `RecordFactory`, - * instead apply the props type when subclassing: - * - * ```js - * type PersonProps = {name: string, age: number}; - * const defaultValues: PersonProps = {name: 'Aristotle', age: 2400}; - * const PersonRecord = Record(defaultValues); - * class Person extends PersonRecord { - * getName(): string { - * return this.get('name') - * } - * - * setName(name: string): this { - * return this.set('name', name); - * } - * } - * ``` - * - * **Choosing Records vs plain JavaScript objects** - * - * Records offer a persistently immutable alternative to plain JavaScript - * objects, however they're not required to be used within Immutable.js - * collections. In fact, the deep-access and deep-updating functions - * like `getIn()` and `setIn()` work with plain JavaScript Objects as well. - * - * Deciding to use Records or Objects in your application should be informed - * by the tradeoffs and relative benefits of each: - * - * - *Runtime immutability*: plain JS objects may be carefully treated as - * immutable, however Record instances will *throw* if attempted to be - * mutated directly. Records provide this additional guarantee, however at - * some marginal runtime cost. While JS objects are mutable by nature, the - * use of type-checking tools like [Flow](https://medium.com/@gcanti/immutability-with-flow-faa050a1aef4) - * can help gain confidence in code written to favor immutability. - * - * - *Value equality*: Records use value equality when compared with `is()` - * or `record.equals()`. That is, two Records with the same keys and values - * are equal. Plain objects use *reference equality*. Two objects with the - * same keys and values are not equal since they are different objects. - * This is important to consider when using objects as keys in a `Map` or - * values in a `Set`, which use equality when retrieving values. - * - * - *API methods*: Records have a full featured API, with methods like - * `.getIn()`, and `.equals()`. These can make working with these values - * easier, but comes at the cost of not allowing keys with those names. - * - * - *Default values*: Records provide default values for every key, which - * can be useful when constructing Records with often unchanging values. - * However default values can make using Flow and TypeScript more laborious. - * - * - *Serialization*: Records use a custom internal representation to - * efficiently store and update their values. Converting to and from this - * form isn't free. If converting Records to plain objects is common, - * consider sticking with plain objects to begin with. - */ - export namespace Record { - /** - * True if `maybeRecord` is an instance of a Record. - */ - export function isRecord(maybeRecord: unknown): maybeRecord is Record<{}>; - - /** - * Records allow passing a second parameter to supply a descriptive name - * that appears when converting a Record to a string or in any error - * messages. A descriptive name for any record can be accessed by using this - * method. If one was not provided, the string "Record" is returned. - * - * ```js - * const { Record } = require('immutable') - * const Person = Record({ - * name: null - * }, 'Person') - * - * var me = Person({ name: 'My Name' }) - * me.toString() // "Person { "name": "My Name" }" - * Record.getDescriptiveName(me) // "Person" - * ``` - */ - export function getDescriptiveName(record: Record): string; - - /** - * A Record.Factory is created by the `Record()` function. Record instances - * are created by passing it some of the accepted values for that Record - * type: - * - * - * ```js - * // makePerson is a Record Factory function - * const makePerson = Record({ name: null, favoriteColor: 'unknown' }); - * - * // alan is a Record instance - * const alan = makePerson({ name: 'Alan' }); - * ``` - * - * Note that Record Factories return `Record & Readonly`, - * this allows use of both the Record instance API, and direct property - * access on the resulting instances: - * - * - * ```js - * // Use the Record API - * console.log('Record API: ' + alan.get('name')) - * - * // Or direct property access (Readonly) - * console.log('property access: ' + alan.name) - * ``` - * - * **Flow Typing Records:** - * - * Use the `RecordFactory` Flow type to get high quality type checking of - * Records: - * - * ```js - * import type { RecordFactory, RecordOf } from 'immutable'; - * - * // Use RecordFactory for defining new Record factory functions. - * type PersonProps = { name: ?string, favoriteColor: string }; - * const makePerson: RecordFactory = Record({ name: null, favoriteColor: 'unknown' }); - * - * // Use RecordOf for defining new instances of that Record. - * type Person = RecordOf; - * const alan: Person = makePerson({ name: 'Alan' }); - * ``` - */ - export namespace Factory {} - - export interface Factory { - (values?: Partial | Iterable<[string, unknown]>): Record & - Readonly; - new ( - values?: Partial | Iterable<[string, unknown]> - ): Record & Readonly; - - /** - * The name provided to `Record(values, name)` can be accessed with - * `displayName`. - */ - displayName: string; - } - - export function Factory( - values?: Partial | Iterable<[string, unknown]> - ): Record & Readonly; - } - - /** - * Unlike other types in Immutable.js, the `Record()` function creates a new - * Record Factory, which is a function that creates Record instances. - * - * See above for examples of using `Record()`. - * - * Note: `Record` is a factory function and not a class, and does not use the - * `new` keyword during construction. - */ - export function Record( - defaultValues: TProps, - name?: string - ): Record.Factory; - - export interface Record { - // Reading values - - has(key: string): key is keyof TProps & string; - - /** - * Returns the value associated with the provided key, which may be the - * default value defined when creating the Record factory function. - * - * If the requested key is not defined by this Record type, then - * notSetValue will be returned if provided. Note that this scenario would - * produce an error when using Flow or TypeScript. - */ - get(key: K, notSetValue?: unknown): TProps[K]; - get(key: string, notSetValue: T): T; - - // Reading deep values - - hasIn(keyPath: Iterable): boolean; - getIn(keyPath: Iterable): unknown; - - // Value equality - - equals(other: unknown): boolean; - hashCode(): number; - - // Persistent changes - - set(key: K, value: TProps[K]): this; - update( - key: K, - updater: (value: TProps[K]) => TProps[K] - ): this; - merge( - ...collections: Array | Iterable<[string, unknown]>> - ): this; - mergeDeep( - ...collections: Array | Iterable<[string, unknown]>> - ): this; - - mergeWith( - merger: (oldVal: unknown, newVal: unknown, key: keyof TProps) => unknown, - ...collections: Array | Iterable<[string, unknown]>> - ): this; - mergeDeepWith( - merger: (oldVal: unknown, newVal: unknown, key: unknown) => unknown, - ...collections: Array | Iterable<[string, unknown]>> - ): this; - - /** - * Returns a new instance of this Record type with the value for the - * specific key set to its default value. - * - * @alias remove - */ - delete(key: K): this; - remove(key: K): this; - - /** - * Returns a new instance of this Record type with all values set - * to their default values. - */ - clear(): this; - - // Deep persistent changes - - setIn(keyPath: Iterable, value: unknown): this; - updateIn( - keyPath: Iterable, - updater: (value: unknown) => unknown - ): this; - mergeIn(keyPath: Iterable, ...collections: Array): this; - mergeDeepIn( - keyPath: Iterable, - ...collections: Array - ): this; - - /** - * @alias removeIn - */ - deleteIn(keyPath: Iterable): this; - removeIn(keyPath: Iterable): this; - - // Conversion to JavaScript types - - /** - * Deeply converts this Record to equivalent native JavaScript Object. - * - * Note: This method may not be overridden. Objects with custom - * serialization to plain JS may override toJSON() instead. - */ - toJS(): { [K in keyof TProps]: unknown }; - - /** - * Shallowly converts this Record to equivalent native JavaScript Object. - */ - toJSON(): TProps; - - /** - * Shallowly converts this Record to equivalent JavaScript Object. - */ - toObject(): TProps; - - // Transient changes - - /** - * Note: Not all methods can be used on a mutable collection or within - * `withMutations`! Only `set` may be used mutatively. - * - * @see `Map#withMutations` - */ - withMutations(mutator: (mutable: this) => unknown): this; - - /** - * @see `Map#asMutable` - */ - asMutable(): this; - - /** - * @see `Map#wasAltered` - */ - wasAltered(): boolean; - - /** - * @see `Map#asImmutable` - */ - asImmutable(): this; - - // Sequence algorithms - - toSeq(): Seq.Keyed; - - [Symbol.iterator](): IterableIterator<[keyof TProps, TProps[keyof TProps]]>; - } - - /** - * RecordOf is used in TypeScript to define interfaces expecting an - * instance of record with type T. - * - * This is equivalent to an instance of a record created by a Record Factory. - */ - export type RecordOf = Record & - Readonly; - - /** - * `Seq` describes a lazy operation, allowing them to efficiently chain - * use of all the higher-order collection methods (such as `map` and `filter`) - * by not creating intermediate collections. - * - * **Seq is immutable** — Once a Seq is created, it cannot be - * changed, appended to, rearranged or otherwise modified. Instead, any - * mutative method called on a `Seq` will return a new `Seq`. - * - * **Seq is lazy** — `Seq` does as little work as necessary to respond to any - * method call. Values are often created during iteration, including implicit - * iteration when reducing or converting to a concrete data structure such as - * a `List` or JavaScript `Array`. - * - * For example, the following performs no work, because the resulting - * `Seq`'s values are never iterated: - * - * ```js - * const { Seq } = require('immutable') - * const oddSquares = Seq([ 1, 2, 3, 4, 5, 6, 7, 8 ]) - * .filter(x => x % 2 !== 0) - * .map(x => x * x) - * ``` - * - * Once the `Seq` is used, it performs only the work necessary. In this - * example, no intermediate arrays are ever created, filter is called three - * times, and map is only called once: - * - * ```js - * oddSquares.get(1); // 9 - * ``` - * - * Any collection can be converted to a lazy Seq with `Seq()`. - * - * - * ```js - * const { Map } = require('immutable') - * const map = Map({ a: 1, b: 2, c: 3 }) - * const lazySeq = Seq(map) - * ``` - * - * `Seq` allows for the efficient chaining of operations, allowing for the - * expression of logic that can otherwise be very tedious: - * - * ```js - * lazySeq - * .flip() - * .map(key => key.toUpperCase()) - * .flip() - * // Seq { A: 1, B: 1, C: 1 } - * ``` - * - * As well as expressing logic that would otherwise seem memory or time - * limited, for example `Range` is a special kind of Lazy sequence. - * - * - * ```js - * const { Range } = require('immutable') - * Range(1, Infinity) - * .skip(1000) - * .map(n => -n) - * .filter(n => n % 2 === 0) - * .take(2) - * .reduce((r, n) => r * n, 1) - * // 1006008 - * ``` - * - * Seq is often used to provide a rich collection API to JavaScript Object. - * - * ```js - * Seq({ x: 0, y: 1, z: 2 }).map(v => v * 2).toObject(); - * // { x: 0, y: 2, z: 4 } - * ``` - */ - - export namespace Seq { - /** - * True if `maybeSeq` is a Seq, it is not backed by a concrete - * structure such as Map, List, or Set. - */ - function isSeq( - maybeSeq: unknown - ): maybeSeq is - | Seq.Indexed - | Seq.Keyed - | Seq.Set; - - /** - * `Seq` which represents key-value pairs. - */ - export namespace Keyed {} - - /** - * Always returns a Seq.Keyed, if input is not keyed, expects an - * collection of [K, V] tuples. - * - * Note: `Seq.Keyed` is a conversion function and not a class, and does not - * use the `new` keyword during construction. - */ - export function Keyed(collection?: Iterable<[K, V]>): Seq.Keyed; - export function Keyed(obj: { [key: string]: V }): Seq.Keyed; - - export interface Keyed extends Seq, Collection.Keyed { - /** - * Deeply converts this Keyed Seq to equivalent native JavaScript Object. - * - * Converts keys to Strings. - */ - toJS(): { [key: string]: unknown }; - - /** - * Shallowly converts this Keyed Seq to equivalent native JavaScript Object. - * - * Converts keys to Strings. - */ - toJSON(): { [key: string]: V }; - - /** - * Shallowly converts this collection to an Array. - */ - toArray(): Array<[K, V]>; - - /** - * Returns itself - */ - toSeq(): this; - - /** - * Returns a new Seq with other collections concatenated to this one. - * - * All entries will be present in the resulting Seq, even if they - * have the same key. - */ - concat( - ...collections: Array> - ): Seq.Keyed; - concat( - ...collections: Array<{ [key: string]: C }> - ): Seq.Keyed; - - /** - * Returns a new Seq.Keyed with values passed through a - * `mapper` function. - * - * ```js - * const { Seq } = require('immutable') - * Seq.Keyed({ a: 1, b: 2 }).map(x => 10 * x) - * // Seq { "a": 10, "b": 20 } - * ``` - * - * Note: `map()` always returns a new instance, even if it produced the - * same value at every step. - */ - map( - mapper: (value: V, key: K, iter: this) => M, - context?: unknown - ): Seq.Keyed; - - /** - * @see Collection.Keyed.mapKeys - */ - mapKeys( - mapper: (key: K, value: V, iter: this) => M, - context?: unknown - ): Seq.Keyed; - - /** - * @see Collection.Keyed.mapEntries - */ - mapEntries( - mapper: ( - entry: [K, V], - index: number, - iter: this - ) => [KM, VM] | undefined, - context?: unknown - ): Seq.Keyed; - - /** - * Flat-maps the Seq, returning a Seq of the same type. - * - * Similar to `seq.map(...).flatten(true)`. - */ - flatMap( - mapper: (value: V, key: K, iter: this) => Iterable<[KM, VM]>, - context?: unknown - ): Seq.Keyed; - - /** - * Returns a new Seq with only the entries for which the `predicate` - * function returns true. - * - * Note: `filter()` always returns a new instance, even if it results in - * not filtering out any values. - */ - filter( - predicate: (value: V, key: K, iter: this) => value is F, - context?: unknown - ): Seq.Keyed; - filter( - predicate: (value: V, key: K, iter: this) => unknown, - context?: unknown - ): this; - - /** - * @see Collection.Keyed.flip - */ - flip(): Seq.Keyed; - - [Symbol.iterator](): IterableIterator<[K, V]>; - } - - /** - * `Seq` which represents an ordered indexed list of values. - */ - namespace Indexed { - /** - * Provides an Seq.Indexed of the values provided. - */ - function of(...values: Array): Seq.Indexed; - } - - /** - * Always returns Seq.Indexed, discarding associated keys and - * supplying incrementing indices. - * - * Note: `Seq.Indexed` is a conversion function and not a class, and does - * not use the `new` keyword during construction. - */ - export function Indexed( - collection: Iterable | ArrayLike - ): Seq.Indexed; - - export interface Indexed extends Seq, Collection.Indexed { - /** - * Deeply converts this Indexed Seq to equivalent native JavaScript Array. - */ - toJS(): Array; - - /** - * Shallowly converts this Indexed Seq to equivalent native JavaScript Array. - */ - toJSON(): Array; - - /** - * Shallowly converts this collection to an Array. - */ - toArray(): Array; - - /** - * Returns itself - */ - toSeq(): this; - - /** - * Returns a new Seq with other collections concatenated to this one. - */ - concat( - ...valuesOrCollections: Array | C> - ): Seq.Indexed; - - /** - * Returns a new Seq.Indexed with values passed through a - * `mapper` function. - * - * ```js - * const { Seq } = require('immutable') - * Seq.Indexed([ 1, 2 ]).map(x => 10 * x) - * // Seq [ 10, 20 ] - * ``` - * - * Note: `map()` always returns a new instance, even if it produced the - * same value at every step. - */ - map( - mapper: (value: T, key: number, iter: this) => M, - context?: unknown - ): Seq.Indexed; - - /** - * Flat-maps the Seq, returning a a Seq of the same type. - * - * Similar to `seq.map(...).flatten(true)`. - */ - flatMap( - mapper: (value: T, key: number, iter: this) => Iterable, - context?: unknown - ): Seq.Indexed; - - /** - * Returns a new Seq with only the values for which the `predicate` - * function returns true. - * - * Note: `filter()` always returns a new instance, even if it results in - * not filtering out any values. - */ - filter( - predicate: (value: T, index: number, iter: this) => value is F, - context?: unknown - ): Seq.Indexed; - filter( - predicate: (value: T, index: number, iter: this) => unknown, - context?: unknown - ): this; - - /** - * Returns a Seq "zipped" with the provided collections. - * - * Like `zipWith`, but using the default `zipper`: creating an `Array`. - * - * ```js - * const a = Seq([ 1, 2, 3 ]); - * const b = Seq([ 4, 5, 6 ]); - * const c = a.zip(b); // Seq [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] - * ``` - */ - zip(other: Collection): Seq.Indexed<[T, U]>; - zip( - other: Collection, - other2: Collection - ): Seq.Indexed<[T, U, V]>; - zip( - ...collections: Array> - ): Seq.Indexed; - - /** - * Returns a Seq "zipped" with the provided collections. - * - * Unlike `zip`, `zipAll` continues zipping until the longest collection is - * exhausted. Missing values from shorter collections are filled with `undefined`. - * - * ```js - * const a = Seq([ 1, 2 ]); - * const b = Seq([ 3, 4, 5 ]); - * const c = a.zipAll(b); // Seq [ [ 1, 3 ], [ 2, 4 ], [ undefined, 5 ] ] - * ``` - */ - zipAll(other: Collection): Seq.Indexed<[T, U]>; - zipAll( - other: Collection, - other2: Collection - ): Seq.Indexed<[T, U, V]>; - zipAll( - ...collections: Array> - ): Seq.Indexed; - - /** - * Returns a Seq "zipped" with the provided collections by using a - * custom `zipper` function. - * - * ```js - * const a = Seq([ 1, 2, 3 ]); - * const b = Seq([ 4, 5, 6 ]); - * const c = a.zipWith((a, b) => a + b, b); - * // Seq [ 5, 7, 9 ] - * ``` - */ - zipWith( - zipper: (value: T, otherValue: U) => Z, - otherCollection: Collection - ): Seq.Indexed; - zipWith( - zipper: (value: T, otherValue: U, thirdValue: V) => Z, - otherCollection: Collection, - thirdCollection: Collection - ): Seq.Indexed; - zipWith( - zipper: (...values: Array) => Z, - ...collections: Array> - ): Seq.Indexed; - - [Symbol.iterator](): IterableIterator; - } - - /** - * `Seq` which represents a set of values. - * - * Because `Seq` are often lazy, `Seq.Set` does not provide the same guarantee - * of value uniqueness as the concrete `Set`. - */ - export namespace Set { - /** - * Returns a Seq.Set of the provided values - */ - function of(...values: Array): Seq.Set; - } - - /** - * Always returns a Seq.Set, discarding associated indices or keys. - * - * Note: `Seq.Set` is a conversion function and not a class, and does not - * use the `new` keyword during construction. - */ - export function Set(collection: Iterable | ArrayLike): Seq.Set; - - export interface Set extends Seq, Collection.Set { - /** - * Deeply converts this Set Seq to equivalent native JavaScript Array. - */ - toJS(): Array; - - /** - * Shallowly converts this Set Seq to equivalent native JavaScript Array. - */ - toJSON(): Array; - - /** - * Shallowly converts this collection to an Array. - */ - toArray(): Array; - - /** - * Returns itself - */ - toSeq(): this; - - /** - * Returns a new Seq with other collections concatenated to this one. - * - * All entries will be present in the resulting Seq, even if they - * are duplicates. - */ - concat(...collections: Array>): Seq.Set; - - /** - * Returns a new Seq.Set with values passed through a - * `mapper` function. - * - * ```js - * Seq.Set([ 1, 2 ]).map(x => 10 * x) - * // Seq { 10, 20 } - * ``` - * - * Note: `map()` always returns a new instance, even if it produced the - * same value at every step. - */ - map( - mapper: (value: T, key: T, iter: this) => M, - context?: unknown - ): Seq.Set; - - /** - * Flat-maps the Seq, returning a Seq of the same type. - * - * Similar to `seq.map(...).flatten(true)`. - */ - flatMap( - mapper: (value: T, key: T, iter: this) => Iterable, - context?: unknown - ): Seq.Set; - - /** - * Returns a new Seq with only the values for which the `predicate` - * function returns true. - * - * Note: `filter()` always returns a new instance, even if it results in - * not filtering out any values. - */ - filter( - predicate: (value: T, key: T, iter: this) => value is F, - context?: unknown - ): Seq.Set; - filter( - predicate: (value: T, key: T, iter: this) => unknown, - context?: unknown - ): this; - - [Symbol.iterator](): IterableIterator; - } - } - - /** - * Creates a Seq. - * - * Returns a particular kind of `Seq` based on the input. - * - * * If a `Seq`, that same `Seq`. - * * If an `Collection`, a `Seq` of the same kind (Keyed, Indexed, or Set). - * * If an Array-like, an `Seq.Indexed`. - * * If an Iterable Object, an `Seq.Indexed`. - * * If an Object, a `Seq.Keyed`. - * - * Note: An Iterator itself will be treated as an object, becoming a `Seq.Keyed`, - * which is usually not what you want. You should turn your Iterator Object into - * an iterable object by defining a Symbol.iterator (or @@iterator) method which - * returns `this`. - * - * Note: `Seq` is a conversion function and not a class, and does not use the - * `new` keyword during construction. - */ - export function Seq>(seq: S): S; - export function Seq( - collection: Collection.Keyed - ): Seq.Keyed; - export function Seq(collection: Collection.Set): Seq.Set; - export function Seq( - collection: Collection.Indexed | Iterable | ArrayLike - ): Seq.Indexed; - export function Seq(obj: { [key: string]: V }): Seq.Keyed; - export function Seq(): Seq; - - export interface Seq extends Collection { - /** - * Some Seqs can describe their size lazily. When this is the case, - * size will be an integer. Otherwise it will be undefined. - * - * For example, Seqs returned from `map()` or `reverse()` - * preserve the size of the original `Seq` while `filter()` does not. - * - * Note: `Range`, `Repeat` and `Seq`s made from `Array`s and `Object`s will - * always have a size. - */ - readonly size: number | undefined; - - // Force evaluation - - /** - * Because Sequences are lazy and designed to be chained together, they do - * not cache their results. For example, this map function is called a total - * of 6 times, as each `join` iterates the Seq of three values. - * - * var squares = Seq([ 1, 2, 3 ]).map(x => x * x) - * squares.join() + squares.join() - * - * If you know a `Seq` will be used multiple times, it may be more - * efficient to first cache it in memory. Here, the map function is called - * only 3 times. - * - * var squares = Seq([ 1, 2, 3 ]).map(x => x * x).cacheResult() - * squares.join() + squares.join() - * - * Use this method judiciously, as it must fully evaluate a Seq which can be - * a burden on memory and possibly performance. - * - * Note: after calling `cacheResult`, a Seq will always have a `size`. - */ - cacheResult(): this; - - // Sequence algorithms - - /** - * Returns a new Seq with values passed through a - * `mapper` function. - * - * ```js - * const { Seq } = require('immutable') - * Seq([ 1, 2 ]).map(x => 10 * x) - * // Seq [ 10, 20 ] - * ``` - * - * Note: `map()` always returns a new instance, even if it produced the same - * value at every step. - */ - map( - mapper: (value: V, key: K, iter: this) => M, - context?: unknown - ): Seq; - - /** - * Returns a new Seq with values passed through a - * `mapper` function. - * - * ```js - * const { Seq } = require('immutable') - * Seq([ 1, 2 ]).map(x => 10 * x) - * // Seq [ 10, 20 ] - * ``` - * - * Note: `map()` always returns a new instance, even if it produced the same - * value at every step. - * Note: used only for sets. - */ - map( - mapper: (value: V, key: K, iter: this) => M, - context?: unknown - ): Seq; - - /** - * Flat-maps the Seq, returning a Seq of the same type. - * - * Similar to `seq.map(...).flatten(true)`. - */ - flatMap( - mapper: (value: V, key: K, iter: this) => Iterable, - context?: unknown - ): Seq; - - /** - * Flat-maps the Seq, returning a Seq of the same type. - * - * Similar to `seq.map(...).flatten(true)`. - * Note: Used only for sets. - */ - flatMap( - mapper: (value: V, key: K, iter: this) => Iterable, - context?: unknown - ): Seq; - - /** - * Returns a new Seq with only the values for which the `predicate` - * function returns true. - * - * Note: `filter()` always returns a new instance, even if it results in - * not filtering out any values. - */ - filter( - predicate: (value: V, key: K, iter: this) => value is F, - context?: unknown - ): Seq; - filter( - predicate: (value: V, key: K, iter: this) => unknown, - context?: unknown - ): this; - } - - /** - * The `Collection` is a set of (key, value) entries which can be iterated, and - * is the base class for all collections in `immutable`, allowing them to - * make use of all the Collection methods (such as `map` and `filter`). - * - * Note: A collection is always iterated in the same order, however that order - * may not always be well defined, as is the case for the `Map` and `Set`. - * - * Collection is the abstract base class for concrete data structures. It - * cannot be constructed directly. - * - * Implementations should extend one of the subclasses, `Collection.Keyed`, - * `Collection.Indexed`, or `Collection.Set`. - */ - export namespace Collection { - /** - * @deprecated use `const { isKeyed } = require('immutable')` - */ - function isKeyed( - maybeKeyed: unknown - ): maybeKeyed is Collection.Keyed; - - /** - * @deprecated use `const { isIndexed } = require('immutable')` - */ - function isIndexed( - maybeIndexed: unknown - ): maybeIndexed is Collection.Indexed; - - /** - * @deprecated use `const { isAssociative } = require('immutable')` - */ - function isAssociative( - maybeAssociative: unknown - ): maybeAssociative is - | Collection.Keyed - | Collection.Indexed; - - /** - * @deprecated use `const { isOrdered } = require('immutable')` - */ - function isOrdered(maybeOrdered: unknown): boolean; - - /** - * Keyed Collections have discrete keys tied to each value. - * - * When iterating `Collection.Keyed`, each iteration will yield a `[K, V]` - * tuple, in other words, `Collection#entries` is the default iterator for - * Keyed Collections. - */ - export namespace Keyed {} - - /** - * Creates a Collection.Keyed - * - * Similar to `Collection()`, however it expects collection-likes of [K, V] - * tuples if not constructed from a Collection.Keyed or JS Object. - * - * Note: `Collection.Keyed` is a conversion function and not a class, and - * does not use the `new` keyword during construction. - */ - export function Keyed( - collection: Iterable<[K, V]> - ): Collection.Keyed; - export function Keyed(obj: { - [key: string]: V; - }): Collection.Keyed; - - export interface Keyed extends Collection { - /** - * Deeply converts this Keyed collection to equivalent native JavaScript Object. - * - * Converts keys to Strings. - */ - toJS(): { [key: string]: unknown }; - - /** - * Shallowly converts this Keyed collection to equivalent native JavaScript Object. - * - * Converts keys to Strings. - */ - toJSON(): { [key: string]: V }; - - /** - * Shallowly converts this collection to an Array. - */ - toArray(): Array<[K, V]>; - - /** - * Returns Seq.Keyed. - * @override - */ - toSeq(): Seq.Keyed; - - // Sequence functions - - /** - * Returns a new Collection.Keyed of the same type where the keys and values - * have been flipped. - * - * - * ```js - * const { Map } = require('immutable') - * Map({ a: 'z', b: 'y' }).flip() - * // Map { "z": "a", "y": "b" } - * ``` - */ - flip(): Collection.Keyed; - - /** - * Returns a new Collection with other collections concatenated to this one. - */ - concat( - ...collections: Array> - ): Collection.Keyed; - concat( - ...collections: Array<{ [key: string]: C }> - ): Collection.Keyed; - - /** - * Returns a new Collection.Keyed with values passed through a - * `mapper` function. - * - * ```js - * const { Collection } = require('immutable') - * Collection.Keyed({ a: 1, b: 2 }).map(x => 10 * x) - * // Seq { "a": 10, "b": 20 } - * ``` - * - * Note: `map()` always returns a new instance, even if it produced the - * same value at every step. - */ - map( - mapper: (value: V, key: K, iter: this) => M, - context?: unknown - ): Collection.Keyed; - - /** - * Returns a new Collection.Keyed of the same type with keys passed through - * a `mapper` function. - * - * - * ```js - * const { Map } = require('immutable') - * Map({ a: 1, b: 2 }).mapKeys(x => x.toUpperCase()) - * // Map { "A": 1, "B": 2 } - * ``` - * - * Note: `mapKeys()` always returns a new instance, even if it produced - * the same key at every step. - */ - mapKeys( - mapper: (key: K, value: V, iter: this) => M, - context?: unknown - ): Collection.Keyed; - - /** - * Returns a new Collection.Keyed of the same type with entries - * ([key, value] tuples) passed through a `mapper` function. - * - * - * ```js - * const { Map } = require('immutable') - * Map({ a: 1, b: 2 }) - * .mapEntries(([ k, v ]) => [ k.toUpperCase(), v * 2 ]) - * // Map { "A": 2, "B": 4 } - * ``` - * - * Note: `mapEntries()` always returns a new instance, even if it produced - * the same entry at every step. - * - * If the mapper function returns `undefined`, then the entry will be filtered - */ - mapEntries( - mapper: ( - entry: [K, V], - index: number, - iter: this - ) => [KM, VM] | undefined, - context?: unknown - ): Collection.Keyed; - - /** - * Flat-maps the Collection, returning a Collection of the same type. - * - * Similar to `collection.map(...).flatten(true)`. - */ - flatMap( - mapper: (value: V, key: K, iter: this) => Iterable<[KM, VM]>, - context?: unknown - ): Collection.Keyed; - - /** - * Returns a new Collection with only the values for which the `predicate` - * function returns true. - * - * Note: `filter()` always returns a new instance, even if it results in - * not filtering out any values. - */ - filter( - predicate: (value: V, key: K, iter: this) => value is F, - context?: unknown - ): Collection.Keyed; - filter( - predicate: (value: V, key: K, iter: this) => unknown, - context?: unknown - ): this; - - [Symbol.iterator](): IterableIterator<[K, V]>; - } - - /** - * Indexed Collections have incrementing numeric keys. They exhibit - * slightly different behavior than `Collection.Keyed` for some methods in order - * to better mirror the behavior of JavaScript's `Array`, and add methods - * which do not make sense on non-indexed Collections such as `indexOf`. - * - * Unlike JavaScript arrays, `Collection.Indexed`s are always dense. "Unset" - * indices and `undefined` indices are indistinguishable, and all indices from - * 0 to `size` are visited when iterated. - * - * All Collection.Indexed methods return re-indexed Collections. In other words, - * indices always start at 0 and increment until size. If you wish to - * preserve indices, using them as keys, convert to a Collection.Keyed by - * calling `toKeyedSeq`. - */ - export namespace Indexed {} - - /** - * Creates a new Collection.Indexed. - * - * Note: `Collection.Indexed` is a conversion function and not a class, and - * does not use the `new` keyword during construction. - */ - export function Indexed( - collection: Iterable | ArrayLike - ): Collection.Indexed; - - export interface Indexed extends Collection { - /** - * Deeply converts this Indexed collection to equivalent native JavaScript Array. - */ - toJS(): Array; - - /** - * Shallowly converts this Indexed collection to equivalent native JavaScript Array. - */ - toJSON(): Array; - - /** - * Shallowly converts this collection to an Array. - */ - toArray(): Array; - - // Reading values - - /** - * Returns the value associated with the provided index, or notSetValue if - * the index is beyond the bounds of the Collection. - * - * `index` may be a negative number, which indexes back from the end of the - * Collection. `s.get(-1)` gets the last item in the Collection. - */ - get(index: number, notSetValue: NSV): T | NSV; - get(index: number): T | undefined; - - // Conversion to Seq - - /** - * Returns Seq.Indexed. - * @override - */ - toSeq(): Seq.Indexed; - - /** - * If this is a collection of [key, value] entry tuples, it will return a - * Seq.Keyed of those entries. - */ - fromEntrySeq(): Seq.Keyed; - - // Combination - - /** - * Returns a Collection of the same type with `separator` between each item - * in this Collection. - */ - interpose(separator: T): this; - - /** - * Returns a Collection of the same type with the provided `collections` - * interleaved into this collection. - * - * The resulting Collection includes the first item from each, then the - * second from each, etc. - * - * - * ```js - * const { List } = require('immutable') - * List([ 1, 2, 3 ]).interleave(List([ 'A', 'B', 'C' ])) - * // List [ 1, "A", 2, "B", 3, "C" ] - * ``` - * - * The shortest Collection stops interleave. - * - * - * ```js - * List([ 1, 2, 3 ]).interleave( - * List([ 'A', 'B' ]), - * List([ 'X', 'Y', 'Z' ]) - * ) - * // List [ 1, "A", "X", 2, "B", "Y" ] - * ``` - * - * Since `interleave()` re-indexes values, it produces a complete copy, - * which has `O(N)` complexity. - * - * Note: `interleave` *cannot* be used in `withMutations`. - */ - interleave(...collections: Array>): this; - - /** - * Splice returns a new indexed Collection by replacing a region of this - * Collection with new values. If values are not provided, it only skips the - * region to be removed. - * - * `index` may be a negative number, which indexes back from the end of the - * Collection. `s.splice(-2)` splices after the second to last item. - * - * - * ```js - * const { List } = require('immutable') - * List([ 'a', 'b', 'c', 'd' ]).splice(1, 2, 'q', 'r', 's') - * // List [ "a", "q", "r", "s", "d" ] - * ``` - * - * Since `splice()` re-indexes values, it produces a complete copy, which - * has `O(N)` complexity. - * - * Note: `splice` *cannot* be used in `withMutations`. - */ - splice(index: number, removeNum: number, ...values: Array): this; - - /** - * Returns a Collection of the same type "zipped" with the provided - * collections. - * - * Like `zipWith`, but using the default `zipper`: creating an `Array`. - * - * - * - * ```js - * const a = List([ 1, 2, 3 ]); - * const b = List([ 4, 5, 6 ]); - * const c = a.zip(b); // List [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] - * ``` - */ - zip(other: Collection): Collection.Indexed<[T, U]>; - zip( - other: Collection, - other2: Collection - ): Collection.Indexed<[T, U, V]>; - zip( - ...collections: Array> - ): Collection.Indexed; - - /** - * Returns a Collection "zipped" with the provided collections. - * - * Unlike `zip`, `zipAll` continues zipping until the longest collection is - * exhausted. Missing values from shorter collections are filled with `undefined`. - * - * ```js - * const a = List([ 1, 2 ]); - * const b = List([ 3, 4, 5 ]); - * const c = a.zipAll(b); // List [ [ 1, 3 ], [ 2, 4 ], [ undefined, 5 ] ] - * ``` - */ - zipAll(other: Collection): Collection.Indexed<[T, U]>; - zipAll( - other: Collection, - other2: Collection - ): Collection.Indexed<[T, U, V]>; - zipAll( - ...collections: Array> - ): Collection.Indexed; - - /** - * Returns a Collection of the same type "zipped" with the provided - * collections by using a custom `zipper` function. - * - * - * ```js - * const a = List([ 1, 2, 3 ]); - * const b = List([ 4, 5, 6 ]); - * const c = a.zipWith((a, b) => a + b, b); - * // List [ 5, 7, 9 ] - * ``` - */ - zipWith( - zipper: (value: T, otherValue: U) => Z, - otherCollection: Collection - ): Collection.Indexed; - zipWith( - zipper: (value: T, otherValue: U, thirdValue: V) => Z, - otherCollection: Collection, - thirdCollection: Collection - ): Collection.Indexed; - zipWith( - zipper: (...values: Array) => Z, - ...collections: Array> - ): Collection.Indexed; - - // Search for value - - /** - * Returns the first index at which a given value can be found in the - * Collection, or -1 if it is not present. - */ - indexOf(searchValue: T): number; - - /** - * Returns the last index at which a given value can be found in the - * Collection, or -1 if it is not present. - */ - lastIndexOf(searchValue: T): number; - - /** - * Returns the first index in the Collection where a value satisfies the - * provided predicate function. Otherwise -1 is returned. - */ - findIndex( - predicate: (value: T, index: number, iter: this) => boolean, - context?: unknown - ): number; - - /** - * Returns the last index in the Collection where a value satisfies the - * provided predicate function. Otherwise -1 is returned. - */ - findLastIndex( - predicate: (value: T, index: number, iter: this) => boolean, - context?: unknown - ): number; - - // Sequence algorithms - - /** - * Returns a new Collection with other collections concatenated to this one. - */ - concat( - ...valuesOrCollections: Array | C> - ): Collection.Indexed; - - /** - * Returns a new Collection.Indexed with values passed through a - * `mapper` function. - * - * ```js - * const { Collection } = require('immutable') - * Collection.Indexed([1,2]).map(x => 10 * x) - * // Seq [ 1, 2 ] - * ``` - * - * Note: `map()` always returns a new instance, even if it produced the - * same value at every step. - */ - map( - mapper: (value: T, key: number, iter: this) => M, - context?: unknown - ): Collection.Indexed; - - /** - * Flat-maps the Collection, returning a Collection of the same type. - * - * Similar to `collection.map(...).flatten(true)`. - */ - flatMap( - mapper: (value: T, key: number, iter: this) => Iterable, - context?: unknown - ): Collection.Indexed; - - /** - * Returns a new Collection with only the values for which the `predicate` - * function returns true. - * - * Note: `filter()` always returns a new instance, even if it results in - * not filtering out any values. - */ - filter( - predicate: (value: T, index: number, iter: this) => value is F, - context?: unknown - ): Collection.Indexed; - filter( - predicate: (value: T, index: number, iter: this) => unknown, - context?: unknown - ): this; - - [Symbol.iterator](): IterableIterator; - } - - /** - * Set Collections only represent values. They have no associated keys or - * indices. Duplicate values are possible in the lazy `Seq.Set`s, however - * the concrete `Set` Collection does not allow duplicate values. - * - * Collection methods on Collection.Set such as `map` and `forEach` will provide - * the value as both the first and second arguments to the provided function. - * - * ```js - * const { Collection } = require('immutable') - * const seq = Collection.Set([ 'A', 'B', 'C' ]) - * // Seq { "A", "B", "C" } - * seq.forEach((v, k) => - * assert.equal(v, k) - * ) - * ``` - */ - export namespace Set {} - - /** - * Similar to `Collection()`, but always returns a Collection.Set. - * - * Note: `Collection.Set` is a factory function and not a class, and does - * not use the `new` keyword during construction. - */ - export function Set( - collection: Iterable | ArrayLike - ): Collection.Set; - - export interface Set extends Collection { - /** - * Deeply converts this Set collection to equivalent native JavaScript Array. - */ - toJS(): Array; - - /** - * Shallowly converts this Set collection to equivalent native JavaScript Array. - */ - toJSON(): Array; - - /** - * Shallowly converts this collection to an Array. - */ - toArray(): Array; - - /** - * Returns Seq.Set. - * @override - */ - toSeq(): Seq.Set; - - // Sequence algorithms - - /** - * Returns a new Collection with other collections concatenated to this one. - */ - concat(...collections: Array>): Collection.Set; - - /** - * Returns a new Collection.Set with values passed through a - * `mapper` function. - * - * ``` - * Collection.Set([ 1, 2 ]).map(x => 10 * x) - * // Seq { 1, 2 } - * ``` - * - * Note: `map()` always returns a new instance, even if it produced the - * same value at every step. - */ - map( - mapper: (value: T, key: T, iter: this) => M, - context?: unknown - ): Collection.Set; - - /** - * Flat-maps the Collection, returning a Collection of the same type. - * - * Similar to `collection.map(...).flatten(true)`. - */ - flatMap( - mapper: (value: T, key: T, iter: this) => Iterable, - context?: unknown - ): Collection.Set; - - /** - * Returns a new Collection with only the values for which the `predicate` - * function returns true. - * - * Note: `filter()` always returns a new instance, even if it results in - * not filtering out any values. - */ - filter( - predicate: (value: T, key: T, iter: this) => value is F, - context?: unknown - ): Collection.Set; - filter( - predicate: (value: T, key: T, iter: this) => unknown, - context?: unknown - ): this; - - [Symbol.iterator](): IterableIterator; - } - } - - /** - * Creates a Collection. - * - * The type of Collection created is based on the input. - * - * * If an `Collection`, that same `Collection`. - * * If an Array-like, an `Collection.Indexed`. - * * If an Object with an Iterator defined, an `Collection.Indexed`. - * * If an Object, an `Collection.Keyed`. - * - * This methods forces the conversion of Objects and Strings to Collections. - * If you want to ensure that a Collection of one item is returned, use - * `Seq.of`. - * - * Note: An Iterator itself will be treated as an object, becoming a `Seq.Keyed`, - * which is usually not what you want. You should turn your Iterator Object into - * an iterable object by defining a Symbol.iterator (or @@iterator) method which - * returns `this`. - * - * Note: `Collection` is a conversion function and not a class, and does not - * use the `new` keyword during construction. - */ - export function Collection>( - collection: I - ): I; - export function Collection( - collection: Iterable | ArrayLike - ): Collection.Indexed; - export function Collection(obj: { - [key: string]: V; - }): Collection.Keyed; - - export interface Collection extends ValueObject { - // Value equality - - /** - * True if this and the other Collection have value equality, as defined - * by `Immutable.is()`. - * - * Note: This is equivalent to `Immutable.is(this, other)`, but provided to - * allow for chained expressions. - */ - equals(other: unknown): boolean; - - /** - * Computes and returns the hashed identity for this Collection. - * - * The `hashCode` of a Collection is used to determine potential equality, - * and is used when adding this to a `Set` or as a key in a `Map`, enabling - * lookup via a different instance. - * - * - * ```js - * const a = List([ 1, 2, 3 ]); - * const b = List([ 1, 2, 3 ]); - * assert.notStrictEqual(a, b); // different instances - * const set = Set([ a ]); - * assert.equal(set.has(b), true); - * ``` - * - * If two values have the same `hashCode`, they are [not guaranteed - * to be equal][Hash Collision]. If two values have different `hashCode`s, - * they must not be equal. - * - * [Hash Collision]: https://en.wikipedia.org/wiki/Collision_(computer_science) - */ - hashCode(): number; - - // Reading values - - /** - * Returns the value associated with the provided key, or notSetValue if - * the Collection does not contain this key. - * - * Note: it is possible a key may be associated with an `undefined` value, - * so if `notSetValue` is not provided and this method returns `undefined`, - * that does not guarantee the key was not found. - */ - get(key: K, notSetValue: NSV): V | NSV; - get(key: K): V | undefined; - - /** - * True if a key exists within this `Collection`, using `Immutable.is` - * to determine equality - */ - has(key: K): boolean; - - /** - * True if a value exists within this `Collection`, using `Immutable.is` - * to determine equality - * @alias contains - */ - includes(value: V): boolean; - contains(value: V): boolean; - - /** - * In case the `Collection` is not empty returns the first element of the - * `Collection`. - * In case the `Collection` is empty returns the optional default - * value if provided, if no default value is provided returns undefined. - */ - first(notSetValue?: NSV): V | NSV; - - /** - * In case the `Collection` is not empty returns the last element of the - * `Collection`. - * In case the `Collection` is empty returns the optional default - * value if provided, if no default value is provided returns undefined. - */ - last(notSetValue?: NSV): V | NSV; - - // Reading deep values - - /** - * Returns the value found by following a path of keys or indices through - * nested Collections. - * - * - * ```js - * const { Map, List } = require('immutable') - * const deepData = Map({ x: List([ Map({ y: 123 }) ]) }); - * deepData.getIn(['x', 0, 'y']) // 123 - * ``` - * - * Plain JavaScript Object or Arrays may be nested within an Immutable.js - * Collection, and getIn() can access those values as well: - * - * - * ```js - * const { Map, List } = require('immutable') - * const deepData = Map({ x: [ { y: 123 } ] }); - * deepData.getIn(['x', 0, 'y']) // 123 - * ``` - */ - getIn(searchKeyPath: Iterable, notSetValue?: unknown): unknown; - - /** - * True if the result of following a path of keys or indices through nested - * Collections results in a set value. - */ - hasIn(searchKeyPath: Iterable): boolean; - - // Persistent changes - - /** - * This can be very useful as a way to "chain" a normal function into a - * sequence of methods. RxJS calls this "let" and lodash calls it "thru". - * - * For example, to sum a Seq after mapping and filtering: - * - * - * ```js - * const { Seq } = require('immutable') - * - * function sum(collection) { - * return collection.reduce((sum, x) => sum + x, 0) - * } - * - * Seq([ 1, 2, 3 ]) - * .map(x => x + 1) - * .filter(x => x % 2 === 0) - * .update(sum) - * // 6 - * ``` - */ - update(updater: (value: this) => R): R; - - // Conversion to JavaScript types - - /** - * Deeply converts this Collection to equivalent native JavaScript Array or Object. - * - * `Collection.Indexed`, and `Collection.Set` become `Array`, while - * `Collection.Keyed` become `Object`, converting keys to Strings. - */ - toJS(): Array | { [key: string]: unknown }; - - /** - * Shallowly converts this Collection to equivalent native JavaScript Array or Object. - * - * `Collection.Indexed`, and `Collection.Set` become `Array`, while - * `Collection.Keyed` become `Object`, converting keys to Strings. - */ - toJSON(): Array | { [key: string]: V }; - - /** - * Shallowly converts this collection to an Array. - * - * `Collection.Indexed`, and `Collection.Set` produce an Array of values. - * `Collection.Keyed` produce an Array of [key, value] tuples. - */ - toArray(): Array | Array<[K, V]>; - - /** - * Shallowly converts this Collection to an Object. - * - * Converts keys to Strings. - */ - toObject(): { [key: string]: V }; - - // Conversion to Collections - - /** - * Converts this Collection to a Map, Throws if keys are not hashable. - * - * Note: This is equivalent to `Map(this.toKeyedSeq())`, but provided - * for convenience and to allow for chained expressions. - */ - toMap(): Map; - - /** - * Converts this Collection to a Map, maintaining the order of iteration. - * - * Note: This is equivalent to `OrderedMap(this.toKeyedSeq())`, but - * provided for convenience and to allow for chained expressions. - */ - toOrderedMap(): OrderedMap; - - /** - * Converts this Collection to a Set, discarding keys. Throws if values - * are not hashable. - * - * Note: This is equivalent to `Set(this)`, but provided to allow for - * chained expressions. - */ - toSet(): Set; - - /** - * Converts this Collection to a Set, maintaining the order of iteration and - * discarding keys. - * - * Note: This is equivalent to `OrderedSet(this.valueSeq())`, but provided - * for convenience and to allow for chained expressions. - */ - toOrderedSet(): OrderedSet; - - /** - * Converts this Collection to a List, discarding keys. - * - * This is similar to `List(collection)`, but provided to allow for chained - * expressions. However, when called on `Map` or other keyed collections, - * `collection.toList()` discards the keys and creates a list of only the - * values, whereas `List(collection)` creates a list of entry tuples. - * - * - * ```js - * const { Map, List } = require('immutable') - * var myMap = Map({ a: 'Apple', b: 'Banana' }) - * List(myMap) // List [ [ "a", "Apple" ], [ "b", "Banana" ] ] - * myMap.toList() // List [ "Apple", "Banana" ] - * ``` - */ - toList(): List; - - /** - * Converts this Collection to a Stack, discarding keys. Throws if values - * are not hashable. - * - * Note: This is equivalent to `Stack(this)`, but provided to allow for - * chained expressions. - */ - toStack(): Stack; - - // Conversion to Seq - - /** - * Converts this Collection to a Seq of the same kind (indexed, - * keyed, or set). - */ - toSeq(): Seq; - - /** - * Returns a Seq.Keyed from this Collection where indices are treated as keys. - * - * This is useful if you want to operate on an - * Collection.Indexed and preserve the [index, value] pairs. - * - * The returned Seq will have identical iteration order as - * this Collection. - * - * - * ```js - * const { Seq } = require('immutable') - * const indexedSeq = Seq([ 'A', 'B', 'C' ]) - * // Seq [ "A", "B", "C" ] - * indexedSeq.filter(v => v === 'B') - * // Seq [ "B" ] - * const keyedSeq = indexedSeq.toKeyedSeq() - * // Seq { 0: "A", 1: "B", 2: "C" } - * keyedSeq.filter(v => v === 'B') - * // Seq { 1: "B" } - * ``` - */ - toKeyedSeq(): Seq.Keyed; - - /** - * Returns an Seq.Indexed of the values of this Collection, discarding keys. - */ - toIndexedSeq(): Seq.Indexed; - - /** - * Returns a Seq.Set of the values of this Collection, discarding keys. - */ - toSetSeq(): Seq.Set; - - // Iterators - - /** - * An iterator of this `Collection`'s keys. - * - * Note: this will return an ES6 iterator which does not support - * Immutable.js sequence algorithms. Use `keySeq` instead, if this is - * what you want. - */ - keys(): IterableIterator; - - /** - * An iterator of this `Collection`'s values. - * - * Note: this will return an ES6 iterator which does not support - * Immutable.js sequence algorithms. Use `valueSeq` instead, if this is - * what you want. - */ - values(): IterableIterator; - - /** - * An iterator of this `Collection`'s entries as `[ key, value ]` tuples. - * - * Note: this will return an ES6 iterator which does not support - * Immutable.js sequence algorithms. Use `entrySeq` instead, if this is - * what you want. - */ - entries(): IterableIterator<[K, V]>; - - [Symbol.iterator](): IterableIterator; - - // Collections (Seq) - - /** - * Returns a new Seq.Indexed of the keys of this Collection, - * discarding values. - */ - keySeq(): Seq.Indexed; - - /** - * Returns an Seq.Indexed of the values of this Collection, discarding keys. - */ - valueSeq(): Seq.Indexed; - - /** - * Returns a new Seq.Indexed of [key, value] tuples. - */ - entrySeq(): Seq.Indexed<[K, V]>; - - // Sequence algorithms - - /** - * Returns a new Collection of the same type with values passed through a - * `mapper` function. - * - * - * ```js - * const { Collection } = require('immutable') - * Collection({ a: 1, b: 2 }).map(x => 10 * x) - * // Seq { "a": 10, "b": 20 } - * ``` - * - * Note: `map()` always returns a new instance, even if it produced the same - * value at every step. - */ - map( - mapper: (value: V, key: K, iter: this) => M, - context?: unknown - ): Collection; - - /** - * Note: used only for sets, which return Collection but are otherwise - * identical to normal `map()`. - * - * @ignore - */ - map(...args: Array): unknown; - - /** - * Returns a new Collection of the same type with only the entries for which - * the `predicate` function returns true. - * - * - * ```js - * const { Map } = require('immutable') - * Map({ a: 1, b: 2, c: 3, d: 4}).filter(x => x % 2 === 0) - * // Map { "b": 2, "d": 4 } - * ``` - * - * Note: `filter()` always returns a new instance, even if it results in - * not filtering out any values. - */ - filter( - predicate: (value: V, key: K, iter: this) => value is F, - context?: unknown - ): Collection; - filter( - predicate: (value: V, key: K, iter: this) => unknown, - context?: unknown - ): this; - - /** - * Returns a new Collection of the same type with only the entries for which - * the `predicate` function returns false. - * - * - * ```js - * const { Map } = require('immutable') - * Map({ a: 1, b: 2, c: 3, d: 4}).filterNot(x => x % 2 === 0) - * // Map { "a": 1, "c": 3 } - * ``` - * - * Note: `filterNot()` always returns a new instance, even if it results in - * not filtering out any values. - */ - filterNot( - predicate: (value: V, key: K, iter: this) => boolean, - context?: unknown - ): this; - - /** - * Returns a new Collection of the same type in reverse order. - */ - reverse(): this; - - /** - * Returns a new Collection of the same type which includes the same entries, - * stably sorted by using a `comparator`. - * - * If a `comparator` is not provided, a default comparator uses `<` and `>`. - * - * `comparator(valueA, valueB)`: - * - * * Returns `0` if the elements should not be swapped. - * * Returns `-1` (or any negative number) if `valueA` comes before `valueB` - * * Returns `1` (or any positive number) if `valueA` comes after `valueB` - * * Is pure, i.e. it must always return the same value for the same pair - * of values. - * - * When sorting collections which have no defined order, their ordered - * equivalents will be returned. e.g. `map.sort()` returns OrderedMap. - * - * - * ```js - * const { Map } = require('immutable') - * Map({ "c": 3, "a": 1, "b": 2 }).sort((a, b) => { - * if (a < b) { return -1; } - * if (a > b) { return 1; } - * if (a === b) { return 0; } - * }); - * // OrderedMap { "a": 1, "b": 2, "c": 3 } - * ``` - * - * Note: `sort()` Always returns a new instance, even if the original was - * already sorted. - * - * Note: This is always an eager operation. - */ - sort(comparator?: (valueA: V, valueB: V) => number): this; - - /** - * Like `sort`, but also accepts a `comparatorValueMapper` which allows for - * sorting by more sophisticated means: - * - * - * ```js - * const { Map } = require('immutable') - * const beattles = Map({ - * John: { name: "Lennon" }, - * Paul: { name: "McCartney" }, - * George: { name: "Harrison" }, - * Ringo: { name: "Starr" }, - * }); - * beattles.sortBy(member => member.name); - * ``` - * - * Note: `sortBy()` Always returns a new instance, even if the original was - * already sorted. - * - * Note: This is always an eager operation. - */ - sortBy( - comparatorValueMapper: (value: V, key: K, iter: this) => C, - comparator?: (valueA: C, valueB: C) => number - ): this; - - /** - * Returns a `Collection.Keyed` of `Collection.Keyeds`, grouped by the return - * value of the `grouper` function. - * - * Note: This is always an eager operation. - * - * - * ```js - * const { List, Map } = require('immutable') - * const listOfMaps = List([ - * Map({ v: 0 }), - * Map({ v: 1 }), - * Map({ v: 1 }), - * Map({ v: 0 }), - * Map({ v: 2 }) - * ]) - * const groupsOfMaps = listOfMaps.groupBy(x => x.get('v')) - * // Map { - * // 0: List [ Map{ "v": 0 }, Map { "v": 0 } ], - * // 1: List [ Map{ "v": 1 }, Map { "v": 1 } ], - * // 2: List [ Map{ "v": 2 } ], - * // } - * ``` - */ - groupBy( - grouper: (value: V, key: K, iter: this) => G, - context?: unknown - ): /*Map*/ Seq.Keyed>; - - // Side effects - - /** - * The `sideEffect` is executed for every entry in the Collection. - * - * Unlike `Array#forEach`, if any call of `sideEffect` returns - * `false`, the iteration will stop. Returns the number of entries iterated - * (including the last iteration which returned false). - */ - forEach( - sideEffect: (value: V, key: K, iter: this) => unknown, - context?: unknown - ): number; - - // Creating subsets - - /** - * Returns a new Collection of the same type representing a portion of this - * Collection from start up to but not including end. - * - * If begin is negative, it is offset from the end of the Collection. e.g. - * `slice(-2)` returns a Collection of the last two entries. If it is not - * provided the new Collection will begin at the beginning of this Collection. - * - * If end is negative, it is offset from the end of the Collection. e.g. - * `slice(0, -1)` returns a Collection of everything but the last entry. If - * it is not provided, the new Collection will continue through the end of - * this Collection. - * - * If the requested slice is equivalent to the current Collection, then it - * will return itself. - */ - slice(begin?: number, end?: number): this; - - /** - * Returns a new Collection of the same type containing all entries except - * the first. - */ - rest(): this; - - /** - * Returns a new Collection of the same type containing all entries except - * the last. - */ - butLast(): this; - - /** - * Returns a new Collection of the same type which excludes the first `amount` - * entries from this Collection. - */ - skip(amount: number): this; - - /** - * Returns a new Collection of the same type which excludes the last `amount` - * entries from this Collection. - */ - skipLast(amount: number): this; - - /** - * Returns a new Collection of the same type which includes entries starting - * from when `predicate` first returns false. - * - * - * ```js - * const { List } = require('immutable') - * List([ 'dog', 'frog', 'cat', 'hat', 'god' ]) - * .skipWhile(x => x.match(/g/)) - * // List [ "cat", "hat", "god" ] - * ``` - */ - skipWhile( - predicate: (value: V, key: K, iter: this) => boolean, - context?: unknown - ): this; - - /** - * Returns a new Collection of the same type which includes entries starting - * from when `predicate` first returns true. - * - * - * ```js - * const { List } = require('immutable') - * List([ 'dog', 'frog', 'cat', 'hat', 'god' ]) - * .skipUntil(x => x.match(/hat/)) - * // List [ "hat", "god" ] - * ``` - */ - skipUntil( - predicate: (value: V, key: K, iter: this) => boolean, - context?: unknown - ): this; - - /** - * Returns a new Collection of the same type which includes the first `amount` - * entries from this Collection. - */ - take(amount: number): this; - - /** - * Returns a new Collection of the same type which includes the last `amount` - * entries from this Collection. - */ - takeLast(amount: number): this; - - /** - * Returns a new Collection of the same type which includes entries from this - * Collection as long as the `predicate` returns true. - * - * - * ```js - * const { List } = require('immutable') - * List([ 'dog', 'frog', 'cat', 'hat', 'god' ]) - * .takeWhile(x => x.match(/o/)) - * // List [ "dog", "frog" ] - * ``` - */ - takeWhile( - predicate: (value: V, key: K, iter: this) => boolean, - context?: unknown - ): this; - - /** - * Returns a new Collection of the same type which includes entries from this - * Collection as long as the `predicate` returns false. - * - * - * ```js - * const { List } = require('immutable') - * List([ 'dog', 'frog', 'cat', 'hat', 'god' ]) - * .takeUntil(x => x.match(/at/)) - * // List [ "dog", "frog" ] - * ``` - */ - takeUntil( - predicate: (value: V, key: K, iter: this) => boolean, - context?: unknown - ): this; - - // Combination - - /** - * Returns a new Collection of the same type with other values and - * collection-like concatenated to this one. - * - * For Seqs, all entries will be present in the resulting Seq, even if they - * have the same key. - */ - concat( - ...valuesOrCollections: Array - ): Collection; - - /** - * Flattens nested Collections. - * - * Will deeply flatten the Collection by default, returning a Collection of the - * same type, but a `depth` can be provided in the form of a number or - * boolean (where true means to shallowly flatten one level). A depth of 0 - * (or shallow: false) will deeply flatten. - * - * Flattens only others Collection, not Arrays or Objects. - * - * Note: `flatten(true)` operates on Collection> and - * returns Collection - */ - flatten(depth?: number): Collection; - // tslint:disable-next-line unified-signatures - flatten(shallow?: boolean): Collection; - - /** - * Flat-maps the Collection, returning a Collection of the same type. - * - * Similar to `collection.map(...).flatten(true)`. - */ - flatMap( - mapper: (value: V, key: K, iter: this) => Iterable, - context?: unknown - ): Collection; - - /** - * Flat-maps the Collection, returning a Collection of the same type. - * - * Similar to `collection.map(...).flatten(true)`. - * Used for Dictionaries only. - */ - flatMap( - mapper: (value: V, key: K, iter: this) => Iterable<[KM, VM]>, - context?: unknown - ): Collection; - - // Reducing a value - - /** - * Reduces the Collection to a value by calling the `reducer` for every entry - * in the Collection and passing along the reduced value. - * - * If `initialReduction` is not provided, the first item in the - * Collection will be used. - * - * @see `Array#reduce`. - */ - reduce( - reducer: (reduction: R, value: V, key: K, iter: this) => R, - initialReduction: R, - context?: unknown - ): R; - reduce( - reducer: (reduction: V | R, value: V, key: K, iter: this) => R - ): R; - - /** - * Reduces the Collection in reverse (from the right side). - * - * Note: Similar to this.reverse().reduce(), and provided for parity - * with `Array#reduceRight`. - */ - reduceRight( - reducer: (reduction: R, value: V, key: K, iter: this) => R, - initialReduction: R, - context?: unknown - ): R; - reduceRight( - reducer: (reduction: V | R, value: V, key: K, iter: this) => R - ): R; - - /** - * True if `predicate` returns true for all entries in the Collection. - */ - every( - predicate: (value: V, key: K, iter: this) => boolean, - context?: unknown - ): boolean; - - /** - * True if `predicate` returns true for any entry in the Collection. - */ - some( - predicate: (value: V, key: K, iter: this) => boolean, - context?: unknown - ): boolean; - - /** - * Joins values together as a string, inserting a separator between each. - * The default separator is `","`. - */ - join(separator?: string): string; - - /** - * Returns true if this Collection includes no values. - * - * For some lazy `Seq`, `isEmpty` might need to iterate to determine - * emptiness. At most one iteration will occur. - */ - isEmpty(): boolean; - - /** - * Returns the size of this Collection. - * - * Regardless of if this Collection can describe its size lazily (some Seqs - * cannot), this method will always return the correct size. E.g. it - * evaluates a lazy `Seq` if necessary. - * - * If `predicate` is provided, then this returns the count of entries in the - * Collection for which the `predicate` returns true. - */ - count(): number; - count( - predicate: (value: V, key: K, iter: this) => boolean, - context?: unknown - ): number; - - /** - * Returns a `Seq.Keyed` of counts, grouped by the return value of - * the `grouper` function. - * - * Note: This is not a lazy operation. - */ - countBy( - grouper: (value: V, key: K, iter: this) => G, - context?: unknown - ): Map; - - // Search for value - - /** - * Returns the first value for which the `predicate` returns true. - */ - find( - predicate: (value: V, key: K, iter: this) => boolean, - context?: unknown, - notSetValue?: V - ): V | undefined; - - /** - * Returns the last value for which the `predicate` returns true. - * - * Note: `predicate` will be called for each entry in reverse. - */ - findLast( - predicate: (value: V, key: K, iter: this) => boolean, - context?: unknown, - notSetValue?: V - ): V | undefined; - - /** - * Returns the first [key, value] entry for which the `predicate` returns true. - */ - findEntry( - predicate: (value: V, key: K, iter: this) => boolean, - context?: unknown, - notSetValue?: V - ): [K, V] | undefined; - - /** - * Returns the last [key, value] entry for which the `predicate` - * returns true. - * - * Note: `predicate` will be called for each entry in reverse. - */ - findLastEntry( - predicate: (value: V, key: K, iter: this) => boolean, - context?: unknown, - notSetValue?: V - ): [K, V] | undefined; - - /** - * Returns the key for which the `predicate` returns true. - */ - findKey( - predicate: (value: V, key: K, iter: this) => boolean, - context?: unknown - ): K | undefined; - - /** - * Returns the last key for which the `predicate` returns true. - * - * Note: `predicate` will be called for each entry in reverse. - */ - findLastKey( - predicate: (value: V, key: K, iter: this) => boolean, - context?: unknown - ): K | undefined; - - /** - * Returns the key associated with the search value, or undefined. - */ - keyOf(searchValue: V): K | undefined; - - /** - * Returns the last key associated with the search value, or undefined. - */ - lastKeyOf(searchValue: V): K | undefined; - - /** - * Returns the maximum value in this collection. If any values are - * comparatively equivalent, the first one found will be returned. - * - * The `comparator` is used in the same way as `Collection#sort`. If it is not - * provided, the default comparator is `>`. - * - * When two values are considered equivalent, the first encountered will be - * returned. Otherwise, `max` will operate independent of the order of input - * as long as the comparator is commutative. The default comparator `>` is - * commutative *only* when types do not differ. - * - * If `comparator` returns 0 and either value is NaN, undefined, or null, - * that value will be returned. - */ - max(comparator?: (valueA: V, valueB: V) => number): V | undefined; - - /** - * Like `max`, but also accepts a `comparatorValueMapper` which allows for - * comparing by more sophisticated means: - * - * - * ```js - * const { List, } = require('immutable'); - * const l = List([ - * { name: 'Bob', avgHit: 1 }, - * { name: 'Max', avgHit: 3 }, - * { name: 'Lili', avgHit: 2 } , - * ]); - * l.maxBy(i => i.avgHit); // will output { name: 'Max', avgHit: 3 } - * ``` - */ - maxBy( - comparatorValueMapper: (value: V, key: K, iter: this) => C, - comparator?: (valueA: C, valueB: C) => number - ): V | undefined; - - /** - * Returns the minimum value in this collection. If any values are - * comparatively equivalent, the first one found will be returned. - * - * The `comparator` is used in the same way as `Collection#sort`. If it is not - * provided, the default comparator is `<`. - * - * When two values are considered equivalent, the first encountered will be - * returned. Otherwise, `min` will operate independent of the order of input - * as long as the comparator is commutative. The default comparator `<` is - * commutative *only* when types do not differ. - * - * If `comparator` returns 0 and either value is NaN, undefined, or null, - * that value will be returned. - */ - min(comparator?: (valueA: V, valueB: V) => number): V | undefined; - - /** - * Like `min`, but also accepts a `comparatorValueMapper` which allows for - * comparing by more sophisticated means: - * - * - * ```js - * const { List, } = require('immutable'); - * const l = List([ - * { name: 'Bob', avgHit: 1 }, - * { name: 'Max', avgHit: 3 }, - * { name: 'Lili', avgHit: 2 } , - * ]); - * l.minBy(i => i.avgHit); // will output { name: 'Bob', avgHit: 1 } - * ``` - */ - minBy( - comparatorValueMapper: (value: V, key: K, iter: this) => C, - comparator?: (valueA: C, valueB: C) => number - ): V | undefined; - - // Comparison - - /** - * True if `iter` includes every value in this Collection. - */ - isSubset(iter: Iterable): boolean; - - /** - * True if this Collection includes every value in `iter`. - */ - isSuperset(iter: Iterable): boolean; - } - - /** - * The interface to fulfill to qualify as a Value Object. - */ - export interface ValueObject { - /** - * True if this and the other Collection have value equality, as defined - * by `Immutable.is()`. - * - * Note: This is equivalent to `Immutable.is(this, other)`, but provided to - * allow for chained expressions. - */ - equals(other: unknown): boolean; - - /** - * Computes and returns the hashed identity for this Collection. - * - * The `hashCode` of a Collection is used to determine potential equality, - * and is used when adding this to a `Set` or as a key in a `Map`, enabling - * lookup via a different instance. - * - * - * ```js - * const { List, Set } = require('immutable'); - * const a = List([ 1, 2, 3 ]); - * const b = List([ 1, 2, 3 ]); - * assert.notStrictEqual(a, b); // different instances - * const set = Set([ a ]); - * assert.equal(set.has(b), true); - * ``` - * - * Note: hashCode() MUST return a Uint32 number. The easiest way to - * guarantee this is to return `myHash | 0` from a custom implementation. - * - * If two values have the same `hashCode`, they are [not guaranteed - * to be equal][Hash Collision]. If two values have different `hashCode`s, - * they must not be equal. - * - * Note: `hashCode()` is not guaranteed to always be called before - * `equals()`. Most but not all Immutable.js collections use hash codes to - * organize their internal data structures, while all Immutable.js - * collections use equality during lookups. - * - * [Hash Collision]: https://en.wikipedia.org/wiki/Collision_(computer_science) - */ - hashCode(): number; - } - - /** - * Deeply converts plain JS objects and arrays to Immutable Maps and Lists. - * - * If a `reviver` is optionally provided, it will be called with every - * collection as a Seq (beginning with the most nested collections - * and proceeding to the top-level collection itself), along with the key - * referring to each collection and the parent JS object provided as `this`. - * For the top level, object, the key will be `""`. This `reviver` is expected - * to return a new Immutable Collection, allowing for custom conversions from - * deep JS objects. Finally, a `path` is provided which is the sequence of - * keys to this value from the starting value. - * - * `reviver` acts similarly to the [same parameter in `JSON.parse`][1]. - * - * If `reviver` is not provided, the default behavior will convert Objects - * into Maps and Arrays into Lists like so: - * - * - * ```js - * const { fromJS, isKeyed } = require('immutable') - * function (key, value) { - * return isKeyed(value) ? value.toMap() : value.toList() - * } - * ``` - * - * `fromJS` is conservative in its conversion. It will only convert - * arrays which pass `Array.isArray` to Lists, and only raw objects (no custom - * prototype) to Map. - * - * Accordingly, this example converts native JS data to OrderedMap and List: - * - * - * ```js - * const { fromJS, isKeyed } = require('immutable') - * fromJS({ a: {b: [10, 20, 30]}, c: 40}, function (key, value, path) { - * console.log(key, value, path) - * return isKeyed(value) ? value.toOrderedMap() : value.toList() - * }) - * - * > "b", [ 10, 20, 30 ], [ "a", "b" ] - * > "a", {b: [10, 20, 30]}, [ "a" ] - * > "", {a: {b: [10, 20, 30]}, c: 40}, [] - * ``` - * - * Keep in mind, when using JS objects to construct Immutable Maps, that - * JavaScript Object properties are always strings, even if written in a - * quote-less shorthand, while Immutable Maps accept keys of any type. - * - * - * ```js - * const { Map } = require('immutable') - * let obj = { 1: "one" }; - * Object.keys(obj); // [ "1" ] - * assert.equal(obj["1"], obj[1]); // "one" === "one" - * - * let map = Map(obj); - * assert.notEqual(map.get("1"), map.get(1)); // "one" !== undefined - * ``` - * - * Property access for JavaScript Objects first converts the key to a string, - * but since Immutable Map keys can be of any type the argument to `get()` is - * not altered. - * - * [1]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse#Example.3A_Using_the_reviver_parameter - * "Using the reviver parameter" - */ - export function fromJS( - jsValue: unknown, - reviver?: ( - key: string | number, - sequence: Collection.Keyed | Collection.Indexed, - path?: Array - ) => unknown - ): Collection; - - /** - * Value equality check with semantics similar to `Object.is`, but treats - * Immutable `Collection`s as values, equal if the second `Collection` includes - * equivalent values. - * - * It's used throughout Immutable when checking for equality, including `Map` - * key equality and `Set` membership. - * - * - * ```js - * const { Map, is } = require('immutable') - * const map1 = Map({ a: 1, b: 1, c: 1 }) - * const map2 = Map({ a: 1, b: 1, c: 1 }) - * assert.equal(map1 !== map2, true) - * assert.equal(Object.is(map1, map2), false) - * assert.equal(is(map1, map2), true) - * ``` - * - * `is()` compares primitive types like strings and numbers, Immutable.js - * collections like `Map` and `List`, but also any custom object which - * implements `ValueObject` by providing `equals()` and `hashCode()` methods. - * - * Note: Unlike `Object.is`, `Immutable.is` assumes `0` and `-0` are the same - * value, matching the behavior of ES6 Map key equality. - */ - export function is(first: unknown, second: unknown): boolean; - - /** - * The `hash()` function is an important part of how Immutable determines if - * two values are equivalent and is used to determine how to store those - * values. Provided with any value, `hash()` will return a 31-bit integer. - * - * When designing Objects which may be equal, it's important that when a - * `.equals()` method returns true, that both values `.hashCode()` method - * return the same value. `hash()` may be used to produce those values. - * - * For non-Immutable Objects that do not provide a `.hashCode()` functions - * (including plain Objects, plain Arrays, Date objects, etc), a unique hash - * value will be created for each *instance*. That is, the create hash - * represents referential equality, and not value equality for Objects. This - * ensures that if that Object is mutated over time that its hash code will - * remain consistent, allowing Objects to be used as keys and values in - * Immutable.js collections. - * - * Note that `hash()` attempts to balance between speed and avoiding - * collisions, however it makes no attempt to produce secure hashes. - * - * *New in Version 4.0* - */ - export function hash(value: unknown): number; - - /** - * True if `maybeImmutable` is an Immutable Collection or Record. - * - * Note: Still returns true even if the collections is within a `withMutations()`. - * - * - * ```js - * const { isImmutable, Map, List, Stack } = require('immutable'); - * isImmutable([]); // false - * isImmutable({}); // false - * isImmutable(Map()); // true - * isImmutable(List()); // true - * isImmutable(Stack()); // true - * isImmutable(Map().asMutable()); // true - * ``` - */ - export function isImmutable( - maybeImmutable: unknown - ): maybeImmutable is Collection; - - /** - * True if `maybeCollection` is a Collection, or any of its subclasses. - * - * - * ```js - * const { isCollection, Map, List, Stack } = require('immutable'); - * isCollection([]); // false - * isCollection({}); // false - * isCollection(Map()); // true - * isCollection(List()); // true - * isCollection(Stack()); // true - * ``` - */ - export function isCollection( - maybeCollection: unknown - ): maybeCollection is Collection; - - /** - * True if `maybeKeyed` is a Collection.Keyed, or any of its subclasses. - * - * - * ```js - * const { isKeyed, Map, List, Stack } = require('immutable'); - * isKeyed([]); // false - * isKeyed({}); // false - * isKeyed(Map()); // true - * isKeyed(List()); // false - * isKeyed(Stack()); // false - * ``` - */ - export function isKeyed( - maybeKeyed: unknown - ): maybeKeyed is Collection.Keyed; - - /** - * True if `maybeIndexed` is a Collection.Indexed, or any of its subclasses. - * - * - * ```js - * const { isIndexed, Map, List, Stack, Set } = require('immutable'); - * isIndexed([]); // false - * isIndexed({}); // false - * isIndexed(Map()); // false - * isIndexed(List()); // true - * isIndexed(Stack()); // true - * isIndexed(Set()); // false - * ``` - */ - export function isIndexed( - maybeIndexed: unknown - ): maybeIndexed is Collection.Indexed; - - /** - * True if `maybeAssociative` is either a Keyed or Indexed Collection. - * - * - * ```js - * const { isAssociative, Map, List, Stack, Set } = require('immutable'); - * isAssociative([]); // false - * isAssociative({}); // false - * isAssociative(Map()); // true - * isAssociative(List()); // true - * isAssociative(Stack()); // true - * isAssociative(Set()); // false - * ``` - */ - export function isAssociative( - maybeAssociative: unknown - ): maybeAssociative is - | Collection.Keyed - | Collection.Indexed; - - /** - * True if `maybeOrdered` is a Collection where iteration order is well - * defined. True for Collection.Indexed as well as OrderedMap and OrderedSet. - * - * - * ```js - * const { isOrdered, Map, OrderedMap, List, Set } = require('immutable'); - * isOrdered([]); // false - * isOrdered({}); // false - * isOrdered(Map()); // false - * isOrdered(OrderedMap()); // true - * isOrdered(List()); // true - * isOrdered(Set()); // false - * ``` - */ - export function isOrdered(maybeOrdered: unknown): boolean; - - /** - * True if `maybeValue` is a JavaScript Object which has *both* `equals()` - * and `hashCode()` methods. - * - * Any two instances of *value objects* can be compared for value equality with - * `Immutable.is()` and can be used as keys in a `Map` or members in a `Set`. - */ - export function isValueObject(maybeValue: unknown): maybeValue is ValueObject; - - /** - * True if `maybeSeq` is a Seq. - */ - export function isSeq( - maybeSeq: unknown - ): maybeSeq is - | Seq.Indexed - | Seq.Keyed - | Seq.Set; - - /** - * True if `maybeList` is a List. - */ - export function isList(maybeList: unknown): maybeList is List; - - /** - * True if `maybeMap` is a Map. - * - * Also true for OrderedMaps. - */ - export function isMap(maybeMap: unknown): maybeMap is Map; - - /** - * True if `maybeOrderedMap` is an OrderedMap. - */ - export function isOrderedMap( - maybeOrderedMap: unknown - ): maybeOrderedMap is OrderedMap; - - /** - * True if `maybeStack` is a Stack. - */ - export function isStack(maybeStack: unknown): maybeStack is Stack; - - /** - * True if `maybeSet` is a Set. - * - * Also true for OrderedSets. - */ - export function isSet(maybeSet: unknown): maybeSet is Set; - - /** - * True if `maybeOrderedSet` is an OrderedSet. - */ - export function isOrderedSet( - maybeOrderedSet: unknown - ): maybeOrderedSet is OrderedSet; - - /** - * True if `maybeRecord` is a Record. - */ - export function isRecord(maybeRecord: unknown): maybeRecord is Record<{}>; - - /** - * Returns the value within the provided collection associated with the - * provided key, or notSetValue if the key is not defined in the collection. - * - * A functional alternative to `collection.get(key)` which will also work on - * plain Objects and Arrays as an alternative for `collection[key]`. - * - * - * ```js - * const { get } = require('immutable') - * get([ 'dog', 'frog', 'cat' ], 2) // 'frog' - * get({ x: 123, y: 456 }, 'x') // 123 - * get({ x: 123, y: 456 }, 'z', 'ifNotSet') // 'ifNotSet' - * ``` - */ - export function get( - collection: Collection, - key: K - ): V | undefined; - export function get( - collection: Collection, - key: K, - notSetValue: NSV - ): V | NSV; - export function get( - record: Record, - key: K, - notSetValue: unknown - ): TProps[K]; - export function get(collection: Array, key: number): V | undefined; - export function get( - collection: Array, - key: number, - notSetValue: NSV - ): V | NSV; - export function get( - object: C, - key: K, - notSetValue: unknown - ): C[K]; - export function get( - collection: { [key: string]: V }, - key: string - ): V | undefined; - export function get( - collection: { [key: string]: V }, - key: string, - notSetValue: NSV - ): V | NSV; - - /** - * Returns true if the key is defined in the provided collection. - * - * A functional alternative to `collection.has(key)` which will also work with - * plain Objects and Arrays as an alternative for - * `collection.hasOwnProperty(key)`. - * - * - * ```js - * const { has } = require('immutable') - * has([ 'dog', 'frog', 'cat' ], 2) // true - * has([ 'dog', 'frog', 'cat' ], 5) // false - * has({ x: 123, y: 456 }, 'x') // true - * has({ x: 123, y: 456 }, 'z') // false - * ``` - */ - export function has(collection: object, key: unknown): boolean; - - /** - * Returns a copy of the collection with the value at key removed. - * - * A functional alternative to `collection.remove(key)` which will also work - * with plain Objects and Arrays as an alternative for - * `delete collectionCopy[key]`. - * - * - * ```js - * const { remove } = require('immutable') - * const originalArray = [ 'dog', 'frog', 'cat' ] - * remove(originalArray, 1) // [ 'dog', 'cat' ] - * console.log(originalArray) // [ 'dog', 'frog', 'cat' ] - * const originalObject = { x: 123, y: 456 } - * remove(originalObject, 'x') // { y: 456 } - * console.log(originalObject) // { x: 123, y: 456 } - * ``` - */ - export function remove>( - collection: C, - key: K - ): C; - export function remove< - TProps extends object, - C extends Record, - K extends keyof TProps - >(collection: C, key: K): C; - export function remove>( - collection: C, - key: number - ): C; - export function remove(collection: C, key: K): C; - export function remove< - C extends { [key: string]: unknown }, - K extends keyof C - >(collection: C, key: K): C; - - /** - * Returns a copy of the collection with the value at key set to the provided - * value. - * - * A functional alternative to `collection.set(key, value)` which will also - * work with plain Objects and Arrays as an alternative for - * `collectionCopy[key] = value`. - * - * - * ```js - * const { set } = require('immutable') - * const originalArray = [ 'dog', 'frog', 'cat' ] - * set(originalArray, 1, 'cow') // [ 'dog', 'cow', 'cat' ] - * console.log(originalArray) // [ 'dog', 'frog', 'cat' ] - * const originalObject = { x: 123, y: 456 } - * set(originalObject, 'x', 789) // { x: 789, y: 456 } - * console.log(originalObject) // { x: 123, y: 456 } - * ``` - */ - export function set>( - collection: C, - key: K, - value: V - ): C; - export function set< - TProps extends object, - C extends Record, - K extends keyof TProps - >(record: C, key: K, value: TProps[K]): C; - export function set>( - collection: C, - key: number, - value: V - ): C; - export function set(object: C, key: K, value: C[K]): C; - export function set( - collection: C, - key: string, - value: V - ): C; - - /** - * Returns a copy of the collection with the value at key set to the result of - * providing the existing value to the updating function. - * - * A functional alternative to `collection.update(key, fn)` which will also - * work with plain Objects and Arrays as an alternative for - * `collectionCopy[key] = fn(collection[key])`. - * - * - * ```js - * const { update } = require('immutable') - * const originalArray = [ 'dog', 'frog', 'cat' ] - * update(originalArray, 1, val => val.toUpperCase()) // [ 'dog', 'FROG', 'cat' ] - * console.log(originalArray) // [ 'dog', 'frog', 'cat' ] - * const originalObject = { x: 123, y: 456 } - * update(originalObject, 'x', val => val * 6) // { x: 738, y: 456 } - * console.log(originalObject) // { x: 123, y: 456 } - * ``` - */ - export function update>( - collection: C, - key: K, - updater: (value: V | undefined) => V - ): C; - export function update, NSV>( - collection: C, - key: K, - notSetValue: NSV, - updater: (value: V | NSV) => V - ): C; - export function update< - TProps extends object, - C extends Record, - K extends keyof TProps - >(record: C, key: K, updater: (value: TProps[K]) => TProps[K]): C; - export function update< - TProps extends object, - C extends Record, - K extends keyof TProps, - NSV - >( - record: C, - key: K, - notSetValue: NSV, - updater: (value: TProps[K] | NSV) => TProps[K] - ): C; - export function update( - collection: Array, - key: number, - updater: (value: V) => V - ): Array; - export function update( - collection: Array, - key: number, - notSetValue: NSV, - updater: (value: V | NSV) => V - ): Array; - export function update( - object: C, - key: K, - updater: (value: C[K]) => C[K] - ): C; - export function update( - object: C, - key: K, - notSetValue: NSV, - updater: (value: C[K] | NSV) => C[K] - ): C; - export function update( - collection: C, - key: K, - updater: (value: V) => V - ): { [key: string]: V }; - export function update< - V, - C extends { [key: string]: V }, - K extends keyof C, - NSV - >( - collection: C, - key: K, - notSetValue: NSV, - updater: (value: V | NSV) => V - ): { [key: string]: V }; - - /** - * Returns the value at the provided key path starting at the provided - * collection, or notSetValue if the key path is not defined. - * - * A functional alternative to `collection.getIn(keypath)` which will also - * work with plain Objects and Arrays. - * - * - * ```js - * const { getIn } = require('immutable') - * getIn({ x: { y: { z: 123 }}}, ['x', 'y', 'z']) // 123 - * getIn({ x: { y: { z: 123 }}}, ['x', 'q', 'p'], 'ifNotSet') // 'ifNotSet' - * ``` - */ - export function getIn( - collection: unknown, - keyPath: Iterable, - notSetValue?: unknown - ): unknown; - - /** - * Returns true if the key path is defined in the provided collection. - * - * A functional alternative to `collection.hasIn(keypath)` which will also - * work with plain Objects and Arrays. - * - * - * ```js - * const { hasIn } = require('immutable') - * hasIn({ x: { y: { z: 123 }}}, ['x', 'y', 'z']) // true - * hasIn({ x: { y: { z: 123 }}}, ['x', 'q', 'p']) // false - * ``` - */ - export function hasIn( - collection: unknown, - keyPath: Iterable - ): boolean; - - /** - * Returns a copy of the collection with the value at the key path removed. - * - * A functional alternative to `collection.removeIn(keypath)` which will also - * work with plain Objects and Arrays. - * - * - * ```js - * const { removeIn } = require('immutable') - * const original = { x: { y: { z: 123 }}} - * removeIn(original, ['x', 'y', 'z']) // { x: { y: {}}} - * console.log(original) // { x: { y: { z: 123 }}} - * ``` - */ - export function removeIn(collection: C, keyPath: Iterable): C; - - /** - * Returns a copy of the collection with the value at the key path set to the - * provided value. - * - * A functional alternative to `collection.setIn(keypath)` which will also - * work with plain Objects and Arrays. - * - * - * ```js - * const { setIn } = require('immutable') - * const original = { x: { y: { z: 123 }}} - * setIn(original, ['x', 'y', 'z'], 456) // { x: { y: { z: 456 }}} - * console.log(original) // { x: { y: { z: 123 }}} - * ``` - */ - export function setIn( - collection: C, - keyPath: Iterable, - value: unknown - ): C; - - /** - * Returns a copy of the collection with the value at key path set to the - * result of providing the existing value to the updating function. - * - * A functional alternative to `collection.updateIn(keypath)` which will also - * work with plain Objects and Arrays. - * - * - * ```js - * const { updateIn } = require('immutable') - * const original = { x: { y: { z: 123 }}} - * updateIn(original, ['x', 'y', 'z'], val => val * 6) // { x: { y: { z: 738 }}} - * console.log(original) // { x: { y: { z: 123 }}} - * ``` - */ - export function updateIn( - collection: C, - keyPath: Iterable, - updater: (value: unknown) => unknown - ): C; - export function updateIn( - collection: C, - keyPath: Iterable, - notSetValue: unknown, - updater: (value: unknown) => unknown - ): C; - - /** - * Returns a copy of the collection with the remaining collections merged in. - * - * A functional alternative to `collection.merge()` which will also work with - * plain Objects and Arrays. - * - * - * ```js - * const { merge } = require('immutable') - * const original = { x: 123, y: 456 } - * merge(original, { y: 789, z: 'abc' }) // { x: 123, y: 789, z: 'abc' } - * console.log(original) // { x: 123, y: 456 } - * ``` - */ - export function merge( - collection: C, - ...collections: Array< - | Iterable - | Iterable<[unknown, unknown]> - | { [key: string]: unknown } - > - ): C; - - /** - * Returns a copy of the collection with the remaining collections merged in, - * calling the `merger` function whenever an existing value is encountered. - * - * A functional alternative to `collection.mergeWith()` which will also work - * with plain Objects and Arrays. - * - * - * ```js - * const { mergeWith } = require('immutable') - * const original = { x: 123, y: 456 } - * mergeWith( - * (oldVal, newVal) => oldVal + newVal, - * original, - * { y: 789, z: 'abc' } - * ) // { x: 123, y: 1245, z: 'abc' } - * console.log(original) // { x: 123, y: 456 } - * ``` - */ - export function mergeWith( - merger: (oldVal: unknown, newVal: unknown, key: unknown) => unknown, - collection: C, - ...collections: Array< - | Iterable - | Iterable<[unknown, unknown]> - | { [key: string]: unknown } - > - ): C; - - /** - * Returns a copy of the collection with the remaining collections merged in - * deeply (recursively). - * - * A functional alternative to `collection.mergeDeep()` which will also work - * with plain Objects and Arrays. - * - * - * ```js - * const { mergeDeep } = require('immutable') - * const original = { x: { y: 123 }} - * mergeDeep(original, { x: { z: 456 }}) // { x: { y: 123, z: 456 }} - * console.log(original) // { x: { y: 123 }} - * ``` - */ - export function mergeDeep( - collection: C, - ...collections: Array< - | Iterable - | Iterable<[unknown, unknown]> - | { [key: string]: unknown } - > - ): C; - - /** - * Returns a copy of the collection with the remaining collections merged in - * deeply (recursively), calling the `merger` function whenever an existing - * value is encountered. - * - * A functional alternative to `collection.mergeDeepWith()` which will also - * work with plain Objects and Arrays. - * - * - * ```js - * const { mergeDeepWith } = require('immutable') - * const original = { x: { y: 123 }} - * mergeDeepWith( - * (oldVal, newVal) => oldVal + newVal, - * original, - * { x: { y: 456 }} - * ) // { x: { y: 579 }} - * console.log(original) // { x: { y: 123 }} - * ``` - */ - export function mergeDeepWith( - merger: (oldVal: unknown, newVal: unknown, key: unknown) => unknown, - collection: C, - ...collections: Array< - | Iterable - | Iterable<[unknown, unknown]> - | { [key: string]: unknown } - > - ): C; - diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index dffc2d414c..af45330084 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -105,7 +105,7 @@ declare namespace Immutable { * "unset" index and an index set to `undefined`. `List#forEach` visits all * indices from 0 to size, regardless of whether they were explicitly defined. */ - export namespace List { + namespace List { /** * True if the provided value is a List * @@ -171,9 +171,9 @@ declare namespace Immutable { * listFromPlainSet.equals(listFromPlainArray) // true * ``` */ - export function List(collection?: Iterable | ArrayLike): List; + function List(collection?: Iterable | ArrayLike): List; - export interface List extends Collection.Indexed { + interface List extends Collection.Indexed { /** * The number of items in this List. */ @@ -691,7 +691,7 @@ declare namespace Immutable { * * Implemented by a hash-array mapped trie. */ - export namespace Map { + namespace Map { /** * True if the provided value is a Map * @@ -759,11 +759,11 @@ declare namespace Immutable { * but since Immutable Map keys can be of any type the argument to `get()` is * not altered. */ - export function Map(collection?: Iterable<[K, V]>): Map; - export function Map(obj: { [key: string]: V }): Map; - export function Map(obj: { [P in K]?: V }): Map; + function Map(collection?: Iterable<[K, V]>): Map; + function Map(obj: { [key: string]: V }): Map; + function Map(obj: { [P in K]?: V }): Map; - export interface Map extends Collection.Keyed { + interface Map extends Collection.Keyed { /** * The number of entries in this Map. */ @@ -1414,8 +1414,7 @@ declare namespace Immutable { * consume more memory. `OrderedMap#set` is amortized O(log32 N), but not * stable. */ - - export namespace OrderedMap { + namespace OrderedMap { /** * True if the provided value is an OrderedMap. */ @@ -1439,14 +1438,10 @@ declare namespace Immutable { * Note: `OrderedMap` is a factory function and not a class, and does not use * the `new` keyword during construction. */ - export function OrderedMap( - collection?: Iterable<[K, V]> - ): OrderedMap; - export function OrderedMap(obj: { - [key: string]: V; - }): OrderedMap; + function OrderedMap(collection?: Iterable<[K, V]>): OrderedMap; + function OrderedMap(obj: { [key: string]: V }): OrderedMap; - export interface OrderedMap extends Map { + interface OrderedMap extends Map { /** * The number of entries in this OrderedMap. */ @@ -1587,7 +1582,7 @@ declare namespace Immutable { * `Immutable.is`, enabling Sets to uniquely include other Immutable * collections, custom value types, and NaN. */ - export namespace Set { + namespace Set { /** * True if the provided value is a Set */ @@ -1643,9 +1638,9 @@ declare namespace Immutable { * Note: `Set` is a factory function and not a class, and does not use the * `new` keyword during construction. */ - export function Set(collection?: Iterable | ArrayLike): Set; + function Set(collection?: Iterable | ArrayLike): Set; - export interface Set extends Collection.Set { + interface Set extends Collection.Set { /** * The number of items in this Set. */ @@ -1795,7 +1790,7 @@ declare namespace Immutable { * consume more memory. `OrderedSet#add` is amortized O(log32 N), but not * stable. */ - export namespace OrderedSet { + namespace OrderedSet { /** * True if the provided value is an OrderedSet. */ @@ -1821,11 +1816,11 @@ declare namespace Immutable { * Note: `OrderedSet` is a factory function and not a class, and does not use * the `new` keyword during construction. */ - export function OrderedSet( + function OrderedSet( collection?: Iterable | ArrayLike ): OrderedSet; - export interface OrderedSet extends Set { + interface OrderedSet extends Set { /** * The number of items in this OrderedSet. */ @@ -1965,7 +1960,7 @@ declare namespace Immutable { * * Stack is implemented with a Single-Linked List. */ - export namespace Stack { + namespace Stack { /** * True if the provided value is a Stack */ @@ -1987,9 +1982,9 @@ declare namespace Immutable { * Note: `Stack` is a factory function and not a class, and does not use the * `new` keyword during construction. */ - export function Stack(collection?: Iterable | ArrayLike): Stack; + function Stack(collection?: Iterable | ArrayLike): Stack; - export interface Stack extends Collection.Indexed { + interface Stack extends Collection.Indexed { /** * The number of items in this Stack. */ @@ -2218,7 +2213,7 @@ declare namespace Immutable { * Range(30, 30, 5) // [] * ``` */ - export function Range( + function Range( start?: number, end?: number, step?: number @@ -2237,7 +2232,7 @@ declare namespace Immutable { * Repeat('bar', 4) // [ 'bar', 'bar', 'bar', 'bar' ] * ``` */ - export function Repeat(value: T, times?: number): Seq.Indexed; + function Repeat(value: T, times?: number): Seq.Indexed; /** * A record is similar to a JS object, but enforces a specific set of allowed @@ -2398,11 +2393,11 @@ declare namespace Immutable { * form isn't free. If converting Records to plain objects is common, * consider sticking with plain objects to begin with. */ - export namespace Record { + namespace Record { /** * True if `maybeRecord` is an instance of a Record. */ - export function isRecord(maybeRecord: unknown): maybeRecord is Record<{}>; + function isRecord(maybeRecord: unknown): maybeRecord is Record<{}>; /** * Records allow passing a second parameter to supply a descriptive name @@ -2421,7 +2416,7 @@ declare namespace Immutable { * Record.getDescriptiveName(me) // "Person" * ``` */ - export function getDescriptiveName(record: Record): string; + function getDescriptiveName(record: Record): string; /** * A Record.Factory is created by the `Record()` function. Record instances @@ -2471,9 +2466,9 @@ declare namespace Immutable { * const alan: Person = makePerson({ name: 'Alan' }); * ``` */ - export namespace Factory {} + namespace Factory {} - export interface Factory { + interface Factory { (values?: Partial | Iterable<[string, unknown]>): Record & Readonly; new ( @@ -2487,7 +2482,7 @@ declare namespace Immutable { displayName: string; } - export function Factory( + function Factory( values?: Partial | Iterable<[string, unknown]> ): Record & Readonly; } @@ -2501,12 +2496,12 @@ declare namespace Immutable { * Note: `Record` is a factory function and not a class, and does not use the * `new` keyword during construction. */ - export function Record( + function Record( defaultValues: TProps, name?: string ): Record.Factory; - export interface Record { + interface Record { // Reading values has(key: string): key is keyof TProps & string; @@ -2647,8 +2642,7 @@ declare namespace Immutable { * * This is equivalent to an instance of a record created by a Record Factory. */ - export type RecordOf = Record & - Readonly; + type RecordOf = Record & Readonly; /** * `Seq` describes a lazy operation, allowing them to efficiently chain @@ -2725,7 +2719,7 @@ declare namespace Immutable { * ``` */ - export namespace Seq { + namespace Seq { /** * True if `maybeSeq` is a Seq, it is not backed by a concrete * structure such as Map, List, or Set. @@ -2740,7 +2734,7 @@ declare namespace Immutable { /** * `Seq` which represents key-value pairs. */ - export namespace Keyed {} + namespace Keyed {} /** * Always returns a Seq.Keyed, if input is not keyed, expects an @@ -2749,10 +2743,10 @@ declare namespace Immutable { * Note: `Seq.Keyed` is a conversion function and not a class, and does not * use the `new` keyword during construction. */ - export function Keyed(collection?: Iterable<[K, V]>): Seq.Keyed; - export function Keyed(obj: { [key: string]: V }): Seq.Keyed; + function Keyed(collection?: Iterable<[K, V]>): Seq.Keyed; + function Keyed(obj: { [key: string]: V }): Seq.Keyed; - export interface Keyed extends Seq, Collection.Keyed { + interface Keyed extends Seq, Collection.Keyed { /** * Deeply converts this Keyed Seq to equivalent native JavaScript Object. * @@ -2879,11 +2873,9 @@ declare namespace Immutable { * Note: `Seq.Indexed` is a conversion function and not a class, and does * not use the `new` keyword during construction. */ - export function Indexed( - collection: Iterable | ArrayLike - ): Seq.Indexed; + function Indexed(collection: Iterable | ArrayLike): Seq.Indexed; - export interface Indexed extends Seq, Collection.Indexed { + interface Indexed extends Seq, Collection.Indexed { /** * Deeply converts this Indexed Seq to equivalent native JavaScript Array. */ @@ -3030,7 +3022,7 @@ declare namespace Immutable { * Because `Seq` are often lazy, `Seq.Set` does not provide the same guarantee * of value uniqueness as the concrete `Set`. */ - export namespace Set { + namespace Set { /** * Returns a Seq.Set of the provided values */ @@ -3043,9 +3035,9 @@ declare namespace Immutable { * Note: `Seq.Set` is a conversion function and not a class, and does not * use the `new` keyword during construction. */ - export function Set(collection: Iterable | ArrayLike): Seq.Set; + function Set(collection: Iterable | ArrayLike): Seq.Set; - export interface Set extends Seq, Collection.Set { + interface Set extends Seq, Collection.Set { /** * Deeply converts this Set Seq to equivalent native JavaScript Array. */ @@ -3140,18 +3132,16 @@ declare namespace Immutable { * Note: `Seq` is a conversion function and not a class, and does not use the * `new` keyword during construction. */ - export function Seq>(seq: S): S; - export function Seq( - collection: Collection.Keyed - ): Seq.Keyed; - export function Seq(collection: Collection.Set): Seq.Set; - export function Seq( + function Seq>(seq: S): S; + function Seq(collection: Collection.Keyed): Seq.Keyed; + function Seq(collection: Collection.Set): Seq.Set; + function Seq( collection: Collection.Indexed | Iterable | ArrayLike ): Seq.Indexed; - export function Seq(obj: { [key: string]: V }): Seq.Keyed; - export function Seq(): Seq; + function Seq(obj: { [key: string]: V }): Seq.Keyed; + function Seq(): Seq; - export interface Seq extends Collection { + interface Seq extends Collection { /** * Some Seqs can describe their size lazily. When this is the case, * size will be an integer. Otherwise it will be undefined. @@ -3279,7 +3269,7 @@ declare namespace Immutable { * Implementations should extend one of the subclasses, `Collection.Keyed`, * `Collection.Indexed`, or `Collection.Set`. */ - export namespace Collection { + namespace Collection { /** * @deprecated use `const { isKeyed } = require('immutable')` */ @@ -3315,7 +3305,7 @@ declare namespace Immutable { * tuple, in other words, `Collection#entries` is the default iterator for * Keyed Collections. */ - export namespace Keyed {} + namespace Keyed {} /** * Creates a Collection.Keyed @@ -3326,14 +3316,10 @@ declare namespace Immutable { * Note: `Collection.Keyed` is a conversion function and not a class, and * does not use the `new` keyword during construction. */ - export function Keyed( - collection: Iterable<[K, V]> - ): Collection.Keyed; - export function Keyed(obj: { - [key: string]: V; - }): Collection.Keyed; + function Keyed(collection: Iterable<[K, V]>): Collection.Keyed; + function Keyed(obj: { [key: string]: V }): Collection.Keyed; - export interface Keyed extends Collection { + interface Keyed extends Collection { /** * Deeply converts this Keyed collection to equivalent native JavaScript Object. * @@ -3491,7 +3477,7 @@ declare namespace Immutable { * preserve indices, using them as keys, convert to a Collection.Keyed by * calling `toKeyedSeq`. */ - export namespace Indexed {} + namespace Indexed {} /** * Creates a new Collection.Indexed. @@ -3499,11 +3485,11 @@ declare namespace Immutable { * Note: `Collection.Indexed` is a conversion function and not a class, and * does not use the `new` keyword during construction. */ - export function Indexed( + function Indexed( collection: Iterable | ArrayLike ): Collection.Indexed; - export interface Indexed extends Collection { + interface Indexed extends Collection { /** * Deeply converts this Indexed collection to equivalent native JavaScript Array. */ @@ -3790,7 +3776,7 @@ declare namespace Immutable { * ) * ``` */ - export namespace Set {} + namespace Set {} /** * Similar to `Collection()`, but always returns a Collection.Set. @@ -3798,11 +3784,9 @@ declare namespace Immutable { * Note: `Collection.Set` is a factory function and not a class, and does * not use the `new` keyword during construction. */ - export function Set( - collection: Iterable | ArrayLike - ): Collection.Set; + function Set(collection: Iterable | ArrayLike): Collection.Set; - export interface Set extends Collection { + interface Set extends Collection { /** * Deeply converts this Set collection to equivalent native JavaScript Array. */ @@ -3900,17 +3884,15 @@ declare namespace Immutable { * Note: `Collection` is a conversion function and not a class, and does not * use the `new` keyword during construction. */ - export function Collection>( - collection: I - ): I; - export function Collection( + function Collection>(collection: I): I; + function Collection( collection: Iterable | ArrayLike ): Collection.Indexed; - export function Collection(obj: { + function Collection(obj: { [key: string]: V; }): Collection.Keyed; - export interface Collection extends ValueObject { + interface Collection extends ValueObject { // Value equality /** @@ -4842,7 +4824,7 @@ declare namespace Immutable { /** * The interface to fulfill to qualify as a Value Object. */ - export interface ValueObject { + interface ValueObject { /** * True if this and the other Collection have value equality, as defined * by `Immutable.is()`. @@ -4952,7 +4934,7 @@ declare namespace Immutable { * [1]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse#Example.3A_Using_the_reviver_parameter * "Using the reviver parameter" */ - export function fromJS( + function fromJS( jsValue: unknown, reviver?: ( key: string | number, @@ -4986,7 +4968,7 @@ declare namespace Immutable { * Note: Unlike `Object.is`, `Immutable.is` assumes `0` and `-0` are the same * value, matching the behavior of ES6 Map key equality. */ - export function is(first: unknown, second: unknown): boolean; + function is(first: unknown, second: unknown): boolean; /** * The `hash()` function is an important part of how Immutable determines if @@ -5010,7 +4992,7 @@ declare namespace Immutable { * * *New in Version 4.0* */ - export function hash(value: unknown): number; + function hash(value: unknown): number; /** * True if `maybeImmutable` is an Immutable Collection or Record. @@ -5028,7 +5010,7 @@ declare namespace Immutable { * isImmutable(Map().asMutable()); // true * ``` */ - export function isImmutable( + function isImmutable( maybeImmutable: unknown ): maybeImmutable is Collection; @@ -5045,7 +5027,7 @@ declare namespace Immutable { * isCollection(Stack()); // true * ``` */ - export function isCollection( + function isCollection( maybeCollection: unknown ): maybeCollection is Collection; @@ -5062,7 +5044,7 @@ declare namespace Immutable { * isKeyed(Stack()); // false * ``` */ - export function isKeyed( + function isKeyed( maybeKeyed: unknown ): maybeKeyed is Collection.Keyed; @@ -5080,7 +5062,7 @@ declare namespace Immutable { * isIndexed(Set()); // false * ``` */ - export function isIndexed( + function isIndexed( maybeIndexed: unknown ): maybeIndexed is Collection.Indexed; @@ -5098,7 +5080,7 @@ declare namespace Immutable { * isAssociative(Set()); // false * ``` */ - export function isAssociative( + function isAssociative( maybeAssociative: unknown ): maybeAssociative is | Collection.Keyed @@ -5119,7 +5101,7 @@ declare namespace Immutable { * isOrdered(Set()); // false * ``` */ - export function isOrdered(maybeOrdered: unknown): boolean; + function isOrdered(maybeOrdered: unknown): boolean; /** * True if `maybeValue` is a JavaScript Object which has *both* `equals()` @@ -5128,12 +5110,12 @@ declare namespace Immutable { * Any two instances of *value objects* can be compared for value equality with * `Immutable.is()` and can be used as keys in a `Map` or members in a `Set`. */ - export function isValueObject(maybeValue: unknown): maybeValue is ValueObject; + function isValueObject(maybeValue: unknown): maybeValue is ValueObject; /** * True if `maybeSeq` is a Seq. */ - export function isSeq( + function isSeq( maybeSeq: unknown ): maybeSeq is | Seq.Indexed @@ -5143,45 +5125,45 @@ declare namespace Immutable { /** * True if `maybeList` is a List. */ - export function isList(maybeList: unknown): maybeList is List; + function isList(maybeList: unknown): maybeList is List; /** * True if `maybeMap` is a Map. * * Also true for OrderedMaps. */ - export function isMap(maybeMap: unknown): maybeMap is Map; + function isMap(maybeMap: unknown): maybeMap is Map; /** * True if `maybeOrderedMap` is an OrderedMap. */ - export function isOrderedMap( + function isOrderedMap( maybeOrderedMap: unknown ): maybeOrderedMap is OrderedMap; /** * True if `maybeStack` is a Stack. */ - export function isStack(maybeStack: unknown): maybeStack is Stack; + function isStack(maybeStack: unknown): maybeStack is Stack; /** * True if `maybeSet` is a Set. * * Also true for OrderedSets. */ - export function isSet(maybeSet: unknown): maybeSet is Set; + function isSet(maybeSet: unknown): maybeSet is Set; /** * True if `maybeOrderedSet` is an OrderedSet. */ - export function isOrderedSet( + function isOrderedSet( maybeOrderedSet: unknown ): maybeOrderedSet is OrderedSet; /** * True if `maybeRecord` is a Record. */ - export function isRecord(maybeRecord: unknown): maybeRecord is Record<{}>; + function isRecord(maybeRecord: unknown): maybeRecord is Record<{}>; /** * Returns the value within the provided collection associated with the @@ -5198,36 +5180,30 @@ declare namespace Immutable { * get({ x: 123, y: 456 }, 'z', 'ifNotSet') // 'ifNotSet' * ``` */ - export function get( - collection: Collection, - key: K - ): V | undefined; - export function get( + function get(collection: Collection, key: K): V | undefined; + function get( collection: Collection, key: K, notSetValue: NSV ): V | NSV; - export function get( + function get( record: Record, key: K, notSetValue: unknown ): TProps[K]; - export function get(collection: Array, key: number): V | undefined; - export function get( + function get(collection: Array, key: number): V | undefined; + function get( collection: Array, key: number, notSetValue: NSV ): V | NSV; - export function get( + function get( object: C, key: K, notSetValue: unknown ): C[K]; - export function get( - collection: { [key: string]: V }, - key: string - ): V | undefined; - export function get( + function get(collection: { [key: string]: V }, key: string): V | undefined; + function get( collection: { [key: string]: V }, key: string, notSetValue: NSV @@ -5249,7 +5225,7 @@ declare namespace Immutable { * has({ x: 123, y: 456 }, 'z') // false * ``` */ - export function has(collection: object, key: unknown): boolean; + function has(collection: object, key: unknown): boolean; /** * Returns a copy of the collection with the value at key removed. @@ -5269,24 +5245,21 @@ declare namespace Immutable { * console.log(originalObject) // { x: 123, y: 456 } * ``` */ - export function remove>( + function remove>( collection: C, key: K ): C; - export function remove< + function remove< TProps extends object, C extends Record, K extends keyof TProps >(collection: C, key: K): C; - export function remove>( + function remove>(collection: C, key: number): C; + function remove(collection: C, key: K): C; + function remove( collection: C, - key: number + key: K ): C; - export function remove(collection: C, key: K): C; - export function remove< - C extends { [key: string]: unknown }, - K extends keyof C - >(collection: C, key: K): C; /** * Returns a copy of the collection with the value at key set to the provided @@ -5307,23 +5280,19 @@ declare namespace Immutable { * console.log(originalObject) // { x: 123, y: 456 } * ``` */ - export function set>( + function set>( collection: C, key: K, value: V ): C; - export function set< + function set< TProps extends object, C extends Record, K extends keyof TProps >(record: C, key: K, value: TProps[K]): C; - export function set>( - collection: C, - key: number, - value: V - ): C; - export function set(object: C, key: K, value: C[K]): C; - export function set( + function set>(collection: C, key: number, value: V): C; + function set(object: C, key: K, value: C[K]): C; + function set( collection: C, key: string, value: V @@ -5348,23 +5317,23 @@ declare namespace Immutable { * console.log(originalObject) // { x: 123, y: 456 } * ``` */ - export function update>( + function update>( collection: C, key: K, updater: (value: V | undefined) => V ): C; - export function update, NSV>( + function update, NSV>( collection: C, key: K, notSetValue: NSV, updater: (value: V | NSV) => V ): C; - export function update< + function update< TProps extends object, C extends Record, K extends keyof TProps >(record: C, key: K, updater: (value: TProps[K]) => TProps[K]): C; - export function update< + function update< TProps extends object, C extends Record, K extends keyof TProps, @@ -5375,39 +5344,34 @@ declare namespace Immutable { notSetValue: NSV, updater: (value: TProps[K] | NSV) => TProps[K] ): C; - export function update( + function update( collection: Array, key: number, updater: (value: V) => V ): Array; - export function update( + function update( collection: Array, key: number, notSetValue: NSV, updater: (value: V | NSV) => V ): Array; - export function update( + function update( object: C, key: K, updater: (value: C[K]) => C[K] ): C; - export function update( + function update( object: C, key: K, notSetValue: NSV, updater: (value: C[K] | NSV) => C[K] ): C; - export function update( + function update( collection: C, key: K, updater: (value: V) => V ): { [key: string]: V }; - export function update< - V, - C extends { [key: string]: V }, - K extends keyof C, - NSV - >( + function update( collection: C, key: K, notSetValue: NSV, @@ -5428,7 +5392,7 @@ declare namespace Immutable { * getIn({ x: { y: { z: 123 }}}, ['x', 'q', 'p'], 'ifNotSet') // 'ifNotSet' * ``` */ - export function getIn( + function getIn( collection: unknown, keyPath: Iterable, notSetValue?: unknown @@ -5447,10 +5411,7 @@ declare namespace Immutable { * hasIn({ x: { y: { z: 123 }}}, ['x', 'q', 'p']) // false * ``` */ - export function hasIn( - collection: unknown, - keyPath: Iterable - ): boolean; + function hasIn(collection: unknown, keyPath: Iterable): boolean; /** * Returns a copy of the collection with the value at the key path removed. @@ -5466,7 +5427,7 @@ declare namespace Immutable { * console.log(original) // { x: { y: { z: 123 }}} * ``` */ - export function removeIn(collection: C, keyPath: Iterable): C; + function removeIn(collection: C, keyPath: Iterable): C; /** * Returns a copy of the collection with the value at the key path set to the @@ -5483,7 +5444,7 @@ declare namespace Immutable { * console.log(original) // { x: { y: { z: 123 }}} * ``` */ - export function setIn( + function setIn( collection: C, keyPath: Iterable, value: unknown @@ -5504,12 +5465,12 @@ declare namespace Immutable { * console.log(original) // { x: { y: { z: 123 }}} * ``` */ - export function updateIn( + function updateIn( collection: C, keyPath: Iterable, updater: (value: unknown) => unknown ): C; - export function updateIn( + function updateIn( collection: C, keyPath: Iterable, notSetValue: unknown, @@ -5530,7 +5491,7 @@ declare namespace Immutable { * console.log(original) // { x: 123, y: 456 } * ``` */ - export function merge( + function merge( collection: C, ...collections: Array< | Iterable @@ -5558,7 +5519,7 @@ declare namespace Immutable { * console.log(original) // { x: 123, y: 456 } * ``` */ - export function mergeWith( + function mergeWith( merger: (oldVal: unknown, newVal: unknown, key: unknown) => unknown, collection: C, ...collections: Array< @@ -5583,7 +5544,7 @@ declare namespace Immutable { * console.log(original) // { x: { y: 123 }} * ``` */ - export function mergeDeep( + function mergeDeep( collection: C, ...collections: Array< | Iterable @@ -5612,7 +5573,7 @@ declare namespace Immutable { * console.log(original) // { x: { y: 123 }} * ``` */ - export function mergeDeepWith( + function mergeDeepWith( merger: (oldVal: unknown, newVal: unknown, key: unknown) => unknown, collection: C, ...collections: Array< @@ -5623,6 +5584,26 @@ declare namespace Immutable { ): C; } -declare module 'immutable' { - export = Immutable; -} +/** + * Defines the main export of the immutable module to be the Immutable namespace + * This supports many common module import patterns: + * + * const Immutable = require("immutable"); + * const { List } = require("immutable"); + * import Immutable from "immutable"; + * import * as Immutable from "immutable"; + * import { List } from "immutable"; + * + */ +export = Immutable; + +/** + * A global "Immutable" namespace used by UMD modules which allows the use of + * the full Immutable API. + * + * If using Immutable as an imported module, prefer using: + * + * import Immutable from 'immutable' + * + */ +export as namespace Immutable; diff --git a/package.json b/package.json index e211c49c3e..ae9ce141d6 100644 --- a/package.json +++ b/package.json @@ -18,10 +18,7 @@ "main": "dist/immutable.js", "module": "dist/immutable.es.js", "sideEffects": false, - "typings": "dist/immutable-nonambient.d.ts", - "typescript": { - "definition": "dist/immutable.d.ts" - }, + "types": "dist/immutable.d.ts", "files": [ "dist", "README.md", From 7f647fc85ff2ac7988dbe21b51e2558c3029758f Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 20 Jul 2021 20:48:56 +0000 Subject: [PATCH 162/242] deploy: 80aa4c6c6ee03dce1dd2b7b686491e33994d463a --- README.md | 98 ++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 79 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index fa89e1a7d9..3881fe4ce2 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,27 @@ [![Build Status](https://github.com/immutable-js/immutable-js/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/immutable-js/immutable-js/actions/workflows/ci.yml?query=branch%3Amain) [Chat on slack](https://immutable-js.slack.com) +[Read the docs](https://immutable-js.com) and eat your vegetables. + +Docs are automatically generated from [README.md][] and [immutable.d.ts][]. +Please contribute! Also, don't miss the [wiki][] which contains articles on +additional specific topics. Can't find something? Open an [issue][]. + +**Table of contents:** + +- [Introduction](#introduction) +- [Getting started](#getting-started) +- [The case for Immutability](#the-case-for-immutability) +- [JavaScript-first API](#javaScript-first-api) +- [Nested Structures](#nested-structures) +- [Equality treats Collections as Values](#equality-treats-collections-as-values) +- [Batching Mutations](#batching-mutations) +- [Lazy Seq](#lazy-seq) +- [Additional Tools and Resources](#additional-tools-and-resources) +- [Contributing](#contributing) + +## Introduction + [Immutable][] data cannot be changed once created, leading to much simpler application development, no defensive copying, and enabling advanced memoization and change detection techniques with simple logic. [Persistent][] data presents @@ -23,6 +44,10 @@ Want to hear more? Watch the presentation about Immutable.js: [![Immutable Data and React](website/public/Immutable-Data-and-React-YouTube.png)](https://youtu.be/I7IdS-PbEgI) +[README.md]: https://github.com/immutable-js/immutable-js/blob/main/README.md +[immutable.d.ts]: https://github.com/immutable-js/immutable-js/blob/main/type-definitions/immutable.d.ts +[wiki]: https://github.com/immutable-js/immutable-js/wiki +[issue]: https://github.com/immutable-js/immutable-js/issues [Persistent]: https://en.wikipedia.org/wiki/Persistent_data_structure [Immutable]: https://en.wikipedia.org/wiki/Immutable_object [hash maps tries]: https://en.wikipedia.org/wiki/Hash_array_mapped_trie @@ -612,25 +637,62 @@ Range(1, Infinity) // 1006008 ``` -## Documentation +## Additional Tools and Resources -## Documentation +- [Atom-store](https://github.com/jameshopkins/atom-store/) + - A Clojure-inspired atom implementation in Javascript with configurability + for external persistance. -[Read the docs](https://immutable-js.com) and eat your vegetables. +- [Chai Immutable](https://github.com/astorije/chai-immutable) + - If you are using the [Chai Assertion Library](https://chaijs.com/), this + provides a set of assertions to use against Immutable.js collections. + +- [Fantasy-land](https://github.com/fantasyland/fantasy-land) + - Specification for interoperability of common algebraic structures in JavaScript. + +- [Immutagen](https://github.com/pelotom/immutagen) + - A library for simulating immutable generators in JavaScript. + +- [Immutable-cursor](https://github.com/redbadger/immutable-cursor) + - Immutable cursors incorporating the Immutable.js interface over + Clojure-inspired atom. + +- [Immutable-ext](https://github.com/DrBoolean/immutable-ext) + - Fantasyland extensions for immutablejs + +- [Immutable-js-tools](https://github.com/madeinfree/immutable-js-tools) + - Util tools for immutable.js -Docs are automatically generated from [immutable.d.ts](https://github.com/immutable-js/immutable-js/blob/main/type-definitions/immutable.d.ts). -Please contribute! +- [Immutable-Redux](https://github.com/gajus/redux-immutable) + - redux-immutable is used to create an equivalent function of Redux + combineReducers that works with Immutable.js state. -Also, don't miss the [Wiki](https://github.com/immutable-js/immutable-js/wiki) which -contains articles on specific topics. Can't find something? Open an [issue](https://github.com/immutable-js/immutable-js/issues). +- [Immutable-Treeutils](https://github.com/lukasbuenger/immutable-treeutils) + - Functional tree traversal helpers for ImmutableJS data structures. -## Testing +- [Irecord](https://github.com/ericelliott/irecord) + - An immutable store that exposes an RxJS observable. Great for React. -If you are using the [Chai Assertion Library](https://chaijs.com/), [Chai Immutable](https://github.com/astorije/chai-immutable) provides a set of assertions to use against Immutable.js collections. +- [Mudash](https://github.com/brianneisler/mudash) + - Lodash wrapper providing Immutable.JS support. -## Contribution +- [React-Immutable-PropTypes](https://github.com/HurricaneJames/react-immutable-proptypes) + - PropType validators that work with Immutable.js. -## Contribution +- [Redux-Immutablejs](https://github.com/indexiatech/redux-immutablejs) + - Redux Immutable facilities. + +- [Rxstate](https://github.com/yamalight/rxstate) + - Simple opinionated state management library based on RxJS and Immutable.js. + +- [Transit-Immutable-js](https://github.com/glenjamin/transit-immutable-js) + - Transit serialisation for Immutable.js. + - See also: [Transit-js](https://github.com/cognitect/transit-js) + +Have an additional tool designed to work with Immutable.js? +Submit a PR to add it to this list in alphabetical order. + +## Contributing Use [Github issues](https://github.com/immutable-js/immutable-js/issues) for requests. @@ -638,20 +700,18 @@ We actively welcome pull requests, learn how to [contribute](https://github.com/ Immutable.js is maintained within the [Contributor Covenant's Code of Conduct](https://www.contributor-covenant.org/version/2/0/code_of_conduct/). -We actively welcome pull requests, learn how to [contribute](https://github.com/immutable-js/immutable-js/blob/main/.github/CONTRIBUTING.md). - -## Changelog +### Changelog Changes are tracked as [Github releases](https://github.com/immutable-js/immutable-js/releases). -## Thanks +### License + +Immutable.js is [MIT-licensed](./LICENSE). + +### Thanks [Phil Bagwell](https://www.youtube.com/watch?v=K2NYwP90bNs), for his inspiration and research in persistent data structures. [Hugh Jackson](https://github.com/hughfdjackson/), for providing the npm package name. If you're looking for his unsupported package, see [this repository](https://github.com/hughfdjackson/immutable). - -## License - -Immutable.js is [MIT-licensed](./LICENSE). From e5b998400549b6cd0ee033627ef20c4c1fc24e83 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 22 Jul 2021 22:47:59 +0000 Subject: [PATCH 163/242] deploy: 6b03706807d59c576c34da8f729993debcc4658f --- dist/immutable.js.flow | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/dist/immutable.js.flow b/dist/immutable.js.flow index fde4bba0f7..4b9d6c950b 100644 --- a/dist/immutable.js.flow +++ b/dist/immutable.js.flow @@ -25,11 +25,14 @@ // some constructors and functions. type PlainObjInput = { +[key: K]: V, __proto__: null }; +type K = $Keys; + // Helper types to extract the "keys" and "values" use by the *In() methods. type $KeyOf = $Call< ((?_Collection) => K) & ((?$ReadOnlyArray) => number) & - ((?RecordInstance | T) => $Keys), + ((?RecordInstance | T) => $Keys) & + ((T) => $Keys), C >; @@ -37,7 +40,7 @@ type $ValOf> = $Call< ((?_Collection) => V) & ((?$ReadOnlyArray) => T) & (>(?RecordInstance | T, K) => $ElementType) & - ((?{ [any]: V }) => V), + ((T) => $Values), C, K >; From 0209e5c4fb600ccfde516c2f996918d988d3976d Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 23 Jul 2021 06:03:19 +0000 Subject: [PATCH 164/242] deploy: f3eff2592e10249d7423845e06cc0c07b6aba3fd --- dist/immutable.es.js | 12 +++++++----- dist/immutable.js | 12 +++++++----- dist/immutable.min.js | 18 +++++++++--------- 3 files changed, 23 insertions(+), 19 deletions(-) diff --git a/dist/immutable.es.js b/dist/immutable.es.js index ab99cd42b5..afeada84d3 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -5300,14 +5300,16 @@ mixin(SetCollection, { }, }); -SetCollection.prototype.has = CollectionPrototype.includes; -SetCollection.prototype.contains = SetCollection.prototype.includes; +var SetCollectionPrototype = SetCollection.prototype; +SetCollectionPrototype.has = CollectionPrototype.includes; +SetCollectionPrototype.contains = SetCollectionPrototype.includes; +SetCollectionPrototype.keys = SetCollectionPrototype.values; // Mixin subclasses -mixin(KeyedSeq, KeyedCollection.prototype); -mixin(IndexedSeq, IndexedCollection.prototype); -mixin(SetSeq, SetCollection.prototype); +mixin(KeyedSeq, KeyedCollectionPrototype); +mixin(IndexedSeq, IndexedCollectionPrototype); +mixin(SetSeq, SetCollectionPrototype); // #pragma Helper functions diff --git a/dist/immutable.js b/dist/immutable.js index 51ede4d175..a5c2bf1012 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -5306,14 +5306,16 @@ }, }); - SetCollection.prototype.has = CollectionPrototype.includes; - SetCollection.prototype.contains = SetCollection.prototype.includes; + var SetCollectionPrototype = SetCollection.prototype; + SetCollectionPrototype.has = CollectionPrototype.includes; + SetCollectionPrototype.contains = SetCollectionPrototype.includes; + SetCollectionPrototype.keys = SetCollectionPrototype.values; // Mixin subclasses - mixin(KeyedSeq, KeyedCollection.prototype); - mixin(IndexedSeq, IndexedCollection.prototype); - mixin(SetSeq, SetCollection.prototype); + mixin(KeyedSeq, KeyedCollectionPrototype); + mixin(IndexedSeq, IndexedCollectionPrototype); + mixin(SetSeq, SetCollectionPrototype); // #pragma Helper functions diff --git a/dist/immutable.min.js b/dist/immutable.min.js index c03cacb84a..748d1d117d 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -42,14 +42,14 @@ r)}}function _r(t,e,r,n,i,o,u){var s=Object.create(sr);return s.size=e-t,s._orig e.prototype.toString=function(){return this.__toString("OrderedMap {","}")},e.prototype.get=function(t,e){t=this._map.get(t);return void 0!==t?this._list.get(t)[1]:e},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._map.clear(),this._list.clear(),this.__altered=!0,this):Sr()},e.prototype.set=function(t,e){return br(this,t,e)},e.prototype.remove=function(t){return br(this,t,v)},e.prototype.__iterate=function(e,t){var r=this;return this._list.__iterate(function(t){return t&&e(t[1],t[0],r)},t)},e.prototype.__iterator=function(t,e){return this._list.fromEntrySeq().__iterator(t,e)},e.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var e=this._map.__ensureOwner(t),r=this._list.__ensureOwner(t);return t?zr(e,r,t,this.__hash):0===this.size?Sr():(this.__ownerID=t,this.__altered=!1,this._map=e,this._list=r,this)},e}(Ke);function zr(t,e,r,n){var i=Object.create(wr.prototype);return i.size=t?t.size:0,i._map=t,i._list=e,i.__ownerID=r,i.__hash=n,i.__altered=!1,i}function Sr(){return mr=mr||zr(Qe(),pr())}function br(t,e,r){var n,i,o=t._map,u=t._list,s=o.get(e),a=void 0!==s;if(r===v){if(!a)return t;l<=u.size&&2*o.size<=u.size?(n=(i=u.filter(function(t,e){return void 0!==t&&s!==e})).toKeyedSeq().map(function(t){return t[0]}).flip().toMap(),t.__ownerID&&(n.__ownerID=i.__ownerID=t.__ownerID)):(n=o.remove(e),i=s===u.size-1?u.pop():u.set(s,void 0))}else if(a){if(r===u.get(s)[1])return t;n=o,i=u.set(s,[e,r])}else n=o.set(e,u.size),i=u.set(u.size,[e,r]);return t.__ownerID?(t.size=n.size,t._map=n,t._list=i,t.__hash=void 0,t.__altered=!0,t):zr(n,i)}wr.isOrderedMap=ft,wr.prototype[k]=!0,wr.prototype[e]=wr.prototype.remove;var Ir="@@__IMMUTABLE_STACK__@@";function Or(t){return!(!t||!t[Ir])}var Er=function(i){function t(t){return null==t?Dr():Or(t)?t:Dr().pushAll(t)}return i&&(t.__proto__=i),((t.prototype=Object.create(i&&i.prototype)).constructor=t).of=function(){return this(arguments)},t.prototype.toString=function(){return this.__toString("Stack [","]")}, t.prototype.get=function(t,e){var r=this._head;for(t=h(this,t);r&&t--;)r=r.next;return r?r.value:e},t.prototype.peek=function(){return this._head&&this._head.value},t.prototype.push=function(){var t=arguments;if(0===arguments.length)return this;for(var e=this.size+arguments.length,r=this._head,n=arguments.length-1;0<=n;n--)r={value:t[n],next:r};return this.__ownerID?(this.size=e,this._head=r,this.__hash=void 0,this.__altered=!0,this):qr(e,r)},t.prototype.pushAll=function(t){if(0===(t=i(t)).size)return this;if(0===this.size&&Or(t))return t;te(t.size);var e=this.size,r=this._head;return t.__iterate(function(t){e++,r={value:t,next:r}},!0),this.__ownerID?(this.size=e,this._head=r,this.__hash=void 0,this.__altered=!0,this):qr(e,r)},t.prototype.pop=function(){return this.slice(1)},t.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):Dr()},t.prototype.slice=function(t,e){if(p(t,e,this.size))return this;var r=y(t,this.size);if(w(e,this.size)!==this.size)return i.prototype.slice.call(this,t,e);for(var e=this.size-r,n=this._head;r--;)n=n.next;return this.__ownerID?(this.size=e,this._head=n,this.__hash=void 0,this.__altered=!0,this):qr(e,n)},t.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?qr(this.size,this._head,t,this.__hash):0===this.size?Dr():(this.__ownerID=t,this.__altered=!1,this)},t.prototype.__iterate=function(r,t){var n=this;if(t)return new tt(this.toArray()).__iterate(function(t,e){return r(t,e,n)},t);for(var e=0,i=this._head;i&&!1!==r(i.value,e++,this);)i=i.next;return e},t.prototype.__iterator=function(e,t){if(t)return new tt(this.toArray()).__iterator(e,t);var r=0,n=this._head;return new W(function(){if(n){var t=n.value;return n=n.next,P(e,r++,t)}return N()})},t}(E);Er.isStack=Or;var Mr,jr=Er.prototype;function qr(t,e,r,n){var i=Object.create(jr);return i.size=t,i._head=e,i.__ownerID=r,i.__hash=n,i.__altered=!1,i}function Dr(){return Mr=Mr||qr(0)}jr[Ir]=!0,jr.shift=jr.pop,jr.unshift=jr.push, jr.unshiftAll=jr.pushAll,jr.withMutations=xe,jr.wasAltered=Ue,jr.asImmutable=Re,jr["@@transducer/init"]=jr.asMutable=ke,jr["@@transducer/step"]=function(t,e){return t.unshift(e)},jr["@@transducer/result"]=function(t){return t.asImmutable()};var Ar="@@__IMMUTABLE_SET__@@";function xr(t){return!(!t||!t[Ar])}function kr(t){return xr(t)&&R(t)}function Rr(r,t){if(r===t)return!0;if(!f(t)||void 0!==r.size&&void 0!==t.size&&r.size!==t.size||void 0!==r.__hash&&void 0!==t.__hash&&r.__hash!==t.__hash||a(r)!==a(t)||S(r)!==S(t)||R(r)!==R(t))return!1;if(0===r.size&&0===t.size)return!0;var n=!b(r);if(R(r)){var i=r.entries();return t.every(function(t,e){var r=i.next().value;return r&&_t(r[1],t)&&(n||_t(r[0],e))})&&i.next().done}var e,o=!1;void 0===r.size&&(void 0===t.size?"function"==typeof r.cacheResult&&r.cacheResult():(o=!0,e=r,r=t,t=e));var u=!0,t=t.__iterate(function(t,e){if(n?!r.has(t):o?!_t(t,r.get(e,v)):!_t(r.get(e,v),t))return u=!1});return u&&r.size===t}function Ur(e,r){function t(t){e.prototype[t]=r[t]}return Object.keys(r).forEach(t),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(r).forEach(t),e}function Kr(t){if(!t||"object"!=typeof t)return t;if(!f(t)){if(!ie(t))return t;t=F(t)}if(a(t)){var r={};return t.__iterate(function(t,e){r[e]=Kr(t)}),r}var e=[];return t.__iterate(function(t){e.push(Kr(t))}),e}var Tr=function(n){function e(r){return null==r?Pr():xr(r)&&!R(r)?r:Pr().withMutations(function(e){var t=n(r);te(t.size),t.forEach(function(t){return e.add(t)})})}return n&&(e.__proto__=n),((e.prototype=Object.create(n&&n.prototype)).constructor=e).of=function(){return this(arguments)},e.fromKeys=function(t){return this(O(t).keySeq())},e.intersect=function(t){return(t=I(t).toArray()).length?Lr.intersect.apply(e(t.pop()),t):Pr()},e.union=function(t){return(t=I(t).toArray()).length?Lr.union.apply(e(t.pop()),t):Pr()},e.prototype.toString=function(){return this.__toString("Set {","}")},e.prototype.has=function(t){return this._map.has(t)},e.prototype.add=function(t){return Br(this,this._map.set(t,t))}, -e.prototype.remove=function(t){return Br(this,this._map.remove(t))},e.prototype.clear=function(){return Br(this,this._map.clear())},e.prototype.map=function(r,n){var i=this,o=!1,t=Br(this,this._map.mapEntries(function(t){var e=t[1],t=r.call(n,e,e,i);return t!==e&&(o=!0),[t,t]},n));return o?t:this},e.prototype.union=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return 0===(r=r.filter(function(t){return 0!==t.size})).length?this:0!==this.size||this.__ownerID||1!==r.length?this.withMutations(function(e){for(var t=0;t>>-15,461845907),e=pt(e<<13|e>>>-13,5),e=pt((e=(e+3864292196|0)^t)^e>>>16,2246822507),e=lt((e=pt(e^e>>>13,3266489909))^e>>>16)}(t.__iterate(r?e?function(t,e){n=31*n+un(yt(t),yt(e))|0}:function(t,e){n=n+un(yt(t),yt(e))|0}:e?function(t){n=31*n+yt(t)|0}:function(t){n=n+yt(t)|0}),n)}(this))}});var Xr=I.prototype;Xr[o]=!0,Xr[B]=Xr.values,Xr.toJSON=Xr.toArray,Xr.__toStringMapper=oe,Xr.inspect=Xr.toSource=function(){return""+this},Xr.chain=Xr.flatMap,Xr.contains=Xr.includes,Ur(O,{flip:function(){return Vt(this,Ut(this))},mapEntries:function(r,n){var i=this,o=0;return Vt(this,this.toSeq().map(function(t,e){return r.call(n,[e,t],o++,i)}).fromEntrySeq())},mapKeys:function(r,n){var i=this;return Vt(this,this.toSeq().flip().map(function(t,e){return r.call(n,t,e,i)}).flip())}});var Fr=O.prototype;Fr[s]=!0,Fr[B]=Xr.entries,Fr.toJSON=Qr,Fr.__toStringMapper=function(t,e){return oe(e)+": "+oe(t)},Ur(E,{toKeyedSeq:function(){return new At(this,!1)},filter:function(t,e){return Vt(this,Ct(this,t,e,!1))},findIndex:function(t,e){e=this.findEntry(t,e);return e?e[0]:-1},indexOf:function(t){t=this.keyOf(t);return void 0===t?-1:t},lastIndexOf:function(t){t=this.lastKeyOf(t);return void 0===t?-1:t},reverse:function(){return Vt(this,Tt(this,!1))},slice:function(t,e){return Vt(this,Lt(this,t,e,!1))},splice:function(t,e){var r=arguments.length;if(e=Math.max(e||0,0),0===r||2===r&&!e)return this;t=y(t,t<0?this.count():this.size);var n=this.slice(0,t);return Vt(this,1===r?n:n.concat(Zt(arguments,2),this.slice(t+e)))},findLastIndex:function(t,e){e=this.findLastEntry(t,e);return e?e[0]:-1},first:function(t){return this.get(0,t)},flatten:function(t){return Vt(this,Wt(this,t,!1))},get:function(r,t){return(r=h(this,r))<0||this.size===1/0||void 0!==this.size&&this.size>2)|0}Gr[z]=!0,Gr[k]=!0,Ur(M,{get:function(t,e){return this.has(t)?t:e},includes:function(t){return this.has(t)},keySeq:function(){return this.valueSeq()}}),M.prototype.has=Xr.includes,M.prototype.contains=M.prototype.includes,Ur(G,O.prototype),Ur(Z,E.prototype),Ur($,M.prototype);var sn=function(t){function e(r){return null==r?hn():kr(r)?r:hn().withMutations(function(e){var t=M(r);te(t.size),t.forEach(function(t){return e.add(t)})})}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).of=function(){return this(arguments)},e.fromKeys=function(t){return this(O(t).keySeq())}, -e.prototype.toString=function(){return this.__toString("OrderedSet {","}")},e}(Tr);sn.isOrderedSet=kr;var an,cn=sn.prototype;function fn(t,e){var r=Object.create(cn);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function hn(){return an=an||fn(Sr())}cn[k]=!0,cn.zip=Gr.zip,cn.zipWith=Gr.zipWith,cn.zipAll=Gr.zipAll,cn.__empty=hn,cn.__make=fn;Fr=function(u,s){var a;!function(t){if(A(t))throw Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(x(t))throw Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(null===t||"object"!=typeof t)throw Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}(u);var c=function(t){var n=this;if(t instanceof c)return t;if(!(this instanceof c))return new c(t);if(!a){a=!0;var e=Object.keys(u),r=f._indices={};f._name=s,f._keys=e,f._defaultValues=u;for(var i=0;i>>-15,461845907),e=pt(e<<13|e>>>-13,5),e=pt((e=(e+3864292196|0)^t)^e>>>16,2246822507),e=lt((e=pt(e^e>>>13,3266489909))^e>>>16)}(t.__iterate(r?e?function(t,e){n=31*n+sn(yt(t),yt(e))|0}:function(t,e){n=n+sn(yt(t),yt(e))|0}:e?function(t){n=31*n+yt(t)|0}:function(t){n=n+yt(t)|0}),n)}(this))}});var Xr=I.prototype;Xr[o]=!0,Xr[B]=Xr.values,Xr.toJSON=Xr.toArray,Xr.__toStringMapper=oe,Xr.inspect=Xr.toSource=function(){return""+this},Xr.chain=Xr.flatMap,Xr.contains=Xr.includes,Ur(O,{flip:function(){return Vt(this,Ut(this))},mapEntries:function(r,n){var i=this,o=0;return Vt(this,this.toSeq().map(function(t,e){return r.call(n,[e,t],o++,i)}).fromEntrySeq())},mapKeys:function(r,n){var i=this;return Vt(this,this.toSeq().flip().map(function(t,e){return r.call(n,t,e,i)}).flip())}});var Fr=O.prototype;Fr[s]=!0,Fr[B]=Xr.entries,Fr.toJSON=Qr,Fr.__toStringMapper=function(t,e){return oe(e)+": "+oe(t)},Ur(E,{toKeyedSeq:function(){return new At(this,!1)},filter:function(t,e){return Vt(this,Ct(this,t,e,!1))},findIndex:function(t,e){e=this.findEntry(t,e);return e?e[0]:-1},indexOf:function(t){t=this.keyOf(t);return void 0===t?-1:t},lastIndexOf:function(t){t=this.lastKeyOf(t);return void 0===t?-1:t},reverse:function(){return Vt(this,Tt(this,!1))},slice:function(t,e){return Vt(this,Lt(this,t,e,!1))},splice:function(t,e){var r=arguments.length;if(e=Math.max(e||0,0),0===r||2===r&&!e)return this;t=y(t,t<0?this.count():this.size);var n=this.slice(0,t);return Vt(this,1===r?n:n.concat(Zt(arguments,2),this.slice(t+e)))},findLastIndex:function(t,e){e=this.findLastEntry(t,e);return e?e[0]:-1},first:function(t){return this.get(0,t)},flatten:function(t){return Vt(this,Wt(this,t,!1))},get:function(r,t){return(r=h(this,r))<0||this.size===1/0||void 0!==this.size&&this.size>2)|0}Zr.has=Xr.includes,Zr.contains=Zr.includes,Zr.keys=Zr.values,Ur(G,Fr),Ur(Z,Gr),Ur($,Zr);var an=function(t){function e(r){return null==r?_n():kr(r)?r:_n().withMutations(function(e){var t=M(r);te(t.size),t.forEach(function(t){return e.add(t)})})}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).of=function(){return this(arguments)},e.fromKeys=function(t){return this(O(t).keySeq())}, +e.prototype.toString=function(){return this.__toString("OrderedSet {","}")},e}(Tr);an.isOrderedSet=kr;var cn,fn=an.prototype;function hn(t,e){var r=Object.create(fn);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function _n(){return cn=cn||hn(Sr())}fn[k]=!0,fn.zip=Gr.zip,fn.zipWith=Gr.zipWith,fn.zipAll=Gr.zipAll,fn.__empty=_n,fn.__make=hn;Zr=function(u,s){var a;!function(t){if(A(t))throw Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(x(t))throw Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(null===t||"object"!=typeof t)throw Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}(u);var c=function(t){var n=this;if(t instanceof c)return t;if(!(this instanceof c))return new c(t);if(!a){a=!0;var e=Object.keys(u),r=f._indices={};f._name=s,f._keys=e,f._defaultValues=u;for(var i=0;i Date: Fri, 23 Jul 2021 16:51:59 +0000 Subject: [PATCH 165/242] deploy: 7c64271fd3571b99de6067719beac2d503f56966 --- dist/immutable.d.ts | 12 +++++--- dist/immutable.es.js | 38 +++++++++++++++---------- dist/immutable.js | 38 +++++++++++++++---------- dist/immutable.min.js | 64 +++++++++++++++++++++---------------------- 4 files changed, 88 insertions(+), 64 deletions(-) diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index af45330084..456f2bc81c 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -4871,6 +4871,10 @@ declare namespace Immutable { /** * Deeply converts plain JS objects and arrays to Immutable Maps and Lists. * + * `fromJS` will convert Arrays and [array-like objects][2] to a List, and + * plain objects (without a custom prototype) to a Map. [Iterable objects][3] + * may be converted to List, Map, or Set. + * * If a `reviver` is optionally provided, it will be called with every * collection as a Seq (beginning with the most nested collections * and proceeding to the top-level collection itself), along with the key @@ -4893,10 +4897,6 @@ declare namespace Immutable { * } * ``` * - * `fromJS` is conservative in its conversion. It will only convert - * arrays which pass `Array.isArray` to Lists, and only raw objects (no custom - * prototype) to Map. - * * Accordingly, this example converts native JS data to OrderedMap and List: * * @@ -4933,6 +4933,10 @@ declare namespace Immutable { * * [1]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse#Example.3A_Using_the_reviver_parameter * "Using the reviver parameter" + * [2]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Indexed_collections#working_with_array-like_objects + * "Working with array-like objects" + * [3]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_iterable_protocol + * "The iterable protocol" */ function fromJS( jsValue: unknown, diff --git a/dist/immutable.es.js b/dist/immutable.es.js index afeada84d3..dabedd01aa 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -271,6 +271,16 @@ function getIteratorFn(iterable) { } } +function isEntriesIterable(maybeIterable) { + var iteratorFn = getIteratorFn(maybeIterable); + return iteratorFn && iteratorFn === maybeIterable.entries; +} + +function isKeysIterable(maybeIterable) { + var iteratorFn = getIteratorFn(maybeIterable); + return iteratorFn && iteratorFn === maybeIterable.keys; +} + var hasOwnProperty = Object.prototype.hasOwnProperty; function isArrayLike(value) { @@ -601,11 +611,7 @@ function emptySequence() { } function keyedSeqFromValue(value) { - var seq = Array.isArray(value) - ? new ArraySeq(value) - : hasIterator(value) - ? new CollectionSeq(value) - : undefined; + var seq = maybeIndexedSeqFromValue(value); if (seq) { return seq.fromEntrySeq(); } @@ -631,7 +637,11 @@ function indexedSeqFromValue(value) { function seqFromValue(value) { var seq = maybeIndexedSeqFromValue(value); if (seq) { - return seq; + return isEntriesIterable(value) + ? seq.fromEntrySeq() + : isKeysIterable(value) + ? seq.toSetSeq() + : seq; } if (typeof value === 'object') { return new ObjectSeq(value); @@ -5806,12 +5816,11 @@ function fromJS(value, converter) { } function fromJSWith(stack, converter, value, key, keyPath, parentValue) { - var toSeq = Array.isArray(value) - ? IndexedSeq - : isPlainObject(value) - ? KeyedSeq - : null; - if (toSeq) { + if ( + typeof value !== 'string' && + !isImmutable(value) && + (isArrayLike(value) || hasIterator(value) || isPlainObject(value)) + ) { if (~stack.indexOf(value)) { throw new TypeError('Cannot convert circular structure to Immutable'); } @@ -5820,7 +5829,7 @@ function fromJSWith(stack, converter, value, key, keyPath, parentValue) { var converted = converter.call( parentValue, key, - toSeq(value).map(function (v, k) { return fromJSWith(stack, converter, v, k, keyPath, value); } + Seq(value).map(function (v, k) { return fromJSWith(stack, converter, v, k, keyPath, value); } ), keyPath && keyPath.slice() ); @@ -5832,7 +5841,8 @@ function fromJSWith(stack, converter, value, key, keyPath, parentValue) { } function defaultConverter(k, v) { - return isKeyed(v) ? v.toMap() : v.toList(); + // Effectively the opposite of "Collection.toSeq()" + return isIndexed(v) ? v.toList() : isKeyed(v) ? v.toMap() : v.toSet(); } var version = "4.0.0-rc.14"; diff --git a/dist/immutable.js b/dist/immutable.js index a5c2bf1012..9603347302 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -277,6 +277,16 @@ } } + function isEntriesIterable(maybeIterable) { + var iteratorFn = getIteratorFn(maybeIterable); + return iteratorFn && iteratorFn === maybeIterable.entries; + } + + function isKeysIterable(maybeIterable) { + var iteratorFn = getIteratorFn(maybeIterable); + return iteratorFn && iteratorFn === maybeIterable.keys; + } + var hasOwnProperty = Object.prototype.hasOwnProperty; function isArrayLike(value) { @@ -607,11 +617,7 @@ } function keyedSeqFromValue(value) { - var seq = Array.isArray(value) - ? new ArraySeq(value) - : hasIterator(value) - ? new CollectionSeq(value) - : undefined; + var seq = maybeIndexedSeqFromValue(value); if (seq) { return seq.fromEntrySeq(); } @@ -637,7 +643,11 @@ function seqFromValue(value) { var seq = maybeIndexedSeqFromValue(value); if (seq) { - return seq; + return isEntriesIterable(value) + ? seq.fromEntrySeq() + : isKeysIterable(value) + ? seq.toSetSeq() + : seq; } if (typeof value === 'object') { return new ObjectSeq(value); @@ -5812,12 +5822,11 @@ } function fromJSWith(stack, converter, value, key, keyPath, parentValue) { - var toSeq = Array.isArray(value) - ? IndexedSeq - : isPlainObject(value) - ? KeyedSeq - : null; - if (toSeq) { + if ( + typeof value !== 'string' && + !isImmutable(value) && + (isArrayLike(value) || hasIterator(value) || isPlainObject(value)) + ) { if (~stack.indexOf(value)) { throw new TypeError('Cannot convert circular structure to Immutable'); } @@ -5826,7 +5835,7 @@ var converted = converter.call( parentValue, key, - toSeq(value).map(function (v, k) { return fromJSWith(stack, converter, v, k, keyPath, value); } + Seq(value).map(function (v, k) { return fromJSWith(stack, converter, v, k, keyPath, value); } ), keyPath && keyPath.slice() ); @@ -5838,7 +5847,8 @@ } function defaultConverter(k, v) { - return isKeyed(v) ? v.toMap() : v.toList(); + // Effectively the opposite of "Collection.toSeq()" + return isIndexed(v) ? v.toList() : isKeyed(v) ? v.toMap() : v.toSet(); } var version = "4.0.0-rc.14"; diff --git a/dist/immutable.min.js b/dist/immutable.min.js index 748d1d117d..ed9baa6652 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -21,35 +21,35 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).Immutable={})}(this,function(t){"use strict";var e="delete",d=5,l=1<>>0;if(""+r!==e||4294967295==r)return NaN;e=r}return e<0?c(t)+e:e}function r(){return!0}function p(t,e,r){return(0===t&&!i(t)||void 0!==r&&t<=-r)&&(void 0===e||void 0!==r&&r<=e)}function y(t,e){return n(t,e,0)}function w(t,e){return n(t,e,e)}function n(t,e,r){return void 0===t?r:i(t)?e===1/0?e:0|Math.max(0,e+t):void 0===e||e===t?t:0|Math.min(e,t)}function i(t){return t<0||0===t&&1/t==-1/0}var o="@@__IMMUTABLE_ITERABLE__@@";function f(t){return!(!t||!t[o])}var s="@@__IMMUTABLE_KEYED__@@";function a(t){return!(!t||!t[s])}var z="@@__IMMUTABLE_INDEXED__@@";function S(t){return!(!t||!t[z])}function b(t){return a(t)||S(t)}function I(t){return f(t)?t:F(t)}var O=function(t){function e(t){return a(t)?t:G(t)}return e.__proto__=t,(e.prototype=Object.create(t.prototype)).constructor=e}(I),E=function(t){function e(t){return S(t)?t:Z(t)}return e.__proto__=t,(e.prototype=Object.create(t.prototype)).constructor=e}(I),M=function(t){function e(t){return f(t)&&!b(t)?t:$(t)}return e.__proto__=t,(e.prototype=Object.create(t.prototype)).constructor=e}(I);I.Keyed=O,I.Indexed=E,I.Set=M;var j="@@__IMMUTABLE_SEQ__@@";function q(t){return!(!t||!t[j])}var D="@@__IMMUTABLE_RECORD__@@";function A(t){return!(!t||!t[D])}function x(t){return f(t)||A(t)}var k="@@__IMMUTABLE_ORDERED__@@";function R(t){return!(!t||!t[k])}var U=0,K=1,T=2,C="function"==typeof Symbol&&Symbol.iterator,L="@@iterator",B=C||L,W=function(t){this.next=t};function P(t,e,r,n){r=0===t?e:1===t?r:[e,r];return n?n.value=r:n={value:r,done:!1},n}function N(){return{value:void 0,done:!0}}function H(t){return Array.isArray(t -)||Y(t)}function J(t){return t&&"function"==typeof t.next}function V(t){var e=Y(t);return e&&e.call(t)}function Y(t){t=t&&(C&&t[C]||t[L]);if("function"==typeof t)return t}W.prototype.toString=function(){return"[Iterator]"},W.KEYS=U,W.VALUES=K,W.ENTRIES=T,W.prototype.inspect=W.prototype.toSource=function(){return""+this},W.prototype[B]=function(){return this};var Q=Object.prototype.hasOwnProperty;function X(t){return Array.isArray(t)||"string"==typeof t||t&&"object"==typeof t&&Number.isInteger(t.length)&&0<=t.length&&(0===t.length?1===Object.keys(t).length:t.hasOwnProperty(t.length-1))}var F=function(t){function e(t){return null==t?it():x(t)?t.toSeq():function(t){var e=st(t);if(e)return e;if("object"!=typeof t)throw new TypeError("Expected Array or collection object of values, or keyed object: "+t);return new et(t)}(t)}return e.__proto__=t,((e.prototype=Object.create(t.prototype)).constructor=e).prototype.toSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq {","}")},e.prototype.cacheResult=function(){return!this._cache&&this.__iterateUncached&&(this._cache=this.entrySeq().toArray(),this.size=this._cache.length),this},e.prototype.__iterate=function(t,e){var r=this._cache;if(r){for(var n=r.length,i=0;i!==n;){var o=r[e?n-++i:i++];if(!1===t(o[1],o[0],this))break}return i}return this.__iterateUncached(t,e)},e.prototype.__iterator=function(e,r){var n=this._cache;if(n){var i=n.length,o=0;return new W(function(){if(o===i)return N();var t=n[r?i-++o:o++];return P(e,t[0],t[1])})}return this.__iteratorUncached(e,r)},e}(I),G=function(t){function e(t){return null==t?it().toKeyedSeq():f(t)?a(t)?t.toSeq():t.fromEntrySeq():A(t)?t.toSeq():ot(t)}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).prototype.toKeyedSeq=function(){return this},e}(F),Z=function(t){function e(t){return null==t?it():f(t)?a(t)?t.entrySeq():t.toIndexedSeq():A(t)?t.toSeq().entrySeq():ut(t)}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).of=function(){ -return e(arguments)},e.prototype.toIndexedSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq [","]")},e}(F),$=function(t){function e(t){return(f(t)&&!b(t)?t:Z(t)).toSetSeq()}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).of=function(){return e(arguments)},e.prototype.toSetSeq=function(){return this},e}(F);F.isSeq=q,F.Keyed=G,F.Set=$,F.Indexed=Z,F.prototype[j]=!0;var tt=function(t){function e(t){this._array=t,this.size=t.length}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).prototype.get=function(t,e){return this.has(t)?this._array[h(this,t)]:e},e.prototype.__iterate=function(t,e){for(var r=this._array,n=r.length,i=0;i!==n;){var o=e?n-++i:i++;if(!1===t(r[o],o,this))break}return i},e.prototype.__iterator=function(e,r){var n=this._array,i=n.length,o=0;return new W(function(){if(o===i)return N();var t=r?i-++o:o++;return P(e,t,n[t])})},e}(Z),et=function(t){function e(t){var e=Object.keys(t);this._object=t,this._keys=e,this.size=e.length}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).prototype.get=function(t,e){return void 0===e||this.has(t)?this._object[t]:e},e.prototype.has=function(t){return Q.call(this._object,t)},e.prototype.__iterate=function(t,e){for(var r=this._object,n=this._keys,i=n.length,o=0;o!==i;){var u=n[e?i-++o:o++];if(!1===t(r[u],u,this))break}return o},e.prototype.__iterator=function(e,r){var n=this._object,i=this._keys,o=i.length,u=0;return new W(function(){if(u===o)return N();var t=i[r?o-++u:u++];return P(e,t,n[t])})},e}(G);et.prototype[k]=!0;var rt,nt=function(t){function e(t){this._collection=t,this.size=t.length||t.size}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).prototype.__iterateUncached=function(t,e){if(e)return this.cacheResult().__iterate(t,e);var r,n=V(this._collection),i=0;if(J(n))for(;!(r=n.next()).done&&!1!==t(r.value,i++,this););return i},e.prototype.__iteratorUncached=function(e,t){if(t -)return this.cacheResult().__iterator(e,t);var r=V(this._collection);if(!J(r))return new W(N);var n=0;return new W(function(){var t=r.next();return t.done?t:P(e,n++,t.value)})},e}(Z);function it(){return rt=rt||new tt([])}function ot(t){var e=Array.isArray(t)?new tt(t):H(t)?new nt(t):void 0;if(e)return e.fromEntrySeq();if("object"==typeof t)return new et(t);throw new TypeError("Expected Array or collection object of [k, v] entries, or keyed object: "+t)}function ut(t){var e=st(t);if(e)return e;throw new TypeError("Expected Array or collection object of values: "+t)}function st(t){return X(t)?new tt(t):H(t)?new nt(t):void 0}var at="@@__IMMUTABLE_MAP__@@";function ct(t){return!(!t||!t[at])}function ft(t){return ct(t)&&R(t)}function ht(t){return!(!t||"function"!=typeof t.equals||"function"!=typeof t.hashCode)}function _t(t,e){if(t===e||t!=t&&e!=e)return!0;if(!t||!e)return!1;if("function"==typeof t.valueOf&&"function"==typeof e.valueOf){if((t=t.valueOf())===(e=e.valueOf())||t!=t&&e!=e)return!0;if(!t||!e)return!1}return!!(ht(t)&&ht(e)&&t.equals(e))}var pt="function"==typeof Math.imul&&-2==Math.imul(4294967295,2)?Math.imul:function(t,e){var r=65535&(t|=0),n=65535&(e|=0);return r*n+((t>>>16)*n+r*(e>>>16)<<16>>>0)|0};function lt(t){return t>>>1&1073741824|3221225471&t}var vt=Object.prototype.valueOf;function yt(t){if(null==t)return dt(t);if("function"==typeof t.hashCode)return lt(t.hashCode(t));var e,r=(e=t).valueOf!==vt&&"function"==typeof e.valueOf?e.valueOf(e):e;if(null==r)return dt(r);switch(typeof r){case"boolean":return r?1108378657:1108378656;case"number":return function(t){if(t!=t||t===1/0)return 0;var e=0|t;e!==t&&(e^=4294967295*t);for(;4294967295f)return N();var t=r.next();return a||e===K||t.done?t:P(e,i-1,e===U?void 0:t.value[1],t)})},r}function Bt(e,c,f,h){var t=Xt(e);return t.__iterateUncached=function(n,t){var i=this;if(t)return this.cacheResult().__iterate(n,t);var o=!0,u=0;return e.__iterate(function(t,e,r){if(!(o=o&&c.call(f,t,e,r)))return u++,n(t,h?e:u-1,i)}),u},t.__iteratorUncached=function(i,t){var o=this;if(t)return this.cacheResult().__iterator(i,t);var u=e.__iterator(T,t),s=!0,a=0;return new W(function(){var t;do{if((t=u.next()).done)return h||i===K?t:P(i,a++,i===U?void 0:t.value[1],t);var e=t.value,r=e[0],n=e[1];s=s&&c.call(f,n,r,o)}while(s);return i===T?t:P(i,r,n,t)})},t}function Wt(t,s,a){var c=Xt(t);return c.__iterateUncached=function(i,e){if(e)return this.cacheResult().__iterate(i,e);var o=0,u=!1;return function r(t,n){t.__iterate(function(t,e){return(!s||n>>t)&g),o=this.bitmap;return 0==(o&i)?n:this.nodes[$e(o&i-1)].get(t+d,e,r,n)},Le.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=yt(n));var s=(0===e?r:r>>>e)&g,a=1<>>=1)u[s]=1&r?e[o++]:void 0;return u[n]=i,new Be(t,o+1,u)}(t,_,c,s,u);if(f&&!u&&2===_.length&&Ge(_[1^h]))return _[1^h];if(f&&u&&1===_.length&&Ge(u))return u;s=t&&t===this.ownerID,a=f?u?c:c^a:c|a,u=f?u?tr(_,h,u,s):function(t,e,r){var n=t.length-1;if(r&&e===n)return t.pop(),t;for(var i=Array(n),o=0,u=0;u>>t)&g];return i?i.get(t+d,e,r,n):n}, -Be.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=yt(n));var s=(0===e?r:r>>>e)&g,a=this.nodes,c=a[s];if(i===v&&!c)return this;o=Fe(c,t,e+d,r,n,i,o,u);if(o===c)return this;u=this.count;if(c){if(!o&&--u>>r)&g,u=(0===r?n:n>>>r)&g,t=o==u?[Ze(t,e,r+d,n,i)]:(i=new Pe(e,n,i),o>1&1431655765))+(t>>2&858993459))+(t>>4)&252645135,t+=t>>8,127&(t+=t>>16)}function tr(t,e,r,n){t=n?t:Zt(t);return t[e]=r,t}var er=l/4,rr=l/2,nr=l/4,ir="@@__IMMUTABLE_LIST__@@";function or(t){return!(!t||!t[ir])}var ur=function(o){function t(t){var e=pr();if(null==t)return e;if(or(t))return t;var n=o(t),i=n.size;return 0===i?e:(te(i),0=gr(t._capacity)?n=lr(n,t.__ownerID,0,e,r,o):i=lr(i,t.__ownerID,t._level,e,r,o);if(!o.value)return t;if(t.__ownerID)return t._root=i,t._tail=n,t.__hash=void 0,t.__altered=!0,t;return _r(t._origin,t._capacity,t._level,i,n)}(this,t,e)},t.prototype.remove=function(t){return this.has(t)?0===t?this.shift():t===this.size-1?this.pop():this.splice(t,1):this},t.prototype.insert=function(t,e){return this.splice(t,0,e)},t.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=this._origin=this._capacity=0,this._level=d,this._root=this._tail=this.__hash=void 0,this.__altered=!0,this):pr()},t.prototype.push=function(){var r=arguments,n=this.size;return this.withMutations(function(t){dr(t,0,n+r.length);for(var e=0;e>>e&g;if(this.array.length<=n)return new ar([],t);var i=0==n;if(0>>e&g;if(this.array.length<=n)return this;if(0>e,u=1+(c-r>>e);l>>r&g,a=t&&s=gr(t._capacity))return t._tail;if(e<1<>>n&g],n-=d;return r}}function dr(t,e,r){void 0!==e&&(e|=0),void 0!==r&&(r|=0);var n=t.__ownerID||new m,i=t._origin,o=t._capacity,u=i+e,s=void 0===r?o:r<0?o+r:i+r;if(u===i&&s===o)return t;if(s<=u)return t.clear();for(var a=t._level,c=t._root,f=0;u+f<0;)c=new ar(c&&c.array.length?[void 0,c]:[],n),f+=1<<(a+=d);f&&(u+=f,i+=f,s+=f,o+=f);for(var h=gr(o),_=gr(s);1<>>l&g,p=p.array[v]=vr(p.array[v],n);p.array[h>>>d&g]=e}if(s>>a&g;if(y!=_>>>a&g)break;y&&(f+=(1<>>d<>>-15,461845907),e=pt(e<<13|e>>>-13,5),e=pt((e=(e+3864292196|0)^t)^e>>>16,2246822507),e=lt((e=pt(e^e>>>13,3266489909))^e>>>16)}(t.__iterate(r?e?function(t,e){n=31*n+sn(yt(t),yt(e))|0}:function(t,e){n=n+sn(yt(t),yt(e))|0}:e?function(t){n=31*n+yt(t)|0}:function(t){n=n+yt(t)|0}),n)}(this))}});var Xr=I.prototype;Xr[o]=!0,Xr[B]=Xr.values,Xr.toJSON=Xr.toArray,Xr.__toStringMapper=oe,Xr.inspect=Xr.toSource=function(){return""+this},Xr.chain=Xr.flatMap,Xr.contains=Xr.includes,Ur(O,{flip:function(){return Vt(this,Ut(this))},mapEntries:function(r,n){var i=this,o=0;return Vt(this,this.toSeq().map(function(t,e){return r.call(n,[e,t],o++,i)}).fromEntrySeq())},mapKeys:function(r,n){var i=this;return Vt(this,this.toSeq().flip().map(function(t,e){return r.call(n,t,e,i)}).flip())}});var Fr=O.prototype;Fr[s]=!0,Fr[B]=Xr.entries,Fr.toJSON=Qr,Fr.__toStringMapper=function(t,e){return oe(e)+": "+oe(t)},Ur(E,{toKeyedSeq:function(){return new At(this,!1)},filter:function(t,e){return Vt(this,Ct(this,t,e,!1))},findIndex:function(t,e){e=this.findEntry(t,e);return e?e[0]:-1},indexOf:function(t){t=this.keyOf(t);return void 0===t?-1:t},lastIndexOf:function(t){t=this.lastKeyOf(t);return void 0===t?-1:t},reverse:function(){return Vt(this,Tt(this,!1))},slice:function(t,e){return Vt(this,Lt(this,t,e,!1))},splice:function(t,e){var r=arguments.length;if(e=Math.max(e||0,0),0===r||2===r&&!e)return this;t=y(t,t<0?this.count():this.size);var n=this.slice(0,t);return Vt(this,1===r?n:n.concat(Zt(arguments,2),this.slice(t+e)))},findLastIndex:function(t,e){e=this.findLastEntry(t,e);return e?e[0]:-1},first:function(t){return this.get(0,t)},flatten:function(t){return Vt(this,Wt(this,t,!1))},get:function(r,t){return(r=h(this,r))<0||this.size===1/0||void 0!==this.size&&this.size>2)|0}Zr.has=Xr.includes,Zr.contains=Zr.includes,Zr.keys=Zr.values,Ur(G,Fr),Ur(Z,Gr),Ur($,Zr);var an=function(t){function e(r){return null==r?_n():kr(r)?r:_n().withMutations(function(e){var t=M(r);te(t.size),t.forEach(function(t){return e.add(t)})})}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).of=function(){return this(arguments)},e.fromKeys=function(t){return this(O(t).keySeq())}, -e.prototype.toString=function(){return this.__toString("OrderedSet {","}")},e}(Tr);an.isOrderedSet=kr;var cn,fn=an.prototype;function hn(t,e){var r=Object.create(fn);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function _n(){return cn=cn||hn(Sr())}fn[k]=!0,fn.zip=Gr.zip,fn.zipWith=Gr.zipWith,fn.zipAll=Gr.zipAll,fn.__empty=_n,fn.__make=hn;Zr=function(u,s){var a;!function(t){if(A(t))throw Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(x(t))throw Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(null===t||"object"!=typeof t)throw Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}(u);var c=function(t){var n=this;if(t instanceof c)return t;if(!(this instanceof c))return new c(t);if(!a){a=!0;var e=Object.keys(u),r=f._indices={};f._name=s,f._keys=e,f._defaultValues=u;for(var i=0;i>>0;if(""+r!==e||4294967295==r)return NaN;e=r}return e<0?c(t)+e:e}function r(){return!0}function p(t,e,r){return(0===t&&!i(t)||void 0!==r&&t<=-r)&&(void 0===e||void 0!==r&&r<=e)}function y(t,e){return n(t,e,0)}function w(t,e){return n(t,e,e)}function n(t,e,r){return void 0===t?r:i(t)?e===1/0?e:0|Math.max(0,e+t):void 0===e||e===t?t:0|Math.min(e,t)}function i(t){return t<0||0===t&&1/t==-1/0}var o="@@__IMMUTABLE_ITERABLE__@@";function f(t){return!(!t||!t[o])}var s="@@__IMMUTABLE_KEYED__@@";function a(t){return!(!t||!t[s])}var S="@@__IMMUTABLE_INDEXED__@@";function z(t){return!(!t||!t[S])}function b(t){return a(t)||z(t)}function I(t){return f(t)?t:F(t)}var O=function(t){function e(t){return a(t)?t:G(t)}return e.__proto__=t,(e.prototype=Object.create(t.prototype)).constructor=e}(I),E=function(t){function e(t){return z(t)?t:Z(t)}return e.__proto__=t,(e.prototype=Object.create(t.prototype)).constructor=e}(I),q=function(t){function e(t){return f(t)&&!b(t)?t:$(t)}return e.__proto__=t,(e.prototype=Object.create(t.prototype)).constructor=e}(I);I.Keyed=O,I.Indexed=E,I.Set=q;var M="@@__IMMUTABLE_SEQ__@@";function j(t){return!(!t||!t[M])}var D="@@__IMMUTABLE_RECORD__@@";function x(t){return!(!t||!t[D])}function A(t){return f(t)||x(t)}var k="@@__IMMUTABLE_ORDERED__@@";function R(t){return!(!t||!t[k])}var U=0,K=1,T=2,C="function"==typeof Symbol&&Symbol.iterator,L="@@iterator",B=C||L,W=function(t){this.next=t};function P(t,e,r,n){r=0===t?e:1===t?r:[e,r];return n?n.value=r:n={value:r,done:!1},n}function N(){return{value:void 0,done:!0}}function H(t){return Array.isArray(t +)||Y(t)}function J(t){return t&&"function"==typeof t.next}function V(t){var e=Y(t);return e&&e.call(t)}function Y(t){t=t&&(C&&t[C]||t[L]);if("function"==typeof t)return t}W.prototype.toString=function(){return"[Iterator]"},W.KEYS=U,W.VALUES=K,W.ENTRIES=T,W.prototype.inspect=W.prototype.toSource=function(){return""+this},W.prototype[B]=function(){return this};var Q=Object.prototype.hasOwnProperty;function X(t){return Array.isArray(t)||"string"==typeof t||t&&"object"==typeof t&&Number.isInteger(t.length)&&0<=t.length&&(0===t.length?1===Object.keys(t).length:t.hasOwnProperty(t.length-1))}var F=function(t){function e(t){return null==t?it():A(t)?t.toSeq():function(t){var e=st(t);if(e)return function(t){var e=Y(t);return e&&e===t.entries}(t)?e.fromEntrySeq():function(t){var e=Y(t);return e&&e===t.keys}(t)?e.toSetSeq():e;if("object"!=typeof t)throw new TypeError("Expected Array or collection object of values, or keyed object: "+t);return new et(t)}(t)}return e.__proto__=t,((e.prototype=Object.create(t.prototype)).constructor=e).prototype.toSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq {","}")},e.prototype.cacheResult=function(){return!this._cache&&this.__iterateUncached&&(this._cache=this.entrySeq().toArray(),this.size=this._cache.length),this},e.prototype.__iterate=function(t,e){var r=this._cache;if(r){for(var n=r.length,i=0;i!==n;){var o=r[e?n-++i:i++];if(!1===t(o[1],o[0],this))break}return i}return this.__iterateUncached(t,e)},e.prototype.__iterator=function(e,r){var n=this._cache;if(n){var i=n.length,o=0;return new W(function(){if(o===i)return N();var t=n[r?i-++o:o++];return P(e,t[0],t[1])})}return this.__iteratorUncached(e,r)},e}(I),G=function(t){function e(t){return null==t?it().toKeyedSeq():f(t)?a(t)?t.toSeq():t.fromEntrySeq():x(t)?t.toSeq():ot(t)}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).prototype.toKeyedSeq=function(){return this},e}(F),Z=function(t){function e(t){return null==t?it():f(t)?a(t)?t.entrySeq():t.toIndexedSeq():x(t +)?t.toSeq().entrySeq():ut(t)}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).of=function(){return e(arguments)},e.prototype.toIndexedSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq [","]")},e}(F),$=function(t){function e(t){return(f(t)&&!b(t)?t:Z(t)).toSetSeq()}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).of=function(){return e(arguments)},e.prototype.toSetSeq=function(){return this},e}(F);F.isSeq=j,F.Keyed=G,F.Set=$,F.Indexed=Z,F.prototype[M]=!0;var tt=function(t){function e(t){this._array=t,this.size=t.length}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).prototype.get=function(t,e){return this.has(t)?this._array[h(this,t)]:e},e.prototype.__iterate=function(t,e){for(var r=this._array,n=r.length,i=0;i!==n;){var o=e?n-++i:i++;if(!1===t(r[o],o,this))break}return i},e.prototype.__iterator=function(e,r){var n=this._array,i=n.length,o=0;return new W(function(){if(o===i)return N();var t=r?i-++o:o++;return P(e,t,n[t])})},e}(Z),et=function(t){function e(t){var e=Object.keys(t);this._object=t,this._keys=e,this.size=e.length}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).prototype.get=function(t,e){return void 0===e||this.has(t)?this._object[t]:e},e.prototype.has=function(t){return Q.call(this._object,t)},e.prototype.__iterate=function(t,e){for(var r=this._object,n=this._keys,i=n.length,o=0;o!==i;){var u=n[e?i-++o:o++];if(!1===t(r[u],u,this))break}return o},e.prototype.__iterator=function(e,r){var n=this._object,i=this._keys,o=i.length,u=0;return new W(function(){if(u===o)return N();var t=i[r?o-++u:u++];return P(e,t,n[t])})},e}(G);et.prototype[k]=!0;var rt,nt=function(t){function e(t){this._collection=t,this.size=t.length||t.size}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).prototype.__iterateUncached=function(t,e){if(e)return this.cacheResult().__iterate(t,e);var r,n=V(this._collection), +i=0;if(J(n))for(;!(r=n.next()).done&&!1!==t(r.value,i++,this););return i},e.prototype.__iteratorUncached=function(e,t){if(t)return this.cacheResult().__iterator(e,t);var r=V(this._collection);if(!J(r))return new W(N);var n=0;return new W(function(){var t=r.next();return t.done?t:P(e,n++,t.value)})},e}(Z);function it(){return rt=rt||new tt([])}function ot(t){var e=st(t);if(e)return e.fromEntrySeq();if("object"==typeof t)return new et(t);throw new TypeError("Expected Array or collection object of [k, v] entries, or keyed object: "+t)}function ut(t){var e=st(t);if(e)return e;throw new TypeError("Expected Array or collection object of values: "+t)}function st(t){return X(t)?new tt(t):H(t)?new nt(t):void 0}var at="@@__IMMUTABLE_MAP__@@";function ct(t){return!(!t||!t[at])}function ft(t){return ct(t)&&R(t)}function ht(t){return!(!t||"function"!=typeof t.equals||"function"!=typeof t.hashCode)}function _t(t,e){if(t===e||t!=t&&e!=e)return!0;if(!t||!e)return!1;if("function"==typeof t.valueOf&&"function"==typeof e.valueOf){if((t=t.valueOf())===(e=e.valueOf())||t!=t&&e!=e)return!0;if(!t||!e)return!1}return!!(ht(t)&&ht(e)&&t.equals(e))}var pt="function"==typeof Math.imul&&-2==Math.imul(4294967295,2)?Math.imul:function(t,e){var r=65535&(t|=0),n=65535&(e|=0);return r*n+((t>>>16)*n+r*(e>>>16)<<16>>>0)|0};function lt(t){return t>>>1&1073741824|3221225471&t}var vt=Object.prototype.valueOf;function yt(t){if(null==t)return dt(t);if("function"==typeof t.hashCode)return lt(t.hashCode(t));var e,r=(e=t).valueOf!==vt&&"function"==typeof e.valueOf?e.valueOf(e):e;if(null==r)return dt(r);switch(typeof r){case"boolean":return r?1108378657:1108378656;case"number":return function(t){if(t!=t||t===1/0)return 0;var e=0|t;e!==t&&(e^=4294967295*t);for(;4294967295f)return N();var t=r.next();return a||e===K||t.done?t:P(e,i-1,e===U?void 0:t.value[1],t)})},r}function Bt(e,c,f,h){var t=Xt(e);return t.__iterateUncached=function(n,t){var i=this;if(t)return this.cacheResult().__iterate(n,t);var o=!0,u=0;return e.__iterate(function(t,e,r){if(!(o=o&&c.call(f,t,e,r)))return u++,n(t,h?e:u-1,i)}),u},t.__iteratorUncached=function(i,t){var o=this;if(t)return this.cacheResult().__iterator(i,t);var u=e.__iterator(T,t),s=!0,a=0;return new W(function(){var t;do{if((t=u.next()).done)return h||i===K?t:P(i,a++,i===U?void 0:t.value[1],t);var e=t.value,r=e[0],n=e[1];s=s&&c.call(f,n,r,o)}while(s);return i===T?t:P(i,r,n,t)})},t}function Wt(t,s,a){var c=Xt(t);return c.__iterateUncached=function(i,e){if(e)return this.cacheResult().__iterate(i,e);var o=0,u=!1;return function r(t,n){t.__iterate(function(t,e){return(!s||n>>t)&g),o=this.bitmap;return 0==(o&i)?n:this.nodes[$e(o&i-1)].get(t+d,e,r,n)},Le.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=yt(n));var s=(0===e?r:r>>>e)&g,a=1<>>=1)u[s]=1&r?e[o++]:void 0;return u[n]=i,new Be(t,o+1,u)}(t,_,c,s,u);if(f&&!u&&2===_.length&&Ge(_[1^h]))return _[1^h];if(f&&u&&1===_.length&&Ge(u))return u;s=t&&t===this.ownerID,a=f?u?c:c^a:c|a,u=f?u?tr(_,h,u,s):function(t,e,r){var n=t.length-1;if(r&&e===n)return t.pop(),t;for(var i=Array(n),o=0,u=0;u>>t)&g];return i?i.get(t+d,e,r,n):n},Be.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=yt(n));var s=(0===e?r:r>>>e)&g,a=this.nodes,c=a[s];if(i===v&&!c)return this;o=Fe(c,t,e+d,r,n,i,o,u);if(o===c)return this;u=this.count;if(c){if(!o&&--u>>r)&g,u=(0===r?n:n>>>r)&g,t=o==u?[Ze(t,e,r+d,n,i)]:(i=new Pe(e,n,i),o>1&1431655765))+(t>>2&858993459))+(t>>4)&252645135,t+=t>>8,127&(t+=t>>16)}function tr(t,e,r,n){t=n?t:Zt(t);return t[e]=r,t}var er=l/4,rr=l/2,nr=l/4,ir="@@__IMMUTABLE_LIST__@@";function or(t){return!(!t||!t[ir])}var ur=function(o){function t(t){var e=pr();if(null==t)return e;if(or(t))return t;var n=o(t),i=n.size;return 0===i?e:(te(i),0=gr(t._capacity)?n=lr(n,t.__ownerID,0,e,r,o):i=lr(i,t.__ownerID,t._level,e,r,o);if(!o.value)return t;if(t.__ownerID)return t._root=i,t._tail=n,t.__hash=void 0,t.__altered=!0,t;return _r(t._origin,t._capacity,t._level,i,n)}(this,t,e)},t.prototype.remove=function(t){return this.has(t)?0===t?this.shift():t===this.size-1?this.pop():this.splice(t,1):this},t.prototype.insert=function(t,e){return this.splice(t,0,e)},t.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=this._origin=this._capacity=0,this._level=d,this._root=this._tail=this.__hash=void 0,this.__altered=!0,this):pr()},t.prototype.push=function(){var r=arguments,n=this.size;return this.withMutations(function(t){dr(t,0,n+r.length);for(var e=0;e>>e&g;if(this.array.length<=n)return new ar([],t);var i=0==n;if(0>>e&g;if(this.array.length<=n)return this;if(0>e,u=1+(c-r>>e);l>>r&g,a=t&&s=gr(t._capacity))return t._tail;if(e<1<>>n&g],n-=d;return r}}function dr(t,e,r){void 0!==e&&(e|=0),void 0!==r&&(r|=0);var n=t.__ownerID||new m,i=t._origin,o=t._capacity,u=i+e,s=void 0===r?o:r<0?o+r:i+r;if(u===i&&s===o)return t;if(s<=u)return t.clear();for(var a=t._level,c=t._root,f=0;u+f<0;)c=new ar(c&&c.array.length?[void 0,c]:[],n),f+=1<<(a+=d);f&&(u+=f,i+=f,s+=f,o+=f);for(var h=gr(o),_=gr(s);1<>>l&g,p=p.array[v]=vr(p.array[v],n);p.array[h>>>d&g]=e}if(s>>a&g;if(y!=_>>>a&g)break;y&&(f+=(1<>>d<>>-15,461845907),e=pt(e<<13|e>>>-13,5),e=pt((e=(e+3864292196|0)^t)^e>>>16,2246822507),e=lt((e=pt(e^e>>>13,3266489909))^e>>>16)}(t.__iterate(r?e?function(t,e){n=31*n+sn(yt(t),yt(e))|0}:function(t,e){n=n+sn(yt(t),yt(e))|0}:e?function(t){n=31*n+yt(t)|0}:function(t){n=n+yt(t)|0}),n)}(this))}});var Xr=I.prototype;Xr[o]=!0,Xr[B]=Xr.values,Xr.toJSON=Xr.toArray,Xr.__toStringMapper=oe,Xr.inspect=Xr.toSource=function(){return""+this},Xr.chain=Xr.flatMap,Xr.contains=Xr.includes,Ur(O,{flip:function(){return Vt(this,Ut(this))},mapEntries:function(r,n){var i=this,o=0;return Vt(this,this.toSeq().map(function(t,e){return r.call(n,[e,t],o++,i)}).fromEntrySeq())},mapKeys:function(r,n){var i=this;return Vt(this,this.toSeq().flip().map(function(t,e){return r.call(n,t,e,i)}).flip())}});var Fr=O.prototype;Fr[s]=!0,Fr[B]=Xr.entries,Fr.toJSON=Qr,Fr.__toStringMapper=function(t,e){return oe(e)+": "+oe(t)},Ur(E,{toKeyedSeq:function(){return new xt(this,!1)},filter:function(t,e){return Vt(this,Ct(this,t,e,!1))},findIndex:function(t,e){e=this.findEntry(t,e);return e?e[0]:-1},indexOf:function(t){t=this.keyOf(t);return void 0===t?-1:t},lastIndexOf:function(t){t=this.lastKeyOf(t);return void 0===t?-1:t},reverse:function(){return Vt(this,Tt(this,!1))},slice:function(t,e){return Vt(this,Lt(this,t,e,!1))},splice:function(t,e){var r=arguments.length;if(e=Math.max(e||0,0),0===r||2===r&&!e)return this;t=y(t,t<0?this.count():this.size);var n=this.slice(0,t);return Vt(this,1===r?n:n.concat(Zt(arguments,2),this.slice(t+e)))},findLastIndex:function(t,e){e=this.findLastEntry(t,e);return e?e[0]:-1},first:function(t){return this.get(0,t)},flatten:function(t){return Vt(this,Wt(this,t,!1))},get:function(r,t){return(r=h(this,r))<0||this.size===1/0||void 0!==this.size&&this.size>2)|0}Zr.has=Xr.includes,Zr.contains=Zr.includes,Zr.keys=Zr.values,Ur(G,Fr),Ur(Z,Gr),Ur($,Zr);var an=function(t){function e(r){return null==r?_n():kr(r)?r:_n().withMutations(function(e){var t=q(r);te(t.size),t.forEach(function(t){return e.add(t)})})}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).of=function(){return this(arguments)}, +e.fromKeys=function(t){return this(O(t).keySeq())},e.prototype.toString=function(){return this.__toString("OrderedSet {","}")},e}(Tr);an.isOrderedSet=kr;var cn,fn=an.prototype;function hn(t,e){var r=Object.create(fn);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function _n(){return cn=cn||hn(zr())}fn[k]=!0,fn.zip=Gr.zip,fn.zipWith=Gr.zipWith,fn.zipAll=Gr.zipAll,fn.__empty=_n,fn.__make=hn;Zr=function(u,s){var a;!function(t){if(x(t))throw Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(A(t))throw Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(null===t||"object"!=typeof t)throw Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}(u);var c=function(t){var n=this;if(t instanceof c)return t;if(!(this instanceof c))return new c(t);if(!a){a=!0;var e=Object.keys(u),r=f._indices={};f._name=s,f._keys=e,f._defaultValues=u;for(var i=0;i Date: Mon, 6 Sep 2021 07:18:51 +0000 Subject: [PATCH 166/242] deploy: 678b8026a586d1e81a0b58c97b61ffb9eed680a9 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3881fe4ce2..678257f027 100644 --- a/README.md +++ b/README.md @@ -148,7 +148,7 @@ via relative path to the type definitions at the top of your file. ```js /// -import Immutable from require('immutable'); +import Immutable from 'immutable'; var map1: Immutable.Map; map1 = Immutable.Map({ a: 1, b: 2, c: 3 }); var map2 = map1.set('b', 50); From 26ce703c67707249a79814d50aabf1a3883eb6ac Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 13 Sep 2021 20:40:08 +0000 Subject: [PATCH 167/242] deploy: ad90f2e3957c802350ca8127913375978859688f --- dist/immutable.d.ts | 46 +++++++++++++++++++++++++++++++------------ dist/immutable.es.js | 20 ++++++++++++++++++- dist/immutable.js | 20 ++++++++++++++++++- dist/immutable.min.js | 38 +++++++++++++++++------------------ 4 files changed, 90 insertions(+), 34 deletions(-) diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index 456f2bc81c..187e3d41b5 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -1015,12 +1015,18 @@ declare namespace Immutable { ): this; /** - * Like `merge()`, but when two Collections conflict, it merges them as well, - * recursing deeply through the nested data. - * - * Note: Values provided to `merge` are shallowly converted before being - * merged. No nested values are altered unless they will also be merged at - * a deeper level. + * Like `merge()`, but when two compatible collections are encountered with + * the same key, it merges them as well, recursing deeply through the nested + * data. Two collections are considered to be compatible (and thus will be + * merged together) if they both fall into one of three categories: keyed + * (e.g., `Map`s, `Record`s, and objects), indexed (e.g., `List`s and + * arrays), or set-like (e.g., `Set`s). If they fall into separate + * categories, `mergeDeep` will replace the existing collection with the + * collection being merged in. This behavior can be customized by using + * `mergeDeepWith()`. + * + * Note: Indexed and set-like collections are merged using + * `concat()`/`union()` and therefore do not recurse. * * * ```js @@ -1042,8 +1048,11 @@ declare namespace Immutable { ): this; /** - * Like `mergeDeep()`, but when two non-Collections conflict, it uses the - * `merger` function to determine the resulting value. + * Like `mergeDeep()`, but when two non-collections or incompatible + * collections are encountered at the same key, it uses the `merger` + * function to determine the resulting value. Collections are considered + * incompatible if they fall into separate categories between keyed, + * indexed, and set-like. * * * ```js @@ -5534,8 +5543,18 @@ declare namespace Immutable { ): C; /** - * Returns a copy of the collection with the remaining collections merged in - * deeply (recursively). + * Like `merge()`, but when two compatible collections are encountered with + * the same key, it merges them as well, recursing deeply through the nested + * data. Two collections are considered to be compatible (and thus will be + * merged together) if they both fall into one of three categories: keyed + * (e.g., `Map`s, `Record`s, and objects), indexed (e.g., `List`s and + * arrays), or set-like (e.g., `Set`s). If they fall into separate + * categories, `mergeDeep` will replace the existing collection with the + * collection being merged in. This behavior can be customized by using + * `mergeDeepWith()`. + * + * Note: Indexed and set-like collections are merged using + * `concat()`/`union()` and therefore do not recurse. * * A functional alternative to `collection.mergeDeep()` which will also work * with plain Objects and Arrays. @@ -5558,9 +5577,10 @@ declare namespace Immutable { ): C; /** - * Returns a copy of the collection with the remaining collections merged in - * deeply (recursively), calling the `merger` function whenever an existing - * value is encountered. + * Like `mergeDeep()`, but when two non-collections or incompatible + * collections are encountered at the same key, it uses the `merger` function + * to determine the resulting value. Collections are considered incompatible + * if they fall into separate categories between keyed, indexed, and set-like. * * A functional alternative to `collection.mergeDeepWith()` which will also * work with plain Objects and Arrays. diff --git a/dist/immutable.es.js b/dist/immutable.es.js index dabedd01aa..65fa26f4f5 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -2286,7 +2286,9 @@ function mergeWithSources(collection, sources, merger) { function deepMergerWith(merger) { function deepMerger(oldValue, newValue, key) { - return isDataStructure(oldValue) && isDataStructure(newValue) + return isDataStructure(oldValue) && + isDataStructure(newValue) && + areMergeable(oldValue, newValue) ? mergeWithSources(oldValue, [newValue], deepMerger) : merger ? merger(oldValue, newValue, key) @@ -2295,6 +2297,22 @@ function deepMergerWith(merger) { return deepMerger; } +/** + * It's unclear what the desired behavior is for merging two collections that + * fall into separate categories between keyed, indexed, or set-like, so we only + * consider them mergeable if they fall into the same category. + */ +function areMergeable(oldDataStructure, newDataStructure) { + var oldSeq = Seq(oldDataStructure); + var newSeq = Seq(newDataStructure); + // This logic assumes that a sequence can only fall into one of the three + // categories mentioned above (since there's no `isSetLike()` method). + return ( + isIndexed(oldSeq) === isIndexed(newSeq) && + isKeyed(oldSeq) === isKeyed(newSeq) + ); +} + function mergeDeep() { var iters = [], len = arguments.length; while ( len-- ) iters[ len ] = arguments[ len ]; diff --git a/dist/immutable.js b/dist/immutable.js index 9603347302..9727b9a91d 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -2292,7 +2292,9 @@ function deepMergerWith(merger) { function deepMerger(oldValue, newValue, key) { - return isDataStructure(oldValue) && isDataStructure(newValue) + return isDataStructure(oldValue) && + isDataStructure(newValue) && + areMergeable(oldValue, newValue) ? mergeWithSources(oldValue, [newValue], deepMerger) : merger ? merger(oldValue, newValue, key) @@ -2301,6 +2303,22 @@ return deepMerger; } + /** + * It's unclear what the desired behavior is for merging two collections that + * fall into separate categories between keyed, indexed, or set-like, so we only + * consider them mergeable if they fall into the same category. + */ + function areMergeable(oldDataStructure, newDataStructure) { + var oldSeq = Seq(oldDataStructure); + var newSeq = Seq(newDataStructure); + // This logic assumes that a sequence can only fall into one of the three + // categories mentioned above (since there's no `isSetLike()` method). + return ( + isIndexed(oldSeq) === isIndexed(newSeq) && + isKeyed(oldSeq) === isKeyed(newSeq) + ); + } + function mergeDeep() { var iters = [], len = arguments.length; while ( len-- ) iters[ len ] = arguments[ len ]; diff --git a/dist/immutable.min.js b/dist/immutable.min.js index ed9baa6652..3933523d9b 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -31,25 +31,25 @@ t.has=function(t){return i.includes(t)},t.includes=function(t){return i.has(t)}, function Lt(s,t,e,a){var r=s.size;if(p(t,e,r))return s;var c=y(t,r),r=w(e,r);if(c!=c||r!=r)return Lt(s.toSeq().cacheResult(),t,e,a);var f,r=r-c;r==r&&(f=r<0?0:r);r=Xt(s);return r.size=0===f?f:s.size&&f||void 0,!a&&j(s)&&0<=f&&(r.get=function(t,e){return 0<=(t=h(this,t))&&tf)return N();var t=r.next();return a||e===K||t.done?t:P(e,i-1,e===U?void 0:t.value[1],t)})},r}function Bt(e,c,f,h){var t=Xt(e);return t.__iterateUncached=function(n,t){var i=this;if(t)return this.cacheResult().__iterate(n,t);var o=!0,u=0;return e.__iterate(function(t,e,r){if(!(o=o&&c.call(f,t,e,r)))return u++,n(t,h?e:u-1,i)}),u},t.__iteratorUncached=function(i,t){var o=this;if(t)return this.cacheResult().__iterator(i,t);var u=e.__iterator(T,t),s=!0,a=0;return new W(function(){var t;do{if((t=u.next()).done)return h||i===K?t:P(i,a++,i===U?void 0:t.value[1],t);var e=t.value,r=e[0],n=e[1];s=s&&c.call(f,n,r,o)}while(s);return i===T?t:P(i,r,n,t)})},t}function Wt(t,s,a){var c=Xt(t);return c.__iterateUncached=function(i,e){if(e)return this.cacheResult().__iterate(i,e);var o=0,u=!1;return function r(t,n){t.__iterate(function(t,e){return(!s||n>>t)&g),o=this.bitmap;return 0==(o&i)?n:this.nodes[$e(o&i-1)].get(t+d,e,r,n)},Le.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=yt(n));var s=(0===e?r:r>>>e)&g,a=1<>>=1)u[s]=1&r?e[o++]:void 0;return u[n]=i,new Be(t,o+1,u)}(t,_,c,s,u);if(f&&!u&&2===_.length&&Ge(_[1^h]))return _[1^h];if(f&&u&&1===_.length&&Ge(u))return u;s=t&&t===this.ownerID,a=f?u?c:c^a:c|a,u=f?u?tr(_,h,u,s):function(t,e,r){var n=t.length-1;if(r&&e===n)return t.pop(),t;for(var i=Array(n),o=0,u=0;u>>t)&g];return i?i.get(t+d,e,r,n):n},Be.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=yt(n));var s=(0===e?r:r>>>e)&g,a=this.nodes,c=a[s];if(i===v&&!c)return this;o=Fe(c,t,e+d,r,n,i,o,u);if(o===c)return this;u=this.count;if(c){if(!o&&--u>>r)&g,u=(0===r?n:n>>>r)&g,t=o==u?[Ze(t,e,r+d,n,i)]:(i=new Pe(e,n,i),o>1&1431655765))+(t>>2&858993459))+(t>>4)&252645135,t+=t>>8,127&(t+=t>>16)}function tr(t,e,r,n){t=n?t:Zt(t);return t[e]=r,t}var er=l/4,rr=l/2,nr=l/4,ir="@@__IMMUTABLE_LIST__@@";function or(t){return!(!t||!t[ir])}var ur=function(o){function t(t){var e=pr();if(null==t)return e;if(or(t))return t;var n=o(t),i=n.size;return 0===i?e:(te(i),0=gr(t._capacity)?n=lr(n,t.__ownerID,0,e,r,o):i=lr(i,t.__ownerID,t._level,e,r,o);if(!o.value)return t;if(t.__ownerID)return t._root=i,t._tail=n,t.__hash=void 0,t.__altered=!0,t;return _r(t._origin,t._capacity,t._level,i,n)}(this,t,e)},t.prototype.remove=function(t){return this.has(t)?0===t?this.shift():t===this.size-1?this.pop():this.splice(t,1):this},t.prototype.insert=function(t,e){return this.splice(t,0,e)},t.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=this._origin=this._capacity=0,this._level=d,this._root=this._tail=this.__hash=void 0,this.__altered=!0,this):pr()},t.prototype.push=function(){var r=arguments,n=this.size;return this.withMutations(function(t){dr(t,0,n+r.length);for(var e=0;e>>e&g;if(this.array.length<=n)return new ar([],t);var i=0==n;if(0>>e&g;if(this.array.length<=n)return this;if(0>e,u=1+(c-r>>e);l>>r&g,a=t&&s=gr(t._capacity))return t._tail;if(e<1<>>n&g],n-=d;return r}}function dr(t,e,r){void 0!==e&&(e|=0),void 0!==r&&(r|=0);var n=t.__ownerID||new m,i=t._origin,o=t._capacity,u=i+e,s=void 0===r?o:r<0?o+r:i+r;if(u===i&&s===o)return t;if(s<=u)return t.clear();for(var a=t._level,c=t._root,f=0;u+f<0;)c=new ar(c&&c.array.length?[void 0,c]:[],n),f+=1<<(a+=d);f&&(u+=f,i+=f,s+=f,o+=f);for(var h=gr(o),_=gr(s);1<>>l&g,p=p.array[v]=vr(p.array[v],n);p.array[h>>>d&g]=e}if(s>>a&g;if(y!=_>>>a&g)break;y&&(f+=(1<>>d<>>-15,461845907),e=pt(e<<13|e>>>-13,5),e=pt((e=(e+3864292196|0)^t)^e>>>16,2246822507),e=lt((e=pt(e^e>>>13,3266489909))^e>>>16)}(t.__iterate(r?e?function(t,e){n=31*n+sn(yt(t),yt(e))|0}:function(t,e){n=n+sn(yt(t),yt(e))|0}:e?function(t){n=31*n+yt(t)|0}:function(t){n=n+yt(t)|0}),n)}(this))}});var Xr=I.prototype;Xr[o]=!0,Xr[B]=Xr.values,Xr.toJSON=Xr.toArray,Xr.__toStringMapper=oe,Xr.inspect=Xr.toSource=function(){return""+this},Xr.chain=Xr.flatMap,Xr.contains=Xr.includes,Ur(O,{flip:function(){return Vt(this,Ut(this))},mapEntries:function(r,n){var i=this,o=0;return Vt(this,this.toSeq().map(function(t,e){return r.call(n,[e,t],o++,i)}).fromEntrySeq())},mapKeys:function(r,n){var i=this;return Vt(this,this.toSeq().flip().map(function(t,e){return r.call(n,t,e,i)}).flip())}});var Fr=O.prototype;Fr[s]=!0,Fr[B]=Xr.entries,Fr.toJSON=Qr,Fr.__toStringMapper=function(t,e){return oe(e)+": "+oe(t)},Ur(E,{toKeyedSeq:function(){return new xt(this,!1)},filter:function(t,e){return Vt(this,Ct(this,t,e,!1))},findIndex:function(t,e){e=this.findEntry(t,e);return e?e[0]:-1},indexOf:function(t){t=this.keyOf(t);return void 0===t?-1:t},lastIndexOf:function(t){t=this.lastKeyOf(t);return void 0===t?-1:t},reverse:function(){return Vt(this,Tt(this,!1))},slice:function(t,e){return Vt(this,Lt(this,t,e,!1))},splice:function(t,e){var r=arguments.length;if(e=Math.max(e||0,0),0===r||2===r&&!e)return this;t=y(t,t<0?this.count():this.size);var n=this.slice(0,t);return Vt(this,1===r?n:n.concat(Zt(arguments,2),this.slice(t+e)))},findLastIndex:function(t,e){e=this.findLastEntry(t,e);return e?e[0]:-1},first:function(t){return this.get(0,t)},flatten:function(t){return Vt(this,Wt(this,t,!1))},get:function(r,t){return(r=h(this,r))<0||this.size===1/0||void 0!==this.size&&this.size>2)|0}Zr.has=Xr.includes,Zr.contains=Zr.includes,Zr.keys=Zr.values,Ur(G,Fr),Ur(Z,Gr),Ur($,Zr);var an=function(t){function e(r){return null==r?_n():kr(r)?r:_n().withMutations(function(e){var t=q(r);te(t.size),t.forEach(function(t){return e.add(t)})})}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).of=function(){return this(arguments)}, -e.fromKeys=function(t){return this(O(t).keySeq())},e.prototype.toString=function(){return this.__toString("OrderedSet {","}")},e}(Tr);an.isOrderedSet=kr;var cn,fn=an.prototype;function hn(t,e){var r=Object.create(fn);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function _n(){return cn=cn||hn(zr())}fn[k]=!0,fn.zip=Gr.zip,fn.zipWith=Gr.zipWith,fn.zipAll=Gr.zipAll,fn.__empty=_n,fn.__make=hn;Zr=function(u,s){var a;!function(t){if(x(t))throw Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(A(t))throw Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(null===t||"object"!=typeof t)throw Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}(u);var c=function(t){var n=this;if(t instanceof c)return t;if(!(this instanceof c))return new c(t);if(!a){a=!0;var e=Object.keys(u),r=f._indices={};f._name=s,f._keys=e,f._defaultValues=u;for(var i=0;i>>t)&g),o=this.bitmap;return 0==(o&i)?n:this.nodes[$e(o&i-1)].get(t+d,e,r,n)},Le.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=yt(n));var s=(0===e?r:r>>>e)&g,a=1<>>=1)u[s]=1&r?e[o++]:void 0;return u[n]=i,new Be(t,o+1,u)}(t,_,c,s,u);if(f&&!u&&2===_.length&&Ge(_[1^h]))return _[1^h];if(f&&u&&1===_.length&&Ge(u))return u;s=t&&t===this.ownerID,a=f?u?c:c^a:c|a,u=f?u?tr(_,h,u,s):function(t,e,r){var n=t.length-1;if(r&&e===n)return t.pop(),t;for(var i=Array(n),o=0,u=0;u>>t)&g];return i?i.get(t+d,e,r,n):n},Be.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=yt(n));var s=(0===e?r:r>>>e)&g,a=this.nodes,c=a[s];if(i===v&&!c)return this;o=Fe(c,t,e+d,r,n,i,o,u);if(o===c)return this;u=this.count;if(c){if(!o&&--u>>r)&g,u=(0===r?n:n>>>r)&g,t=o==u?[Ze(t,e,r+d,n,i)]:(i=new Pe(e,n,i),o>1&1431655765))+(t>>2&858993459))+(t>>4)&252645135,t+=t>>8,127&(t+=t>>16)}function tr(t,e,r,n){t=n?t:Zt(t);return t[e]=r,t}var er=l/4,rr=l/2,nr=l/4,ir="@@__IMMUTABLE_LIST__@@";function or(t){return!(!t||!t[ir])}var ur=function(o){function t(t){var e=pr();if(null==t)return e;if(or(t))return t;var n=o(t),i=n.size;return 0===i?e:(te(i),0=gr(t._capacity)?n=lr(n,t.__ownerID,0,e,r,o):i=lr(i,t.__ownerID,t._level,e,r,o);if(!o.value)return t;if(t.__ownerID)return t._root=i,t._tail=n,t.__hash=void 0,t.__altered=!0,t;return _r(t._origin,t._capacity,t._level,i,n)}(this,t,e)},t.prototype.remove=function(t){return this.has(t)?0===t?this.shift():t===this.size-1?this.pop():this.splice(t,1):this},t.prototype.insert=function(t,e){return this.splice(t,0,e)},t.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=this._origin=this._capacity=0,this._level=d,this._root=this._tail=this.__hash=void 0,this.__altered=!0,this):pr()},t.prototype.push=function(){var r=arguments,n=this.size;return this.withMutations(function(t){dr(t,0,n+r.length);for(var e=0;e>>e&g;if(this.array.length<=n)return new ar([],t);var i=0==n;if(0>>e&g;if(this.array.length<=n)return this;if(0>e,u=1+(c-r>>e);l>>r&g,a=t&&s=gr(t._capacity))return t._tail;if(e<1<>>n&g],n-=d;return r}}function dr(t,e,r){void 0!==e&&(e|=0),void 0!==r&&(r|=0);var n=t.__ownerID||new m,i=t._origin,o=t._capacity,u=i+e,s=void 0===r?o:r<0?o+r:i+r;if(u===i&&s===o)return t;if(s<=u)return t.clear();for(var a=t._level,c=t._root,f=0;u+f<0;)c=new ar(c&&c.array.length?[void 0,c]:[],n),f+=1<<(a+=d);f&&(u+=f,i+=f,s+=f,o+=f);for(var h=gr(o),_=gr(s);1<>>l&g,p=p.array[v]=vr(p.array[v],n);p.array[h>>>d&g]=e}if(s>>a&g;if(y!=_>>>a&g)break;y&&(f+=(1<>>d<>>-15,461845907),e=pt(e<<13|e>>>-13,5),e=pt((e=(e+3864292196|0)^t)^e>>>16,2246822507),e=lt((e=pt(e^e>>>13,3266489909))^e>>>16)}(t.__iterate(r?e?function(t,e){n=31*n+sn(yt(t),yt(e))|0}:function(t,e){n=n+sn(yt(t),yt(e))|0}:e?function(t){n=31*n+yt(t)|0}:function(t){n=n+yt(t)|0}),n)}(this))}});var Xr=I.prototype;Xr[o]=!0,Xr[B]=Xr.values,Xr.toJSON=Xr.toArray,Xr.__toStringMapper=oe,Xr.inspect=Xr.toSource=function(){return""+this},Xr.chain=Xr.flatMap,Xr.contains=Xr.includes,Ur(O,{flip:function(){return Vt(this,Ut(this))},mapEntries:function(r,n){var i=this,o=0;return Vt(this,this.toSeq().map(function(t,e){return r.call(n,[e,t],o++,i)}).fromEntrySeq())},mapKeys:function(r,n){var i=this;return Vt(this,this.toSeq().flip().map(function(t,e){return r.call(n,t,e,i)}).flip())}});var Fr=O.prototype;Fr[s]=!0,Fr[B]=Xr.entries,Fr.toJSON=Qr,Fr.__toStringMapper=function(t,e){return oe(e)+": "+oe(t)},Ur(E,{toKeyedSeq:function(){return new xt(this,!1)},filter:function(t,e){return Vt(this,Ct(this,t,e,!1))},findIndex:function(t,e){e=this.findEntry(t,e);return e?e[0]:-1},indexOf:function(t){t=this.keyOf(t);return void 0===t?-1:t},lastIndexOf:function(t){t=this.lastKeyOf(t);return void 0===t?-1:t},reverse:function(){return Vt(this,Tt(this,!1))},slice:function(t,e){return Vt(this,Lt(this,t,e,!1))},splice:function(t,e){var r=arguments.length;if(e=Math.max(e||0,0),0===r||2===r&&!e)return this;t=y(t,t<0?this.count():this.size);var n=this.slice(0,t);return Vt(this,1===r?n:n.concat(Zt(arguments,2),this.slice(t+e)))},findLastIndex:function(t,e){e=this.findLastEntry(t,e);return e?e[0]:-1},first:function(t){return this.get(0,t)},flatten:function(t){return Vt(this,Wt(this,t,!1))},get:function(r,t){return(r=h(this,r))<0||this.size===1/0||void 0!==this.size&&this.size>2)|0}Zr.has=Xr.includes,Zr.contains=Zr.includes,Zr.keys=Zr.values,Ur(G,Fr),Ur(Z,Gr),Ur($,Zr);var an=function(t){function e(r){return null==r?_n():kr(r)?r:_n().withMutations(function(e){var t=q(r);te(t.size),t.forEach(function(t){return e.add(t)})})}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).of=function(){return this( +arguments)},e.fromKeys=function(t){return this(O(t).keySeq())},e.prototype.toString=function(){return this.__toString("OrderedSet {","}")},e}(Tr);an.isOrderedSet=kr;var cn,fn=an.prototype;function hn(t,e){var r=Object.create(fn);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function _n(){return cn=cn||hn(zr())}fn[k]=!0,fn.zip=Gr.zip,fn.zipWith=Gr.zipWith,fn.zipAll=Gr.zipAll,fn.__empty=_n,fn.__make=hn;Zr=function(u,s){var a;!function(t){if(x(t))throw Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(A(t))throw Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(null===t||"object"!=typeof t)throw Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}(u);var c=function(t){var n=this;if(t instanceof c)return t;if(!(this instanceof c))return new c(t);if(!a){a=!0;var e=Object.keys(u),r=f._indices={};f._name=s,f._keys=e,f._defaultValues=u;for(var i=0;i Date: Thu, 16 Sep 2021 22:57:35 +0000 Subject: [PATCH 168/242] deploy: ec328d6b7b130ee884cad7c218e26c47becfe073 --- bower.json | 2 +- dist/immutable.es.js | 2 +- dist/immutable.js | 2 +- dist/immutable.min.js | 2 +- package.json | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/bower.json b/bower.json index ae9ce141d6..21ac9066ac 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "immutable", - "version": "4.0.0-rc.14", + "version": "4.0.0-rc.15", "description": "Immutable Data Collections", "license": "MIT", "homepage": "https://immutable-js.com", diff --git a/dist/immutable.es.js b/dist/immutable.es.js index 65fa26f4f5..5759212ab4 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -5863,7 +5863,7 @@ function defaultConverter(k, v) { return isIndexed(v) ? v.toList() : isKeyed(v) ? v.toMap() : v.toSet(); } -var version = "4.0.0-rc.14"; +var version = "4.0.0-rc.15"; var Immutable = { version: version, diff --git a/dist/immutable.js b/dist/immutable.js index 9727b9a91d..fdd87686b0 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -5869,7 +5869,7 @@ return isIndexed(v) ? v.toList() : isKeyed(v) ? v.toMap() : v.toSet(); } - var version = "4.0.0-rc.14"; + var version = "4.0.0-rc.15"; var Immutable = { version: version, diff --git a/dist/immutable.min.js b/dist/immutable.min.js index 3933523d9b..bd4dc1e2dd 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -51,5 +51,5 @@ function(t,e){return _t(e,r)},void 0,t)},getIn:Vr,groupBy:function(t,e){return f function(t,e){return e===r},void 0,t)},has:function(t){return 0<=(t=h(this,t))&&(void 0!==this.size?this.size===1/0||t>2)|0}Zr.has=Xr.includes,Zr.contains=Zr.includes,Zr.keys=Zr.values,Ur(G,Fr),Ur(Z,Gr),Ur($,Zr);var an=function(t){function e(r){return null==r?_n():kr(r)?r:_n().withMutations(function(e){var t=q(r);te(t.size),t.forEach(function(t){return e.add(t)})})}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).of=function(){return this( arguments)},e.fromKeys=function(t){return this(O(t).keySeq())},e.prototype.toString=function(){return this.__toString("OrderedSet {","}")},e}(Tr);an.isOrderedSet=kr;var cn,fn=an.prototype;function hn(t,e){var r=Object.create(fn);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function _n(){return cn=cn||hn(zr())}fn[k]=!0,fn.zip=Gr.zip,fn.zipWith=Gr.zipWith,fn.zipAll=Gr.zipAll,fn.__empty=_n,fn.__make=hn;Zr=function(u,s){var a;!function(t){if(x(t))throw Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(A(t))throw Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(null===t||"object"!=typeof t)throw Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}(u);var c=function(t){var n=this;if(t instanceof c)return t;if(!(this instanceof c))return new c(t);if(!a){a=!0;var e=Object.keys(u),r=f._indices={};f._name=s,f._keys=e,f._defaultValues=u;for(var i=0;i Date: Thu, 23 Sep 2021 23:56:34 +0000 Subject: [PATCH 169/242] deploy: d2522bdc7464cb036981aca09f21c4f4db3ee79c --- dist/immutable.d.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index 187e3d41b5..6365280367 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -2882,7 +2882,9 @@ declare namespace Immutable { * Note: `Seq.Indexed` is a conversion function and not a class, and does * not use the `new` keyword during construction. */ - function Indexed(collection: Iterable | ArrayLike): Seq.Indexed; + function Indexed( + collection?: Iterable | ArrayLike + ): Seq.Indexed; interface Indexed extends Seq, Collection.Indexed { /** @@ -3044,7 +3046,7 @@ declare namespace Immutable { * Note: `Seq.Set` is a conversion function and not a class, and does not * use the `new` keyword during construction. */ - function Set(collection: Iterable | ArrayLike): Seq.Set; + function Set(collection?: Iterable | ArrayLike): Seq.Set; interface Set extends Seq, Collection.Set { /** @@ -3148,7 +3150,7 @@ declare namespace Immutable { collection: Collection.Indexed | Iterable | ArrayLike ): Seq.Indexed; function Seq(obj: { [key: string]: V }): Seq.Keyed; - function Seq(): Seq; + function Seq(): Seq; interface Seq extends Collection { /** @@ -3325,7 +3327,7 @@ declare namespace Immutable { * Note: `Collection.Keyed` is a conversion function and not a class, and * does not use the `new` keyword during construction. */ - function Keyed(collection: Iterable<[K, V]>): Collection.Keyed; + function Keyed(collection?: Iterable<[K, V]>): Collection.Keyed; function Keyed(obj: { [key: string]: V }): Collection.Keyed; interface Keyed extends Collection { @@ -3495,7 +3497,7 @@ declare namespace Immutable { * does not use the `new` keyword during construction. */ function Indexed( - collection: Iterable | ArrayLike + collection?: Iterable | ArrayLike ): Collection.Indexed; interface Indexed extends Collection { @@ -3793,7 +3795,7 @@ declare namespace Immutable { * Note: `Collection.Set` is a factory function and not a class, and does * not use the `new` keyword during construction. */ - function Set(collection: Iterable | ArrayLike): Collection.Set; + function Set(collection?: Iterable | ArrayLike): Collection.Set; interface Set extends Collection { /** @@ -3900,6 +3902,7 @@ declare namespace Immutable { function Collection(obj: { [key: string]: V; }): Collection.Keyed; + function Collection(): Collection; interface Collection extends ValueObject { // Value equality From 3a0fc8a12a4d60096f25495871bc0926fd34e652 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 7 Oct 2021 23:49:09 +0000 Subject: [PATCH 170/242] deploy: 2ddb5c235f543464010569f9fb8249974fd56314 --- bower.json | 2 +- dist/immutable.es.js | 2 +- dist/immutable.js | 2 +- dist/immutable.min.js | 8 ++++---- package.json | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/bower.json b/bower.json index 21ac9066ac..1a854a6e03 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "immutable", - "version": "4.0.0-rc.15", + "version": "4.0.0", "description": "Immutable Data Collections", "license": "MIT", "homepage": "https://immutable-js.com", diff --git a/dist/immutable.es.js b/dist/immutable.es.js index 5759212ab4..3855f03477 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -5863,7 +5863,7 @@ function defaultConverter(k, v) { return isIndexed(v) ? v.toList() : isKeyed(v) ? v.toMap() : v.toSet(); } -var version = "4.0.0-rc.15"; +var version = "4.0.0"; var Immutable = { version: version, diff --git a/dist/immutable.js b/dist/immutable.js index fdd87686b0..0a8d65299a 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -5869,7 +5869,7 @@ return isIndexed(v) ? v.toList() : isKeyed(v) ? v.toMap() : v.toSet(); } - var version = "4.0.0-rc.15"; + var version = "4.0.0"; var Immutable = { version: version, diff --git a/dist/immutable.min.js b/dist/immutable.min.js index bd4dc1e2dd..30212f84f0 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -49,7 +49,7 @@ function Wr(t,e){var r=Object.create(Lr);return r.size=t?t.size:0,r._map=t,r.__o function(t,e){return _t(e,r)},void 0,t)},getIn:Vr,groupBy:function(t,e){return function(n,t,i){var o=a(n),u=(R(n)?wr:Ke)().asMutable();n.__iterate(function(e,r){u.update(t.call(i,e,r,n),function(t){return(t=t||[]).push(o?[r,e]:e),t})});var e=Qt(n);return u.map(function(t){return Vt(n,e(t))}).asImmutable()}(this,t,e)},has:function(t){return this.get(t,v)!==v},hasIn:function(t){return Yr(this,t)},isSubset:function(e){return e="function"==typeof e.includes?e:I(e),this.every(function(t){return e.includes(t)})},isSuperset:function(t){return(t="function"==typeof t.isSubset?t:I(t)).isSubset(this)},keyOf:function(e){return this.findKey(function(t){return _t(t,e)})},keySeq:function(){return this.toSeq().map(tn).toIndexedSeq()},last:function(t){return this.toSeq().reverse().first(t)},lastKeyOf:function(t){return this.toKeyedSeq().reverse().keyOf(t)},max:function(t){return Nt(this,t)},maxBy:function(t,e){return Nt(this,e,t)},min:function(t){return Nt(this,t?nn(t):un)},minBy:function(t,e){return Nt(this,e?nn(e):un,t)},rest:function(){return this.slice(1)},skip:function(t){return 0===t?this:this.slice(Math.max(0,t))},skipLast:function(t){return 0===t?this:this.slice(0,-Math.max(0,t))},skipWhile:function(t,e){return Vt(this,Bt(this,t,e,!0))},skipUntil:function(t,e){return this.skipWhile(rn(t),e)},sortBy:function(t,e){return Vt(this,Pt(this,e,t))},take:function(t){return this.slice(0,Math.max(0,t))},takeLast:function(t){return this.slice(-Math.max(0,t))},takeWhile:function(t,e){return Vt(this,(s=t,a=e,(e=Xt(r=this)).__iterateUncached=function(n,t){var i=this;if(t)return this.cacheResult().__iterate(n,t);var o=0;return r.__iterate(function(t,e,r){return s.call(a,t,e,r)&&++o&&n(t,e,i)}),o},e.__iteratorUncached=function(n,t){var i=this;if(t)return this.cacheResult().__iterator(n,t);var o=r.__iterator(T,t),u=!0;return new W(function(){if(!u)return N();var t=o.next();if(t.done)return t;var e=t.value,r=e[0],e=e[1];return s.call(a,e,r,i)?n===T?t:P(n,r,e,t):(u=!1,N())})},e));var r,s,a},takeUntil:function(t,e){return this.takeWhile(rn(t ),e)},update:function(t){return t(this)},valueSeq:function(){return this.toIndexedSeq()},hashCode:function(){return this.__hash||(this.__hash=function(t){if(t.size===1/0)return 0;var e=R(t),r=a(t),n=e?1:0;return function(t,e){return e=pt(e,3432918353),e=pt(e<<15|e>>>-15,461845907),e=pt(e<<13|e>>>-13,5),e=pt((e=(e+3864292196|0)^t)^e>>>16,2246822507),e=lt((e=pt(e^e>>>13,3266489909))^e>>>16)}(t.__iterate(r?e?function(t,e){n=31*n+sn(yt(t),yt(e))|0}:function(t,e){n=n+sn(yt(t),yt(e))|0}:e?function(t){n=31*n+yt(t)|0}:function(t){n=n+yt(t)|0}),n)}(this))}});var Xr=I.prototype;Xr[o]=!0,Xr[B]=Xr.values,Xr.toJSON=Xr.toArray,Xr.__toStringMapper=oe,Xr.inspect=Xr.toSource=function(){return""+this},Xr.chain=Xr.flatMap,Xr.contains=Xr.includes,Ur(O,{flip:function(){return Vt(this,Ut(this))},mapEntries:function(r,n){var i=this,o=0;return Vt(this,this.toSeq().map(function(t,e){return r.call(n,[e,t],o++,i)}).fromEntrySeq())},mapKeys:function(r,n){var i=this;return Vt(this,this.toSeq().flip().map(function(t,e){return r.call(n,t,e,i)}).flip())}});var Fr=O.prototype;Fr[s]=!0,Fr[B]=Xr.entries,Fr.toJSON=Qr,Fr.__toStringMapper=function(t,e){return oe(e)+": "+oe(t)},Ur(E,{toKeyedSeq:function(){return new xt(this,!1)},filter:function(t,e){return Vt(this,Ct(this,t,e,!1))},findIndex:function(t,e){e=this.findEntry(t,e);return e?e[0]:-1},indexOf:function(t){t=this.keyOf(t);return void 0===t?-1:t},lastIndexOf:function(t){t=this.lastKeyOf(t);return void 0===t?-1:t},reverse:function(){return Vt(this,Tt(this,!1))},slice:function(t,e){return Vt(this,Lt(this,t,e,!1))},splice:function(t,e){var r=arguments.length;if(e=Math.max(e||0,0),0===r||2===r&&!e)return this;t=y(t,t<0?this.count():this.size);var n=this.slice(0,t);return Vt(this,1===r?n:n.concat(Zt(arguments,2),this.slice(t+e)))},findLastIndex:function(t,e){e=this.findLastEntry(t,e);return e?e[0]:-1},first:function(t){return this.get(0,t)},flatten:function(t){return Vt(this,Wt(this,t,!1))},get:function(r,t){return(r=h(this,r))<0||this.size===1/0||void 0!==this.size&&this.size>2)|0}Zr.has=Xr.includes,Zr.contains=Zr.includes,Zr.keys=Zr.values,Ur(G,Fr),Ur(Z,Gr),Ur($,Zr);var an=function(t){function e(r){return null==r?_n():kr(r)?r:_n().withMutations(function(e){var t=q(r);te(t.size),t.forEach(function(t){return e.add(t)})})}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).of=function(){return this( -arguments)},e.fromKeys=function(t){return this(O(t).keySeq())},e.prototype.toString=function(){return this.__toString("OrderedSet {","}")},e}(Tr);an.isOrderedSet=kr;var cn,fn=an.prototype;function hn(t,e){var r=Object.create(fn);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function _n(){return cn=cn||hn(zr())}fn[k]=!0,fn.zip=Gr.zip,fn.zipWith=Gr.zipWith,fn.zipAll=Gr.zipAll,fn.__empty=_n,fn.__make=hn;Zr=function(u,s){var a;!function(t){if(x(t))throw Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(A(t))throw Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(null===t||"object"!=typeof t)throw Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}(u);var c=function(t){var n=this;if(t instanceof c)return t;if(!(this instanceof c))return new c(t);if(!a){a=!0;var e=Object.keys(u),r=f._indices={};f._name=s,f._keys=e,f._defaultValues=u;for(var i=0;i Date: Thu, 28 Oct 2021 09:37:30 +0000 Subject: [PATCH 171/242] deploy: 803e8a94f86a13eee33a1ca876f8d5bc81d3196a --- dist/immutable.es.js | 18 +++++++++--------- dist/immutable.js | 18 +++++++++--------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/dist/immutable.es.js b/dist/immutable.es.js index 3855f03477..e6d8f99974 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -304,7 +304,7 @@ function isArrayLike(value) { var Seq = /*@__PURE__*/(function (Collection) { function Seq(value) { - return value === null || value === undefined + return value === undefined || value === null ? emptySequence() : isImmutable(value) ? value.toSeq() @@ -372,7 +372,7 @@ var Seq = /*@__PURE__*/(function (Collection) { var KeyedSeq = /*@__PURE__*/(function (Seq) { function KeyedSeq(value) { - return value === null || value === undefined + return value === undefined || value === null ? emptySequence().toKeyedSeq() : isCollection(value) ? isKeyed(value) @@ -396,7 +396,7 @@ var KeyedSeq = /*@__PURE__*/(function (Seq) { var IndexedSeq = /*@__PURE__*/(function (Seq) { function IndexedSeq(value) { - return value === null || value === undefined + return value === undefined || value === null ? emptySequence() : isCollection(value) ? isKeyed(value) @@ -2362,7 +2362,7 @@ function wasAltered() { var Map = /*@__PURE__*/(function (KeyedCollection) { function Map(value) { - return value === null || value === undefined + return value === undefined || value === null ? emptyMap() : isMap(value) && !isOrdered(value) ? value @@ -3153,7 +3153,7 @@ function isList(maybeList) { var List = /*@__PURE__*/(function (IndexedCollection) { function List(value) { var empty = emptyList(); - if (value === null || value === undefined) { + if (value === undefined || value === null) { return empty; } if (isList(value)) { @@ -3803,7 +3803,7 @@ function getTailOffset(size) { var OrderedMap = /*@__PURE__*/(function (Map) { function OrderedMap(value) { - return value === null || value === undefined + return value === undefined || value === null ? emptyOrderedMap() : isOrderedMap(value) ? value @@ -3971,7 +3971,7 @@ function isStack(maybeStack) { var Stack = /*@__PURE__*/(function (IndexedCollection) { function Stack(value) { - return value === null || value === undefined + return value === undefined || value === null ? emptyStack() : isStack(value) ? value @@ -4305,7 +4305,7 @@ function toJS(value) { var Set = /*@__PURE__*/(function (SetCollection) { function Set(value) { - return value === null || value === undefined + return value === undefined || value === null ? emptySet() : isSet(value) && !isOrdered(value) ? value @@ -5426,7 +5426,7 @@ function hashMerge(a, b) { var OrderedSet = /*@__PURE__*/(function (Set) { function OrderedSet(value) { - return value === null || value === undefined + return value === undefined || value === null ? emptyOrderedSet() : isOrderedSet(value) ? value diff --git a/dist/immutable.js b/dist/immutable.js index 0a8d65299a..c77e7aad78 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -310,7 +310,7 @@ var Seq = /*@__PURE__*/(function (Collection) { function Seq(value) { - return value === null || value === undefined + return value === undefined || value === null ? emptySequence() : isImmutable(value) ? value.toSeq() @@ -378,7 +378,7 @@ var KeyedSeq = /*@__PURE__*/(function (Seq) { function KeyedSeq(value) { - return value === null || value === undefined + return value === undefined || value === null ? emptySequence().toKeyedSeq() : isCollection(value) ? isKeyed(value) @@ -402,7 +402,7 @@ var IndexedSeq = /*@__PURE__*/(function (Seq) { function IndexedSeq(value) { - return value === null || value === undefined + return value === undefined || value === null ? emptySequence() : isCollection(value) ? isKeyed(value) @@ -2368,7 +2368,7 @@ var Map = /*@__PURE__*/(function (KeyedCollection) { function Map(value) { - return value === null || value === undefined + return value === undefined || value === null ? emptyMap() : isMap(value) && !isOrdered(value) ? value @@ -3159,7 +3159,7 @@ var List = /*@__PURE__*/(function (IndexedCollection) { function List(value) { var empty = emptyList(); - if (value === null || value === undefined) { + if (value === undefined || value === null) { return empty; } if (isList(value)) { @@ -3809,7 +3809,7 @@ var OrderedMap = /*@__PURE__*/(function (Map) { function OrderedMap(value) { - return value === null || value === undefined + return value === undefined || value === null ? emptyOrderedMap() : isOrderedMap(value) ? value @@ -3977,7 +3977,7 @@ var Stack = /*@__PURE__*/(function (IndexedCollection) { function Stack(value) { - return value === null || value === undefined + return value === undefined || value === null ? emptyStack() : isStack(value) ? value @@ -4311,7 +4311,7 @@ var Set = /*@__PURE__*/(function (SetCollection) { function Set(value) { - return value === null || value === undefined + return value === undefined || value === null ? emptySet() : isSet(value) && !isOrdered(value) ? value @@ -5432,7 +5432,7 @@ var OrderedSet = /*@__PURE__*/(function (Set) { function OrderedSet(value) { - return value === null || value === undefined + return value === undefined || value === null ? emptyOrderedSet() : isOrderedSet(value) ? value From 718355fff82b05c65bdd61590746cc63ca8f70ca Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 12 Nov 2021 11:12:42 +0000 Subject: [PATCH 172/242] deploy: 4d0e9819e509861d0f16a64a4fc0bfdc892563f9 --- dist/immutable.d.ts | 2 +- dist/immutable.es.js | 4 ++- dist/immutable.js | 4 ++- dist/immutable.min.js | 64 +++++++++++++++++++++---------------------- 4 files changed, 39 insertions(+), 35 deletions(-) diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index 6365280367..a8c62e1d78 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -761,7 +761,7 @@ declare namespace Immutable { */ function Map(collection?: Iterable<[K, V]>): Map; function Map(obj: { [key: string]: V }): Map; - function Map(obj: { [P in K]?: V }): Map; + function Map(obj: { [P in K]?: V }): Map; interface Map extends Collection.Keyed { /** diff --git a/dist/immutable.es.js b/dist/immutable.es.js index e6d8f99974..40cab9598c 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -502,7 +502,9 @@ var ArraySeq = /*@__PURE__*/(function (IndexedSeq) { var ObjectSeq = /*@__PURE__*/(function (KeyedSeq) { function ObjectSeq(object) { - var keys = Object.keys(object); + var keys = Object.keys(object).concat( + Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(object) : [] + ); this._object = object; this._keys = keys; this.size = keys.length; diff --git a/dist/immutable.js b/dist/immutable.js index c77e7aad78..53168c03ca 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -508,7 +508,9 @@ var ObjectSeq = /*@__PURE__*/(function (KeyedSeq) { function ObjectSeq(object) { - var keys = Object.keys(object); + var keys = Object.keys(object).concat( + Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(object) : [] + ); this._object = object; this._keys = keys; this.size = keys.length; diff --git a/dist/immutable.min.js b/dist/immutable.min.js index 30212f84f0..29b3b3556a 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -21,35 +21,35 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).Immutable={})}(this,function(t){"use strict";var e="delete",d=5,l=1<>>0;if(""+r!==e||4294967295==r)return NaN;e=r}return e<0?c(t)+e:e}function r(){return!0}function p(t,e,r){return(0===t&&!i(t)||void 0!==r&&t<=-r)&&(void 0===e||void 0!==r&&r<=e)}function y(t,e){return n(t,e,0)}function w(t,e){return n(t,e,e)}function n(t,e,r){return void 0===t?r:i(t)?e===1/0?e:0|Math.max(0,e+t):void 0===e||e===t?t:0|Math.min(e,t)}function i(t){return t<0||0===t&&1/t==-1/0}var o="@@__IMMUTABLE_ITERABLE__@@";function f(t){return!(!t||!t[o])}var s="@@__IMMUTABLE_KEYED__@@";function a(t){return!(!t||!t[s])}var S="@@__IMMUTABLE_INDEXED__@@";function z(t){return!(!t||!t[S])}function b(t){return a(t)||z(t)}function I(t){return f(t)?t:F(t)}var O=function(t){function e(t){return a(t)?t:G(t)}return e.__proto__=t,(e.prototype=Object.create(t.prototype)).constructor=e}(I),E=function(t){function e(t){return z(t)?t:Z(t)}return e.__proto__=t,(e.prototype=Object.create(t.prototype)).constructor=e}(I),q=function(t){function e(t){return f(t)&&!b(t)?t:$(t)}return e.__proto__=t,(e.prototype=Object.create(t.prototype)).constructor=e}(I);I.Keyed=O,I.Indexed=E,I.Set=q;var M="@@__IMMUTABLE_SEQ__@@";function j(t){return!(!t||!t[M])}var D="@@__IMMUTABLE_RECORD__@@";function x(t){return!(!t||!t[D])}function A(t){return f(t)||x(t)}var k="@@__IMMUTABLE_ORDERED__@@";function R(t){return!(!t||!t[k])}var U=0,K=1,T=2,C="function"==typeof Symbol&&Symbol.iterator,L="@@iterator",B=C||L,W=function(t){this.next=t};function P(t,e,r,n){r=0===t?e:1===t?r:[e,r];return n?n.value=r:n={value:r,done:!1},n}function N(){return{value:void 0,done:!0}}function H(t){return Array.isArray(t -)||Y(t)}function J(t){return t&&"function"==typeof t.next}function V(t){var e=Y(t);return e&&e.call(t)}function Y(t){t=t&&(C&&t[C]||t[L]);if("function"==typeof t)return t}W.prototype.toString=function(){return"[Iterator]"},W.KEYS=U,W.VALUES=K,W.ENTRIES=T,W.prototype.inspect=W.prototype.toSource=function(){return""+this},W.prototype[B]=function(){return this};var Q=Object.prototype.hasOwnProperty;function X(t){return Array.isArray(t)||"string"==typeof t||t&&"object"==typeof t&&Number.isInteger(t.length)&&0<=t.length&&(0===t.length?1===Object.keys(t).length:t.hasOwnProperty(t.length-1))}var F=function(t){function e(t){return null==t?it():A(t)?t.toSeq():function(t){var e=st(t);if(e)return function(t){var e=Y(t);return e&&e===t.entries}(t)?e.fromEntrySeq():function(t){var e=Y(t);return e&&e===t.keys}(t)?e.toSetSeq():e;if("object"!=typeof t)throw new TypeError("Expected Array or collection object of values, or keyed object: "+t);return new et(t)}(t)}return e.__proto__=t,((e.prototype=Object.create(t.prototype)).constructor=e).prototype.toSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq {","}")},e.prototype.cacheResult=function(){return!this._cache&&this.__iterateUncached&&(this._cache=this.entrySeq().toArray(),this.size=this._cache.length),this},e.prototype.__iterate=function(t,e){var r=this._cache;if(r){for(var n=r.length,i=0;i!==n;){var o=r[e?n-++i:i++];if(!1===t(o[1],o[0],this))break}return i}return this.__iterateUncached(t,e)},e.prototype.__iterator=function(e,r){var n=this._cache;if(n){var i=n.length,o=0;return new W(function(){if(o===i)return N();var t=n[r?i-++o:o++];return P(e,t[0],t[1])})}return this.__iteratorUncached(e,r)},e}(I),G=function(t){function e(t){return null==t?it().toKeyedSeq():f(t)?a(t)?t.toSeq():t.fromEntrySeq():x(t)?t.toSeq():ot(t)}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).prototype.toKeyedSeq=function(){return this},e}(F),Z=function(t){function e(t){return null==t?it():f(t)?a(t)?t.entrySeq():t.toIndexedSeq():x(t -)?t.toSeq().entrySeq():ut(t)}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).of=function(){return e(arguments)},e.prototype.toIndexedSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq [","]")},e}(F),$=function(t){function e(t){return(f(t)&&!b(t)?t:Z(t)).toSetSeq()}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).of=function(){return e(arguments)},e.prototype.toSetSeq=function(){return this},e}(F);F.isSeq=j,F.Keyed=G,F.Set=$,F.Indexed=Z,F.prototype[M]=!0;var tt=function(t){function e(t){this._array=t,this.size=t.length}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).prototype.get=function(t,e){return this.has(t)?this._array[h(this,t)]:e},e.prototype.__iterate=function(t,e){for(var r=this._array,n=r.length,i=0;i!==n;){var o=e?n-++i:i++;if(!1===t(r[o],o,this))break}return i},e.prototype.__iterator=function(e,r){var n=this._array,i=n.length,o=0;return new W(function(){if(o===i)return N();var t=r?i-++o:o++;return P(e,t,n[t])})},e}(Z),et=function(t){function e(t){var e=Object.keys(t);this._object=t,this._keys=e,this.size=e.length}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).prototype.get=function(t,e){return void 0===e||this.has(t)?this._object[t]:e},e.prototype.has=function(t){return Q.call(this._object,t)},e.prototype.__iterate=function(t,e){for(var r=this._object,n=this._keys,i=n.length,o=0;o!==i;){var u=n[e?i-++o:o++];if(!1===t(r[u],u,this))break}return o},e.prototype.__iterator=function(e,r){var n=this._object,i=this._keys,o=i.length,u=0;return new W(function(){if(u===o)return N();var t=i[r?o-++u:u++];return P(e,t,n[t])})},e}(G);et.prototype[k]=!0;var rt,nt=function(t){function e(t){this._collection=t,this.size=t.length||t.size}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).prototype.__iterateUncached=function(t,e){if(e)return this.cacheResult().__iterate(t,e);var r,n=V(this._collection), -i=0;if(J(n))for(;!(r=n.next()).done&&!1!==t(r.value,i++,this););return i},e.prototype.__iteratorUncached=function(e,t){if(t)return this.cacheResult().__iterator(e,t);var r=V(this._collection);if(!J(r))return new W(N);var n=0;return new W(function(){var t=r.next();return t.done?t:P(e,n++,t.value)})},e}(Z);function it(){return rt=rt||new tt([])}function ot(t){var e=st(t);if(e)return e.fromEntrySeq();if("object"==typeof t)return new et(t);throw new TypeError("Expected Array or collection object of [k, v] entries, or keyed object: "+t)}function ut(t){var e=st(t);if(e)return e;throw new TypeError("Expected Array or collection object of values: "+t)}function st(t){return X(t)?new tt(t):H(t)?new nt(t):void 0}var at="@@__IMMUTABLE_MAP__@@";function ct(t){return!(!t||!t[at])}function ft(t){return ct(t)&&R(t)}function ht(t){return!(!t||"function"!=typeof t.equals||"function"!=typeof t.hashCode)}function _t(t,e){if(t===e||t!=t&&e!=e)return!0;if(!t||!e)return!1;if("function"==typeof t.valueOf&&"function"==typeof e.valueOf){if((t=t.valueOf())===(e=e.valueOf())||t!=t&&e!=e)return!0;if(!t||!e)return!1}return!!(ht(t)&&ht(e)&&t.equals(e))}var pt="function"==typeof Math.imul&&-2==Math.imul(4294967295,2)?Math.imul:function(t,e){var r=65535&(t|=0),n=65535&(e|=0);return r*n+((t>>>16)*n+r*(e>>>16)<<16>>>0)|0};function lt(t){return t>>>1&1073741824|3221225471&t}var vt=Object.prototype.valueOf;function yt(t){if(null==t)return dt(t);if("function"==typeof t.hashCode)return lt(t.hashCode(t));var e,r=(e=t).valueOf!==vt&&"function"==typeof e.valueOf?e.valueOf(e):e;if(null==r)return dt(r);switch(typeof r){case"boolean":return r?1108378657:1108378656;case"number":return function(t){if(t!=t||t===1/0)return 0;var e=0|t;e!==t&&(e^=4294967295*t);for(;4294967295f)return N();var t=r.next();return a||e===K||t.done?t:P(e,i-1,e===U?void 0:t.value[1],t)})},r}function Bt(e,c,f,h){var t=Xt(e);return t.__iterateUncached=function(n,t){var i=this;if(t)return this.cacheResult().__iterate(n,t);var o=!0,u=0;return e.__iterate(function(t,e,r){if(!(o=o&&c.call(f,t,e,r)))return u++,n(t,h?e:u-1,i)}),u},t.__iteratorUncached=function(i,t){var o=this;if(t)return this.cacheResult().__iterator(i,t);var u=e.__iterator(T,t),s=!0,a=0;return new W(function(){var t;do{if((t=u.next()).done)return h||i===K?t:P(i,a++,i===U?void 0:t.value[1],t);var e=t.value,r=e[0],n=e[1];s=s&&c.call(f,n,r,o)}while(s);return i===T?t:P(i,r,n,t)})},t}function Wt(t,s,a){var c=Xt(t);return c.__iterateUncached=function(i,e){if(e)return this.cacheResult().__iterate(i,e);var o=0,u=!1;return function r(t,n){t.__iterate(function(t,e){return(!s||n>>t)&g),o=this.bitmap;return 0==(o&i)?n:this.nodes[$e(o&i-1)].get(t+d,e,r,n)},Le.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=yt(n));var s=(0===e?r:r>>>e)&g,a=1<>>=1)u[s]=1&r?e[o++]:void 0;return u[n]=i,new Be(t,o+1,u)}(t,_,c,s,u);if(f&&!u&&2===_.length&&Ge(_[1^h]))return _[1^h];if(f&&u&&1===_.length&&Ge(u))return u;s=t&&t===this.ownerID,a=f?u?c:c^a:c|a,u=f?u?tr(_,h,u,s):function(t,e,r){var n=t.length-1;if(r&&e===n)return t.pop(),t;for(var i=Array(n),o=0,u=0;u>>t)&g];return i?i.get(t+d,e,r,n):n},Be.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=yt(n));var s=(0===e?r:r>>>e)&g,a=this.nodes,c=a[s];if(i===v&&!c)return this;o=Fe(c,t,e+d,r,n,i,o,u);if(o===c)return this;u=this.count;if(c){if(!o&&--u>>r)&g,u=(0===r?n:n>>>r)&g,t=o==u?[Ze(t,e,r+d,n,i)]:(i=new Pe(e,n,i),o>1&1431655765))+(t>>2&858993459))+(t>>4)&252645135,t+=t>>8,127&(t+=t>>16)}function tr(t,e,r,n){t=n?t:Zt(t);return t[e]=r,t}var er=l/4,rr=l/2,nr=l/4,ir="@@__IMMUTABLE_LIST__@@";function or(t){return!(!t||!t[ir])}var ur=function(o){function t(t){var e=pr();if(null==t)return e;if(or(t))return t;var n=o(t),i=n.size;return 0===i?e:(te(i),0=gr(t._capacity)?n=lr(n,t.__ownerID,0,e,r,o):i=lr(i,t.__ownerID,t._level,e,r,o);if(!o.value)return t;if(t.__ownerID)return t._root=i,t._tail=n,t.__hash=void 0,t.__altered=!0,t;return _r(t._origin,t._capacity,t._level,i,n)}(this,t,e)},t.prototype.remove=function(t){return this.has(t)?0===t?this.shift():t===this.size-1?this.pop():this.splice(t,1):this},t.prototype.insert=function(t,e){return this.splice(t,0,e)},t.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=this._origin=this._capacity=0,this._level=d,this._root=this._tail=this.__hash=void 0,this.__altered=!0,this):pr()},t.prototype.push=function(){var r=arguments,n=this.size;return this.withMutations(function(t){dr(t,0,n+r.length);for(var e=0;e>>e&g;if(this.array.length<=n)return new ar([],t);var i=0==n;if(0>>e&g;if(this.array.length<=n)return this;if(0>e,u=1+(c-r>>e);l>>r&g,a=t&&s=gr(t._capacity))return t._tail;if(e<1<>>n&g],n-=d;return r}}function dr(t,e,r){void 0!==e&&(e|=0),void 0!==r&&(r|=0);var n=t.__ownerID||new m,i=t._origin,o=t._capacity,u=i+e,s=void 0===r?o:r<0?o+r:i+r;if(u===i&&s===o)return t;if(s<=u)return t.clear();for(var a=t._level,c=t._root,f=0;u+f<0;)c=new ar(c&&c.array.length?[void 0,c]:[],n),f+=1<<(a+=d);f&&(u+=f,i+=f,s+=f,o+=f);for(var h=gr(o),_=gr(s);1<>>l&g,p=p.array[v]=vr(p.array[v],n);p.array[h>>>d&g]=e}if(s>>a&g;if(y!=_>>>a&g)break;y&&(f+=(1<>>d<>>-15,461845907),e=pt(e<<13|e>>>-13,5),e=pt((e=(e+3864292196|0)^t)^e>>>16,2246822507),e=lt((e=pt(e^e>>>13,3266489909))^e>>>16)}(t.__iterate(r?e?function(t,e){n=31*n+sn(yt(t),yt(e))|0}:function(t,e){n=n+sn(yt(t),yt(e))|0}:e?function(t){n=31*n+yt(t)|0}:function(t){n=n+yt(t)|0}),n)}(this))}});var Xr=I.prototype;Xr[o]=!0,Xr[B]=Xr.values,Xr.toJSON=Xr.toArray,Xr.__toStringMapper=oe,Xr.inspect=Xr.toSource=function(){return""+this},Xr.chain=Xr.flatMap,Xr.contains=Xr.includes,Ur(O,{flip:function(){return Vt(this,Ut(this))},mapEntries:function(r,n){var i=this,o=0;return Vt(this,this.toSeq().map(function(t,e){return r.call(n,[e,t],o++,i)}).fromEntrySeq())},mapKeys:function(r,n){var i=this;return Vt(this,this.toSeq().flip().map(function(t,e){return r.call(n,t,e,i)}).flip())}});var Fr=O.prototype;Fr[s]=!0,Fr[B]=Xr.entries,Fr.toJSON=Qr,Fr.__toStringMapper=function(t,e){return oe(e)+": "+oe(t)},Ur(E,{toKeyedSeq:function(){return new xt(this,!1)},filter:function(t,e){return Vt(this,Ct(this,t,e,!1))},findIndex:function(t,e){e=this.findEntry(t,e);return e?e[0]:-1},indexOf:function(t){t=this.keyOf(t);return void 0===t?-1:t},lastIndexOf:function(t){t=this.lastKeyOf(t);return void 0===t?-1:t},reverse:function(){return Vt(this,Tt(this,!1))},slice:function(t,e){return Vt(this,Lt(this,t,e,!1))},splice:function(t,e){var r=arguments.length;if(e=Math.max(e||0,0),0===r||2===r&&!e)return this;t=y(t,t<0?this.count():this.size);var n=this.slice(0,t);return Vt(this,1===r?n:n.concat(Zt(arguments,2),this.slice(t+e)))},findLastIndex:function(t,e){e=this.findLastEntry(t,e);return e?e[0]:-1},first:function(t){return this.get(0,t)},flatten:function(t){return Vt(this,Wt(this,t,!1))},get:function(r,t){return(r=h(this,r))<0||this.size===1/0||void 0!==this.size&&this.size>2)|0}Zr.has=Xr.includes,Zr.contains=Zr.includes,Zr.keys=Zr.values,Ur(G,Fr),Ur(Z,Gr),Ur($,Zr);var an=function(t){function e(r){return null==r?_n():kr(r)?r:_n().withMutations(function(e){var t=q(r);te(t.size),t.forEach(function(t){return e.add(t)})})}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).of=function(){return this( -arguments)},e.fromKeys=function(t){return this(O(t).keySeq())},e.prototype.toString=function(){return this.__toString("OrderedSet {","}")},e}(Tr);an.isOrderedSet=kr;var cn,fn=an.prototype;function hn(t,e){var r=Object.create(fn);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function _n(){return cn=cn||hn(zr())}fn[k]=!0,fn.zip=Gr.zip,fn.zipWith=Gr.zipWith,fn.zipAll=Gr.zipAll,fn.__empty=_n,fn.__make=hn;Gr=function(u,s){var a;!function(t){if(x(t))throw Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(A(t))throw Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(null===t||"object"!=typeof t)throw Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}(u);var c=function(t){var n=this;if(t instanceof c)return t;if(!(this instanceof c))return new c(t);if(!a){a=!0;var e=Object.keys(u),r=f._indices={};f._name=s,f._keys=e,f._defaultValues=u;for(var i=0;i>>0;if(""+r!==e||4294967295==r)return NaN;e=r}return e<0?c(t)+e:e}function r(){return!0}function p(t,e,r){return(0===t&&!i(t)||void 0!==r&&t<=-r)&&(void 0===e||void 0!==r&&r<=e)}function y(t,e){return n(t,e,0)}function w(t,e){return n(t,e,e)}function n(t,e,r){return void 0===t?r:i(t)?e===1/0?e:0|Math.max(0,e+t):void 0===e||e===t?t:0|Math.min(e,t)}function i(t){return t<0||0===t&&1/t==-1/0}var o="@@__IMMUTABLE_ITERABLE__@@";function f(t){return!(!t||!t[o])}var s="@@__IMMUTABLE_KEYED__@@";function a(t){return!(!t||!t[s])}var S="@@__IMMUTABLE_INDEXED__@@";function z(t){return!(!t||!t[S])}function b(t){return a(t)||z(t)}function I(t){return f(t)?t:F(t)}var O=function(t){function e(t){return a(t)?t:G(t)}return e.__proto__=t,(e.prototype=Object.create(t.prototype)).constructor=e}(I),E=function(t){function e(t){return z(t)?t:Z(t)}return e.__proto__=t,(e.prototype=Object.create(t.prototype)).constructor=e}(I),j=function(t){function e(t){return f(t)&&!b(t)?t:$(t)}return e.__proto__=t,(e.prototype=Object.create(t.prototype)).constructor=e}(I);I.Keyed=O,I.Indexed=E,I.Set=j;var q="@@__IMMUTABLE_SEQ__@@";function M(t){return!(!t||!t[q])}var D="@@__IMMUTABLE_RECORD__@@";function x(t){return!(!t||!t[D])}function A(t){return f(t)||x(t)}var k="@@__IMMUTABLE_ORDERED__@@";function R(t){return!(!t||!t[k])}var U=0,K=1,T=2,C="function"==typeof Symbol&&Symbol.iterator,L="@@iterator",B=C||L,P=function(t){this.next=t};function W(t,e,r,n){r=0===t?e:1===t?r:[e,r];return n?n.value=r:n={value:r,done:!1},n}function N(){return{value:void 0,done:!0}}function H(t){return Array.isArray(t +)||Y(t)}function J(t){return t&&"function"==typeof t.next}function V(t){var e=Y(t);return e&&e.call(t)}function Y(t){t=t&&(C&&t[C]||t[L]);if("function"==typeof t)return t}P.prototype.toString=function(){return"[Iterator]"},P.KEYS=U,P.VALUES=K,P.ENTRIES=T,P.prototype.inspect=P.prototype.toSource=function(){return""+this},P.prototype[B]=function(){return this};var Q=Object.prototype.hasOwnProperty;function X(t){return Array.isArray(t)||"string"==typeof t||t&&"object"==typeof t&&Number.isInteger(t.length)&&0<=t.length&&(0===t.length?1===Object.keys(t).length:t.hasOwnProperty(t.length-1))}var F=function(t){function e(t){return null==t?it():A(t)?t.toSeq():function(t){var e=st(t);if(e)return function(t){var e=Y(t);return e&&e===t.entries}(t)?e.fromEntrySeq():function(t){var e=Y(t);return e&&e===t.keys}(t)?e.toSetSeq():e;if("object"!=typeof t)throw new TypeError("Expected Array or collection object of values, or keyed object: "+t);return new et(t)}(t)}return e.__proto__=t,((e.prototype=Object.create(t.prototype)).constructor=e).prototype.toSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq {","}")},e.prototype.cacheResult=function(){return!this._cache&&this.__iterateUncached&&(this._cache=this.entrySeq().toArray(),this.size=this._cache.length),this},e.prototype.__iterate=function(t,e){var r=this._cache;if(r){for(var n=r.length,i=0;i!==n;){var o=r[e?n-++i:i++];if(!1===t(o[1],o[0],this))break}return i}return this.__iterateUncached(t,e)},e.prototype.__iterator=function(e,r){var n=this._cache;if(n){var i=n.length,o=0;return new P(function(){if(o===i)return N();var t=n[r?i-++o:o++];return W(e,t[0],t[1])})}return this.__iteratorUncached(e,r)},e}(I),G=function(t){function e(t){return null==t?it().toKeyedSeq():f(t)?a(t)?t.toSeq():t.fromEntrySeq():x(t)?t.toSeq():ot(t)}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).prototype.toKeyedSeq=function(){return this},e}(F),Z=function(t){function e(t){return null==t?it():f(t)?a(t)?t.entrySeq():t.toIndexedSeq():x(t +)?t.toSeq().entrySeq():ut(t)}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).of=function(){return e(arguments)},e.prototype.toIndexedSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq [","]")},e}(F),$=function(t){function e(t){return(f(t)&&!b(t)?t:Z(t)).toSetSeq()}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).of=function(){return e(arguments)},e.prototype.toSetSeq=function(){return this},e}(F);F.isSeq=M,F.Keyed=G,F.Set=$,F.Indexed=Z,F.prototype[q]=!0;var tt=function(t){function e(t){this._array=t,this.size=t.length}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).prototype.get=function(t,e){return this.has(t)?this._array[h(this,t)]:e},e.prototype.__iterate=function(t,e){for(var r=this._array,n=r.length,i=0;i!==n;){var o=e?n-++i:i++;if(!1===t(r[o],o,this))break}return i},e.prototype.__iterator=function(e,r){var n=this._array,i=n.length,o=0;return new P(function(){if(o===i)return N();var t=r?i-++o:o++;return W(e,t,n[t])})},e}(Z),et=function(t){function e(t){var e=Object.keys(t).concat(Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(t):[]);this._object=t,this._keys=e,this.size=e.length}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).prototype.get=function(t,e){return void 0===e||this.has(t)?this._object[t]:e},e.prototype.has=function(t){return Q.call(this._object,t)},e.prototype.__iterate=function(t,e){for(var r=this._object,n=this._keys,i=n.length,o=0;o!==i;){var u=n[e?i-++o:o++];if(!1===t(r[u],u,this))break}return o},e.prototype.__iterator=function(e,r){var n=this._object,i=this._keys,o=i.length,u=0;return new P(function(){if(u===o)return N();var t=i[r?o-++u:u++];return W(e,t,n[t])})},e}(G);et.prototype[k]=!0;var rt,nt=function(t){function e(t){this._collection=t,this.size=t.length||t.size}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).prototype.__iterateUncached=function(t,e){ +if(e)return this.cacheResult().__iterate(t,e);var r,n=V(this._collection),i=0;if(J(n))for(;!(r=n.next()).done&&!1!==t(r.value,i++,this););return i},e.prototype.__iteratorUncached=function(e,t){if(t)return this.cacheResult().__iterator(e,t);var r=V(this._collection);if(!J(r))return new P(N);var n=0;return new P(function(){var t=r.next();return t.done?t:W(e,n++,t.value)})},e}(Z);function it(){return rt=rt||new tt([])}function ot(t){var e=st(t);if(e)return e.fromEntrySeq();if("object"==typeof t)return new et(t);throw new TypeError("Expected Array or collection object of [k, v] entries, or keyed object: "+t)}function ut(t){var e=st(t);if(e)return e;throw new TypeError("Expected Array or collection object of values: "+t)}function st(t){return X(t)?new tt(t):H(t)?new nt(t):void 0}var at="@@__IMMUTABLE_MAP__@@";function ct(t){return!(!t||!t[at])}function ft(t){return ct(t)&&R(t)}function ht(t){return!(!t||"function"!=typeof t.equals||"function"!=typeof t.hashCode)}function _t(t,e){if(t===e||t!=t&&e!=e)return!0;if(!t||!e)return!1;if("function"==typeof t.valueOf&&"function"==typeof e.valueOf){if((t=t.valueOf())===(e=e.valueOf())||t!=t&&e!=e)return!0;if(!t||!e)return!1}return!!(ht(t)&&ht(e)&&t.equals(e))}var pt="function"==typeof Math.imul&&-2==Math.imul(4294967295,2)?Math.imul:function(t,e){var r=65535&(t|=0),n=65535&(e|=0);return r*n+((t>>>16)*n+r*(e>>>16)<<16>>>0)|0};function lt(t){return t>>>1&1073741824|3221225471&t}var vt=Object.prototype.valueOf;function yt(t){if(null==t)return dt(t);if("function"==typeof t.hashCode)return lt(t.hashCode(t));var e,r=(e=t).valueOf!==vt&&"function"==typeof e.valueOf?e.valueOf(e):e;if(null==r)return dt(r);switch(typeof r){case"boolean":return r?1108378657:1108378656;case"number":return function(t){if(t!=t||t===1/0)return 0;var e=0|t;e!==t&&(e^=4294967295*t);for(;4294967295f)return N();var t=r.next();return a||e===K||t.done?t:W(e,i-1,e===U?void 0:t.value[1],t)})},r}function Bt(e,c,f,h){var t=Xt(e);return t.__iterateUncached=function(n,t){var i=this;if(t)return this.cacheResult().__iterate(n,t);var o=!0,u=0;return e.__iterate(function(t,e,r){if(!(o=o&&c.call(f,t,e,r)))return u++,n(t,h?e:u-1,i)}),u},t.__iteratorUncached=function(i,t){var o=this;if(t)return this.cacheResult().__iterator(i,t);var u=e.__iterator(T,t),s=!0,a=0;return new P(function(){var t;do{if((t=u.next()).done)return h||i===K?t:W(i,a++,i===U?void 0:t.value[1],t);var e=t.value,r=e[0],n=e[1];s=s&&c.call(f,n,r,o)}while(s);return i===T?t:W(i,r,n,t)})},t}function Pt(t,s,a){var c=Xt(t);return c.__iterateUncached=function(i,e){if(e)return this.cacheResult().__iterate(i,e);var o=0,u=!1;return function r(t,n){t.__iterate(function(t,e){return(!s||n>>t)&g),o=this.bitmap;return 0==(o&i)?n:this.nodes[$e(o&i-1)].get(t+d,e,r,n)},Le.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=yt(n));var s=(0===e?r:r>>>e)&g,a=1<>>=1)u[s]=1&r?e[o++]:void 0;return u[n]=i,new Be(t,o+1,u)}(t,_,c,s,u);if(f&&!u&&2===_.length&&Ge(_[1^h]))return _[1^h];if(f&&u&&1===_.length&&Ge(u))return u;s=t&&t===this.ownerID,a=f?u?c:c^a:c|a,u=f?u?tr(_,h,u,s):function(t,e,r){var n=t.length-1;if(r&&e===n)return t.pop(),t;for(var i=Array(n),o=0,u=0;u>>t)&g];return i?i.get(t+d,e,r,n):n},Be.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=yt(n));var s=(0===e?r:r>>>e)&g,a=this.nodes,c=a[s];if(i===v&&!c)return this;o=Fe(c,t,e+d,r,n,i,o,u);if(o===c)return this;u=this.count;if(c){if(!o&&--u>>r)&g,u=(0===r?n:n>>>r)&g,t=o==u?[Ze(t,e,r+d,n,i)]:(i=new We(e,n,i),o>1&1431655765))+(t>>2&858993459))+(t>>4)&252645135,t+=t>>8,127&(t+=t>>16)}function tr(t,e,r,n){t=n?t:Zt(t);return t[e]=r,t}var er=l/4,rr=l/2,nr=l/4,ir="@@__IMMUTABLE_LIST__@@";function or(t){return!(!t||!t[ir])}var ur=function(o){function t(t){var e=pr();if(null==t)return e;if(or(t))return t;var n=o(t),i=n.size;return 0===i?e:(te(i),0=gr(t._capacity)?n=lr(n,t.__ownerID,0,e,r,o):i=lr(i,t.__ownerID,t._level,e,r,o);if(!o.value)return t;if(t.__ownerID)return t._root=i,t._tail=n,t.__hash=void 0,t.__altered=!0,t;return _r(t._origin,t._capacity,t._level,i,n)}(this,t,e)},t.prototype.remove=function(t){return this.has(t)?0===t?this.shift():t===this.size-1?this.pop():this.splice(t,1):this},t.prototype.insert=function(t,e){return this.splice(t,0,e)},t.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=this._origin=this._capacity=0,this._level=d,this._root=this._tail=this.__hash=void 0,this.__altered=!0,this):pr()},t.prototype.push=function(){var r=arguments,n=this.size;return this.withMutations(function(t){dr(t,0,n+r.length);for(var e=0;e>>e&g;if(this.array.length<=n)return new ar([],t);var i=0==n;if(0>>e&g;if(this.array.length<=n)return this;if(0>e,u=1+(c-r>>e);l>>r&g,a=t&&s=gr(t._capacity))return t._tail;if(e<1<>>n&g],n-=d;return r}}function dr(t,e,r){void 0!==e&&(e|=0),void 0!==r&&(r|=0);var n=t.__ownerID||new m,i=t._origin,o=t._capacity,u=i+e,s=void 0===r?o:r<0?o+r:i+r;if(u===i&&s===o)return t;if(s<=u)return t.clear();for(var a=t._level,c=t._root,f=0;u+f<0;)c=new ar(c&&c.array.length?[void 0,c]:[],n),f+=1<<(a+=d);f&&(u+=f,i+=f,s+=f,o+=f);for(var h=gr(o),_=gr(s);1<>>l&g,p=p.array[v]=vr(p.array[v],n);p.array[h>>>d&g]=e}if(s>>a&g;if(y!=_>>>a&g)break;y&&(f+=(1<>>d<>>-15,461845907),e=pt(e<<13|e>>>-13,5),e=pt((e=(e+3864292196|0)^t)^e>>>16,2246822507),e=lt((e=pt(e^e>>>13,3266489909))^e>>>16)}(t.__iterate(r?e?function(t,e){n=31*n+sn(yt(t),yt(e))|0}:function(t,e){n=n+sn(yt(t),yt(e))|0}:e?function(t){n=31*n+yt(t)|0}:function(t){n=n+yt(t)|0}),n)}(this))}});var Xr=I.prototype;Xr[o]=!0,Xr[B]=Xr.values,Xr.toJSON=Xr.toArray,Xr.__toStringMapper=oe,Xr.inspect=Xr.toSource=function(){return""+this},Xr.chain=Xr.flatMap,Xr.contains=Xr.includes,Ur(O,{flip:function(){return Vt(this,Ut(this))},mapEntries:function(r,n){var i=this,o=0;return Vt(this,this.toSeq().map(function(t,e){return r.call(n,[e,t],o++,i)}).fromEntrySeq())},mapKeys:function(r,n){var i=this;return Vt(this,this.toSeq().flip().map(function(t,e){return r.call(n,t,e,i)}).flip())}});var Fr=O.prototype;Fr[s]=!0,Fr[B]=Xr.entries,Fr.toJSON=Qr,Fr.__toStringMapper=function(t,e){return oe(e)+": "+oe(t)},Ur(E,{toKeyedSeq:function(){return new xt(this,!1)},filter:function(t,e){return Vt(this,Ct(this,t,e,!1))},findIndex:function(t,e){e=this.findEntry(t,e);return e?e[0]:-1},indexOf:function(t){t=this.keyOf(t);return void 0===t?-1:t},lastIndexOf:function(t){t=this.lastKeyOf(t);return void 0===t?-1:t},reverse:function(){return Vt(this,Tt(this,!1))},slice:function(t,e){return Vt(this,Lt(this,t,e,!1))},splice:function(t,e){var r=arguments.length;if(e=Math.max(e||0,0),0===r||2===r&&!e)return this;t=y(t,t<0?this.count():this.size);var n=this.slice(0,t);return Vt(this,1===r?n:n.concat(Zt(arguments,2),this.slice(t+e)))},findLastIndex:function(t,e){e=this.findLastEntry(t,e);return e?e[0]:-1},first:function(t){ +return this.get(0,t)},flatten:function(t){return Vt(this,Pt(this,t,!1))},get:function(r,t){return(r=h(this,r))<0||this.size===1/0||void 0!==this.size&&this.size>2)|0}Zr.has=Xr.includes,Zr.contains=Zr.includes,Zr.keys=Zr.values,Ur(G,Fr),Ur(Z,Gr),Ur($,Zr);var an=function(t){function e(r){return null==r?_n():kr(r)?r:_n().withMutations(function(e){var t=j( +r);te(t.size),t.forEach(function(t){return e.add(t)})})}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).of=function(){return this(arguments)},e.fromKeys=function(t){return this(O(t).keySeq())},e.prototype.toString=function(){return this.__toString("OrderedSet {","}")},e}(Tr);an.isOrderedSet=kr;var cn,fn=an.prototype;function hn(t,e){var r=Object.create(fn);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function _n(){return cn=cn||hn(zr())}fn[k]=!0,fn.zip=Gr.zip,fn.zipWith=Gr.zipWith,fn.zipAll=Gr.zipAll,fn.__empty=_n,fn.__make=hn;Gr=function(u,s){var a;!function(t){if(x(t))throw Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(A(t))throw Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(null===t||"object"!=typeof t)throw Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}(u);var c=function(t){var n=this;if(t instanceof c)return t;if(!(this instanceof c))return new c(t);if(!a){a=!0;var e=Object.keys(u),r=f._indices={};f._name=s,f._keys=e,f._defaultValues=u;for(var i=0;i Date: Fri, 29 Apr 2022 13:08:30 +0000 Subject: [PATCH 173/242] deploy: 13b9e4db84c549ac7ecb2f58000808c90317c81f --- dist/immutable.js.flow | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/dist/immutable.js.flow b/dist/immutable.js.flow index 4b9d6c950b..251fcb1730 100644 --- a/dist/immutable.js.flow +++ b/dist/immutable.js.flow @@ -1999,15 +1999,15 @@ declare function hasIn(collection: Object, keyPath: Iterable): boolean; declare function removeIn(collection: C, keyPath: []): void; declare function removeIn>(collection: C, keyPath: [K]): C; -declare function removeIn, K2: $KeyOf<$ValOf>>( +declare function removeIn, K2: $KeyOf<$ValOf>>( collection: C, keyPath: [K, K2] ): C; declare function removeIn< C, K: $KeyOf, - K2: $KeyOf<$ValOf>, - K3: $KeyOf<$ValOf<$ValOf, K2>> + K2: $KeyOf<$ValOf>, + K3: $KeyOf<$ValOf<$ValOf, K2>> >( collection: C, keyPath: [K, K2, K3] @@ -2015,9 +2015,9 @@ declare function removeIn< declare function removeIn< C, K: $KeyOf, - K2: $KeyOf<$ValOf>, - K3: $KeyOf<$ValOf<$ValOf, K2>>, - K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>> + K2: $KeyOf<$ValOf>, + K3: $KeyOf<$ValOf<$ValOf, K2>>, + K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>> >( collection: C, keyPath: [K, K2, K3, K4] @@ -2025,10 +2025,10 @@ declare function removeIn< declare function removeIn< C, K: $KeyOf, - K2: $KeyOf<$ValOf>, - K3: $KeyOf<$ValOf<$ValOf, K2>>, - K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>>, - K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>> + K2: $KeyOf<$ValOf>, + K3: $KeyOf<$ValOf<$ValOf, K2>>, + K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>>, + K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>> >( collection: C, keyPath: [K, K2, K3, K4, K5] From 43f13d986a03254fa1896ccd794cac26ee98ec15 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 9 May 2022 04:13:49 +0000 Subject: [PATCH 174/242] deploy: 800364678ff9052ce1bb8daeefa15dd515dda602 --- dist/immutable.es.js | 3 ++- dist/immutable.js | 3 ++- dist/immutable.min.js | 6 +++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/dist/immutable.es.js b/dist/immutable.es.js index 40cab9598c..5d344cb189 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -5582,7 +5582,8 @@ Record.prototype.toString = function toString () { Record.prototype.equals = function equals (other) { return ( - this === other || (other && recordSeq(this).equals(recordSeq(other))) + this === other || + (isRecord(other) && recordSeq(this).equals(recordSeq(other))) ); }; diff --git a/dist/immutable.js b/dist/immutable.js index 53168c03ca..cf23b3818f 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -5588,7 +5588,8 @@ Record.prototype.equals = function equals (other) { return ( - this === other || (other && recordSeq(this).equals(recordSeq(other))) + this === other || + (isRecord(other) && recordSeq(this).equals(recordSeq(other))) ); }; diff --git a/dist/immutable.min.js b/dist/immutable.min.js index 29b3b3556a..cdbaffef0d 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -50,6 +50,6 @@ return t instanceof n?this._start===t._start&&this._end===t._end&&this._step===t ;if(t.done)return t;var e=t.value,r=e[0],e=e[1];return s.call(a,e,r,i)?n===T?t:W(n,r,e,t):(u=!1,N())})},e));var r,s,a},takeUntil:function(t,e){return this.takeWhile(rn(t),e)},update:function(t){return t(this)},valueSeq:function(){return this.toIndexedSeq()},hashCode:function(){return this.__hash||(this.__hash=function(t){if(t.size===1/0)return 0;var e=R(t),r=a(t),n=e?1:0;return function(t,e){return e=pt(e,3432918353),e=pt(e<<15|e>>>-15,461845907),e=pt(e<<13|e>>>-13,5),e=pt((e=(e+3864292196|0)^t)^e>>>16,2246822507),e=lt((e=pt(e^e>>>13,3266489909))^e>>>16)}(t.__iterate(r?e?function(t,e){n=31*n+sn(yt(t),yt(e))|0}:function(t,e){n=n+sn(yt(t),yt(e))|0}:e?function(t){n=31*n+yt(t)|0}:function(t){n=n+yt(t)|0}),n)}(this))}});var Xr=I.prototype;Xr[o]=!0,Xr[B]=Xr.values,Xr.toJSON=Xr.toArray,Xr.__toStringMapper=oe,Xr.inspect=Xr.toSource=function(){return""+this},Xr.chain=Xr.flatMap,Xr.contains=Xr.includes,Ur(O,{flip:function(){return Vt(this,Ut(this))},mapEntries:function(r,n){var i=this,o=0;return Vt(this,this.toSeq().map(function(t,e){return r.call(n,[e,t],o++,i)}).fromEntrySeq())},mapKeys:function(r,n){var i=this;return Vt(this,this.toSeq().flip().map(function(t,e){return r.call(n,t,e,i)}).flip())}});var Fr=O.prototype;Fr[s]=!0,Fr[B]=Xr.entries,Fr.toJSON=Qr,Fr.__toStringMapper=function(t,e){return oe(e)+": "+oe(t)},Ur(E,{toKeyedSeq:function(){return new xt(this,!1)},filter:function(t,e){return Vt(this,Ct(this,t,e,!1))},findIndex:function(t,e){e=this.findEntry(t,e);return e?e[0]:-1},indexOf:function(t){t=this.keyOf(t);return void 0===t?-1:t},lastIndexOf:function(t){t=this.lastKeyOf(t);return void 0===t?-1:t},reverse:function(){return Vt(this,Tt(this,!1))},slice:function(t,e){return Vt(this,Lt(this,t,e,!1))},splice:function(t,e){var r=arguments.length;if(e=Math.max(e||0,0),0===r||2===r&&!e)return this;t=y(t,t<0?this.count():this.size);var n=this.slice(0,t);return Vt(this,1===r?n:n.concat(Zt(arguments,2),this.slice(t+e)))},findLastIndex:function(t,e){e=this.findLastEntry(t,e);return e?e[0]:-1},first:function(t){ return this.get(0,t)},flatten:function(t){return Vt(this,Pt(this,t,!1))},get:function(r,t){return(r=h(this,r))<0||this.size===1/0||void 0!==this.size&&this.size>2)|0}Zr.has=Xr.includes,Zr.contains=Zr.includes,Zr.keys=Zr.values,Ur(G,Fr),Ur(Z,Gr),Ur($,Zr);var an=function(t){function e(r){return null==r?_n():kr(r)?r:_n().withMutations(function(e){var t=j( r);te(t.size),t.forEach(function(t){return e.add(t)})})}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).of=function(){return this(arguments)},e.fromKeys=function(t){return this(O(t).keySeq())},e.prototype.toString=function(){return this.__toString("OrderedSet {","}")},e}(Tr);an.isOrderedSet=kr;var cn,fn=an.prototype;function hn(t,e){var r=Object.create(fn);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function _n(){return cn=cn||hn(zr())}fn[k]=!0,fn.zip=Gr.zip,fn.zipWith=Gr.zipWith,fn.zipAll=Gr.zipAll,fn.__empty=_n,fn.__make=hn;Gr=function(u,s){var a;!function(t){if(x(t))throw Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(A(t))throw Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(null===t||"object"!=typeof t)throw Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}(u);var c=function(t){var n=this;if(t instanceof c)return t;if(!(this instanceof c))return new c(t);if(!a){a=!0;var e=Object.keys(u),r=f._indices={};f._name=s,f._keys=e,f._defaultValues=u;for(var i=0;i Date: Mon, 23 May 2022 19:03:36 +0000 Subject: [PATCH 175/242] deploy: fb4701a71ca3b138cb31b6697f047e637780867e --- bower.json | 2 +- dist/immutable.es.js | 2 +- dist/immutable.js | 2 +- dist/immutable.min.js | 4 ++-- package.json | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bower.json b/bower.json index 1a854a6e03..20ef5e9918 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "immutable", - "version": "4.0.0", + "version": "4.1.0", "description": "Immutable Data Collections", "license": "MIT", "homepage": "https://immutable-js.com", diff --git a/dist/immutable.es.js b/dist/immutable.es.js index 5d344cb189..7281c0c589 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -5866,7 +5866,7 @@ function defaultConverter(k, v) { return isIndexed(v) ? v.toList() : isKeyed(v) ? v.toMap() : v.toSet(); } -var version = "4.0.0"; +var version = "4.1.0"; var Immutable = { version: version, diff --git a/dist/immutable.js b/dist/immutable.js index cf23b3818f..3d763747d5 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -5872,7 +5872,7 @@ return isIndexed(v) ? v.toList() : isKeyed(v) ? v.toMap() : v.toSet(); } - var version = "4.0.0"; + var version = "4.1.0"; var Immutable = { version: version, diff --git a/dist/immutable.min.js b/dist/immutable.min.js index cdbaffef0d..293771bdaf 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -51,5 +51,5 @@ return t instanceof n?this._start===t._start&&this._end===t._end&&this._step===t return this.get(0,t)},flatten:function(t){return Vt(this,Pt(this,t,!1))},get:function(r,t){return(r=h(this,r))<0||this.size===1/0||void 0!==this.size&&this.size>2)|0}Zr.has=Xr.includes,Zr.contains=Zr.includes,Zr.keys=Zr.values,Ur(G,Fr),Ur(Z,Gr),Ur($,Zr);var an=function(t){function e(r){return null==r?_n():kr(r)?r:_n().withMutations(function(e){var t=j( r);te(t.size),t.forEach(function(t){return e.add(t)})})}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).of=function(){return this(arguments)},e.fromKeys=function(t){return this(O(t).keySeq())},e.prototype.toString=function(){return this.__toString("OrderedSet {","}")},e}(Tr);an.isOrderedSet=kr;var cn,fn=an.prototype;function hn(t,e){var r=Object.create(fn);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function _n(){return cn=cn||hn(zr())}fn[k]=!0,fn.zip=Gr.zip,fn.zipWith=Gr.zipWith,fn.zipAll=Gr.zipAll,fn.__empty=_n,fn.__make=hn;Gr=function(u,s){var a;!function(t){if(x(t))throw Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(A(t))throw Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(null===t||"object"!=typeof t)throw Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}(u);var c=function(t){var n=this;if(t instanceof c)return t;if(!(this instanceof c))return new c(t);if(!a){a=!0;var e=Object.keys(u),r=f._indices={};f._name=s,f._keys=e,f._defaultValues=u;for(var i=0;i Date: Thu, 17 Nov 2022 15:32:51 +0000 Subject: [PATCH 176/242] deploy: 908f205b09e494cb8a1c1309170498cb1254f48c --- dist/immutable.es.js | 6 +++++- dist/immutable.js | 6 +++++- dist/immutable.min.js | 4 ++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/dist/immutable.es.js b/dist/immutable.es.js index 7281c0c589..4a77a3263b 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -4407,7 +4407,11 @@ var Set = /*@__PURE__*/(function (SetCollection) { } return this.withMutations(function (set) { for (var ii = 0; ii < iters.length; ii++) { - SetCollection(iters[ii]).forEach(function (value) { return set.add(value); }); + if (typeof iters[ii] === 'string') { + set.add(iters[ii]); + } else { + SetCollection(iters[ii]).forEach(function (value) { return set.add(value); }); + } } }); }; diff --git a/dist/immutable.js b/dist/immutable.js index 3d763747d5..dde42f3eaa 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -4413,7 +4413,11 @@ } return this.withMutations(function (set) { for (var ii = 0; ii < iters.length; ii++) { - SetCollection(iters[ii]).forEach(function (value) { return set.add(value); }); + if (typeof iters[ii] === 'string') { + set.add(iters[ii]); + } else { + SetCollection(iters[ii]).forEach(function (value) { return set.add(value); }); + } } }); }; diff --git a/dist/immutable.min.js b/dist/immutable.min.js index 293771bdaf..e3da8ba05d 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -42,8 +42,8 @@ var n,i=t&&t.array,o=a>e,u=1+(c-r>>e);l Date: Mon, 12 Dec 2022 21:40:16 +0000 Subject: [PATCH 177/242] deploy: 9ff46127eb326d19b3814c2e65d05b9d365a8ca6 --- README.md | 40 ++++++++++ dist/immutable.d.ts | 172 ++++++++++++++++++++++++++++++++++++++++++ dist/immutable.es.js | 16 ++++ dist/immutable.js | 16 ++++ dist/immutable.min.js | 16 ++-- 5 files changed, 252 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 678257f027..9b09af848c 100644 --- a/README.md +++ b/README.md @@ -637,6 +637,46 @@ Range(1, Infinity) // 1006008 ``` +## Comparison of filter(), groupBy(), and partition() + +The `filter()`, `groupBy()`, and `partition()` methods are similar in that they +all divide a collection into parts based on applying a function to each element. +All three call the predicate or grouping function once for each item in the +input collection. All three return zero or more collections of the same type as +their input. The returned collections are always distinct from the input +(according to `===`), even if the contents are identical. + +Of these methods, `filter()` is the only one that is lazy and the only one which +discards items from the input collection. It is the simplest to use, and the +fact that it returns exactly one collection makes it easy to combine with other +methods to form a pipeline of operations. + +The `partition()` method is similar to an eager version of `filter()`, but it +returns two collections; the first contains the items that would have been +discarded by `filter()`, and the second contains the items that would have been +kept. It always returns an array of exactly two collections, which can make it +easier to use than `groupBy()`. Compared to making two separate calls to +`filter()`, `partition()` makes half as many calls it the predicate passed to +it. + +The `groupBy()` method is a more generalized version of `partition()` that can +group by an arbitrary function rather than just a predicate. It returns a map +with zero or more entries, where the keys are the values returned by the +grouping function, and the values are nonempty collections of the corresponding +arguments. Although `groupBy()` is more powerful than `partition()`, it can be +harder to use because it is not always possible predict in advance how many +entries the returned map will have and what their keys will be. + +| Summary | `filter` | `partition` | `groupBy` | +|:------------------------------|:---------|:------------|:---------------| +| ease of use | easiest | moderate | hardest | +| generality | least | moderate | most | +| laziness | lazy | eager | eager | +| # of returned sub-collections | 1 | 2 | 0 or more | +| sub-collections may be empty | yes | yes | no | +| can discard items | yes | no | no | +| wrapping container | none | array | Map/OrderedMap | + ## Additional Tools and Resources - [Atom-store](https://github.com/jameshopkins/atom-store/) diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index a8c62e1d78..db4816ec79 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -588,6 +588,19 @@ declare namespace Immutable { context?: unknown ): this; + /** + * Returns a new List with the values for which the `predicate` + * function returns false and another for which is returns true. + */ + partition( + predicate: (this: C, value: T, index: number, iter: this) => value is F, + context?: C + ): [List, List]; + partition( + predicate: (this: C, value: T, index: number, iter: this) => unknown, + context?: C + ): [this, this]; + /** * Returns a List "zipped" with the provided collection. * @@ -1406,6 +1419,19 @@ declare namespace Immutable { context?: unknown ): this; + /** + * Returns a new Map with the values for which the `predicate` + * function returns false and another for which is returns true. + */ + partition( + predicate: (this: C, value: V, key: K, iter: this) => value is F, + context?: C + ): [Map, Map]; + partition( + predicate: (this: C, value: V, key: K, iter: this) => unknown, + context?: C + ): [this, this]; + /** * @see Collection.Keyed.flip */ @@ -1574,6 +1600,19 @@ declare namespace Immutable { context?: unknown ): this; + /** + * Returns a new OrderedMap with the values for which the `predicate` + * function returns false and another for which is returns true. + */ + partition( + predicate: (this: C, value: V, key: K, iter: this) => value is F, + context?: C + ): [OrderedMap, OrderedMap]; + partition( + predicate: (this: C, value: V, key: K, iter: this) => unknown, + context?: C + ): [this, this]; + /** * @see Collection.Keyed.flip */ @@ -1787,6 +1826,19 @@ declare namespace Immutable { predicate: (value: T, key: T, iter: this) => unknown, context?: unknown ): this; + + /** + * Returns a new Set with the values for which the `predicate` function + * returns false and another for which is returns true. + */ + partition( + predicate: (this: C, value: T, key: T, iter: this) => value is F, + context?: C + ): [Set, Set]; + partition( + predicate: (this: C, value: T, key: T, iter: this) => unknown, + context?: C + ): [this, this]; } /** @@ -1887,6 +1939,19 @@ declare namespace Immutable { context?: unknown ): this; + /** + * Returns a new OrderedSet with the values for which the `predicate` + * function returns false and another for which is returns true. + */ + partition( + predicate: (this: C, value: T, key: T, iter: this) => value is F, + context?: C + ): [OrderedSet, OrderedSet]; + partition( + predicate: (this: C, value: T, key: T, iter: this) => unknown, + context?: C + ): [this, this]; + /** * Returns an OrderedSet of the same type "zipped" with the provided * collections. @@ -2857,6 +2922,19 @@ declare namespace Immutable { context?: unknown ): this; + /** + * Returns a new keyed Seq with the values for which the `predicate` + * function returns false and another for which is returns true. + */ + partition( + predicate: (this: C, value: V, key: K, iter: this) => value is F, + context?: C + ): [Seq.Keyed, Seq.Keyed]; + partition( + predicate: (this: C, value: V, key: K, iter: this) => unknown, + context?: C + ): [this, this]; + /** * @see Collection.Keyed.flip */ @@ -2958,6 +3036,19 @@ declare namespace Immutable { context?: unknown ): this; + /** + * Returns a new indexed Seq with the values for which the `predicate` + * function returns false and another for which is returns true. + */ + partition( + predicate: (this: C, value: T, index: number, iter: this) => value is F, + context?: C + ): [Seq.Indexed, Seq.Indexed]; + partition( + predicate: (this: C, value: T, index: number, iter: this) => unknown, + context?: C + ): [this, this]; + /** * Returns a Seq "zipped" with the provided collections. * @@ -3120,6 +3211,19 @@ declare namespace Immutable { context?: unknown ): this; + /** + * Returns a new set Seq with the values for which the `predicate` + * function returns false and another for which is returns true. + */ + partition( + predicate: (this: C, value: T, key: T, iter: this) => value is F, + context?: C + ): [Seq.Set, Seq.Set]; + partition( + predicate: (this: C, value: T, key: T, iter: this) => unknown, + context?: C + ): [this, this]; + [Symbol.iterator](): IterableIterator; } } @@ -3264,6 +3368,19 @@ declare namespace Immutable { predicate: (value: V, key: K, iter: this) => unknown, context?: unknown ): this; + + /** + * Returns a new Seq with the values for which the `predicate` function + * returns false and another for which is returns true. + */ + partition( + predicate: (this: C, value: V, key: K, iter: this) => value is F, + context?: C + ): [Seq, Seq]; + partition( + predicate: (this: C, value: V, key: K, iter: this) => unknown, + context?: C + ): [this, this]; } /** @@ -3470,6 +3587,20 @@ declare namespace Immutable { context?: unknown ): this; + /** + * Returns a new keyed Collection with the values for which the + * `predicate` function returns false and another for which is returns + * true. + */ + partition( + predicate: (this: C, value: V, key: K, iter: this) => value is F, + context?: C + ): [Collection.Keyed, Collection.Keyed]; + partition( + predicate: (this: C, value: V, key: K, iter: this) => unknown, + context?: C + ): [this, this]; + [Symbol.iterator](): IterableIterator<[K, V]>; } @@ -3767,6 +3898,20 @@ declare namespace Immutable { context?: unknown ): this; + /** + * Returns a new indexed Collection with the values for which the + * `predicate` function returns false and another for which is returns + * true. + */ + partition( + predicate: (this: C, value: T, index: number, iter: this) => value is F, + context?: C + ): [Collection.Indexed, Collection.Indexed]; + partition( + predicate: (this: C, value: T, index: number, iter: this) => unknown, + context?: C + ): [this, this]; + [Symbol.iterator](): IterableIterator; } @@ -3869,6 +4014,20 @@ declare namespace Immutable { context?: unknown ): this; + /** + * Returns a new set Collection with the values for which the + * `predicate` function returns false and another for which is returns + * true. + */ + partition( + predicate: (this: C, value: T, key: T, iter: this) => value is F, + context?: C + ): [Collection.Set, Collection.Set]; + partition( + predicate: (this: C, value: T, key: T, iter: this) => unknown, + context?: C + ): [this, this]; + [Symbol.iterator](): IterableIterator; } } @@ -4299,6 +4458,19 @@ declare namespace Immutable { context?: unknown ): this; + /** + * Returns a new Collection with the values for which the `predicate` + * function returns false and another for which is returns true. + */ + partition( + predicate: (this: C, value: V, key: K, iter: this) => value is F, + context?: C + ): [Collection, Collection]; + partition( + predicate: (this: C, value: V, key: K, iter: this) => unknown, + context?: C + ): [this, this]; + /** * Returns a new Collection of the same type in reverse order. */ diff --git a/dist/immutable.es.js b/dist/immutable.es.js index 4a77a3263b..01681e88b4 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -1410,6 +1410,18 @@ function groupByFactory(collection, grouper, context) { return groups.map(function (arr) { return reify(collection, coerce(arr)); }).asImmutable(); } +function partitionFactory(collection, predicate, context) { + var isKeyedIter = isKeyed(collection); + var groups = [[], []]; + collection.__iterate(function (v, k) { + groups[predicate.call(context, v, k, collection) ? 1 : 0].push( + isKeyedIter ? [k, v] : v + ); + }); + var coerce = collectionClass(collection); + return groups.map(function (arr) { return reify(collection, coerce(arr)); }); +} + function sliceFactory(collection, begin, end, useKeys) { var originalSize = collection.size; @@ -4848,6 +4860,10 @@ mixin(Collection, { return reify(this, filterFactory(this, predicate, context, true)); }, + partition: function partition(predicate, context) { + return partitionFactory(this, predicate, context); + }, + find: function find(predicate, context, notSetValue) { var entry = this.findEntry(predicate, context); return entry ? entry[1] : notSetValue; diff --git a/dist/immutable.js b/dist/immutable.js index dde42f3eaa..bb82318d71 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -1416,6 +1416,18 @@ return groups.map(function (arr) { return reify(collection, coerce(arr)); }).asImmutable(); } + function partitionFactory(collection, predicate, context) { + var isKeyedIter = isKeyed(collection); + var groups = [[], []]; + collection.__iterate(function (v, k) { + groups[predicate.call(context, v, k, collection) ? 1 : 0].push( + isKeyedIter ? [k, v] : v + ); + }); + var coerce = collectionClass(collection); + return groups.map(function (arr) { return reify(collection, coerce(arr)); }); + } + function sliceFactory(collection, begin, end, useKeys) { var originalSize = collection.size; @@ -4854,6 +4866,10 @@ return reify(this, filterFactory(this, predicate, context, true)); }, + partition: function partition(predicate, context) { + return partitionFactory(this, predicate, context); + }, + find: function find(predicate, context, notSetValue) { var entry = this.findEntry(predicate, context); return entry ? entry[1] : notSetValue; diff --git a/dist/immutable.min.js b/dist/immutable.min.js index e3da8ba05d..fcf942e060 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -45,11 +45,11 @@ var i=Object.create(qr);return i.size=t,i._head=e,i.__ownerID=r,i.__hash=n,i.__a e.prototype.toString=function(){return this.__toString("Set {","}")},e.prototype.has=function(t){return this._map.has(t)},e.prototype.add=function(t){return Br(this,this._map.set(t,t))},e.prototype.remove=function(t){return Br(this,this._map.remove(t))},e.prototype.clear=function(){return Br(this,this._map.clear())},e.prototype.map=function(r,n){var i=this,o=!1,t=Br(this,this._map.mapEntries(function(t){var e=t[1],t=r.call(n,e,e,i);return t!==e&&(o=!0),[t,t]},n));return o?t:this},e.prototype.union=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return 0===(r=r.filter(function(t){return 0!==t.size})).length?this:0!==this.size||this.__ownerID||1!==r.length?this.withMutations(function(e){for(var t=0;t>>-15,461845907),e=pt(e<<13|e>>>-13,5),e=pt((e=(e+3864292196|0)^t)^e>>>16,2246822507),e=lt((e=pt(e^e>>>13,3266489909))^e>>>16)}(t.__iterate(r?e?function(t,e){n=31*n+sn(yt(t),yt(e))|0}:function(t,e){n=n+sn(yt(t),yt(e))|0}:e?function(t){n=31*n+yt(t)|0}:function(t){n=n+yt(t)|0}),n)}(this))}});var Xr=I.prototype;Xr[o]=!0,Xr[B]=Xr.values,Xr.toJSON=Xr.toArray,Xr.__toStringMapper=oe,Xr.inspect=Xr.toSource=function(){return""+this},Xr.chain=Xr.flatMap,Xr.contains=Xr.includes,Ur(O,{flip:function(){return Vt(this,Ut(this))},mapEntries:function(r,n){var i=this,o=0;return Vt(this,this.toSeq().map(function(t,e){return r.call(n,[e,t],o++,i)}).fromEntrySeq())},mapKeys:function(r,n){var i=this;return Vt(this,this.toSeq().flip().map(function(t,e){return r.call(n,t,e,i)}).flip())}});var Fr=O.prototype;Fr[s]=!0,Fr[B]=Xr.entries,Fr.toJSON=Qr,Fr.__toStringMapper=function(t,e){return oe(e)+": "+oe(t)},Ur(E,{toKeyedSeq:function(){return new xt(this,!1)},filter:function(t,e){return Vt(this,Ct(this,t,e,!1))},findIndex:function(t,e){e=this.findEntry(t,e);return e?e[0]:-1},indexOf:function(t){t=this.keyOf(t);return void 0===t?-1:t},lastIndexOf:function(t){t=this.lastKeyOf(t);return void 0===t?-1:t},reverse:function(){return Vt(this,Tt(this,!1))},slice:function(t,e){return Vt(this,Lt(this,t,e,!1))},splice:function(t,e){var r=arguments.length;if(e=Math.max(e||0,0),0===r||2===r&&!e)return this;t=y(t,t<0?this.count():this.size);var n=this.slice(0,t);return Vt(this,1===r?n:n.concat(Zt(arguments,2),this.slice(t+e)))},findLastIndex:function(t,e){e=this.findLastEntry(t,e);return e?e[0]:-1},first:function(t){ -return this.get(0,t)},flatten:function(t){return Vt(this,Pt(this,t,!1))},get:function(r,t){return(r=h(this,r))<0||this.size===1/0||void 0!==this.size&&this.size>2)|0}Zr.has=Xr.includes,Zr.contains=Zr.includes,Zr.keys=Zr.values,Ur(G,Fr),Ur(Z,Gr),Ur($,Zr);var an=function(t){function e(r){return null==r?_n():kr(r)?r:_n().withMutations(function(e){var t=j( -r);te(t.size),t.forEach(function(t){return e.add(t)})})}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).of=function(){return this(arguments)},e.fromKeys=function(t){return this(O(t).keySeq())},e.prototype.toString=function(){return this.__toString("OrderedSet {","}")},e}(Tr);an.isOrderedSet=kr;var cn,fn=an.prototype;function hn(t,e){var r=Object.create(fn);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function _n(){return cn=cn||hn(zr())}fn[k]=!0,fn.zip=Gr.zip,fn.zipWith=Gr.zipWith,fn.zipAll=Gr.zipAll,fn.__empty=_n,fn.__make=hn;Gr=function(u,s){var a;!function(t){if(x(t))throw Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(A(t))throw Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(null===t||"object"!=typeof t)throw Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}(u);var c=function(t){var n=this;if(t instanceof c)return t;if(!(this instanceof c))return new c(t);if(!a){a=!0;var e=Object.keys(u),r=f._indices={};f._name=s,f._keys=e,f._defaultValues=u;for(var i=0;i>>-15,461845907),e=pt(e<<13|e>>>-13,5),e=pt((e=(e+3864292196|0)^t)^e>>>16,2246822507),e=lt((e=pt(e^e>>>13,3266489909))^e>>>16)}(t.__iterate(r?e?function(t,e){n=31*n+sn(yt(t),yt(e))|0}:function(t,e){n=n+sn(yt(t),yt(e))|0}:e?function(t){n=31*n+yt(t)|0}:function(t){n=n+yt(t)|0}),n)}(this))}});var Xr=I.prototype;Xr[o]=!0,Xr[B]=Xr.values,Xr.toJSON=Xr.toArray,Xr.__toStringMapper=oe,Xr.inspect=Xr.toSource=function(){return""+this},Xr.chain=Xr.flatMap,Xr.contains=Xr.includes,Ur(O,{flip:function(){return Vt(this,Ut(this))},mapEntries:function(r,n){var i=this,o=0;return Vt(this,this.toSeq().map(function(t,e){return r.call(n,[e,t],o++,i)}).fromEntrySeq())},mapKeys:function(r,n){var i=this;return Vt(this,this.toSeq().flip().map(function(t,e){return r.call(n,t,e,i)}).flip())}});var Fr=O.prototype;Fr[s]=!0,Fr[B]=Xr.entries,Fr.toJSON=Qr,Fr.__toStringMapper=function(t,e){return oe(e)+": "+oe(t)},Ur(E,{toKeyedSeq:function(){return new xt(this,!1)},filter:function(t,e){return Vt(this,Ct(this,t,e,!1))},findIndex:function(t,e){e=this.findEntry(t,e);return e?e[0]:-1},indexOf:function(t){t=this.keyOf(t);return void 0===t?-1:t},lastIndexOf:function(t){t=this.lastKeyOf(t);return void 0===t?-1:t},reverse:function(){return Vt(this,Tt(this,!1))},slice:function(t,e){return Vt(this,Lt(this,t,e,!1))},splice:function(t,e){var r=arguments.length;if(e=Math.max(e||0,0),0===r||2===r&&!e)return this;t=y(t,t<0?this.count( +):this.size);var n=this.slice(0,t);return Vt(this,1===r?n:n.concat(Zt(arguments,2),this.slice(t+e)))},findLastIndex:function(t,e){e=this.findLastEntry(t,e);return e?e[0]:-1},first:function(t){return this.get(0,t)},flatten:function(t){return Vt(this,Pt(this,t,!1))},get:function(r,t){return(r=h(this,r))<0||this.size===1/0||void 0!==this.size&&this.size>2 +)|0}Zr.has=Xr.includes,Zr.contains=Zr.includes,Zr.keys=Zr.values,Ur(G,Fr),Ur(Z,Gr),Ur($,Zr);var an=function(t){function e(r){return null==r?_n():kr(r)?r:_n().withMutations(function(e){var t=j(r);te(t.size),t.forEach(function(t){return e.add(t)})})}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).of=function(){return this(arguments)},e.fromKeys=function(t){return this(O(t).keySeq())},e.prototype.toString=function(){return this.__toString("OrderedSet {","}")},e}(Tr);an.isOrderedSet=kr;var cn,fn=an.prototype;function hn(t,e){var r=Object.create(fn);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function _n(){return cn=cn||hn(zr())}fn[k]=!0,fn.zip=Gr.zip,fn.zipWith=Gr.zipWith,fn.zipAll=Gr.zipAll,fn.__empty=_n,fn.__make=hn;Gr=function(u,s){var a;!function(t){if(x(t))throw Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(A(t))throw Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(null===t||"object"!=typeof t)throw Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}(u);var c=function(t){var n=this;if(t instanceof c)return t;if(!(this instanceof c))return new c(t);if(!a){a=!0;var e=Object.keys(u),r=f._indices={};f._name=s,f._keys=e,f._defaultValues=u;for(var i=0;i Date: Thu, 22 Dec 2022 15:28:15 +0000 Subject: [PATCH 178/242] deploy: ffb3ee8322ec70cbca822617593e58a3ab9fff54 --- dist/immutable.d.ts | 48 ++++++++++++++++++++++++++++++++++----------- 1 file changed, 37 insertions(+), 11 deletions(-) diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index db4816ec79..7adfdeb381 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -91,6 +91,30 @@ */ declare namespace Immutable { + /** + * @ignore + */ + export type DeepCopy = T extends Collection.Keyed + ? // convert KeyedCollection to DeepCopy plain JS object + { + [key in KeyedKey extends string | number | symbol + ? KeyedKey + : string]: DeepCopy; + } + : // convert IndexedCollection or Immutable.Set to DeepCopy plain JS array + T extends Collection + ? Array> + : T extends string | number // Iterable scalar types : should be kept as is + ? T + : T extends Iterable // Iterable are converted to plain JS array + ? Array> + : T extends object // plain JS object are converted deeply + ? { + [ObjectKey in keyof T]: DeepCopy; + } + : // other case : should be kept as is + T; + /** * Lists are ordered indexed dense collections, much like a JavaScript * Array. @@ -2666,7 +2690,7 @@ declare namespace Immutable { * Note: This method may not be overridden. Objects with custom * serialization to plain JS may override toJSON() instead. */ - toJS(): { [K in keyof TProps]: unknown }; + toJS(): DeepCopy; /** * Shallowly converts this Record to equivalent native JavaScript Object. @@ -2826,14 +2850,14 @@ declare namespace Immutable { * * Converts keys to Strings. */ - toJS(): { [key: string]: unknown }; + toJS(): { [key in string | number | symbol]: DeepCopy }; /** * Shallowly converts this Keyed Seq to equivalent native JavaScript Object. * * Converts keys to Strings. */ - toJSON(): { [key: string]: V }; + toJSON(): { [key in string | number | symbol]: V }; /** * Shallowly converts this collection to an Array. @@ -2968,7 +2992,7 @@ declare namespace Immutable { /** * Deeply converts this Indexed Seq to equivalent native JavaScript Array. */ - toJS(): Array; + toJS(): Array>; /** * Shallowly converts this Indexed Seq to equivalent native JavaScript Array. @@ -3143,7 +3167,7 @@ declare namespace Immutable { /** * Deeply converts this Set Seq to equivalent native JavaScript Array. */ - toJS(): Array; + toJS(): Array>; /** * Shallowly converts this Set Seq to equivalent native JavaScript Array. @@ -3453,14 +3477,14 @@ declare namespace Immutable { * * Converts keys to Strings. */ - toJS(): { [key: string]: unknown }; + toJS(): { [key in string | number | symbol]: DeepCopy }; /** * Shallowly converts this Keyed collection to equivalent native JavaScript Object. * * Converts keys to Strings. */ - toJSON(): { [key: string]: V }; + toJSON(): { [key in string | number | symbol]: V }; /** * Shallowly converts this collection to an Array. @@ -3635,7 +3659,7 @@ declare namespace Immutable { /** * Deeply converts this Indexed collection to equivalent native JavaScript Array. */ - toJS(): Array; + toJS(): Array>; /** * Shallowly converts this Indexed collection to equivalent native JavaScript Array. @@ -3946,7 +3970,7 @@ declare namespace Immutable { /** * Deeply converts this Set collection to equivalent native JavaScript Array. */ - toJS(): Array; + toJS(): Array>; /** * Shallowly converts this Set collection to equivalent native JavaScript Array. @@ -4208,7 +4232,9 @@ declare namespace Immutable { * `Collection.Indexed`, and `Collection.Set` become `Array`, while * `Collection.Keyed` become `Object`, converting keys to Strings. */ - toJS(): Array | { [key: string]: unknown }; + toJS(): + | Array> + | { [key in string | number | symbol]: DeepCopy }; /** * Shallowly converts this Collection to equivalent native JavaScript Array or Object. @@ -4216,7 +4242,7 @@ declare namespace Immutable { * `Collection.Indexed`, and `Collection.Set` become `Array`, while * `Collection.Keyed` become `Object`, converting keys to Strings. */ - toJSON(): Array | { [key: string]: V }; + toJSON(): Array | { [key in string | number | symbol]: V }; /** * Shallowly converts this collection to an Array. From 68b1b883e2890f585ef5ff6a895c49bf9a6187bf Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 22 Dec 2022 15:37:50 +0000 Subject: [PATCH 179/242] deploy: d88f7221f1d3b960aeaf7aedd72e306d2b8b4cf5 --- bower.json | 2 +- dist/immutable.es.js | 2 +- dist/immutable.js | 2 +- dist/immutable.min.js | 4 ++-- package.json | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bower.json b/bower.json index 20ef5e9918..b4e3a16828 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "immutable", - "version": "4.1.0", + "version": "4.2.0", "description": "Immutable Data Collections", "license": "MIT", "homepage": "https://immutable-js.com", diff --git a/dist/immutable.es.js b/dist/immutable.es.js index 01681e88b4..0dd89ee16b 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -5886,7 +5886,7 @@ function defaultConverter(k, v) { return isIndexed(v) ? v.toList() : isKeyed(v) ? v.toMap() : v.toSet(); } -var version = "4.1.0"; +var version = "4.2.0"; var Immutable = { version: version, diff --git a/dist/immutable.js b/dist/immutable.js index bb82318d71..5a0b81143d 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -5892,7 +5892,7 @@ return isIndexed(v) ? v.toList() : isKeyed(v) ? v.toMap() : v.toSet(); } - var version = "4.1.0"; + var version = "4.2.0"; var Immutable = { version: version, diff --git a/dist/immutable.min.js b/dist/immutable.min.js index fcf942e060..f024be439b 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -51,5 +51,5 @@ t,e,r)&&++o&&n(t,e,i)}),o},e.__iteratorUncached=function(n,t){var i=this;if(t)re ):this.size);var n=this.slice(0,t);return Vt(this,1===r?n:n.concat(Zt(arguments,2),this.slice(t+e)))},findLastIndex:function(t,e){e=this.findLastEntry(t,e);return e?e[0]:-1},first:function(t){return this.get(0,t)},flatten:function(t){return Vt(this,Pt(this,t,!1))},get:function(r,t){return(r=h(this,r))<0||this.size===1/0||void 0!==this.size&&this.size>2 )|0}Zr.has=Xr.includes,Zr.contains=Zr.includes,Zr.keys=Zr.values,Ur(G,Fr),Ur(Z,Gr),Ur($,Zr);var an=function(t){function e(r){return null==r?_n():kr(r)?r:_n().withMutations(function(e){var t=j(r);te(t.size),t.forEach(function(t){return e.add(t)})})}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).of=function(){return this(arguments)},e.fromKeys=function(t){return this(O(t).keySeq())},e.prototype.toString=function(){return this.__toString("OrderedSet {","}")},e}(Tr);an.isOrderedSet=kr;var cn,fn=an.prototype;function hn(t,e){var r=Object.create(fn);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function _n(){return cn=cn||hn(zr())}fn[k]=!0,fn.zip=Gr.zip,fn.zipWith=Gr.zipWith,fn.zipAll=Gr.zipAll,fn.__empty=_n,fn.__make=hn;Gr=function(u,s){var a;!function(t){if(x(t))throw Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(A(t))throw Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(null===t||"object"!=typeof t)throw Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}(u);var c=function(t){var n=this;if(t instanceof c)return t;if(!(this instanceof c))return new c(t);if(!a){a=!0;var e=Object.keys(u),r=f._indices={};f._name=s,f._keys=e,f._defaultValues=u;for(var i=0;i Date: Fri, 23 Dec 2022 13:33:01 +0000 Subject: [PATCH 180/242] deploy: ac3a055c84131545602aec7afc556232323b6bab --- dist/immutable.d.ts | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index 7adfdeb381..bf21c42bf4 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -93,24 +93,34 @@ declare namespace Immutable { /** * @ignore + * + * Used to convert deeply all immutable types to a plain TS type. + * Using `unknown` on object instead of recursive call as we have a circular reference issue */ - export type DeepCopy = T extends Collection.Keyed + export type DeepCopy = T extends Record + ? // convert Record to DeepCopy plain JS object + { + [key in keyof R]: R[key] extends object ? unknown : R[key]; + } + : T extends Collection.Keyed ? // convert KeyedCollection to DeepCopy plain JS object { [key in KeyedKey extends string | number | symbol ? KeyedKey - : string]: DeepCopy; + : string]: V extends object ? unknown : V; } : // convert IndexedCollection or Immutable.Set to DeepCopy plain JS array T extends Collection - ? Array> + ? Array : T extends string | number // Iterable scalar types : should be kept as is ? T : T extends Iterable // Iterable are converted to plain JS array - ? Array> + ? Array : T extends object // plain JS object are converted deeply ? { - [ObjectKey in keyof T]: DeepCopy; + [ObjectKey in keyof T]: T[ObjectKey] extends object + ? unknown + : T[ObjectKey]; } : // other case : should be kept as is T; From e173fde574957609c4aecf29ada44542b410b0ef Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 23 Dec 2022 13:37:50 +0000 Subject: [PATCH 181/242] deploy: 7e33ca96d861c0a67cd7c60c814389aee2cba1dd --- bower.json | 2 +- dist/immutable.es.js | 2 +- dist/immutable.js | 2 +- dist/immutable.min.js | 4 ++-- package.json | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bower.json b/bower.json index b4e3a16828..a81944574f 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "immutable", - "version": "4.2.0", + "version": "4.2.1", "description": "Immutable Data Collections", "license": "MIT", "homepage": "https://immutable-js.com", diff --git a/dist/immutable.es.js b/dist/immutable.es.js index 0dd89ee16b..f7b18338e4 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -5886,7 +5886,7 @@ function defaultConverter(k, v) { return isIndexed(v) ? v.toList() : isKeyed(v) ? v.toMap() : v.toSet(); } -var version = "4.2.0"; +var version = "4.2.1"; var Immutable = { version: version, diff --git a/dist/immutable.js b/dist/immutable.js index 5a0b81143d..4dc54eaaea 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -5892,7 +5892,7 @@ return isIndexed(v) ? v.toList() : isKeyed(v) ? v.toMap() : v.toSet(); } - var version = "4.2.0"; + var version = "4.2.1"; var Immutable = { version: version, diff --git a/dist/immutable.min.js b/dist/immutable.min.js index f024be439b..26321b5f17 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -51,5 +51,5 @@ t,e,r)&&++o&&n(t,e,i)}),o},e.__iteratorUncached=function(n,t){var i=this;if(t)re ):this.size);var n=this.slice(0,t);return Vt(this,1===r?n:n.concat(Zt(arguments,2),this.slice(t+e)))},findLastIndex:function(t,e){e=this.findLastEntry(t,e);return e?e[0]:-1},first:function(t){return this.get(0,t)},flatten:function(t){return Vt(this,Pt(this,t,!1))},get:function(r,t){return(r=h(this,r))<0||this.size===1/0||void 0!==this.size&&this.size>2 )|0}Zr.has=Xr.includes,Zr.contains=Zr.includes,Zr.keys=Zr.values,Ur(G,Fr),Ur(Z,Gr),Ur($,Zr);var an=function(t){function e(r){return null==r?_n():kr(r)?r:_n().withMutations(function(e){var t=j(r);te(t.size),t.forEach(function(t){return e.add(t)})})}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).of=function(){return this(arguments)},e.fromKeys=function(t){return this(O(t).keySeq())},e.prototype.toString=function(){return this.__toString("OrderedSet {","}")},e}(Tr);an.isOrderedSet=kr;var cn,fn=an.prototype;function hn(t,e){var r=Object.create(fn);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function _n(){return cn=cn||hn(zr())}fn[k]=!0,fn.zip=Gr.zip,fn.zipWith=Gr.zipWith,fn.zipAll=Gr.zipAll,fn.__empty=_n,fn.__make=hn;Gr=function(u,s){var a;!function(t){if(x(t))throw Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(A(t))throw Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(null===t||"object"!=typeof t)throw Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}(u);var c=function(t){var n=this;if(t instanceof c)return t;if(!(this instanceof c))return new c(t);if(!a){a=!0;var e=Object.keys(u),r=f._indices={};f._name=s,f._keys=e,f._defaultValues=u;for(var i=0;i Date: Mon, 2 Jan 2023 11:19:11 +0000 Subject: [PATCH 182/242] deploy: 03d8b39909b7ddddb3e9740d427698ff7e747359 --- dist/immutable.js.flow | 55 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/dist/immutable.js.flow b/dist/immutable.js.flow index 251fcb1730..856591a127 100644 --- a/dist/immutable.js.flow +++ b/dist/immutable.js.flow @@ -332,6 +332,11 @@ declare class KeyedCollection extends Collection { context?: mixed ): KeyedCollection; + partition( + predicate: (value: V, key: K, iter: this) => mixed, + context?: mixed + ): [this, this]; + map( mapper: (value: V, key: K, iter: this) => M, context?: mixed @@ -484,6 +489,11 @@ declare class IndexedCollection<+T> extends Collection { context?: mixed ): IndexedCollection; + partition( + predicate: (value: T, index: number, iter: this) => mixed, + context?: mixed + ): [this, this]; + map( mapper: (value: T, index: number, iter: this) => M, context?: mixed @@ -519,6 +529,11 @@ declare class SetCollection<+T> extends Collection { context?: mixed ): SetCollection; + partition( + predicate: (value: T, value: T, iter: this) => mixed, + context?: mixed + ): [this, this]; + map( mapper: (value: T, value: T, iter: this) => M, context?: mixed @@ -570,6 +585,11 @@ declare class KeyedSeq extends Seq mixins KeyedCollection { context?: mixed ): KeyedSeq; + partition( + predicate: (value: V, key: K, iter: this) => mixed, + context?: mixed + ): [this, this]; + map( mapper: (value: V, key: K, iter: this) => M, context?: mixed @@ -612,6 +632,11 @@ declare class IndexedSeq<+T> context?: mixed ): IndexedSeq; + partition( + predicate: (value: T, index: number, iter: this) => mixed, + context?: mixed + ): [this, this]; + map( mapper: (value: T, index: number, iter: this) => M, context?: mixed @@ -729,6 +754,11 @@ declare class SetSeq<+T> extends Seq mixins SetCollection { context?: mixed ): SetSeq; + partition( + predicate: (value: T, value: T, iter: this) => mixed, + context?: mixed + ): [this, this]; + map( mapper: (value: T, value: T, iter: this) => M, context?: mixed @@ -949,6 +979,11 @@ declare class List<+T> context?: mixed ): List; + partition( + predicate: (value: T, index: number, iter: this) => mixed, + context?: mixed + ): [this, this]; + map( mapper: (value: T, index: number, iter: this) => M, context?: mixed @@ -1124,6 +1159,11 @@ declare class Map context?: mixed ): Map; + partition( + predicate: (value: V, key: K, iter: this) => mixed, + context?: mixed + ): [this, this]; + map( mapper: (value: V, key: K, iter: this) => M, context?: mixed @@ -1221,6 +1261,11 @@ declare class OrderedMap context?: mixed ): OrderedMap; + partition( + predicate: (value: V, key: K, iter: this) => mixed, + context?: mixed + ): [this, this]; + map( mapper: (value: V, key: K, iter: this) => M, context?: mixed @@ -1285,6 +1330,11 @@ declare class Set<+T> extends SetCollection { context?: mixed ): Set; + partition( + predicate: (value: T, value: T, iter: this) => mixed, + context?: mixed + ): [this, this]; + map( mapper: (value: T, value: T, iter: this) => M, context?: mixed @@ -1327,6 +1377,11 @@ declare class OrderedSet<+T> extends Set { context?: mixed ): OrderedSet; + partition( + predicate: (value: T, value: T, iter: this) => mixed, + context?: mixed + ): [this, this]; + map( mapper: (value: T, value: T, iter: this) => M, context?: mixed From 21ad37eee8d1a9478594e7aaddc37573928f5bac Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 2 Jan 2023 15:12:41 +0000 Subject: [PATCH 183/242] deploy: f172ca1f298028c25ee1fa0637b14c97439c103e --- bower.json | 2 +- dist/immutable.es.js | 2 +- dist/immutable.js | 2 +- dist/immutable.min.js | 4 ++-- package.json | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bower.json b/bower.json index a81944574f..c148bb568f 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "immutable", - "version": "4.2.1", + "version": "4.2.2", "description": "Immutable Data Collections", "license": "MIT", "homepage": "https://immutable-js.com", diff --git a/dist/immutable.es.js b/dist/immutable.es.js index f7b18338e4..4e73d612d5 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -5886,7 +5886,7 @@ function defaultConverter(k, v) { return isIndexed(v) ? v.toList() : isKeyed(v) ? v.toMap() : v.toSet(); } -var version = "4.2.1"; +var version = "4.2.2"; var Immutable = { version: version, diff --git a/dist/immutable.js b/dist/immutable.js index 4dc54eaaea..d7b928525d 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -5892,7 +5892,7 @@ return isIndexed(v) ? v.toList() : isKeyed(v) ? v.toMap() : v.toSet(); } - var version = "4.2.1"; + var version = "4.2.2"; var Immutable = { version: version, diff --git a/dist/immutable.min.js b/dist/immutable.min.js index 26321b5f17..d208f8f699 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -51,5 +51,5 @@ t,e,r)&&++o&&n(t,e,i)}),o},e.__iteratorUncached=function(n,t){var i=this;if(t)re ):this.size);var n=this.slice(0,t);return Vt(this,1===r?n:n.concat(Zt(arguments,2),this.slice(t+e)))},findLastIndex:function(t,e){e=this.findLastEntry(t,e);return e?e[0]:-1},first:function(t){return this.get(0,t)},flatten:function(t){return Vt(this,Pt(this,t,!1))},get:function(r,t){return(r=h(this,r))<0||this.size===1/0||void 0!==this.size&&this.size>2 )|0}Zr.has=Xr.includes,Zr.contains=Zr.includes,Zr.keys=Zr.values,Ur(G,Fr),Ur(Z,Gr),Ur($,Zr);var an=function(t){function e(r){return null==r?_n():kr(r)?r:_n().withMutations(function(e){var t=j(r);te(t.size),t.forEach(function(t){return e.add(t)})})}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).of=function(){return this(arguments)},e.fromKeys=function(t){return this(O(t).keySeq())},e.prototype.toString=function(){return this.__toString("OrderedSet {","}")},e}(Tr);an.isOrderedSet=kr;var cn,fn=an.prototype;function hn(t,e){var r=Object.create(fn);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function _n(){return cn=cn||hn(zr())}fn[k]=!0,fn.zip=Gr.zip,fn.zipWith=Gr.zipWith,fn.zipAll=Gr.zipAll,fn.__empty=_n,fn.__make=hn;Gr=function(u,s){var a;!function(t){if(x(t))throw Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(A(t))throw Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(null===t||"object"!=typeof t)throw Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}(u);var c=function(t){var n=this;if(t instanceof c)return t;if(!(this instanceof c))return new c(t);if(!a){a=!0;var e=Object.keys(u),r=f._indices={};f._name=s,f._keys=e,f._defaultValues=u;for(var i=0;i Date: Wed, 1 Feb 2023 20:21:48 +0000 Subject: [PATCH 184/242] deploy: 0d2f2baa0244b8bdee571b67e7fc927ad3878e42 --- dist/immutable.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index bf21c42bf4..75d9797acb 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -4574,7 +4574,7 @@ declare namespace Immutable { ): this; /** - * Returns a `Collection.Keyed` of `Collection.Keyeds`, grouped by the return + * Returns a `Map` of `Collection`, grouped by the return * value of the `grouper` function. * * Note: This is always an eager operation. @@ -4600,7 +4600,7 @@ declare namespace Immutable { groupBy( grouper: (value: V, key: K, iter: this) => G, context?: unknown - ): /*Map*/ Seq.Keyed>; + ): Map; // Side effects From 6b6df8ad7d0b3a1bc61b251598b2a70eef7092b4 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 2 Feb 2023 20:13:10 +0000 Subject: [PATCH 185/242] deploy: d2d5819cb458861e54c9e00f0470cca59cc42063 --- bower.json | 2 +- dist/immutable.es.js | 2 +- dist/immutable.js | 2 +- dist/immutable.min.js | 4 ++-- package.json | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bower.json b/bower.json index c148bb568f..3451320feb 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "immutable", - "version": "4.2.2", + "version": "4.2.3", "description": "Immutable Data Collections", "license": "MIT", "homepage": "https://immutable-js.com", diff --git a/dist/immutable.es.js b/dist/immutable.es.js index 4e73d612d5..fe3e88b011 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -5886,7 +5886,7 @@ function defaultConverter(k, v) { return isIndexed(v) ? v.toList() : isKeyed(v) ? v.toMap() : v.toSet(); } -var version = "4.2.2"; +var version = "4.2.3"; var Immutable = { version: version, diff --git a/dist/immutable.js b/dist/immutable.js index d7b928525d..0a923ba8bb 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -5892,7 +5892,7 @@ return isIndexed(v) ? v.toList() : isKeyed(v) ? v.toMap() : v.toSet(); } - var version = "4.2.2"; + var version = "4.2.3"; var Immutable = { version: version, diff --git a/dist/immutable.min.js b/dist/immutable.min.js index d208f8f699..cfba1df0de 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -51,5 +51,5 @@ t,e,r)&&++o&&n(t,e,i)}),o},e.__iteratorUncached=function(n,t){var i=this;if(t)re ):this.size);var n=this.slice(0,t);return Vt(this,1===r?n:n.concat(Zt(arguments,2),this.slice(t+e)))},findLastIndex:function(t,e){e=this.findLastEntry(t,e);return e?e[0]:-1},first:function(t){return this.get(0,t)},flatten:function(t){return Vt(this,Pt(this,t,!1))},get:function(r,t){return(r=h(this,r))<0||this.size===1/0||void 0!==this.size&&this.size>2 )|0}Zr.has=Xr.includes,Zr.contains=Zr.includes,Zr.keys=Zr.values,Ur(G,Fr),Ur(Z,Gr),Ur($,Zr);var an=function(t){function e(r){return null==r?_n():kr(r)?r:_n().withMutations(function(e){var t=j(r);te(t.size),t.forEach(function(t){return e.add(t)})})}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).of=function(){return this(arguments)},e.fromKeys=function(t){return this(O(t).keySeq())},e.prototype.toString=function(){return this.__toString("OrderedSet {","}")},e}(Tr);an.isOrderedSet=kr;var cn,fn=an.prototype;function hn(t,e){var r=Object.create(fn);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function _n(){return cn=cn||hn(zr())}fn[k]=!0,fn.zip=Gr.zip,fn.zipWith=Gr.zipWith,fn.zipAll=Gr.zipAll,fn.__empty=_n,fn.__make=hn;Gr=function(u,s){var a;!function(t){if(x(t))throw Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(A(t))throw Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(null===t||"object"!=typeof t)throw Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}(u);var c=function(t){var n=this;if(t instanceof c)return t;if(!(this instanceof c))return new c(t);if(!a){a=!0;var e=Object.keys(u),r=f._indices={};f._name=s,f._keys=e,f._defaultValues=u;for(var i=0;i Date: Fri, 3 Feb 2023 16:56:34 +0000 Subject: [PATCH 186/242] deploy: 5e2379b82e5be71a6ff839c92964e4913f16e5fc --- dist/immutable.d.ts | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index 75d9797acb..f343aa06ff 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -5160,12 +5160,39 @@ declare namespace Immutable { */ function fromJS( jsValue: unknown, - reviver?: ( + reviver: ( key: string | number, sequence: Collection.Keyed | Collection.Indexed, path?: Array ) => unknown ): Collection; + function fromJS( + jsValue: JSValue, + reviver?: undefined + ): FromJS; + + type FromJS = JSValue extends FromJSNoTransform + ? JSValue + : JSValue extends Array + ? FromJSArray + : JSValue extends {} + ? FromJSObject + : any; + + type FromJSNoTransform = + | Collection + | number + | string + | null + | undefined; + + type FromJSArray = JSValue extends Array + ? List> + : never; + + type FromJSObject = JSValue extends {} + ? Map> + : never; /** * Value equality check with semantics similar to `Object.is`, but treats From 9e2e9c1c630186ce320f7083f61ae4ca88fffdcc Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 6 Feb 2023 08:15:39 +0000 Subject: [PATCH 187/242] deploy: af0a387c75a70d9fc21a1ebf78d442bd7650778d --- bower.json | 2 +- dist/immutable.es.js | 2 +- dist/immutable.js | 2 +- dist/immutable.min.js | 4 ++-- package.json | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bower.json b/bower.json index 3451320feb..0b7f840048 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "immutable", - "version": "4.2.3", + "version": "4.2.4", "description": "Immutable Data Collections", "license": "MIT", "homepage": "https://immutable-js.com", diff --git a/dist/immutable.es.js b/dist/immutable.es.js index fe3e88b011..cf5d2a30aa 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -5886,7 +5886,7 @@ function defaultConverter(k, v) { return isIndexed(v) ? v.toList() : isKeyed(v) ? v.toMap() : v.toSet(); } -var version = "4.2.3"; +var version = "4.2.4"; var Immutable = { version: version, diff --git a/dist/immutable.js b/dist/immutable.js index 0a923ba8bb..62c9b35553 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -5892,7 +5892,7 @@ return isIndexed(v) ? v.toList() : isKeyed(v) ? v.toMap() : v.toSet(); } - var version = "4.2.3"; + var version = "4.2.4"; var Immutable = { version: version, diff --git a/dist/immutable.min.js b/dist/immutable.min.js index cfba1df0de..11c4f68ea7 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -51,5 +51,5 @@ t,e,r)&&++o&&n(t,e,i)}),o},e.__iteratorUncached=function(n,t){var i=this;if(t)re ):this.size);var n=this.slice(0,t);return Vt(this,1===r?n:n.concat(Zt(arguments,2),this.slice(t+e)))},findLastIndex:function(t,e){e=this.findLastEntry(t,e);return e?e[0]:-1},first:function(t){return this.get(0,t)},flatten:function(t){return Vt(this,Pt(this,t,!1))},get:function(r,t){return(r=h(this,r))<0||this.size===1/0||void 0!==this.size&&this.size>2 )|0}Zr.has=Xr.includes,Zr.contains=Zr.includes,Zr.keys=Zr.values,Ur(G,Fr),Ur(Z,Gr),Ur($,Zr);var an=function(t){function e(r){return null==r?_n():kr(r)?r:_n().withMutations(function(e){var t=j(r);te(t.size),t.forEach(function(t){return e.add(t)})})}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).of=function(){return this(arguments)},e.fromKeys=function(t){return this(O(t).keySeq())},e.prototype.toString=function(){return this.__toString("OrderedSet {","}")},e}(Tr);an.isOrderedSet=kr;var cn,fn=an.prototype;function hn(t,e){var r=Object.create(fn);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function _n(){return cn=cn||hn(zr())}fn[k]=!0,fn.zip=Gr.zip,fn.zipWith=Gr.zipWith,fn.zipAll=Gr.zipAll,fn.__empty=_n,fn.__make=hn;Gr=function(u,s){var a;!function(t){if(x(t))throw Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(A(t))throw Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(null===t||"object"!=typeof t)throw Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}(u);var c=function(t){var n=this;if(t instanceof c)return t;if(!(this instanceof c))return new c(t);if(!a){a=!0;var e=Object.keys(u),r=f._indices={};f._name=s,f._keys=e,f._defaultValues=u;for(var i=0;i Date: Thu, 9 Feb 2023 23:21:11 +0000 Subject: [PATCH 188/242] deploy: f88e4f9899bcd06c56df5d2c01cd7a34b2ba7499 --- dist/immutable.d.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index f343aa06ff..38ecac080a 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -424,7 +424,10 @@ declare namespace Immutable { * @see `Map#update` */ update(index: number, notSetValue: T, updater: (value: T) => T): this; - update(index: number, updater: (value: T | undefined) => T): this; + update( + index: number, + updater: (value: T | undefined) => T | undefined + ): this; update(updater: (value: this) => R): R; /** @@ -1001,7 +1004,7 @@ declare namespace Immutable { * Note: `update(key)` can be used in `withMutations`. */ update(key: K, notSetValue: V, updater: (value: V) => V): this; - update(key: K, updater: (value: V | undefined) => V): this; + update(key: K, updater: (value: V | undefined) => V | undefined): this; update(updater: (value: this) => R): R; /** @@ -5571,7 +5574,7 @@ declare namespace Immutable { function update>( collection: C, key: K, - updater: (value: V | undefined) => V + updater: (value: V | undefined) => V | undefined ): C; function update, NSV>( collection: C, @@ -5598,7 +5601,7 @@ declare namespace Immutable { function update( collection: Array, key: number, - updater: (value: V) => V + updater: (value: V | undefined) => V | undefined ): Array; function update( collection: Array, From acacec1d6ecff727834e18d643021ca10ff9524b Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 13 Feb 2023 06:47:50 +0000 Subject: [PATCH 189/242] deploy: 14832cad4b59520cadff2cece3cf4b9ad42369aa --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9b09af848c..203bfcc38f 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ additional specific topics. Can't find something? Open an [issue][]. - [Introduction](#introduction) - [Getting started](#getting-started) - [The case for Immutability](#the-case-for-immutability) -- [JavaScript-first API](#javaScript-first-api) +- [JavaScript-first API](#javascript-first-api) - [Nested Structures](#nested-structures) - [Equality treats Collections as Values](#equality-treats-collections-as-values) - [Batching Mutations](#batching-mutations) From 78687071389fe40f91da1a2d6e0f7fc7a9c2228c Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 10 Mar 2023 15:12:37 +0000 Subject: [PATCH 190/242] deploy: 376944d00f9d040d91870c92737226ea07a03882 --- dist/immutable.d.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index 38ecac080a..ead7f225f9 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -5161,18 +5161,18 @@ declare namespace Immutable { * [3]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_iterable_protocol * "The iterable protocol" */ + function fromJS( + jsValue: JSValue, + reviver?: undefined + ): FromJS; function fromJS( jsValue: unknown, - reviver: ( + reviver?: ( key: string | number, sequence: Collection.Keyed | Collection.Indexed, path?: Array ) => unknown ): Collection; - function fromJS( - jsValue: JSValue, - reviver?: undefined - ): FromJS; type FromJS = JSValue extends FromJSNoTransform ? JSValue From f80f61622c887683ed22932ff6ac3c53d9dd74af Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 10 Mar 2023 15:14:06 +0000 Subject: [PATCH 191/242] deploy: f0f393289ac37ece2149365e920963611cd995b8 --- dist/immutable.d.ts | 34 ++++++++++++++++++++++++------ dist/immutable.es.js | 8 ++++++- dist/immutable.js | 7 ++++++ dist/immutable.js.flow | 22 +++++++++++++------ dist/immutable.min.js | 48 +++++++++++++++++++++--------------------- 5 files changed, 82 insertions(+), 37 deletions(-) diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index ead7f225f9..7ae4eec33d 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -125,6 +125,27 @@ declare namespace Immutable { : // other case : should be kept as is T; + /** + * Describes which item in a pair should be placed first when sorting + * + * @ignore + */ + export enum PairSorting { + LeftThenRight = -1, + RightThenLeft = +1, + } + + /** + * Function comparing two items of the same type. It can return: + * + * * a PairSorting value, to indicate whether the left-hand item or the right-hand item should be placed before the other + * + * * the traditional numeric return value - especially -1, 0, or 1 + * + * @ignore + */ + export type Comparator = (left: T, right: T) => PairSorting | number; + /** * Lists are ordered indexed dense collections, much like a JavaScript * Array. @@ -4526,6 +4547,7 @@ declare namespace Immutable { * * Returns `0` if the elements should not be swapped. * * Returns `-1` (or any negative number) if `valueA` comes before `valueB` * * Returns `1` (or any positive number) if `valueA` comes after `valueB` + * * Alternatively, can return a value of the `PairSorting` enum type * * Is pure, i.e. it must always return the same value for the same pair * of values. * @@ -4548,7 +4570,7 @@ declare namespace Immutable { * * Note: This is always an eager operation. */ - sort(comparator?: (valueA: V, valueB: V) => number): this; + sort(comparator?: Comparator): this; /** * Like `sort`, but also accepts a `comparatorValueMapper` which allows for @@ -4573,7 +4595,7 @@ declare namespace Immutable { */ sortBy( comparatorValueMapper: (value: V, key: K, iter: this) => C, - comparator?: (valueA: C, valueB: C) => number + comparator?: Comparator ): this; /** @@ -4972,7 +4994,7 @@ declare namespace Immutable { * If `comparator` returns 0 and either value is NaN, undefined, or null, * that value will be returned. */ - max(comparator?: (valueA: V, valueB: V) => number): V | undefined; + max(comparator?: Comparator): V | undefined; /** * Like `max`, but also accepts a `comparatorValueMapper` which allows for @@ -4991,7 +5013,7 @@ declare namespace Immutable { */ maxBy( comparatorValueMapper: (value: V, key: K, iter: this) => C, - comparator?: (valueA: C, valueB: C) => number + comparator?: Comparator ): V | undefined; /** @@ -5009,7 +5031,7 @@ declare namespace Immutable { * If `comparator` returns 0 and either value is NaN, undefined, or null, * that value will be returned. */ - min(comparator?: (valueA: V, valueB: V) => number): V | undefined; + min(comparator?: Comparator): V | undefined; /** * Like `min`, but also accepts a `comparatorValueMapper` which allows for @@ -5028,7 +5050,7 @@ declare namespace Immutable { */ minBy( comparatorValueMapper: (value: V, key: K, iter: this) => C, - comparator?: (valueA: C, valueB: C) => number + comparator?: Comparator ): V | undefined; // Comparison diff --git a/dist/immutable.es.js b/dist/immutable.es.js index cf5d2a30aa..f201c9e89d 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -5504,6 +5504,11 @@ function emptyOrderedSet() { ); } +var PairSorting = { + LeftThenRight: -1, + RightThenLeft: +1, +}; + function throwOnInvalidDefaultValues(defaultValues) { if (isRecord(defaultValues)) { throw new Error( @@ -5902,6 +5907,7 @@ var Immutable = { Stack: Stack, Set: Set, OrderedSet: OrderedSet, + PairSorting: PairSorting, Record: Record, Range: Range, @@ -5948,4 +5954,4 @@ var Immutable = { var Iterable = Collection; export default Immutable; -export { Collection, Iterable, List, Map, OrderedMap, OrderedSet, Range, Record, Repeat, Seq, Set, Stack, fromJS, get, getIn$1 as getIn, has, hasIn$1 as hasIn, hash, is, isAssociative, isCollection, isImmutable, isIndexed, isKeyed, isList, isMap, isOrdered, isOrderedMap, isOrderedSet, isPlainObject, isRecord, isSeq, isSet, isStack, isValueObject, merge, mergeDeep$1 as mergeDeep, mergeDeepWith$1 as mergeDeepWith, mergeWith, remove, removeIn, set, setIn$1 as setIn, update$1 as update, updateIn$1 as updateIn, version }; +export { Collection, Iterable, List, Map, OrderedMap, OrderedSet, PairSorting, Range, Record, Repeat, Seq, Set, Stack, fromJS, get, getIn$1 as getIn, has, hasIn$1 as hasIn, hash, is, isAssociative, isCollection, isImmutable, isIndexed, isKeyed, isList, isMap, isOrdered, isOrderedMap, isOrderedSet, isPlainObject, isRecord, isSeq, isSet, isStack, isValueObject, merge, mergeDeep$1 as mergeDeep, mergeDeepWith$1 as mergeDeepWith, mergeWith, remove, removeIn, set, setIn$1 as setIn, update$1 as update, updateIn$1 as updateIn, version }; diff --git a/dist/immutable.js b/dist/immutable.js index 62c9b35553..c59890c27a 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -5510,6 +5510,11 @@ ); } + var PairSorting = { + LeftThenRight: -1, + RightThenLeft: +1, + }; + function throwOnInvalidDefaultValues(defaultValues) { if (isRecord(defaultValues)) { throw new Error( @@ -5908,6 +5913,7 @@ Stack: Stack, Set: Set, OrderedSet: OrderedSet, + PairSorting: PairSorting, Record: Record, Range: Range, @@ -5959,6 +5965,7 @@ exports.Map = Map; exports.OrderedMap = OrderedMap; exports.OrderedSet = OrderedSet; + exports.PairSorting = PairSorting; exports.Range = Range; exports.Record = Record; exports.Repeat = Repeat; diff --git a/dist/immutable.js.flow b/dist/immutable.js.flow index 856591a127..67a496f29c 100644 --- a/dist/immutable.js.flow +++ b/dist/immutable.js.flow @@ -60,6 +60,14 @@ type $IterableOf = $Call< C >; +const PairSorting: $ReadOnly<{ LeftThenRight: number, RightThenLeft: number }> = + { + LeftThenRight: -1, + RightThenLeft: +1, + }; + +type Comparator = (left: T, right: T) => number; + declare class _Collection implements ValueObject { equals(other: mixed): boolean; hashCode(): number; @@ -129,11 +137,11 @@ declare class _Collection implements ValueObject { entrySeq(): IndexedSeq<[K, V]>; reverse(): this; - sort(comparator?: (valueA: V, valueB: V) => number): this; + sort(comparator?: Comparator): this; sortBy( comparatorValueMapper: (value: V, key: K, iter: this) => C, - comparator?: (valueA: C, valueB: C) => number + comparator?: Comparator ): this; groupBy( @@ -238,15 +246,15 @@ declare class _Collection implements ValueObject { keyOf(searchValue: V): K | void; lastKeyOf(searchValue: V): K | void; - max(comparator?: (valueA: V, valueB: V) => number): V; + max(comparator?: Comparator): V; maxBy( comparatorValueMapper: (value: V, key: K, iter: this) => C, - comparator?: (valueA: C, valueB: C) => number + comparator?: Comparator ): V; - min(comparator?: (valueA: V, valueB: V) => number): V; + min(comparator?: Comparator): V; minBy( comparatorValueMapper: (value: V, key: K, iter: this) => C, - comparator?: (valueA: C, valueB: C) => number + comparator?: Comparator ): V; isSubset(iter: Iterable): boolean; @@ -2351,6 +2359,7 @@ export default { Map, OrderedMap, OrderedSet, + PairSorting, Range, Repeat, Record, @@ -2387,6 +2396,7 @@ export default { }; export type { + Comparator, KeyedCollection, IndexedCollection, SetCollection, diff --git a/dist/immutable.min.js b/dist/immutable.min.js index 11c4f68ea7..3cf87e30aa 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -21,35 +21,35 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).Immutable={})}(this,function(t){"use strict";var e="delete",d=5,l=1<>>0;if(""+r!==e||4294967295==r)return NaN;e=r}return e<0?c(t)+e:e}function r(){return!0}function p(t,e,r){return(0===t&&!i(t)||void 0!==r&&t<=-r)&&(void 0===e||void 0!==r&&r<=e)}function y(t,e){return n(t,e,0)}function w(t,e){return n(t,e,e)}function n(t,e,r){return void 0===t?r:i(t)?e===1/0?e:0|Math.max(0,e+t):void 0===e||e===t?t:0|Math.min(e,t)}function i(t){return t<0||0===t&&1/t==-1/0}var o="@@__IMMUTABLE_ITERABLE__@@";function f(t){return!(!t||!t[o])}var s="@@__IMMUTABLE_KEYED__@@";function a(t){return!(!t||!t[s])}var S="@@__IMMUTABLE_INDEXED__@@";function z(t){return!(!t||!t[S])}function b(t){return a(t)||z(t)}function I(t){return f(t)?t:F(t)}var O=function(t){function e(t){return a(t)?t:G(t)}return e.__proto__=t,(e.prototype=Object.create(t.prototype)).constructor=e}(I),E=function(t){function e(t){return z(t)?t:Z(t)}return e.__proto__=t,(e.prototype=Object.create(t.prototype)).constructor=e}(I),j=function(t){function e(t){return f(t)&&!b(t)?t:$(t)}return e.__proto__=t,(e.prototype=Object.create(t.prototype)).constructor=e}(I);I.Keyed=O,I.Indexed=E,I.Set=j;var q="@@__IMMUTABLE_SEQ__@@";function M(t){return!(!t||!t[q])}var D="@@__IMMUTABLE_RECORD__@@";function x(t){return!(!t||!t[D])}function A(t){return f(t)||x(t)}var k="@@__IMMUTABLE_ORDERED__@@";function R(t){return!(!t||!t[k])}var U=0,K=1,T=2,C="function"==typeof Symbol&&Symbol.iterator,L="@@iterator",B=C||L,P=function(t){this.next=t};function W(t,e,r,n){r=0===t?e:1===t?r:[e,r];return n?n.value=r:n={value:r,done:!1},n}function N(){return{value:void 0,done:!0}}function H(t){return Array.isArray(t -)||Y(t)}function J(t){return t&&"function"==typeof t.next}function V(t){var e=Y(t);return e&&e.call(t)}function Y(t){t=t&&(C&&t[C]||t[L]);if("function"==typeof t)return t}P.prototype.toString=function(){return"[Iterator]"},P.KEYS=U,P.VALUES=K,P.ENTRIES=T,P.prototype.inspect=P.prototype.toSource=function(){return""+this},P.prototype[B]=function(){return this};var Q=Object.prototype.hasOwnProperty;function X(t){return Array.isArray(t)||"string"==typeof t||t&&"object"==typeof t&&Number.isInteger(t.length)&&0<=t.length&&(0===t.length?1===Object.keys(t).length:t.hasOwnProperty(t.length-1))}var F=function(t){function e(t){return null==t?it():A(t)?t.toSeq():function(t){var e=st(t);if(e)return function(t){var e=Y(t);return e&&e===t.entries}(t)?e.fromEntrySeq():function(t){var e=Y(t);return e&&e===t.keys}(t)?e.toSetSeq():e;if("object"!=typeof t)throw new TypeError("Expected Array or collection object of values, or keyed object: "+t);return new et(t)}(t)}return e.__proto__=t,((e.prototype=Object.create(t.prototype)).constructor=e).prototype.toSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq {","}")},e.prototype.cacheResult=function(){return!this._cache&&this.__iterateUncached&&(this._cache=this.entrySeq().toArray(),this.size=this._cache.length),this},e.prototype.__iterate=function(t,e){var r=this._cache;if(r){for(var n=r.length,i=0;i!==n;){var o=r[e?n-++i:i++];if(!1===t(o[1],o[0],this))break}return i}return this.__iterateUncached(t,e)},e.prototype.__iterator=function(e,r){var n=this._cache;if(n){var i=n.length,o=0;return new P(function(){if(o===i)return N();var t=n[r?i-++o:o++];return W(e,t[0],t[1])})}return this.__iteratorUncached(e,r)},e}(I),G=function(t){function e(t){return null==t?it().toKeyedSeq():f(t)?a(t)?t.toSeq():t.fromEntrySeq():x(t)?t.toSeq():ot(t)}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).prototype.toKeyedSeq=function(){return this},e}(F),Z=function(t){function e(t){return null==t?it():f(t)?a(t)?t.entrySeq():t.toIndexedSeq():x(t +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).Immutable={})}(this,function(t){"use strict";var e="delete",d=5,l=1<>>0;if(""+r!==e||4294967295==r)return NaN;e=r}return e<0?c(t)+e:e}function r(){return!0}function p(t,e,r){return(0===t&&!i(t)||void 0!==r&&t<=-r)&&(void 0===e||void 0!==r&&r<=e)}function y(t,e){return n(t,e,0)}function w(t,e){return n(t,e,e)}function n(t,e,r){return void 0===t?r:i(t)?e===1/0?e:0|Math.max(0,e+t):void 0===e||e===t?t:0|Math.min(e,t)}function i(t){return t<0||0===t&&1/t==-1/0}var o="@@__IMMUTABLE_ITERABLE__@@";function f(t){return!(!t||!t[o])}var s="@@__IMMUTABLE_KEYED__@@";function a(t){return!(!t||!t[s])}var S="@@__IMMUTABLE_INDEXED__@@";function z(t){return!(!t||!t[S])}function b(t){return a(t)||z(t)}function I(t){return f(t)?t:F(t)}var O=function(t){function e(t){return a(t)?t:G(t)}return e.__proto__=t,(e.prototype=Object.create(t.prototype)).constructor=e}(I),E=function(t){function e(t){return z(t)?t:Z(t)}return e.__proto__=t,(e.prototype=Object.create(t.prototype)).constructor=e}(I),j=function(t){function e(t){return f(t)&&!b(t)?t:$(t)}return e.__proto__=t,(e.prototype=Object.create(t.prototype)).constructor=e}(I);I.Keyed=O,I.Indexed=E,I.Set=j;var q="@@__IMMUTABLE_SEQ__@@";function M(t){return!(!t||!t[q])}var D="@@__IMMUTABLE_RECORD__@@";function x(t){return!(!t||!t[D])}function A(t){return f(t)||x(t)}var k="@@__IMMUTABLE_ORDERED__@@";function R(t){return!(!t||!t[k])}var U=0,T=1,K=2,L="function"==typeof Symbol&&Symbol.iterator,C="@@iterator",B=L||C,P=function(t){this.next=t};function W(t,e,r,n){r=0===t?e:1===t?r:[e,r];return n?n.value=r:n={value:r,done:!1},n}function N(){return{value:void 0,done:!0}}function H(t){return Array.isArray(t +)||Y(t)}function J(t){return t&&"function"==typeof t.next}function V(t){var e=Y(t);return e&&e.call(t)}function Y(t){t=t&&(L&&t[L]||t[C]);if("function"==typeof t)return t}P.prototype.toString=function(){return"[Iterator]"},P.KEYS=U,P.VALUES=T,P.ENTRIES=K,P.prototype.inspect=P.prototype.toSource=function(){return""+this},P.prototype[B]=function(){return this};var Q=Object.prototype.hasOwnProperty;function X(t){return Array.isArray(t)||"string"==typeof t||t&&"object"==typeof t&&Number.isInteger(t.length)&&0<=t.length&&(0===t.length?1===Object.keys(t).length:t.hasOwnProperty(t.length-1))}var F=function(t){function e(t){return null==t?it():A(t)?t.toSeq():function(t){var e=st(t);if(e)return function(t){var e=Y(t);return e&&e===t.entries}(t)?e.fromEntrySeq():function(t){var e=Y(t);return e&&e===t.keys}(t)?e.toSetSeq():e;if("object"!=typeof t)throw new TypeError("Expected Array or collection object of values, or keyed object: "+t);return new et(t)}(t)}return e.__proto__=t,((e.prototype=Object.create(t.prototype)).constructor=e).prototype.toSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq {","}")},e.prototype.cacheResult=function(){return!this._cache&&this.__iterateUncached&&(this._cache=this.entrySeq().toArray(),this.size=this._cache.length),this},e.prototype.__iterate=function(t,e){var r=this._cache;if(r){for(var n=r.length,i=0;i!==n;){var o=r[e?n-++i:i++];if(!1===t(o[1],o[0],this))break}return i}return this.__iterateUncached(t,e)},e.prototype.__iterator=function(e,r){var n=this._cache;if(n){var i=n.length,o=0;return new P(function(){if(o===i)return N();var t=n[r?i-++o:o++];return W(e,t[0],t[1])})}return this.__iteratorUncached(e,r)},e}(I),G=function(t){function e(t){return null==t?it().toKeyedSeq():f(t)?a(t)?t.toSeq():t.fromEntrySeq():x(t)?t.toSeq():ot(t)}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).prototype.toKeyedSeq=function(){return this},e}(F),Z=function(t){function e(t){return null==t?it():f(t)?a(t)?t.entrySeq():t.toIndexedSeq():x(t )?t.toSeq().entrySeq():ut(t)}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).of=function(){return e(arguments)},e.prototype.toIndexedSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq [","]")},e}(F),$=function(t){function e(t){return(f(t)&&!b(t)?t:Z(t)).toSetSeq()}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).of=function(){return e(arguments)},e.prototype.toSetSeq=function(){return this},e}(F);F.isSeq=M,F.Keyed=G,F.Set=$,F.Indexed=Z,F.prototype[q]=!0;var tt=function(t){function e(t){this._array=t,this.size=t.length}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).prototype.get=function(t,e){return this.has(t)?this._array[h(this,t)]:e},e.prototype.__iterate=function(t,e){for(var r=this._array,n=r.length,i=0;i!==n;){var o=e?n-++i:i++;if(!1===t(r[o],o,this))break}return i},e.prototype.__iterator=function(e,r){var n=this._array,i=n.length,o=0;return new P(function(){if(o===i)return N();var t=r?i-++o:o++;return W(e,t,n[t])})},e}(Z),et=function(t){function e(t){var e=Object.keys(t).concat(Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(t):[]);this._object=t,this._keys=e,this.size=e.length}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).prototype.get=function(t,e){return void 0===e||this.has(t)?this._object[t]:e},e.prototype.has=function(t){return Q.call(this._object,t)},e.prototype.__iterate=function(t,e){for(var r=this._object,n=this._keys,i=n.length,o=0;o!==i;){var u=n[e?i-++o:o++];if(!1===t(r[u],u,this))break}return o},e.prototype.__iterator=function(e,r){var n=this._object,i=this._keys,o=i.length,u=0;return new P(function(){if(u===o)return N();var t=i[r?o-++u:u++];return W(e,t,n[t])})},e}(G);et.prototype[k]=!0;var rt,nt=function(t){function e(t){this._collection=t,this.size=t.length||t.size}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).prototype.__iterateUncached=function(t,e){ if(e)return this.cacheResult().__iterate(t,e);var r,n=V(this._collection),i=0;if(J(n))for(;!(r=n.next()).done&&!1!==t(r.value,i++,this););return i},e.prototype.__iteratorUncached=function(e,t){if(t)return this.cacheResult().__iterator(e,t);var r=V(this._collection);if(!J(r))return new P(N);var n=0;return new P(function(){var t=r.next();return t.done?t:W(e,n++,t.value)})},e}(Z);function it(){return rt=rt||new tt([])}function ot(t){var e=st(t);if(e)return e.fromEntrySeq();if("object"==typeof t)return new et(t);throw new TypeError("Expected Array or collection object of [k, v] entries, or keyed object: "+t)}function ut(t){var e=st(t);if(e)return e;throw new TypeError("Expected Array or collection object of values: "+t)}function st(t){return X(t)?new tt(t):H(t)?new nt(t):void 0}var at="@@__IMMUTABLE_MAP__@@";function ct(t){return!(!t||!t[at])}function ft(t){return ct(t)&&R(t)}function ht(t){return!(!t||"function"!=typeof t.equals||"function"!=typeof t.hashCode)}function _t(t,e){if(t===e||t!=t&&e!=e)return!0;if(!t||!e)return!1;if("function"==typeof t.valueOf&&"function"==typeof e.valueOf){if((t=t.valueOf())===(e=e.valueOf())||t!=t&&e!=e)return!0;if(!t||!e)return!1}return!!(ht(t)&&ht(e)&&t.equals(e))}var pt="function"==typeof Math.imul&&-2==Math.imul(4294967295,2)?Math.imul:function(t,e){var r=65535&(t|=0),n=65535&(e|=0);return r*n+((t>>>16)*n+r*(e>>>16)<<16>>>0)|0};function lt(t){return t>>>1&1073741824|3221225471&t}var vt=Object.prototype.valueOf;function yt(t){if(null==t)return dt(t);if("function"==typeof t.hashCode)return lt(t.hashCode(t));var e,r=(e=t).valueOf!==vt&&"function"==typeof e.valueOf?e.valueOf(e):e;if(null==r)return dt(r);switch(typeof r){case"boolean":return r?1108378657:1108378656;case"number":return function(t){if(t!=t||t===1/0)return 0;var e=0|t;e!==t&&(e^=4294967295*t);for(;4294967295f)return N();var t=r.next();return a||e===K||t.done?t:W(e,i-1,e===U?void 0:t.value[1],t)})},r}function Bt(e,c,f,h){var t=Xt(e);return t.__iterateUncached=function(n,t){var i=this;if(t)return this.cacheResult().__iterate(n,t);var o=!0,u=0;return e.__iterate(function(t,e,r){if(!(o=o&&c.call(f,t,e,r)))return u++,n(t,h?e:u-1,i)}),u},t.__iteratorUncached=function(i,t){var o=this;if(t)return this.cacheResult().__iterator(i,t);var u=e.__iterator(T,t),s=!0,a=0;return new P(function(){var t;do{if((t=u.next()).done)return h||i===K?t:W(i,a++,i===U?void 0:t.value[1],t);var e=t.value,r=e[0],n=e[1];s=s&&c.call(f,n,r,o)}while(s);return i===T?t:W(i,r,n,t)})},t}function Pt(t,s,a){var c=Xt(t);return c.__iterateUncached=function(i,e){if(e)return this.cacheResult().__iterate(i,e);var o=0,u=!1;return function r(t,n){t.__iterate(function(t,e){return(!s||nf)return N();var t=r.next();return a||e===T||t.done?t:W(e,i-1,e===U?void 0:t.value[1],t)})},r}function Bt(e,c,f,h){var t=Xt(e);return t.__iterateUncached=function(n,t){var i=this;if(t)return this.cacheResult().__iterate(n,t);var o=!0,u=0;return e.__iterate(function(t,e,r){if(!(o=o&&c.call(f,t,e,r)))return u++,n(t,h?e:u-1,i)}),u},t.__iteratorUncached=function(i,t){var o=this;if(t)return this.cacheResult().__iterator(i,t);var u=e.__iterator(K,t),s=!0,a=0;return new P(function(){var t;do{if((t=u.next()).done)return h||i===T?t:W(i,a++,i===U?void 0:t.value[1],t);var e=t.value,r=e[0],n=e[1];s=s&&c.call(f,n,r,o)}while(s);return i===K?t:W(i,r,n,t)})},t}function Pt(t,s,a){var c=Xt(t);return c.__iterateUncached=function(i,e){if(e)return this.cacheResult().__iterate(i,e);var o=0,u=!1;return function r(t,n){t.__iterate(function(t,e){return(!s||n>>t)&g),o=this.bitmap;return 0==(o&i)?n:this.nodes[$e(o&i-1)].get(t+d,e,r,n)},Le.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=yt(n));var s=(0===e?r:r>>>e)&g,a=1<>>=1)u[s]=1&r?e[o++]:void 0;return u[n]=i,new Be(t,o+1,u)}(t,_,c,s,u);if(f&&!u&&2===_.length&&Ge(_[1^h]))return _[1^h];if(f&&u&&1===_.length&&Ge(u))return u;s=t&&t===this.ownerID,a=f?u?c:c^a:c|a,u=f?u?tr(_,h,u,s):function(t,e,r){var n=t.length-1;if(r&&e===n)return t.pop(),t;for(var i=Array(n),o=0,u=0;u>>t)&g];return i?i.get(t+d,e,r,n):n},Be.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=yt(n));var s=(0===e?r:r>>>e)&g,a=this.nodes,c=a[s];if(i===v&&!c)return this;o=Fe(c,t,e+d,r,n,i,o,u);if(o===c)return this;u=this.count;if(c){if(!o&&--u>>r)&g,u=(0===r?n:n>>>r)&g,t=o==u?[Ze(t,e,r+d,n,i)]:(i=new We(e,n,i),o>1&1431655765))+(t>>2&858993459))+(t>>4)&252645135,t+=t>>8,127&(t+=t>>16)}function tr(t,e,r,n){t=n?t:Zt(t);return t[e]=r,t}var er=l/4,rr=l/2,nr=l/4,ir="@@__IMMUTABLE_LIST__@@";function or(t){return!(!t||!t[ir])}var ur=function(o){function t(t){var e=pr();if(null==t)return e;if(or(t))return t;var n=o(t),i=n.size;return 0===i?e:(te(i),0>>t)&g),o=this.bitmap;return 0==(o&i)?n:this.nodes[$e(o&i-1)].get(t+d,e,r,n)},Ce.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=yt(n));var s=(0===e?r:r>>>e)&g,a=1<>>=1)u[s]=1&r?e[o++]:void 0;return u[n]=i,new Be(t,o+1,u)}(t,_,c,s,u);if(f&&!u&&2===_.length&&Ge(_[1^h]))return _[1^h];if(f&&u&&1===_.length&&Ge(u))return u;s=t&&t===this.ownerID,a=f?u?c:c^a:c|a,u=f?u?tr(_,h,u,s):function(t,e,r){var n=t.length-1;if(r&&e===n)return t.pop(),t;for(var i=Array(n),o=0,u=0;u>>t)&g];return i?i.get(t+d,e,r,n):n},Be.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=yt(n));var s=(0===e?r:r>>>e)&g,a=this.nodes,c=a[s];if(i===v&&!c)return this;o=Fe(c,t,e+d,r,n,i,o,u);if(o===c)return this;u=this.count;if(c){if(!o&&--u>>r)&g,u=(0===r?n:n>>>r)&g,t=o==u?[Ze(t,e,r+d,n,i)]:(i=new We(e,n,i),o>1&1431655765))+(t>>2&858993459))+(t>>4)&252645135,t+=t>>8,127&(t+=t>>16)}function tr(t,e,r,n){t=n?t:Zt(t);return t[e]=r,t}var er=l/4,rr=l/2,nr=l/4,ir="@@__IMMUTABLE_LIST__@@";function or(t){return!(!t||!t[ir])}var ur=function(o){function t(t){var e=pr();if(null==t)return e;if(or(t))return t;var n=o(t),i=n.size;return 0===i?e:(te(i),0=gr(t._capacity)?n=lr(n,t.__ownerID,0,e,r,o):i=lr(i,t.__ownerID,t._level,e,r,o);if(!o.value)return t;if(t.__ownerID)return t._root=i,t._tail=n,t.__hash=void 0,t.__altered=!0,t;return _r(t._origin,t._capacity,t._level,i,n)}(this,t,e)},t.prototype.remove=function(t){return this.has(t)?0===t?this.shift():t===this.size-1?this.pop():this.splice(t,1):this},t.prototype.insert=function(t,e){return this.splice(t,0,e)},t.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=this._origin=this._capacity=0,this._level=d,this._root=this._tail=this.__hash=void 0,this.__altered=!0,this):pr()},t.prototype.push=function(){var r=arguments,n=this.size;return this.withMutations(function(t){dr(t,0,n+r.length);for(var e=0;e>>e&g;if(this.array.length<=n)return new ar([],t);var i=0==n;if(0>>e&g;if(this.array.length<=n)return this;if(0>e,u=1+(c-r>>e);l>>r&g,a=t&&s=gr(t._capacity))return t._tail;if(e<1<>>n&g],n-=d;return r}}function dr(t,e,r){void 0!==e&&(e|=0),void 0!==r&&(r|=0);var n=t.__ownerID||new m,i=t._origin,o=t._capacity,u=i+e,s=void 0===r?o:r<0?o+r:i+r;if(u===i&&s===o)return t;if(s<=u)return t.clear();for(var a=t._level,c=t._root,f=0;u+f<0;)c=new ar(c&&c.array.length?[void 0,c]:[],n),f+=1<<(a+=d);f&&(u+=f,i+=f,s+=f,o+=f);for(var h=gr(o),_=gr(s);1<>>l&g,p=p.array[v]=vr(p.array[v],n);p.array[h>>>d&g]=e}if(s>>a&g;if(y!=_>>>a&g)break;y&&(f+=(1<>>d<>>-15,461845907),e=pt(e<<13|e>>>-13,5),e=pt((e=(e+3864292196|0)^t)^e>>>16,2246822507),e=lt((e=pt(e^e>>>13,3266489909))^e>>>16)}(t.__iterate(r?e?function(t,e){n=31*n+sn(yt(t),yt(e))|0}:function(t,e){n=n+sn(yt(t),yt(e))|0}:e?function(t){n=31*n+yt(t)|0}:function(t){n=n+yt(t)|0}),n)}(this))}});var Xr=I.prototype;Xr[o]=!0,Xr[B]=Xr.values,Xr.toJSON=Xr.toArray,Xr.__toStringMapper=oe,Xr.inspect=Xr.toSource=function(){return""+this},Xr.chain=Xr.flatMap,Xr.contains=Xr.includes,Ur(O,{flip:function(){return Vt(this,Ut(this))},mapEntries:function(r,n){var i=this,o=0;return Vt(this,this.toSeq().map(function(t,e){return r.call(n,[e,t],o++,i)}).fromEntrySeq())},mapKeys:function(r,n){var i=this;return Vt(this,this.toSeq().flip().map(function(t,e){return r.call(n,t,e,i)}).flip())}});var Fr=O.prototype;Fr[s]=!0,Fr[B]=Xr.entries,Fr.toJSON=Qr,Fr.__toStringMapper=function(t,e){return oe(e)+": "+oe(t)},Ur(E,{toKeyedSeq:function(){return new xt(this,!1)},filter:function(t,e){return Vt(this,Ct(this,t,e,!1))},findIndex:function(t,e){e=this.findEntry(t,e);return e?e[0]:-1},indexOf:function(t){t=this.keyOf(t);return void 0===t?-1:t},lastIndexOf:function(t){t=this.lastKeyOf(t);return void 0===t?-1:t},reverse:function(){return Vt(this,Tt(this,!1))},slice:function(t,e){return Vt(this,Lt(this,t,e,!1))},splice:function(t,e){var r=arguments.length;if(e=Math.max(e||0,0),0===r||2===r&&!e)return this;t=y(t,t<0?this.count( -):this.size);var n=this.slice(0,t);return Vt(this,1===r?n:n.concat(Zt(arguments,2),this.slice(t+e)))},findLastIndex:function(t,e){e=this.findLastEntry(t,e);return e?e[0]:-1},first:function(t){return this.get(0,t)},flatten:function(t){return Vt(this,Pt(this,t,!1))},get:function(r,t){return(r=h(this,r))<0||this.size===1/0||void 0!==this.size&&this.size>2 -)|0}Zr.has=Xr.includes,Zr.contains=Zr.includes,Zr.keys=Zr.values,Ur(G,Fr),Ur(Z,Gr),Ur($,Zr);var an=function(t){function e(r){return null==r?_n():kr(r)?r:_n().withMutations(function(e){var t=j(r);te(t.size),t.forEach(function(t){return e.add(t)})})}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).of=function(){return this(arguments)},e.fromKeys=function(t){return this(O(t).keySeq())},e.prototype.toString=function(){return this.__toString("OrderedSet {","}")},e}(Tr);an.isOrderedSet=kr;var cn,fn=an.prototype;function hn(t,e){var r=Object.create(fn);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function _n(){return cn=cn||hn(zr())}fn[k]=!0,fn.zip=Gr.zip,fn.zipWith=Gr.zipWith,fn.zipAll=Gr.zipAll,fn.__empty=_n,fn.__make=hn;Gr=function(u,s){var a;!function(t){if(x(t))throw Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(A(t))throw Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(null===t||"object"!=typeof t)throw Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}(u);var c=function(t){var n=this;if(t instanceof c)return t;if(!(this instanceof c))return new c(t);if(!a){a=!0;var e=Object.keys(u),r=f._indices={};f._name=s,f._keys=e,f._defaultValues=u;for(var i=0;i>>-15,461845907),e=pt(e<<13|e>>>-13,5),e=pt((e=(e+3864292196|0)^t)^e>>>16,2246822507),e=lt((e=pt(e^e>>>13,3266489909))^e>>>16)}(t.__iterate(r?e?function(t,e){n=31*n+sn(yt(t),yt(e))|0}:function(t,e){n=n+sn(yt(t),yt(e))|0}:e?function(t){n=31*n+yt(t)|0}:function(t){n=n+yt(t)|0}),n)}(this))}});var Xr=I.prototype;Xr[o]=!0,Xr[B]=Xr.values,Xr.toJSON=Xr.toArray,Xr.__toStringMapper=oe,Xr.inspect=Xr.toSource=function(){return""+this},Xr.chain=Xr.flatMap,Xr.contains=Xr.includes,Ur(O,{flip:function(){return Vt(this,Ut(this))},mapEntries:function(r,n){var i=this,o=0;return Vt(this,this.toSeq().map(function(t,e){return r.call(n,[e,t],o++,i)}).fromEntrySeq())},mapKeys:function(r,n){var i=this;return Vt(this,this.toSeq().flip().map(function(t,e){return r.call(n,t,e,i)}).flip())}});var Fr=O.prototype;Fr[s]=!0,Fr[B]=Xr.entries,Fr.toJSON=Qr,Fr.__toStringMapper=function(t,e){return oe(e)+": "+oe(t)},Ur(E,{toKeyedSeq:function(){return new xt(this,!1)},filter:function(t,e){return Vt(this,Lt(this,t,e,!1))},findIndex:function(t,e){e=this.findEntry(t,e);return e?e[0]:-1},indexOf:function(t){t=this.keyOf(t);return void 0===t?-1:t},lastIndexOf:function(t){t=this.lastKeyOf(t);return void 0===t?-1:t},reverse:function(){return Vt(this,Kt(this,!1))},slice:function(t,e){return Vt(this,Ct(this,t,e,!1))},splice:function(t,e){var r=arguments.length;if(e=Math.max(e||0,0),0===r||2===r&&!e)return this;t=y(t,t<0?this.count( +):this.size);var n=this.slice(0,t);return Vt(this,1===r?n:n.concat(Zt(arguments,2),this.slice(t+e)))},findLastIndex:function(t,e){e=this.findLastEntry(t,e);return e?e[0]:-1},first:function(t){return this.get(0,t)},flatten:function(t){return Vt(this,Pt(this,t,!1))},get:function(r,t){return(r=h(this,r))<0||this.size===1/0||void 0!==this.size&&this.size>2 +)|0}Zr.has=Xr.includes,Zr.contains=Zr.includes,Zr.keys=Zr.values,Ur(G,Fr),Ur(Z,Gr),Ur($,Zr);var an=function(t){function e(r){return null==r?_n():kr(r)?r:_n().withMutations(function(e){var t=j(r);te(t.size),t.forEach(function(t){return e.add(t)})})}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).of=function(){return this(arguments)},e.fromKeys=function(t){return this(O(t).keySeq())},e.prototype.toString=function(){return this.__toString("OrderedSet {","}")},e}(Kr);an.isOrderedSet=kr;var cn,fn=an.prototype;function hn(t,e){var r=Object.create(fn);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function _n(){return cn=cn||hn(zr())}fn[k]=!0,fn.zip=Gr.zip,fn.zipWith=Gr.zipWith,fn.zipAll=Gr.zipAll,fn.__empty=_n,fn.__make=hn;Zr={LeftThenRight:-1,RightThenLeft:1};Gr=function(u,s){var a;!function(t){if(x(t))throw Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(A(t))throw Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(null===t||"object"!=typeof t)throw Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}(u);var c=function(t){var n=this;if(t instanceof c)return t;if(!(this instanceof c))return new c(t);if(!a){a=!0;var e=Object.keys(u),r=f._indices={};f._name=s,f._keys=e,f._defaultValues=u;for(var i=0;i Date: Fri, 10 Mar 2023 15:18:34 +0000 Subject: [PATCH 192/242] deploy: 41fcd04a1e02f9914e9304da316592ac2c83c7ed --- bower.json | 2 +- dist/immutable.es.js | 2 +- dist/immutable.js | 2 +- dist/immutable.min.js | 4 ++-- package.json | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bower.json b/bower.json index 0b7f840048..95cc94b581 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "immutable", - "version": "4.2.4", + "version": "4.3.0", "description": "Immutable Data Collections", "license": "MIT", "homepage": "https://immutable-js.com", diff --git a/dist/immutable.es.js b/dist/immutable.es.js index f201c9e89d..861b4c7c98 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -5891,7 +5891,7 @@ function defaultConverter(k, v) { return isIndexed(v) ? v.toList() : isKeyed(v) ? v.toMap() : v.toSet(); } -var version = "4.2.4"; +var version = "4.3.0"; var Immutable = { version: version, diff --git a/dist/immutable.js b/dist/immutable.js index c59890c27a..ed23446dc8 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -5897,7 +5897,7 @@ return isIndexed(v) ? v.toList() : isKeyed(v) ? v.toMap() : v.toSet(); } - var version = "4.2.4"; + var version = "4.3.0"; var Immutable = { version: version, diff --git a/dist/immutable.min.js b/dist/immutable.min.js index 3cf87e30aa..c1b07cb832 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -51,5 +51,5 @@ t,e,r)&&++o&&n(t,e,i)}),o},e.__iteratorUncached=function(n,t){var i=this;if(t)re ):this.size);var n=this.slice(0,t);return Vt(this,1===r?n:n.concat(Zt(arguments,2),this.slice(t+e)))},findLastIndex:function(t,e){e=this.findLastEntry(t,e);return e?e[0]:-1},first:function(t){return this.get(0,t)},flatten:function(t){return Vt(this,Pt(this,t,!1))},get:function(r,t){return(r=h(this,r))<0||this.size===1/0||void 0!==this.size&&this.size>2 )|0}Zr.has=Xr.includes,Zr.contains=Zr.includes,Zr.keys=Zr.values,Ur(G,Fr),Ur(Z,Gr),Ur($,Zr);var an=function(t){function e(r){return null==r?_n():kr(r)?r:_n().withMutations(function(e){var t=j(r);te(t.size),t.forEach(function(t){return e.add(t)})})}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).of=function(){return this(arguments)},e.fromKeys=function(t){return this(O(t).keySeq())},e.prototype.toString=function(){return this.__toString("OrderedSet {","}")},e}(Kr);an.isOrderedSet=kr;var cn,fn=an.prototype;function hn(t,e){var r=Object.create(fn);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function _n(){return cn=cn||hn(zr())}fn[k]=!0,fn.zip=Gr.zip,fn.zipWith=Gr.zipWith,fn.zipAll=Gr.zipAll,fn.__empty=_n,fn.__make=hn;Zr={LeftThenRight:-1,RightThenLeft:1};Gr=function(u,s){var a;!function(t){if(x(t))throw Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(A(t))throw Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(null===t||"object"!=typeof t)throw Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}(u);var c=function(t){var n=this;if(t instanceof c)return t;if(!(this instanceof c))return new c(t);if(!a){a=!0;var e=Object.keys(u),r=f._indices={};f._name=s,f._keys=e,f._defaultValues=u;for(var i=0;i Date: Mon, 10 Jul 2023 12:32:45 +0000 Subject: [PATCH 193/242] deploy: ad5aeb4f21e4dbf87d2bdfed012b2cb0d29d3cb5 --- dist/immutable.es.js | 10 +++++++++- dist/immutable.js | 10 +++++++++- dist/immutable.min.js | 16 ++++++++-------- 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/dist/immutable.es.js b/dist/immutable.es.js index 861b4c7c98..858a2471f5 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -4925,7 +4925,15 @@ mixin(Collection, { }, some: function some(predicate, context) { - return !this.every(not(predicate), context); + assertNotInfinite(this.size); + var returnValue = false; + this.__iterate(function (v, k, c) { + if (predicate.call(context, v, k, c)) { + returnValue = true; + return false; + } + }); + return returnValue; }, sort: function sort(comparator) { diff --git a/dist/immutable.js b/dist/immutable.js index ed23446dc8..303812e3a9 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -4931,7 +4931,15 @@ }, some: function some(predicate, context) { - return !this.every(not(predicate), context); + assertNotInfinite(this.size); + var returnValue = false; + this.__iterate(function (v, k, c) { + if (predicate.call(context, v, k, c)) { + returnValue = true; + return false; + } + }); + return returnValue; }, sort: function sort(comparator) { diff --git a/dist/immutable.min.js b/dist/immutable.min.js index c1b07cb832..828f49029d 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -45,11 +45,11 @@ var i=Object.create(qr);return i.size=t,i._head=e,i.__ownerID=r,i.__hash=n,i.__a e.prototype.toString=function(){return this.__toString("Set {","}")},e.prototype.has=function(t){return this._map.has(t)},e.prototype.add=function(t){return Br(this,this._map.set(t,t))},e.prototype.remove=function(t){return Br(this,this._map.remove(t))},e.prototype.clear=function(){return Br(this,this._map.clear())},e.prototype.map=function(r,n){var i=this,o=!1,t=Br(this,this._map.mapEntries(function(t){var e=t[1],t=r.call(n,e,e,i);return t!==e&&(o=!0),[t,t]},n));return o?t:this},e.prototype.union=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return 0===(r=r.filter(function(t){return 0!==t.size})).length?this:0!==this.size||this.__ownerID||1!==r.length?this.withMutations(function(e){for(var t=0;t>>-15,461845907),e=pt(e<<13|e>>>-13,5),e=pt((e=(e+3864292196|0)^t)^e>>>16,2246822507),e=lt((e=pt(e^e>>>13,3266489909))^e>>>16)}(t.__iterate(r?e?function(t,e){n=31*n+sn(yt(t),yt(e))|0}:function(t,e){n=n+sn(yt(t),yt(e))|0}:e?function(t){n=31*n+yt(t)|0}:function(t){n=n+yt(t)|0}),n)}(this))}});var Xr=I.prototype;Xr[o]=!0,Xr[B]=Xr.values,Xr.toJSON=Xr.toArray,Xr.__toStringMapper=oe,Xr.inspect=Xr.toSource=function(){return""+this},Xr.chain=Xr.flatMap,Xr.contains=Xr.includes,Ur(O,{flip:function(){return Vt(this,Ut(this))},mapEntries:function(r,n){var i=this,o=0;return Vt(this,this.toSeq().map(function(t,e){return r.call(n,[e,t],o++,i)}).fromEntrySeq())},mapKeys:function(r,n){var i=this;return Vt(this,this.toSeq().flip().map(function(t,e){return r.call(n,t,e,i)}).flip())}});var Fr=O.prototype;Fr[s]=!0,Fr[B]=Xr.entries,Fr.toJSON=Qr,Fr.__toStringMapper=function(t,e){return oe(e)+": "+oe(t)},Ur(E,{toKeyedSeq:function(){return new xt(this,!1)},filter:function(t,e){return Vt(this,Lt(this,t,e,!1))},findIndex:function(t,e){e=this.findEntry(t,e);return e?e[0]:-1},indexOf:function(t){t=this.keyOf(t);return void 0===t?-1:t},lastIndexOf:function(t){t=this.lastKeyOf(t);return void 0===t?-1:t},reverse:function(){return Vt(this,Kt(this,!1))},slice:function(t,e){return Vt(this,Ct(this,t,e,!1))},splice:function(t,e){var r=arguments.length;if(e=Math.max(e||0,0),0===r||2===r&&!e)return this;t=y(t,t<0?this.count( -):this.size);var n=this.slice(0,t);return Vt(this,1===r?n:n.concat(Zt(arguments,2),this.slice(t+e)))},findLastIndex:function(t,e){e=this.findLastEntry(t,e);return e?e[0]:-1},first:function(t){return this.get(0,t)},flatten:function(t){return Vt(this,Pt(this,t,!1))},get:function(r,t){return(r=h(this,r))<0||this.size===1/0||void 0!==this.size&&this.size>2 -)|0}Zr.has=Xr.includes,Zr.contains=Zr.includes,Zr.keys=Zr.values,Ur(G,Fr),Ur(Z,Gr),Ur($,Zr);var an=function(t){function e(r){return null==r?_n():kr(r)?r:_n().withMutations(function(e){var t=j(r);te(t.size),t.forEach(function(t){return e.add(t)})})}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).of=function(){return this(arguments)},e.fromKeys=function(t){return this(O(t).keySeq())},e.prototype.toString=function(){return this.__toString("OrderedSet {","}")},e}(Kr);an.isOrderedSet=kr;var cn,fn=an.prototype;function hn(t,e){var r=Object.create(fn);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function _n(){return cn=cn||hn(zr())}fn[k]=!0,fn.zip=Gr.zip,fn.zipWith=Gr.zipWith,fn.zipAll=Gr.zipAll,fn.__empty=_n,fn.__make=hn;Zr={LeftThenRight:-1,RightThenLeft:1};Gr=function(u,s){var a;!function(t){if(x(t))throw Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(A(t))throw Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(null===t||"object"!=typeof t)throw Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}(u);var c=function(t){var n=this;if(t instanceof c)return t;if(!(this instanceof c))return new c(t);if(!a){a=!0;var e=Object.keys(u),r=f._indices={};f._name=s,f._keys=e,f._defaultValues=u;for(var i=0;i>>-15,461845907),e=pt(e<<13|e>>>-13,5),e=pt((e=(e+3864292196|0)^t)^e>>>16,2246822507),e=lt((e=pt(e^e>>>13,3266489909))^e>>>16)}(t.__iterate(r?e?function(t,e){n=31*n+sn(yt(t),yt(e))|0}:function(t,e){n=n+sn(yt(t),yt(e))|0}:e?function(t){n=31*n+yt(t)|0}:function(t){n=n+yt(t)|0}),n)}(this))}});var Xr=I.prototype;Xr[o]=!0,Xr[B]=Xr.values,Xr.toJSON=Xr.toArray,Xr.__toStringMapper=oe,Xr.inspect=Xr.toSource=function(){return""+this},Xr.chain=Xr.flatMap,Xr.contains=Xr.includes,Ur(O,{flip:function(){return Vt(this,Ut(this))},mapEntries:function(r,n){var i=this,o=0;return Vt(this,this.toSeq().map(function(t,e){return r.call(n,[e,t],o++,i)}).fromEntrySeq())},mapKeys:function(r,n){var i=this;return Vt(this,this.toSeq().flip().map(function(t,e){return r.call(n,t,e,i)}).flip())}});var Fr=O.prototype;Fr[s]=!0,Fr[B]=Xr.entries,Fr.toJSON=Qr,Fr.__toStringMapper=function(t,e){return oe(e)+": "+oe(t)},Ur(E,{toKeyedSeq:function(){return new xt(this,!1)},filter:function(t,e){return Vt(this,Lt(this,t,e,!1))},findIndex:function(t,e){e=this.findEntry(t,e);return e?e[0]:-1},indexOf:function(t){t=this.keyOf(t);return void 0===t?-1:t},lastIndexOf:function(t){t=this.lastKeyOf(t);return void 0===t?-1:t},reverse:function(){return Vt(this,Kt(this,!1))},slice:function(t,e){return Vt(this,Ct(this,t,e,!1))},splice:function(t,e){ +var r=arguments.length;if(e=Math.max(e||0,0),0===r||2===r&&!e)return this;t=y(t,t<0?this.count():this.size);var n=this.slice(0,t);return Vt(this,1===r?n:n.concat(Zt(arguments,2),this.slice(t+e)))},findLastIndex:function(t,e){e=this.findLastEntry(t,e);return e?e[0]:-1},first:function(t){return this.get(0,t)},flatten:function(t){return Vt(this,Pt(this,t,!1))},get:function(r,t){return(r=h(this,r))<0||this.size===1/0||void 0!==this.size&&this.size>2)|0}Zr.has=Xr.includes,Zr.contains=Zr.includes,Zr.keys=Zr.values,Ur(G,Fr),Ur(Z,Gr),Ur($,Zr);var an=function(t){function e(r){return null==r?_n():kr(r)?r:_n().withMutations(function(e){var t=j(r);te(t.size),t.forEach(function(t){return e.add(t)})})}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).of=function(){return this(arguments)},e.fromKeys=function(t){return this(O(t).keySeq())},e.prototype.toString=function(){return this.__toString("OrderedSet {","}")},e}(Kr);an.isOrderedSet=kr;var cn,fn=an.prototype;function hn(t,e){var r=Object.create(fn);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function _n(){return cn=cn||hn(zr())}fn[k]=!0,fn.zip=Gr.zip,fn.zipWith=Gr.zipWith,fn.zipAll=Gr.zipAll,fn.__empty=_n,fn.__make=hn;Zr={LeftThenRight:-1,RightThenLeft:1};Gr=function(u,s){var a;!function(t){if(x(t))throw Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(A(t))throw Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(null===t||"object"!=typeof t)throw Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}(u);var c=function(t){var n=this;if(t instanceof c)return t;if(!(this instanceof c))return new c(t);if(!a){a=!0;var e=Object.keys(u),r=f._indices={};f._name=s,f._keys=e,f._defaultValues=u;for(var i=0;i Date: Tue, 11 Jul 2023 20:50:36 +0000 Subject: [PATCH 194/242] deploy: 5f03635a1ba1698fde5b19c88419106813ab4c8e --- bower.json | 2 +- dist/immutable.es.js | 2 +- dist/immutable.js | 2 +- dist/immutable.min.js | 4 ++-- package.json | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bower.json b/bower.json index 95cc94b581..caf5a9e8d1 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "immutable", - "version": "4.3.0", + "version": "4.3.1", "description": "Immutable Data Collections", "license": "MIT", "homepage": "https://immutable-js.com", diff --git a/dist/immutable.es.js b/dist/immutable.es.js index 858a2471f5..d7f94a5d20 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -5899,7 +5899,7 @@ function defaultConverter(k, v) { return isIndexed(v) ? v.toList() : isKeyed(v) ? v.toMap() : v.toSet(); } -var version = "4.3.0"; +var version = "4.3.1"; var Immutable = { version: version, diff --git a/dist/immutable.js b/dist/immutable.js index 303812e3a9..175a8c01c5 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -5905,7 +5905,7 @@ return isIndexed(v) ? v.toList() : isKeyed(v) ? v.toMap() : v.toSet(); } - var version = "4.3.0"; + var version = "4.3.1"; var Immutable = { version: version, diff --git a/dist/immutable.min.js b/dist/immutable.min.js index 828f49029d..437a6ce46a 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -51,5 +51,5 @@ return this.toKeyedSeq().reverse().findEntry(t,e,r)},findLastKey:function(t,e){r var r=arguments.length;if(e=Math.max(e||0,0),0===r||2===r&&!e)return this;t=y(t,t<0?this.count():this.size);var n=this.slice(0,t);return Vt(this,1===r?n:n.concat(Zt(arguments,2),this.slice(t+e)))},findLastIndex:function(t,e){e=this.findLastEntry(t,e);return e?e[0]:-1},first:function(t){return this.get(0,t)},flatten:function(t){return Vt(this,Pt(this,t,!1))},get:function(r,t){return(r=h(this,r))<0||this.size===1/0||void 0!==this.size&&this.size>2)|0}Zr.has=Xr.includes,Zr.contains=Zr.includes,Zr.keys=Zr.values,Ur(G,Fr),Ur(Z,Gr),Ur($,Zr);var an=function(t){function e(r){return null==r?_n():kr(r)?r:_n().withMutations(function(e){var t=j(r);te(t.size),t.forEach(function(t){return e.add(t)})})}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).of=function(){return this(arguments)},e.fromKeys=function(t){return this(O(t).keySeq())},e.prototype.toString=function(){return this.__toString("OrderedSet {","}")},e}(Kr);an.isOrderedSet=kr;var cn,fn=an.prototype;function hn(t,e){var r=Object.create(fn);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function _n(){return cn=cn||hn(zr())}fn[k]=!0,fn.zip=Gr.zip,fn.zipWith=Gr.zipWith,fn.zipAll=Gr.zipAll,fn.__empty=_n,fn.__make=hn;Zr={LeftThenRight:-1,RightThenLeft:1};Gr=function(u,s){var a;!function(t){if(x(t))throw Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(A(t))throw Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(null===t||"object"!=typeof t)throw Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}(u);var c=function(t){var n=this;if(t instanceof c)return t;if(!(this instanceof c))return new c(t);if(!a){a=!0;var e=Object.keys(u),r=f._indices={};f._name=s,f._keys=e,f._defaultValues=u;for(var i=0;i Date: Tue, 1 Aug 2023 14:30:49 +0000 Subject: [PATCH 195/242] deploy: 40e5945f5d027222ae0686209236678458a042f8 --- dist/immutable.d.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index 7ae4eec33d..3036bc93f7 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -1913,7 +1913,9 @@ declare namespace Immutable { /** * True if the provided value is an OrderedSet. */ - function isOrderedSet(maybeOrderedSet: unknown): boolean; + function isOrderedSet( + maybeOrderedSet: unknown + ): maybeOrderedSet is OrderedSet; /** * Creates a new OrderedSet containing `values`. From fd94936ebd7e114e3a88b8bfad2cc8c53b5bdb6e Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 3 Aug 2023 06:52:23 +0000 Subject: [PATCH 196/242] deploy: ab69aaafd91edb80b3e9e3b583ed121c374b1ee1 --- bower.json | 2 +- dist/immutable.es.js | 2 +- dist/immutable.js | 2 +- dist/immutable.min.js | 4 ++-- package.json | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bower.json b/bower.json index caf5a9e8d1..c16b1f2f6a 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "immutable", - "version": "4.3.1", + "version": "4.3.2", "description": "Immutable Data Collections", "license": "MIT", "homepage": "https://immutable-js.com", diff --git a/dist/immutable.es.js b/dist/immutable.es.js index d7f94a5d20..8cad377e21 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -5899,7 +5899,7 @@ function defaultConverter(k, v) { return isIndexed(v) ? v.toList() : isKeyed(v) ? v.toMap() : v.toSet(); } -var version = "4.3.1"; +var version = "4.3.2"; var Immutable = { version: version, diff --git a/dist/immutable.js b/dist/immutable.js index 175a8c01c5..e8fc9a0454 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -5905,7 +5905,7 @@ return isIndexed(v) ? v.toList() : isKeyed(v) ? v.toMap() : v.toSet(); } - var version = "4.3.1"; + var version = "4.3.2"; var Immutable = { version: version, diff --git a/dist/immutable.min.js b/dist/immutable.min.js index 437a6ce46a..e66c58c814 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -51,5 +51,5 @@ return this.toKeyedSeq().reverse().findEntry(t,e,r)},findLastKey:function(t,e){r var r=arguments.length;if(e=Math.max(e||0,0),0===r||2===r&&!e)return this;t=y(t,t<0?this.count():this.size);var n=this.slice(0,t);return Vt(this,1===r?n:n.concat(Zt(arguments,2),this.slice(t+e)))},findLastIndex:function(t,e){e=this.findLastEntry(t,e);return e?e[0]:-1},first:function(t){return this.get(0,t)},flatten:function(t){return Vt(this,Pt(this,t,!1))},get:function(r,t){return(r=h(this,r))<0||this.size===1/0||void 0!==this.size&&this.size>2)|0}Zr.has=Xr.includes,Zr.contains=Zr.includes,Zr.keys=Zr.values,Ur(G,Fr),Ur(Z,Gr),Ur($,Zr);var an=function(t){function e(r){return null==r?_n():kr(r)?r:_n().withMutations(function(e){var t=j(r);te(t.size),t.forEach(function(t){return e.add(t)})})}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).of=function(){return this(arguments)},e.fromKeys=function(t){return this(O(t).keySeq())},e.prototype.toString=function(){return this.__toString("OrderedSet {","}")},e}(Kr);an.isOrderedSet=kr;var cn,fn=an.prototype;function hn(t,e){var r=Object.create(fn);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function _n(){return cn=cn||hn(zr())}fn[k]=!0,fn.zip=Gr.zip,fn.zipWith=Gr.zipWith,fn.zipAll=Gr.zipAll,fn.__empty=_n,fn.__make=hn;Zr={LeftThenRight:-1,RightThenLeft:1};Gr=function(u,s){var a;!function(t){if(x(t))throw Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(A(t))throw Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(null===t||"object"!=typeof t)throw Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}(u);var c=function(t){var n=this;if(t instanceof c)return t;if(!(this instanceof c))return new c(t);if(!a){a=!0;var e=Object.keys(u),r=f._indices={};f._name=s,f._keys=e,f._defaultValues=u;for(var i=0;i Date: Wed, 16 Aug 2023 08:13:44 +0000 Subject: [PATCH 197/242] deploy: 7b3aa41e8be06c5e4610bbe7b6761c6f12c2d6ce --- README.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 203bfcc38f..a66bc4c17f 100644 --- a/README.md +++ b/README.md @@ -58,13 +58,17 @@ Want to hear more? Watch the presentation about Immutable.js: Install `immutable` using npm. ```shell +# using npm npm install immutable -``` - -Or install using yarn. -```shell +# using Yarn yarn add immutable + +# using pnpm +pnpn add immutable + +# using Bun +bun add immutable ``` Then require it into any module. From c67c2e138a019278335292ecf671db593017464d Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 17 Aug 2023 08:02:22 +0000 Subject: [PATCH 198/242] deploy: 3dfdf737f25f638c6806b33798a30bc5d9fc21b2 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a66bc4c17f..02e143cd9e 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,7 @@ npm install immutable yarn add immutable # using pnpm -pnpn add immutable +pnpm add immutable # using Bun bun add immutable From 9a1f8b727bd54b8d41057b10558d9db1409129d9 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 23 Aug 2023 09:32:02 +0000 Subject: [PATCH 199/242] deploy: 0224bd01a41206e3a2ce5929eb17662563f3a46c --- dist/immutable.d.ts | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index 3036bc93f7..0331a54bcf 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -100,27 +100,25 @@ declare namespace Immutable { export type DeepCopy = T extends Record ? // convert Record to DeepCopy plain JS object { - [key in keyof R]: R[key] extends object ? unknown : R[key]; + [key in keyof R]: DeepCopy; } : T extends Collection.Keyed ? // convert KeyedCollection to DeepCopy plain JS object { [key in KeyedKey extends string | number | symbol ? KeyedKey - : string]: V extends object ? unknown : V; + : string]: DeepCopy; } : // convert IndexedCollection or Immutable.Set to DeepCopy plain JS array T extends Collection - ? Array + ? Array> : T extends string | number // Iterable scalar types : should be kept as is ? T : T extends Iterable // Iterable are converted to plain JS array - ? Array + ? Array> : T extends object // plain JS object are converted deeply ? { - [ObjectKey in keyof T]: T[ObjectKey] extends object - ? unknown - : T[ObjectKey]; + [ObjectKey in keyof T]: DeepCopy; } : // other case : should be kept as is T; From 2f469ba90dc63ce0612dae25a0de73e74fca5ae6 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 23 Aug 2023 10:00:50 +0000 Subject: [PATCH 200/242] deploy: 2306527b42067bc433d9d32be12a7e561e85d9e0 --- bower.json | 2 +- dist/immutable.es.js | 2 +- dist/immutable.js | 2 +- dist/immutable.min.js | 4 ++-- package.json | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bower.json b/bower.json index c16b1f2f6a..6be9cf90e5 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "immutable", - "version": "4.3.2", + "version": "4.3.3", "description": "Immutable Data Collections", "license": "MIT", "homepage": "https://immutable-js.com", diff --git a/dist/immutable.es.js b/dist/immutable.es.js index 8cad377e21..91cb6ef6f1 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -5899,7 +5899,7 @@ function defaultConverter(k, v) { return isIndexed(v) ? v.toList() : isKeyed(v) ? v.toMap() : v.toSet(); } -var version = "4.3.2"; +var version = "4.3.3"; var Immutable = { version: version, diff --git a/dist/immutable.js b/dist/immutable.js index e8fc9a0454..efe7de465c 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -5905,7 +5905,7 @@ return isIndexed(v) ? v.toList() : isKeyed(v) ? v.toMap() : v.toSet(); } - var version = "4.3.2"; + var version = "4.3.3"; var Immutable = { version: version, diff --git a/dist/immutable.min.js b/dist/immutable.min.js index e66c58c814..561ea6d08f 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -51,5 +51,5 @@ return this.toKeyedSeq().reverse().findEntry(t,e,r)},findLastKey:function(t,e){r var r=arguments.length;if(e=Math.max(e||0,0),0===r||2===r&&!e)return this;t=y(t,t<0?this.count():this.size);var n=this.slice(0,t);return Vt(this,1===r?n:n.concat(Zt(arguments,2),this.slice(t+e)))},findLastIndex:function(t,e){e=this.findLastEntry(t,e);return e?e[0]:-1},first:function(t){return this.get(0,t)},flatten:function(t){return Vt(this,Pt(this,t,!1))},get:function(r,t){return(r=h(this,r))<0||this.size===1/0||void 0!==this.size&&this.size>2)|0}Zr.has=Xr.includes,Zr.contains=Zr.includes,Zr.keys=Zr.values,Ur(G,Fr),Ur(Z,Gr),Ur($,Zr);var an=function(t){function e(r){return null==r?_n():kr(r)?r:_n().withMutations(function(e){var t=j(r);te(t.size),t.forEach(function(t){return e.add(t)})})}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).of=function(){return this(arguments)},e.fromKeys=function(t){return this(O(t).keySeq())},e.prototype.toString=function(){return this.__toString("OrderedSet {","}")},e}(Kr);an.isOrderedSet=kr;var cn,fn=an.prototype;function hn(t,e){var r=Object.create(fn);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function _n(){return cn=cn||hn(zr())}fn[k]=!0,fn.zip=Gr.zip,fn.zipWith=Gr.zipWith,fn.zipAll=Gr.zipAll,fn.__empty=_n,fn.__make=hn;Zr={LeftThenRight:-1,RightThenLeft:1};Gr=function(u,s){var a;!function(t){if(x(t))throw Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(A(t))throw Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(null===t||"object"!=typeof t)throw Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}(u);var c=function(t){var n=this;if(t instanceof c)return t;if(!(this instanceof c))return new c(t);if(!a){a=!0;var e=Object.keys(u),r=f._indices={};f._name=s,f._keys=e,f._defaultValues=u;for(var i=0;i Date: Fri, 25 Aug 2023 13:40:24 +0000 Subject: [PATCH 201/242] deploy: 1e2ec73c9fd78e480cfba598786cbc70034f5c3d --- dist/immutable.d.ts | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index 0331a54bcf..7bd59b2e2b 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -91,6 +91,16 @@ */ declare namespace Immutable { + /** @ignore */ + type OnlyObject = Extract; + + /** @ignore */ + type ContainObject = OnlyObject extends object + ? OnlyObject extends never + ? false + : true + : false; + /** * @ignore * @@ -100,14 +110,14 @@ declare namespace Immutable { export type DeepCopy = T extends Record ? // convert Record to DeepCopy plain JS object { - [key in keyof R]: DeepCopy; + [key in keyof R]: ContainObject extends true ? unknown : R[key]; } : T extends Collection.Keyed ? // convert KeyedCollection to DeepCopy plain JS object { [key in KeyedKey extends string | number | symbol ? KeyedKey - : string]: DeepCopy; + : string]: V extends object ? unknown : V; } : // convert IndexedCollection or Immutable.Set to DeepCopy plain JS array T extends Collection @@ -118,7 +128,9 @@ declare namespace Immutable { ? Array> : T extends object // plain JS object are converted deeply ? { - [ObjectKey in keyof T]: DeepCopy; + [ObjectKey in keyof T]: ContainObject extends true + ? unknown + : T[ObjectKey]; } : // other case : should be kept as is T; From 2d5aa8a6e08ec3f6150d8c2c793840d144e89f6a Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 25 Aug 2023 13:42:28 +0000 Subject: [PATCH 202/242] deploy: fdfc97514f1b288301c7a1ea73873bbd4c832ffb --- bower.json | 2 +- dist/immutable.es.js | 2 +- dist/immutable.js | 2 +- dist/immutable.min.js | 4 ++-- package.json | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bower.json b/bower.json index 6be9cf90e5..de54a3d1ec 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "immutable", - "version": "4.3.3", + "version": "4.3.4", "description": "Immutable Data Collections", "license": "MIT", "homepage": "https://immutable-js.com", diff --git a/dist/immutable.es.js b/dist/immutable.es.js index 91cb6ef6f1..57e977f5d4 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -5899,7 +5899,7 @@ function defaultConverter(k, v) { return isIndexed(v) ? v.toList() : isKeyed(v) ? v.toMap() : v.toSet(); } -var version = "4.3.3"; +var version = "4.3.4"; var Immutable = { version: version, diff --git a/dist/immutable.js b/dist/immutable.js index efe7de465c..f96480a626 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -5905,7 +5905,7 @@ return isIndexed(v) ? v.toList() : isKeyed(v) ? v.toMap() : v.toSet(); } - var version = "4.3.3"; + var version = "4.3.4"; var Immutable = { version: version, diff --git a/dist/immutable.min.js b/dist/immutable.min.js index 561ea6d08f..fc49aa8afd 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -51,5 +51,5 @@ return this.toKeyedSeq().reverse().findEntry(t,e,r)},findLastKey:function(t,e){r var r=arguments.length;if(e=Math.max(e||0,0),0===r||2===r&&!e)return this;t=y(t,t<0?this.count():this.size);var n=this.slice(0,t);return Vt(this,1===r?n:n.concat(Zt(arguments,2),this.slice(t+e)))},findLastIndex:function(t,e){e=this.findLastEntry(t,e);return e?e[0]:-1},first:function(t){return this.get(0,t)},flatten:function(t){return Vt(this,Pt(this,t,!1))},get:function(r,t){return(r=h(this,r))<0||this.size===1/0||void 0!==this.size&&this.size>2)|0}Zr.has=Xr.includes,Zr.contains=Zr.includes,Zr.keys=Zr.values,Ur(G,Fr),Ur(Z,Gr),Ur($,Zr);var an=function(t){function e(r){return null==r?_n():kr(r)?r:_n().withMutations(function(e){var t=j(r);te(t.size),t.forEach(function(t){return e.add(t)})})}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).of=function(){return this(arguments)},e.fromKeys=function(t){return this(O(t).keySeq())},e.prototype.toString=function(){return this.__toString("OrderedSet {","}")},e}(Kr);an.isOrderedSet=kr;var cn,fn=an.prototype;function hn(t,e){var r=Object.create(fn);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function _n(){return cn=cn||hn(zr())}fn[k]=!0,fn.zip=Gr.zip,fn.zipWith=Gr.zipWith,fn.zipAll=Gr.zipAll,fn.__empty=_n,fn.__make=hn;Zr={LeftThenRight:-1,RightThenLeft:1};Gr=function(u,s){var a;!function(t){if(x(t))throw Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(A(t))throw Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(null===t||"object"!=typeof t)throw Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}(u);var c=function(t){var n=this;if(t instanceof c)return t;if(!(this instanceof c))return new c(t);if(!a){a=!0;var e=Object.keys(u),r=f._indices={};f._name=s,f._keys=e,f._defaultValues=u;for(var i=0;i Date: Mon, 28 Aug 2023 12:28:09 +0000 Subject: [PATCH 203/242] deploy: 8cb4e535cca858fc8b54fb7536448ed9556ced73 --- bower.json | 2 +- dist/immutable.es.js | 2 +- dist/immutable.js | 2 +- dist/immutable.min.js | 8 ++++---- package.json | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/bower.json b/bower.json index de54a3d1ec..5184dab7b7 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "immutable", - "version": "4.3.4", + "version": "5.0.0-beta.3", "description": "Immutable Data Collections", "license": "MIT", "homepage": "https://immutable-js.com", diff --git a/dist/immutable.es.js b/dist/immutable.es.js index 57e977f5d4..fdcbceba14 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -5899,7 +5899,7 @@ function defaultConverter(k, v) { return isIndexed(v) ? v.toList() : isKeyed(v) ? v.toMap() : v.toSet(); } -var version = "4.3.4"; +var version = "5.0.0-beta.3"; var Immutable = { version: version, diff --git a/dist/immutable.js b/dist/immutable.js index f96480a626..a670245dc6 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -5905,7 +5905,7 @@ return isIndexed(v) ? v.toList() : isKeyed(v) ? v.toMap() : v.toSet(); } - var version = "4.3.4"; + var version = "5.0.0-beta.3"; var Immutable = { version: version, diff --git a/dist/immutable.min.js b/dist/immutable.min.js index fc49aa8afd..d327ff191a 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -49,7 +49,7 @@ return t instanceof n?this._start===t._start&&this._end===t._end&&this._step===t return this.toKeyedSeq().reverse().findEntry(t,e,r)},findLastKey:function(t,e){return this.toKeyedSeq().reverse().findKey(t,e)},first:function(t){return this.find(r,null,t)},flatMap:function(t,e){return Vt(this,(n=t,i=e,o=Qt(r=this),r.toSeq().map(function(t,e){return o(n.call(i,t,e,r))}).flatten(!0)));var r,n,i,o},flatten:function(t){return Vt(this,Pt(this,t,!0))},fromEntrySeq:function(){return new Rt(this)},get:function(r,t){return this.find(function(t,e){return _t(e,r)},void 0,t)},getIn:Vr,groupBy:function(t,e){return function(n,t,i){var o=a(n),u=(R(n)?wr:Te)().asMutable();n.__iterate(function(e,r){u.update(t.call(i,e,r,n),function(t){return(t=t||[]).push(o?[r,e]:e),t})});var e=Qt(n);return u.map(function(t){return Vt(n,e(t))}).asImmutable()}(this,t,e)},has:function(t){return this.get(t,v)!==v},hasIn:function(t){return Yr(this,t)},isSubset:function(e){return e="function"==typeof e.includes?e:I(e),this.every(function(t){return e.includes(t)})},isSuperset:function(t){return(t="function"==typeof t.isSubset?t:I(t)).isSubset(this)},keyOf:function(e){return this.findKey(function(t){return _t(t,e)})},keySeq:function(){return this.toSeq().map(tn).toIndexedSeq()},last:function(t){return this.toSeq().reverse().first(t)},lastKeyOf:function(t){return this.toKeyedSeq().reverse().keyOf(t)},max:function(t){return Nt(this,t)},maxBy:function(t,e){return Nt(this,e,t)},min:function(t){return Nt(this,t?nn(t):un)},minBy:function(t,e){return Nt(this,e?nn(e):un,t)},rest:function(){return this.slice(1)},skip:function(t){return 0===t?this:this.slice(Math.max(0,t))},skipLast:function(t){return 0===t?this:this.slice(0,-Math.max(0,t))},skipWhile:function(t,e){return Vt(this,Bt(this,t,e,!0))},skipUntil:function(t,e){return this.skipWhile(rn(t),e)},sortBy:function(t,e){return Vt(this,Wt(this,e,t))},take:function(t){return this.slice(0,Math.max(0,t))},takeLast:function(t){return this.slice(-Math.max(0,t))},takeWhile:function(t,e){return Vt(this,(s=t,a=e,(e=Xt(r=this)).__iterateUncached=function(n,t){var i=this;if(t)return this.cacheResult( ).__iterate(n,t);var o=0;return r.__iterate(function(t,e,r){return s.call(a,t,e,r)&&++o&&n(t,e,i)}),o},e.__iteratorUncached=function(n,t){var i=this;if(t)return this.cacheResult().__iterator(n,t);var o=r.__iterator(K,t),u=!0;return new P(function(){if(!u)return N();var t=o.next();if(t.done)return t;var e=t.value,r=e[0],e=e[1];return s.call(a,e,r,i)?n===K?t:W(n,r,e,t):(u=!1,N())})},e));var r,s,a},takeUntil:function(t,e){return this.takeWhile(rn(t),e)},update:function(t){return t(this)},valueSeq:function(){return this.toIndexedSeq()},hashCode:function(){return this.__hash||(this.__hash=function(t){if(t.size===1/0)return 0;var e=R(t),r=a(t),n=e?1:0;return function(t,e){return e=pt(e,3432918353),e=pt(e<<15|e>>>-15,461845907),e=pt(e<<13|e>>>-13,5),e=pt((e=(e+3864292196|0)^t)^e>>>16,2246822507),e=lt((e=pt(e^e>>>13,3266489909))^e>>>16)}(t.__iterate(r?e?function(t,e){n=31*n+sn(yt(t),yt(e))|0}:function(t,e){n=n+sn(yt(t),yt(e))|0}:e?function(t){n=31*n+yt(t)|0}:function(t){n=n+yt(t)|0}),n)}(this))}});var Xr=I.prototype;Xr[o]=!0,Xr[B]=Xr.values,Xr.toJSON=Xr.toArray,Xr.__toStringMapper=oe,Xr.inspect=Xr.toSource=function(){return""+this},Xr.chain=Xr.flatMap,Xr.contains=Xr.includes,Ur(O,{flip:function(){return Vt(this,Ut(this))},mapEntries:function(r,n){var i=this,o=0;return Vt(this,this.toSeq().map(function(t,e){return r.call(n,[e,t],o++,i)}).fromEntrySeq())},mapKeys:function(r,n){var i=this;return Vt(this,this.toSeq().flip().map(function(t,e){return r.call(n,t,e,i)}).flip())}});var Fr=O.prototype;Fr[s]=!0,Fr[B]=Xr.entries,Fr.toJSON=Qr,Fr.__toStringMapper=function(t,e){return oe(e)+": "+oe(t)},Ur(E,{toKeyedSeq:function(){return new xt(this,!1)},filter:function(t,e){return Vt(this,Lt(this,t,e,!1))},findIndex:function(t,e){e=this.findEntry(t,e);return e?e[0]:-1},indexOf:function(t){t=this.keyOf(t);return void 0===t?-1:t},lastIndexOf:function(t){t=this.lastKeyOf(t);return void 0===t?-1:t},reverse:function(){return Vt(this,Kt(this,!1))},slice:function(t,e){return Vt(this,Ct(this,t,e,!1))},splice:function(t,e){ var r=arguments.length;if(e=Math.max(e||0,0),0===r||2===r&&!e)return this;t=y(t,t<0?this.count():this.size);var n=this.slice(0,t);return Vt(this,1===r?n:n.concat(Zt(arguments,2),this.slice(t+e)))},findLastIndex:function(t,e){e=this.findLastEntry(t,e);return e?e[0]:-1},first:function(t){return this.get(0,t)},flatten:function(t){return Vt(this,Pt(this,t,!1))},get:function(r,t){return(r=h(this,r))<0||this.size===1/0||void 0!==this.size&&this.size>2)|0}Zr.has=Xr.includes,Zr.contains=Zr.includes,Zr.keys=Zr.values,Ur(G,Fr),Ur(Z,Gr),Ur($,Zr);var an=function(t){function e(r){return null==r?_n():kr(r)?r:_n().withMutations(function(e){var t=j(r);te(t.size),t.forEach(function(t){return e.add(t)})})}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).of=function(){return this(arguments)},e.fromKeys=function(t){return this(O(t).keySeq())},e.prototype.toString=function(){return this.__toString("OrderedSet {","}")},e}(Kr);an.isOrderedSet=kr;var cn,fn=an.prototype;function hn(t,e){var r=Object.create(fn);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function _n(){return cn=cn||hn(zr())}fn[k]=!0,fn.zip=Gr.zip,fn.zipWith=Gr.zipWith,fn.zipAll=Gr.zipAll,fn.__empty=_n,fn.__make=hn;Zr={LeftThenRight:-1,RightThenLeft:1};Gr=function(u,s){var a;!function(t){if(x(t))throw Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(A(t))throw Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(null===t||"object"!=typeof t)throw Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}(u);var c=function(t){var n=this;if(t instanceof c)return t;if(!(this instanceof c))return new c(t);if(!a){a=!0;var e=Object.keys(u),r=f._indices={};f._name=s,f._keys=e,f._defaultValues=u;for(var i=0;i>2)|0}Zr.has=Xr.includes,Zr.contains=Zr.includes,Zr.keys=Zr.values,Ur(G,Fr),Ur(Z,Gr),Ur($,Zr);var an=function(t){function e(r){return null==r?_n():kr(r)?r:_n().withMutations(function(e){var t=j(r);te(t.size),t.forEach(function(t){return e.add(t)})})}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).of=function(){return this(arguments)},e.fromKeys=function(t){return this(O(t).keySeq())},e.prototype.toString=function(){return this.__toString("OrderedSet {","}")},e}(Kr);an.isOrderedSet=kr;var cn,fn=an.prototype;function hn(t,e){var r=Object.create(fn);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function _n(){return cn=cn||hn(zr())}fn[k]=!0,fn.zip=Gr.zip,fn.zipWith=Gr.zipWith,fn.zipAll=Gr.zipAll,fn.__empty=_n,fn.__make=hn;Fr={LeftThenRight:-1,RightThenLeft:1};Zr=function(u,s){var a;!function(t){if(x(t))throw Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(A(t))throw Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(null===t||"object"!=typeof t)throw Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}(u);var c=function(t){var n=this;if(t instanceof c)return t;if(!(this instanceof c))return new c(t);if(!a){a=!0;var e=Object.keys(u),r=f._indices={};f._name=s,f._keys=e,f._defaultValues=u;for(var i=0;i Date: Mon, 28 Aug 2023 12:50:10 +0000 Subject: [PATCH 204/242] deploy: 2e95835fe8e9517745f025c29131355d6956acd7 --- bower.json | 2 +- dist/immutable.es.js | 2 +- dist/immutable.js | 2 +- dist/immutable.min.js | 8 ++++---- package.json | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/bower.json b/bower.json index 5184dab7b7..de54a3d1ec 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "immutable", - "version": "5.0.0-beta.3", + "version": "4.3.4", "description": "Immutable Data Collections", "license": "MIT", "homepage": "https://immutable-js.com", diff --git a/dist/immutable.es.js b/dist/immutable.es.js index fdcbceba14..57e977f5d4 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -5899,7 +5899,7 @@ function defaultConverter(k, v) { return isIndexed(v) ? v.toList() : isKeyed(v) ? v.toMap() : v.toSet(); } -var version = "5.0.0-beta.3"; +var version = "4.3.4"; var Immutable = { version: version, diff --git a/dist/immutable.js b/dist/immutable.js index a670245dc6..f96480a626 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -5905,7 +5905,7 @@ return isIndexed(v) ? v.toList() : isKeyed(v) ? v.toMap() : v.toSet(); } - var version = "5.0.0-beta.3"; + var version = "4.3.4"; var Immutable = { version: version, diff --git a/dist/immutable.min.js b/dist/immutable.min.js index d327ff191a..fc49aa8afd 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -49,7 +49,7 @@ return t instanceof n?this._start===t._start&&this._end===t._end&&this._step===t return this.toKeyedSeq().reverse().findEntry(t,e,r)},findLastKey:function(t,e){return this.toKeyedSeq().reverse().findKey(t,e)},first:function(t){return this.find(r,null,t)},flatMap:function(t,e){return Vt(this,(n=t,i=e,o=Qt(r=this),r.toSeq().map(function(t,e){return o(n.call(i,t,e,r))}).flatten(!0)));var r,n,i,o},flatten:function(t){return Vt(this,Pt(this,t,!0))},fromEntrySeq:function(){return new Rt(this)},get:function(r,t){return this.find(function(t,e){return _t(e,r)},void 0,t)},getIn:Vr,groupBy:function(t,e){return function(n,t,i){var o=a(n),u=(R(n)?wr:Te)().asMutable();n.__iterate(function(e,r){u.update(t.call(i,e,r,n),function(t){return(t=t||[]).push(o?[r,e]:e),t})});var e=Qt(n);return u.map(function(t){return Vt(n,e(t))}).asImmutable()}(this,t,e)},has:function(t){return this.get(t,v)!==v},hasIn:function(t){return Yr(this,t)},isSubset:function(e){return e="function"==typeof e.includes?e:I(e),this.every(function(t){return e.includes(t)})},isSuperset:function(t){return(t="function"==typeof t.isSubset?t:I(t)).isSubset(this)},keyOf:function(e){return this.findKey(function(t){return _t(t,e)})},keySeq:function(){return this.toSeq().map(tn).toIndexedSeq()},last:function(t){return this.toSeq().reverse().first(t)},lastKeyOf:function(t){return this.toKeyedSeq().reverse().keyOf(t)},max:function(t){return Nt(this,t)},maxBy:function(t,e){return Nt(this,e,t)},min:function(t){return Nt(this,t?nn(t):un)},minBy:function(t,e){return Nt(this,e?nn(e):un,t)},rest:function(){return this.slice(1)},skip:function(t){return 0===t?this:this.slice(Math.max(0,t))},skipLast:function(t){return 0===t?this:this.slice(0,-Math.max(0,t))},skipWhile:function(t,e){return Vt(this,Bt(this,t,e,!0))},skipUntil:function(t,e){return this.skipWhile(rn(t),e)},sortBy:function(t,e){return Vt(this,Wt(this,e,t))},take:function(t){return this.slice(0,Math.max(0,t))},takeLast:function(t){return this.slice(-Math.max(0,t))},takeWhile:function(t,e){return Vt(this,(s=t,a=e,(e=Xt(r=this)).__iterateUncached=function(n,t){var i=this;if(t)return this.cacheResult( ).__iterate(n,t);var o=0;return r.__iterate(function(t,e,r){return s.call(a,t,e,r)&&++o&&n(t,e,i)}),o},e.__iteratorUncached=function(n,t){var i=this;if(t)return this.cacheResult().__iterator(n,t);var o=r.__iterator(K,t),u=!0;return new P(function(){if(!u)return N();var t=o.next();if(t.done)return t;var e=t.value,r=e[0],e=e[1];return s.call(a,e,r,i)?n===K?t:W(n,r,e,t):(u=!1,N())})},e));var r,s,a},takeUntil:function(t,e){return this.takeWhile(rn(t),e)},update:function(t){return t(this)},valueSeq:function(){return this.toIndexedSeq()},hashCode:function(){return this.__hash||(this.__hash=function(t){if(t.size===1/0)return 0;var e=R(t),r=a(t),n=e?1:0;return function(t,e){return e=pt(e,3432918353),e=pt(e<<15|e>>>-15,461845907),e=pt(e<<13|e>>>-13,5),e=pt((e=(e+3864292196|0)^t)^e>>>16,2246822507),e=lt((e=pt(e^e>>>13,3266489909))^e>>>16)}(t.__iterate(r?e?function(t,e){n=31*n+sn(yt(t),yt(e))|0}:function(t,e){n=n+sn(yt(t),yt(e))|0}:e?function(t){n=31*n+yt(t)|0}:function(t){n=n+yt(t)|0}),n)}(this))}});var Xr=I.prototype;Xr[o]=!0,Xr[B]=Xr.values,Xr.toJSON=Xr.toArray,Xr.__toStringMapper=oe,Xr.inspect=Xr.toSource=function(){return""+this},Xr.chain=Xr.flatMap,Xr.contains=Xr.includes,Ur(O,{flip:function(){return Vt(this,Ut(this))},mapEntries:function(r,n){var i=this,o=0;return Vt(this,this.toSeq().map(function(t,e){return r.call(n,[e,t],o++,i)}).fromEntrySeq())},mapKeys:function(r,n){var i=this;return Vt(this,this.toSeq().flip().map(function(t,e){return r.call(n,t,e,i)}).flip())}});var Fr=O.prototype;Fr[s]=!0,Fr[B]=Xr.entries,Fr.toJSON=Qr,Fr.__toStringMapper=function(t,e){return oe(e)+": "+oe(t)},Ur(E,{toKeyedSeq:function(){return new xt(this,!1)},filter:function(t,e){return Vt(this,Lt(this,t,e,!1))},findIndex:function(t,e){e=this.findEntry(t,e);return e?e[0]:-1},indexOf:function(t){t=this.keyOf(t);return void 0===t?-1:t},lastIndexOf:function(t){t=this.lastKeyOf(t);return void 0===t?-1:t},reverse:function(){return Vt(this,Kt(this,!1))},slice:function(t,e){return Vt(this,Ct(this,t,e,!1))},splice:function(t,e){ var r=arguments.length;if(e=Math.max(e||0,0),0===r||2===r&&!e)return this;t=y(t,t<0?this.count():this.size);var n=this.slice(0,t);return Vt(this,1===r?n:n.concat(Zt(arguments,2),this.slice(t+e)))},findLastIndex:function(t,e){e=this.findLastEntry(t,e);return e?e[0]:-1},first:function(t){return this.get(0,t)},flatten:function(t){return Vt(this,Pt(this,t,!1))},get:function(r,t){return(r=h(this,r))<0||this.size===1/0||void 0!==this.size&&this.size>2)|0}Zr.has=Xr.includes,Zr.contains=Zr.includes,Zr.keys=Zr.values,Ur(G,Fr),Ur(Z,Gr),Ur($,Zr);var an=function(t){function e(r){return null==r?_n():kr(r)?r:_n().withMutations(function(e){var t=j(r);te(t.size),t.forEach(function(t){return e.add(t)})})}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).of=function(){return this(arguments)},e.fromKeys=function(t){return this(O(t).keySeq())},e.prototype.toString=function(){return this.__toString("OrderedSet {","}")},e}(Kr);an.isOrderedSet=kr;var cn,fn=an.prototype;function hn(t,e){var r=Object.create(fn);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function _n(){return cn=cn||hn(zr())}fn[k]=!0,fn.zip=Gr.zip,fn.zipWith=Gr.zipWith,fn.zipAll=Gr.zipAll,fn.__empty=_n,fn.__make=hn;Fr={LeftThenRight:-1,RightThenLeft:1};Zr=function(u,s){var a;!function(t){if(x(t))throw Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(A(t))throw Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(null===t||"object"!=typeof t)throw Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}(u);var c=function(t){var n=this;if(t instanceof c)return t;if(!(this instanceof c))return new c(t);if(!a){a=!0;var e=Object.keys(u),r=f._indices={};f._name=s,f._keys=e,f._defaultValues=u;for(var i=0;i>2)|0}Zr.has=Xr.includes,Zr.contains=Zr.includes,Zr.keys=Zr.values,Ur(G,Fr),Ur(Z,Gr),Ur($,Zr);var an=function(t){function e(r){return null==r?_n():kr(r)?r:_n().withMutations(function(e){var t=j(r);te(t.size),t.forEach(function(t){return e.add(t)})})}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).of=function(){return this(arguments)},e.fromKeys=function(t){return this(O(t).keySeq())},e.prototype.toString=function(){return this.__toString("OrderedSet {","}")},e}(Kr);an.isOrderedSet=kr;var cn,fn=an.prototype;function hn(t,e){var r=Object.create(fn);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function _n(){return cn=cn||hn(zr())}fn[k]=!0,fn.zip=Gr.zip,fn.zipWith=Gr.zipWith,fn.zipAll=Gr.zipAll,fn.__empty=_n,fn.__make=hn;Zr={LeftThenRight:-1,RightThenLeft:1};Gr=function(u,s){var a;!function(t){if(x(t))throw Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(A(t))throw Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(null===t||"object"!=typeof t)throw Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}(u);var c=function(t){var n=this;if(t instanceof c)return t;if(!(this instanceof c))return new c(t);if(!a){a=!0;var e=Object.keys(u),r=f._indices={};f._name=s,f._keys=e,f._defaultValues=u;for(var i=0;i Date: Fri, 26 Jan 2024 10:20:10 +0000 Subject: [PATCH 205/242] deploy: 2342972baf03612a286c6c0c66fdf68405a31e5a --- README.md | 2 +- dist/immutable.d.ts | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 02e143cd9e..a6eae67dd5 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![Build Status](https://github.com/immutable-js/immutable-js/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/immutable-js/immutable-js/actions/workflows/ci.yml?query=branch%3Amain) [Chat on slack](https://immutable-js.slack.com) -[Read the docs](https://immutable-js.com) and eat your vegetables. +[Read the docs](https://immutable-js.com/docs/) and eat your vegetables. Docs are automatically generated from [README.md][] and [immutable.d.ts][]. Please contribute! Also, don't miss the [wiki][] which contains articles on diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index 7bd59b2e2b..dc2b24547c 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -1713,6 +1713,8 @@ declare namespace Immutable { * `Set.fromKeys()` creates a new immutable Set containing the keys from * this Collection or JavaScript Object. */ + function fromKeys(iter: Collection.Keyed): Set; + // tslint:disable-next-line unified-signatures function fromKeys(iter: Collection): Set; function fromKeys(obj: { [key: string]: unknown }): Set; @@ -1936,6 +1938,8 @@ declare namespace Immutable { * `OrderedSet.fromKeys()` creates a new immutable OrderedSet containing * the keys from this Collection or JavaScript Object. */ + function fromKeys(iter: Collection.Keyed): OrderedSet; + // tslint:disable-next-line unified-signatures function fromKeys(iter: Collection): OrderedSet; function fromKeys(obj: { [key: string]: unknown }): OrderedSet; } From 904c3ff8c31b5b38cc56056ec58d7427d93125f5 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 26 Jan 2024 10:32:42 +0000 Subject: [PATCH 206/242] deploy: a5b50b2dcc36898e153ba8f1760ca7fc5d941046 --- bower.json | 2 +- dist/immutable.es.js | 2 +- dist/immutable.js | 2 +- dist/immutable.min.js | 4 ++-- package.json | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bower.json b/bower.json index de54a3d1ec..bbe31b2d9b 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "immutable", - "version": "4.3.4", + "version": "4.3.5", "description": "Immutable Data Collections", "license": "MIT", "homepage": "https://immutable-js.com", diff --git a/dist/immutable.es.js b/dist/immutable.es.js index 57e977f5d4..cc36709e45 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -5899,7 +5899,7 @@ function defaultConverter(k, v) { return isIndexed(v) ? v.toList() : isKeyed(v) ? v.toMap() : v.toSet(); } -var version = "4.3.4"; +var version = "4.3.5"; var Immutable = { version: version, diff --git a/dist/immutable.js b/dist/immutable.js index f96480a626..cd1dd8eeda 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -5905,7 +5905,7 @@ return isIndexed(v) ? v.toList() : isKeyed(v) ? v.toMap() : v.toSet(); } - var version = "4.3.4"; + var version = "4.3.5"; var Immutable = { version: version, diff --git a/dist/immutable.min.js b/dist/immutable.min.js index fc49aa8afd..e40a66bd47 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -51,5 +51,5 @@ return this.toKeyedSeq().reverse().findEntry(t,e,r)},findLastKey:function(t,e){r var r=arguments.length;if(e=Math.max(e||0,0),0===r||2===r&&!e)return this;t=y(t,t<0?this.count():this.size);var n=this.slice(0,t);return Vt(this,1===r?n:n.concat(Zt(arguments,2),this.slice(t+e)))},findLastIndex:function(t,e){e=this.findLastEntry(t,e);return e?e[0]:-1},first:function(t){return this.get(0,t)},flatten:function(t){return Vt(this,Pt(this,t,!1))},get:function(r,t){return(r=h(this,r))<0||this.size===1/0||void 0!==this.size&&this.size>2)|0}Zr.has=Xr.includes,Zr.contains=Zr.includes,Zr.keys=Zr.values,Ur(G,Fr),Ur(Z,Gr),Ur($,Zr);var an=function(t){function e(r){return null==r?_n():kr(r)?r:_n().withMutations(function(e){var t=j(r);te(t.size),t.forEach(function(t){return e.add(t)})})}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).of=function(){return this(arguments)},e.fromKeys=function(t){return this(O(t).keySeq())},e.prototype.toString=function(){return this.__toString("OrderedSet {","}")},e}(Kr);an.isOrderedSet=kr;var cn,fn=an.prototype;function hn(t,e){var r=Object.create(fn);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function _n(){return cn=cn||hn(zr())}fn[k]=!0,fn.zip=Gr.zip,fn.zipWith=Gr.zipWith,fn.zipAll=Gr.zipAll,fn.__empty=_n,fn.__make=hn;Zr={LeftThenRight:-1,RightThenLeft:1};Gr=function(u,s){var a;!function(t){if(x(t))throw Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(A(t))throw Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(null===t||"object"!=typeof t)throw Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}(u);var c=function(t){var n=this;if(t instanceof c)return t;if(!(this instanceof c))return new c(t);if(!a){a=!0;var e=Object.keys(u),r=f._indices={};f._name=s,f._keys=e,f._defaultValues=u;for(var i=0;i Date: Fri, 26 Jan 2024 22:59:19 +0000 Subject: [PATCH 207/242] deploy: 7f9ba5816e205cdaa8d1099389de6d5d679fa17d --- dist/immutable.es.js | 23 +++++++++++++++++++++++ dist/immutable.js | 23 +++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/dist/immutable.es.js b/dist/immutable.es.js index cc36709e45..d7d3891264 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -135,11 +135,13 @@ function isAssociative(maybeAssociative) { } var Collection = function Collection(value) { + // eslint-disable-next-line no-constructor-return return isCollection(value) ? value : Seq(value); }; var KeyedCollection = /*@__PURE__*/(function (Collection) { function KeyedCollection(value) { + // eslint-disable-next-line no-constructor-return return isKeyed(value) ? value : KeyedSeq(value); } @@ -152,6 +154,7 @@ var KeyedCollection = /*@__PURE__*/(function (Collection) { var IndexedCollection = /*@__PURE__*/(function (Collection) { function IndexedCollection(value) { + // eslint-disable-next-line no-constructor-return return isIndexed(value) ? value : IndexedSeq(value); } @@ -164,6 +167,7 @@ var IndexedCollection = /*@__PURE__*/(function (Collection) { var SetCollection = /*@__PURE__*/(function (Collection) { function SetCollection(value) { + // eslint-disable-next-line no-constructor-return return isCollection(value) && !isAssociative(value) ? value : SetSeq(value); } @@ -304,6 +308,7 @@ function isArrayLike(value) { var Seq = /*@__PURE__*/(function (Collection) { function Seq(value) { + // eslint-disable-next-line no-constructor-return return value === undefined || value === null ? emptySequence() : isImmutable(value) @@ -372,6 +377,7 @@ var Seq = /*@__PURE__*/(function (Collection) { var KeyedSeq = /*@__PURE__*/(function (Seq) { function KeyedSeq(value) { + // eslint-disable-next-line no-constructor-return return value === undefined || value === null ? emptySequence().toKeyedSeq() : isCollection(value) @@ -396,6 +402,7 @@ var KeyedSeq = /*@__PURE__*/(function (Seq) { var IndexedSeq = /*@__PURE__*/(function (Seq) { function IndexedSeq(value) { + // eslint-disable-next-line no-constructor-return return value === undefined || value === null ? emptySequence() : isCollection(value) @@ -428,6 +435,7 @@ var IndexedSeq = /*@__PURE__*/(function (Seq) { var SetSeq = /*@__PURE__*/(function (Seq) { function SetSeq(value) { + // eslint-disable-next-line no-constructor-return return ( isCollection(value) && !isAssociative(value) ? value : IndexedSeq(value) ).toSetSeq(); @@ -2376,6 +2384,7 @@ function wasAltered() { var Map = /*@__PURE__*/(function (KeyedCollection) { function Map(value) { + // eslint-disable-next-line no-constructor-return return value === undefined || value === null ? emptyMap() : isMap(value) && !isOrdered(value) @@ -3168,20 +3177,25 @@ var List = /*@__PURE__*/(function (IndexedCollection) { function List(value) { var empty = emptyList(); if (value === undefined || value === null) { + // eslint-disable-next-line no-constructor-return return empty; } if (isList(value)) { + // eslint-disable-next-line no-constructor-return return value; } var iter = IndexedCollection(value); var size = iter.size; if (size === 0) { + // eslint-disable-next-line no-constructor-return return empty; } assertNotInfinite(size); if (size > 0 && size < SIZE) { + // eslint-disable-next-line no-constructor-return return makeList(0, size, SHIFT, null, new VNode(iter.toArray())); } + // eslint-disable-next-line no-constructor-return return empty.withMutations(function (list) { list.setSize(size); iter.forEach(function (v, i) { return list.set(i, v); }); @@ -3817,6 +3831,7 @@ function getTailOffset(size) { var OrderedMap = /*@__PURE__*/(function (Map) { function OrderedMap(value) { + // eslint-disable-next-line no-constructor-return return value === undefined || value === null ? emptyOrderedMap() : isOrderedMap(value) @@ -3985,6 +4000,7 @@ function isStack(maybeStack) { var Stack = /*@__PURE__*/(function (IndexedCollection) { function Stack(value) { + // eslint-disable-next-line no-constructor-return return value === undefined || value === null ? emptyStack() : isStack(value) @@ -4319,6 +4335,7 @@ function toJS(value) { var Set = /*@__PURE__*/(function (SetCollection) { function Set(value) { + // eslint-disable-next-line no-constructor-return return value === undefined || value === null ? emptySet() : isSet(value) && !isOrdered(value) @@ -4566,6 +4583,7 @@ function emptySet() { var Range = /*@__PURE__*/(function (IndexedSeq) { function Range(start, end, step) { if (!(this instanceof Range)) { + // eslint-disable-next-line no-constructor-return return new Range(start, end, step); } invariant(step !== 0, 'Cannot step a Range by 0'); @@ -4583,6 +4601,7 @@ var Range = /*@__PURE__*/(function (IndexedSeq) { this.size = Math.max(0, Math.ceil((end - start) / step - 1) + 1); if (this.size === 0) { if (EMPTY_RANGE) { + // eslint-disable-next-line no-constructor-return return EMPTY_RANGE; } EMPTY_RANGE = this; @@ -5456,6 +5475,7 @@ function hashMerge(a, b) { var OrderedSet = /*@__PURE__*/(function (Set) { function OrderedSet(value) { + // eslint-disable-next-line no-constructor-return return value === undefined || value === null ? emptyOrderedSet() : isOrderedSet(value) @@ -5599,6 +5619,7 @@ var Record = function Record(defaultValues, name) { RecordType.displayName = name; } + // eslint-disable-next-line no-constructor-return return RecordType; }; @@ -5766,12 +5787,14 @@ function setProp(prototype, name) { var Repeat = /*@__PURE__*/(function (IndexedSeq) { function Repeat(value, times) { if (!(this instanceof Repeat)) { + // eslint-disable-next-line no-constructor-return return new Repeat(value, times); } this._value = value; this.size = times === undefined ? Infinity : Math.max(0, times); if (this.size === 0) { if (EMPTY_REPEAT) { + // eslint-disable-next-line no-constructor-return return EMPTY_REPEAT; } EMPTY_REPEAT = this; diff --git a/dist/immutable.js b/dist/immutable.js index cd1dd8eeda..305dc1e6e5 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -141,11 +141,13 @@ } var Collection = function Collection(value) { + // eslint-disable-next-line no-constructor-return return isCollection(value) ? value : Seq(value); }; var KeyedCollection = /*@__PURE__*/(function (Collection) { function KeyedCollection(value) { + // eslint-disable-next-line no-constructor-return return isKeyed(value) ? value : KeyedSeq(value); } @@ -158,6 +160,7 @@ var IndexedCollection = /*@__PURE__*/(function (Collection) { function IndexedCollection(value) { + // eslint-disable-next-line no-constructor-return return isIndexed(value) ? value : IndexedSeq(value); } @@ -170,6 +173,7 @@ var SetCollection = /*@__PURE__*/(function (Collection) { function SetCollection(value) { + // eslint-disable-next-line no-constructor-return return isCollection(value) && !isAssociative(value) ? value : SetSeq(value); } @@ -310,6 +314,7 @@ var Seq = /*@__PURE__*/(function (Collection) { function Seq(value) { + // eslint-disable-next-line no-constructor-return return value === undefined || value === null ? emptySequence() : isImmutable(value) @@ -378,6 +383,7 @@ var KeyedSeq = /*@__PURE__*/(function (Seq) { function KeyedSeq(value) { + // eslint-disable-next-line no-constructor-return return value === undefined || value === null ? emptySequence().toKeyedSeq() : isCollection(value) @@ -402,6 +408,7 @@ var IndexedSeq = /*@__PURE__*/(function (Seq) { function IndexedSeq(value) { + // eslint-disable-next-line no-constructor-return return value === undefined || value === null ? emptySequence() : isCollection(value) @@ -434,6 +441,7 @@ var SetSeq = /*@__PURE__*/(function (Seq) { function SetSeq(value) { + // eslint-disable-next-line no-constructor-return return ( isCollection(value) && !isAssociative(value) ? value : IndexedSeq(value) ).toSetSeq(); @@ -2382,6 +2390,7 @@ var Map = /*@__PURE__*/(function (KeyedCollection) { function Map(value) { + // eslint-disable-next-line no-constructor-return return value === undefined || value === null ? emptyMap() : isMap(value) && !isOrdered(value) @@ -3174,20 +3183,25 @@ function List(value) { var empty = emptyList(); if (value === undefined || value === null) { + // eslint-disable-next-line no-constructor-return return empty; } if (isList(value)) { + // eslint-disable-next-line no-constructor-return return value; } var iter = IndexedCollection(value); var size = iter.size; if (size === 0) { + // eslint-disable-next-line no-constructor-return return empty; } assertNotInfinite(size); if (size > 0 && size < SIZE) { + // eslint-disable-next-line no-constructor-return return makeList(0, size, SHIFT, null, new VNode(iter.toArray())); } + // eslint-disable-next-line no-constructor-return return empty.withMutations(function (list) { list.setSize(size); iter.forEach(function (v, i) { return list.set(i, v); }); @@ -3823,6 +3837,7 @@ var OrderedMap = /*@__PURE__*/(function (Map) { function OrderedMap(value) { + // eslint-disable-next-line no-constructor-return return value === undefined || value === null ? emptyOrderedMap() : isOrderedMap(value) @@ -3991,6 +4006,7 @@ var Stack = /*@__PURE__*/(function (IndexedCollection) { function Stack(value) { + // eslint-disable-next-line no-constructor-return return value === undefined || value === null ? emptyStack() : isStack(value) @@ -4325,6 +4341,7 @@ var Set = /*@__PURE__*/(function (SetCollection) { function Set(value) { + // eslint-disable-next-line no-constructor-return return value === undefined || value === null ? emptySet() : isSet(value) && !isOrdered(value) @@ -4572,6 +4589,7 @@ var Range = /*@__PURE__*/(function (IndexedSeq) { function Range(start, end, step) { if (!(this instanceof Range)) { + // eslint-disable-next-line no-constructor-return return new Range(start, end, step); } invariant(step !== 0, 'Cannot step a Range by 0'); @@ -4589,6 +4607,7 @@ this.size = Math.max(0, Math.ceil((end - start) / step - 1) + 1); if (this.size === 0) { if (EMPTY_RANGE) { + // eslint-disable-next-line no-constructor-return return EMPTY_RANGE; } EMPTY_RANGE = this; @@ -5462,6 +5481,7 @@ var OrderedSet = /*@__PURE__*/(function (Set) { function OrderedSet(value) { + // eslint-disable-next-line no-constructor-return return value === undefined || value === null ? emptyOrderedSet() : isOrderedSet(value) @@ -5605,6 +5625,7 @@ RecordType.displayName = name; } + // eslint-disable-next-line no-constructor-return return RecordType; }; @@ -5772,12 +5793,14 @@ var Repeat = /*@__PURE__*/(function (IndexedSeq) { function Repeat(value, times) { if (!(this instanceof Repeat)) { + // eslint-disable-next-line no-constructor-return return new Repeat(value, times); } this._value = value; this.size = times === undefined ? Infinity : Math.max(0, times); if (this.size === 0) { if (EMPTY_REPEAT) { + // eslint-disable-next-line no-constructor-return return EMPTY_REPEAT; } EMPTY_REPEAT = this; From 0dac1b825e71c3689bf4b65c2dcc0de7511289f2 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 10 May 2024 10:15:58 +0000 Subject: [PATCH 208/242] deploy: be3cb9a7ae9a29f82c9d0c595f5f3cb957d7006c --- dist/immutable.es.js | 2 +- dist/immutable.js | 2 +- dist/immutable.min.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/dist/immutable.es.js b/dist/immutable.es.js index d7d3891264..1100c49b33 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -5873,7 +5873,7 @@ var Repeat = /*@__PURE__*/(function (IndexedSeq) { Repeat.prototype.equals = function equals (other) { return other instanceof Repeat ? is(this._value, other._value) - : deepEqual(other); + : deepEqual(this, other); }; return Repeat; diff --git a/dist/immutable.js b/dist/immutable.js index 305dc1e6e5..7516b4df74 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -5879,7 +5879,7 @@ Repeat.prototype.equals = function equals (other) { return other instanceof Repeat ? is(this._value, other._value) - : deepEqual(other); + : deepEqual(this, other); }; return Repeat; diff --git a/dist/immutable.min.js b/dist/immutable.min.js index e40a66bd47..3235fb8adc 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -51,5 +51,5 @@ return this.toKeyedSeq().reverse().findEntry(t,e,r)},findLastKey:function(t,e){r var r=arguments.length;if(e=Math.max(e||0,0),0===r||2===r&&!e)return this;t=y(t,t<0?this.count():this.size);var n=this.slice(0,t);return Vt(this,1===r?n:n.concat(Zt(arguments,2),this.slice(t+e)))},findLastIndex:function(t,e){e=this.findLastEntry(t,e);return e?e[0]:-1},first:function(t){return this.get(0,t)},flatten:function(t){return Vt(this,Pt(this,t,!1))},get:function(r,t){return(r=h(this,r))<0||this.size===1/0||void 0!==this.size&&this.size>2)|0}Zr.has=Xr.includes,Zr.contains=Zr.includes,Zr.keys=Zr.values,Ur(G,Fr),Ur(Z,Gr),Ur($,Zr);var an=function(t){function e(r){return null==r?_n():kr(r)?r:_n().withMutations(function(e){var t=j(r);te(t.size),t.forEach(function(t){return e.add(t)})})}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).of=function(){return this(arguments)},e.fromKeys=function(t){return this(O(t).keySeq())},e.prototype.toString=function(){return this.__toString("OrderedSet {","}")},e}(Kr);an.isOrderedSet=kr;var cn,fn=an.prototype;function hn(t,e){var r=Object.create(fn);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function _n(){return cn=cn||hn(zr())}fn[k]=!0,fn.zip=Gr.zip,fn.zipWith=Gr.zipWith,fn.zipAll=Gr.zipAll,fn.__empty=_n,fn.__make=hn;Zr={LeftThenRight:-1,RightThenLeft:1};Gr=function(u,s){var a;!function(t){if(x(t))throw Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(A(t))throw Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(null===t||"object"!=typeof t)throw Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}(u);var c=function(t){var n=this;if(t instanceof c)return t;if(!(this instanceof c))return new c(t);if(!a){a=!0;var e=Object.keys(u),r=f._indices={};f._name=s,f._keys=e,f._defaultValues=u;for(var i=0;i Date: Mon, 13 May 2024 09:01:52 +0000 Subject: [PATCH 209/242] deploy: 493afba6ec17d9c999dc5a15ac80c71c6bdba1c3 --- bower.json | 2 +- dist/immutable.es.js | 2 +- dist/immutable.js | 2 +- dist/immutable.min.js | 4 ++-- package.json | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bower.json b/bower.json index bbe31b2d9b..431cf9a526 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "immutable", - "version": "4.3.5", + "version": "4.3.6", "description": "Immutable Data Collections", "license": "MIT", "homepage": "https://immutable-js.com", diff --git a/dist/immutable.es.js b/dist/immutable.es.js index 1100c49b33..2c6730e51a 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -5922,7 +5922,7 @@ function defaultConverter(k, v) { return isIndexed(v) ? v.toList() : isKeyed(v) ? v.toMap() : v.toSet(); } -var version = "4.3.5"; +var version = "4.3.6"; var Immutable = { version: version, diff --git a/dist/immutable.js b/dist/immutable.js index 7516b4df74..13ba74bf7b 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -5928,7 +5928,7 @@ return isIndexed(v) ? v.toList() : isKeyed(v) ? v.toMap() : v.toSet(); } - var version = "4.3.5"; + var version = "4.3.6"; var Immutable = { version: version, diff --git a/dist/immutable.min.js b/dist/immutable.min.js index 3235fb8adc..b502eaaf91 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -51,5 +51,5 @@ return this.toKeyedSeq().reverse().findEntry(t,e,r)},findLastKey:function(t,e){r var r=arguments.length;if(e=Math.max(e||0,0),0===r||2===r&&!e)return this;t=y(t,t<0?this.count():this.size);var n=this.slice(0,t);return Vt(this,1===r?n:n.concat(Zt(arguments,2),this.slice(t+e)))},findLastIndex:function(t,e){e=this.findLastEntry(t,e);return e?e[0]:-1},first:function(t){return this.get(0,t)},flatten:function(t){return Vt(this,Pt(this,t,!1))},get:function(r,t){return(r=h(this,r))<0||this.size===1/0||void 0!==this.size&&this.size>2)|0}Zr.has=Xr.includes,Zr.contains=Zr.includes,Zr.keys=Zr.values,Ur(G,Fr),Ur(Z,Gr),Ur($,Zr);var an=function(t){function e(r){return null==r?_n():kr(r)?r:_n().withMutations(function(e){var t=j(r);te(t.size),t.forEach(function(t){return e.add(t)})})}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).of=function(){return this(arguments)},e.fromKeys=function(t){return this(O(t).keySeq())},e.prototype.toString=function(){return this.__toString("OrderedSet {","}")},e}(Kr);an.isOrderedSet=kr;var cn,fn=an.prototype;function hn(t,e){var r=Object.create(fn);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function _n(){return cn=cn||hn(zr())}fn[k]=!0,fn.zip=Gr.zip,fn.zipWith=Gr.zipWith,fn.zipAll=Gr.zipAll,fn.__empty=_n,fn.__make=hn;Zr={LeftThenRight:-1,RightThenLeft:1};Gr=function(u,s){var a;!function(t){if(x(t))throw Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(A(t))throw Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(null===t||"object"!=typeof t)throw Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}(u);var c=function(t){var n=this;if(t instanceof c)return t;if(!(this instanceof c))return new c(t);if(!a){a=!0;var e=Object.keys(u),r=f._indices={};f._name=s,f._keys=e,f._defaultValues=u;for(var i=0;i Date: Mon, 22 Jul 2024 12:07:52 +0000 Subject: [PATCH 210/242] deploy: 23daf26b51ecc2805dcd9ac8534ce523397f9b62 --- dist/immutable.es.js | 10 +++++----- dist/immutable.js | 10 +++++----- dist/immutable.min.js | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/dist/immutable.es.js b/dist/immutable.es.js index 2c6730e51a..4735fdde53 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -1437,16 +1437,16 @@ function sliceFactory(collection, begin, end, useKeys) { return collection; } - var resolvedBegin = resolveBegin(begin, originalSize); - var resolvedEnd = resolveEnd(end, originalSize); - - // begin or end will be NaN if they were provided as negative numbers and + // begin or end can not be resolved if they were provided as negative numbers and // this collection's size is unknown. In that case, cache first so there is // a known size and these do not resolve to NaN. - if (resolvedBegin !== resolvedBegin || resolvedEnd !== resolvedEnd) { + if (typeof originalSize === 'undefined' && (begin < 0 || end < 0)) { return sliceFactory(collection.toSeq().cacheResult(), begin, end, useKeys); } + var resolvedBegin = resolveBegin(begin, originalSize); + var resolvedEnd = resolveEnd(end, originalSize); + // Note: resolvedEnd is undefined when the original sequence's length is // unknown and this slice did not supply an end and should contain all // elements after resolvedBegin. diff --git a/dist/immutable.js b/dist/immutable.js index 13ba74bf7b..6fafc99af6 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -1443,16 +1443,16 @@ return collection; } - var resolvedBegin = resolveBegin(begin, originalSize); - var resolvedEnd = resolveEnd(end, originalSize); - - // begin or end will be NaN if they were provided as negative numbers and + // begin or end can not be resolved if they were provided as negative numbers and // this collection's size is unknown. In that case, cache first so there is // a known size and these do not resolve to NaN. - if (resolvedBegin !== resolvedBegin || resolvedEnd !== resolvedEnd) { + if (typeof originalSize === 'undefined' && (begin < 0 || end < 0)) { return sliceFactory(collection.toSeq().cacheResult(), begin, end, useKeys); } + var resolvedBegin = resolveBegin(begin, originalSize); + var resolvedEnd = resolveEnd(end, originalSize); + // Note: resolvedEnd is undefined when the original sequence's length is // unknown and this slice did not supply an end and should contain all // elements after resolvedBegin. diff --git a/dist/immutable.min.js b/dist/immutable.min.js index b502eaaf91..bfcccb1985 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -28,7 +28,7 @@ if(e)return this.cacheResult().__iterate(t,e);var r,n=V(this._collection),i=0;if var e;if(bt&&void 0!==(e=zt.get(t)))return e;if(void 0!==(e=t[Et]))return e;if(!wt){if(void 0!==(e=t.propertyIsEnumerable&&t.propertyIsEnumerable[Et]))return e;if(void 0!==(e=function(t){if(t&&0f)return N();var t=r.next();return a||e===T||t.done?t:W(e,i-1,e===U?void 0:t.value[1],t)})},r}function Bt(e,c,f,h){var t=Xt(e);return t.__iterateUncached=function(n,t){var i=this;if(t)return this.cacheResult().__iterate(n,t);var o=!0,u=0;return e.__iterate(function(t,e,r){if(!(o=o&&c.call(f,t,e,r)))return u++,n(t,h?e:u-1,i)}),u},t.__iteratorUncached=function(i,t){var o=this;if(t)return this.cacheResult().__iterator(i,t);var u=e.__iterator(K,t),s=!0,a=0;return new P(function(){var t;do{if((t=u.next()).done)return h||i===T?t:W(i,a++,i===U?void 0:t.value[1],t);var e=t.value,r=e[0],n=e[1];s=s&&c.call(f,n,r,o)}while(s);return i===K?t:W(i,r,n,t)})},t}function Pt(t,s,a){var c=Xt(t);return c.__iterateUncached=function(i,e){if(e)return this.cacheResult().__iterate(i,e);var o=0,u=!1;return function r(t,n){t.__iterate(function(t,e){return(!s||nc)return N();var t=r.next();return a||e===T||t.done?t:W(e,i-1,e===U?void 0:t.value[1],t)})},r}function Bt(e,c,f,h){var t=Xt(e);return t.__iterateUncached=function(n,t){var i=this;if(t)return this.cacheResult().__iterate(n,t);var o=!0,u=0;return e.__iterate(function(t,e,r){if(!(o=o&&c.call(f,t,e,r)))return u++,n(t,h?e:u-1,i)}),u},t.__iteratorUncached=function(i,t){var o=this;if(t)return this.cacheResult().__iterator(i,t);var u=e.__iterator(K,t),s=!0,a=0;return new P(function(){var t;do{if((t=u.next()).done)return h||i===T?t:W(i,a++,i===U?void 0:t.value[1],t);var e=t.value,r=e[0],n=e[1];s=s&&c.call(f,n,r,o)}while(s);return i===K?t:W(i,r,n,t)})},t}function Pt(t,s,a){var c=Xt(t);return c.__iterateUncached=function(i,e){if(e)return this.cacheResult().__iterate(i,e);var o=0,u=!1;return function r(t,n){t.__iterate(function(t,e){return(!s||n Date: Mon, 22 Jul 2024 12:11:52 +0000 Subject: [PATCH 211/242] deploy: 37ca4170060827e5f4eaa1969d1b61e5dc5eb11d --- bower.json | 2 +- dist/immutable.es.js | 2 +- dist/immutable.js | 2 +- dist/immutable.min.js | 4 ++-- package.json | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bower.json b/bower.json index 431cf9a526..e380730f6d 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "immutable", - "version": "4.3.6", + "version": "4.3.7", "description": "Immutable Data Collections", "license": "MIT", "homepage": "https://immutable-js.com", diff --git a/dist/immutable.es.js b/dist/immutable.es.js index 4735fdde53..30f5e00e66 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -5922,7 +5922,7 @@ function defaultConverter(k, v) { return isIndexed(v) ? v.toList() : isKeyed(v) ? v.toMap() : v.toSet(); } -var version = "4.3.6"; +var version = "4.3.7"; var Immutable = { version: version, diff --git a/dist/immutable.js b/dist/immutable.js index 6fafc99af6..61aa251039 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -5928,7 +5928,7 @@ return isIndexed(v) ? v.toList() : isKeyed(v) ? v.toMap() : v.toSet(); } - var version = "4.3.6"; + var version = "4.3.7"; var Immutable = { version: version, diff --git a/dist/immutable.min.js b/dist/immutable.min.js index bfcccb1985..641cdbe205 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -51,5 +51,5 @@ return this.toKeyedSeq().reverse().findEntry(t,e,r)},findLastKey:function(t,e){r var r=arguments.length;if(e=Math.max(e||0,0),0===r||2===r&&!e)return this;t=y(t,t<0?this.count():this.size);var n=this.slice(0,t);return Vt(this,1===r?n:n.concat(Zt(arguments,2),this.slice(t+e)))},findLastIndex:function(t,e){e=this.findLastEntry(t,e);return e?e[0]:-1},first:function(t){return this.get(0,t)},flatten:function(t){return Vt(this,Pt(this,t,!1))},get:function(r,t){return(r=h(this,r))<0||this.size===1/0||void 0!==this.size&&this.size>2)|0}Zr.has=Xr.includes,Zr.contains=Zr.includes,Zr.keys=Zr.values,Ur(G,Fr),Ur(Z,Gr),Ur($,Zr);var an=function(t){function e(r){return null==r?_n():kr(r)?r:_n().withMutations(function(e){var t=j(r);te(t.size),t.forEach(function(t){return e.add(t)})})}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).of=function(){return this(arguments)},e.fromKeys=function(t){return this(O(t).keySeq())},e.prototype.toString=function(){return this.__toString("OrderedSet {","}")},e}(Kr);an.isOrderedSet=kr;var cn,fn=an.prototype;function hn(t,e){var r=Object.create(fn);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function _n(){return cn=cn||hn(zr())}fn[k]=!0,fn.zip=Gr.zip,fn.zipWith=Gr.zipWith,fn.zipAll=Gr.zipAll,fn.__empty=_n,fn.__make=hn;Zr={LeftThenRight:-1,RightThenLeft:1};Gr=function(u,s){var a;!function(t){if(x(t))throw Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(A(t))throw Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(null===t||"object"!=typeof t)throw Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}(u);var c=function(t){var n=this;if(t instanceof c)return t;if(!(this instanceof c))return new c(t);if(!a){a=!0;var e=Object.keys(u),r=f._indices={};f._name=s,f._keys=e,f._defaultValues=u;for(var i=0;i Date: Thu, 17 Oct 2024 22:06:34 +0000 Subject: [PATCH 212/242] deploy: 2898646e0378c397e3be4e2c097a00e306c984cf --- README.md | 8 +- bower.json | 5 +- dist/es/Collection.js | 79 + dist/es/CollectionImpl.js | 776 ++++ dist/es/Hash.js | 260 ++ dist/es/Immutable.js | 73 + dist/es/Iterator.js | 106 + dist/es/List.js | 697 ++++ dist/es/Map.js | 820 ++++ dist/es/Math.js | 45 + dist/es/Operations.js | 953 +++++ dist/es/OrderedMap.js | 196 + dist/es/OrderedSet.js | 92 + dist/es/PairSorting.js | 30 + dist/es/Range.js | 178 + dist/es/Record.js | 292 ++ dist/es/Repeat.js | 133 + dist/es/Seq.js | 401 ++ dist/es/Set.js | 279 ++ dist/es/Stack.js | 261 ++ dist/es/TrieUtils.js | 117 + dist/es/fromJS.js | 74 + dist/es/functional/get.js | 38 + dist/es/functional/getIn.js | 41 + dist/es/functional/has.js | 35 + dist/es/functional/hasIn.js | 32 + dist/es/functional/merge.js | 137 + dist/es/functional/remove.js | 56 + dist/es/functional/removeIn.js | 32 + dist/es/functional/set.js | 52 + dist/es/functional/setIn.js | 32 + dist/es/functional/update.js | 31 + dist/es/functional/updateIn.js | 94 + dist/es/is.js | 108 + dist/es/methods/asImmutable.js | 29 + dist/es/methods/asMutable.js | 31 + dist/es/methods/deleteIn.js | 31 + dist/es/methods/getIn.js | 31 + dist/es/methods/hasIn.js | 31 + dist/es/methods/merge.js | 79 + dist/es/methods/mergeDeep.js | 41 + dist/es/methods/mergeDeepIn.js | 37 + dist/es/methods/mergeIn.js | 36 + dist/es/methods/setIn.js | 31 + dist/es/methods/toObject.js | 36 + dist/es/methods/update.js | 33 + dist/es/methods/updateIn.js | 31 + dist/es/methods/wasAltered.js | 29 + dist/es/methods/withMutations.js | 31 + dist/es/package.json.js | 27 + dist/es/predicates/isAssociative.js | 32 + dist/es/predicates/isCollection.js | 32 + dist/es/predicates/isImmutable.js | 32 + dist/es/predicates/isIndexed.js | 31 + dist/es/predicates/isKeyed.js | 31 + dist/es/predicates/isList.js | 31 + dist/es/predicates/isMap.js | 31 + dist/es/predicates/isOrdered.js | 31 + dist/es/predicates/isOrderedMap.js | 32 + dist/es/predicates/isOrderedSet.js | 32 + dist/es/predicates/isRecord.js | 31 + dist/es/predicates/isSeq.js | 31 + dist/es/predicates/isSet.js | 31 + dist/es/predicates/isStack.js | 31 + dist/es/predicates/isValueObject.js | 33 + dist/es/toJS.js | 54 + dist/es/utils/arrCopy.js | 36 + dist/es/utils/assertNotInfinite.js | 34 + dist/es/utils/coerceKeyPath.js | 40 + dist/es/utils/deepEqual.js | 99 + dist/es/utils/hasOwnProperty.js | 27 + dist/es/utils/invariant.js | 29 + dist/es/utils/isArrayLike.js | 44 + dist/es/utils/isDataStructure.js | 39 + dist/es/utils/isPlainObj.js | 52 + dist/es/utils/mixin.js | 38 + dist/es/utils/quoteString.js | 36 + dist/es/utils/shallowCopy.js | 41 + dist/immutable.d.ts | 209 +- dist/immutable.es.js | 5988 --------------------------- dist/immutable.js | 125 +- dist/immutable.js.flow | 18 +- dist/immutable.min.js | 34 +- package.json | 5 +- 84 files changed, 8350 insertions(+), 6197 deletions(-) create mode 100644 dist/es/Collection.js create mode 100644 dist/es/CollectionImpl.js create mode 100644 dist/es/Hash.js create mode 100644 dist/es/Immutable.js create mode 100644 dist/es/Iterator.js create mode 100644 dist/es/List.js create mode 100644 dist/es/Map.js create mode 100644 dist/es/Math.js create mode 100644 dist/es/Operations.js create mode 100644 dist/es/OrderedMap.js create mode 100644 dist/es/OrderedSet.js create mode 100644 dist/es/PairSorting.js create mode 100644 dist/es/Range.js create mode 100644 dist/es/Record.js create mode 100644 dist/es/Repeat.js create mode 100644 dist/es/Seq.js create mode 100644 dist/es/Set.js create mode 100644 dist/es/Stack.js create mode 100644 dist/es/TrieUtils.js create mode 100644 dist/es/fromJS.js create mode 100644 dist/es/functional/get.js create mode 100644 dist/es/functional/getIn.js create mode 100644 dist/es/functional/has.js create mode 100644 dist/es/functional/hasIn.js create mode 100644 dist/es/functional/merge.js create mode 100644 dist/es/functional/remove.js create mode 100644 dist/es/functional/removeIn.js create mode 100644 dist/es/functional/set.js create mode 100644 dist/es/functional/setIn.js create mode 100644 dist/es/functional/update.js create mode 100644 dist/es/functional/updateIn.js create mode 100644 dist/es/is.js create mode 100644 dist/es/methods/asImmutable.js create mode 100644 dist/es/methods/asMutable.js create mode 100644 dist/es/methods/deleteIn.js create mode 100644 dist/es/methods/getIn.js create mode 100644 dist/es/methods/hasIn.js create mode 100644 dist/es/methods/merge.js create mode 100644 dist/es/methods/mergeDeep.js create mode 100644 dist/es/methods/mergeDeepIn.js create mode 100644 dist/es/methods/mergeIn.js create mode 100644 dist/es/methods/setIn.js create mode 100644 dist/es/methods/toObject.js create mode 100644 dist/es/methods/update.js create mode 100644 dist/es/methods/updateIn.js create mode 100644 dist/es/methods/wasAltered.js create mode 100644 dist/es/methods/withMutations.js create mode 100644 dist/es/package.json.js create mode 100644 dist/es/predicates/isAssociative.js create mode 100644 dist/es/predicates/isCollection.js create mode 100644 dist/es/predicates/isImmutable.js create mode 100644 dist/es/predicates/isIndexed.js create mode 100644 dist/es/predicates/isKeyed.js create mode 100644 dist/es/predicates/isList.js create mode 100644 dist/es/predicates/isMap.js create mode 100644 dist/es/predicates/isOrdered.js create mode 100644 dist/es/predicates/isOrderedMap.js create mode 100644 dist/es/predicates/isOrderedSet.js create mode 100644 dist/es/predicates/isRecord.js create mode 100644 dist/es/predicates/isSeq.js create mode 100644 dist/es/predicates/isSet.js create mode 100644 dist/es/predicates/isStack.js create mode 100644 dist/es/predicates/isValueObject.js create mode 100644 dist/es/toJS.js create mode 100644 dist/es/utils/arrCopy.js create mode 100644 dist/es/utils/assertNotInfinite.js create mode 100644 dist/es/utils/coerceKeyPath.js create mode 100644 dist/es/utils/deepEqual.js create mode 100644 dist/es/utils/hasOwnProperty.js create mode 100644 dist/es/utils/invariant.js create mode 100644 dist/es/utils/isArrayLike.js create mode 100644 dist/es/utils/isDataStructure.js create mode 100644 dist/es/utils/isPlainObj.js create mode 100644 dist/es/utils/mixin.js create mode 100644 dist/es/utils/quoteString.js create mode 100644 dist/es/utils/shallowCopy.js delete mode 100644 dist/immutable.es.js diff --git a/README.md b/README.md index a6eae67dd5..bcb5d0b818 100644 --- a/README.md +++ b/README.md @@ -86,7 +86,7 @@ map1.get('b') + ' vs. ' + map2.get('b'); // 2 vs. 50 Immutable.js has no dependencies, which makes it predictable to include in a Browser. -It's highly recommended to use a module bundler like [webpack](https://webpack.github.io/), +It's highly recommended to use a module bundler like [webpack](https://webpack.js.org/), [rollup](https://rollupjs.org/), or [browserify](https://browserify.org/). The `immutable` npm module works without any additional consideration. All examples throughout the documentation @@ -152,9 +152,9 @@ via relative path to the type definitions at the top of your file. ```js /// -import Immutable from 'immutable'; -var map1: Immutable.Map; -map1 = Immutable.Map({ a: 1, b: 2, c: 3 }); +import { Map } from 'immutable'; +var map1: Map; +map1 = Map({ a: 1, b: 2, c: 3 }); var map2 = map1.set('b', 50); map1.get('b'); // 2 map2.get('b'); // 50 diff --git a/bower.json b/bower.json index e380730f6d..7a9f05049d 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "immutable", - "version": "4.3.7", + "version": "5.0.0-rc.1", "description": "Immutable Data Collections", "license": "MIT", "homepage": "https://immutable-js.com", @@ -16,8 +16,7 @@ "url": "https://github.com/immutable-js/immutable-js/issues" }, "main": "dist/immutable.js", - "module": "dist/immutable.es.js", - "sideEffects": false, + "module": "dist/es/Immutable.js", "types": "dist/immutable.d.ts", "files": [ "dist", diff --git a/dist/es/Collection.js b/dist/es/Collection.js new file mode 100644 index 0000000000..0b6f921efc --- /dev/null +++ b/dist/es/Collection.js @@ -0,0 +1,79 @@ +/** + * @license + * MIT License + * + * Copyright (c) 2014-present, Lee Byron and other contributors. + * + * 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: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +import { Seq, KeyedSeq, IndexedSeq, SetSeq } from './Seq.js'; +import { isCollection } from './predicates/isCollection.js'; +import { isKeyed } from './predicates/isKeyed.js'; +import { isIndexed } from './predicates/isIndexed.js'; +import { isAssociative } from './predicates/isAssociative.js'; + +var Collection = function Collection(value) { + // eslint-disable-next-line no-constructor-return + return isCollection(value) ? value : Seq(value); +}; + +var KeyedCollection = /*@__PURE__*/(function (Collection) { + function KeyedCollection(value) { + // eslint-disable-next-line no-constructor-return + return isKeyed(value) ? value : KeyedSeq(value); + } + + if ( Collection ) KeyedCollection.__proto__ = Collection; + KeyedCollection.prototype = Object.create( Collection && Collection.prototype ); + KeyedCollection.prototype.constructor = KeyedCollection; + + return KeyedCollection; +}(Collection)); + +var IndexedCollection = /*@__PURE__*/(function (Collection) { + function IndexedCollection(value) { + // eslint-disable-next-line no-constructor-return + return isIndexed(value) ? value : IndexedSeq(value); + } + + if ( Collection ) IndexedCollection.__proto__ = Collection; + IndexedCollection.prototype = Object.create( Collection && Collection.prototype ); + IndexedCollection.prototype.constructor = IndexedCollection; + + return IndexedCollection; +}(Collection)); + +var SetCollection = /*@__PURE__*/(function (Collection) { + function SetCollection(value) { + // eslint-disable-next-line no-constructor-return + return isCollection(value) && !isAssociative(value) ? value : SetSeq(value); + } + + if ( Collection ) SetCollection.__proto__ = Collection; + SetCollection.prototype = Object.create( Collection && Collection.prototype ); + SetCollection.prototype.constructor = SetCollection; + + return SetCollection; +}(Collection)); + +Collection.Keyed = KeyedCollection; +Collection.Indexed = IndexedCollection; +Collection.Set = SetCollection; + +export { Collection, IndexedCollection, KeyedCollection, SetCollection }; diff --git a/dist/es/CollectionImpl.js b/dist/es/CollectionImpl.js new file mode 100644 index 0000000000..2040320a58 --- /dev/null +++ b/dist/es/CollectionImpl.js @@ -0,0 +1,776 @@ +/** + * @license + * MIT License + * + * Copyright (c) 2014-present, Lee Byron and other contributors. + * + * 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: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +import { Collection, KeyedCollection, IndexedCollection, SetCollection } from './Collection.js'; +import { IS_COLLECTION_SYMBOL } from './predicates/isCollection.js'; +import { isKeyed, IS_KEYED_SYMBOL } from './predicates/isKeyed.js'; +import { isIndexed, IS_INDEXED_SYMBOL } from './predicates/isIndexed.js'; +import { IS_ORDERED_SYMBOL, isOrdered } from './predicates/isOrdered.js'; +import { is } from './is.js'; +import { ensureSize, returnTrue, NOT_SET, resolveBegin, wrapIndex } from './TrieUtils.js'; +import { hash } from './Hash.js'; +import { imul, smi } from './Math.js'; +import { ITERATE_ENTRIES, ITERATE_KEYS, ITERATE_VALUES, ITERATOR_SYMBOL, Iterator } from './Iterator.js'; +import arrCopy from './utils/arrCopy.js'; +import assertNotInfinite from './utils/assertNotInfinite.js'; +import deepEqual from './utils/deepEqual.js'; +import mixin from './utils/mixin.js'; +import quoteString from './utils/quoteString.js'; +import { toJS } from './toJS.js'; +import { Map } from './Map.js'; +import { OrderedMap } from './OrderedMap.js'; +import { List } from './List.js'; +import { Set } from './Set.js'; +import { OrderedSet } from './OrderedSet.js'; +import { Stack } from './Stack.js'; +import { Range } from './Range.js'; +import { ArraySeq, IndexedSeq, KeyedSeq, SetSeq } from './Seq.js'; +import { ToIndexedSequence, ToKeyedSequence, ToSetSequence, reify, concatFactory, filterFactory, partitionFactory, mapFactory, reverseFactory, sliceFactory, sortFactory, countByFactory, flatMapFactory, flattenFactory, FromEntriesSequence, groupByFactory, maxFactory, skipWhileFactory, takeWhileFactory, flipFactory, interposeFactory, zipWithFactory } from './Operations.js'; +import { getIn } from './methods/getIn.js'; +import { hasIn } from './methods/hasIn.js'; +import { toObject } from './methods/toObject.js'; + +Collection.Iterator = Iterator; + +mixin(Collection, { + // ### Conversion to other types + + toArray: function toArray() { + assertNotInfinite(this.size); + var array = new Array(this.size || 0); + var useTuples = isKeyed(this); + var i = 0; + this.__iterate(function (v, k) { + // Keyed collections produce an array of tuples. + array[i++] = useTuples ? [k, v] : v; + }); + return array; + }, + + toIndexedSeq: function toIndexedSeq() { + return new ToIndexedSequence(this); + }, + + toJS: function toJS$1() { + return toJS(this); + }, + + toKeyedSeq: function toKeyedSeq() { + return new ToKeyedSequence(this, true); + }, + + toMap: function toMap() { + // Use Late Binding here to solve the circular dependency. + return Map(this.toKeyedSeq()); + }, + + toObject: toObject, + + toOrderedMap: function toOrderedMap() { + // Use Late Binding here to solve the circular dependency. + return OrderedMap(this.toKeyedSeq()); + }, + + toOrderedSet: function toOrderedSet() { + // Use Late Binding here to solve the circular dependency. + return OrderedSet(isKeyed(this) ? this.valueSeq() : this); + }, + + toSet: function toSet() { + // Use Late Binding here to solve the circular dependency. + return Set(isKeyed(this) ? this.valueSeq() : this); + }, + + toSetSeq: function toSetSeq() { + return new ToSetSequence(this); + }, + + toSeq: function toSeq() { + return isIndexed(this) + ? this.toIndexedSeq() + : isKeyed(this) + ? this.toKeyedSeq() + : this.toSetSeq(); + }, + + toStack: function toStack() { + // Use Late Binding here to solve the circular dependency. + return Stack(isKeyed(this) ? this.valueSeq() : this); + }, + + toList: function toList() { + // Use Late Binding here to solve the circular dependency. + return List(isKeyed(this) ? this.valueSeq() : this); + }, + + // ### Common JavaScript methods and properties + + toString: function toString() { + return '[Collection]'; + }, + + __toString: function __toString(head, tail) { + if (this.size === 0) { + return head + tail; + } + return ( + head + + ' ' + + this.toSeq().map(this.__toStringMapper).join(', ') + + ' ' + + tail + ); + }, + + // ### ES6 Collection methods (ES6 Array and Map) + + concat: function concat() { + var values = [], len = arguments.length; + while ( len-- ) values[ len ] = arguments[ len ]; + + return reify(this, concatFactory(this, values)); + }, + + includes: function includes(searchValue) { + return this.some(function (value) { return is(value, searchValue); }); + }, + + entries: function entries() { + return this.__iterator(ITERATE_ENTRIES); + }, + + every: function every(predicate, context) { + assertNotInfinite(this.size); + var returnValue = true; + this.__iterate(function (v, k, c) { + if (!predicate.call(context, v, k, c)) { + returnValue = false; + return false; + } + }); + return returnValue; + }, + + filter: function filter(predicate, context) { + return reify(this, filterFactory(this, predicate, context, true)); + }, + + partition: function partition(predicate, context) { + return partitionFactory(this, predicate, context); + }, + + find: function find(predicate, context, notSetValue) { + var entry = this.findEntry(predicate, context); + return entry ? entry[1] : notSetValue; + }, + + forEach: function forEach(sideEffect, context) { + assertNotInfinite(this.size); + return this.__iterate(context ? sideEffect.bind(context) : sideEffect); + }, + + join: function join(separator) { + assertNotInfinite(this.size); + separator = separator !== undefined ? '' + separator : ','; + var joined = ''; + var isFirst = true; + this.__iterate(function (v) { + isFirst ? (isFirst = false) : (joined += separator); + joined += v !== null && v !== undefined ? v.toString() : ''; + }); + return joined; + }, + + keys: function keys() { + return this.__iterator(ITERATE_KEYS); + }, + + map: function map(mapper, context) { + return reify(this, mapFactory(this, mapper, context)); + }, + + reduce: function reduce$1(reducer, initialReduction, context) { + return reduce( + this, + reducer, + initialReduction, + context, + arguments.length < 2, + false + ); + }, + + reduceRight: function reduceRight(reducer, initialReduction, context) { + return reduce( + this, + reducer, + initialReduction, + context, + arguments.length < 2, + true + ); + }, + + reverse: function reverse() { + return reify(this, reverseFactory(this, true)); + }, + + slice: function slice(begin, end) { + return reify(this, sliceFactory(this, begin, end, true)); + }, + + some: function some(predicate, context) { + assertNotInfinite(this.size); + var returnValue = false; + this.__iterate(function (v, k, c) { + if (predicate.call(context, v, k, c)) { + returnValue = true; + return false; + } + }); + return returnValue; + }, + + sort: function sort(comparator) { + return reify(this, sortFactory(this, comparator)); + }, + + values: function values() { + return this.__iterator(ITERATE_VALUES); + }, + + // ### More sequential methods + + butLast: function butLast() { + return this.slice(0, -1); + }, + + isEmpty: function isEmpty() { + return this.size !== undefined ? this.size === 0 : !this.some(function () { return true; }); + }, + + count: function count(predicate, context) { + return ensureSize( + predicate ? this.toSeq().filter(predicate, context) : this + ); + }, + + countBy: function countBy(grouper, context) { + return countByFactory(this, grouper, context); + }, + + equals: function equals(other) { + return deepEqual(this, other); + }, + + entrySeq: function entrySeq() { + // eslint-disable-next-line @typescript-eslint/no-this-alias + var collection = this; + if (collection._cache) { + // We cache as an entries array, so we can just return the cache! + return new ArraySeq(collection._cache); + } + var entriesSequence = collection.toSeq().map(entryMapper).toIndexedSeq(); + entriesSequence.fromEntrySeq = function () { return collection.toSeq(); }; + return entriesSequence; + }, + + filterNot: function filterNot(predicate, context) { + return this.filter(not(predicate), context); + }, + + findEntry: function findEntry(predicate, context, notSetValue) { + var found = notSetValue; + this.__iterate(function (v, k, c) { + if (predicate.call(context, v, k, c)) { + found = [k, v]; + return false; + } + }); + return found; + }, + + findKey: function findKey(predicate, context) { + var entry = this.findEntry(predicate, context); + return entry && entry[0]; + }, + + findLast: function findLast(predicate, context, notSetValue) { + return this.toKeyedSeq().reverse().find(predicate, context, notSetValue); + }, + + findLastEntry: function findLastEntry(predicate, context, notSetValue) { + return this.toKeyedSeq() + .reverse() + .findEntry(predicate, context, notSetValue); + }, + + findLastKey: function findLastKey(predicate, context) { + return this.toKeyedSeq().reverse().findKey(predicate, context); + }, + + first: function first(notSetValue) { + return this.find(returnTrue, null, notSetValue); + }, + + flatMap: function flatMap(mapper, context) { + return reify(this, flatMapFactory(this, mapper, context)); + }, + + flatten: function flatten(depth) { + return reify(this, flattenFactory(this, depth, true)); + }, + + fromEntrySeq: function fromEntrySeq() { + return new FromEntriesSequence(this); + }, + + get: function get(searchKey, notSetValue) { + return this.find(function (_, key) { return is(key, searchKey); }, undefined, notSetValue); + }, + + getIn: getIn, + + groupBy: function groupBy(grouper, context) { + return groupByFactory(this, grouper, context); + }, + + has: function has(searchKey) { + return this.get(searchKey, NOT_SET) !== NOT_SET; + }, + + hasIn: hasIn, + + isSubset: function isSubset(iter) { + iter = typeof iter.includes === 'function' ? iter : Collection(iter); + return this.every(function (value) { return iter.includes(value); }); + }, + + isSuperset: function isSuperset(iter) { + iter = typeof iter.isSubset === 'function' ? iter : Collection(iter); + return iter.isSubset(this); + }, + + keyOf: function keyOf(searchValue) { + return this.findKey(function (value) { return is(value, searchValue); }); + }, + + keySeq: function keySeq() { + return this.toSeq().map(keyMapper).toIndexedSeq(); + }, + + last: function last(notSetValue) { + return this.toSeq().reverse().first(notSetValue); + }, + + lastKeyOf: function lastKeyOf(searchValue) { + return this.toKeyedSeq().reverse().keyOf(searchValue); + }, + + max: function max(comparator) { + return maxFactory(this, comparator); + }, + + maxBy: function maxBy(mapper, comparator) { + return maxFactory(this, comparator, mapper); + }, + + min: function min(comparator) { + return maxFactory( + this, + comparator ? neg(comparator) : defaultNegComparator + ); + }, + + minBy: function minBy(mapper, comparator) { + return maxFactory( + this, + comparator ? neg(comparator) : defaultNegComparator, + mapper + ); + }, + + rest: function rest() { + return this.slice(1); + }, + + skip: function skip(amount) { + return amount === 0 ? this : this.slice(Math.max(0, amount)); + }, + + skipLast: function skipLast(amount) { + return amount === 0 ? this : this.slice(0, -Math.max(0, amount)); + }, + + skipWhile: function skipWhile(predicate, context) { + return reify(this, skipWhileFactory(this, predicate, context, true)); + }, + + skipUntil: function skipUntil(predicate, context) { + return this.skipWhile(not(predicate), context); + }, + + sortBy: function sortBy(mapper, comparator) { + return reify(this, sortFactory(this, comparator, mapper)); + }, + + take: function take(amount) { + return this.slice(0, Math.max(0, amount)); + }, + + takeLast: function takeLast(amount) { + return this.slice(-Math.max(0, amount)); + }, + + takeWhile: function takeWhile(predicate, context) { + return reify(this, takeWhileFactory(this, predicate, context)); + }, + + takeUntil: function takeUntil(predicate, context) { + return this.takeWhile(not(predicate), context); + }, + + update: function update(fn) { + return fn(this); + }, + + valueSeq: function valueSeq() { + return this.toIndexedSeq(); + }, + + // ### Hashable Object + + hashCode: function hashCode() { + return this.__hash || (this.__hash = hashCollection(this)); + }, + + // ### Internal + + // abstract __iterate(fn, reverse) + + // abstract __iterator(type, reverse) +}); + +var CollectionPrototype = Collection.prototype; +CollectionPrototype[IS_COLLECTION_SYMBOL] = true; +CollectionPrototype[ITERATOR_SYMBOL] = CollectionPrototype.values; +CollectionPrototype.toJSON = CollectionPrototype.toArray; +CollectionPrototype.__toStringMapper = quoteString; +CollectionPrototype.inspect = CollectionPrototype.toSource = function () { + return this.toString(); +}; +CollectionPrototype.chain = CollectionPrototype.flatMap; +CollectionPrototype.contains = CollectionPrototype.includes; + +mixin(KeyedCollection, { + // ### More sequential methods + + flip: function flip() { + return reify(this, flipFactory(this)); + }, + + mapEntries: function mapEntries(mapper, context) { + var this$1$1 = this; + + var iterations = 0; + return reify( + this, + this.toSeq() + .map(function (v, k) { return mapper.call(context, [k, v], iterations++, this$1$1); }) + .fromEntrySeq() + ); + }, + + mapKeys: function mapKeys(mapper, context) { + var this$1$1 = this; + + return reify( + this, + this.toSeq() + .flip() + .map(function (k, v) { return mapper.call(context, k, v, this$1$1); }) + .flip() + ); + }, +}); + +var KeyedCollectionPrototype = KeyedCollection.prototype; +KeyedCollectionPrototype[IS_KEYED_SYMBOL] = true; +KeyedCollectionPrototype[ITERATOR_SYMBOL] = CollectionPrototype.entries; +KeyedCollectionPrototype.toJSON = toObject; +KeyedCollectionPrototype.__toStringMapper = function (v, k) { return quoteString(k) + ': ' + quoteString(v); }; + +mixin(IndexedCollection, { + // ### Conversion to other types + + toKeyedSeq: function toKeyedSeq() { + return new ToKeyedSequence(this, false); + }, + + // ### ES6 Collection methods (ES6 Array and Map) + + filter: function filter(predicate, context) { + return reify(this, filterFactory(this, predicate, context, false)); + }, + + findIndex: function findIndex(predicate, context) { + var entry = this.findEntry(predicate, context); + return entry ? entry[0] : -1; + }, + + indexOf: function indexOf(searchValue) { + var key = this.keyOf(searchValue); + return key === undefined ? -1 : key; + }, + + lastIndexOf: function lastIndexOf(searchValue) { + var key = this.lastKeyOf(searchValue); + return key === undefined ? -1 : key; + }, + + reverse: function reverse() { + return reify(this, reverseFactory(this, false)); + }, + + slice: function slice(begin, end) { + return reify(this, sliceFactory(this, begin, end, false)); + }, + + splice: function splice(index, removeNum /*, ...values*/) { + var numArgs = arguments.length; + removeNum = Math.max(removeNum || 0, 0); + if (numArgs === 0 || (numArgs === 2 && !removeNum)) { + return this; + } + // If index is negative, it should resolve relative to the size of the + // collection. However size may be expensive to compute if not cached, so + // only call count() if the number is in fact negative. + index = resolveBegin(index, index < 0 ? this.count() : this.size); + var spliced = this.slice(0, index); + return reify( + this, + numArgs === 1 + ? spliced + : spliced.concat(arrCopy(arguments, 2), this.slice(index + removeNum)) + ); + }, + + // ### More collection methods + + findLastIndex: function findLastIndex(predicate, context) { + var entry = this.findLastEntry(predicate, context); + return entry ? entry[0] : -1; + }, + + first: function first(notSetValue) { + return this.get(0, notSetValue); + }, + + flatten: function flatten(depth) { + return reify(this, flattenFactory(this, depth, false)); + }, + + get: function get(index, notSetValue) { + index = wrapIndex(this, index); + return index < 0 || + this.size === Infinity || + (this.size !== undefined && index > this.size) + ? notSetValue + : this.find(function (_, key) { return key === index; }, undefined, notSetValue); + }, + + has: function has(index) { + index = wrapIndex(this, index); + return ( + index >= 0 && + (this.size !== undefined + ? this.size === Infinity || index < this.size + : this.indexOf(index) !== -1) + ); + }, + + interpose: function interpose(separator) { + return reify(this, interposeFactory(this, separator)); + }, + + interleave: function interleave(/*...collections*/) { + var collections = [this].concat(arrCopy(arguments)); + var zipped = zipWithFactory(this.toSeq(), IndexedSeq.of, collections); + var interleaved = zipped.flatten(true); + if (zipped.size) { + interleaved.size = zipped.size * collections.length; + } + return reify(this, interleaved); + }, + + keySeq: function keySeq() { + return Range(0, this.size); + }, + + last: function last(notSetValue) { + return this.get(-1, notSetValue); + }, + + skipWhile: function skipWhile(predicate, context) { + return reify(this, skipWhileFactory(this, predicate, context, false)); + }, + + zip: function zip(/*, ...collections */) { + var collections = [this].concat(arrCopy(arguments)); + return reify(this, zipWithFactory(this, defaultZipper, collections)); + }, + + zipAll: function zipAll(/*, ...collections */) { + var collections = [this].concat(arrCopy(arguments)); + return reify(this, zipWithFactory(this, defaultZipper, collections, true)); + }, + + zipWith: function zipWith(zipper /*, ...collections */) { + var collections = arrCopy(arguments); + collections[0] = this; + return reify(this, zipWithFactory(this, zipper, collections)); + }, +}); + +var IndexedCollectionPrototype = IndexedCollection.prototype; +IndexedCollectionPrototype[IS_INDEXED_SYMBOL] = true; +IndexedCollectionPrototype[IS_ORDERED_SYMBOL] = true; + +mixin(SetCollection, { + // ### ES6 Collection methods (ES6 Array and Map) + + get: function get(value, notSetValue) { + return this.has(value) ? value : notSetValue; + }, + + includes: function includes(value) { + return this.has(value); + }, + + // ### More sequential methods + + keySeq: function keySeq() { + return this.valueSeq(); + }, +}); + +var SetCollectionPrototype = SetCollection.prototype; +SetCollectionPrototype.has = CollectionPrototype.includes; +SetCollectionPrototype.contains = SetCollectionPrototype.includes; +SetCollectionPrototype.keys = SetCollectionPrototype.values; + +// Mixin subclasses + +mixin(KeyedSeq, KeyedCollectionPrototype); +mixin(IndexedSeq, IndexedCollectionPrototype); +mixin(SetSeq, SetCollectionPrototype); + +// #pragma Helper functions + +function reduce(collection, reducer, reduction, context, useFirst, reverse) { + assertNotInfinite(collection.size); + collection.__iterate(function (v, k, c) { + if (useFirst) { + useFirst = false; + reduction = v; + } else { + reduction = reducer.call(context, reduction, v, k, c); + } + }, reverse); + return reduction; +} + +function keyMapper(v, k) { + return k; +} + +function entryMapper(v, k) { + return [k, v]; +} + +function not(predicate) { + return function () { + return !predicate.apply(this, arguments); + }; +} + +function neg(predicate) { + return function () { + return -predicate.apply(this, arguments); + }; +} + +function defaultZipper() { + return arrCopy(arguments); +} + +function defaultNegComparator(a, b) { + return a < b ? 1 : a > b ? -1 : 0; +} + +function hashCollection(collection) { + if (collection.size === Infinity) { + return 0; + } + var ordered = isOrdered(collection); + var keyed = isKeyed(collection); + var h = ordered ? 1 : 0; + + collection.__iterate( + keyed + ? ordered + ? function (v, k) { + h = (31 * h + hashMerge(hash(v), hash(k))) | 0; + } + : function (v, k) { + h = (h + hashMerge(hash(v), hash(k))) | 0; + } + : ordered + ? function (v) { + h = (31 * h + hash(v)) | 0; + } + : function (v) { + h = (h + hash(v)) | 0; + } + ); + + return murmurHashOfSize(collection.size, h); +} + +function murmurHashOfSize(size, h) { + h = imul(h, 0xcc9e2d51); + h = imul((h << 15) | (h >>> -15), 0x1b873593); + h = imul((h << 13) | (h >>> -13), 5); + h = ((h + 0xe6546b64) | 0) ^ size; + h = imul(h ^ (h >>> 16), 0x85ebca6b); + h = imul(h ^ (h >>> 13), 0xc2b2ae35); + h = smi(h ^ (h >>> 16)); + return h; +} + +function hashMerge(a, b) { + return (a ^ (b + 0x9e3779b9 + (a << 6) + (a >> 2))) | 0; // int +} + +export { Collection, CollectionPrototype, IndexedCollectionPrototype }; diff --git a/dist/es/Hash.js b/dist/es/Hash.js new file mode 100644 index 0000000000..3fc7909aa2 --- /dev/null +++ b/dist/es/Hash.js @@ -0,0 +1,260 @@ +/** + * @license + * MIT License + * + * Copyright (c) 2014-present, Lee Byron and other contributors. + * + * 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: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +import { smi } from './Math.js'; + +var defaultValueOf = Object.prototype.valueOf; + +function hash(o) { + if (o == null) { + return hashNullish(o); + } + + if (typeof o.hashCode === 'function') { + // Drop any high bits from accidentally long hash codes. + return smi(o.hashCode(o)); + } + + var v = valueOf(o); + + if (v == null) { + return hashNullish(v); + } + + switch (typeof v) { + case 'boolean': + // The hash values for built-in constants are a 1 value for each 5-byte + // shift region expect for the first, which encodes the value. This + // reduces the odds of a hash collision for these common values. + return v ? 0x42108421 : 0x42108420; + case 'number': + return hashNumber(v); + case 'string': + return v.length > STRING_HASH_CACHE_MIN_STRLEN + ? cachedHashString(v) + : hashString(v); + case 'object': + case 'function': + return hashJSObj(v); + case 'symbol': + return hashSymbol(v); + default: + if (typeof v.toString === 'function') { + return hashString(v.toString()); + } + throw new Error('Value type ' + typeof v + ' cannot be hashed.'); + } +} + +function hashNullish(nullish) { + return nullish === null ? 0x42108422 : /* undefined */ 0x42108423; +} + +// Compress arbitrarily large numbers into smi hashes. +function hashNumber(n) { + if (n !== n || n === Infinity) { + return 0; + } + var hash = n | 0; + if (hash !== n) { + hash ^= n * 0xffffffff; + } + while (n > 0xffffffff) { + n /= 0xffffffff; + hash ^= n; + } + return smi(hash); +} + +function cachedHashString(string) { + var hashed = stringHashCache[string]; + if (hashed === undefined) { + hashed = hashString(string); + if (STRING_HASH_CACHE_SIZE === STRING_HASH_CACHE_MAX_SIZE) { + STRING_HASH_CACHE_SIZE = 0; + stringHashCache = {}; + } + STRING_HASH_CACHE_SIZE++; + stringHashCache[string] = hashed; + } + return hashed; +} + +// http://jsperf.com/hashing-strings +function hashString(string) { + // This is the hash from JVM + // The hash code for a string is computed as + // s[0] * 31 ^ (n - 1) + s[1] * 31 ^ (n - 2) + ... + s[n - 1], + // where s[i] is the ith character of the string and n is the length of + // the string. We "mod" the result to make it between 0 (inclusive) and 2^31 + // (exclusive) by dropping high bits. + var hashed = 0; + for (var ii = 0; ii < string.length; ii++) { + hashed = (31 * hashed + string.charCodeAt(ii)) | 0; + } + return smi(hashed); +} + +function hashSymbol(sym) { + var hashed = symbolMap[sym]; + if (hashed !== undefined) { + return hashed; + } + + hashed = nextHash(); + + symbolMap[sym] = hashed; + + return hashed; +} + +function hashJSObj(obj) { + var hashed; + if (usingWeakMap) { + hashed = weakMap.get(obj); + if (hashed !== undefined) { + return hashed; + } + } + + hashed = obj[UID_HASH_KEY]; + if (hashed !== undefined) { + return hashed; + } + + if (!canDefineProperty) { + hashed = obj.propertyIsEnumerable && obj.propertyIsEnumerable[UID_HASH_KEY]; + if (hashed !== undefined) { + return hashed; + } + + hashed = getIENodeHash(obj); + if (hashed !== undefined) { + return hashed; + } + } + + hashed = nextHash(); + + if (usingWeakMap) { + weakMap.set(obj, hashed); + } else if (isExtensible !== undefined && isExtensible(obj) === false) { + throw new Error('Non-extensible objects are not allowed as keys.'); + } else if (canDefineProperty) { + Object.defineProperty(obj, UID_HASH_KEY, { + enumerable: false, + configurable: false, + writable: false, + value: hashed, + }); + } else if ( + obj.propertyIsEnumerable !== undefined && + obj.propertyIsEnumerable === obj.constructor.prototype.propertyIsEnumerable + ) { + // Since we can't define a non-enumerable property on the object + // we'll hijack one of the less-used non-enumerable properties to + // save our hash on it. Since this is a function it will not show up in + // `JSON.stringify` which is what we want. + obj.propertyIsEnumerable = function () { + return this.constructor.prototype.propertyIsEnumerable.apply( + this, + arguments + ); + }; + obj.propertyIsEnumerable[UID_HASH_KEY] = hashed; + } else if (obj.nodeType !== undefined) { + // At this point we couldn't get the IE `uniqueID` to use as a hash + // and we couldn't use a non-enumerable property to exploit the + // dontEnum bug so we simply add the `UID_HASH_KEY` on the node + // itself. + obj[UID_HASH_KEY] = hashed; + } else { + throw new Error('Unable to set a non-enumerable property on object.'); + } + + return hashed; +} + +// Get references to ES5 object methods. +var isExtensible = Object.isExtensible; + +// True if Object.defineProperty works as expected. IE8 fails this test. +var canDefineProperty = (function () { + try { + Object.defineProperty({}, '@', {}); + return true; + } catch (e) { + return false; + } +})(); + +// IE has a `uniqueID` property on DOM nodes. We can construct the hash from it +// and avoid memory leaks from the IE cloneNode bug. +function getIENodeHash(node) { + if (node && node.nodeType > 0) { + switch (node.nodeType) { + case 1: // Element + return node.uniqueID; + case 9: // Document + return node.documentElement && node.documentElement.uniqueID; + } + } +} + +function valueOf(obj) { + return obj.valueOf !== defaultValueOf && typeof obj.valueOf === 'function' + ? obj.valueOf(obj) + : obj; +} + +function nextHash() { + var nextHash = ++_objHashUID; + if (_objHashUID & 0x40000000) { + _objHashUID = 0; + } + return nextHash; +} + +// If possible, use a WeakMap. +var usingWeakMap = typeof WeakMap === 'function'; +var weakMap; +if (usingWeakMap) { + weakMap = new WeakMap(); +} + +var symbolMap = Object.create(null); + +var _objHashUID = 0; + +var UID_HASH_KEY = '__immutablehash__'; +if (typeof Symbol === 'function') { + UID_HASH_KEY = Symbol(UID_HASH_KEY); +} + +var STRING_HASH_CACHE_MIN_STRLEN = 16; +var STRING_HASH_CACHE_MAX_SIZE = 255; +var STRING_HASH_CACHE_SIZE = 0; +var stringHashCache = {}; + +export { hash }; diff --git a/dist/es/Immutable.js b/dist/es/Immutable.js new file mode 100644 index 0000000000..59bbd81179 --- /dev/null +++ b/dist/es/Immutable.js @@ -0,0 +1,73 @@ +/** + * @license + * MIT License + * + * Copyright (c) 2014-present, Lee Byron and other contributors. + * + * 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: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +export { Seq } from './Seq.js'; +export { OrderedMap } from './OrderedMap.js'; +export { List } from './List.js'; +export { Map } from './Map.js'; +export { Stack } from './Stack.js'; +export { OrderedSet } from './OrderedSet.js'; +export { PairSorting } from './PairSorting.js'; +export { Set } from './Set.js'; +export { Record } from './Record.js'; +export { Range } from './Range.js'; +export { Repeat } from './Repeat.js'; +export { is } from './is.js'; +export { fromJS } from './fromJS.js'; +export { default as isPlainObject } from './utils/isPlainObj.js'; +export { isImmutable } from './predicates/isImmutable.js'; +export { isCollection } from './predicates/isCollection.js'; +export { isKeyed } from './predicates/isKeyed.js'; +export { isIndexed } from './predicates/isIndexed.js'; +export { isAssociative } from './predicates/isAssociative.js'; +export { isOrdered } from './predicates/isOrdered.js'; +export { isValueObject } from './predicates/isValueObject.js'; +export { isSeq } from './predicates/isSeq.js'; +export { isList } from './predicates/isList.js'; +export { isMap } from './predicates/isMap.js'; +export { isOrderedMap } from './predicates/isOrderedMap.js'; +export { isStack } from './predicates/isStack.js'; +export { isSet } from './predicates/isSet.js'; +export { isOrderedSet } from './predicates/isOrderedSet.js'; +export { isRecord } from './predicates/isRecord.js'; +import './CollectionImpl.js'; +export { hash } from './Hash.js'; +export { get } from './functional/get.js'; +export { getIn } from './functional/getIn.js'; +export { has } from './functional/has.js'; +export { hasIn } from './functional/hasIn.js'; +export { merge, mergeDeep, mergeDeepWith, mergeWith } from './functional/merge.js'; +export { remove } from './functional/remove.js'; +export { removeIn } from './functional/removeIn.js'; +export { set } from './functional/set.js'; +export { setIn } from './functional/setIn.js'; +export { update } from './functional/update.js'; +export { updateIn } from './functional/updateIn.js'; +export { version } from './package.json.js'; +import { Collection } from './Collection.js'; + +// Note: Iterable is deprecated +var Iterable = Collection; + +export { Collection, Iterable }; diff --git a/dist/es/Iterator.js b/dist/es/Iterator.js new file mode 100644 index 0000000000..94de58f316 --- /dev/null +++ b/dist/es/Iterator.js @@ -0,0 +1,106 @@ +/** + * @license + * MIT License + * + * Copyright (c) 2014-present, Lee Byron and other contributors. + * + * 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: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +var ITERATE_KEYS = 0; +var ITERATE_VALUES = 1; +var ITERATE_ENTRIES = 2; + +var REAL_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator; +var FAUX_ITERATOR_SYMBOL = '@@iterator'; + +var ITERATOR_SYMBOL = REAL_ITERATOR_SYMBOL || FAUX_ITERATOR_SYMBOL; + +var Iterator = function Iterator(next) { + this.next = next; +}; + +Iterator.prototype.toString = function toString () { + return '[Iterator]'; +}; + +Iterator.KEYS = ITERATE_KEYS; +Iterator.VALUES = ITERATE_VALUES; +Iterator.ENTRIES = ITERATE_ENTRIES; + +Iterator.prototype.inspect = Iterator.prototype.toSource = function () { + return this.toString(); +}; +Iterator.prototype[ITERATOR_SYMBOL] = function () { + return this; +}; + +function iteratorValue(type, k, v, iteratorResult) { + var value = type === 0 ? k : type === 1 ? v : [k, v]; + iteratorResult + ? (iteratorResult.value = value) + : (iteratorResult = { + value: value, + done: false, + }); + return iteratorResult; +} + +function iteratorDone() { + return { value: undefined, done: true }; +} + +function hasIterator(maybeIterable) { + if (Array.isArray(maybeIterable)) { + // IE11 trick as it does not support `Symbol.iterator` + return true; + } + + return !!getIteratorFn(maybeIterable); +} + +function isIterator(maybeIterator) { + return maybeIterator && typeof maybeIterator.next === 'function'; +} + +function getIterator(iterable) { + var iteratorFn = getIteratorFn(iterable); + return iteratorFn && iteratorFn.call(iterable); +} + +function getIteratorFn(iterable) { + var iteratorFn = + iterable && + ((REAL_ITERATOR_SYMBOL && iterable[REAL_ITERATOR_SYMBOL]) || + iterable[FAUX_ITERATOR_SYMBOL]); + if (typeof iteratorFn === 'function') { + return iteratorFn; + } +} + +function isEntriesIterable(maybeIterable) { + var iteratorFn = getIteratorFn(maybeIterable); + return iteratorFn && iteratorFn === maybeIterable.entries; +} + +function isKeysIterable(maybeIterable) { + var iteratorFn = getIteratorFn(maybeIterable); + return iteratorFn && iteratorFn === maybeIterable.keys; +} + +export { ITERATE_ENTRIES, ITERATE_KEYS, ITERATE_VALUES, ITERATOR_SYMBOL, Iterator, getIterator, hasIterator, isEntriesIterable, isIterator, isKeysIterable, iteratorDone, iteratorValue }; diff --git a/dist/es/List.js b/dist/es/List.js new file mode 100644 index 0000000000..096ccb871f --- /dev/null +++ b/dist/es/List.js @@ -0,0 +1,697 @@ +/** + * @license + * MIT License + * + * Copyright (c) 2014-present, Lee Byron and other contributors. + * + * 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: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +import { wrapIndex, MASK, SHIFT, wholeSlice, DELETE, SetRef, OwnerID, SIZE, MakeRef, resolveEnd, resolveBegin } from './TrieUtils.js'; +import { isList, IS_LIST_SYMBOL } from './predicates/isList.js'; +import { IndexedCollection } from './Collection.js'; +import { hasIterator, Iterator, iteratorDone, iteratorValue } from './Iterator.js'; +import { setIn } from './methods/setIn.js'; +import { deleteIn } from './methods/deleteIn.js'; +import { update } from './methods/update.js'; +import { updateIn } from './methods/updateIn.js'; +import { mergeIn } from './methods/mergeIn.js'; +import { mergeDeepIn } from './methods/mergeDeepIn.js'; +import { withMutations } from './methods/withMutations.js'; +import { asMutable } from './methods/asMutable.js'; +import { asImmutable } from './methods/asImmutable.js'; +import { wasAltered } from './methods/wasAltered.js'; +import assertNotInfinite from './utils/assertNotInfinite.js'; + +var List = /*@__PURE__*/(function (IndexedCollection) { + function List(value) { + var empty = emptyList(); + if (value === undefined || value === null) { + // eslint-disable-next-line no-constructor-return + return empty; + } + if (isList(value)) { + // eslint-disable-next-line no-constructor-return + return value; + } + var iter = IndexedCollection(value); + var size = iter.size; + if (size === 0) { + // eslint-disable-next-line no-constructor-return + return empty; + } + assertNotInfinite(size); + if (size > 0 && size < SIZE) { + // eslint-disable-next-line no-constructor-return + return makeList(0, size, SHIFT, null, new VNode(iter.toArray())); + } + // eslint-disable-next-line no-constructor-return + return empty.withMutations(function (list) { + list.setSize(size); + iter.forEach(function (v, i) { return list.set(i, v); }); + }); + } + + if ( IndexedCollection ) List.__proto__ = IndexedCollection; + List.prototype = Object.create( IndexedCollection && IndexedCollection.prototype ); + List.prototype.constructor = List; + + List.of = function of (/*...values*/) { + return this(arguments); + }; + + List.prototype.toString = function toString () { + return this.__toString('List [', ']'); + }; + + // @pragma Access + + List.prototype.get = function get (index, notSetValue) { + index = wrapIndex(this, index); + if (index >= 0 && index < this.size) { + index += this._origin; + var node = listNodeFor(this, index); + return node && node.array[index & MASK]; + } + return notSetValue; + }; + + // @pragma Modification + + List.prototype.set = function set (index, value) { + return updateList(this, index, value); + }; + + List.prototype.remove = function remove (index) { + return !this.has(index) + ? this + : index === 0 + ? this.shift() + : index === this.size - 1 + ? this.pop() + : this.splice(index, 1); + }; + + List.prototype.insert = function insert (index, value) { + return this.splice(index, 0, value); + }; + + List.prototype.clear = function clear () { + if (this.size === 0) { + return this; + } + if (this.__ownerID) { + this.size = this._origin = this._capacity = 0; + this._level = SHIFT; + this._root = this._tail = this.__hash = undefined; + this.__altered = true; + return this; + } + return emptyList(); + }; + + List.prototype.push = function push (/*...values*/) { + var values = arguments; + var oldSize = this.size; + return this.withMutations(function (list) { + setListBounds(list, 0, oldSize + values.length); + for (var ii = 0; ii < values.length; ii++) { + list.set(oldSize + ii, values[ii]); + } + }); + }; + + List.prototype.pop = function pop () { + return setListBounds(this, 0, -1); + }; + + List.prototype.unshift = function unshift (/*...values*/) { + var values = arguments; + return this.withMutations(function (list) { + setListBounds(list, -values.length); + for (var ii = 0; ii < values.length; ii++) { + list.set(ii, values[ii]); + } + }); + }; + + List.prototype.shift = function shift () { + return setListBounds(this, 1); + }; + + // @pragma Composition + + List.prototype.concat = function concat (/*...collections*/) { + var arguments$1 = arguments; + + var seqs = []; + for (var i = 0; i < arguments.length; i++) { + var argument = arguments$1[i]; + var seq = IndexedCollection( + typeof argument !== 'string' && hasIterator(argument) + ? argument + : [argument] + ); + if (seq.size !== 0) { + seqs.push(seq); + } + } + if (seqs.length === 0) { + return this; + } + if (this.size === 0 && !this.__ownerID && seqs.length === 1) { + return this.constructor(seqs[0]); + } + return this.withMutations(function (list) { + seqs.forEach(function (seq) { return seq.forEach(function (value) { return list.push(value); }); }); + }); + }; + + List.prototype.setSize = function setSize (size) { + return setListBounds(this, 0, size); + }; + + List.prototype.map = function map (mapper, context) { + var this$1$1 = this; + + return this.withMutations(function (list) { + for (var i = 0; i < this$1$1.size; i++) { + list.set(i, mapper.call(context, list.get(i), i, this$1$1)); + } + }); + }; + + // @pragma Iteration + + List.prototype.slice = function slice (begin, end) { + var size = this.size; + if (wholeSlice(begin, end, size)) { + return this; + } + return setListBounds( + this, + resolveBegin(begin, size), + resolveEnd(end, size) + ); + }; + + List.prototype.__iterator = function __iterator (type, reverse) { + var index = reverse ? this.size : 0; + var values = iterateList(this, reverse); + return new Iterator(function () { + var value = values(); + return value === DONE + ? iteratorDone() + : iteratorValue(type, reverse ? --index : index++, value); + }); + }; + + List.prototype.__iterate = function __iterate (fn, reverse) { + var index = reverse ? this.size : 0; + var values = iterateList(this, reverse); + var value; + while ((value = values()) !== DONE) { + if (fn(value, reverse ? --index : index++, this) === false) { + break; + } + } + return index; + }; + + List.prototype.__ensureOwner = function __ensureOwner (ownerID) { + if (ownerID === this.__ownerID) { + return this; + } + if (!ownerID) { + if (this.size === 0) { + return emptyList(); + } + this.__ownerID = ownerID; + this.__altered = false; + return this; + } + return makeList( + this._origin, + this._capacity, + this._level, + this._root, + this._tail, + ownerID, + this.__hash + ); + }; + + return List; +}(IndexedCollection)); + +List.isList = isList; + +var ListPrototype = List.prototype; +ListPrototype[IS_LIST_SYMBOL] = true; +ListPrototype[DELETE] = ListPrototype.remove; +ListPrototype.merge = ListPrototype.concat; +ListPrototype.setIn = setIn; +ListPrototype.deleteIn = ListPrototype.removeIn = deleteIn; +ListPrototype.update = update; +ListPrototype.updateIn = updateIn; +ListPrototype.mergeIn = mergeIn; +ListPrototype.mergeDeepIn = mergeDeepIn; +ListPrototype.withMutations = withMutations; +ListPrototype.wasAltered = wasAltered; +ListPrototype.asImmutable = asImmutable; +ListPrototype['@@transducer/init'] = ListPrototype.asMutable = asMutable; +ListPrototype['@@transducer/step'] = function (result, arr) { + return result.push(arr); +}; +ListPrototype['@@transducer/result'] = function (obj) { + return obj.asImmutable(); +}; + +var VNode = function VNode(array, ownerID) { + this.array = array; + this.ownerID = ownerID; +}; + +// TODO: seems like these methods are very similar + +VNode.prototype.removeBefore = function removeBefore (ownerID, level, index) { + if (index === level ? 1 << level : this.array.length === 0) { + return this; + } + var originIndex = (index >>> level) & MASK; + if (originIndex >= this.array.length) { + return new VNode([], ownerID); + } + var removingFirst = originIndex === 0; + var newChild; + if (level > 0) { + var oldChild = this.array[originIndex]; + newChild = + oldChild && oldChild.removeBefore(ownerID, level - SHIFT, index); + if (newChild === oldChild && removingFirst) { + return this; + } + } + if (removingFirst && !newChild) { + return this; + } + var editable = editableVNode(this, ownerID); + if (!removingFirst) { + for (var ii = 0; ii < originIndex; ii++) { + editable.array[ii] = undefined; + } + } + if (newChild) { + editable.array[originIndex] = newChild; + } + return editable; +}; + +VNode.prototype.removeAfter = function removeAfter (ownerID, level, index) { + if (index === (level ? 1 << level : 0) || this.array.length === 0) { + return this; + } + var sizeIndex = ((index - 1) >>> level) & MASK; + if (sizeIndex >= this.array.length) { + return this; + } + + var newChild; + if (level > 0) { + var oldChild = this.array[sizeIndex]; + newChild = + oldChild && oldChild.removeAfter(ownerID, level - SHIFT, index); + if (newChild === oldChild && sizeIndex === this.array.length - 1) { + return this; + } + } + + var editable = editableVNode(this, ownerID); + editable.array.splice(sizeIndex + 1); + if (newChild) { + editable.array[sizeIndex] = newChild; + } + return editable; +}; + +var DONE = {}; + +function iterateList(list, reverse) { + var left = list._origin; + var right = list._capacity; + var tailPos = getTailOffset(right); + var tail = list._tail; + + return iterateNodeOrLeaf(list._root, list._level, 0); + + function iterateNodeOrLeaf(node, level, offset) { + return level === 0 + ? iterateLeaf(node, offset) + : iterateNode(node, level, offset); + } + + function iterateLeaf(node, offset) { + var array = offset === tailPos ? tail && tail.array : node && node.array; + var from = offset > left ? 0 : left - offset; + var to = right - offset; + if (to > SIZE) { + to = SIZE; + } + return function () { + if (from === to) { + return DONE; + } + var idx = reverse ? --to : from++; + return array && array[idx]; + }; + } + + function iterateNode(node, level, offset) { + var values; + var array = node && node.array; + var from = offset > left ? 0 : (left - offset) >> level; + var to = ((right - offset) >> level) + 1; + if (to > SIZE) { + to = SIZE; + } + return function () { + while (true) { + if (values) { + var value = values(); + if (value !== DONE) { + return value; + } + values = null; + } + if (from === to) { + return DONE; + } + var idx = reverse ? --to : from++; + values = iterateNodeOrLeaf( + array && array[idx], + level - SHIFT, + offset + (idx << level) + ); + } + }; + } +} + +function makeList(origin, capacity, level, root, tail, ownerID, hash) { + var list = Object.create(ListPrototype); + list.size = capacity - origin; + list._origin = origin; + list._capacity = capacity; + list._level = level; + list._root = root; + list._tail = tail; + list.__ownerID = ownerID; + list.__hash = hash; + list.__altered = false; + return list; +} + +var EMPTY_LIST; +function emptyList() { + return EMPTY_LIST || (EMPTY_LIST = makeList(0, 0, SHIFT)); +} + +function updateList(list, index, value) { + index = wrapIndex(list, index); + + if (index !== index) { + return list; + } + + if (index >= list.size || index < 0) { + return list.withMutations(function (list) { + index < 0 + ? setListBounds(list, index).set(0, value) + : setListBounds(list, 0, index + 1).set(index, value); + }); + } + + index += list._origin; + + var newTail = list._tail; + var newRoot = list._root; + var didAlter = MakeRef(); + if (index >= getTailOffset(list._capacity)) { + newTail = updateVNode(newTail, list.__ownerID, 0, index, value, didAlter); + } else { + newRoot = updateVNode( + newRoot, + list.__ownerID, + list._level, + index, + value, + didAlter + ); + } + + if (!didAlter.value) { + return list; + } + + if (list.__ownerID) { + list._root = newRoot; + list._tail = newTail; + list.__hash = undefined; + list.__altered = true; + return list; + } + return makeList(list._origin, list._capacity, list._level, newRoot, newTail); +} + +function updateVNode(node, ownerID, level, index, value, didAlter) { + var idx = (index >>> level) & MASK; + var nodeHas = node && idx < node.array.length; + if (!nodeHas && value === undefined) { + return node; + } + + var newNode; + + if (level > 0) { + var lowerNode = node && node.array[idx]; + var newLowerNode = updateVNode( + lowerNode, + ownerID, + level - SHIFT, + index, + value, + didAlter + ); + if (newLowerNode === lowerNode) { + return node; + } + newNode = editableVNode(node, ownerID); + newNode.array[idx] = newLowerNode; + return newNode; + } + + if (nodeHas && node.array[idx] === value) { + return node; + } + + if (didAlter) { + SetRef(didAlter); + } + + newNode = editableVNode(node, ownerID); + if (value === undefined && idx === newNode.array.length - 1) { + newNode.array.pop(); + } else { + newNode.array[idx] = value; + } + return newNode; +} + +function editableVNode(node, ownerID) { + if (ownerID && node && ownerID === node.ownerID) { + return node; + } + return new VNode(node ? node.array.slice() : [], ownerID); +} + +function listNodeFor(list, rawIndex) { + if (rawIndex >= getTailOffset(list._capacity)) { + return list._tail; + } + if (rawIndex < 1 << (list._level + SHIFT)) { + var node = list._root; + var level = list._level; + while (node && level > 0) { + node = node.array[(rawIndex >>> level) & MASK]; + level -= SHIFT; + } + return node; + } +} + +function setListBounds(list, begin, end) { + // Sanitize begin & end using this shorthand for ToInt32(argument) + // http://www.ecma-international.org/ecma-262/6.0/#sec-toint32 + if (begin !== undefined) { + begin |= 0; + } + if (end !== undefined) { + end |= 0; + } + var owner = list.__ownerID || new OwnerID(); + var oldOrigin = list._origin; + var oldCapacity = list._capacity; + var newOrigin = oldOrigin + begin; + var newCapacity = + end === undefined + ? oldCapacity + : end < 0 + ? oldCapacity + end + : oldOrigin + end; + if (newOrigin === oldOrigin && newCapacity === oldCapacity) { + return list; + } + + // If it's going to end after it starts, it's empty. + if (newOrigin >= newCapacity) { + return list.clear(); + } + + var newLevel = list._level; + var newRoot = list._root; + + // New origin might need creating a higher root. + var offsetShift = 0; + while (newOrigin + offsetShift < 0) { + newRoot = new VNode( + newRoot && newRoot.array.length ? [undefined, newRoot] : [], + owner + ); + newLevel += SHIFT; + offsetShift += 1 << newLevel; + } + if (offsetShift) { + newOrigin += offsetShift; + oldOrigin += offsetShift; + newCapacity += offsetShift; + oldCapacity += offsetShift; + } + + var oldTailOffset = getTailOffset(oldCapacity); + var newTailOffset = getTailOffset(newCapacity); + + // New size might need creating a higher root. + while (newTailOffset >= 1 << (newLevel + SHIFT)) { + newRoot = new VNode( + newRoot && newRoot.array.length ? [newRoot] : [], + owner + ); + newLevel += SHIFT; + } + + // Locate or create the new tail. + var oldTail = list._tail; + var newTail = + newTailOffset < oldTailOffset + ? listNodeFor(list, newCapacity - 1) + : newTailOffset > oldTailOffset + ? new VNode([], owner) + : oldTail; + + // Merge Tail into tree. + if ( + oldTail && + newTailOffset > oldTailOffset && + newOrigin < oldCapacity && + oldTail.array.length + ) { + newRoot = editableVNode(newRoot, owner); + var node = newRoot; + for (var level = newLevel; level > SHIFT; level -= SHIFT) { + var idx = (oldTailOffset >>> level) & MASK; + node = node.array[idx] = editableVNode(node.array[idx], owner); + } + node.array[(oldTailOffset >>> SHIFT) & MASK] = oldTail; + } + + // If the size has been reduced, there's a chance the tail needs to be trimmed. + if (newCapacity < oldCapacity) { + newTail = newTail && newTail.removeAfter(owner, 0, newCapacity); + } + + // If the new origin is within the tail, then we do not need a root. + if (newOrigin >= newTailOffset) { + newOrigin -= newTailOffset; + newCapacity -= newTailOffset; + newLevel = SHIFT; + newRoot = null; + newTail = newTail && newTail.removeBefore(owner, 0, newOrigin); + + // Otherwise, if the root has been trimmed, garbage collect. + } else if (newOrigin > oldOrigin || newTailOffset < oldTailOffset) { + offsetShift = 0; + + // Identify the new top root node of the subtree of the old root. + while (newRoot) { + var beginIndex = (newOrigin >>> newLevel) & MASK; + if ((beginIndex !== newTailOffset >>> newLevel) & MASK) { + break; + } + if (beginIndex) { + offsetShift += (1 << newLevel) * beginIndex; + } + newLevel -= SHIFT; + newRoot = newRoot.array[beginIndex]; + } + + // Trim the new sides of the new root. + if (newRoot && newOrigin > oldOrigin) { + newRoot = newRoot.removeBefore(owner, newLevel, newOrigin - offsetShift); + } + if (newRoot && newTailOffset < oldTailOffset) { + newRoot = newRoot.removeAfter( + owner, + newLevel, + newTailOffset - offsetShift + ); + } + if (offsetShift) { + newOrigin -= offsetShift; + newCapacity -= offsetShift; + } + } + + if (list.__ownerID) { + list.size = newCapacity - newOrigin; + list._origin = newOrigin; + list._capacity = newCapacity; + list._level = newLevel; + list._root = newRoot; + list._tail = newTail; + list.__hash = undefined; + list.__altered = true; + return list; + } + return makeList(newOrigin, newCapacity, newLevel, newRoot, newTail); +} + +function getTailOffset(size) { + return size < SIZE ? 0 : ((size - 1) >>> SHIFT) << SHIFT; +} + +export { List, emptyList }; diff --git a/dist/es/Map.js b/dist/es/Map.js new file mode 100644 index 0000000000..3bce552c03 --- /dev/null +++ b/dist/es/Map.js @@ -0,0 +1,820 @@ +/** + * @license + * MIT License + * + * Copyright (c) 2014-present, Lee Byron and other contributors. + * + * 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: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +import { is } from './is.js'; +import { Collection, KeyedCollection } from './Collection.js'; +import { isMap, IS_MAP_SYMBOL } from './predicates/isMap.js'; +import { isOrdered } from './predicates/isOrdered.js'; +import { DELETE, NOT_SET, SetRef, MakeRef, MASK, SHIFT, SIZE, OwnerID } from './TrieUtils.js'; +import { hash } from './Hash.js'; +import { iteratorDone, Iterator, iteratorValue } from './Iterator.js'; +import { sortFactory } from './Operations.js'; +import arrCopy from './utils/arrCopy.js'; +import assertNotInfinite from './utils/assertNotInfinite.js'; +import { setIn } from './methods/setIn.js'; +import { deleteIn } from './methods/deleteIn.js'; +import { update } from './methods/update.js'; +import { updateIn } from './methods/updateIn.js'; +import { merge, mergeWith } from './methods/merge.js'; +import { mergeDeep, mergeDeepWith } from './methods/mergeDeep.js'; +import { mergeIn } from './methods/mergeIn.js'; +import { mergeDeepIn } from './methods/mergeDeepIn.js'; +import { withMutations } from './methods/withMutations.js'; +import { asMutable } from './methods/asMutable.js'; +import { asImmutable } from './methods/asImmutable.js'; +import { wasAltered } from './methods/wasAltered.js'; +import { OrderedMap } from './OrderedMap.js'; + +var Map = /*@__PURE__*/(function (KeyedCollection) { + function Map(value) { + // eslint-disable-next-line no-constructor-return + return value === undefined || value === null + ? emptyMap() + : isMap(value) && !isOrdered(value) + ? value + : emptyMap().withMutations(function (map) { + var iter = KeyedCollection(value); + assertNotInfinite(iter.size); + iter.forEach(function (v, k) { return map.set(k, v); }); + }); + } + + if ( KeyedCollection ) Map.__proto__ = KeyedCollection; + Map.prototype = Object.create( KeyedCollection && KeyedCollection.prototype ); + Map.prototype.constructor = Map; + + Map.prototype.toString = function toString () { + return this.__toString('Map {', '}'); + }; + + // @pragma Access + + Map.prototype.get = function get (k, notSetValue) { + return this._root + ? this._root.get(0, undefined, k, notSetValue) + : notSetValue; + }; + + // @pragma Modification + + Map.prototype.set = function set (k, v) { + return updateMap(this, k, v); + }; + + Map.prototype.remove = function remove (k) { + return updateMap(this, k, NOT_SET); + }; + + Map.prototype.deleteAll = function deleteAll (keys) { + var collection = Collection(keys); + + if (collection.size === 0) { + return this; + } + + return this.withMutations(function (map) { + collection.forEach(function (key) { return map.remove(key); }); + }); + }; + + Map.prototype.clear = function clear () { + if (this.size === 0) { + return this; + } + if (this.__ownerID) { + this.size = 0; + this._root = null; + this.__hash = undefined; + this.__altered = true; + return this; + } + return emptyMap(); + }; + + // @pragma Composition + + Map.prototype.sort = function sort (comparator) { + // Late binding + return OrderedMap(sortFactory(this, comparator)); + }; + + Map.prototype.sortBy = function sortBy (mapper, comparator) { + // Late binding + return OrderedMap(sortFactory(this, comparator, mapper)); + }; + + Map.prototype.map = function map (mapper, context) { + var this$1$1 = this; + + return this.withMutations(function (map) { + map.forEach(function (value, key) { + map.set(key, mapper.call(context, value, key, this$1$1)); + }); + }); + }; + + // @pragma Mutability + + Map.prototype.__iterator = function __iterator (type, reverse) { + return new MapIterator(this, type, reverse); + }; + + Map.prototype.__iterate = function __iterate (fn, reverse) { + var this$1$1 = this; + + var iterations = 0; + this._root && + this._root.iterate(function (entry) { + iterations++; + return fn(entry[1], entry[0], this$1$1); + }, reverse); + return iterations; + }; + + Map.prototype.__ensureOwner = function __ensureOwner (ownerID) { + if (ownerID === this.__ownerID) { + return this; + } + if (!ownerID) { + if (this.size === 0) { + return emptyMap(); + } + this.__ownerID = ownerID; + this.__altered = false; + return this; + } + return makeMap(this.size, this._root, ownerID, this.__hash); + }; + + return Map; +}(KeyedCollection)); + +Map.isMap = isMap; + +var MapPrototype = Map.prototype; +MapPrototype[IS_MAP_SYMBOL] = true; +MapPrototype[DELETE] = MapPrototype.remove; +MapPrototype.removeAll = MapPrototype.deleteAll; +MapPrototype.setIn = setIn; +MapPrototype.removeIn = MapPrototype.deleteIn = deleteIn; +MapPrototype.update = update; +MapPrototype.updateIn = updateIn; +MapPrototype.merge = MapPrototype.concat = merge; +MapPrototype.mergeWith = mergeWith; +MapPrototype.mergeDeep = mergeDeep; +MapPrototype.mergeDeepWith = mergeDeepWith; +MapPrototype.mergeIn = mergeIn; +MapPrototype.mergeDeepIn = mergeDeepIn; +MapPrototype.withMutations = withMutations; +MapPrototype.wasAltered = wasAltered; +MapPrototype.asImmutable = asImmutable; +MapPrototype['@@transducer/init'] = MapPrototype.asMutable = asMutable; +MapPrototype['@@transducer/step'] = function (result, arr) { + return result.set(arr[0], arr[1]); +}; +MapPrototype['@@transducer/result'] = function (obj) { + return obj.asImmutable(); +}; + +// #pragma Trie Nodes + +var ArrayMapNode = function ArrayMapNode(ownerID, entries) { + this.ownerID = ownerID; + this.entries = entries; +}; + +ArrayMapNode.prototype.get = function get (shift, keyHash, key, notSetValue) { + var entries = this.entries; + for (var ii = 0, len = entries.length; ii < len; ii++) { + if (is(key, entries[ii][0])) { + return entries[ii][1]; + } + } + return notSetValue; +}; + +ArrayMapNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { + var removed = value === NOT_SET; + + var entries = this.entries; + var idx = 0; + var len = entries.length; + for (; idx < len; idx++) { + if (is(key, entries[idx][0])) { + break; + } + } + var exists = idx < len; + + if (exists ? entries[idx][1] === value : removed) { + return this; + } + + SetRef(didAlter); + (removed || !exists) && SetRef(didChangeSize); + + if (removed && entries.length === 1) { + return; // undefined + } + + if (!exists && !removed && entries.length >= MAX_ARRAY_MAP_SIZE) { + return createNodes(ownerID, entries, key, value); + } + + var isEditable = ownerID && ownerID === this.ownerID; + var newEntries = isEditable ? entries : arrCopy(entries); + + if (exists) { + if (removed) { + idx === len - 1 + ? newEntries.pop() + : (newEntries[idx] = newEntries.pop()); + } else { + newEntries[idx] = [key, value]; + } + } else { + newEntries.push([key, value]); + } + + if (isEditable) { + this.entries = newEntries; + return this; + } + + return new ArrayMapNode(ownerID, newEntries); +}; + +var BitmapIndexedNode = function BitmapIndexedNode(ownerID, bitmap, nodes) { + this.ownerID = ownerID; + this.bitmap = bitmap; + this.nodes = nodes; +}; + +BitmapIndexedNode.prototype.get = function get (shift, keyHash, key, notSetValue) { + if (keyHash === undefined) { + keyHash = hash(key); + } + var bit = 1 << ((shift === 0 ? keyHash : keyHash >>> shift) & MASK); + var bitmap = this.bitmap; + return (bitmap & bit) === 0 + ? notSetValue + : this.nodes[popCount(bitmap & (bit - 1))].get( + shift + SHIFT, + keyHash, + key, + notSetValue + ); +}; + +BitmapIndexedNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { + if (keyHash === undefined) { + keyHash = hash(key); + } + var keyHashFrag = (shift === 0 ? keyHash : keyHash >>> shift) & MASK; + var bit = 1 << keyHashFrag; + var bitmap = this.bitmap; + var exists = (bitmap & bit) !== 0; + + if (!exists && value === NOT_SET) { + return this; + } + + var idx = popCount(bitmap & (bit - 1)); + var nodes = this.nodes; + var node = exists ? nodes[idx] : undefined; + var newNode = updateNode( + node, + ownerID, + shift + SHIFT, + keyHash, + key, + value, + didChangeSize, + didAlter + ); + + if (newNode === node) { + return this; + } + + if (!exists && newNode && nodes.length >= MAX_BITMAP_INDEXED_SIZE) { + return expandNodes(ownerID, nodes, bitmap, keyHashFrag, newNode); + } + + if ( + exists && + !newNode && + nodes.length === 2 && + isLeafNode(nodes[idx ^ 1]) + ) { + return nodes[idx ^ 1]; + } + + if (exists && newNode && nodes.length === 1 && isLeafNode(newNode)) { + return newNode; + } + + var isEditable = ownerID && ownerID === this.ownerID; + var newBitmap = exists ? (newNode ? bitmap : bitmap ^ bit) : bitmap | bit; + var newNodes = exists + ? newNode + ? setAt(nodes, idx, newNode, isEditable) + : spliceOut(nodes, idx, isEditable) + : spliceIn(nodes, idx, newNode, isEditable); + + if (isEditable) { + this.bitmap = newBitmap; + this.nodes = newNodes; + return this; + } + + return new BitmapIndexedNode(ownerID, newBitmap, newNodes); +}; + +var HashArrayMapNode = function HashArrayMapNode(ownerID, count, nodes) { + this.ownerID = ownerID; + this.count = count; + this.nodes = nodes; +}; + +HashArrayMapNode.prototype.get = function get (shift, keyHash, key, notSetValue) { + if (keyHash === undefined) { + keyHash = hash(key); + } + var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK; + var node = this.nodes[idx]; + return node + ? node.get(shift + SHIFT, keyHash, key, notSetValue) + : notSetValue; +}; + +HashArrayMapNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { + if (keyHash === undefined) { + keyHash = hash(key); + } + var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK; + var removed = value === NOT_SET; + var nodes = this.nodes; + var node = nodes[idx]; + + if (removed && !node) { + return this; + } + + var newNode = updateNode( + node, + ownerID, + shift + SHIFT, + keyHash, + key, + value, + didChangeSize, + didAlter + ); + if (newNode === node) { + return this; + } + + var newCount = this.count; + if (!node) { + newCount++; + } else if (!newNode) { + newCount--; + if (newCount < MIN_HASH_ARRAY_MAP_SIZE) { + return packNodes(ownerID, nodes, newCount, idx); + } + } + + var isEditable = ownerID && ownerID === this.ownerID; + var newNodes = setAt(nodes, idx, newNode, isEditable); + + if (isEditable) { + this.count = newCount; + this.nodes = newNodes; + return this; + } + + return new HashArrayMapNode(ownerID, newCount, newNodes); +}; + +var HashCollisionNode = function HashCollisionNode(ownerID, keyHash, entries) { + this.ownerID = ownerID; + this.keyHash = keyHash; + this.entries = entries; +}; + +HashCollisionNode.prototype.get = function get (shift, keyHash, key, notSetValue) { + var entries = this.entries; + for (var ii = 0, len = entries.length; ii < len; ii++) { + if (is(key, entries[ii][0])) { + return entries[ii][1]; + } + } + return notSetValue; +}; + +HashCollisionNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { + if (keyHash === undefined) { + keyHash = hash(key); + } + + var removed = value === NOT_SET; + + if (keyHash !== this.keyHash) { + if (removed) { + return this; + } + SetRef(didAlter); + SetRef(didChangeSize); + return mergeIntoNode(this, ownerID, shift, keyHash, [key, value]); + } + + var entries = this.entries; + var idx = 0; + var len = entries.length; + for (; idx < len; idx++) { + if (is(key, entries[idx][0])) { + break; + } + } + var exists = idx < len; + + if (exists ? entries[idx][1] === value : removed) { + return this; + } + + SetRef(didAlter); + (removed || !exists) && SetRef(didChangeSize); + + if (removed && len === 2) { + return new ValueNode(ownerID, this.keyHash, entries[idx ^ 1]); + } + + var isEditable = ownerID && ownerID === this.ownerID; + var newEntries = isEditable ? entries : arrCopy(entries); + + if (exists) { + if (removed) { + idx === len - 1 + ? newEntries.pop() + : (newEntries[idx] = newEntries.pop()); + } else { + newEntries[idx] = [key, value]; + } + } else { + newEntries.push([key, value]); + } + + if (isEditable) { + this.entries = newEntries; + return this; + } + + return new HashCollisionNode(ownerID, this.keyHash, newEntries); +}; + +var ValueNode = function ValueNode(ownerID, keyHash, entry) { + this.ownerID = ownerID; + this.keyHash = keyHash; + this.entry = entry; +}; + +ValueNode.prototype.get = function get (shift, keyHash, key, notSetValue) { + return is(key, this.entry[0]) ? this.entry[1] : notSetValue; +}; + +ValueNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { + var removed = value === NOT_SET; + var keyMatch = is(key, this.entry[0]); + if (keyMatch ? value === this.entry[1] : removed) { + return this; + } + + SetRef(didAlter); + + if (removed) { + SetRef(didChangeSize); + return; // undefined + } + + if (keyMatch) { + if (ownerID && ownerID === this.ownerID) { + this.entry[1] = value; + return this; + } + return new ValueNode(ownerID, this.keyHash, [key, value]); + } + + SetRef(didChangeSize); + return mergeIntoNode(this, ownerID, shift, hash(key), [key, value]); +}; + +// #pragma Iterators + +ArrayMapNode.prototype.iterate = HashCollisionNode.prototype.iterate = + function (fn, reverse) { + var entries = this.entries; + for (var ii = 0, maxIndex = entries.length - 1; ii <= maxIndex; ii++) { + if (fn(entries[reverse ? maxIndex - ii : ii]) === false) { + return false; + } + } + }; + +BitmapIndexedNode.prototype.iterate = HashArrayMapNode.prototype.iterate = + function (fn, reverse) { + var nodes = this.nodes; + for (var ii = 0, maxIndex = nodes.length - 1; ii <= maxIndex; ii++) { + var node = nodes[reverse ? maxIndex - ii : ii]; + if (node && node.iterate(fn, reverse) === false) { + return false; + } + } + }; + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +ValueNode.prototype.iterate = function (fn, reverse) { + return fn(this.entry); +}; + +var MapIterator = /*@__PURE__*/(function (Iterator) { + function MapIterator(map, type, reverse) { + this._type = type; + this._reverse = reverse; + this._stack = map._root && mapIteratorFrame(map._root); + } + + if ( Iterator ) MapIterator.__proto__ = Iterator; + MapIterator.prototype = Object.create( Iterator && Iterator.prototype ); + MapIterator.prototype.constructor = MapIterator; + + MapIterator.prototype.next = function next () { + var type = this._type; + var stack = this._stack; + while (stack) { + var node = stack.node; + var index = stack.index++; + var maxIndex = (void 0); + if (node.entry) { + if (index === 0) { + return mapIteratorValue(type, node.entry); + } + } else if (node.entries) { + maxIndex = node.entries.length - 1; + if (index <= maxIndex) { + return mapIteratorValue( + type, + node.entries[this._reverse ? maxIndex - index : index] + ); + } + } else { + maxIndex = node.nodes.length - 1; + if (index <= maxIndex) { + var subNode = node.nodes[this._reverse ? maxIndex - index : index]; + if (subNode) { + if (subNode.entry) { + return mapIteratorValue(type, subNode.entry); + } + stack = this._stack = mapIteratorFrame(subNode, stack); + } + continue; + } + } + stack = this._stack = this._stack.__prev; + } + return iteratorDone(); + }; + + return MapIterator; +}(Iterator)); + +function mapIteratorValue(type, entry) { + return iteratorValue(type, entry[0], entry[1]); +} + +function mapIteratorFrame(node, prev) { + return { + node: node, + index: 0, + __prev: prev, + }; +} + +function makeMap(size, root, ownerID, hash) { + var map = Object.create(MapPrototype); + map.size = size; + map._root = root; + map.__ownerID = ownerID; + map.__hash = hash; + map.__altered = false; + return map; +} + +var EMPTY_MAP; +function emptyMap() { + return EMPTY_MAP || (EMPTY_MAP = makeMap(0)); +} + +function updateMap(map, k, v) { + var newRoot; + var newSize; + if (!map._root) { + if (v === NOT_SET) { + return map; + } + newSize = 1; + newRoot = new ArrayMapNode(map.__ownerID, [[k, v]]); + } else { + var didChangeSize = MakeRef(); + var didAlter = MakeRef(); + newRoot = updateNode( + map._root, + map.__ownerID, + 0, + undefined, + k, + v, + didChangeSize, + didAlter + ); + if (!didAlter.value) { + return map; + } + newSize = map.size + (didChangeSize.value ? (v === NOT_SET ? -1 : 1) : 0); + } + if (map.__ownerID) { + map.size = newSize; + map._root = newRoot; + map.__hash = undefined; + map.__altered = true; + return map; + } + return newRoot ? makeMap(newSize, newRoot) : emptyMap(); +} + +function updateNode( + node, + ownerID, + shift, + keyHash, + key, + value, + didChangeSize, + didAlter +) { + if (!node) { + if (value === NOT_SET) { + return node; + } + SetRef(didAlter); + SetRef(didChangeSize); + return new ValueNode(ownerID, keyHash, [key, value]); + } + return node.update( + ownerID, + shift, + keyHash, + key, + value, + didChangeSize, + didAlter + ); +} + +function isLeafNode(node) { + return ( + node.constructor === ValueNode || node.constructor === HashCollisionNode + ); +} + +function mergeIntoNode(node, ownerID, shift, keyHash, entry) { + if (node.keyHash === keyHash) { + return new HashCollisionNode(ownerID, keyHash, [node.entry, entry]); + } + + var idx1 = (shift === 0 ? node.keyHash : node.keyHash >>> shift) & MASK; + var idx2 = (shift === 0 ? keyHash : keyHash >>> shift) & MASK; + + var newNode; + var nodes = + idx1 === idx2 + ? [mergeIntoNode(node, ownerID, shift + SHIFT, keyHash, entry)] + : ((newNode = new ValueNode(ownerID, keyHash, entry)), + idx1 < idx2 ? [node, newNode] : [newNode, node]); + + return new BitmapIndexedNode(ownerID, (1 << idx1) | (1 << idx2), nodes); +} + +function createNodes(ownerID, entries, key, value) { + if (!ownerID) { + ownerID = new OwnerID(); + } + var node = new ValueNode(ownerID, hash(key), [key, value]); + for (var ii = 0; ii < entries.length; ii++) { + var entry = entries[ii]; + node = node.update(ownerID, 0, undefined, entry[0], entry[1]); + } + return node; +} + +function packNodes(ownerID, nodes, count, excluding) { + var bitmap = 0; + var packedII = 0; + var packedNodes = new Array(count); + for (var ii = 0, bit = 1, len = nodes.length; ii < len; ii++, bit <<= 1) { + var node = nodes[ii]; + if (node !== undefined && ii !== excluding) { + bitmap |= bit; + packedNodes[packedII++] = node; + } + } + return new BitmapIndexedNode(ownerID, bitmap, packedNodes); +} + +function expandNodes(ownerID, nodes, bitmap, including, node) { + var count = 0; + var expandedNodes = new Array(SIZE); + for (var ii = 0; bitmap !== 0; ii++, bitmap >>>= 1) { + expandedNodes[ii] = bitmap & 1 ? nodes[count++] : undefined; + } + expandedNodes[including] = node; + return new HashArrayMapNode(ownerID, count + 1, expandedNodes); +} + +function popCount(x) { + x -= (x >> 1) & 0x55555555; + x = (x & 0x33333333) + ((x >> 2) & 0x33333333); + x = (x + (x >> 4)) & 0x0f0f0f0f; + x += x >> 8; + x += x >> 16; + return x & 0x7f; +} + +function setAt(array, idx, val, canEdit) { + var newArray = canEdit ? array : arrCopy(array); + newArray[idx] = val; + return newArray; +} + +function spliceIn(array, idx, val, canEdit) { + var newLen = array.length + 1; + if (canEdit && idx + 1 === newLen) { + array[idx] = val; + return array; + } + var newArray = new Array(newLen); + var after = 0; + for (var ii = 0; ii < newLen; ii++) { + if (ii === idx) { + newArray[ii] = val; + after = -1; + } else { + newArray[ii] = array[ii + after]; + } + } + return newArray; +} + +function spliceOut(array, idx, canEdit) { + var newLen = array.length - 1; + if (canEdit && idx === newLen) { + array.pop(); + return array; + } + var newArray = new Array(newLen); + var after = 0; + for (var ii = 0; ii < newLen; ii++) { + if (ii === idx) { + after = 1; + } + newArray[ii] = array[ii + after]; + } + return newArray; +} + +var MAX_ARRAY_MAP_SIZE = SIZE / 4; +var MAX_BITMAP_INDEXED_SIZE = SIZE / 2; +var MIN_HASH_ARRAY_MAP_SIZE = SIZE / 4; + +export { Map, emptyMap }; diff --git a/dist/es/Math.js b/dist/es/Math.js new file mode 100644 index 0000000000..ffc262ee6b --- /dev/null +++ b/dist/es/Math.js @@ -0,0 +1,45 @@ +/** + * @license + * MIT License + * + * Copyright (c) 2014-present, Lee Byron and other contributors. + * + * 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: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +var imul = + typeof Math.imul === 'function' && Math.imul(0xffffffff, 2) === -2 + ? Math.imul + : function imul(a, b) { + a |= 0; // int + b |= 0; // int + var c = a & 0xffff; + var d = b & 0xffff; + // Shift by 0 fixes the sign on the high part. + return (c * d + ((((a >>> 16) * d + c * (b >>> 16)) << 16) >>> 0)) | 0; // int + }; + +// v8 has an optimization for storing 31-bit signed numbers. +// Values which have either 00 or 11 as the high order bits qualify. +// This function drops the highest order bit in a signed number, maintaining +// the sign bit. +function smi(i32) { + return ((i32 >>> 1) & 0x40000000) | (i32 & 0xbfffffff); +} + +export { imul, smi }; diff --git a/dist/es/Operations.js b/dist/es/Operations.js new file mode 100644 index 0000000000..a4c5cf9fa5 --- /dev/null +++ b/dist/es/Operations.js @@ -0,0 +1,953 @@ +/** + * @license + * MIT License + * + * Copyright (c) 2014-present, Lee Byron and other contributors. + * + * 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: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +import { ensureSize, NOT_SET, wholeSlice, wrapIndex, resolveBegin, resolveEnd } from './TrieUtils.js'; +import { KeyedCollection, Collection, IndexedCollection, SetCollection } from './Collection.js'; +import { isCollection } from './predicates/isCollection.js'; +import { isKeyed } from './predicates/isKeyed.js'; +import { isIndexed } from './predicates/isIndexed.js'; +import { IS_ORDERED_SYMBOL, isOrdered } from './predicates/isOrdered.js'; +import { isSeq } from './predicates/isSeq.js'; +import { ITERATE_VALUES, Iterator, iteratorValue, ITERATE_ENTRIES, ITERATE_KEYS, iteratorDone, getIterator } from './Iterator.js'; +import { KeyedSeq, IndexedSeq, SetSeq, keyedSeqFromValue, indexedSeqFromValue, ArraySeq, Seq } from './Seq.js'; +import { Map } from './Map.js'; +import { OrderedMap } from './OrderedMap.js'; + +var ToKeyedSequence = /*@__PURE__*/(function (KeyedSeq) { + function ToKeyedSequence(indexed, useKeys) { + this._iter = indexed; + this._useKeys = useKeys; + this.size = indexed.size; + } + + if ( KeyedSeq ) ToKeyedSequence.__proto__ = KeyedSeq; + ToKeyedSequence.prototype = Object.create( KeyedSeq && KeyedSeq.prototype ); + ToKeyedSequence.prototype.constructor = ToKeyedSequence; + + ToKeyedSequence.prototype.get = function get (key, notSetValue) { + return this._iter.get(key, notSetValue); + }; + + ToKeyedSequence.prototype.has = function has (key) { + return this._iter.has(key); + }; + + ToKeyedSequence.prototype.valueSeq = function valueSeq () { + return this._iter.valueSeq(); + }; + + ToKeyedSequence.prototype.reverse = function reverse () { + var this$1$1 = this; + + var reversedSequence = reverseFactory(this, true); + if (!this._useKeys) { + reversedSequence.valueSeq = function () { return this$1$1._iter.toSeq().reverse(); }; + } + return reversedSequence; + }; + + ToKeyedSequence.prototype.map = function map (mapper, context) { + var this$1$1 = this; + + var mappedSequence = mapFactory(this, mapper, context); + if (!this._useKeys) { + mappedSequence.valueSeq = function () { return this$1$1._iter.toSeq().map(mapper, context); }; + } + return mappedSequence; + }; + + ToKeyedSequence.prototype.__iterate = function __iterate (fn, reverse) { + var this$1$1 = this; + + return this._iter.__iterate(function (v, k) { return fn(v, k, this$1$1); }, reverse); + }; + + ToKeyedSequence.prototype.__iterator = function __iterator (type, reverse) { + return this._iter.__iterator(type, reverse); + }; + + return ToKeyedSequence; +}(KeyedSeq)); +ToKeyedSequence.prototype[IS_ORDERED_SYMBOL] = true; + +var ToIndexedSequence = /*@__PURE__*/(function (IndexedSeq) { + function ToIndexedSequence(iter) { + this._iter = iter; + this.size = iter.size; + } + + if ( IndexedSeq ) ToIndexedSequence.__proto__ = IndexedSeq; + ToIndexedSequence.prototype = Object.create( IndexedSeq && IndexedSeq.prototype ); + ToIndexedSequence.prototype.constructor = ToIndexedSequence; + + ToIndexedSequence.prototype.includes = function includes (value) { + return this._iter.includes(value); + }; + + ToIndexedSequence.prototype.__iterate = function __iterate (fn, reverse) { + var this$1$1 = this; + + var i = 0; + reverse && ensureSize(this); + return this._iter.__iterate( + function (v) { return fn(v, reverse ? this$1$1.size - ++i : i++, this$1$1); }, + reverse + ); + }; + + ToIndexedSequence.prototype.__iterator = function __iterator (type, reverse) { + var this$1$1 = this; + + var iterator = this._iter.__iterator(ITERATE_VALUES, reverse); + var i = 0; + reverse && ensureSize(this); + return new Iterator(function () { + var step = iterator.next(); + return step.done + ? step + : iteratorValue( + type, + reverse ? this$1$1.size - ++i : i++, + step.value, + step + ); + }); + }; + + return ToIndexedSequence; +}(IndexedSeq)); + +var ToSetSequence = /*@__PURE__*/(function (SetSeq) { + function ToSetSequence(iter) { + this._iter = iter; + this.size = iter.size; + } + + if ( SetSeq ) ToSetSequence.__proto__ = SetSeq; + ToSetSequence.prototype = Object.create( SetSeq && SetSeq.prototype ); + ToSetSequence.prototype.constructor = ToSetSequence; + + ToSetSequence.prototype.has = function has (key) { + return this._iter.includes(key); + }; + + ToSetSequence.prototype.__iterate = function __iterate (fn, reverse) { + var this$1$1 = this; + + return this._iter.__iterate(function (v) { return fn(v, v, this$1$1); }, reverse); + }; + + ToSetSequence.prototype.__iterator = function __iterator (type, reverse) { + var iterator = this._iter.__iterator(ITERATE_VALUES, reverse); + return new Iterator(function () { + var step = iterator.next(); + return step.done + ? step + : iteratorValue(type, step.value, step.value, step); + }); + }; + + return ToSetSequence; +}(SetSeq)); + +var FromEntriesSequence = /*@__PURE__*/(function (KeyedSeq) { + function FromEntriesSequence(entries) { + this._iter = entries; + this.size = entries.size; + } + + if ( KeyedSeq ) FromEntriesSequence.__proto__ = KeyedSeq; + FromEntriesSequence.prototype = Object.create( KeyedSeq && KeyedSeq.prototype ); + FromEntriesSequence.prototype.constructor = FromEntriesSequence; + + FromEntriesSequence.prototype.entrySeq = function entrySeq () { + return this._iter.toSeq(); + }; + + FromEntriesSequence.prototype.__iterate = function __iterate (fn, reverse) { + var this$1$1 = this; + + return this._iter.__iterate(function (entry) { + // Check if entry exists first so array access doesn't throw for holes + // in the parent iteration. + if (entry) { + validateEntry(entry); + var indexedCollection = isCollection(entry); + return fn( + indexedCollection ? entry.get(1) : entry[1], + indexedCollection ? entry.get(0) : entry[0], + this$1$1 + ); + } + }, reverse); + }; + + FromEntriesSequence.prototype.__iterator = function __iterator (type, reverse) { + var iterator = this._iter.__iterator(ITERATE_VALUES, reverse); + return new Iterator(function () { + while (true) { + var step = iterator.next(); + if (step.done) { + return step; + } + var entry = step.value; + // Check if entry exists first so array access doesn't throw for holes + // in the parent iteration. + if (entry) { + validateEntry(entry); + var indexedCollection = isCollection(entry); + return iteratorValue( + type, + indexedCollection ? entry.get(0) : entry[0], + indexedCollection ? entry.get(1) : entry[1], + step + ); + } + } + }); + }; + + return FromEntriesSequence; +}(KeyedSeq)); + +ToIndexedSequence.prototype.cacheResult = + ToKeyedSequence.prototype.cacheResult = + ToSetSequence.prototype.cacheResult = + FromEntriesSequence.prototype.cacheResult = + cacheResultThrough; + +function flipFactory(collection) { + var flipSequence = makeSequence(collection); + flipSequence._iter = collection; + flipSequence.size = collection.size; + flipSequence.flip = function () { return collection; }; + flipSequence.reverse = function () { + var reversedSequence = collection.reverse.apply(this); // super.reverse() + reversedSequence.flip = function () { return collection.reverse(); }; + return reversedSequence; + }; + flipSequence.has = function (key) { return collection.includes(key); }; + flipSequence.includes = function (key) { return collection.has(key); }; + flipSequence.cacheResult = cacheResultThrough; + flipSequence.__iterateUncached = function (fn, reverse) { + var this$1$1 = this; + + return collection.__iterate(function (v, k) { return fn(k, v, this$1$1) !== false; }, reverse); + }; + flipSequence.__iteratorUncached = function (type, reverse) { + if (type === ITERATE_ENTRIES) { + var iterator = collection.__iterator(type, reverse); + return new Iterator(function () { + var step = iterator.next(); + if (!step.done) { + var k = step.value[0]; + step.value[0] = step.value[1]; + step.value[1] = k; + } + return step; + }); + } + return collection.__iterator( + type === ITERATE_VALUES ? ITERATE_KEYS : ITERATE_VALUES, + reverse + ); + }; + return flipSequence; +} + +function mapFactory(collection, mapper, context) { + var mappedSequence = makeSequence(collection); + mappedSequence.size = collection.size; + mappedSequence.has = function (key) { return collection.has(key); }; + mappedSequence.get = function (key, notSetValue) { + var v = collection.get(key, NOT_SET); + return v === NOT_SET + ? notSetValue + : mapper.call(context, v, key, collection); + }; + mappedSequence.__iterateUncached = function (fn, reverse) { + var this$1$1 = this; + + return collection.__iterate( + function (v, k, c) { return fn(mapper.call(context, v, k, c), k, this$1$1) !== false; }, + reverse + ); + }; + mappedSequence.__iteratorUncached = function (type, reverse) { + var iterator = collection.__iterator(ITERATE_ENTRIES, reverse); + return new Iterator(function () { + var step = iterator.next(); + if (step.done) { + return step; + } + var entry = step.value; + var key = entry[0]; + return iteratorValue( + type, + key, + mapper.call(context, entry[1], key, collection), + step + ); + }); + }; + return mappedSequence; +} + +function reverseFactory(collection, useKeys) { + var this$1$1 = this; + + var reversedSequence = makeSequence(collection); + reversedSequence._iter = collection; + reversedSequence.size = collection.size; + reversedSequence.reverse = function () { return collection; }; + if (collection.flip) { + reversedSequence.flip = function () { + var flipSequence = flipFactory(collection); + flipSequence.reverse = function () { return collection.flip(); }; + return flipSequence; + }; + } + reversedSequence.get = function (key, notSetValue) { return collection.get(useKeys ? key : -1 - key, notSetValue); }; + reversedSequence.has = function (key) { return collection.has(useKeys ? key : -1 - key); }; + reversedSequence.includes = function (value) { return collection.includes(value); }; + reversedSequence.cacheResult = cacheResultThrough; + reversedSequence.__iterate = function (fn, reverse) { + var this$1$1 = this; + + var i = 0; + reverse && ensureSize(collection); + return collection.__iterate( + function (v, k) { return fn(v, useKeys ? k : reverse ? this$1$1.size - ++i : i++, this$1$1); }, + !reverse + ); + }; + reversedSequence.__iterator = function (type, reverse) { + var i = 0; + reverse && ensureSize(collection); + var iterator = collection.__iterator(ITERATE_ENTRIES, !reverse); + return new Iterator(function () { + var step = iterator.next(); + if (step.done) { + return step; + } + var entry = step.value; + return iteratorValue( + type, + useKeys ? entry[0] : reverse ? this$1$1.size - ++i : i++, + entry[1], + step + ); + }); + }; + return reversedSequence; +} + +function filterFactory(collection, predicate, context, useKeys) { + var filterSequence = makeSequence(collection); + if (useKeys) { + filterSequence.has = function (key) { + var v = collection.get(key, NOT_SET); + return v !== NOT_SET && !!predicate.call(context, v, key, collection); + }; + filterSequence.get = function (key, notSetValue) { + var v = collection.get(key, NOT_SET); + return v !== NOT_SET && predicate.call(context, v, key, collection) + ? v + : notSetValue; + }; + } + filterSequence.__iterateUncached = function (fn, reverse) { + var this$1$1 = this; + + var iterations = 0; + collection.__iterate(function (v, k, c) { + if (predicate.call(context, v, k, c)) { + iterations++; + return fn(v, useKeys ? k : iterations - 1, this$1$1); + } + }, reverse); + return iterations; + }; + filterSequence.__iteratorUncached = function (type, reverse) { + var iterator = collection.__iterator(ITERATE_ENTRIES, reverse); + var iterations = 0; + return new Iterator(function () { + while (true) { + var step = iterator.next(); + if (step.done) { + return step; + } + var entry = step.value; + var key = entry[0]; + var value = entry[1]; + if (predicate.call(context, value, key, collection)) { + return iteratorValue(type, useKeys ? key : iterations++, value, step); + } + } + }); + }; + return filterSequence; +} + +function countByFactory(collection, grouper, context) { + var groups = Map().asMutable(); + collection.__iterate(function (v, k) { + groups.update(grouper.call(context, v, k, collection), 0, function (a) { return a + 1; }); + }); + return groups.asImmutable(); +} + +function groupByFactory(collection, grouper, context) { + var isKeyedIter = isKeyed(collection); + var groups = (isOrdered(collection) ? OrderedMap() : Map()).asMutable(); + collection.__iterate(function (v, k) { + groups.update( + grouper.call(context, v, k, collection), + function (a) { return ((a = a || []), a.push(isKeyedIter ? [k, v] : v), a); } + ); + }); + var coerce = collectionClass(collection); + return groups.map(function (arr) { return reify(collection, coerce(arr)); }).asImmutable(); +} + +function partitionFactory(collection, predicate, context) { + var isKeyedIter = isKeyed(collection); + var groups = [[], []]; + collection.__iterate(function (v, k) { + groups[predicate.call(context, v, k, collection) ? 1 : 0].push( + isKeyedIter ? [k, v] : v + ); + }); + var coerce = collectionClass(collection); + return groups.map(function (arr) { return reify(collection, coerce(arr)); }); +} + +function sliceFactory(collection, begin, end, useKeys) { + var originalSize = collection.size; + + if (wholeSlice(begin, end, originalSize)) { + return collection; + } + + // begin or end can not be resolved if they were provided as negative numbers and + // this collection's size is unknown. In that case, cache first so there is + // a known size and these do not resolve to NaN. + if (typeof originalSize === 'undefined' && (begin < 0 || end < 0)) { + return sliceFactory(collection.toSeq().cacheResult(), begin, end, useKeys); + } + + var resolvedBegin = resolveBegin(begin, originalSize); + var resolvedEnd = resolveEnd(end, originalSize); + + // Note: resolvedEnd is undefined when the original sequence's length is + // unknown and this slice did not supply an end and should contain all + // elements after resolvedBegin. + // In that case, resolvedSize will be NaN and sliceSize will remain undefined. + var resolvedSize = resolvedEnd - resolvedBegin; + var sliceSize; + if (resolvedSize === resolvedSize) { + sliceSize = resolvedSize < 0 ? 0 : resolvedSize; + } + + var sliceSeq = makeSequence(collection); + + // If collection.size is undefined, the size of the realized sliceSeq is + // unknown at this point unless the number of items to slice is 0 + sliceSeq.size = + sliceSize === 0 ? sliceSize : (collection.size && sliceSize) || undefined; + + if (!useKeys && isSeq(collection) && sliceSize >= 0) { + sliceSeq.get = function (index, notSetValue) { + index = wrapIndex(this, index); + return index >= 0 && index < sliceSize + ? collection.get(index + resolvedBegin, notSetValue) + : notSetValue; + }; + } + + sliceSeq.__iterateUncached = function (fn, reverse) { + var this$1$1 = this; + + if (sliceSize === 0) { + return 0; + } + if (reverse) { + return this.cacheResult().__iterate(fn, reverse); + } + var skipped = 0; + var isSkipping = true; + var iterations = 0; + collection.__iterate(function (v, k) { + if (!(isSkipping && (isSkipping = skipped++ < resolvedBegin))) { + iterations++; + return ( + fn(v, useKeys ? k : iterations - 1, this$1$1) !== false && + iterations !== sliceSize + ); + } + }); + return iterations; + }; + + sliceSeq.__iteratorUncached = function (type, reverse) { + if (sliceSize !== 0 && reverse) { + return this.cacheResult().__iterator(type, reverse); + } + // Don't bother instantiating parent iterator if taking 0. + if (sliceSize === 0) { + return new Iterator(iteratorDone); + } + var iterator = collection.__iterator(type, reverse); + var skipped = 0; + var iterations = 0; + return new Iterator(function () { + while (skipped++ < resolvedBegin) { + iterator.next(); + } + if (++iterations > sliceSize) { + return iteratorDone(); + } + var step = iterator.next(); + if (useKeys || type === ITERATE_VALUES || step.done) { + return step; + } + if (type === ITERATE_KEYS) { + return iteratorValue(type, iterations - 1, undefined, step); + } + return iteratorValue(type, iterations - 1, step.value[1], step); + }); + }; + + return sliceSeq; +} + +function takeWhileFactory(collection, predicate, context) { + var takeSequence = makeSequence(collection); + takeSequence.__iterateUncached = function (fn, reverse) { + var this$1$1 = this; + + if (reverse) { + return this.cacheResult().__iterate(fn, reverse); + } + var iterations = 0; + collection.__iterate( + function (v, k, c) { return predicate.call(context, v, k, c) && ++iterations && fn(v, k, this$1$1); } + ); + return iterations; + }; + takeSequence.__iteratorUncached = function (type, reverse) { + var this$1$1 = this; + + if (reverse) { + return this.cacheResult().__iterator(type, reverse); + } + var iterator = collection.__iterator(ITERATE_ENTRIES, reverse); + var iterating = true; + return new Iterator(function () { + if (!iterating) { + return iteratorDone(); + } + var step = iterator.next(); + if (step.done) { + return step; + } + var entry = step.value; + var k = entry[0]; + var v = entry[1]; + if (!predicate.call(context, v, k, this$1$1)) { + iterating = false; + return iteratorDone(); + } + return type === ITERATE_ENTRIES ? step : iteratorValue(type, k, v, step); + }); + }; + return takeSequence; +} + +function skipWhileFactory(collection, predicate, context, useKeys) { + var skipSequence = makeSequence(collection); + skipSequence.__iterateUncached = function (fn, reverse) { + var this$1$1 = this; + + if (reverse) { + return this.cacheResult().__iterate(fn, reverse); + } + var isSkipping = true; + var iterations = 0; + collection.__iterate(function (v, k, c) { + if (!(isSkipping && (isSkipping = predicate.call(context, v, k, c)))) { + iterations++; + return fn(v, useKeys ? k : iterations - 1, this$1$1); + } + }); + return iterations; + }; + skipSequence.__iteratorUncached = function (type, reverse) { + var this$1$1 = this; + + if (reverse) { + return this.cacheResult().__iterator(type, reverse); + } + var iterator = collection.__iterator(ITERATE_ENTRIES, reverse); + var skipping = true; + var iterations = 0; + return new Iterator(function () { + var step; + var k; + var v; + do { + step = iterator.next(); + if (step.done) { + if (useKeys || type === ITERATE_VALUES) { + return step; + } + if (type === ITERATE_KEYS) { + return iteratorValue(type, iterations++, undefined, step); + } + return iteratorValue(type, iterations++, step.value[1], step); + } + var entry = step.value; + k = entry[0]; + v = entry[1]; + skipping && (skipping = predicate.call(context, v, k, this$1$1)); + } while (skipping); + return type === ITERATE_ENTRIES ? step : iteratorValue(type, k, v, step); + }); + }; + return skipSequence; +} + +function concatFactory(collection, values) { + var isKeyedCollection = isKeyed(collection); + var iters = [collection] + .concat(values) + .map(function (v) { + if (!isCollection(v)) { + v = isKeyedCollection + ? keyedSeqFromValue(v) + : indexedSeqFromValue(Array.isArray(v) ? v : [v]); + } else if (isKeyedCollection) { + v = KeyedCollection(v); + } + return v; + }) + .filter(function (v) { return v.size !== 0; }); + + if (iters.length === 0) { + return collection; + } + + if (iters.length === 1) { + var singleton = iters[0]; + if ( + singleton === collection || + (isKeyedCollection && isKeyed(singleton)) || + (isIndexed(collection) && isIndexed(singleton)) + ) { + return singleton; + } + } + + var concatSeq = new ArraySeq(iters); + if (isKeyedCollection) { + concatSeq = concatSeq.toKeyedSeq(); + } else if (!isIndexed(collection)) { + concatSeq = concatSeq.toSetSeq(); + } + concatSeq = concatSeq.flatten(true); + concatSeq.size = iters.reduce(function (sum, seq) { + if (sum !== undefined) { + var size = seq.size; + if (size !== undefined) { + return sum + size; + } + } + }, 0); + return concatSeq; +} + +function flattenFactory(collection, depth, useKeys) { + var flatSequence = makeSequence(collection); + flatSequence.__iterateUncached = function (fn, reverse) { + if (reverse) { + return this.cacheResult().__iterate(fn, reverse); + } + var iterations = 0; + var stopped = false; + function flatDeep(iter, currentDepth) { + iter.__iterate(function (v, k) { + if ((!depth || currentDepth < depth) && isCollection(v)) { + flatDeep(v, currentDepth + 1); + } else { + iterations++; + if (fn(v, useKeys ? k : iterations - 1, flatSequence) === false) { + stopped = true; + } + } + return !stopped; + }, reverse); + } + flatDeep(collection, 0); + return iterations; + }; + flatSequence.__iteratorUncached = function (type, reverse) { + if (reverse) { + return this.cacheResult().__iterator(type, reverse); + } + var iterator = collection.__iterator(type, reverse); + var stack = []; + var iterations = 0; + return new Iterator(function () { + while (iterator) { + var step = iterator.next(); + if (step.done !== false) { + iterator = stack.pop(); + continue; + } + var v = step.value; + if (type === ITERATE_ENTRIES) { + v = v[1]; + } + if ((!depth || stack.length < depth) && isCollection(v)) { + stack.push(iterator); + iterator = v.__iterator(type, reverse); + } else { + return useKeys ? step : iteratorValue(type, iterations++, v, step); + } + } + return iteratorDone(); + }); + }; + return flatSequence; +} + +function flatMapFactory(collection, mapper, context) { + var coerce = collectionClass(collection); + return collection + .toSeq() + .map(function (v, k) { return coerce(mapper.call(context, v, k, collection)); }) + .flatten(true); +} + +function interposeFactory(collection, separator) { + var interposedSequence = makeSequence(collection); + interposedSequence.size = collection.size && collection.size * 2 - 1; + interposedSequence.__iterateUncached = function (fn, reverse) { + var this$1$1 = this; + + var iterations = 0; + collection.__iterate( + function (v) { return (!iterations || fn(separator, iterations++, this$1$1) !== false) && + fn(v, iterations++, this$1$1) !== false; }, + reverse + ); + return iterations; + }; + interposedSequence.__iteratorUncached = function (type, reverse) { + var iterator = collection.__iterator(ITERATE_VALUES, reverse); + var iterations = 0; + var step; + return new Iterator(function () { + if (!step || iterations % 2) { + step = iterator.next(); + if (step.done) { + return step; + } + } + return iterations % 2 + ? iteratorValue(type, iterations++, separator) + : iteratorValue(type, iterations++, step.value, step); + }); + }; + return interposedSequence; +} + +function sortFactory(collection, comparator, mapper) { + if (!comparator) { + comparator = defaultComparator; + } + var isKeyedCollection = isKeyed(collection); + var index = 0; + var entries = collection + .toSeq() + .map(function (v, k) { return [k, v, index++, mapper ? mapper(v, k, collection) : v]; }) + .valueSeq() + .toArray(); + entries + .sort(function (a, b) { return comparator(a[3], b[3]) || a[2] - b[2]; }) + .forEach( + isKeyedCollection + ? function (v, i) { + entries[i].length = 2; + } + : function (v, i) { + entries[i] = v[1]; + } + ); + return isKeyedCollection + ? KeyedSeq(entries) + : isIndexed(collection) + ? IndexedSeq(entries) + : SetSeq(entries); +} + +function maxFactory(collection, comparator, mapper) { + if (!comparator) { + comparator = defaultComparator; + } + if (mapper) { + var entry = collection + .toSeq() + .map(function (v, k) { return [v, mapper(v, k, collection)]; }) + .reduce(function (a, b) { return (maxCompare(comparator, a[1], b[1]) ? b : a); }); + return entry && entry[0]; + } + return collection.reduce(function (a, b) { return (maxCompare(comparator, a, b) ? b : a); }); +} + +function maxCompare(comparator, a, b) { + var comp = comparator(b, a); + // b is considered the new max if the comparator declares them equal, but + // they are not equal and b is in fact a nullish value. + return ( + (comp === 0 && b !== a && (b === undefined || b === null || b !== b)) || + comp > 0 + ); +} + +function zipWithFactory(keyIter, zipper, iters, zipAll) { + var zipSequence = makeSequence(keyIter); + var sizes = new ArraySeq(iters).map(function (i) { return i.size; }); + zipSequence.size = zipAll ? sizes.max() : sizes.min(); + // Note: this a generic base implementation of __iterate in terms of + // __iterator which may be more generically useful in the future. + zipSequence.__iterate = function (fn, reverse) { + /* generic: + var iterator = this.__iterator(ITERATE_ENTRIES, reverse); + var step; + var iterations = 0; + while (!(step = iterator.next()).done) { + iterations++; + if (fn(step.value[1], step.value[0], this) === false) { + break; + } + } + return iterations; + */ + // indexed: + var iterator = this.__iterator(ITERATE_VALUES, reverse); + var step; + var iterations = 0; + while (!(step = iterator.next()).done) { + if (fn(step.value, iterations++, this) === false) { + break; + } + } + return iterations; + }; + zipSequence.__iteratorUncached = function (type, reverse) { + var iterators = iters.map( + function (i) { return ((i = Collection(i)), getIterator(reverse ? i.reverse() : i)); } + ); + var iterations = 0; + var isDone = false; + return new Iterator(function () { + var steps; + if (!isDone) { + steps = iterators.map(function (i) { return i.next(); }); + isDone = zipAll ? steps.every(function (s) { return s.done; }) : steps.some(function (s) { return s.done; }); + } + if (isDone) { + return iteratorDone(); + } + return iteratorValue( + type, + iterations++, + zipper.apply( + null, + steps.map(function (s) { return s.value; }) + ) + ); + }); + }; + return zipSequence; +} + +// #pragma Helper Functions + +function reify(iter, seq) { + return iter === seq ? iter : isSeq(iter) ? seq : iter.constructor(seq); +} + +function validateEntry(entry) { + if (entry !== Object(entry)) { + throw new TypeError('Expected [K, V] tuple: ' + entry); + } +} + +function collectionClass(collection) { + return isKeyed(collection) + ? KeyedCollection + : isIndexed(collection) + ? IndexedCollection + : SetCollection; +} + +function makeSequence(collection) { + return Object.create( + (isKeyed(collection) + ? KeyedSeq + : isIndexed(collection) + ? IndexedSeq + : SetSeq + ).prototype + ); +} + +function cacheResultThrough() { + if (this._iter.cacheResult) { + this._iter.cacheResult(); + this.size = this._iter.size; + return this; + } + return Seq.prototype.cacheResult.call(this); +} + +function defaultComparator(a, b) { + if (a === undefined && b === undefined) { + return 0; + } + + if (a === undefined) { + return 1; + } + + if (b === undefined) { + return -1; + } + + return a > b ? 1 : a < b ? -1 : 0; +} + +export { FromEntriesSequence, ToIndexedSequence, ToKeyedSequence, ToSetSequence, concatFactory, countByFactory, filterFactory, flatMapFactory, flattenFactory, flipFactory, groupByFactory, interposeFactory, mapFactory, maxFactory, partitionFactory, reify, reverseFactory, skipWhileFactory, sliceFactory, sortFactory, takeWhileFactory, zipWithFactory }; diff --git a/dist/es/OrderedMap.js b/dist/es/OrderedMap.js new file mode 100644 index 0000000000..09562161a3 --- /dev/null +++ b/dist/es/OrderedMap.js @@ -0,0 +1,196 @@ +/** + * @license + * MIT License + * + * Copyright (c) 2014-present, Lee Byron and other contributors. + * + * 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: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +import { KeyedCollection } from './Collection.js'; +import { IS_ORDERED_SYMBOL } from './predicates/isOrdered.js'; +import { isOrderedMap } from './predicates/isOrderedMap.js'; +import { Map, emptyMap } from './Map.js'; +import { emptyList } from './List.js'; +import { DELETE, NOT_SET, SIZE } from './TrieUtils.js'; +import assertNotInfinite from './utils/assertNotInfinite.js'; + +var OrderedMap = /*@__PURE__*/(function (Map) { + function OrderedMap(value) { + // eslint-disable-next-line no-constructor-return + return value === undefined || value === null + ? emptyOrderedMap() + : isOrderedMap(value) + ? value + : emptyOrderedMap().withMutations(function (map) { + var iter = KeyedCollection(value); + assertNotInfinite(iter.size); + iter.forEach(function (v, k) { return map.set(k, v); }); + }); + } + + if ( Map ) OrderedMap.__proto__ = Map; + OrderedMap.prototype = Object.create( Map && Map.prototype ); + OrderedMap.prototype.constructor = OrderedMap; + + OrderedMap.of = function of (/*...values*/) { + return this(arguments); + }; + + OrderedMap.prototype.toString = function toString () { + return this.__toString('OrderedMap {', '}'); + }; + + // @pragma Access + + OrderedMap.prototype.get = function get (k, notSetValue) { + var index = this._map.get(k); + return index !== undefined ? this._list.get(index)[1] : notSetValue; + }; + + // @pragma Modification + + OrderedMap.prototype.clear = function clear () { + if (this.size === 0) { + return this; + } + if (this.__ownerID) { + this.size = 0; + this._map.clear(); + this._list.clear(); + this.__altered = true; + return this; + } + return emptyOrderedMap(); + }; + + OrderedMap.prototype.set = function set (k, v) { + return updateOrderedMap(this, k, v); + }; + + OrderedMap.prototype.remove = function remove (k) { + return updateOrderedMap(this, k, NOT_SET); + }; + + OrderedMap.prototype.__iterate = function __iterate (fn, reverse) { + var this$1$1 = this; + + return this._list.__iterate( + function (entry) { return entry && fn(entry[1], entry[0], this$1$1); }, + reverse + ); + }; + + OrderedMap.prototype.__iterator = function __iterator (type, reverse) { + return this._list.fromEntrySeq().__iterator(type, reverse); + }; + + OrderedMap.prototype.__ensureOwner = function __ensureOwner (ownerID) { + if (ownerID === this.__ownerID) { + return this; + } + var newMap = this._map.__ensureOwner(ownerID); + var newList = this._list.__ensureOwner(ownerID); + if (!ownerID) { + if (this.size === 0) { + return emptyOrderedMap(); + } + this.__ownerID = ownerID; + this.__altered = false; + this._map = newMap; + this._list = newList; + return this; + } + return makeOrderedMap(newMap, newList, ownerID, this.__hash); + }; + + return OrderedMap; +}(Map)); + +OrderedMap.isOrderedMap = isOrderedMap; + +OrderedMap.prototype[IS_ORDERED_SYMBOL] = true; +OrderedMap.prototype[DELETE] = OrderedMap.prototype.remove; + +function makeOrderedMap(map, list, ownerID, hash) { + var omap = Object.create(OrderedMap.prototype); + omap.size = map ? map.size : 0; + omap._map = map; + omap._list = list; + omap.__ownerID = ownerID; + omap.__hash = hash; + omap.__altered = false; + return omap; +} + +var EMPTY_ORDERED_MAP; +function emptyOrderedMap() { + return ( + EMPTY_ORDERED_MAP || + (EMPTY_ORDERED_MAP = makeOrderedMap(emptyMap(), emptyList())) + ); +} + +function updateOrderedMap(omap, k, v) { + var map = omap._map; + var list = omap._list; + var i = map.get(k); + var has = i !== undefined; + var newMap; + var newList; + if (v === NOT_SET) { + // removed + if (!has) { + return omap; + } + if (list.size >= SIZE && list.size >= map.size * 2) { + newList = list.filter(function (entry, idx) { return entry !== undefined && i !== idx; }); + newMap = newList + .toKeyedSeq() + .map(function (entry) { return entry[0]; }) + .flip() + .toMap(); + if (omap.__ownerID) { + newMap.__ownerID = newList.__ownerID = omap.__ownerID; + } + } else { + newMap = map.remove(k); + newList = i === list.size - 1 ? list.pop() : list.set(i, undefined); + } + } else if (has) { + if (v === list.get(i)[1]) { + return omap; + } + newMap = map; + newList = list.set(i, [k, v]); + } else { + newMap = map.set(k, list.size); + newList = list.set(list.size, [k, v]); + } + if (omap.__ownerID) { + omap.size = newMap.size; + omap._map = newMap; + omap._list = newList; + omap.__hash = undefined; + omap.__altered = true; + return omap; + } + return makeOrderedMap(newMap, newList); +} + +export { OrderedMap, emptyOrderedMap }; diff --git a/dist/es/OrderedSet.js b/dist/es/OrderedSet.js new file mode 100644 index 0000000000..b314a86493 --- /dev/null +++ b/dist/es/OrderedSet.js @@ -0,0 +1,92 @@ +/** + * @license + * MIT License + * + * Copyright (c) 2014-present, Lee Byron and other contributors. + * + * 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: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +import { KeyedCollection, SetCollection } from './Collection.js'; +import { IS_ORDERED_SYMBOL } from './predicates/isOrdered.js'; +import { isOrderedSet } from './predicates/isOrderedSet.js'; +import { IndexedCollectionPrototype } from './CollectionImpl.js'; +import { Set } from './Set.js'; +import { emptyOrderedMap } from './OrderedMap.js'; +import assertNotInfinite from './utils/assertNotInfinite.js'; + +var OrderedSet = /*@__PURE__*/(function (Set) { + function OrderedSet(value) { + // eslint-disable-next-line no-constructor-return + return value === undefined || value === null + ? emptyOrderedSet() + : isOrderedSet(value) + ? value + : emptyOrderedSet().withMutations(function (set) { + var iter = SetCollection(value); + assertNotInfinite(iter.size); + iter.forEach(function (v) { return set.add(v); }); + }); + } + + if ( Set ) OrderedSet.__proto__ = Set; + OrderedSet.prototype = Object.create( Set && Set.prototype ); + OrderedSet.prototype.constructor = OrderedSet; + + OrderedSet.of = function of (/*...values*/) { + return this(arguments); + }; + + OrderedSet.fromKeys = function fromKeys (value) { + return this(KeyedCollection(value).keySeq()); + }; + + OrderedSet.prototype.toString = function toString () { + return this.__toString('OrderedSet {', '}'); + }; + + return OrderedSet; +}(Set)); + +OrderedSet.isOrderedSet = isOrderedSet; + +var OrderedSetPrototype = OrderedSet.prototype; +OrderedSetPrototype[IS_ORDERED_SYMBOL] = true; +OrderedSetPrototype.zip = IndexedCollectionPrototype.zip; +OrderedSetPrototype.zipWith = IndexedCollectionPrototype.zipWith; +OrderedSetPrototype.zipAll = IndexedCollectionPrototype.zipAll; + +OrderedSetPrototype.__empty = emptyOrderedSet; +OrderedSetPrototype.__make = makeOrderedSet; + +function makeOrderedSet(map, ownerID) { + var set = Object.create(OrderedSetPrototype); + set.size = map ? map.size : 0; + set._map = map; + set.__ownerID = ownerID; + return set; +} + +var EMPTY_ORDERED_SET; +function emptyOrderedSet() { + return ( + EMPTY_ORDERED_SET || (EMPTY_ORDERED_SET = makeOrderedSet(emptyOrderedMap())) + ); +} + +export { OrderedSet }; diff --git a/dist/es/PairSorting.js b/dist/es/PairSorting.js new file mode 100644 index 0000000000..30b24ed7ed --- /dev/null +++ b/dist/es/PairSorting.js @@ -0,0 +1,30 @@ +/** + * @license + * MIT License + * + * Copyright (c) 2014-present, Lee Byron and other contributors. + * + * 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: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +var PairSorting = { + LeftThenRight: -1, + RightThenLeft: +1, +}; + +export { PairSorting }; diff --git a/dist/es/Range.js b/dist/es/Range.js new file mode 100644 index 0000000000..f890d72a57 --- /dev/null +++ b/dist/es/Range.js @@ -0,0 +1,178 @@ +/** + * @license + * MIT License + * + * Copyright (c) 2014-present, Lee Byron and other contributors. + * + * 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: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +import { wrapIndex, wholeSlice, resolveBegin, resolveEnd } from './TrieUtils.js'; +import { IndexedSeq } from './Seq.js'; +import { Iterator, iteratorDone, iteratorValue } from './Iterator.js'; +import invariant from './utils/invariant.js'; +import deepEqual from './utils/deepEqual.js'; + +/** + * Returns a lazy seq of nums from start (inclusive) to end + * (exclusive), by step, where start defaults to 0, step to 1, and end to + * infinity. When start is equal to end, returns empty list. + */ +var Range = /*@__PURE__*/(function (IndexedSeq) { + function Range(start, end, step) { + if ( step === void 0 ) step = 1; + + if (!(this instanceof Range)) { + // eslint-disable-next-line no-constructor-return + return new Range(start, end, step); + } + invariant(step !== 0, 'Cannot step a Range by 0'); + invariant( + start !== undefined, + 'You must define a start value when using Range' + ); + invariant( + end !== undefined, + 'You must define an end value when using Range' + ); + + step = Math.abs(step); + if (end < start) { + step = -step; + } + this._start = start; + this._end = end; + this._step = step; + this.size = Math.max(0, Math.ceil((end - start) / step - 1) + 1); + if (this.size === 0) { + if (EMPTY_RANGE) { + // eslint-disable-next-line no-constructor-return + return EMPTY_RANGE; + } + // eslint-disable-next-line @typescript-eslint/no-this-alias + EMPTY_RANGE = this; + } + } + + if ( IndexedSeq ) Range.__proto__ = IndexedSeq; + Range.prototype = Object.create( IndexedSeq && IndexedSeq.prototype ); + Range.prototype.constructor = Range; + + Range.prototype.toString = function toString () { + if (this.size === 0) { + return 'Range []'; + } + return ( + 'Range [ ' + + this._start + + '...' + + this._end + + (this._step !== 1 ? ' by ' + this._step : '') + + ' ]' + ); + }; + + Range.prototype.get = function get (index, notSetValue) { + return this.has(index) + ? this._start + wrapIndex(this, index) * this._step + : notSetValue; + }; + + Range.prototype.includes = function includes (searchValue) { + var possibleIndex = (searchValue - this._start) / this._step; + return ( + possibleIndex >= 0 && + possibleIndex < this.size && + possibleIndex === Math.floor(possibleIndex) + ); + }; + + Range.prototype.slice = function slice (begin, end) { + if (wholeSlice(begin, end, this.size)) { + return this; + } + begin = resolveBegin(begin, this.size); + end = resolveEnd(end, this.size); + if (end <= begin) { + return new Range(0, 0); + } + return new Range( + this.get(begin, this._end), + this.get(end, this._end), + this._step + ); + }; + + Range.prototype.indexOf = function indexOf (searchValue) { + var offsetValue = searchValue - this._start; + if (offsetValue % this._step === 0) { + var index = offsetValue / this._step; + if (index >= 0 && index < this.size) { + return index; + } + } + return -1; + }; + + Range.prototype.lastIndexOf = function lastIndexOf (searchValue) { + return this.indexOf(searchValue); + }; + + Range.prototype.__iterate = function __iterate (fn, reverse) { + var size = this.size; + var step = this._step; + var value = reverse ? this._start + (size - 1) * step : this._start; + var i = 0; + while (i !== size) { + if (fn(value, reverse ? size - ++i : i++, this) === false) { + break; + } + value += reverse ? -step : step; + } + return i; + }; + + Range.prototype.__iterator = function __iterator (type, reverse) { + var size = this.size; + var step = this._step; + var value = reverse ? this._start + (size - 1) * step : this._start; + var i = 0; + return new Iterator(function () { + if (i === size) { + return iteratorDone(); + } + var v = value; + value += reverse ? -step : step; + return iteratorValue(type, reverse ? size - ++i : i++, v); + }); + }; + + Range.prototype.equals = function equals (other) { + return other instanceof Range + ? this._start === other._start && + this._end === other._end && + this._step === other._step + : deepEqual(this, other); + }; + + return Range; +}(IndexedSeq)); + +var EMPTY_RANGE; + +export { Range }; diff --git a/dist/es/Record.js b/dist/es/Record.js new file mode 100644 index 0000000000..7053e011b6 --- /dev/null +++ b/dist/es/Record.js @@ -0,0 +1,292 @@ +/** + * @license + * MIT License + * + * Copyright (c) 2014-present, Lee Byron and other contributors. + * + * 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: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +import { toJS } from './toJS.js'; +import { KeyedCollection } from './Collection.js'; +import { keyedSeqFromValue } from './Seq.js'; +import { List } from './List.js'; +import { ITERATOR_SYMBOL, ITERATE_ENTRIES } from './Iterator.js'; +import { isRecord, IS_RECORD_SYMBOL } from './predicates/isRecord.js'; +import { CollectionPrototype } from './CollectionImpl.js'; +import { DELETE } from './TrieUtils.js'; +import { getIn } from './methods/getIn.js'; +import { setIn } from './methods/setIn.js'; +import { deleteIn } from './methods/deleteIn.js'; +import { update } from './methods/update.js'; +import { updateIn } from './methods/updateIn.js'; +import { merge, mergeWith } from './methods/merge.js'; +import { mergeDeep, mergeDeepWith } from './methods/mergeDeep.js'; +import { mergeIn } from './methods/mergeIn.js'; +import { mergeDeepIn } from './methods/mergeDeepIn.js'; +import { withMutations } from './methods/withMutations.js'; +import { asMutable } from './methods/asMutable.js'; +import { asImmutable } from './methods/asImmutable.js'; +import invariant from './utils/invariant.js'; +import quoteString from './utils/quoteString.js'; +import { isImmutable } from './predicates/isImmutable.js'; + +function throwOnInvalidDefaultValues(defaultValues) { + if (isRecord(defaultValues)) { + throw new Error( + 'Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.' + ); + } + + if (isImmutable(defaultValues)) { + throw new Error( + 'Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.' + ); + } + + if (defaultValues === null || typeof defaultValues !== 'object') { + throw new Error( + 'Can not call `Record` with a non-object as default values. Use a plain javascript object instead.' + ); + } +} + +var Record = function Record(defaultValues, name) { + var hasInitialized; + + throwOnInvalidDefaultValues(defaultValues); + + var RecordType = function Record(values) { + var this$1$1 = this; + + if (values instanceof RecordType) { + return values; + } + if (!(this instanceof RecordType)) { + return new RecordType(values); + } + if (!hasInitialized) { + hasInitialized = true; + var keys = Object.keys(defaultValues); + var indices = (RecordTypePrototype._indices = {}); + // Deprecated: left to attempt not to break any external code which + // relies on a ._name property existing on record instances. + // Use Record.getDescriptiveName() instead + RecordTypePrototype._name = name; + RecordTypePrototype._keys = keys; + RecordTypePrototype._defaultValues = defaultValues; + for (var i = 0; i < keys.length; i++) { + var propName = keys[i]; + indices[propName] = i; + if (RecordTypePrototype[propName]) { + /* eslint-disable no-console */ + typeof console === 'object' && + console.warn && + console.warn( + 'Cannot define ' + + recordName(this) + + ' with property "' + + propName + + '" since that property name is part of the Record API.' + ); + /* eslint-enable no-console */ + } else { + setProp(RecordTypePrototype, propName); + } + } + } + this.__ownerID = undefined; + this._values = List().withMutations(function (l) { + l.setSize(this$1$1._keys.length); + KeyedCollection(values).forEach(function (v, k) { + l.set(this$1$1._indices[k], v === this$1$1._defaultValues[k] ? undefined : v); + }); + }); + return this; + }; + + var RecordTypePrototype = (RecordType.prototype = + Object.create(RecordPrototype)); + RecordTypePrototype.constructor = RecordType; + + if (name) { + RecordType.displayName = name; + } + + // eslint-disable-next-line no-constructor-return + return RecordType; +}; + +Record.prototype.toString = function toString () { + var str = recordName(this) + ' { '; + var keys = this._keys; + var k; + for (var i = 0, l = keys.length; i !== l; i++) { + k = keys[i]; + str += (i ? ', ' : '') + k + ': ' + quoteString(this.get(k)); + } + return str + ' }'; +}; + +Record.prototype.equals = function equals (other) { + return ( + this === other || + (isRecord(other) && recordSeq(this).equals(recordSeq(other))) + ); +}; + +Record.prototype.hashCode = function hashCode () { + return recordSeq(this).hashCode(); +}; + +// @pragma Access + +Record.prototype.has = function has (k) { + return this._indices.hasOwnProperty(k); +}; + +Record.prototype.get = function get (k, notSetValue) { + if (!this.has(k)) { + return notSetValue; + } + var index = this._indices[k]; + var value = this._values.get(index); + return value === undefined ? this._defaultValues[k] : value; +}; + +// @pragma Modification + +Record.prototype.set = function set (k, v) { + if (this.has(k)) { + var newValues = this._values.set( + this._indices[k], + v === this._defaultValues[k] ? undefined : v + ); + if (newValues !== this._values && !this.__ownerID) { + return makeRecord(this, newValues); + } + } + return this; +}; + +Record.prototype.remove = function remove (k) { + return this.set(k); +}; + +Record.prototype.clear = function clear () { + var newValues = this._values.clear().setSize(this._keys.length); + + return this.__ownerID ? this : makeRecord(this, newValues); +}; + +Record.prototype.wasAltered = function wasAltered () { + return this._values.wasAltered(); +}; + +Record.prototype.toSeq = function toSeq () { + return recordSeq(this); +}; + +Record.prototype.toJS = function toJS$1 () { + return toJS(this); +}; + +Record.prototype.entries = function entries () { + return this.__iterator(ITERATE_ENTRIES); +}; + +Record.prototype.__iterator = function __iterator (type, reverse) { + return recordSeq(this).__iterator(type, reverse); +}; + +Record.prototype.__iterate = function __iterate (fn, reverse) { + return recordSeq(this).__iterate(fn, reverse); +}; + +Record.prototype.__ensureOwner = function __ensureOwner (ownerID) { + if (ownerID === this.__ownerID) { + return this; + } + var newValues = this._values.__ensureOwner(ownerID); + if (!ownerID) { + this.__ownerID = ownerID; + this._values = newValues; + return this; + } + return makeRecord(this, newValues, ownerID); +}; + +Record.isRecord = isRecord; +Record.getDescriptiveName = recordName; +var RecordPrototype = Record.prototype; +RecordPrototype[IS_RECORD_SYMBOL] = true; +RecordPrototype[DELETE] = RecordPrototype.remove; +RecordPrototype.deleteIn = RecordPrototype.removeIn = deleteIn; +RecordPrototype.getIn = getIn; +RecordPrototype.hasIn = CollectionPrototype.hasIn; +RecordPrototype.merge = merge; +RecordPrototype.mergeWith = mergeWith; +RecordPrototype.mergeIn = mergeIn; +RecordPrototype.mergeDeep = mergeDeep; +RecordPrototype.mergeDeepWith = mergeDeepWith; +RecordPrototype.mergeDeepIn = mergeDeepIn; +RecordPrototype.setIn = setIn; +RecordPrototype.update = update; +RecordPrototype.updateIn = updateIn; +RecordPrototype.withMutations = withMutations; +RecordPrototype.asMutable = asMutable; +RecordPrototype.asImmutable = asImmutable; +RecordPrototype[ITERATOR_SYMBOL] = RecordPrototype.entries; +RecordPrototype.toJSON = RecordPrototype.toObject = + CollectionPrototype.toObject; +RecordPrototype.inspect = RecordPrototype.toSource = function () { + return this.toString(); +}; + +function makeRecord(likeRecord, values, ownerID) { + var record = Object.create(Object.getPrototypeOf(likeRecord)); + record._values = values; + record.__ownerID = ownerID; + return record; +} + +function recordName(record) { + return record.constructor.displayName || record.constructor.name || 'Record'; +} + +function recordSeq(record) { + return keyedSeqFromValue(record._keys.map(function (k) { return [k, record.get(k)]; })); +} + +function setProp(prototype, name) { + try { + Object.defineProperty(prototype, name, { + get: function () { + return this.get(name); + }, + set: function (value) { + invariant(this.__ownerID, 'Cannot set on an immutable record.'); + this.set(name, value); + }, + }); + } catch (error) { + // Object.defineProperty failed. Probably IE8. + } +} + +export { Record }; diff --git a/dist/es/Repeat.js b/dist/es/Repeat.js new file mode 100644 index 0000000000..964ddb95fe --- /dev/null +++ b/dist/es/Repeat.js @@ -0,0 +1,133 @@ +/** + * @license + * MIT License + * + * Copyright (c) 2014-present, Lee Byron and other contributors. + * + * 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: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +import { wholeSlice, resolveEnd, resolveBegin } from './TrieUtils.js'; +import { IndexedSeq } from './Seq.js'; +import { is } from './is.js'; +import { Iterator, iteratorDone, iteratorValue } from './Iterator.js'; +import deepEqual from './utils/deepEqual.js'; + +/** + * Returns a lazy Seq of `value` repeated `times` times. When `times` is + * undefined, returns an infinite sequence of `value`. + */ +var Repeat = /*@__PURE__*/(function (IndexedSeq) { + function Repeat(value, times) { + if (!(this instanceof Repeat)) { + // eslint-disable-next-line no-constructor-return + return new Repeat(value, times); + } + this._value = value; + this.size = times === undefined ? Infinity : Math.max(0, times); + if (this.size === 0) { + if (EMPTY_REPEAT) { + // eslint-disable-next-line no-constructor-return + return EMPTY_REPEAT; + } + // eslint-disable-next-line @typescript-eslint/no-this-alias + EMPTY_REPEAT = this; + } + } + + if ( IndexedSeq ) Repeat.__proto__ = IndexedSeq; + Repeat.prototype = Object.create( IndexedSeq && IndexedSeq.prototype ); + Repeat.prototype.constructor = Repeat; + + Repeat.prototype.toString = function toString () { + if (this.size === 0) { + return 'Repeat []'; + } + return 'Repeat [ ' + this._value + ' ' + this.size + ' times ]'; + }; + + Repeat.prototype.get = function get (index, notSetValue) { + return this.has(index) ? this._value : notSetValue; + }; + + Repeat.prototype.includes = function includes (searchValue) { + return is(this._value, searchValue); + }; + + Repeat.prototype.slice = function slice (begin, end) { + var size = this.size; + return wholeSlice(begin, end, size) + ? this + : new Repeat( + this._value, + resolveEnd(end, size) - resolveBegin(begin, size) + ); + }; + + Repeat.prototype.reverse = function reverse () { + return this; + }; + + Repeat.prototype.indexOf = function indexOf (searchValue) { + if (is(this._value, searchValue)) { + return 0; + } + return -1; + }; + + Repeat.prototype.lastIndexOf = function lastIndexOf (searchValue) { + if (is(this._value, searchValue)) { + return this.size; + } + return -1; + }; + + Repeat.prototype.__iterate = function __iterate (fn, reverse) { + var size = this.size; + var i = 0; + while (i !== size) { + if (fn(this._value, reverse ? size - ++i : i++, this) === false) { + break; + } + } + return i; + }; + + Repeat.prototype.__iterator = function __iterator (type, reverse) { + var this$1$1 = this; + + var size = this.size; + var i = 0; + return new Iterator(function () { return i === size + ? iteratorDone() + : iteratorValue(type, reverse ? size - ++i : i++, this$1$1._value); } + ); + }; + + Repeat.prototype.equals = function equals (other) { + return other instanceof Repeat + ? is(this._value, other._value) + : deepEqual(this, other); + }; + + return Repeat; +}(IndexedSeq)); + +var EMPTY_REPEAT; + +export { Repeat }; diff --git a/dist/es/Seq.js b/dist/es/Seq.js new file mode 100644 index 0000000000..daffb3c7c1 --- /dev/null +++ b/dist/es/Seq.js @@ -0,0 +1,401 @@ +/** + * @license + * MIT License + * + * Copyright (c) 2014-present, Lee Byron and other contributors. + * + * 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: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +import { wrapIndex } from './TrieUtils.js'; +import { Collection } from './Collection.js'; +import { isSeq, IS_SEQ_SYMBOL } from './predicates/isSeq.js'; +import { isImmutable } from './predicates/isImmutable.js'; +import { isCollection } from './predicates/isCollection.js'; +import { isKeyed } from './predicates/isKeyed.js'; +import { isAssociative } from './predicates/isAssociative.js'; +import { isRecord } from './predicates/isRecord.js'; +import { IS_ORDERED_SYMBOL } from './predicates/isOrdered.js'; +import { Iterator, iteratorDone, iteratorValue, isEntriesIterable, isKeysIterable, hasIterator, getIterator, isIterator } from './Iterator.js'; +import hasOwnProperty from './utils/hasOwnProperty.js'; +import isArrayLike from './utils/isArrayLike.js'; + +var Seq = /*@__PURE__*/(function (Collection) { + function Seq(value) { + // eslint-disable-next-line no-constructor-return + return value === undefined || value === null + ? emptySequence() + : isImmutable(value) + ? value.toSeq() + : seqFromValue(value); + } + + if ( Collection ) Seq.__proto__ = Collection; + Seq.prototype = Object.create( Collection && Collection.prototype ); + Seq.prototype.constructor = Seq; + + Seq.prototype.toSeq = function toSeq () { + return this; + }; + + Seq.prototype.toString = function toString () { + return this.__toString('Seq {', '}'); + }; + + Seq.prototype.cacheResult = function cacheResult () { + if (!this._cache && this.__iterateUncached) { + this._cache = this.entrySeq().toArray(); + this.size = this._cache.length; + } + return this; + }; + + // abstract __iterateUncached(fn, reverse) + + Seq.prototype.__iterate = function __iterate (fn, reverse) { + var cache = this._cache; + if (cache) { + var size = cache.length; + var i = 0; + while (i !== size) { + var entry = cache[reverse ? size - ++i : i++]; + if (fn(entry[1], entry[0], this) === false) { + break; + } + } + return i; + } + return this.__iterateUncached(fn, reverse); + }; + + // abstract __iteratorUncached(type, reverse) + + Seq.prototype.__iterator = function __iterator (type, reverse) { + var cache = this._cache; + if (cache) { + var size = cache.length; + var i = 0; + return new Iterator(function () { + if (i === size) { + return iteratorDone(); + } + var entry = cache[reverse ? size - ++i : i++]; + return iteratorValue(type, entry[0], entry[1]); + }); + } + return this.__iteratorUncached(type, reverse); + }; + + return Seq; +}(Collection)); + +var KeyedSeq = /*@__PURE__*/(function (Seq) { + function KeyedSeq(value) { + // eslint-disable-next-line no-constructor-return + return value === undefined || value === null + ? emptySequence().toKeyedSeq() + : isCollection(value) + ? isKeyed(value) + ? value.toSeq() + : value.fromEntrySeq() + : isRecord(value) + ? value.toSeq() + : keyedSeqFromValue(value); + } + + if ( Seq ) KeyedSeq.__proto__ = Seq; + KeyedSeq.prototype = Object.create( Seq && Seq.prototype ); + KeyedSeq.prototype.constructor = KeyedSeq; + + KeyedSeq.prototype.toKeyedSeq = function toKeyedSeq () { + return this; + }; + + return KeyedSeq; +}(Seq)); + +var IndexedSeq = /*@__PURE__*/(function (Seq) { + function IndexedSeq(value) { + // eslint-disable-next-line no-constructor-return + return value === undefined || value === null + ? emptySequence() + : isCollection(value) + ? isKeyed(value) + ? value.entrySeq() + : value.toIndexedSeq() + : isRecord(value) + ? value.toSeq().entrySeq() + : indexedSeqFromValue(value); + } + + if ( Seq ) IndexedSeq.__proto__ = Seq; + IndexedSeq.prototype = Object.create( Seq && Seq.prototype ); + IndexedSeq.prototype.constructor = IndexedSeq; + + IndexedSeq.of = function of (/*...values*/) { + return IndexedSeq(arguments); + }; + + IndexedSeq.prototype.toIndexedSeq = function toIndexedSeq () { + return this; + }; + + IndexedSeq.prototype.toString = function toString () { + return this.__toString('Seq [', ']'); + }; + + return IndexedSeq; +}(Seq)); + +var SetSeq = /*@__PURE__*/(function (Seq) { + function SetSeq(value) { + // eslint-disable-next-line no-constructor-return + return ( + isCollection(value) && !isAssociative(value) ? value : IndexedSeq(value) + ).toSetSeq(); + } + + if ( Seq ) SetSeq.__proto__ = Seq; + SetSeq.prototype = Object.create( Seq && Seq.prototype ); + SetSeq.prototype.constructor = SetSeq; + + SetSeq.of = function of (/*...values*/) { + return SetSeq(arguments); + }; + + SetSeq.prototype.toSetSeq = function toSetSeq () { + return this; + }; + + return SetSeq; +}(Seq)); + +Seq.isSeq = isSeq; +Seq.Keyed = KeyedSeq; +Seq.Set = SetSeq; +Seq.Indexed = IndexedSeq; + +Seq.prototype[IS_SEQ_SYMBOL] = true; + +// #pragma Root Sequences + +var ArraySeq = /*@__PURE__*/(function (IndexedSeq) { + function ArraySeq(array) { + this._array = array; + this.size = array.length; + } + + if ( IndexedSeq ) ArraySeq.__proto__ = IndexedSeq; + ArraySeq.prototype = Object.create( IndexedSeq && IndexedSeq.prototype ); + ArraySeq.prototype.constructor = ArraySeq; + + ArraySeq.prototype.get = function get (index, notSetValue) { + return this.has(index) ? this._array[wrapIndex(this, index)] : notSetValue; + }; + + ArraySeq.prototype.__iterate = function __iterate (fn, reverse) { + var array = this._array; + var size = array.length; + var i = 0; + while (i !== size) { + var ii = reverse ? size - ++i : i++; + if (fn(array[ii], ii, this) === false) { + break; + } + } + return i; + }; + + ArraySeq.prototype.__iterator = function __iterator (type, reverse) { + var array = this._array; + var size = array.length; + var i = 0; + return new Iterator(function () { + if (i === size) { + return iteratorDone(); + } + var ii = reverse ? size - ++i : i++; + return iteratorValue(type, ii, array[ii]); + }); + }; + + return ArraySeq; +}(IndexedSeq)); + +var ObjectSeq = /*@__PURE__*/(function (KeyedSeq) { + function ObjectSeq(object) { + var keys = Object.keys(object).concat( + Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(object) : [] + ); + this._object = object; + this._keys = keys; + this.size = keys.length; + } + + if ( KeyedSeq ) ObjectSeq.__proto__ = KeyedSeq; + ObjectSeq.prototype = Object.create( KeyedSeq && KeyedSeq.prototype ); + ObjectSeq.prototype.constructor = ObjectSeq; + + ObjectSeq.prototype.get = function get (key, notSetValue) { + if (notSetValue !== undefined && !this.has(key)) { + return notSetValue; + } + return this._object[key]; + }; + + ObjectSeq.prototype.has = function has (key) { + return hasOwnProperty.call(this._object, key); + }; + + ObjectSeq.prototype.__iterate = function __iterate (fn, reverse) { + var object = this._object; + var keys = this._keys; + var size = keys.length; + var i = 0; + while (i !== size) { + var key = keys[reverse ? size - ++i : i++]; + if (fn(object[key], key, this) === false) { + break; + } + } + return i; + }; + + ObjectSeq.prototype.__iterator = function __iterator (type, reverse) { + var object = this._object; + var keys = this._keys; + var size = keys.length; + var i = 0; + return new Iterator(function () { + if (i === size) { + return iteratorDone(); + } + var key = keys[reverse ? size - ++i : i++]; + return iteratorValue(type, key, object[key]); + }); + }; + + return ObjectSeq; +}(KeyedSeq)); +ObjectSeq.prototype[IS_ORDERED_SYMBOL] = true; + +var CollectionSeq = /*@__PURE__*/(function (IndexedSeq) { + function CollectionSeq(collection) { + this._collection = collection; + this.size = collection.length || collection.size; + } + + if ( IndexedSeq ) CollectionSeq.__proto__ = IndexedSeq; + CollectionSeq.prototype = Object.create( IndexedSeq && IndexedSeq.prototype ); + CollectionSeq.prototype.constructor = CollectionSeq; + + CollectionSeq.prototype.__iterateUncached = function __iterateUncached (fn, reverse) { + if (reverse) { + return this.cacheResult().__iterate(fn, reverse); + } + var collection = this._collection; + var iterator = getIterator(collection); + var iterations = 0; + if (isIterator(iterator)) { + var step; + while (!(step = iterator.next()).done) { + if (fn(step.value, iterations++, this) === false) { + break; + } + } + } + return iterations; + }; + + CollectionSeq.prototype.__iteratorUncached = function __iteratorUncached (type, reverse) { + if (reverse) { + return this.cacheResult().__iterator(type, reverse); + } + var collection = this._collection; + var iterator = getIterator(collection); + if (!isIterator(iterator)) { + return new Iterator(iteratorDone); + } + var iterations = 0; + return new Iterator(function () { + var step = iterator.next(); + return step.done ? step : iteratorValue(type, iterations++, step.value); + }); + }; + + return CollectionSeq; +}(IndexedSeq)); + +// # pragma Helper functions + +var EMPTY_SEQ; + +function emptySequence() { + return EMPTY_SEQ || (EMPTY_SEQ = new ArraySeq([])); +} + +function keyedSeqFromValue(value) { + var seq = maybeIndexedSeqFromValue(value); + if (seq) { + return seq.fromEntrySeq(); + } + if (typeof value === 'object') { + return new ObjectSeq(value); + } + throw new TypeError( + 'Expected Array or collection object of [k, v] entries, or keyed object: ' + + value + ); +} + +function indexedSeqFromValue(value) { + var seq = maybeIndexedSeqFromValue(value); + if (seq) { + return seq; + } + throw new TypeError( + 'Expected Array or collection object of values: ' + value + ); +} + +function seqFromValue(value) { + var seq = maybeIndexedSeqFromValue(value); + if (seq) { + return isEntriesIterable(value) + ? seq.fromEntrySeq() + : isKeysIterable(value) + ? seq.toSetSeq() + : seq; + } + if (typeof value === 'object') { + return new ObjectSeq(value); + } + throw new TypeError( + 'Expected Array or collection object of values, or keyed object: ' + value + ); +} + +function maybeIndexedSeqFromValue(value) { + return isArrayLike(value) + ? new ArraySeq(value) + : hasIterator(value) + ? new CollectionSeq(value) + : undefined; +} + +export { ArraySeq, IndexedSeq, KeyedSeq, Seq, SetSeq, indexedSeqFromValue, keyedSeqFromValue }; diff --git a/dist/es/Set.js b/dist/es/Set.js new file mode 100644 index 0000000000..e61ed85d92 --- /dev/null +++ b/dist/es/Set.js @@ -0,0 +1,279 @@ +/** + * @license + * MIT License + * + * Copyright (c) 2014-present, Lee Byron and other contributors. + * + * 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: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +import { KeyedCollection, Collection, SetCollection } from './Collection.js'; +import { isOrdered } from './predicates/isOrdered.js'; +import { isSet, IS_SET_SYMBOL } from './predicates/isSet.js'; +import { emptyMap } from './Map.js'; +import { DELETE } from './TrieUtils.js'; +import { sortFactory } from './Operations.js'; +import assertNotInfinite from './utils/assertNotInfinite.js'; +import { asImmutable } from './methods/asImmutable.js'; +import { asMutable } from './methods/asMutable.js'; +import { withMutations } from './methods/withMutations.js'; +import { OrderedSet } from './OrderedSet.js'; + +var Set = /*@__PURE__*/(function (SetCollection) { + function Set(value) { + // eslint-disable-next-line no-constructor-return + return value === undefined || value === null + ? emptySet() + : isSet(value) && !isOrdered(value) + ? value + : emptySet().withMutations(function (set) { + var iter = SetCollection(value); + assertNotInfinite(iter.size); + iter.forEach(function (v) { return set.add(v); }); + }); + } + + if ( SetCollection ) Set.__proto__ = SetCollection; + Set.prototype = Object.create( SetCollection && SetCollection.prototype ); + Set.prototype.constructor = Set; + + Set.of = function of (/*...values*/) { + return this(arguments); + }; + + Set.fromKeys = function fromKeys (value) { + return this(KeyedCollection(value).keySeq()); + }; + + Set.intersect = function intersect (sets) { + sets = Collection(sets).toArray(); + return sets.length + ? SetPrototype.intersect.apply(Set(sets.pop()), sets) + : emptySet(); + }; + + Set.union = function union (sets) { + sets = Collection(sets).toArray(); + return sets.length + ? SetPrototype.union.apply(Set(sets.pop()), sets) + : emptySet(); + }; + + Set.prototype.toString = function toString () { + return this.__toString('Set {', '}'); + }; + + // @pragma Access + + Set.prototype.has = function has (value) { + return this._map.has(value); + }; + + // @pragma Modification + + Set.prototype.add = function add (value) { + return updateSet(this, this._map.set(value, value)); + }; + + Set.prototype.remove = function remove (value) { + return updateSet(this, this._map.remove(value)); + }; + + Set.prototype.clear = function clear () { + return updateSet(this, this._map.clear()); + }; + + // @pragma Composition + + Set.prototype.map = function map (mapper, context) { + var this$1$1 = this; + + // keep track if the set is altered by the map function + var didChanges = false; + + var newMap = updateSet( + this, + this._map.mapEntries(function (ref) { + var v = ref[1]; + + var mapped = mapper.call(context, v, v, this$1$1); + + if (mapped !== v) { + didChanges = true; + } + + return [mapped, mapped]; + }, context) + ); + + return didChanges ? newMap : this; + }; + + Set.prototype.union = function union () { + var iters = [], len = arguments.length; + while ( len-- ) iters[ len ] = arguments[ len ]; + + iters = iters.filter(function (x) { return x.size !== 0; }); + if (iters.length === 0) { + return this; + } + if (this.size === 0 && !this.__ownerID && iters.length === 1) { + return this.constructor(iters[0]); + } + return this.withMutations(function (set) { + for (var ii = 0; ii < iters.length; ii++) { + if (typeof iters[ii] === 'string') { + set.add(iters[ii]); + } else { + SetCollection(iters[ii]).forEach(function (value) { return set.add(value); }); + } + } + }); + }; + + Set.prototype.intersect = function intersect () { + var iters = [], len = arguments.length; + while ( len-- ) iters[ len ] = arguments[ len ]; + + if (iters.length === 0) { + return this; + } + iters = iters.map(function (iter) { return SetCollection(iter); }); + var toRemove = []; + this.forEach(function (value) { + if (!iters.every(function (iter) { return iter.includes(value); })) { + toRemove.push(value); + } + }); + return this.withMutations(function (set) { + toRemove.forEach(function (value) { + set.remove(value); + }); + }); + }; + + Set.prototype.subtract = function subtract () { + var iters = [], len = arguments.length; + while ( len-- ) iters[ len ] = arguments[ len ]; + + if (iters.length === 0) { + return this; + } + iters = iters.map(function (iter) { return SetCollection(iter); }); + var toRemove = []; + this.forEach(function (value) { + if (iters.some(function (iter) { return iter.includes(value); })) { + toRemove.push(value); + } + }); + return this.withMutations(function (set) { + toRemove.forEach(function (value) { + set.remove(value); + }); + }); + }; + + Set.prototype.sort = function sort (comparator) { + // Late binding + return OrderedSet(sortFactory(this, comparator)); + }; + + Set.prototype.sortBy = function sortBy (mapper, comparator) { + // Late binding + return OrderedSet(sortFactory(this, comparator, mapper)); + }; + + Set.prototype.wasAltered = function wasAltered () { + return this._map.wasAltered(); + }; + + Set.prototype.__iterate = function __iterate (fn, reverse) { + var this$1$1 = this; + + return this._map.__iterate(function (k) { return fn(k, k, this$1$1); }, reverse); + }; + + Set.prototype.__iterator = function __iterator (type, reverse) { + return this._map.__iterator(type, reverse); + }; + + Set.prototype.__ensureOwner = function __ensureOwner (ownerID) { + if (ownerID === this.__ownerID) { + return this; + } + var newMap = this._map.__ensureOwner(ownerID); + if (!ownerID) { + if (this.size === 0) { + return this.__empty(); + } + this.__ownerID = ownerID; + this._map = newMap; + return this; + } + return this.__make(newMap, ownerID); + }; + + return Set; +}(SetCollection)); + +Set.isSet = isSet; + +var SetPrototype = Set.prototype; +SetPrototype[IS_SET_SYMBOL] = true; +SetPrototype[DELETE] = SetPrototype.remove; +SetPrototype.merge = SetPrototype.concat = SetPrototype.union; +SetPrototype.withMutations = withMutations; +SetPrototype.asImmutable = asImmutable; +SetPrototype['@@transducer/init'] = SetPrototype.asMutable = asMutable; +SetPrototype['@@transducer/step'] = function (result, arr) { + return result.add(arr); +}; +SetPrototype['@@transducer/result'] = function (obj) { + return obj.asImmutable(); +}; + +SetPrototype.__empty = emptySet; +SetPrototype.__make = makeSet; + +function updateSet(set, newMap) { + if (set.__ownerID) { + set.size = newMap.size; + set._map = newMap; + return set; + } + return newMap === set._map + ? set + : newMap.size === 0 + ? set.__empty() + : set.__make(newMap); +} + +function makeSet(map, ownerID) { + var set = Object.create(SetPrototype); + set.size = map ? map.size : 0; + set._map = map; + set.__ownerID = ownerID; + return set; +} + +var EMPTY_SET; +function emptySet() { + return EMPTY_SET || (EMPTY_SET = makeSet(emptyMap())); +} + +export { Set }; diff --git a/dist/es/Stack.js b/dist/es/Stack.js new file mode 100644 index 0000000000..0a39641d73 --- /dev/null +++ b/dist/es/Stack.js @@ -0,0 +1,261 @@ +/** + * @license + * MIT License + * + * Copyright (c) 2014-present, Lee Byron and other contributors. + * + * 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: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +import { wrapIndex, wholeSlice, resolveBegin, resolveEnd } from './TrieUtils.js'; +import { IndexedCollection } from './Collection.js'; +import { ArraySeq } from './Seq.js'; +import { Iterator, iteratorValue, iteratorDone } from './Iterator.js'; +import { isStack, IS_STACK_SYMBOL } from './predicates/isStack.js'; +import assertNotInfinite from './utils/assertNotInfinite.js'; +import { asImmutable } from './methods/asImmutable.js'; +import { asMutable } from './methods/asMutable.js'; +import { wasAltered } from './methods/wasAltered.js'; +import { withMutations } from './methods/withMutations.js'; + +var Stack = /*@__PURE__*/(function (IndexedCollection) { + function Stack(value) { + // eslint-disable-next-line no-constructor-return + return value === undefined || value === null + ? emptyStack() + : isStack(value) + ? value + : emptyStack().pushAll(value); + } + + if ( IndexedCollection ) Stack.__proto__ = IndexedCollection; + Stack.prototype = Object.create( IndexedCollection && IndexedCollection.prototype ); + Stack.prototype.constructor = Stack; + + Stack.of = function of (/*...values*/) { + return this(arguments); + }; + + Stack.prototype.toString = function toString () { + return this.__toString('Stack [', ']'); + }; + + // @pragma Access + + Stack.prototype.get = function get (index, notSetValue) { + var head = this._head; + index = wrapIndex(this, index); + while (head && index--) { + head = head.next; + } + return head ? head.value : notSetValue; + }; + + Stack.prototype.peek = function peek () { + return this._head && this._head.value; + }; + + // @pragma Modification + + Stack.prototype.push = function push (/*...values*/) { + var arguments$1 = arguments; + + if (arguments.length === 0) { + return this; + } + var newSize = this.size + arguments.length; + var head = this._head; + for (var ii = arguments.length - 1; ii >= 0; ii--) { + head = { + value: arguments$1[ii], + next: head, + }; + } + if (this.__ownerID) { + this.size = newSize; + this._head = head; + this.__hash = undefined; + this.__altered = true; + return this; + } + return makeStack(newSize, head); + }; + + Stack.prototype.pushAll = function pushAll (iter) { + iter = IndexedCollection(iter); + if (iter.size === 0) { + return this; + } + if (this.size === 0 && isStack(iter)) { + return iter; + } + assertNotInfinite(iter.size); + var newSize = this.size; + var head = this._head; + iter.__iterate(function (value) { + newSize++; + head = { + value: value, + next: head, + }; + }, /* reverse */ true); + if (this.__ownerID) { + this.size = newSize; + this._head = head; + this.__hash = undefined; + this.__altered = true; + return this; + } + return makeStack(newSize, head); + }; + + Stack.prototype.pop = function pop () { + return this.slice(1); + }; + + Stack.prototype.clear = function clear () { + if (this.size === 0) { + return this; + } + if (this.__ownerID) { + this.size = 0; + this._head = undefined; + this.__hash = undefined; + this.__altered = true; + return this; + } + return emptyStack(); + }; + + Stack.prototype.slice = function slice (begin, end) { + if (wholeSlice(begin, end, this.size)) { + return this; + } + var resolvedBegin = resolveBegin(begin, this.size); + var resolvedEnd = resolveEnd(end, this.size); + if (resolvedEnd !== this.size) { + // super.slice(begin, end); + return IndexedCollection.prototype.slice.call(this, begin, end); + } + var newSize = this.size - resolvedBegin; + var head = this._head; + while (resolvedBegin--) { + head = head.next; + } + if (this.__ownerID) { + this.size = newSize; + this._head = head; + this.__hash = undefined; + this.__altered = true; + return this; + } + return makeStack(newSize, head); + }; + + // @pragma Mutability + + Stack.prototype.__ensureOwner = function __ensureOwner (ownerID) { + if (ownerID === this.__ownerID) { + return this; + } + if (!ownerID) { + if (this.size === 0) { + return emptyStack(); + } + this.__ownerID = ownerID; + this.__altered = false; + return this; + } + return makeStack(this.size, this._head, ownerID, this.__hash); + }; + + // @pragma Iteration + + Stack.prototype.__iterate = function __iterate (fn, reverse) { + var this$1$1 = this; + + if (reverse) { + return new ArraySeq(this.toArray()).__iterate( + function (v, k) { return fn(v, k, this$1$1); }, + reverse + ); + } + var iterations = 0; + var node = this._head; + while (node) { + if (fn(node.value, iterations++, this) === false) { + break; + } + node = node.next; + } + return iterations; + }; + + Stack.prototype.__iterator = function __iterator (type, reverse) { + if (reverse) { + return new ArraySeq(this.toArray()).__iterator(type, reverse); + } + var iterations = 0; + var node = this._head; + return new Iterator(function () { + if (node) { + var value = node.value; + node = node.next; + return iteratorValue(type, iterations++, value); + } + return iteratorDone(); + }); + }; + + return Stack; +}(IndexedCollection)); + +Stack.isStack = isStack; + +var StackPrototype = Stack.prototype; +StackPrototype[IS_STACK_SYMBOL] = true; +StackPrototype.shift = StackPrototype.pop; +StackPrototype.unshift = StackPrototype.push; +StackPrototype.unshiftAll = StackPrototype.pushAll; +StackPrototype.withMutations = withMutations; +StackPrototype.wasAltered = wasAltered; +StackPrototype.asImmutable = asImmutable; +StackPrototype['@@transducer/init'] = StackPrototype.asMutable = asMutable; +StackPrototype['@@transducer/step'] = function (result, arr) { + return result.unshift(arr); +}; +StackPrototype['@@transducer/result'] = function (obj) { + return obj.asImmutable(); +}; + +function makeStack(size, head, ownerID, hash) { + var map = Object.create(StackPrototype); + map.size = size; + map._head = head; + map.__ownerID = ownerID; + map.__hash = hash; + map.__altered = false; + return map; +} + +var EMPTY_STACK; +function emptyStack() { + return EMPTY_STACK || (EMPTY_STACK = makeStack(0)); +} + +export { Stack }; diff --git a/dist/es/TrieUtils.js b/dist/es/TrieUtils.js new file mode 100644 index 0000000000..e22c3accff --- /dev/null +++ b/dist/es/TrieUtils.js @@ -0,0 +1,117 @@ +/** + * @license + * MIT License + * + * Copyright (c) 2014-present, Lee Byron and other contributors. + * + * 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: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// Used for setting prototype methods that IE8 chokes on. +var DELETE = 'delete'; + +// Constants describing the size of trie nodes. +var SHIFT = 5; // Resulted in best performance after ______? +var SIZE = 1 << SHIFT; +var MASK = SIZE - 1; + +// A consistent shared value representing "not set" which equals nothing other +// than itself, and nothing that could be provided externally. +var NOT_SET = {}; + +// Boolean references, Rough equivalent of `bool &`. +function MakeRef() { + return { value: false }; +} + +function SetRef(ref) { + if (ref) { + ref.value = true; + } +} + +// A function which returns a value representing an "owner" for transient writes +// to tries. The return value will only ever equal itself, and will not equal +// the return of any subsequent call of this function. +function OwnerID() {} + +function ensureSize(iter) { + if (iter.size === undefined) { + iter.size = iter.__iterate(returnTrue); + } + return iter.size; +} + +function wrapIndex(iter, index) { + // This implements "is array index" which the ECMAString spec defines as: + // + // A String property name P is an array index if and only if + // ToString(ToUint32(P)) is equal to P and ToUint32(P) is not equal + // to 2^32−1. + // + // http://www.ecma-international.org/ecma-262/6.0/#sec-array-exotic-objects + if (typeof index !== 'number') { + var uint32Index = index >>> 0; // N >>> 0 is shorthand for ToUint32 + if ('' + uint32Index !== index || uint32Index === 4294967295) { + return NaN; + } + index = uint32Index; + } + return index < 0 ? ensureSize(iter) + index : index; +} + +function returnTrue() { + return true; +} + +function wholeSlice(begin, end, size) { + return ( + ((begin === 0 && !isNeg(begin)) || + (size !== undefined && begin <= -size)) && + (end === undefined || (size !== undefined && end >= size)) + ); +} + +function resolveBegin(begin, size) { + return resolveIndex(begin, size, 0); +} + +function resolveEnd(end, size) { + return resolveIndex(end, size, size); +} + +function resolveIndex(index, size, defaultIndex) { + // Sanitize indices using this shorthand for ToInt32(argument) + // http://www.ecma-international.org/ecma-262/6.0/#sec-toint32 + return index === undefined + ? defaultIndex + : isNeg(index) + ? size === Infinity + ? size + : Math.max(0, size + index) | 0 + : size === undefined || size === index + ? index + : Math.min(size, index) | 0; +} + +function isNeg(value) { + // Account for -0 which is negative, but not less than 0. + return value < 0 || (value === 0 && 1 / value === -Infinity); +} + +export { DELETE, MASK, MakeRef, NOT_SET, OwnerID, SHIFT, SIZE, SetRef, ensureSize, resolveBegin, resolveEnd, returnTrue, wholeSlice, wrapIndex }; diff --git a/dist/es/fromJS.js b/dist/es/fromJS.js new file mode 100644 index 0000000000..c6860d3af1 --- /dev/null +++ b/dist/es/fromJS.js @@ -0,0 +1,74 @@ +/** + * @license + * MIT License + * + * Copyright (c) 2014-present, Lee Byron and other contributors. + * + * 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: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +import { Seq } from './Seq.js'; +import { hasIterator } from './Iterator.js'; +import { isImmutable } from './predicates/isImmutable.js'; +import { isIndexed } from './predicates/isIndexed.js'; +import { isKeyed } from './predicates/isKeyed.js'; +import isArrayLike from './utils/isArrayLike.js'; +import isPlainObject from './utils/isPlainObj.js'; + +function fromJS(value, converter) { + return fromJSWith( + [], + converter || defaultConverter, + value, + '', + converter && converter.length > 2 ? [] : undefined, + { '': value } + ); +} + +function fromJSWith(stack, converter, value, key, keyPath, parentValue) { + if ( + typeof value !== 'string' && + !isImmutable(value) && + (isArrayLike(value) || hasIterator(value) || isPlainObject(value)) + ) { + if (~stack.indexOf(value)) { + throw new TypeError('Cannot convert circular structure to Immutable'); + } + stack.push(value); + keyPath && key !== '' && keyPath.push(key); + var converted = converter.call( + parentValue, + key, + Seq(value).map(function (v, k) { return fromJSWith(stack, converter, v, k, keyPath, value); } + ), + keyPath && keyPath.slice() + ); + stack.pop(); + keyPath && keyPath.pop(); + return converted; + } + return value; +} + +function defaultConverter(k, v) { + // Effectively the opposite of "Collection.toSeq()" + return isIndexed(v) ? v.toList() : isKeyed(v) ? v.toMap() : v.toSet(); +} + +export { fromJS }; diff --git a/dist/es/functional/get.js b/dist/es/functional/get.js new file mode 100644 index 0000000000..aaf3cbdf01 --- /dev/null +++ b/dist/es/functional/get.js @@ -0,0 +1,38 @@ +/** + * @license + * MIT License + * + * Copyright (c) 2014-present, Lee Byron and other contributors. + * + * 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: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +import { isImmutable } from '../predicates/isImmutable.js'; +import { has } from './has.js'; + +function get(collection, key, notSetValue) { + return isImmutable(collection) + ? collection.get(key, notSetValue) + : !has(collection, key) + ? notSetValue + : typeof collection.get === 'function' + ? collection.get(key) + : collection[key]; +} + +export { get }; diff --git a/dist/es/functional/getIn.js b/dist/es/functional/getIn.js new file mode 100644 index 0000000000..4b1dc9dd31 --- /dev/null +++ b/dist/es/functional/getIn.js @@ -0,0 +1,41 @@ +/** + * @license + * MIT License + * + * Copyright (c) 2014-present, Lee Byron and other contributors. + * + * 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: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +import coerceKeyPath from '../utils/coerceKeyPath.js'; +import { NOT_SET } from '../TrieUtils.js'; +import { get } from './get.js'; + +function getIn(collection, searchKeyPath, notSetValue) { + var keyPath = coerceKeyPath(searchKeyPath); + var i = 0; + while (i !== keyPath.length) { + collection = get(collection, keyPath[i++], NOT_SET); + if (collection === NOT_SET) { + return notSetValue; + } + } + return collection; +} + +export { getIn }; diff --git a/dist/es/functional/has.js b/dist/es/functional/has.js new file mode 100644 index 0000000000..7a1a7f2e0a --- /dev/null +++ b/dist/es/functional/has.js @@ -0,0 +1,35 @@ +/** + * @license + * MIT License + * + * Copyright (c) 2014-present, Lee Byron and other contributors. + * + * 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: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +import { isImmutable } from '../predicates/isImmutable.js'; +import hasOwnProperty from '../utils/hasOwnProperty.js'; +import isDataStructure from '../utils/isDataStructure.js'; + +function has(collection, key) { + return isImmutable(collection) + ? collection.has(key) + : isDataStructure(collection) && hasOwnProperty.call(collection, key); +} + +export { has }; diff --git a/dist/es/functional/hasIn.js b/dist/es/functional/hasIn.js new file mode 100644 index 0000000000..011501129d --- /dev/null +++ b/dist/es/functional/hasIn.js @@ -0,0 +1,32 @@ +/** + * @license + * MIT License + * + * Copyright (c) 2014-present, Lee Byron and other contributors. + * + * 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: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +import { getIn } from './getIn.js'; +import { NOT_SET } from '../TrieUtils.js'; + +function hasIn(collection, keyPath) { + return getIn(collection, keyPath, NOT_SET) !== NOT_SET; +} + +export { hasIn }; diff --git a/dist/es/functional/merge.js b/dist/es/functional/merge.js new file mode 100644 index 0000000000..947ea2619c --- /dev/null +++ b/dist/es/functional/merge.js @@ -0,0 +1,137 @@ +/** + * @license + * MIT License + * + * Copyright (c) 2014-present, Lee Byron and other contributors. + * + * 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: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +import { isImmutable } from '../predicates/isImmutable.js'; +import { isIndexed } from '../predicates/isIndexed.js'; +import { isKeyed } from '../predicates/isKeyed.js'; +import { IndexedCollection, KeyedCollection } from '../Collection.js'; +import { Seq } from '../Seq.js'; +import hasOwnProperty from '../utils/hasOwnProperty.js'; +import isDataStructure from '../utils/isDataStructure.js'; +import shallowCopy from '../utils/shallowCopy.js'; + +function merge(collection) { + var sources = [], len = arguments.length - 1; + while ( len-- > 0 ) sources[ len ] = arguments[ len + 1 ]; + + return mergeWithSources(collection, sources); +} + +function mergeWith(merger, collection) { + var sources = [], len = arguments.length - 2; + while ( len-- > 0 ) sources[ len ] = arguments[ len + 2 ]; + + return mergeWithSources(collection, sources, merger); +} + +function mergeDeep(collection) { + var sources = [], len = arguments.length - 1; + while ( len-- > 0 ) sources[ len ] = arguments[ len + 1 ]; + + return mergeDeepWithSources(collection, sources); +} + +function mergeDeepWith(merger, collection) { + var sources = [], len = arguments.length - 2; + while ( len-- > 0 ) sources[ len ] = arguments[ len + 2 ]; + + return mergeDeepWithSources(collection, sources, merger); +} + +function mergeDeepWithSources(collection, sources, merger) { + return mergeWithSources(collection, sources, deepMergerWith(merger)); +} + +function mergeWithSources(collection, sources, merger) { + if (!isDataStructure(collection)) { + throw new TypeError( + 'Cannot merge into non-data-structure value: ' + collection + ); + } + if (isImmutable(collection)) { + return typeof merger === 'function' && collection.mergeWith + ? collection.mergeWith.apply(collection, [ merger ].concat( sources )) + : collection.merge + ? collection.merge.apply(collection, sources) + : collection.concat.apply(collection, sources); + } + var isArray = Array.isArray(collection); + var merged = collection; + var Collection = isArray ? IndexedCollection : KeyedCollection; + var mergeItem = isArray + ? function (value) { + // Copy on write + if (merged === collection) { + merged = shallowCopy(merged); + } + merged.push(value); + } + : function (value, key) { + var hasVal = hasOwnProperty.call(merged, key); + var nextVal = + hasVal && merger ? merger(merged[key], value, key) : value; + if (!hasVal || nextVal !== merged[key]) { + // Copy on write + if (merged === collection) { + merged = shallowCopy(merged); + } + merged[key] = nextVal; + } + }; + for (var i = 0; i < sources.length; i++) { + Collection(sources[i]).forEach(mergeItem); + } + return merged; +} + +function deepMergerWith(merger) { + function deepMerger(oldValue, newValue, key) { + return isDataStructure(oldValue) && + isDataStructure(newValue) && + areMergeable(oldValue, newValue) + ? mergeWithSources(oldValue, [newValue], deepMerger) + : merger + ? merger(oldValue, newValue, key) + : newValue; + } + return deepMerger; +} + +/** + * It's unclear what the desired behavior is for merging two collections that + * fall into separate categories between keyed, indexed, or set-like, so we only + * consider them mergeable if they fall into the same category. + */ +function areMergeable(oldDataStructure, newDataStructure) { + var oldSeq = Seq(oldDataStructure); + var newSeq = Seq(newDataStructure); + // This logic assumes that a sequence can only fall into one of the three + // categories mentioned above (since there's no `isSetLike()` method). + return ( + isIndexed(oldSeq) === isIndexed(newSeq) && + isKeyed(oldSeq) === isKeyed(newSeq) + ); +} + +export { merge, mergeDeep, mergeDeepWith, mergeDeepWithSources, mergeWith, mergeWithSources }; diff --git a/dist/es/functional/remove.js b/dist/es/functional/remove.js new file mode 100644 index 0000000000..29bd9aba86 --- /dev/null +++ b/dist/es/functional/remove.js @@ -0,0 +1,56 @@ +/** + * @license + * MIT License + * + * Copyright (c) 2014-present, Lee Byron and other contributors. + * + * 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: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +import { isImmutable } from '../predicates/isImmutable.js'; +import hasOwnProperty from '../utils/hasOwnProperty.js'; +import isDataStructure from '../utils/isDataStructure.js'; +import shallowCopy from '../utils/shallowCopy.js'; + +function remove(collection, key) { + if (!isDataStructure(collection)) { + throw new TypeError( + 'Cannot update non-data-structure value: ' + collection + ); + } + if (isImmutable(collection)) { + if (!collection.remove) { + throw new TypeError( + 'Cannot update immutable value without .remove() method: ' + collection + ); + } + return collection.remove(key); + } + if (!hasOwnProperty.call(collection, key)) { + return collection; + } + var collectionCopy = shallowCopy(collection); + if (Array.isArray(collectionCopy)) { + collectionCopy.splice(key, 1); + } else { + delete collectionCopy[key]; + } + return collectionCopy; +} + +export { remove }; diff --git a/dist/es/functional/removeIn.js b/dist/es/functional/removeIn.js new file mode 100644 index 0000000000..4ef2a02205 --- /dev/null +++ b/dist/es/functional/removeIn.js @@ -0,0 +1,32 @@ +/** + * @license + * MIT License + * + * Copyright (c) 2014-present, Lee Byron and other contributors. + * + * 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: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +import { updateIn } from './updateIn.js'; +import { NOT_SET } from '../TrieUtils.js'; + +function removeIn(collection, keyPath) { + return updateIn(collection, keyPath, function () { return NOT_SET; }); +} + +export { removeIn }; diff --git a/dist/es/functional/set.js b/dist/es/functional/set.js new file mode 100644 index 0000000000..d571aac11e --- /dev/null +++ b/dist/es/functional/set.js @@ -0,0 +1,52 @@ +/** + * @license + * MIT License + * + * Copyright (c) 2014-present, Lee Byron and other contributors. + * + * 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: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +import { isImmutable } from '../predicates/isImmutable.js'; +import hasOwnProperty from '../utils/hasOwnProperty.js'; +import isDataStructure from '../utils/isDataStructure.js'; +import shallowCopy from '../utils/shallowCopy.js'; + +function set(collection, key, value) { + if (!isDataStructure(collection)) { + throw new TypeError( + 'Cannot update non-data-structure value: ' + collection + ); + } + if (isImmutable(collection)) { + if (!collection.set) { + throw new TypeError( + 'Cannot update immutable value without .set() method: ' + collection + ); + } + return collection.set(key, value); + } + if (hasOwnProperty.call(collection, key) && value === collection[key]) { + return collection; + } + var collectionCopy = shallowCopy(collection); + collectionCopy[key] = value; + return collectionCopy; +} + +export { set }; diff --git a/dist/es/functional/setIn.js b/dist/es/functional/setIn.js new file mode 100644 index 0000000000..1c5bfbfcb2 --- /dev/null +++ b/dist/es/functional/setIn.js @@ -0,0 +1,32 @@ +/** + * @license + * MIT License + * + * Copyright (c) 2014-present, Lee Byron and other contributors. + * + * 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: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +import { updateIn } from './updateIn.js'; +import { NOT_SET } from '../TrieUtils.js'; + +function setIn(collection, keyPath, value) { + return updateIn(collection, keyPath, NOT_SET, function () { return value; }); +} + +export { setIn }; diff --git a/dist/es/functional/update.js b/dist/es/functional/update.js new file mode 100644 index 0000000000..e24f89c554 --- /dev/null +++ b/dist/es/functional/update.js @@ -0,0 +1,31 @@ +/** + * @license + * MIT License + * + * Copyright (c) 2014-present, Lee Byron and other contributors. + * + * 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: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +import { updateIn } from './updateIn.js'; + +function update(collection, key, notSetValue, updater) { + return updateIn(collection, [key], notSetValue, updater); +} + +export { update }; diff --git a/dist/es/functional/updateIn.js b/dist/es/functional/updateIn.js new file mode 100644 index 0000000000..8b66e52273 --- /dev/null +++ b/dist/es/functional/updateIn.js @@ -0,0 +1,94 @@ +/** + * @license + * MIT License + * + * Copyright (c) 2014-present, Lee Byron and other contributors. + * + * 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: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +import { isImmutable } from '../predicates/isImmutable.js'; +import coerceKeyPath from '../utils/coerceKeyPath.js'; +import isDataStructure from '../utils/isDataStructure.js'; +import quoteString from '../utils/quoteString.js'; +import { NOT_SET } from '../TrieUtils.js'; +import { emptyMap } from '../Map.js'; +import { get } from './get.js'; +import { remove } from './remove.js'; +import { set } from './set.js'; + +function updateIn(collection, keyPath, notSetValue, updater) { + if (!updater) { + updater = notSetValue; + notSetValue = undefined; + } + var updatedValue = updateInDeeply( + isImmutable(collection), + collection, + coerceKeyPath(keyPath), + 0, + notSetValue, + updater + ); + return updatedValue === NOT_SET ? notSetValue : updatedValue; +} + +function updateInDeeply( + inImmutable, + existing, + keyPath, + i, + notSetValue, + updater +) { + var wasNotSet = existing === NOT_SET; + if (i === keyPath.length) { + var existingValue = wasNotSet ? notSetValue : existing; + var newValue = updater(existingValue); + return newValue === existingValue ? existing : newValue; + } + if (!wasNotSet && !isDataStructure(existing)) { + throw new TypeError( + 'Cannot update within non-data-structure value in path [' + + keyPath.slice(0, i).map(quoteString) + + ']: ' + + existing + ); + } + var key = keyPath[i]; + var nextExisting = wasNotSet ? NOT_SET : get(existing, key, NOT_SET); + var nextUpdated = updateInDeeply( + nextExisting === NOT_SET ? inImmutable : isImmutable(nextExisting), + nextExisting, + keyPath, + i + 1, + notSetValue, + updater + ); + return nextUpdated === nextExisting + ? existing + : nextUpdated === NOT_SET + ? remove(existing, key) + : set( + wasNotSet ? (inImmutable ? emptyMap() : {}) : existing, + key, + nextUpdated + ); +} + +export { updateIn }; diff --git a/dist/es/is.js b/dist/es/is.js new file mode 100644 index 0000000000..95dcac8c19 --- /dev/null +++ b/dist/es/is.js @@ -0,0 +1,108 @@ +/** + * @license + * MIT License + * + * Copyright (c) 2014-present, Lee Byron and other contributors. + * + * 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: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +import { isValueObject } from './predicates/isValueObject.js'; + +/** + * An extension of the "same-value" algorithm as [described for use by ES6 Map + * and Set](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map#Key_equality) + * + * NaN is considered the same as NaN, however -0 and 0 are considered the same + * value, which is different from the algorithm described by + * [`Object.is`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is). + * + * This is extended further to allow Objects to describe the values they + * represent, by way of `valueOf` or `equals` (and `hashCode`). + * + * Note: because of this extension, the key equality of Immutable.Map and the + * value equality of Immutable.Set will differ from ES6 Map and Set. + * + * ### Defining custom values + * + * The easiest way to describe the value an object represents is by implementing + * `valueOf`. For example, `Date` represents a value by returning a unix + * timestamp for `valueOf`: + * + * var date1 = new Date(1234567890000); // Fri Feb 13 2009 ... + * var date2 = new Date(1234567890000); + * date1.valueOf(); // 1234567890000 + * assert( date1 !== date2 ); + * assert( Immutable.is( date1, date2 ) ); + * + * Note: overriding `valueOf` may have other implications if you use this object + * where JavaScript expects a primitive, such as implicit string coercion. + * + * For more complex types, especially collections, implementing `valueOf` may + * not be performant. An alternative is to implement `equals` and `hashCode`. + * + * `equals` takes another object, presumably of similar type, and returns true + * if it is equal. Equality is symmetrical, so the same result should be + * returned if this and the argument are flipped. + * + * assert( a.equals(b) === b.equals(a) ); + * + * `hashCode` returns a 32bit integer number representing the object which will + * be used to determine how to store the value object in a Map or Set. You must + * provide both or neither methods, one must not exist without the other. + * + * Also, an important relationship between these methods must be upheld: if two + * values are equal, they *must* return the same hashCode. If the values are not + * equal, they might have the same hashCode; this is called a hash collision, + * and while undesirable for performance reasons, it is acceptable. + * + * if (a.equals(b)) { + * assert( a.hashCode() === b.hashCode() ); + * } + * + * All Immutable collections are Value Objects: they implement `equals()` + * and `hashCode()`. + */ +function is(valueA, valueB) { + if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) { + return true; + } + if (!valueA || !valueB) { + return false; + } + if ( + typeof valueA.valueOf === 'function' && + typeof valueB.valueOf === 'function' + ) { + valueA = valueA.valueOf(); + valueB = valueB.valueOf(); + if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) { + return true; + } + if (!valueA || !valueB) { + return false; + } + } + return !!( + isValueObject(valueA) && + isValueObject(valueB) && + valueA.equals(valueB) + ); +} + +export { is }; diff --git a/dist/es/methods/asImmutable.js b/dist/es/methods/asImmutable.js new file mode 100644 index 0000000000..a634b40ac8 --- /dev/null +++ b/dist/es/methods/asImmutable.js @@ -0,0 +1,29 @@ +/** + * @license + * MIT License + * + * Copyright (c) 2014-present, Lee Byron and other contributors. + * + * 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: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +function asImmutable() { + return this.__ensureOwner(); +} + +export { asImmutable }; diff --git a/dist/es/methods/asMutable.js b/dist/es/methods/asMutable.js new file mode 100644 index 0000000000..1d2fbb1e59 --- /dev/null +++ b/dist/es/methods/asMutable.js @@ -0,0 +1,31 @@ +/** + * @license + * MIT License + * + * Copyright (c) 2014-present, Lee Byron and other contributors. + * + * 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: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +import { OwnerID } from '../TrieUtils.js'; + +function asMutable() { + return this.__ownerID ? this : this.__ensureOwner(new OwnerID()); +} + +export { asMutable }; diff --git a/dist/es/methods/deleteIn.js b/dist/es/methods/deleteIn.js new file mode 100644 index 0000000000..6b289d201d --- /dev/null +++ b/dist/es/methods/deleteIn.js @@ -0,0 +1,31 @@ +/** + * @license + * MIT License + * + * Copyright (c) 2014-present, Lee Byron and other contributors. + * + * 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: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +import { removeIn } from '../functional/removeIn.js'; + +function deleteIn(keyPath) { + return removeIn(this, keyPath); +} + +export { deleteIn }; diff --git a/dist/es/methods/getIn.js b/dist/es/methods/getIn.js new file mode 100644 index 0000000000..c3c46a199f --- /dev/null +++ b/dist/es/methods/getIn.js @@ -0,0 +1,31 @@ +/** + * @license + * MIT License + * + * Copyright (c) 2014-present, Lee Byron and other contributors. + * + * 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: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +import { getIn as getIn$1 } from '../functional/getIn.js'; + +function getIn(searchKeyPath, notSetValue) { + return getIn$1(this, searchKeyPath, notSetValue); +} + +export { getIn }; diff --git a/dist/es/methods/hasIn.js b/dist/es/methods/hasIn.js new file mode 100644 index 0000000000..31d523ccb1 --- /dev/null +++ b/dist/es/methods/hasIn.js @@ -0,0 +1,31 @@ +/** + * @license + * MIT License + * + * Copyright (c) 2014-present, Lee Byron and other contributors. + * + * 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: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +import { hasIn as hasIn$1 } from '../functional/hasIn.js'; + +function hasIn(searchKeyPath) { + return hasIn$1(this, searchKeyPath); +} + +export { hasIn }; diff --git a/dist/es/methods/merge.js b/dist/es/methods/merge.js new file mode 100644 index 0000000000..05d3708244 --- /dev/null +++ b/dist/es/methods/merge.js @@ -0,0 +1,79 @@ +/** + * @license + * MIT License + * + * Copyright (c) 2014-present, Lee Byron and other contributors. + * + * 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: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +import { KeyedCollection } from '../Collection.js'; +import { NOT_SET } from '../TrieUtils.js'; +import { update } from '../functional/update.js'; + +function merge() { + var iters = [], len = arguments.length; + while ( len-- ) iters[ len ] = arguments[ len ]; + + return mergeIntoKeyedWith(this, iters); +} + +function mergeWith(merger) { + var iters = [], len = arguments.length - 1; + while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; + + if (typeof merger !== 'function') { + throw new TypeError('Invalid merger function: ' + merger); + } + return mergeIntoKeyedWith(this, iters, merger); +} + +function mergeIntoKeyedWith(collection, collections, merger) { + var iters = []; + for (var ii = 0; ii < collections.length; ii++) { + var collection$1 = KeyedCollection(collections[ii]); + if (collection$1.size !== 0) { + iters.push(collection$1); + } + } + if (iters.length === 0) { + return collection; + } + if ( + collection.toSeq().size === 0 && + !collection.__ownerID && + iters.length === 1 + ) { + return collection.constructor(iters[0]); + } + return collection.withMutations(function (collection) { + var mergeIntoCollection = merger + ? function (value, key) { + update(collection, key, NOT_SET, function (oldVal) { return oldVal === NOT_SET ? value : merger(oldVal, value, key); } + ); + } + : function (value, key) { + collection.set(key, value); + }; + for (var ii = 0; ii < iters.length; ii++) { + iters[ii].forEach(mergeIntoCollection); + } + }); +} + +export { merge, mergeWith }; diff --git a/dist/es/methods/mergeDeep.js b/dist/es/methods/mergeDeep.js new file mode 100644 index 0000000000..22b25d1ca1 --- /dev/null +++ b/dist/es/methods/mergeDeep.js @@ -0,0 +1,41 @@ +/** + * @license + * MIT License + * + * Copyright (c) 2014-present, Lee Byron and other contributors. + * + * 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: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +import { mergeDeepWithSources } from '../functional/merge.js'; + +function mergeDeep() { + var iters = [], len = arguments.length; + while ( len-- ) iters[ len ] = arguments[ len ]; + + return mergeDeepWithSources(this, iters); +} + +function mergeDeepWith(merger) { + var iters = [], len = arguments.length - 1; + while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; + + return mergeDeepWithSources(this, iters, merger); +} + +export { mergeDeep, mergeDeepWith }; diff --git a/dist/es/methods/mergeDeepIn.js b/dist/es/methods/mergeDeepIn.js new file mode 100644 index 0000000000..3c487586b7 --- /dev/null +++ b/dist/es/methods/mergeDeepIn.js @@ -0,0 +1,37 @@ +/** + * @license + * MIT License + * + * Copyright (c) 2014-present, Lee Byron and other contributors. + * + * 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: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +import { mergeDeepWithSources } from '../functional/merge.js'; +import { updateIn } from '../functional/updateIn.js'; +import { emptyMap } from '../Map.js'; + +function mergeDeepIn(keyPath) { + var iters = [], len = arguments.length - 1; + while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; + + return updateIn(this, keyPath, emptyMap(), function (m) { return mergeDeepWithSources(m, iters); } + ); +} + +export { mergeDeepIn }; diff --git a/dist/es/methods/mergeIn.js b/dist/es/methods/mergeIn.js new file mode 100644 index 0000000000..9c2e51ece0 --- /dev/null +++ b/dist/es/methods/mergeIn.js @@ -0,0 +1,36 @@ +/** + * @license + * MIT License + * + * Copyright (c) 2014-present, Lee Byron and other contributors. + * + * 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: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +import { mergeWithSources } from '../functional/merge.js'; +import { updateIn } from '../functional/updateIn.js'; +import { emptyMap } from '../Map.js'; + +function mergeIn(keyPath) { + var iters = [], len = arguments.length - 1; + while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; + + return updateIn(this, keyPath, emptyMap(), function (m) { return mergeWithSources(m, iters); }); +} + +export { mergeIn }; diff --git a/dist/es/methods/setIn.js b/dist/es/methods/setIn.js new file mode 100644 index 0000000000..5227a88b05 --- /dev/null +++ b/dist/es/methods/setIn.js @@ -0,0 +1,31 @@ +/** + * @license + * MIT License + * + * Copyright (c) 2014-present, Lee Byron and other contributors. + * + * 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: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +import { setIn as setIn$1 } from '../functional/setIn.js'; + +function setIn(keyPath, v) { + return setIn$1(this, keyPath, v); +} + +export { setIn }; diff --git a/dist/es/methods/toObject.js b/dist/es/methods/toObject.js new file mode 100644 index 0000000000..364bbb0746 --- /dev/null +++ b/dist/es/methods/toObject.js @@ -0,0 +1,36 @@ +/** + * @license + * MIT License + * + * Copyright (c) 2014-present, Lee Byron and other contributors. + * + * 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: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +import assertNotInfinite from '../utils/assertNotInfinite.js'; + +function toObject() { + assertNotInfinite(this.size); + var object = {}; + this.__iterate(function (v, k) { + object[k] = v; + }); + return object; +} + +export { toObject }; diff --git a/dist/es/methods/update.js b/dist/es/methods/update.js new file mode 100644 index 0000000000..f09c0c5f03 --- /dev/null +++ b/dist/es/methods/update.js @@ -0,0 +1,33 @@ +/** + * @license + * MIT License + * + * Copyright (c) 2014-present, Lee Byron and other contributors. + * + * 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: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +import { update as update$1 } from '../functional/update.js'; + +function update(key, notSetValue, updater) { + return arguments.length === 1 + ? key(this) + : update$1(this, key, notSetValue, updater); +} + +export { update }; diff --git a/dist/es/methods/updateIn.js b/dist/es/methods/updateIn.js new file mode 100644 index 0000000000..bd7c957f78 --- /dev/null +++ b/dist/es/methods/updateIn.js @@ -0,0 +1,31 @@ +/** + * @license + * MIT License + * + * Copyright (c) 2014-present, Lee Byron and other contributors. + * + * 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: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +import { updateIn as updateIn$1 } from '../functional/updateIn.js'; + +function updateIn(keyPath, notSetValue, updater) { + return updateIn$1(this, keyPath, notSetValue, updater); +} + +export { updateIn }; diff --git a/dist/es/methods/wasAltered.js b/dist/es/methods/wasAltered.js new file mode 100644 index 0000000000..44cec027d1 --- /dev/null +++ b/dist/es/methods/wasAltered.js @@ -0,0 +1,29 @@ +/** + * @license + * MIT License + * + * Copyright (c) 2014-present, Lee Byron and other contributors. + * + * 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: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +function wasAltered() { + return this.__altered; +} + +export { wasAltered }; diff --git a/dist/es/methods/withMutations.js b/dist/es/methods/withMutations.js new file mode 100644 index 0000000000..a447af7709 --- /dev/null +++ b/dist/es/methods/withMutations.js @@ -0,0 +1,31 @@ +/** + * @license + * MIT License + * + * Copyright (c) 2014-present, Lee Byron and other contributors. + * + * 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: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +function withMutations(fn) { + var mutable = this.asMutable(); + fn(mutable); + return mutable.wasAltered() ? mutable.__ensureOwner(this.__ownerID) : this; +} + +export { withMutations }; diff --git a/dist/es/package.json.js b/dist/es/package.json.js new file mode 100644 index 0000000000..2688d81805 --- /dev/null +++ b/dist/es/package.json.js @@ -0,0 +1,27 @@ +/** + * @license + * MIT License + * + * Copyright (c) 2014-present, Lee Byron and other contributors. + * + * 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: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +var version = "5.0.0-rc.1"; + +export { version }; diff --git a/dist/es/predicates/isAssociative.js b/dist/es/predicates/isAssociative.js new file mode 100644 index 0000000000..1a1686bf87 --- /dev/null +++ b/dist/es/predicates/isAssociative.js @@ -0,0 +1,32 @@ +/** + * @license + * MIT License + * + * Copyright (c) 2014-present, Lee Byron and other contributors. + * + * 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: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +import { isKeyed } from './isKeyed.js'; +import { isIndexed } from './isIndexed.js'; + +function isAssociative(maybeAssociative) { + return isKeyed(maybeAssociative) || isIndexed(maybeAssociative); +} + +export { isAssociative }; diff --git a/dist/es/predicates/isCollection.js b/dist/es/predicates/isCollection.js new file mode 100644 index 0000000000..ba73d2cdbd --- /dev/null +++ b/dist/es/predicates/isCollection.js @@ -0,0 +1,32 @@ +/** + * @license + * MIT License + * + * Copyright (c) 2014-present, Lee Byron and other contributors. + * + * 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: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// Note: value is unchanged to not break immutable-devtools. +var IS_COLLECTION_SYMBOL = '@@__IMMUTABLE_ITERABLE__@@'; + +function isCollection(maybeCollection) { + return Boolean(maybeCollection && maybeCollection[IS_COLLECTION_SYMBOL]); +} + +export { IS_COLLECTION_SYMBOL, isCollection }; diff --git a/dist/es/predicates/isImmutable.js b/dist/es/predicates/isImmutable.js new file mode 100644 index 0000000000..e4a99af392 --- /dev/null +++ b/dist/es/predicates/isImmutable.js @@ -0,0 +1,32 @@ +/** + * @license + * MIT License + * + * Copyright (c) 2014-present, Lee Byron and other contributors. + * + * 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: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +import { isCollection } from './isCollection.js'; +import { isRecord } from './isRecord.js'; + +function isImmutable(maybeImmutable) { + return isCollection(maybeImmutable) || isRecord(maybeImmutable); +} + +export { isImmutable }; diff --git a/dist/es/predicates/isIndexed.js b/dist/es/predicates/isIndexed.js new file mode 100644 index 0000000000..3a13eb537c --- /dev/null +++ b/dist/es/predicates/isIndexed.js @@ -0,0 +1,31 @@ +/** + * @license + * MIT License + * + * Copyright (c) 2014-present, Lee Byron and other contributors. + * + * 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: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +var IS_INDEXED_SYMBOL = '@@__IMMUTABLE_INDEXED__@@'; + +function isIndexed(maybeIndexed) { + return Boolean(maybeIndexed && maybeIndexed[IS_INDEXED_SYMBOL]); +} + +export { IS_INDEXED_SYMBOL, isIndexed }; diff --git a/dist/es/predicates/isKeyed.js b/dist/es/predicates/isKeyed.js new file mode 100644 index 0000000000..c932aa17e9 --- /dev/null +++ b/dist/es/predicates/isKeyed.js @@ -0,0 +1,31 @@ +/** + * @license + * MIT License + * + * Copyright (c) 2014-present, Lee Byron and other contributors. + * + * 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: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +var IS_KEYED_SYMBOL = '@@__IMMUTABLE_KEYED__@@'; + +function isKeyed(maybeKeyed) { + return Boolean(maybeKeyed && maybeKeyed[IS_KEYED_SYMBOL]); +} + +export { IS_KEYED_SYMBOL, isKeyed }; diff --git a/dist/es/predicates/isList.js b/dist/es/predicates/isList.js new file mode 100644 index 0000000000..bba54d714e --- /dev/null +++ b/dist/es/predicates/isList.js @@ -0,0 +1,31 @@ +/** + * @license + * MIT License + * + * Copyright (c) 2014-present, Lee Byron and other contributors. + * + * 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: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +var IS_LIST_SYMBOL = '@@__IMMUTABLE_LIST__@@'; + +function isList(maybeList) { + return Boolean(maybeList && maybeList[IS_LIST_SYMBOL]); +} + +export { IS_LIST_SYMBOL, isList }; diff --git a/dist/es/predicates/isMap.js b/dist/es/predicates/isMap.js new file mode 100644 index 0000000000..b23db2ef36 --- /dev/null +++ b/dist/es/predicates/isMap.js @@ -0,0 +1,31 @@ +/** + * @license + * MIT License + * + * Copyright (c) 2014-present, Lee Byron and other contributors. + * + * 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: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +var IS_MAP_SYMBOL = '@@__IMMUTABLE_MAP__@@'; + +function isMap(maybeMap) { + return Boolean(maybeMap && maybeMap[IS_MAP_SYMBOL]); +} + +export { IS_MAP_SYMBOL, isMap }; diff --git a/dist/es/predicates/isOrdered.js b/dist/es/predicates/isOrdered.js new file mode 100644 index 0000000000..b490caaf23 --- /dev/null +++ b/dist/es/predicates/isOrdered.js @@ -0,0 +1,31 @@ +/** + * @license + * MIT License + * + * Copyright (c) 2014-present, Lee Byron and other contributors. + * + * 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: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +var IS_ORDERED_SYMBOL = '@@__IMMUTABLE_ORDERED__@@'; + +function isOrdered(maybeOrdered) { + return Boolean(maybeOrdered && maybeOrdered[IS_ORDERED_SYMBOL]); +} + +export { IS_ORDERED_SYMBOL, isOrdered }; diff --git a/dist/es/predicates/isOrderedMap.js b/dist/es/predicates/isOrderedMap.js new file mode 100644 index 0000000000..bd7f751cf4 --- /dev/null +++ b/dist/es/predicates/isOrderedMap.js @@ -0,0 +1,32 @@ +/** + * @license + * MIT License + * + * Copyright (c) 2014-present, Lee Byron and other contributors. + * + * 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: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +import { isMap } from './isMap.js'; +import { isOrdered } from './isOrdered.js'; + +function isOrderedMap(maybeOrderedMap) { + return isMap(maybeOrderedMap) && isOrdered(maybeOrderedMap); +} + +export { isOrderedMap }; diff --git a/dist/es/predicates/isOrderedSet.js b/dist/es/predicates/isOrderedSet.js new file mode 100644 index 0000000000..1accc1de17 --- /dev/null +++ b/dist/es/predicates/isOrderedSet.js @@ -0,0 +1,32 @@ +/** + * @license + * MIT License + * + * Copyright (c) 2014-present, Lee Byron and other contributors. + * + * 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: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +import { isSet } from './isSet.js'; +import { isOrdered } from './isOrdered.js'; + +function isOrderedSet(maybeOrderedSet) { + return isSet(maybeOrderedSet) && isOrdered(maybeOrderedSet); +} + +export { isOrderedSet }; diff --git a/dist/es/predicates/isRecord.js b/dist/es/predicates/isRecord.js new file mode 100644 index 0000000000..158bdf8212 --- /dev/null +++ b/dist/es/predicates/isRecord.js @@ -0,0 +1,31 @@ +/** + * @license + * MIT License + * + * Copyright (c) 2014-present, Lee Byron and other contributors. + * + * 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: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +var IS_RECORD_SYMBOL = '@@__IMMUTABLE_RECORD__@@'; + +function isRecord(maybeRecord) { + return Boolean(maybeRecord && maybeRecord[IS_RECORD_SYMBOL]); +} + +export { IS_RECORD_SYMBOL, isRecord }; diff --git a/dist/es/predicates/isSeq.js b/dist/es/predicates/isSeq.js new file mode 100644 index 0000000000..e1979aed49 --- /dev/null +++ b/dist/es/predicates/isSeq.js @@ -0,0 +1,31 @@ +/** + * @license + * MIT License + * + * Copyright (c) 2014-present, Lee Byron and other contributors. + * + * 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: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +var IS_SEQ_SYMBOL = '@@__IMMUTABLE_SEQ__@@'; + +function isSeq(maybeSeq) { + return Boolean(maybeSeq && maybeSeq[IS_SEQ_SYMBOL]); +} + +export { IS_SEQ_SYMBOL, isSeq }; diff --git a/dist/es/predicates/isSet.js b/dist/es/predicates/isSet.js new file mode 100644 index 0000000000..ddc509d269 --- /dev/null +++ b/dist/es/predicates/isSet.js @@ -0,0 +1,31 @@ +/** + * @license + * MIT License + * + * Copyright (c) 2014-present, Lee Byron and other contributors. + * + * 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: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +var IS_SET_SYMBOL = '@@__IMMUTABLE_SET__@@'; + +function isSet(maybeSet) { + return Boolean(maybeSet && maybeSet[IS_SET_SYMBOL]); +} + +export { IS_SET_SYMBOL, isSet }; diff --git a/dist/es/predicates/isStack.js b/dist/es/predicates/isStack.js new file mode 100644 index 0000000000..7409eb64ea --- /dev/null +++ b/dist/es/predicates/isStack.js @@ -0,0 +1,31 @@ +/** + * @license + * MIT License + * + * Copyright (c) 2014-present, Lee Byron and other contributors. + * + * 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: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +var IS_STACK_SYMBOL = '@@__IMMUTABLE_STACK__@@'; + +function isStack(maybeStack) { + return Boolean(maybeStack && maybeStack[IS_STACK_SYMBOL]); +} + +export { IS_STACK_SYMBOL, isStack }; diff --git a/dist/es/predicates/isValueObject.js b/dist/es/predicates/isValueObject.js new file mode 100644 index 0000000000..3ef2f0e6a8 --- /dev/null +++ b/dist/es/predicates/isValueObject.js @@ -0,0 +1,33 @@ +/** + * @license + * MIT License + * + * Copyright (c) 2014-present, Lee Byron and other contributors. + * + * 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: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +function isValueObject(maybeValue) { + return Boolean( + maybeValue && + typeof maybeValue.equals === 'function' && + typeof maybeValue.hashCode === 'function' + ); +} + +export { isValueObject }; diff --git a/dist/es/toJS.js b/dist/es/toJS.js new file mode 100644 index 0000000000..bb79094756 --- /dev/null +++ b/dist/es/toJS.js @@ -0,0 +1,54 @@ +/** + * @license + * MIT License + * + * Copyright (c) 2014-present, Lee Byron and other contributors. + * + * 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: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +import { Seq } from './Seq.js'; +import { isCollection } from './predicates/isCollection.js'; +import { isKeyed } from './predicates/isKeyed.js'; +import isDataStructure from './utils/isDataStructure.js'; + +function toJS(value) { + if (!value || typeof value !== 'object') { + return value; + } + if (!isCollection(value)) { + if (!isDataStructure(value)) { + return value; + } + value = Seq(value); + } + if (isKeyed(value)) { + var result$1 = {}; + value.__iterate(function (v, k) { + result$1[k] = toJS(v); + }); + return result$1; + } + var result = []; + value.__iterate(function (v) { + result.push(toJS(v)); + }); + return result; +} + +export { toJS }; diff --git a/dist/es/utils/arrCopy.js b/dist/es/utils/arrCopy.js new file mode 100644 index 0000000000..8e173f05d4 --- /dev/null +++ b/dist/es/utils/arrCopy.js @@ -0,0 +1,36 @@ +/** + * @license + * MIT License + * + * Copyright (c) 2014-present, Lee Byron and other contributors. + * + * 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: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// http://jsperf.com/copy-array-inline +function arrCopy(arr, offset) { + offset = offset || 0; + var len = Math.max(0, arr.length - offset); + var newArr = new Array(len); + for (var ii = 0; ii < len; ii++) { + newArr[ii] = arr[ii + offset]; + } + return newArr; +} + +export { arrCopy as default }; diff --git a/dist/es/utils/assertNotInfinite.js b/dist/es/utils/assertNotInfinite.js new file mode 100644 index 0000000000..0f49cb6e99 --- /dev/null +++ b/dist/es/utils/assertNotInfinite.js @@ -0,0 +1,34 @@ +/** + * @license + * MIT License + * + * Copyright (c) 2014-present, Lee Byron and other contributors. + * + * 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: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +import invariant from './invariant.js'; + +function assertNotInfinite(size) { + invariant( + size !== Infinity, + 'Cannot perform this action with an infinite size.' + ); +} + +export { assertNotInfinite as default }; diff --git a/dist/es/utils/coerceKeyPath.js b/dist/es/utils/coerceKeyPath.js new file mode 100644 index 0000000000..f9dbd0143e --- /dev/null +++ b/dist/es/utils/coerceKeyPath.js @@ -0,0 +1,40 @@ +/** + * @license + * MIT License + * + * Copyright (c) 2014-present, Lee Byron and other contributors. + * + * 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: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +import { isOrdered } from '../predicates/isOrdered.js'; +import isArrayLike from './isArrayLike.js'; + +function coerceKeyPath(keyPath) { + if (isArrayLike(keyPath) && typeof keyPath !== 'string') { + return keyPath; + } + if (isOrdered(keyPath)) { + return keyPath.toArray(); + } + throw new TypeError( + 'Invalid keyPath: expected Ordered Collection or Array: ' + keyPath + ); +} + +export { coerceKeyPath as default }; diff --git a/dist/es/utils/deepEqual.js b/dist/es/utils/deepEqual.js new file mode 100644 index 0000000000..c79a31e3a5 --- /dev/null +++ b/dist/es/utils/deepEqual.js @@ -0,0 +1,99 @@ +/** + * @license + * MIT License + * + * Copyright (c) 2014-present, Lee Byron and other contributors. + * + * 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: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +import { is } from '../is.js'; +import { NOT_SET } from '../TrieUtils.js'; +import { isCollection } from '../predicates/isCollection.js'; +import { isKeyed } from '../predicates/isKeyed.js'; +import { isIndexed } from '../predicates/isIndexed.js'; +import { isAssociative } from '../predicates/isAssociative.js'; +import { isOrdered } from '../predicates/isOrdered.js'; + +function deepEqual(a, b) { + if (a === b) { + return true; + } + + if ( + !isCollection(b) || + (a.size !== undefined && b.size !== undefined && a.size !== b.size) || + (a.__hash !== undefined && + b.__hash !== undefined && + a.__hash !== b.__hash) || + isKeyed(a) !== isKeyed(b) || + isIndexed(a) !== isIndexed(b) || + isOrdered(a) !== isOrdered(b) + ) { + return false; + } + + if (a.size === 0 && b.size === 0) { + return true; + } + + var notAssociative = !isAssociative(a); + + if (isOrdered(a)) { + var entries = a.entries(); + return ( + b.every(function (v, k) { + var entry = entries.next().value; + return entry && is(entry[1], v) && (notAssociative || is(entry[0], k)); + }) && entries.next().done + ); + } + + var flipped = false; + + if (a.size === undefined) { + if (b.size === undefined) { + if (typeof a.cacheResult === 'function') { + a.cacheResult(); + } + } else { + flipped = true; + var _ = a; + a = b; + b = _; + } + } + + var allEqual = true; + var bSize = b.__iterate(function (v, k) { + if ( + notAssociative + ? !a.has(v) + : flipped + ? !is(v, a.get(k, NOT_SET)) + : !is(a.get(k, NOT_SET), v) + ) { + allEqual = false; + return false; + } + }); + + return allEqual && a.size === bSize; +} + +export { deepEqual as default }; diff --git a/dist/es/utils/hasOwnProperty.js b/dist/es/utils/hasOwnProperty.js new file mode 100644 index 0000000000..f5befa4b04 --- /dev/null +++ b/dist/es/utils/hasOwnProperty.js @@ -0,0 +1,27 @@ +/** + * @license + * MIT License + * + * Copyright (c) 2014-present, Lee Byron and other contributors. + * + * 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: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +var hasOwnProperty = Object.prototype.hasOwnProperty; + +export { hasOwnProperty as default }; diff --git a/dist/es/utils/invariant.js b/dist/es/utils/invariant.js new file mode 100644 index 0000000000..1495de43c6 --- /dev/null +++ b/dist/es/utils/invariant.js @@ -0,0 +1,29 @@ +/** + * @license + * MIT License + * + * Copyright (c) 2014-present, Lee Byron and other contributors. + * + * 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: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +function invariant(condition, error) { + if (!condition) { throw new Error(error); } +} + +export { invariant as default }; diff --git a/dist/es/utils/isArrayLike.js b/dist/es/utils/isArrayLike.js new file mode 100644 index 0000000000..d1a26b09c1 --- /dev/null +++ b/dist/es/utils/isArrayLike.js @@ -0,0 +1,44 @@ +/** + * @license + * MIT License + * + * Copyright (c) 2014-present, Lee Byron and other contributors. + * + * 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: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +function isArrayLike(value) { + if (Array.isArray(value) || typeof value === 'string') { + return true; + } + + return ( + value && + typeof value === 'object' && + Number.isInteger(value.length) && + value.length >= 0 && + (value.length === 0 + ? // Only {length: 0} is considered Array-like. + Object.keys(value).length === 1 + : // An object is only Array-like if it has a property where the last value + // in the array-like may be found (which could be undefined). + value.hasOwnProperty(value.length - 1)) + ); +} + +export { isArrayLike as default }; diff --git a/dist/es/utils/isDataStructure.js b/dist/es/utils/isDataStructure.js new file mode 100644 index 0000000000..9f8e8d5663 --- /dev/null +++ b/dist/es/utils/isDataStructure.js @@ -0,0 +1,39 @@ +/** + * @license + * MIT License + * + * Copyright (c) 2014-present, Lee Byron and other contributors. + * + * 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: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +import { isImmutable } from '../predicates/isImmutable.js'; +import isPlainObject from './isPlainObj.js'; + +/** + * Returns true if the value is a potentially-persistent data structure, either + * provided by Immutable.js or a plain Array or Object. + */ +function isDataStructure(value) { + return ( + typeof value === 'object' && + (isImmutable(value) || Array.isArray(value) || isPlainObject(value)) + ); +} + +export { isDataStructure as default }; diff --git a/dist/es/utils/isPlainObj.js b/dist/es/utils/isPlainObj.js new file mode 100644 index 0000000000..02df7f16f8 --- /dev/null +++ b/dist/es/utils/isPlainObj.js @@ -0,0 +1,52 @@ +/** + * @license + * MIT License + * + * Copyright (c) 2014-present, Lee Byron and other contributors. + * + * 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: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +var toString = Object.prototype.toString; + +function isPlainObject(value) { + // The base prototype's toString deals with Argument objects and native namespaces like Math + if ( + !value || + typeof value !== 'object' || + toString.call(value) !== '[object Object]' + ) { + return false; + } + + var proto = Object.getPrototypeOf(value); + if (proto === null) { + return true; + } + + // Iteratively going up the prototype chain is needed for cross-realm environments (differing contexts, iframes, etc) + var parentProto = proto; + var nextProto = Object.getPrototypeOf(proto); + while (nextProto !== null) { + parentProto = nextProto; + nextProto = Object.getPrototypeOf(parentProto); + } + return parentProto === proto; +} + +export { isPlainObject as default }; diff --git a/dist/es/utils/mixin.js b/dist/es/utils/mixin.js new file mode 100644 index 0000000000..35fbe82d97 --- /dev/null +++ b/dist/es/utils/mixin.js @@ -0,0 +1,38 @@ +/** + * @license + * MIT License + * + * Copyright (c) 2014-present, Lee Byron and other contributors. + * + * 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: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +/** + * Contributes additional methods to a constructor + */ +function mixin(ctor, methods) { + var keyCopier = function (key) { + ctor.prototype[key] = methods[key]; + }; + Object.keys(methods).forEach(keyCopier); + Object.getOwnPropertySymbols && + Object.getOwnPropertySymbols(methods).forEach(keyCopier); + return ctor; +} + +export { mixin as default }; diff --git a/dist/es/utils/quoteString.js b/dist/es/utils/quoteString.js new file mode 100644 index 0000000000..4059262460 --- /dev/null +++ b/dist/es/utils/quoteString.js @@ -0,0 +1,36 @@ +/** + * @license + * MIT License + * + * Copyright (c) 2014-present, Lee Byron and other contributors. + * + * 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: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +/** + * Converts a value to a string, adding quotes if a string was provided. + */ +function quoteString(value) { + try { + return typeof value === 'string' ? JSON.stringify(value) : String(value); + } catch (_ignoreError) { + return JSON.stringify(value); + } +} + +export { quoteString as default }; diff --git a/dist/es/utils/shallowCopy.js b/dist/es/utils/shallowCopy.js new file mode 100644 index 0000000000..4f791ac40c --- /dev/null +++ b/dist/es/utils/shallowCopy.js @@ -0,0 +1,41 @@ +/** + * @license + * MIT License + * + * Copyright (c) 2014-present, Lee Byron and other contributors. + * + * 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: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +import arrCopy from './arrCopy.js'; +import hasOwnProperty from './hasOwnProperty.js'; + +function shallowCopy(from) { + if (Array.isArray(from)) { + return arrCopy(from); + } + var to = {}; + for (var key in from) { + if (hasOwnProperty.call(from, key)) { + to[key] = from[key]; + } + } + return to; +} + +export { shallowCopy as default }; diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index dc2b24547c..d0d804dec4 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -1,3 +1,5 @@ +/** @ignore we should disable this rules, but let's activate it to enable eslint first */ +/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types */ /** * Immutable data encourages pure functions (data-in, data-out) and lends itself * to much simpler application development and enabling techniques from @@ -112,6 +114,11 @@ declare namespace Immutable { { [key in keyof R]: ContainObject extends true ? unknown : R[key]; } + : T extends MapOf + ? // convert MapOf to DeepCopy plain JS object + { + [key in keyof R]: ContainObject extends true ? unknown : R[key]; + } : T extends Collection.Keyed ? // convert KeyedCollection to DeepCopy plain JS object { @@ -120,6 +127,7 @@ declare namespace Immutable { : string]: V extends object ? unknown : V; } : // convert IndexedCollection or Immutable.Set to DeepCopy plain JS array + // eslint-disable-next-line @typescript-eslint/no-unused-vars T extends Collection ? Array> : T extends string | number // Iterable scalar types : should be kept as is @@ -784,24 +792,6 @@ declare namespace Immutable { * ``` */ function isMap(maybeMap: unknown): maybeMap is Map; - - /** - * Creates a new Map from alternating keys and values - * - * - * ```js - * const { Map } = require('immutable') - * Map.of( - * 'key', 'value', - * 'numerical value', 3, - * 0, 'numerical key' - * ) - * // Map { 0: "numerical key", "key": "value", "numerical value": 3 } - * ``` - * - * @deprecated Use Map([ [ 'k', 'v' ] ]) or Map({ k: 'v' }) - */ - function of(...keyValues: Array): Map; } /** @@ -841,9 +831,98 @@ declare namespace Immutable { * not altered. */ function Map(collection?: Iterable<[K, V]>): Map; + function Map( + obj: R + ): MapOf; function Map(obj: { [key: string]: V }): Map; function Map(obj: { [P in K]?: V }): Map; + /** + * Represent a Map constructed by an object + * + * @ignore + */ + interface MapOf + extends Map { + /** + * Returns the value associated with the provided key, or notSetValue if + * the Collection does not contain this key. + * + * Note: it is possible a key may be associated with an `undefined` value, + * so if `notSetValue` is not provided and this method returns `undefined`, + * that does not guarantee the key was not found. + */ + get(key: K, notSetValue?: unknown): R[K]; + get(key: any, notSetValue: NSV): NSV; + + // TODO `` can be used after dropping support for TypeScript 4.x + // reference: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-0.html#const-type-parameters + // after this change, `as const` assertions can be remove from the type tests + getIn

>( + searchKeyPath: [...P], + notSetValue?: unknown + ): RetrievePath; + + set(key: K, value: R[K]): this; + + update(updater: (value: this) => this): this; + update(key: K, updater: (value: R[K]) => R[K]): this; + update( + key: K, + notSetValue: NSV, + updater: (value: R[K]) => R[K] + ): this; + + // Possible best type is MapOf> but Omit seems to broke other function calls + // and generate recursion error with other methods (update, merge, etc.) until those functions are defined in MapOf + delete( + key: K + ): Extract extends never ? never : this; + remove( + key: K + ): Extract extends never ? never : this; + + toJS(): { [K in keyof R]: DeepCopy }; + + toJSON(): { [K in keyof R]: R[K] }; + } + + // Loosely based off of this work. + // https://github.com/immutable-js/immutable-js/issues/1462#issuecomment-584123268 + + /** @ignore */ + type GetMapType = S extends MapOf ? T : S; + + /** @ignore */ + type Head> = T extends [ + infer H, + ...Array + ] + ? H + : never; + + /** @ignore */ + type Tail> = T extends [unknown, ...infer I] + ? I + : Array; + + /** @ignore */ + type RetrievePathReducer< + T, + C, + L extends ReadonlyArray + > = C extends keyof GetMapType + ? L extends [] + ? GetMapType[C] + : RetrievePathReducer[C], Head, Tail> + : never; + + /** @ignore */ + type RetrievePath< + R, + P extends ReadonlyArray + > = P extends [] ? P : RetrievePathReducer, Tail

>; + interface Map extends Collection.Keyed { /** * The number of entries in this Map. @@ -1061,16 +1140,17 @@ declare namespace Immutable { */ merge( ...collections: Array> - ): Map; + ): Map | VC>; merge( ...collections: Array<{ [key: string]: C }> - ): Map; + ): Map | C>; + concat( ...collections: Array> - ): Map; + ): Map | VC>; concat( ...collections: Array<{ [key: string]: C }> - ): Map; + ): Map | C>; /** * Like `merge()`, `mergeWith()` returns a new Map resulting from merging @@ -1090,10 +1170,14 @@ declare namespace Immutable { * * Note: `mergeWith` can be used in `withMutations`. */ - mergeWith( - merger: (oldVal: V, newVal: V, key: K) => V, - ...collections: Array | { [key: string]: V }> - ): this; + mergeWith( + merger: (oldVal: V, newVal: VC, key: K) => VCC, + ...collections: Array> + ): Map; + mergeWith( + merger: (oldVal: V, newVal: C, key: string) => CC, + ...collections: Array<{ [key: string]: C }> + ): Map; /** * Like `merge()`, but when two compatible collections are encountered with @@ -1124,9 +1208,12 @@ declare namespace Immutable { * * Note: `mergeDeep` can be used in `withMutations`. */ - mergeDeep( - ...collections: Array | { [key: string]: V }> - ): this; + mergeDeep( + ...collections: Array> + ): Map; + mergeDeep( + ...collections: Array<{ [key: string]: C }> + ): Map; /** * Like `mergeDeep()`, but when two non-collections or incompatible @@ -1594,15 +1681,32 @@ declare namespace Immutable { */ merge( ...collections: Array> - ): OrderedMap; + ): OrderedMap | VC>; merge( ...collections: Array<{ [key: string]: C }> - ): OrderedMap; + ): OrderedMap | C>; + concat( ...collections: Array> - ): OrderedMap; + ): OrderedMap | VC>; concat( ...collections: Array<{ [key: string]: C }> + ): OrderedMap | C>; + + mergeWith( + merger: (oldVal: V, newVal: VC, key: K) => VCC, + ...collections: Array> + ): OrderedMap; + mergeWith( + merger: (oldVal: V, newVal: C, key: string) => CC, + ...collections: Array<{ [key: string]: C }> + ): OrderedMap; + + mergeDeep( + ...collections: Array> + ): OrderedMap; + mergeDeep( + ...collections: Array<{ [key: string]: C }> ): OrderedMap; // Sequence algorithms @@ -1714,7 +1818,6 @@ declare namespace Immutable { * this Collection or JavaScript Object. */ function fromKeys(iter: Collection.Keyed): Set; - // tslint:disable-next-line unified-signatures function fromKeys(iter: Collection): Set; function fromKeys(obj: { [key: string]: unknown }): Set; @@ -1939,7 +2042,6 @@ declare namespace Immutable { * the keys from this Collection or JavaScript Object. */ function fromKeys(iter: Collection.Keyed): OrderedSet; - // tslint:disable-next-line unified-signatures function fromKeys(iter: Collection): OrderedSet; function fromKeys(obj: { [key: string]: unknown }): OrderedSet; } @@ -2362,8 +2464,8 @@ declare namespace Immutable { * ``` */ function Range( - start?: number, - end?: number, + start: number, + end: number, step?: number ): Seq.Indexed; @@ -3472,34 +3574,6 @@ declare namespace Immutable { * `Collection.Indexed`, or `Collection.Set`. */ namespace Collection { - /** - * @deprecated use `const { isKeyed } = require('immutable')` - */ - function isKeyed( - maybeKeyed: unknown - ): maybeKeyed is Collection.Keyed; - - /** - * @deprecated use `const { isIndexed } = require('immutable')` - */ - function isIndexed( - maybeIndexed: unknown - ): maybeIndexed is Collection.Indexed; - - /** - * @deprecated use `const { isAssociative } = require('immutable')` - */ - function isAssociative( - maybeAssociative: unknown - ): maybeAssociative is - | Collection.Keyed - | Collection.Indexed; - - /** - * @deprecated use `const { isOrdered } = require('immutable')` - */ - function isOrdered(maybeOrdered: unknown): boolean; - /** * Keyed Collections have discrete keys tied to each value. * @@ -4208,7 +4282,8 @@ declare namespace Immutable { * In case the `Collection` is empty returns the optional default * value if provided, if no default value is provided returns undefined. */ - first(notSetValue?: NSV): V | NSV; + first(notSetValue: NSV): V | NSV; + first(): V | undefined; /** * In case the `Collection` is not empty returns the last element of the @@ -4216,7 +4291,8 @@ declare namespace Immutable { * In case the `Collection` is empty returns the optional default * value if provided, if no default value is provided returns undefined. */ - last(notSetValue?: NSV): V | NSV; + last(notSetValue: NSV): V | NSV; + last(): V | undefined; // Reading deep values @@ -4808,7 +4884,6 @@ declare namespace Immutable { * returns Collection */ flatten(depth?: number): Collection; - // tslint:disable-next-line unified-signatures flatten(shallow?: boolean): Collection; /** diff --git a/dist/immutable.es.js b/dist/immutable.es.js deleted file mode 100644 index 30f5e00e66..0000000000 --- a/dist/immutable.es.js +++ /dev/null @@ -1,5988 +0,0 @@ -/** - * MIT License - * - * Copyright (c) 2014-present, Lee Byron and other contributors. - * - * 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: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -var DELETE = 'delete'; - -// Constants describing the size of trie nodes. -var SHIFT = 5; // Resulted in best performance after ______? -var SIZE = 1 << SHIFT; -var MASK = SIZE - 1; - -// A consistent shared value representing "not set" which equals nothing other -// than itself, and nothing that could be provided externally. -var NOT_SET = {}; - -// Boolean references, Rough equivalent of `bool &`. -function MakeRef() { - return { value: false }; -} - -function SetRef(ref) { - if (ref) { - ref.value = true; - } -} - -// A function which returns a value representing an "owner" for transient writes -// to tries. The return value will only ever equal itself, and will not equal -// the return of any subsequent call of this function. -function OwnerID() {} - -function ensureSize(iter) { - if (iter.size === undefined) { - iter.size = iter.__iterate(returnTrue); - } - return iter.size; -} - -function wrapIndex(iter, index) { - // This implements "is array index" which the ECMAString spec defines as: - // - // A String property name P is an array index if and only if - // ToString(ToUint32(P)) is equal to P and ToUint32(P) is not equal - // to 2^32−1. - // - // http://www.ecma-international.org/ecma-262/6.0/#sec-array-exotic-objects - if (typeof index !== 'number') { - var uint32Index = index >>> 0; // N >>> 0 is shorthand for ToUint32 - if ('' + uint32Index !== index || uint32Index === 4294967295) { - return NaN; - } - index = uint32Index; - } - return index < 0 ? ensureSize(iter) + index : index; -} - -function returnTrue() { - return true; -} - -function wholeSlice(begin, end, size) { - return ( - ((begin === 0 && !isNeg(begin)) || - (size !== undefined && begin <= -size)) && - (end === undefined || (size !== undefined && end >= size)) - ); -} - -function resolveBegin(begin, size) { - return resolveIndex(begin, size, 0); -} - -function resolveEnd(end, size) { - return resolveIndex(end, size, size); -} - -function resolveIndex(index, size, defaultIndex) { - // Sanitize indices using this shorthand for ToInt32(argument) - // http://www.ecma-international.org/ecma-262/6.0/#sec-toint32 - return index === undefined - ? defaultIndex - : isNeg(index) - ? size === Infinity - ? size - : Math.max(0, size + index) | 0 - : size === undefined || size === index - ? index - : Math.min(size, index) | 0; -} - -function isNeg(value) { - // Account for -0 which is negative, but not less than 0. - return value < 0 || (value === 0 && 1 / value === -Infinity); -} - -var IS_COLLECTION_SYMBOL = '@@__IMMUTABLE_ITERABLE__@@'; - -function isCollection(maybeCollection) { - return Boolean(maybeCollection && maybeCollection[IS_COLLECTION_SYMBOL]); -} - -var IS_KEYED_SYMBOL = '@@__IMMUTABLE_KEYED__@@'; - -function isKeyed(maybeKeyed) { - return Boolean(maybeKeyed && maybeKeyed[IS_KEYED_SYMBOL]); -} - -var IS_INDEXED_SYMBOL = '@@__IMMUTABLE_INDEXED__@@'; - -function isIndexed(maybeIndexed) { - return Boolean(maybeIndexed && maybeIndexed[IS_INDEXED_SYMBOL]); -} - -function isAssociative(maybeAssociative) { - return isKeyed(maybeAssociative) || isIndexed(maybeAssociative); -} - -var Collection = function Collection(value) { - // eslint-disable-next-line no-constructor-return - return isCollection(value) ? value : Seq(value); -}; - -var KeyedCollection = /*@__PURE__*/(function (Collection) { - function KeyedCollection(value) { - // eslint-disable-next-line no-constructor-return - return isKeyed(value) ? value : KeyedSeq(value); - } - - if ( Collection ) KeyedCollection.__proto__ = Collection; - KeyedCollection.prototype = Object.create( Collection && Collection.prototype ); - KeyedCollection.prototype.constructor = KeyedCollection; - - return KeyedCollection; -}(Collection)); - -var IndexedCollection = /*@__PURE__*/(function (Collection) { - function IndexedCollection(value) { - // eslint-disable-next-line no-constructor-return - return isIndexed(value) ? value : IndexedSeq(value); - } - - if ( Collection ) IndexedCollection.__proto__ = Collection; - IndexedCollection.prototype = Object.create( Collection && Collection.prototype ); - IndexedCollection.prototype.constructor = IndexedCollection; - - return IndexedCollection; -}(Collection)); - -var SetCollection = /*@__PURE__*/(function (Collection) { - function SetCollection(value) { - // eslint-disable-next-line no-constructor-return - return isCollection(value) && !isAssociative(value) ? value : SetSeq(value); - } - - if ( Collection ) SetCollection.__proto__ = Collection; - SetCollection.prototype = Object.create( Collection && Collection.prototype ); - SetCollection.prototype.constructor = SetCollection; - - return SetCollection; -}(Collection)); - -Collection.Keyed = KeyedCollection; -Collection.Indexed = IndexedCollection; -Collection.Set = SetCollection; - -var IS_SEQ_SYMBOL = '@@__IMMUTABLE_SEQ__@@'; - -function isSeq(maybeSeq) { - return Boolean(maybeSeq && maybeSeq[IS_SEQ_SYMBOL]); -} - -var IS_RECORD_SYMBOL = '@@__IMMUTABLE_RECORD__@@'; - -function isRecord(maybeRecord) { - return Boolean(maybeRecord && maybeRecord[IS_RECORD_SYMBOL]); -} - -function isImmutable(maybeImmutable) { - return isCollection(maybeImmutable) || isRecord(maybeImmutable); -} - -var IS_ORDERED_SYMBOL = '@@__IMMUTABLE_ORDERED__@@'; - -function isOrdered(maybeOrdered) { - return Boolean(maybeOrdered && maybeOrdered[IS_ORDERED_SYMBOL]); -} - -var ITERATE_KEYS = 0; -var ITERATE_VALUES = 1; -var ITERATE_ENTRIES = 2; - -var REAL_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator; -var FAUX_ITERATOR_SYMBOL = '@@iterator'; - -var ITERATOR_SYMBOL = REAL_ITERATOR_SYMBOL || FAUX_ITERATOR_SYMBOL; - -var Iterator = function Iterator(next) { - this.next = next; -}; - -Iterator.prototype.toString = function toString () { - return '[Iterator]'; -}; - -Iterator.KEYS = ITERATE_KEYS; -Iterator.VALUES = ITERATE_VALUES; -Iterator.ENTRIES = ITERATE_ENTRIES; - -Iterator.prototype.inspect = Iterator.prototype.toSource = function () { - return this.toString(); -}; -Iterator.prototype[ITERATOR_SYMBOL] = function () { - return this; -}; - -function iteratorValue(type, k, v, iteratorResult) { - var value = type === 0 ? k : type === 1 ? v : [k, v]; - iteratorResult - ? (iteratorResult.value = value) - : (iteratorResult = { - value: value, - done: false, - }); - return iteratorResult; -} - -function iteratorDone() { - return { value: undefined, done: true }; -} - -function hasIterator(maybeIterable) { - if (Array.isArray(maybeIterable)) { - // IE11 trick as it does not support `Symbol.iterator` - return true; - } - - return !!getIteratorFn(maybeIterable); -} - -function isIterator(maybeIterator) { - return maybeIterator && typeof maybeIterator.next === 'function'; -} - -function getIterator(iterable) { - var iteratorFn = getIteratorFn(iterable); - return iteratorFn && iteratorFn.call(iterable); -} - -function getIteratorFn(iterable) { - var iteratorFn = - iterable && - ((REAL_ITERATOR_SYMBOL && iterable[REAL_ITERATOR_SYMBOL]) || - iterable[FAUX_ITERATOR_SYMBOL]); - if (typeof iteratorFn === 'function') { - return iteratorFn; - } -} - -function isEntriesIterable(maybeIterable) { - var iteratorFn = getIteratorFn(maybeIterable); - return iteratorFn && iteratorFn === maybeIterable.entries; -} - -function isKeysIterable(maybeIterable) { - var iteratorFn = getIteratorFn(maybeIterable); - return iteratorFn && iteratorFn === maybeIterable.keys; -} - -var hasOwnProperty = Object.prototype.hasOwnProperty; - -function isArrayLike(value) { - if (Array.isArray(value) || typeof value === 'string') { - return true; - } - - return ( - value && - typeof value === 'object' && - Number.isInteger(value.length) && - value.length >= 0 && - (value.length === 0 - ? // Only {length: 0} is considered Array-like. - Object.keys(value).length === 1 - : // An object is only Array-like if it has a property where the last value - // in the array-like may be found (which could be undefined). - value.hasOwnProperty(value.length - 1)) - ); -} - -var Seq = /*@__PURE__*/(function (Collection) { - function Seq(value) { - // eslint-disable-next-line no-constructor-return - return value === undefined || value === null - ? emptySequence() - : isImmutable(value) - ? value.toSeq() - : seqFromValue(value); - } - - if ( Collection ) Seq.__proto__ = Collection; - Seq.prototype = Object.create( Collection && Collection.prototype ); - Seq.prototype.constructor = Seq; - - Seq.prototype.toSeq = function toSeq () { - return this; - }; - - Seq.prototype.toString = function toString () { - return this.__toString('Seq {', '}'); - }; - - Seq.prototype.cacheResult = function cacheResult () { - if (!this._cache && this.__iterateUncached) { - this._cache = this.entrySeq().toArray(); - this.size = this._cache.length; - } - return this; - }; - - // abstract __iterateUncached(fn, reverse) - - Seq.prototype.__iterate = function __iterate (fn, reverse) { - var cache = this._cache; - if (cache) { - var size = cache.length; - var i = 0; - while (i !== size) { - var entry = cache[reverse ? size - ++i : i++]; - if (fn(entry[1], entry[0], this) === false) { - break; - } - } - return i; - } - return this.__iterateUncached(fn, reverse); - }; - - // abstract __iteratorUncached(type, reverse) - - Seq.prototype.__iterator = function __iterator (type, reverse) { - var cache = this._cache; - if (cache) { - var size = cache.length; - var i = 0; - return new Iterator(function () { - if (i === size) { - return iteratorDone(); - } - var entry = cache[reverse ? size - ++i : i++]; - return iteratorValue(type, entry[0], entry[1]); - }); - } - return this.__iteratorUncached(type, reverse); - }; - - return Seq; -}(Collection)); - -var KeyedSeq = /*@__PURE__*/(function (Seq) { - function KeyedSeq(value) { - // eslint-disable-next-line no-constructor-return - return value === undefined || value === null - ? emptySequence().toKeyedSeq() - : isCollection(value) - ? isKeyed(value) - ? value.toSeq() - : value.fromEntrySeq() - : isRecord(value) - ? value.toSeq() - : keyedSeqFromValue(value); - } - - if ( Seq ) KeyedSeq.__proto__ = Seq; - KeyedSeq.prototype = Object.create( Seq && Seq.prototype ); - KeyedSeq.prototype.constructor = KeyedSeq; - - KeyedSeq.prototype.toKeyedSeq = function toKeyedSeq () { - return this; - }; - - return KeyedSeq; -}(Seq)); - -var IndexedSeq = /*@__PURE__*/(function (Seq) { - function IndexedSeq(value) { - // eslint-disable-next-line no-constructor-return - return value === undefined || value === null - ? emptySequence() - : isCollection(value) - ? isKeyed(value) - ? value.entrySeq() - : value.toIndexedSeq() - : isRecord(value) - ? value.toSeq().entrySeq() - : indexedSeqFromValue(value); - } - - if ( Seq ) IndexedSeq.__proto__ = Seq; - IndexedSeq.prototype = Object.create( Seq && Seq.prototype ); - IndexedSeq.prototype.constructor = IndexedSeq; - - IndexedSeq.of = function of (/*...values*/) { - return IndexedSeq(arguments); - }; - - IndexedSeq.prototype.toIndexedSeq = function toIndexedSeq () { - return this; - }; - - IndexedSeq.prototype.toString = function toString () { - return this.__toString('Seq [', ']'); - }; - - return IndexedSeq; -}(Seq)); - -var SetSeq = /*@__PURE__*/(function (Seq) { - function SetSeq(value) { - // eslint-disable-next-line no-constructor-return - return ( - isCollection(value) && !isAssociative(value) ? value : IndexedSeq(value) - ).toSetSeq(); - } - - if ( Seq ) SetSeq.__proto__ = Seq; - SetSeq.prototype = Object.create( Seq && Seq.prototype ); - SetSeq.prototype.constructor = SetSeq; - - SetSeq.of = function of (/*...values*/) { - return SetSeq(arguments); - }; - - SetSeq.prototype.toSetSeq = function toSetSeq () { - return this; - }; - - return SetSeq; -}(Seq)); - -Seq.isSeq = isSeq; -Seq.Keyed = KeyedSeq; -Seq.Set = SetSeq; -Seq.Indexed = IndexedSeq; - -Seq.prototype[IS_SEQ_SYMBOL] = true; - -// #pragma Root Sequences - -var ArraySeq = /*@__PURE__*/(function (IndexedSeq) { - function ArraySeq(array) { - this._array = array; - this.size = array.length; - } - - if ( IndexedSeq ) ArraySeq.__proto__ = IndexedSeq; - ArraySeq.prototype = Object.create( IndexedSeq && IndexedSeq.prototype ); - ArraySeq.prototype.constructor = ArraySeq; - - ArraySeq.prototype.get = function get (index, notSetValue) { - return this.has(index) ? this._array[wrapIndex(this, index)] : notSetValue; - }; - - ArraySeq.prototype.__iterate = function __iterate (fn, reverse) { - var array = this._array; - var size = array.length; - var i = 0; - while (i !== size) { - var ii = reverse ? size - ++i : i++; - if (fn(array[ii], ii, this) === false) { - break; - } - } - return i; - }; - - ArraySeq.prototype.__iterator = function __iterator (type, reverse) { - var array = this._array; - var size = array.length; - var i = 0; - return new Iterator(function () { - if (i === size) { - return iteratorDone(); - } - var ii = reverse ? size - ++i : i++; - return iteratorValue(type, ii, array[ii]); - }); - }; - - return ArraySeq; -}(IndexedSeq)); - -var ObjectSeq = /*@__PURE__*/(function (KeyedSeq) { - function ObjectSeq(object) { - var keys = Object.keys(object).concat( - Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(object) : [] - ); - this._object = object; - this._keys = keys; - this.size = keys.length; - } - - if ( KeyedSeq ) ObjectSeq.__proto__ = KeyedSeq; - ObjectSeq.prototype = Object.create( KeyedSeq && KeyedSeq.prototype ); - ObjectSeq.prototype.constructor = ObjectSeq; - - ObjectSeq.prototype.get = function get (key, notSetValue) { - if (notSetValue !== undefined && !this.has(key)) { - return notSetValue; - } - return this._object[key]; - }; - - ObjectSeq.prototype.has = function has (key) { - return hasOwnProperty.call(this._object, key); - }; - - ObjectSeq.prototype.__iterate = function __iterate (fn, reverse) { - var object = this._object; - var keys = this._keys; - var size = keys.length; - var i = 0; - while (i !== size) { - var key = keys[reverse ? size - ++i : i++]; - if (fn(object[key], key, this) === false) { - break; - } - } - return i; - }; - - ObjectSeq.prototype.__iterator = function __iterator (type, reverse) { - var object = this._object; - var keys = this._keys; - var size = keys.length; - var i = 0; - return new Iterator(function () { - if (i === size) { - return iteratorDone(); - } - var key = keys[reverse ? size - ++i : i++]; - return iteratorValue(type, key, object[key]); - }); - }; - - return ObjectSeq; -}(KeyedSeq)); -ObjectSeq.prototype[IS_ORDERED_SYMBOL] = true; - -var CollectionSeq = /*@__PURE__*/(function (IndexedSeq) { - function CollectionSeq(collection) { - this._collection = collection; - this.size = collection.length || collection.size; - } - - if ( IndexedSeq ) CollectionSeq.__proto__ = IndexedSeq; - CollectionSeq.prototype = Object.create( IndexedSeq && IndexedSeq.prototype ); - CollectionSeq.prototype.constructor = CollectionSeq; - - CollectionSeq.prototype.__iterateUncached = function __iterateUncached (fn, reverse) { - if (reverse) { - return this.cacheResult().__iterate(fn, reverse); - } - var collection = this._collection; - var iterator = getIterator(collection); - var iterations = 0; - if (isIterator(iterator)) { - var step; - while (!(step = iterator.next()).done) { - if (fn(step.value, iterations++, this) === false) { - break; - } - } - } - return iterations; - }; - - CollectionSeq.prototype.__iteratorUncached = function __iteratorUncached (type, reverse) { - if (reverse) { - return this.cacheResult().__iterator(type, reverse); - } - var collection = this._collection; - var iterator = getIterator(collection); - if (!isIterator(iterator)) { - return new Iterator(iteratorDone); - } - var iterations = 0; - return new Iterator(function () { - var step = iterator.next(); - return step.done ? step : iteratorValue(type, iterations++, step.value); - }); - }; - - return CollectionSeq; -}(IndexedSeq)); - -// # pragma Helper functions - -var EMPTY_SEQ; - -function emptySequence() { - return EMPTY_SEQ || (EMPTY_SEQ = new ArraySeq([])); -} - -function keyedSeqFromValue(value) { - var seq = maybeIndexedSeqFromValue(value); - if (seq) { - return seq.fromEntrySeq(); - } - if (typeof value === 'object') { - return new ObjectSeq(value); - } - throw new TypeError( - 'Expected Array or collection object of [k, v] entries, or keyed object: ' + - value - ); -} - -function indexedSeqFromValue(value) { - var seq = maybeIndexedSeqFromValue(value); - if (seq) { - return seq; - } - throw new TypeError( - 'Expected Array or collection object of values: ' + value - ); -} - -function seqFromValue(value) { - var seq = maybeIndexedSeqFromValue(value); - if (seq) { - return isEntriesIterable(value) - ? seq.fromEntrySeq() - : isKeysIterable(value) - ? seq.toSetSeq() - : seq; - } - if (typeof value === 'object') { - return new ObjectSeq(value); - } - throw new TypeError( - 'Expected Array or collection object of values, or keyed object: ' + value - ); -} - -function maybeIndexedSeqFromValue(value) { - return isArrayLike(value) - ? new ArraySeq(value) - : hasIterator(value) - ? new CollectionSeq(value) - : undefined; -} - -var IS_MAP_SYMBOL = '@@__IMMUTABLE_MAP__@@'; - -function isMap(maybeMap) { - return Boolean(maybeMap && maybeMap[IS_MAP_SYMBOL]); -} - -function isOrderedMap(maybeOrderedMap) { - return isMap(maybeOrderedMap) && isOrdered(maybeOrderedMap); -} - -function isValueObject(maybeValue) { - return Boolean( - maybeValue && - typeof maybeValue.equals === 'function' && - typeof maybeValue.hashCode === 'function' - ); -} - -/** - * An extension of the "same-value" algorithm as [described for use by ES6 Map - * and Set](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map#Key_equality) - * - * NaN is considered the same as NaN, however -0 and 0 are considered the same - * value, which is different from the algorithm described by - * [`Object.is`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is). - * - * This is extended further to allow Objects to describe the values they - * represent, by way of `valueOf` or `equals` (and `hashCode`). - * - * Note: because of this extension, the key equality of Immutable.Map and the - * value equality of Immutable.Set will differ from ES6 Map and Set. - * - * ### Defining custom values - * - * The easiest way to describe the value an object represents is by implementing - * `valueOf`. For example, `Date` represents a value by returning a unix - * timestamp for `valueOf`: - * - * var date1 = new Date(1234567890000); // Fri Feb 13 2009 ... - * var date2 = new Date(1234567890000); - * date1.valueOf(); // 1234567890000 - * assert( date1 !== date2 ); - * assert( Immutable.is( date1, date2 ) ); - * - * Note: overriding `valueOf` may have other implications if you use this object - * where JavaScript expects a primitive, such as implicit string coercion. - * - * For more complex types, especially collections, implementing `valueOf` may - * not be performant. An alternative is to implement `equals` and `hashCode`. - * - * `equals` takes another object, presumably of similar type, and returns true - * if it is equal. Equality is symmetrical, so the same result should be - * returned if this and the argument are flipped. - * - * assert( a.equals(b) === b.equals(a) ); - * - * `hashCode` returns a 32bit integer number representing the object which will - * be used to determine how to store the value object in a Map or Set. You must - * provide both or neither methods, one must not exist without the other. - * - * Also, an important relationship between these methods must be upheld: if two - * values are equal, they *must* return the same hashCode. If the values are not - * equal, they might have the same hashCode; this is called a hash collision, - * and while undesirable for performance reasons, it is acceptable. - * - * if (a.equals(b)) { - * assert( a.hashCode() === b.hashCode() ); - * } - * - * All Immutable collections are Value Objects: they implement `equals()` - * and `hashCode()`. - */ -function is(valueA, valueB) { - if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) { - return true; - } - if (!valueA || !valueB) { - return false; - } - if ( - typeof valueA.valueOf === 'function' && - typeof valueB.valueOf === 'function' - ) { - valueA = valueA.valueOf(); - valueB = valueB.valueOf(); - if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) { - return true; - } - if (!valueA || !valueB) { - return false; - } - } - return !!( - isValueObject(valueA) && - isValueObject(valueB) && - valueA.equals(valueB) - ); -} - -var imul = - typeof Math.imul === 'function' && Math.imul(0xffffffff, 2) === -2 - ? Math.imul - : function imul(a, b) { - a |= 0; // int - b |= 0; // int - var c = a & 0xffff; - var d = b & 0xffff; - // Shift by 0 fixes the sign on the high part. - return (c * d + ((((a >>> 16) * d + c * (b >>> 16)) << 16) >>> 0)) | 0; // int - }; - -// v8 has an optimization for storing 31-bit signed numbers. -// Values which have either 00 or 11 as the high order bits qualify. -// This function drops the highest order bit in a signed number, maintaining -// the sign bit. -function smi(i32) { - return ((i32 >>> 1) & 0x40000000) | (i32 & 0xbfffffff); -} - -var defaultValueOf = Object.prototype.valueOf; - -function hash(o) { - if (o == null) { - return hashNullish(o); - } - - if (typeof o.hashCode === 'function') { - // Drop any high bits from accidentally long hash codes. - return smi(o.hashCode(o)); - } - - var v = valueOf(o); - - if (v == null) { - return hashNullish(v); - } - - switch (typeof v) { - case 'boolean': - // The hash values for built-in constants are a 1 value for each 5-byte - // shift region expect for the first, which encodes the value. This - // reduces the odds of a hash collision for these common values. - return v ? 0x42108421 : 0x42108420; - case 'number': - return hashNumber(v); - case 'string': - return v.length > STRING_HASH_CACHE_MIN_STRLEN - ? cachedHashString(v) - : hashString(v); - case 'object': - case 'function': - return hashJSObj(v); - case 'symbol': - return hashSymbol(v); - default: - if (typeof v.toString === 'function') { - return hashString(v.toString()); - } - throw new Error('Value type ' + typeof v + ' cannot be hashed.'); - } -} - -function hashNullish(nullish) { - return nullish === null ? 0x42108422 : /* undefined */ 0x42108423; -} - -// Compress arbitrarily large numbers into smi hashes. -function hashNumber(n) { - if (n !== n || n === Infinity) { - return 0; - } - var hash = n | 0; - if (hash !== n) { - hash ^= n * 0xffffffff; - } - while (n > 0xffffffff) { - n /= 0xffffffff; - hash ^= n; - } - return smi(hash); -} - -function cachedHashString(string) { - var hashed = stringHashCache[string]; - if (hashed === undefined) { - hashed = hashString(string); - if (STRING_HASH_CACHE_SIZE === STRING_HASH_CACHE_MAX_SIZE) { - STRING_HASH_CACHE_SIZE = 0; - stringHashCache = {}; - } - STRING_HASH_CACHE_SIZE++; - stringHashCache[string] = hashed; - } - return hashed; -} - -// http://jsperf.com/hashing-strings -function hashString(string) { - // This is the hash from JVM - // The hash code for a string is computed as - // s[0] * 31 ^ (n - 1) + s[1] * 31 ^ (n - 2) + ... + s[n - 1], - // where s[i] is the ith character of the string and n is the length of - // the string. We "mod" the result to make it between 0 (inclusive) and 2^31 - // (exclusive) by dropping high bits. - var hashed = 0; - for (var ii = 0; ii < string.length; ii++) { - hashed = (31 * hashed + string.charCodeAt(ii)) | 0; - } - return smi(hashed); -} - -function hashSymbol(sym) { - var hashed = symbolMap[sym]; - if (hashed !== undefined) { - return hashed; - } - - hashed = nextHash(); - - symbolMap[sym] = hashed; - - return hashed; -} - -function hashJSObj(obj) { - var hashed; - if (usingWeakMap) { - hashed = weakMap.get(obj); - if (hashed !== undefined) { - return hashed; - } - } - - hashed = obj[UID_HASH_KEY]; - if (hashed !== undefined) { - return hashed; - } - - if (!canDefineProperty) { - hashed = obj.propertyIsEnumerable && obj.propertyIsEnumerable[UID_HASH_KEY]; - if (hashed !== undefined) { - return hashed; - } - - hashed = getIENodeHash(obj); - if (hashed !== undefined) { - return hashed; - } - } - - hashed = nextHash(); - - if (usingWeakMap) { - weakMap.set(obj, hashed); - } else if (isExtensible !== undefined && isExtensible(obj) === false) { - throw new Error('Non-extensible objects are not allowed as keys.'); - } else if (canDefineProperty) { - Object.defineProperty(obj, UID_HASH_KEY, { - enumerable: false, - configurable: false, - writable: false, - value: hashed, - }); - } else if ( - obj.propertyIsEnumerable !== undefined && - obj.propertyIsEnumerable === obj.constructor.prototype.propertyIsEnumerable - ) { - // Since we can't define a non-enumerable property on the object - // we'll hijack one of the less-used non-enumerable properties to - // save our hash on it. Since this is a function it will not show up in - // `JSON.stringify` which is what we want. - obj.propertyIsEnumerable = function () { - return this.constructor.prototype.propertyIsEnumerable.apply( - this, - arguments - ); - }; - obj.propertyIsEnumerable[UID_HASH_KEY] = hashed; - } else if (obj.nodeType !== undefined) { - // At this point we couldn't get the IE `uniqueID` to use as a hash - // and we couldn't use a non-enumerable property to exploit the - // dontEnum bug so we simply add the `UID_HASH_KEY` on the node - // itself. - obj[UID_HASH_KEY] = hashed; - } else { - throw new Error('Unable to set a non-enumerable property on object.'); - } - - return hashed; -} - -// Get references to ES5 object methods. -var isExtensible = Object.isExtensible; - -// True if Object.defineProperty works as expected. IE8 fails this test. -var canDefineProperty = (function () { - try { - Object.defineProperty({}, '@', {}); - return true; - } catch (e) { - return false; - } -})(); - -// IE has a `uniqueID` property on DOM nodes. We can construct the hash from it -// and avoid memory leaks from the IE cloneNode bug. -function getIENodeHash(node) { - if (node && node.nodeType > 0) { - switch (node.nodeType) { - case 1: // Element - return node.uniqueID; - case 9: // Document - return node.documentElement && node.documentElement.uniqueID; - } - } -} - -function valueOf(obj) { - return obj.valueOf !== defaultValueOf && typeof obj.valueOf === 'function' - ? obj.valueOf(obj) - : obj; -} - -function nextHash() { - var nextHash = ++_objHashUID; - if (_objHashUID & 0x40000000) { - _objHashUID = 0; - } - return nextHash; -} - -// If possible, use a WeakMap. -var usingWeakMap = typeof WeakMap === 'function'; -var weakMap; -if (usingWeakMap) { - weakMap = new WeakMap(); -} - -var symbolMap = Object.create(null); - -var _objHashUID = 0; - -var UID_HASH_KEY = '__immutablehash__'; -if (typeof Symbol === 'function') { - UID_HASH_KEY = Symbol(UID_HASH_KEY); -} - -var STRING_HASH_CACHE_MIN_STRLEN = 16; -var STRING_HASH_CACHE_MAX_SIZE = 255; -var STRING_HASH_CACHE_SIZE = 0; -var stringHashCache = {}; - -var ToKeyedSequence = /*@__PURE__*/(function (KeyedSeq) { - function ToKeyedSequence(indexed, useKeys) { - this._iter = indexed; - this._useKeys = useKeys; - this.size = indexed.size; - } - - if ( KeyedSeq ) ToKeyedSequence.__proto__ = KeyedSeq; - ToKeyedSequence.prototype = Object.create( KeyedSeq && KeyedSeq.prototype ); - ToKeyedSequence.prototype.constructor = ToKeyedSequence; - - ToKeyedSequence.prototype.get = function get (key, notSetValue) { - return this._iter.get(key, notSetValue); - }; - - ToKeyedSequence.prototype.has = function has (key) { - return this._iter.has(key); - }; - - ToKeyedSequence.prototype.valueSeq = function valueSeq () { - return this._iter.valueSeq(); - }; - - ToKeyedSequence.prototype.reverse = function reverse () { - var this$1$1 = this; - - var reversedSequence = reverseFactory(this, true); - if (!this._useKeys) { - reversedSequence.valueSeq = function () { return this$1$1._iter.toSeq().reverse(); }; - } - return reversedSequence; - }; - - ToKeyedSequence.prototype.map = function map (mapper, context) { - var this$1$1 = this; - - var mappedSequence = mapFactory(this, mapper, context); - if (!this._useKeys) { - mappedSequence.valueSeq = function () { return this$1$1._iter.toSeq().map(mapper, context); }; - } - return mappedSequence; - }; - - ToKeyedSequence.prototype.__iterate = function __iterate (fn, reverse) { - var this$1$1 = this; - - return this._iter.__iterate(function (v, k) { return fn(v, k, this$1$1); }, reverse); - }; - - ToKeyedSequence.prototype.__iterator = function __iterator (type, reverse) { - return this._iter.__iterator(type, reverse); - }; - - return ToKeyedSequence; -}(KeyedSeq)); -ToKeyedSequence.prototype[IS_ORDERED_SYMBOL] = true; - -var ToIndexedSequence = /*@__PURE__*/(function (IndexedSeq) { - function ToIndexedSequence(iter) { - this._iter = iter; - this.size = iter.size; - } - - if ( IndexedSeq ) ToIndexedSequence.__proto__ = IndexedSeq; - ToIndexedSequence.prototype = Object.create( IndexedSeq && IndexedSeq.prototype ); - ToIndexedSequence.prototype.constructor = ToIndexedSequence; - - ToIndexedSequence.prototype.includes = function includes (value) { - return this._iter.includes(value); - }; - - ToIndexedSequence.prototype.__iterate = function __iterate (fn, reverse) { - var this$1$1 = this; - - var i = 0; - reverse && ensureSize(this); - return this._iter.__iterate( - function (v) { return fn(v, reverse ? this$1$1.size - ++i : i++, this$1$1); }, - reverse - ); - }; - - ToIndexedSequence.prototype.__iterator = function __iterator (type, reverse) { - var this$1$1 = this; - - var iterator = this._iter.__iterator(ITERATE_VALUES, reverse); - var i = 0; - reverse && ensureSize(this); - return new Iterator(function () { - var step = iterator.next(); - return step.done - ? step - : iteratorValue( - type, - reverse ? this$1$1.size - ++i : i++, - step.value, - step - ); - }); - }; - - return ToIndexedSequence; -}(IndexedSeq)); - -var ToSetSequence = /*@__PURE__*/(function (SetSeq) { - function ToSetSequence(iter) { - this._iter = iter; - this.size = iter.size; - } - - if ( SetSeq ) ToSetSequence.__proto__ = SetSeq; - ToSetSequence.prototype = Object.create( SetSeq && SetSeq.prototype ); - ToSetSequence.prototype.constructor = ToSetSequence; - - ToSetSequence.prototype.has = function has (key) { - return this._iter.includes(key); - }; - - ToSetSequence.prototype.__iterate = function __iterate (fn, reverse) { - var this$1$1 = this; - - return this._iter.__iterate(function (v) { return fn(v, v, this$1$1); }, reverse); - }; - - ToSetSequence.prototype.__iterator = function __iterator (type, reverse) { - var iterator = this._iter.__iterator(ITERATE_VALUES, reverse); - return new Iterator(function () { - var step = iterator.next(); - return step.done - ? step - : iteratorValue(type, step.value, step.value, step); - }); - }; - - return ToSetSequence; -}(SetSeq)); - -var FromEntriesSequence = /*@__PURE__*/(function (KeyedSeq) { - function FromEntriesSequence(entries) { - this._iter = entries; - this.size = entries.size; - } - - if ( KeyedSeq ) FromEntriesSequence.__proto__ = KeyedSeq; - FromEntriesSequence.prototype = Object.create( KeyedSeq && KeyedSeq.prototype ); - FromEntriesSequence.prototype.constructor = FromEntriesSequence; - - FromEntriesSequence.prototype.entrySeq = function entrySeq () { - return this._iter.toSeq(); - }; - - FromEntriesSequence.prototype.__iterate = function __iterate (fn, reverse) { - var this$1$1 = this; - - return this._iter.__iterate(function (entry) { - // Check if entry exists first so array access doesn't throw for holes - // in the parent iteration. - if (entry) { - validateEntry(entry); - var indexedCollection = isCollection(entry); - return fn( - indexedCollection ? entry.get(1) : entry[1], - indexedCollection ? entry.get(0) : entry[0], - this$1$1 - ); - } - }, reverse); - }; - - FromEntriesSequence.prototype.__iterator = function __iterator (type, reverse) { - var iterator = this._iter.__iterator(ITERATE_VALUES, reverse); - return new Iterator(function () { - while (true) { - var step = iterator.next(); - if (step.done) { - return step; - } - var entry = step.value; - // Check if entry exists first so array access doesn't throw for holes - // in the parent iteration. - if (entry) { - validateEntry(entry); - var indexedCollection = isCollection(entry); - return iteratorValue( - type, - indexedCollection ? entry.get(0) : entry[0], - indexedCollection ? entry.get(1) : entry[1], - step - ); - } - } - }); - }; - - return FromEntriesSequence; -}(KeyedSeq)); - -ToIndexedSequence.prototype.cacheResult = - ToKeyedSequence.prototype.cacheResult = - ToSetSequence.prototype.cacheResult = - FromEntriesSequence.prototype.cacheResult = - cacheResultThrough; - -function flipFactory(collection) { - var flipSequence = makeSequence(collection); - flipSequence._iter = collection; - flipSequence.size = collection.size; - flipSequence.flip = function () { return collection; }; - flipSequence.reverse = function () { - var reversedSequence = collection.reverse.apply(this); // super.reverse() - reversedSequence.flip = function () { return collection.reverse(); }; - return reversedSequence; - }; - flipSequence.has = function (key) { return collection.includes(key); }; - flipSequence.includes = function (key) { return collection.has(key); }; - flipSequence.cacheResult = cacheResultThrough; - flipSequence.__iterateUncached = function (fn, reverse) { - var this$1$1 = this; - - return collection.__iterate(function (v, k) { return fn(k, v, this$1$1) !== false; }, reverse); - }; - flipSequence.__iteratorUncached = function (type, reverse) { - if (type === ITERATE_ENTRIES) { - var iterator = collection.__iterator(type, reverse); - return new Iterator(function () { - var step = iterator.next(); - if (!step.done) { - var k = step.value[0]; - step.value[0] = step.value[1]; - step.value[1] = k; - } - return step; - }); - } - return collection.__iterator( - type === ITERATE_VALUES ? ITERATE_KEYS : ITERATE_VALUES, - reverse - ); - }; - return flipSequence; -} - -function mapFactory(collection, mapper, context) { - var mappedSequence = makeSequence(collection); - mappedSequence.size = collection.size; - mappedSequence.has = function (key) { return collection.has(key); }; - mappedSequence.get = function (key, notSetValue) { - var v = collection.get(key, NOT_SET); - return v === NOT_SET - ? notSetValue - : mapper.call(context, v, key, collection); - }; - mappedSequence.__iterateUncached = function (fn, reverse) { - var this$1$1 = this; - - return collection.__iterate( - function (v, k, c) { return fn(mapper.call(context, v, k, c), k, this$1$1) !== false; }, - reverse - ); - }; - mappedSequence.__iteratorUncached = function (type, reverse) { - var iterator = collection.__iterator(ITERATE_ENTRIES, reverse); - return new Iterator(function () { - var step = iterator.next(); - if (step.done) { - return step; - } - var entry = step.value; - var key = entry[0]; - return iteratorValue( - type, - key, - mapper.call(context, entry[1], key, collection), - step - ); - }); - }; - return mappedSequence; -} - -function reverseFactory(collection, useKeys) { - var this$1$1 = this; - - var reversedSequence = makeSequence(collection); - reversedSequence._iter = collection; - reversedSequence.size = collection.size; - reversedSequence.reverse = function () { return collection; }; - if (collection.flip) { - reversedSequence.flip = function () { - var flipSequence = flipFactory(collection); - flipSequence.reverse = function () { return collection.flip(); }; - return flipSequence; - }; - } - reversedSequence.get = function (key, notSetValue) { return collection.get(useKeys ? key : -1 - key, notSetValue); }; - reversedSequence.has = function (key) { return collection.has(useKeys ? key : -1 - key); }; - reversedSequence.includes = function (value) { return collection.includes(value); }; - reversedSequence.cacheResult = cacheResultThrough; - reversedSequence.__iterate = function (fn, reverse) { - var this$1$1 = this; - - var i = 0; - reverse && ensureSize(collection); - return collection.__iterate( - function (v, k) { return fn(v, useKeys ? k : reverse ? this$1$1.size - ++i : i++, this$1$1); }, - !reverse - ); - }; - reversedSequence.__iterator = function (type, reverse) { - var i = 0; - reverse && ensureSize(collection); - var iterator = collection.__iterator(ITERATE_ENTRIES, !reverse); - return new Iterator(function () { - var step = iterator.next(); - if (step.done) { - return step; - } - var entry = step.value; - return iteratorValue( - type, - useKeys ? entry[0] : reverse ? this$1$1.size - ++i : i++, - entry[1], - step - ); - }); - }; - return reversedSequence; -} - -function filterFactory(collection, predicate, context, useKeys) { - var filterSequence = makeSequence(collection); - if (useKeys) { - filterSequence.has = function (key) { - var v = collection.get(key, NOT_SET); - return v !== NOT_SET && !!predicate.call(context, v, key, collection); - }; - filterSequence.get = function (key, notSetValue) { - var v = collection.get(key, NOT_SET); - return v !== NOT_SET && predicate.call(context, v, key, collection) - ? v - : notSetValue; - }; - } - filterSequence.__iterateUncached = function (fn, reverse) { - var this$1$1 = this; - - var iterations = 0; - collection.__iterate(function (v, k, c) { - if (predicate.call(context, v, k, c)) { - iterations++; - return fn(v, useKeys ? k : iterations - 1, this$1$1); - } - }, reverse); - return iterations; - }; - filterSequence.__iteratorUncached = function (type, reverse) { - var iterator = collection.__iterator(ITERATE_ENTRIES, reverse); - var iterations = 0; - return new Iterator(function () { - while (true) { - var step = iterator.next(); - if (step.done) { - return step; - } - var entry = step.value; - var key = entry[0]; - var value = entry[1]; - if (predicate.call(context, value, key, collection)) { - return iteratorValue(type, useKeys ? key : iterations++, value, step); - } - } - }); - }; - return filterSequence; -} - -function countByFactory(collection, grouper, context) { - var groups = Map().asMutable(); - collection.__iterate(function (v, k) { - groups.update(grouper.call(context, v, k, collection), 0, function (a) { return a + 1; }); - }); - return groups.asImmutable(); -} - -function groupByFactory(collection, grouper, context) { - var isKeyedIter = isKeyed(collection); - var groups = (isOrdered(collection) ? OrderedMap() : Map()).asMutable(); - collection.__iterate(function (v, k) { - groups.update( - grouper.call(context, v, k, collection), - function (a) { return ((a = a || []), a.push(isKeyedIter ? [k, v] : v), a); } - ); - }); - var coerce = collectionClass(collection); - return groups.map(function (arr) { return reify(collection, coerce(arr)); }).asImmutable(); -} - -function partitionFactory(collection, predicate, context) { - var isKeyedIter = isKeyed(collection); - var groups = [[], []]; - collection.__iterate(function (v, k) { - groups[predicate.call(context, v, k, collection) ? 1 : 0].push( - isKeyedIter ? [k, v] : v - ); - }); - var coerce = collectionClass(collection); - return groups.map(function (arr) { return reify(collection, coerce(arr)); }); -} - -function sliceFactory(collection, begin, end, useKeys) { - var originalSize = collection.size; - - if (wholeSlice(begin, end, originalSize)) { - return collection; - } - - // begin or end can not be resolved if they were provided as negative numbers and - // this collection's size is unknown. In that case, cache first so there is - // a known size and these do not resolve to NaN. - if (typeof originalSize === 'undefined' && (begin < 0 || end < 0)) { - return sliceFactory(collection.toSeq().cacheResult(), begin, end, useKeys); - } - - var resolvedBegin = resolveBegin(begin, originalSize); - var resolvedEnd = resolveEnd(end, originalSize); - - // Note: resolvedEnd is undefined when the original sequence's length is - // unknown and this slice did not supply an end and should contain all - // elements after resolvedBegin. - // In that case, resolvedSize will be NaN and sliceSize will remain undefined. - var resolvedSize = resolvedEnd - resolvedBegin; - var sliceSize; - if (resolvedSize === resolvedSize) { - sliceSize = resolvedSize < 0 ? 0 : resolvedSize; - } - - var sliceSeq = makeSequence(collection); - - // If collection.size is undefined, the size of the realized sliceSeq is - // unknown at this point unless the number of items to slice is 0 - sliceSeq.size = - sliceSize === 0 ? sliceSize : (collection.size && sliceSize) || undefined; - - if (!useKeys && isSeq(collection) && sliceSize >= 0) { - sliceSeq.get = function (index, notSetValue) { - index = wrapIndex(this, index); - return index >= 0 && index < sliceSize - ? collection.get(index + resolvedBegin, notSetValue) - : notSetValue; - }; - } - - sliceSeq.__iterateUncached = function (fn, reverse) { - var this$1$1 = this; - - if (sliceSize === 0) { - return 0; - } - if (reverse) { - return this.cacheResult().__iterate(fn, reverse); - } - var skipped = 0; - var isSkipping = true; - var iterations = 0; - collection.__iterate(function (v, k) { - if (!(isSkipping && (isSkipping = skipped++ < resolvedBegin))) { - iterations++; - return ( - fn(v, useKeys ? k : iterations - 1, this$1$1) !== false && - iterations !== sliceSize - ); - } - }); - return iterations; - }; - - sliceSeq.__iteratorUncached = function (type, reverse) { - if (sliceSize !== 0 && reverse) { - return this.cacheResult().__iterator(type, reverse); - } - // Don't bother instantiating parent iterator if taking 0. - if (sliceSize === 0) { - return new Iterator(iteratorDone); - } - var iterator = collection.__iterator(type, reverse); - var skipped = 0; - var iterations = 0; - return new Iterator(function () { - while (skipped++ < resolvedBegin) { - iterator.next(); - } - if (++iterations > sliceSize) { - return iteratorDone(); - } - var step = iterator.next(); - if (useKeys || type === ITERATE_VALUES || step.done) { - return step; - } - if (type === ITERATE_KEYS) { - return iteratorValue(type, iterations - 1, undefined, step); - } - return iteratorValue(type, iterations - 1, step.value[1], step); - }); - }; - - return sliceSeq; -} - -function takeWhileFactory(collection, predicate, context) { - var takeSequence = makeSequence(collection); - takeSequence.__iterateUncached = function (fn, reverse) { - var this$1$1 = this; - - if (reverse) { - return this.cacheResult().__iterate(fn, reverse); - } - var iterations = 0; - collection.__iterate( - function (v, k, c) { return predicate.call(context, v, k, c) && ++iterations && fn(v, k, this$1$1); } - ); - return iterations; - }; - takeSequence.__iteratorUncached = function (type, reverse) { - var this$1$1 = this; - - if (reverse) { - return this.cacheResult().__iterator(type, reverse); - } - var iterator = collection.__iterator(ITERATE_ENTRIES, reverse); - var iterating = true; - return new Iterator(function () { - if (!iterating) { - return iteratorDone(); - } - var step = iterator.next(); - if (step.done) { - return step; - } - var entry = step.value; - var k = entry[0]; - var v = entry[1]; - if (!predicate.call(context, v, k, this$1$1)) { - iterating = false; - return iteratorDone(); - } - return type === ITERATE_ENTRIES ? step : iteratorValue(type, k, v, step); - }); - }; - return takeSequence; -} - -function skipWhileFactory(collection, predicate, context, useKeys) { - var skipSequence = makeSequence(collection); - skipSequence.__iterateUncached = function (fn, reverse) { - var this$1$1 = this; - - if (reverse) { - return this.cacheResult().__iterate(fn, reverse); - } - var isSkipping = true; - var iterations = 0; - collection.__iterate(function (v, k, c) { - if (!(isSkipping && (isSkipping = predicate.call(context, v, k, c)))) { - iterations++; - return fn(v, useKeys ? k : iterations - 1, this$1$1); - } - }); - return iterations; - }; - skipSequence.__iteratorUncached = function (type, reverse) { - var this$1$1 = this; - - if (reverse) { - return this.cacheResult().__iterator(type, reverse); - } - var iterator = collection.__iterator(ITERATE_ENTRIES, reverse); - var skipping = true; - var iterations = 0; - return new Iterator(function () { - var step; - var k; - var v; - do { - step = iterator.next(); - if (step.done) { - if (useKeys || type === ITERATE_VALUES) { - return step; - } - if (type === ITERATE_KEYS) { - return iteratorValue(type, iterations++, undefined, step); - } - return iteratorValue(type, iterations++, step.value[1], step); - } - var entry = step.value; - k = entry[0]; - v = entry[1]; - skipping && (skipping = predicate.call(context, v, k, this$1$1)); - } while (skipping); - return type === ITERATE_ENTRIES ? step : iteratorValue(type, k, v, step); - }); - }; - return skipSequence; -} - -function concatFactory(collection, values) { - var isKeyedCollection = isKeyed(collection); - var iters = [collection] - .concat(values) - .map(function (v) { - if (!isCollection(v)) { - v = isKeyedCollection - ? keyedSeqFromValue(v) - : indexedSeqFromValue(Array.isArray(v) ? v : [v]); - } else if (isKeyedCollection) { - v = KeyedCollection(v); - } - return v; - }) - .filter(function (v) { return v.size !== 0; }); - - if (iters.length === 0) { - return collection; - } - - if (iters.length === 1) { - var singleton = iters[0]; - if ( - singleton === collection || - (isKeyedCollection && isKeyed(singleton)) || - (isIndexed(collection) && isIndexed(singleton)) - ) { - return singleton; - } - } - - var concatSeq = new ArraySeq(iters); - if (isKeyedCollection) { - concatSeq = concatSeq.toKeyedSeq(); - } else if (!isIndexed(collection)) { - concatSeq = concatSeq.toSetSeq(); - } - concatSeq = concatSeq.flatten(true); - concatSeq.size = iters.reduce(function (sum, seq) { - if (sum !== undefined) { - var size = seq.size; - if (size !== undefined) { - return sum + size; - } - } - }, 0); - return concatSeq; -} - -function flattenFactory(collection, depth, useKeys) { - var flatSequence = makeSequence(collection); - flatSequence.__iterateUncached = function (fn, reverse) { - if (reverse) { - return this.cacheResult().__iterate(fn, reverse); - } - var iterations = 0; - var stopped = false; - function flatDeep(iter, currentDepth) { - iter.__iterate(function (v, k) { - if ((!depth || currentDepth < depth) && isCollection(v)) { - flatDeep(v, currentDepth + 1); - } else { - iterations++; - if (fn(v, useKeys ? k : iterations - 1, flatSequence) === false) { - stopped = true; - } - } - return !stopped; - }, reverse); - } - flatDeep(collection, 0); - return iterations; - }; - flatSequence.__iteratorUncached = function (type, reverse) { - if (reverse) { - return this.cacheResult().__iterator(type, reverse); - } - var iterator = collection.__iterator(type, reverse); - var stack = []; - var iterations = 0; - return new Iterator(function () { - while (iterator) { - var step = iterator.next(); - if (step.done !== false) { - iterator = stack.pop(); - continue; - } - var v = step.value; - if (type === ITERATE_ENTRIES) { - v = v[1]; - } - if ((!depth || stack.length < depth) && isCollection(v)) { - stack.push(iterator); - iterator = v.__iterator(type, reverse); - } else { - return useKeys ? step : iteratorValue(type, iterations++, v, step); - } - } - return iteratorDone(); - }); - }; - return flatSequence; -} - -function flatMapFactory(collection, mapper, context) { - var coerce = collectionClass(collection); - return collection - .toSeq() - .map(function (v, k) { return coerce(mapper.call(context, v, k, collection)); }) - .flatten(true); -} - -function interposeFactory(collection, separator) { - var interposedSequence = makeSequence(collection); - interposedSequence.size = collection.size && collection.size * 2 - 1; - interposedSequence.__iterateUncached = function (fn, reverse) { - var this$1$1 = this; - - var iterations = 0; - collection.__iterate( - function (v) { return (!iterations || fn(separator, iterations++, this$1$1) !== false) && - fn(v, iterations++, this$1$1) !== false; }, - reverse - ); - return iterations; - }; - interposedSequence.__iteratorUncached = function (type, reverse) { - var iterator = collection.__iterator(ITERATE_VALUES, reverse); - var iterations = 0; - var step; - return new Iterator(function () { - if (!step || iterations % 2) { - step = iterator.next(); - if (step.done) { - return step; - } - } - return iterations % 2 - ? iteratorValue(type, iterations++, separator) - : iteratorValue(type, iterations++, step.value, step); - }); - }; - return interposedSequence; -} - -function sortFactory(collection, comparator, mapper) { - if (!comparator) { - comparator = defaultComparator; - } - var isKeyedCollection = isKeyed(collection); - var index = 0; - var entries = collection - .toSeq() - .map(function (v, k) { return [k, v, index++, mapper ? mapper(v, k, collection) : v]; }) - .valueSeq() - .toArray(); - entries - .sort(function (a, b) { return comparator(a[3], b[3]) || a[2] - b[2]; }) - .forEach( - isKeyedCollection - ? function (v, i) { - entries[i].length = 2; - } - : function (v, i) { - entries[i] = v[1]; - } - ); - return isKeyedCollection - ? KeyedSeq(entries) - : isIndexed(collection) - ? IndexedSeq(entries) - : SetSeq(entries); -} - -function maxFactory(collection, comparator, mapper) { - if (!comparator) { - comparator = defaultComparator; - } - if (mapper) { - var entry = collection - .toSeq() - .map(function (v, k) { return [v, mapper(v, k, collection)]; }) - .reduce(function (a, b) { return (maxCompare(comparator, a[1], b[1]) ? b : a); }); - return entry && entry[0]; - } - return collection.reduce(function (a, b) { return (maxCompare(comparator, a, b) ? b : a); }); -} - -function maxCompare(comparator, a, b) { - var comp = comparator(b, a); - // b is considered the new max if the comparator declares them equal, but - // they are not equal and b is in fact a nullish value. - return ( - (comp === 0 && b !== a && (b === undefined || b === null || b !== b)) || - comp > 0 - ); -} - -function zipWithFactory(keyIter, zipper, iters, zipAll) { - var zipSequence = makeSequence(keyIter); - var sizes = new ArraySeq(iters).map(function (i) { return i.size; }); - zipSequence.size = zipAll ? sizes.max() : sizes.min(); - // Note: this a generic base implementation of __iterate in terms of - // __iterator which may be more generically useful in the future. - zipSequence.__iterate = function (fn, reverse) { - /* generic: - var iterator = this.__iterator(ITERATE_ENTRIES, reverse); - var step; - var iterations = 0; - while (!(step = iterator.next()).done) { - iterations++; - if (fn(step.value[1], step.value[0], this) === false) { - break; - } - } - return iterations; - */ - // indexed: - var iterator = this.__iterator(ITERATE_VALUES, reverse); - var step; - var iterations = 0; - while (!(step = iterator.next()).done) { - if (fn(step.value, iterations++, this) === false) { - break; - } - } - return iterations; - }; - zipSequence.__iteratorUncached = function (type, reverse) { - var iterators = iters.map( - function (i) { return ((i = Collection(i)), getIterator(reverse ? i.reverse() : i)); } - ); - var iterations = 0; - var isDone = false; - return new Iterator(function () { - var steps; - if (!isDone) { - steps = iterators.map(function (i) { return i.next(); }); - isDone = zipAll ? steps.every(function (s) { return s.done; }) : steps.some(function (s) { return s.done; }); - } - if (isDone) { - return iteratorDone(); - } - return iteratorValue( - type, - iterations++, - zipper.apply( - null, - steps.map(function (s) { return s.value; }) - ) - ); - }); - }; - return zipSequence; -} - -// #pragma Helper Functions - -function reify(iter, seq) { - return iter === seq ? iter : isSeq(iter) ? seq : iter.constructor(seq); -} - -function validateEntry(entry) { - if (entry !== Object(entry)) { - throw new TypeError('Expected [K, V] tuple: ' + entry); - } -} - -function collectionClass(collection) { - return isKeyed(collection) - ? KeyedCollection - : isIndexed(collection) - ? IndexedCollection - : SetCollection; -} - -function makeSequence(collection) { - return Object.create( - (isKeyed(collection) - ? KeyedSeq - : isIndexed(collection) - ? IndexedSeq - : SetSeq - ).prototype - ); -} - -function cacheResultThrough() { - if (this._iter.cacheResult) { - this._iter.cacheResult(); - this.size = this._iter.size; - return this; - } - return Seq.prototype.cacheResult.call(this); -} - -function defaultComparator(a, b) { - if (a === undefined && b === undefined) { - return 0; - } - - if (a === undefined) { - return 1; - } - - if (b === undefined) { - return -1; - } - - return a > b ? 1 : a < b ? -1 : 0; -} - -function arrCopy(arr, offset) { - offset = offset || 0; - var len = Math.max(0, arr.length - offset); - var newArr = new Array(len); - for (var ii = 0; ii < len; ii++) { - newArr[ii] = arr[ii + offset]; - } - return newArr; -} - -function invariant(condition, error) { - if (!condition) { throw new Error(error); } -} - -function assertNotInfinite(size) { - invariant( - size !== Infinity, - 'Cannot perform this action with an infinite size.' - ); -} - -function coerceKeyPath(keyPath) { - if (isArrayLike(keyPath) && typeof keyPath !== 'string') { - return keyPath; - } - if (isOrdered(keyPath)) { - return keyPath.toArray(); - } - throw new TypeError( - 'Invalid keyPath: expected Ordered Collection or Array: ' + keyPath - ); -} - -var toString = Object.prototype.toString; - -function isPlainObject(value) { - // The base prototype's toString deals with Argument objects and native namespaces like Math - if ( - !value || - typeof value !== 'object' || - toString.call(value) !== '[object Object]' - ) { - return false; - } - - var proto = Object.getPrototypeOf(value); - if (proto === null) { - return true; - } - - // Iteratively going up the prototype chain is needed for cross-realm environments (differing contexts, iframes, etc) - var parentProto = proto; - var nextProto = Object.getPrototypeOf(proto); - while (nextProto !== null) { - parentProto = nextProto; - nextProto = Object.getPrototypeOf(parentProto); - } - return parentProto === proto; -} - -/** - * Returns true if the value is a potentially-persistent data structure, either - * provided by Immutable.js or a plain Array or Object. - */ -function isDataStructure(value) { - return ( - typeof value === 'object' && - (isImmutable(value) || Array.isArray(value) || isPlainObject(value)) - ); -} - -function quoteString(value) { - try { - return typeof value === 'string' ? JSON.stringify(value) : String(value); - } catch (_ignoreError) { - return JSON.stringify(value); - } -} - -function has(collection, key) { - return isImmutable(collection) - ? collection.has(key) - : isDataStructure(collection) && hasOwnProperty.call(collection, key); -} - -function get(collection, key, notSetValue) { - return isImmutable(collection) - ? collection.get(key, notSetValue) - : !has(collection, key) - ? notSetValue - : typeof collection.get === 'function' - ? collection.get(key) - : collection[key]; -} - -function shallowCopy(from) { - if (Array.isArray(from)) { - return arrCopy(from); - } - var to = {}; - for (var key in from) { - if (hasOwnProperty.call(from, key)) { - to[key] = from[key]; - } - } - return to; -} - -function remove(collection, key) { - if (!isDataStructure(collection)) { - throw new TypeError( - 'Cannot update non-data-structure value: ' + collection - ); - } - if (isImmutable(collection)) { - if (!collection.remove) { - throw new TypeError( - 'Cannot update immutable value without .remove() method: ' + collection - ); - } - return collection.remove(key); - } - if (!hasOwnProperty.call(collection, key)) { - return collection; - } - var collectionCopy = shallowCopy(collection); - if (Array.isArray(collectionCopy)) { - collectionCopy.splice(key, 1); - } else { - delete collectionCopy[key]; - } - return collectionCopy; -} - -function set(collection, key, value) { - if (!isDataStructure(collection)) { - throw new TypeError( - 'Cannot update non-data-structure value: ' + collection - ); - } - if (isImmutable(collection)) { - if (!collection.set) { - throw new TypeError( - 'Cannot update immutable value without .set() method: ' + collection - ); - } - return collection.set(key, value); - } - if (hasOwnProperty.call(collection, key) && value === collection[key]) { - return collection; - } - var collectionCopy = shallowCopy(collection); - collectionCopy[key] = value; - return collectionCopy; -} - -function updateIn$1(collection, keyPath, notSetValue, updater) { - if (!updater) { - updater = notSetValue; - notSetValue = undefined; - } - var updatedValue = updateInDeeply( - isImmutable(collection), - collection, - coerceKeyPath(keyPath), - 0, - notSetValue, - updater - ); - return updatedValue === NOT_SET ? notSetValue : updatedValue; -} - -function updateInDeeply( - inImmutable, - existing, - keyPath, - i, - notSetValue, - updater -) { - var wasNotSet = existing === NOT_SET; - if (i === keyPath.length) { - var existingValue = wasNotSet ? notSetValue : existing; - var newValue = updater(existingValue); - return newValue === existingValue ? existing : newValue; - } - if (!wasNotSet && !isDataStructure(existing)) { - throw new TypeError( - 'Cannot update within non-data-structure value in path [' + - keyPath.slice(0, i).map(quoteString) + - ']: ' + - existing - ); - } - var key = keyPath[i]; - var nextExisting = wasNotSet ? NOT_SET : get(existing, key, NOT_SET); - var nextUpdated = updateInDeeply( - nextExisting === NOT_SET ? inImmutable : isImmutable(nextExisting), - nextExisting, - keyPath, - i + 1, - notSetValue, - updater - ); - return nextUpdated === nextExisting - ? existing - : nextUpdated === NOT_SET - ? remove(existing, key) - : set( - wasNotSet ? (inImmutable ? emptyMap() : {}) : existing, - key, - nextUpdated - ); -} - -function setIn$1(collection, keyPath, value) { - return updateIn$1(collection, keyPath, NOT_SET, function () { return value; }); -} - -function setIn(keyPath, v) { - return setIn$1(this, keyPath, v); -} - -function removeIn(collection, keyPath) { - return updateIn$1(collection, keyPath, function () { return NOT_SET; }); -} - -function deleteIn(keyPath) { - return removeIn(this, keyPath); -} - -function update$1(collection, key, notSetValue, updater) { - return updateIn$1(collection, [key], notSetValue, updater); -} - -function update(key, notSetValue, updater) { - return arguments.length === 1 - ? key(this) - : update$1(this, key, notSetValue, updater); -} - -function updateIn(keyPath, notSetValue, updater) { - return updateIn$1(this, keyPath, notSetValue, updater); -} - -function merge$1() { - var iters = [], len = arguments.length; - while ( len-- ) iters[ len ] = arguments[ len ]; - - return mergeIntoKeyedWith(this, iters); -} - -function mergeWith$1(merger) { - var iters = [], len = arguments.length - 1; - while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; - - if (typeof merger !== 'function') { - throw new TypeError('Invalid merger function: ' + merger); - } - return mergeIntoKeyedWith(this, iters, merger); -} - -function mergeIntoKeyedWith(collection, collections, merger) { - var iters = []; - for (var ii = 0; ii < collections.length; ii++) { - var collection$1 = KeyedCollection(collections[ii]); - if (collection$1.size !== 0) { - iters.push(collection$1); - } - } - if (iters.length === 0) { - return collection; - } - if ( - collection.toSeq().size === 0 && - !collection.__ownerID && - iters.length === 1 - ) { - return collection.constructor(iters[0]); - } - return collection.withMutations(function (collection) { - var mergeIntoCollection = merger - ? function (value, key) { - update$1(collection, key, NOT_SET, function (oldVal) { return oldVal === NOT_SET ? value : merger(oldVal, value, key); } - ); - } - : function (value, key) { - collection.set(key, value); - }; - for (var ii = 0; ii < iters.length; ii++) { - iters[ii].forEach(mergeIntoCollection); - } - }); -} - -function merge(collection) { - var sources = [], len = arguments.length - 1; - while ( len-- > 0 ) sources[ len ] = arguments[ len + 1 ]; - - return mergeWithSources(collection, sources); -} - -function mergeWith(merger, collection) { - var sources = [], len = arguments.length - 2; - while ( len-- > 0 ) sources[ len ] = arguments[ len + 2 ]; - - return mergeWithSources(collection, sources, merger); -} - -function mergeDeep$1(collection) { - var sources = [], len = arguments.length - 1; - while ( len-- > 0 ) sources[ len ] = arguments[ len + 1 ]; - - return mergeDeepWithSources(collection, sources); -} - -function mergeDeepWith$1(merger, collection) { - var sources = [], len = arguments.length - 2; - while ( len-- > 0 ) sources[ len ] = arguments[ len + 2 ]; - - return mergeDeepWithSources(collection, sources, merger); -} - -function mergeDeepWithSources(collection, sources, merger) { - return mergeWithSources(collection, sources, deepMergerWith(merger)); -} - -function mergeWithSources(collection, sources, merger) { - if (!isDataStructure(collection)) { - throw new TypeError( - 'Cannot merge into non-data-structure value: ' + collection - ); - } - if (isImmutable(collection)) { - return typeof merger === 'function' && collection.mergeWith - ? collection.mergeWith.apply(collection, [ merger ].concat( sources )) - : collection.merge - ? collection.merge.apply(collection, sources) - : collection.concat.apply(collection, sources); - } - var isArray = Array.isArray(collection); - var merged = collection; - var Collection = isArray ? IndexedCollection : KeyedCollection; - var mergeItem = isArray - ? function (value) { - // Copy on write - if (merged === collection) { - merged = shallowCopy(merged); - } - merged.push(value); - } - : function (value, key) { - var hasVal = hasOwnProperty.call(merged, key); - var nextVal = - hasVal && merger ? merger(merged[key], value, key) : value; - if (!hasVal || nextVal !== merged[key]) { - // Copy on write - if (merged === collection) { - merged = shallowCopy(merged); - } - merged[key] = nextVal; - } - }; - for (var i = 0; i < sources.length; i++) { - Collection(sources[i]).forEach(mergeItem); - } - return merged; -} - -function deepMergerWith(merger) { - function deepMerger(oldValue, newValue, key) { - return isDataStructure(oldValue) && - isDataStructure(newValue) && - areMergeable(oldValue, newValue) - ? mergeWithSources(oldValue, [newValue], deepMerger) - : merger - ? merger(oldValue, newValue, key) - : newValue; - } - return deepMerger; -} - -/** - * It's unclear what the desired behavior is for merging two collections that - * fall into separate categories between keyed, indexed, or set-like, so we only - * consider them mergeable if they fall into the same category. - */ -function areMergeable(oldDataStructure, newDataStructure) { - var oldSeq = Seq(oldDataStructure); - var newSeq = Seq(newDataStructure); - // This logic assumes that a sequence can only fall into one of the three - // categories mentioned above (since there's no `isSetLike()` method). - return ( - isIndexed(oldSeq) === isIndexed(newSeq) && - isKeyed(oldSeq) === isKeyed(newSeq) - ); -} - -function mergeDeep() { - var iters = [], len = arguments.length; - while ( len-- ) iters[ len ] = arguments[ len ]; - - return mergeDeepWithSources(this, iters); -} - -function mergeDeepWith(merger) { - var iters = [], len = arguments.length - 1; - while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; - - return mergeDeepWithSources(this, iters, merger); -} - -function mergeIn(keyPath) { - var iters = [], len = arguments.length - 1; - while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; - - return updateIn$1(this, keyPath, emptyMap(), function (m) { return mergeWithSources(m, iters); }); -} - -function mergeDeepIn(keyPath) { - var iters = [], len = arguments.length - 1; - while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; - - return updateIn$1(this, keyPath, emptyMap(), function (m) { return mergeDeepWithSources(m, iters); } - ); -} - -function withMutations(fn) { - var mutable = this.asMutable(); - fn(mutable); - return mutable.wasAltered() ? mutable.__ensureOwner(this.__ownerID) : this; -} - -function asMutable() { - return this.__ownerID ? this : this.__ensureOwner(new OwnerID()); -} - -function asImmutable() { - return this.__ensureOwner(); -} - -function wasAltered() { - return this.__altered; -} - -var Map = /*@__PURE__*/(function (KeyedCollection) { - function Map(value) { - // eslint-disable-next-line no-constructor-return - return value === undefined || value === null - ? emptyMap() - : isMap(value) && !isOrdered(value) - ? value - : emptyMap().withMutations(function (map) { - var iter = KeyedCollection(value); - assertNotInfinite(iter.size); - iter.forEach(function (v, k) { return map.set(k, v); }); - }); - } - - if ( KeyedCollection ) Map.__proto__ = KeyedCollection; - Map.prototype = Object.create( KeyedCollection && KeyedCollection.prototype ); - Map.prototype.constructor = Map; - - Map.of = function of () { - var keyValues = [], len = arguments.length; - while ( len-- ) keyValues[ len ] = arguments[ len ]; - - return emptyMap().withMutations(function (map) { - for (var i = 0; i < keyValues.length; i += 2) { - if (i + 1 >= keyValues.length) { - throw new Error('Missing value for key: ' + keyValues[i]); - } - map.set(keyValues[i], keyValues[i + 1]); - } - }); - }; - - Map.prototype.toString = function toString () { - return this.__toString('Map {', '}'); - }; - - // @pragma Access - - Map.prototype.get = function get (k, notSetValue) { - return this._root - ? this._root.get(0, undefined, k, notSetValue) - : notSetValue; - }; - - // @pragma Modification - - Map.prototype.set = function set (k, v) { - return updateMap(this, k, v); - }; - - Map.prototype.remove = function remove (k) { - return updateMap(this, k, NOT_SET); - }; - - Map.prototype.deleteAll = function deleteAll (keys) { - var collection = Collection(keys); - - if (collection.size === 0) { - return this; - } - - return this.withMutations(function (map) { - collection.forEach(function (key) { return map.remove(key); }); - }); - }; - - Map.prototype.clear = function clear () { - if (this.size === 0) { - return this; - } - if (this.__ownerID) { - this.size = 0; - this._root = null; - this.__hash = undefined; - this.__altered = true; - return this; - } - return emptyMap(); - }; - - // @pragma Composition - - Map.prototype.sort = function sort (comparator) { - // Late binding - return OrderedMap(sortFactory(this, comparator)); - }; - - Map.prototype.sortBy = function sortBy (mapper, comparator) { - // Late binding - return OrderedMap(sortFactory(this, comparator, mapper)); - }; - - Map.prototype.map = function map (mapper, context) { - var this$1$1 = this; - - return this.withMutations(function (map) { - map.forEach(function (value, key) { - map.set(key, mapper.call(context, value, key, this$1$1)); - }); - }); - }; - - // @pragma Mutability - - Map.prototype.__iterator = function __iterator (type, reverse) { - return new MapIterator(this, type, reverse); - }; - - Map.prototype.__iterate = function __iterate (fn, reverse) { - var this$1$1 = this; - - var iterations = 0; - this._root && - this._root.iterate(function (entry) { - iterations++; - return fn(entry[1], entry[0], this$1$1); - }, reverse); - return iterations; - }; - - Map.prototype.__ensureOwner = function __ensureOwner (ownerID) { - if (ownerID === this.__ownerID) { - return this; - } - if (!ownerID) { - if (this.size === 0) { - return emptyMap(); - } - this.__ownerID = ownerID; - this.__altered = false; - return this; - } - return makeMap(this.size, this._root, ownerID, this.__hash); - }; - - return Map; -}(KeyedCollection)); - -Map.isMap = isMap; - -var MapPrototype = Map.prototype; -MapPrototype[IS_MAP_SYMBOL] = true; -MapPrototype[DELETE] = MapPrototype.remove; -MapPrototype.removeAll = MapPrototype.deleteAll; -MapPrototype.setIn = setIn; -MapPrototype.removeIn = MapPrototype.deleteIn = deleteIn; -MapPrototype.update = update; -MapPrototype.updateIn = updateIn; -MapPrototype.merge = MapPrototype.concat = merge$1; -MapPrototype.mergeWith = mergeWith$1; -MapPrototype.mergeDeep = mergeDeep; -MapPrototype.mergeDeepWith = mergeDeepWith; -MapPrototype.mergeIn = mergeIn; -MapPrototype.mergeDeepIn = mergeDeepIn; -MapPrototype.withMutations = withMutations; -MapPrototype.wasAltered = wasAltered; -MapPrototype.asImmutable = asImmutable; -MapPrototype['@@transducer/init'] = MapPrototype.asMutable = asMutable; -MapPrototype['@@transducer/step'] = function (result, arr) { - return result.set(arr[0], arr[1]); -}; -MapPrototype['@@transducer/result'] = function (obj) { - return obj.asImmutable(); -}; - -// #pragma Trie Nodes - -var ArrayMapNode = function ArrayMapNode(ownerID, entries) { - this.ownerID = ownerID; - this.entries = entries; -}; - -ArrayMapNode.prototype.get = function get (shift, keyHash, key, notSetValue) { - var entries = this.entries; - for (var ii = 0, len = entries.length; ii < len; ii++) { - if (is(key, entries[ii][0])) { - return entries[ii][1]; - } - } - return notSetValue; -}; - -ArrayMapNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { - var removed = value === NOT_SET; - - var entries = this.entries; - var idx = 0; - var len = entries.length; - for (; idx < len; idx++) { - if (is(key, entries[idx][0])) { - break; - } - } - var exists = idx < len; - - if (exists ? entries[idx][1] === value : removed) { - return this; - } - - SetRef(didAlter); - (removed || !exists) && SetRef(didChangeSize); - - if (removed && entries.length === 1) { - return; // undefined - } - - if (!exists && !removed && entries.length >= MAX_ARRAY_MAP_SIZE) { - return createNodes(ownerID, entries, key, value); - } - - var isEditable = ownerID && ownerID === this.ownerID; - var newEntries = isEditable ? entries : arrCopy(entries); - - if (exists) { - if (removed) { - idx === len - 1 - ? newEntries.pop() - : (newEntries[idx] = newEntries.pop()); - } else { - newEntries[idx] = [key, value]; - } - } else { - newEntries.push([key, value]); - } - - if (isEditable) { - this.entries = newEntries; - return this; - } - - return new ArrayMapNode(ownerID, newEntries); -}; - -var BitmapIndexedNode = function BitmapIndexedNode(ownerID, bitmap, nodes) { - this.ownerID = ownerID; - this.bitmap = bitmap; - this.nodes = nodes; -}; - -BitmapIndexedNode.prototype.get = function get (shift, keyHash, key, notSetValue) { - if (keyHash === undefined) { - keyHash = hash(key); - } - var bit = 1 << ((shift === 0 ? keyHash : keyHash >>> shift) & MASK); - var bitmap = this.bitmap; - return (bitmap & bit) === 0 - ? notSetValue - : this.nodes[popCount(bitmap & (bit - 1))].get( - shift + SHIFT, - keyHash, - key, - notSetValue - ); -}; - -BitmapIndexedNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { - if (keyHash === undefined) { - keyHash = hash(key); - } - var keyHashFrag = (shift === 0 ? keyHash : keyHash >>> shift) & MASK; - var bit = 1 << keyHashFrag; - var bitmap = this.bitmap; - var exists = (bitmap & bit) !== 0; - - if (!exists && value === NOT_SET) { - return this; - } - - var idx = popCount(bitmap & (bit - 1)); - var nodes = this.nodes; - var node = exists ? nodes[idx] : undefined; - var newNode = updateNode( - node, - ownerID, - shift + SHIFT, - keyHash, - key, - value, - didChangeSize, - didAlter - ); - - if (newNode === node) { - return this; - } - - if (!exists && newNode && nodes.length >= MAX_BITMAP_INDEXED_SIZE) { - return expandNodes(ownerID, nodes, bitmap, keyHashFrag, newNode); - } - - if ( - exists && - !newNode && - nodes.length === 2 && - isLeafNode(nodes[idx ^ 1]) - ) { - return nodes[idx ^ 1]; - } - - if (exists && newNode && nodes.length === 1 && isLeafNode(newNode)) { - return newNode; - } - - var isEditable = ownerID && ownerID === this.ownerID; - var newBitmap = exists ? (newNode ? bitmap : bitmap ^ bit) : bitmap | bit; - var newNodes = exists - ? newNode - ? setAt(nodes, idx, newNode, isEditable) - : spliceOut(nodes, idx, isEditable) - : spliceIn(nodes, idx, newNode, isEditable); - - if (isEditable) { - this.bitmap = newBitmap; - this.nodes = newNodes; - return this; - } - - return new BitmapIndexedNode(ownerID, newBitmap, newNodes); -}; - -var HashArrayMapNode = function HashArrayMapNode(ownerID, count, nodes) { - this.ownerID = ownerID; - this.count = count; - this.nodes = nodes; -}; - -HashArrayMapNode.prototype.get = function get (shift, keyHash, key, notSetValue) { - if (keyHash === undefined) { - keyHash = hash(key); - } - var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK; - var node = this.nodes[idx]; - return node - ? node.get(shift + SHIFT, keyHash, key, notSetValue) - : notSetValue; -}; - -HashArrayMapNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { - if (keyHash === undefined) { - keyHash = hash(key); - } - var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK; - var removed = value === NOT_SET; - var nodes = this.nodes; - var node = nodes[idx]; - - if (removed && !node) { - return this; - } - - var newNode = updateNode( - node, - ownerID, - shift + SHIFT, - keyHash, - key, - value, - didChangeSize, - didAlter - ); - if (newNode === node) { - return this; - } - - var newCount = this.count; - if (!node) { - newCount++; - } else if (!newNode) { - newCount--; - if (newCount < MIN_HASH_ARRAY_MAP_SIZE) { - return packNodes(ownerID, nodes, newCount, idx); - } - } - - var isEditable = ownerID && ownerID === this.ownerID; - var newNodes = setAt(nodes, idx, newNode, isEditable); - - if (isEditable) { - this.count = newCount; - this.nodes = newNodes; - return this; - } - - return new HashArrayMapNode(ownerID, newCount, newNodes); -}; - -var HashCollisionNode = function HashCollisionNode(ownerID, keyHash, entries) { - this.ownerID = ownerID; - this.keyHash = keyHash; - this.entries = entries; -}; - -HashCollisionNode.prototype.get = function get (shift, keyHash, key, notSetValue) { - var entries = this.entries; - for (var ii = 0, len = entries.length; ii < len; ii++) { - if (is(key, entries[ii][0])) { - return entries[ii][1]; - } - } - return notSetValue; -}; - -HashCollisionNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { - if (keyHash === undefined) { - keyHash = hash(key); - } - - var removed = value === NOT_SET; - - if (keyHash !== this.keyHash) { - if (removed) { - return this; - } - SetRef(didAlter); - SetRef(didChangeSize); - return mergeIntoNode(this, ownerID, shift, keyHash, [key, value]); - } - - var entries = this.entries; - var idx = 0; - var len = entries.length; - for (; idx < len; idx++) { - if (is(key, entries[idx][0])) { - break; - } - } - var exists = idx < len; - - if (exists ? entries[idx][1] === value : removed) { - return this; - } - - SetRef(didAlter); - (removed || !exists) && SetRef(didChangeSize); - - if (removed && len === 2) { - return new ValueNode(ownerID, this.keyHash, entries[idx ^ 1]); - } - - var isEditable = ownerID && ownerID === this.ownerID; - var newEntries = isEditable ? entries : arrCopy(entries); - - if (exists) { - if (removed) { - idx === len - 1 - ? newEntries.pop() - : (newEntries[idx] = newEntries.pop()); - } else { - newEntries[idx] = [key, value]; - } - } else { - newEntries.push([key, value]); - } - - if (isEditable) { - this.entries = newEntries; - return this; - } - - return new HashCollisionNode(ownerID, this.keyHash, newEntries); -}; - -var ValueNode = function ValueNode(ownerID, keyHash, entry) { - this.ownerID = ownerID; - this.keyHash = keyHash; - this.entry = entry; -}; - -ValueNode.prototype.get = function get (shift, keyHash, key, notSetValue) { - return is(key, this.entry[0]) ? this.entry[1] : notSetValue; -}; - -ValueNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { - var removed = value === NOT_SET; - var keyMatch = is(key, this.entry[0]); - if (keyMatch ? value === this.entry[1] : removed) { - return this; - } - - SetRef(didAlter); - - if (removed) { - SetRef(didChangeSize); - return; // undefined - } - - if (keyMatch) { - if (ownerID && ownerID === this.ownerID) { - this.entry[1] = value; - return this; - } - return new ValueNode(ownerID, this.keyHash, [key, value]); - } - - SetRef(didChangeSize); - return mergeIntoNode(this, ownerID, shift, hash(key), [key, value]); -}; - -// #pragma Iterators - -ArrayMapNode.prototype.iterate = HashCollisionNode.prototype.iterate = - function (fn, reverse) { - var entries = this.entries; - for (var ii = 0, maxIndex = entries.length - 1; ii <= maxIndex; ii++) { - if (fn(entries[reverse ? maxIndex - ii : ii]) === false) { - return false; - } - } - }; - -BitmapIndexedNode.prototype.iterate = HashArrayMapNode.prototype.iterate = - function (fn, reverse) { - var nodes = this.nodes; - for (var ii = 0, maxIndex = nodes.length - 1; ii <= maxIndex; ii++) { - var node = nodes[reverse ? maxIndex - ii : ii]; - if (node && node.iterate(fn, reverse) === false) { - return false; - } - } - }; - -// eslint-disable-next-line no-unused-vars -ValueNode.prototype.iterate = function (fn, reverse) { - return fn(this.entry); -}; - -var MapIterator = /*@__PURE__*/(function (Iterator) { - function MapIterator(map, type, reverse) { - this._type = type; - this._reverse = reverse; - this._stack = map._root && mapIteratorFrame(map._root); - } - - if ( Iterator ) MapIterator.__proto__ = Iterator; - MapIterator.prototype = Object.create( Iterator && Iterator.prototype ); - MapIterator.prototype.constructor = MapIterator; - - MapIterator.prototype.next = function next () { - var type = this._type; - var stack = this._stack; - while (stack) { - var node = stack.node; - var index = stack.index++; - var maxIndex = (void 0); - if (node.entry) { - if (index === 0) { - return mapIteratorValue(type, node.entry); - } - } else if (node.entries) { - maxIndex = node.entries.length - 1; - if (index <= maxIndex) { - return mapIteratorValue( - type, - node.entries[this._reverse ? maxIndex - index : index] - ); - } - } else { - maxIndex = node.nodes.length - 1; - if (index <= maxIndex) { - var subNode = node.nodes[this._reverse ? maxIndex - index : index]; - if (subNode) { - if (subNode.entry) { - return mapIteratorValue(type, subNode.entry); - } - stack = this._stack = mapIteratorFrame(subNode, stack); - } - continue; - } - } - stack = this._stack = this._stack.__prev; - } - return iteratorDone(); - }; - - return MapIterator; -}(Iterator)); - -function mapIteratorValue(type, entry) { - return iteratorValue(type, entry[0], entry[1]); -} - -function mapIteratorFrame(node, prev) { - return { - node: node, - index: 0, - __prev: prev, - }; -} - -function makeMap(size, root, ownerID, hash) { - var map = Object.create(MapPrototype); - map.size = size; - map._root = root; - map.__ownerID = ownerID; - map.__hash = hash; - map.__altered = false; - return map; -} - -var EMPTY_MAP; -function emptyMap() { - return EMPTY_MAP || (EMPTY_MAP = makeMap(0)); -} - -function updateMap(map, k, v) { - var newRoot; - var newSize; - if (!map._root) { - if (v === NOT_SET) { - return map; - } - newSize = 1; - newRoot = new ArrayMapNode(map.__ownerID, [[k, v]]); - } else { - var didChangeSize = MakeRef(); - var didAlter = MakeRef(); - newRoot = updateNode( - map._root, - map.__ownerID, - 0, - undefined, - k, - v, - didChangeSize, - didAlter - ); - if (!didAlter.value) { - return map; - } - newSize = map.size + (didChangeSize.value ? (v === NOT_SET ? -1 : 1) : 0); - } - if (map.__ownerID) { - map.size = newSize; - map._root = newRoot; - map.__hash = undefined; - map.__altered = true; - return map; - } - return newRoot ? makeMap(newSize, newRoot) : emptyMap(); -} - -function updateNode( - node, - ownerID, - shift, - keyHash, - key, - value, - didChangeSize, - didAlter -) { - if (!node) { - if (value === NOT_SET) { - return node; - } - SetRef(didAlter); - SetRef(didChangeSize); - return new ValueNode(ownerID, keyHash, [key, value]); - } - return node.update( - ownerID, - shift, - keyHash, - key, - value, - didChangeSize, - didAlter - ); -} - -function isLeafNode(node) { - return ( - node.constructor === ValueNode || node.constructor === HashCollisionNode - ); -} - -function mergeIntoNode(node, ownerID, shift, keyHash, entry) { - if (node.keyHash === keyHash) { - return new HashCollisionNode(ownerID, keyHash, [node.entry, entry]); - } - - var idx1 = (shift === 0 ? node.keyHash : node.keyHash >>> shift) & MASK; - var idx2 = (shift === 0 ? keyHash : keyHash >>> shift) & MASK; - - var newNode; - var nodes = - idx1 === idx2 - ? [mergeIntoNode(node, ownerID, shift + SHIFT, keyHash, entry)] - : ((newNode = new ValueNode(ownerID, keyHash, entry)), - idx1 < idx2 ? [node, newNode] : [newNode, node]); - - return new BitmapIndexedNode(ownerID, (1 << idx1) | (1 << idx2), nodes); -} - -function createNodes(ownerID, entries, key, value) { - if (!ownerID) { - ownerID = new OwnerID(); - } - var node = new ValueNode(ownerID, hash(key), [key, value]); - for (var ii = 0; ii < entries.length; ii++) { - var entry = entries[ii]; - node = node.update(ownerID, 0, undefined, entry[0], entry[1]); - } - return node; -} - -function packNodes(ownerID, nodes, count, excluding) { - var bitmap = 0; - var packedII = 0; - var packedNodes = new Array(count); - for (var ii = 0, bit = 1, len = nodes.length; ii < len; ii++, bit <<= 1) { - var node = nodes[ii]; - if (node !== undefined && ii !== excluding) { - bitmap |= bit; - packedNodes[packedII++] = node; - } - } - return new BitmapIndexedNode(ownerID, bitmap, packedNodes); -} - -function expandNodes(ownerID, nodes, bitmap, including, node) { - var count = 0; - var expandedNodes = new Array(SIZE); - for (var ii = 0; bitmap !== 0; ii++, bitmap >>>= 1) { - expandedNodes[ii] = bitmap & 1 ? nodes[count++] : undefined; - } - expandedNodes[including] = node; - return new HashArrayMapNode(ownerID, count + 1, expandedNodes); -} - -function popCount(x) { - x -= (x >> 1) & 0x55555555; - x = (x & 0x33333333) + ((x >> 2) & 0x33333333); - x = (x + (x >> 4)) & 0x0f0f0f0f; - x += x >> 8; - x += x >> 16; - return x & 0x7f; -} - -function setAt(array, idx, val, canEdit) { - var newArray = canEdit ? array : arrCopy(array); - newArray[idx] = val; - return newArray; -} - -function spliceIn(array, idx, val, canEdit) { - var newLen = array.length + 1; - if (canEdit && idx + 1 === newLen) { - array[idx] = val; - return array; - } - var newArray = new Array(newLen); - var after = 0; - for (var ii = 0; ii < newLen; ii++) { - if (ii === idx) { - newArray[ii] = val; - after = -1; - } else { - newArray[ii] = array[ii + after]; - } - } - return newArray; -} - -function spliceOut(array, idx, canEdit) { - var newLen = array.length - 1; - if (canEdit && idx === newLen) { - array.pop(); - return array; - } - var newArray = new Array(newLen); - var after = 0; - for (var ii = 0; ii < newLen; ii++) { - if (ii === idx) { - after = 1; - } - newArray[ii] = array[ii + after]; - } - return newArray; -} - -var MAX_ARRAY_MAP_SIZE = SIZE / 4; -var MAX_BITMAP_INDEXED_SIZE = SIZE / 2; -var MIN_HASH_ARRAY_MAP_SIZE = SIZE / 4; - -var IS_LIST_SYMBOL = '@@__IMMUTABLE_LIST__@@'; - -function isList(maybeList) { - return Boolean(maybeList && maybeList[IS_LIST_SYMBOL]); -} - -var List = /*@__PURE__*/(function (IndexedCollection) { - function List(value) { - var empty = emptyList(); - if (value === undefined || value === null) { - // eslint-disable-next-line no-constructor-return - return empty; - } - if (isList(value)) { - // eslint-disable-next-line no-constructor-return - return value; - } - var iter = IndexedCollection(value); - var size = iter.size; - if (size === 0) { - // eslint-disable-next-line no-constructor-return - return empty; - } - assertNotInfinite(size); - if (size > 0 && size < SIZE) { - // eslint-disable-next-line no-constructor-return - return makeList(0, size, SHIFT, null, new VNode(iter.toArray())); - } - // eslint-disable-next-line no-constructor-return - return empty.withMutations(function (list) { - list.setSize(size); - iter.forEach(function (v, i) { return list.set(i, v); }); - }); - } - - if ( IndexedCollection ) List.__proto__ = IndexedCollection; - List.prototype = Object.create( IndexedCollection && IndexedCollection.prototype ); - List.prototype.constructor = List; - - List.of = function of (/*...values*/) { - return this(arguments); - }; - - List.prototype.toString = function toString () { - return this.__toString('List [', ']'); - }; - - // @pragma Access - - List.prototype.get = function get (index, notSetValue) { - index = wrapIndex(this, index); - if (index >= 0 && index < this.size) { - index += this._origin; - var node = listNodeFor(this, index); - return node && node.array[index & MASK]; - } - return notSetValue; - }; - - // @pragma Modification - - List.prototype.set = function set (index, value) { - return updateList(this, index, value); - }; - - List.prototype.remove = function remove (index) { - return !this.has(index) - ? this - : index === 0 - ? this.shift() - : index === this.size - 1 - ? this.pop() - : this.splice(index, 1); - }; - - List.prototype.insert = function insert (index, value) { - return this.splice(index, 0, value); - }; - - List.prototype.clear = function clear () { - if (this.size === 0) { - return this; - } - if (this.__ownerID) { - this.size = this._origin = this._capacity = 0; - this._level = SHIFT; - this._root = this._tail = this.__hash = undefined; - this.__altered = true; - return this; - } - return emptyList(); - }; - - List.prototype.push = function push (/*...values*/) { - var values = arguments; - var oldSize = this.size; - return this.withMutations(function (list) { - setListBounds(list, 0, oldSize + values.length); - for (var ii = 0; ii < values.length; ii++) { - list.set(oldSize + ii, values[ii]); - } - }); - }; - - List.prototype.pop = function pop () { - return setListBounds(this, 0, -1); - }; - - List.prototype.unshift = function unshift (/*...values*/) { - var values = arguments; - return this.withMutations(function (list) { - setListBounds(list, -values.length); - for (var ii = 0; ii < values.length; ii++) { - list.set(ii, values[ii]); - } - }); - }; - - List.prototype.shift = function shift () { - return setListBounds(this, 1); - }; - - // @pragma Composition - - List.prototype.concat = function concat (/*...collections*/) { - var arguments$1 = arguments; - - var seqs = []; - for (var i = 0; i < arguments.length; i++) { - var argument = arguments$1[i]; - var seq = IndexedCollection( - typeof argument !== 'string' && hasIterator(argument) - ? argument - : [argument] - ); - if (seq.size !== 0) { - seqs.push(seq); - } - } - if (seqs.length === 0) { - return this; - } - if (this.size === 0 && !this.__ownerID && seqs.length === 1) { - return this.constructor(seqs[0]); - } - return this.withMutations(function (list) { - seqs.forEach(function (seq) { return seq.forEach(function (value) { return list.push(value); }); }); - }); - }; - - List.prototype.setSize = function setSize (size) { - return setListBounds(this, 0, size); - }; - - List.prototype.map = function map (mapper, context) { - var this$1$1 = this; - - return this.withMutations(function (list) { - for (var i = 0; i < this$1$1.size; i++) { - list.set(i, mapper.call(context, list.get(i), i, this$1$1)); - } - }); - }; - - // @pragma Iteration - - List.prototype.slice = function slice (begin, end) { - var size = this.size; - if (wholeSlice(begin, end, size)) { - return this; - } - return setListBounds( - this, - resolveBegin(begin, size), - resolveEnd(end, size) - ); - }; - - List.prototype.__iterator = function __iterator (type, reverse) { - var index = reverse ? this.size : 0; - var values = iterateList(this, reverse); - return new Iterator(function () { - var value = values(); - return value === DONE - ? iteratorDone() - : iteratorValue(type, reverse ? --index : index++, value); - }); - }; - - List.prototype.__iterate = function __iterate (fn, reverse) { - var index = reverse ? this.size : 0; - var values = iterateList(this, reverse); - var value; - while ((value = values()) !== DONE) { - if (fn(value, reverse ? --index : index++, this) === false) { - break; - } - } - return index; - }; - - List.prototype.__ensureOwner = function __ensureOwner (ownerID) { - if (ownerID === this.__ownerID) { - return this; - } - if (!ownerID) { - if (this.size === 0) { - return emptyList(); - } - this.__ownerID = ownerID; - this.__altered = false; - return this; - } - return makeList( - this._origin, - this._capacity, - this._level, - this._root, - this._tail, - ownerID, - this.__hash - ); - }; - - return List; -}(IndexedCollection)); - -List.isList = isList; - -var ListPrototype = List.prototype; -ListPrototype[IS_LIST_SYMBOL] = true; -ListPrototype[DELETE] = ListPrototype.remove; -ListPrototype.merge = ListPrototype.concat; -ListPrototype.setIn = setIn; -ListPrototype.deleteIn = ListPrototype.removeIn = deleteIn; -ListPrototype.update = update; -ListPrototype.updateIn = updateIn; -ListPrototype.mergeIn = mergeIn; -ListPrototype.mergeDeepIn = mergeDeepIn; -ListPrototype.withMutations = withMutations; -ListPrototype.wasAltered = wasAltered; -ListPrototype.asImmutable = asImmutable; -ListPrototype['@@transducer/init'] = ListPrototype.asMutable = asMutable; -ListPrototype['@@transducer/step'] = function (result, arr) { - return result.push(arr); -}; -ListPrototype['@@transducer/result'] = function (obj) { - return obj.asImmutable(); -}; - -var VNode = function VNode(array, ownerID) { - this.array = array; - this.ownerID = ownerID; -}; - -// TODO: seems like these methods are very similar - -VNode.prototype.removeBefore = function removeBefore (ownerID, level, index) { - if (index === level ? 1 << level : this.array.length === 0) { - return this; - } - var originIndex = (index >>> level) & MASK; - if (originIndex >= this.array.length) { - return new VNode([], ownerID); - } - var removingFirst = originIndex === 0; - var newChild; - if (level > 0) { - var oldChild = this.array[originIndex]; - newChild = - oldChild && oldChild.removeBefore(ownerID, level - SHIFT, index); - if (newChild === oldChild && removingFirst) { - return this; - } - } - if (removingFirst && !newChild) { - return this; - } - var editable = editableVNode(this, ownerID); - if (!removingFirst) { - for (var ii = 0; ii < originIndex; ii++) { - editable.array[ii] = undefined; - } - } - if (newChild) { - editable.array[originIndex] = newChild; - } - return editable; -}; - -VNode.prototype.removeAfter = function removeAfter (ownerID, level, index) { - if (index === (level ? 1 << level : 0) || this.array.length === 0) { - return this; - } - var sizeIndex = ((index - 1) >>> level) & MASK; - if (sizeIndex >= this.array.length) { - return this; - } - - var newChild; - if (level > 0) { - var oldChild = this.array[sizeIndex]; - newChild = - oldChild && oldChild.removeAfter(ownerID, level - SHIFT, index); - if (newChild === oldChild && sizeIndex === this.array.length - 1) { - return this; - } - } - - var editable = editableVNode(this, ownerID); - editable.array.splice(sizeIndex + 1); - if (newChild) { - editable.array[sizeIndex] = newChild; - } - return editable; -}; - -var DONE = {}; - -function iterateList(list, reverse) { - var left = list._origin; - var right = list._capacity; - var tailPos = getTailOffset(right); - var tail = list._tail; - - return iterateNodeOrLeaf(list._root, list._level, 0); - - function iterateNodeOrLeaf(node, level, offset) { - return level === 0 - ? iterateLeaf(node, offset) - : iterateNode(node, level, offset); - } - - function iterateLeaf(node, offset) { - var array = offset === tailPos ? tail && tail.array : node && node.array; - var from = offset > left ? 0 : left - offset; - var to = right - offset; - if (to > SIZE) { - to = SIZE; - } - return function () { - if (from === to) { - return DONE; - } - var idx = reverse ? --to : from++; - return array && array[idx]; - }; - } - - function iterateNode(node, level, offset) { - var values; - var array = node && node.array; - var from = offset > left ? 0 : (left - offset) >> level; - var to = ((right - offset) >> level) + 1; - if (to > SIZE) { - to = SIZE; - } - return function () { - while (true) { - if (values) { - var value = values(); - if (value !== DONE) { - return value; - } - values = null; - } - if (from === to) { - return DONE; - } - var idx = reverse ? --to : from++; - values = iterateNodeOrLeaf( - array && array[idx], - level - SHIFT, - offset + (idx << level) - ); - } - }; - } -} - -function makeList(origin, capacity, level, root, tail, ownerID, hash) { - var list = Object.create(ListPrototype); - list.size = capacity - origin; - list._origin = origin; - list._capacity = capacity; - list._level = level; - list._root = root; - list._tail = tail; - list.__ownerID = ownerID; - list.__hash = hash; - list.__altered = false; - return list; -} - -var EMPTY_LIST; -function emptyList() { - return EMPTY_LIST || (EMPTY_LIST = makeList(0, 0, SHIFT)); -} - -function updateList(list, index, value) { - index = wrapIndex(list, index); - - if (index !== index) { - return list; - } - - if (index >= list.size || index < 0) { - return list.withMutations(function (list) { - index < 0 - ? setListBounds(list, index).set(0, value) - : setListBounds(list, 0, index + 1).set(index, value); - }); - } - - index += list._origin; - - var newTail = list._tail; - var newRoot = list._root; - var didAlter = MakeRef(); - if (index >= getTailOffset(list._capacity)) { - newTail = updateVNode(newTail, list.__ownerID, 0, index, value, didAlter); - } else { - newRoot = updateVNode( - newRoot, - list.__ownerID, - list._level, - index, - value, - didAlter - ); - } - - if (!didAlter.value) { - return list; - } - - if (list.__ownerID) { - list._root = newRoot; - list._tail = newTail; - list.__hash = undefined; - list.__altered = true; - return list; - } - return makeList(list._origin, list._capacity, list._level, newRoot, newTail); -} - -function updateVNode(node, ownerID, level, index, value, didAlter) { - var idx = (index >>> level) & MASK; - var nodeHas = node && idx < node.array.length; - if (!nodeHas && value === undefined) { - return node; - } - - var newNode; - - if (level > 0) { - var lowerNode = node && node.array[idx]; - var newLowerNode = updateVNode( - lowerNode, - ownerID, - level - SHIFT, - index, - value, - didAlter - ); - if (newLowerNode === lowerNode) { - return node; - } - newNode = editableVNode(node, ownerID); - newNode.array[idx] = newLowerNode; - return newNode; - } - - if (nodeHas && node.array[idx] === value) { - return node; - } - - if (didAlter) { - SetRef(didAlter); - } - - newNode = editableVNode(node, ownerID); - if (value === undefined && idx === newNode.array.length - 1) { - newNode.array.pop(); - } else { - newNode.array[idx] = value; - } - return newNode; -} - -function editableVNode(node, ownerID) { - if (ownerID && node && ownerID === node.ownerID) { - return node; - } - return new VNode(node ? node.array.slice() : [], ownerID); -} - -function listNodeFor(list, rawIndex) { - if (rawIndex >= getTailOffset(list._capacity)) { - return list._tail; - } - if (rawIndex < 1 << (list._level + SHIFT)) { - var node = list._root; - var level = list._level; - while (node && level > 0) { - node = node.array[(rawIndex >>> level) & MASK]; - level -= SHIFT; - } - return node; - } -} - -function setListBounds(list, begin, end) { - // Sanitize begin & end using this shorthand for ToInt32(argument) - // http://www.ecma-international.org/ecma-262/6.0/#sec-toint32 - if (begin !== undefined) { - begin |= 0; - } - if (end !== undefined) { - end |= 0; - } - var owner = list.__ownerID || new OwnerID(); - var oldOrigin = list._origin; - var oldCapacity = list._capacity; - var newOrigin = oldOrigin + begin; - var newCapacity = - end === undefined - ? oldCapacity - : end < 0 - ? oldCapacity + end - : oldOrigin + end; - if (newOrigin === oldOrigin && newCapacity === oldCapacity) { - return list; - } - - // If it's going to end after it starts, it's empty. - if (newOrigin >= newCapacity) { - return list.clear(); - } - - var newLevel = list._level; - var newRoot = list._root; - - // New origin might need creating a higher root. - var offsetShift = 0; - while (newOrigin + offsetShift < 0) { - newRoot = new VNode( - newRoot && newRoot.array.length ? [undefined, newRoot] : [], - owner - ); - newLevel += SHIFT; - offsetShift += 1 << newLevel; - } - if (offsetShift) { - newOrigin += offsetShift; - oldOrigin += offsetShift; - newCapacity += offsetShift; - oldCapacity += offsetShift; - } - - var oldTailOffset = getTailOffset(oldCapacity); - var newTailOffset = getTailOffset(newCapacity); - - // New size might need creating a higher root. - while (newTailOffset >= 1 << (newLevel + SHIFT)) { - newRoot = new VNode( - newRoot && newRoot.array.length ? [newRoot] : [], - owner - ); - newLevel += SHIFT; - } - - // Locate or create the new tail. - var oldTail = list._tail; - var newTail = - newTailOffset < oldTailOffset - ? listNodeFor(list, newCapacity - 1) - : newTailOffset > oldTailOffset - ? new VNode([], owner) - : oldTail; - - // Merge Tail into tree. - if ( - oldTail && - newTailOffset > oldTailOffset && - newOrigin < oldCapacity && - oldTail.array.length - ) { - newRoot = editableVNode(newRoot, owner); - var node = newRoot; - for (var level = newLevel; level > SHIFT; level -= SHIFT) { - var idx = (oldTailOffset >>> level) & MASK; - node = node.array[idx] = editableVNode(node.array[idx], owner); - } - node.array[(oldTailOffset >>> SHIFT) & MASK] = oldTail; - } - - // If the size has been reduced, there's a chance the tail needs to be trimmed. - if (newCapacity < oldCapacity) { - newTail = newTail && newTail.removeAfter(owner, 0, newCapacity); - } - - // If the new origin is within the tail, then we do not need a root. - if (newOrigin >= newTailOffset) { - newOrigin -= newTailOffset; - newCapacity -= newTailOffset; - newLevel = SHIFT; - newRoot = null; - newTail = newTail && newTail.removeBefore(owner, 0, newOrigin); - - // Otherwise, if the root has been trimmed, garbage collect. - } else if (newOrigin > oldOrigin || newTailOffset < oldTailOffset) { - offsetShift = 0; - - // Identify the new top root node of the subtree of the old root. - while (newRoot) { - var beginIndex = (newOrigin >>> newLevel) & MASK; - if ((beginIndex !== newTailOffset >>> newLevel) & MASK) { - break; - } - if (beginIndex) { - offsetShift += (1 << newLevel) * beginIndex; - } - newLevel -= SHIFT; - newRoot = newRoot.array[beginIndex]; - } - - // Trim the new sides of the new root. - if (newRoot && newOrigin > oldOrigin) { - newRoot = newRoot.removeBefore(owner, newLevel, newOrigin - offsetShift); - } - if (newRoot && newTailOffset < oldTailOffset) { - newRoot = newRoot.removeAfter( - owner, - newLevel, - newTailOffset - offsetShift - ); - } - if (offsetShift) { - newOrigin -= offsetShift; - newCapacity -= offsetShift; - } - } - - if (list.__ownerID) { - list.size = newCapacity - newOrigin; - list._origin = newOrigin; - list._capacity = newCapacity; - list._level = newLevel; - list._root = newRoot; - list._tail = newTail; - list.__hash = undefined; - list.__altered = true; - return list; - } - return makeList(newOrigin, newCapacity, newLevel, newRoot, newTail); -} - -function getTailOffset(size) { - return size < SIZE ? 0 : ((size - 1) >>> SHIFT) << SHIFT; -} - -var OrderedMap = /*@__PURE__*/(function (Map) { - function OrderedMap(value) { - // eslint-disable-next-line no-constructor-return - return value === undefined || value === null - ? emptyOrderedMap() - : isOrderedMap(value) - ? value - : emptyOrderedMap().withMutations(function (map) { - var iter = KeyedCollection(value); - assertNotInfinite(iter.size); - iter.forEach(function (v, k) { return map.set(k, v); }); - }); - } - - if ( Map ) OrderedMap.__proto__ = Map; - OrderedMap.prototype = Object.create( Map && Map.prototype ); - OrderedMap.prototype.constructor = OrderedMap; - - OrderedMap.of = function of (/*...values*/) { - return this(arguments); - }; - - OrderedMap.prototype.toString = function toString () { - return this.__toString('OrderedMap {', '}'); - }; - - // @pragma Access - - OrderedMap.prototype.get = function get (k, notSetValue) { - var index = this._map.get(k); - return index !== undefined ? this._list.get(index)[1] : notSetValue; - }; - - // @pragma Modification - - OrderedMap.prototype.clear = function clear () { - if (this.size === 0) { - return this; - } - if (this.__ownerID) { - this.size = 0; - this._map.clear(); - this._list.clear(); - this.__altered = true; - return this; - } - return emptyOrderedMap(); - }; - - OrderedMap.prototype.set = function set (k, v) { - return updateOrderedMap(this, k, v); - }; - - OrderedMap.prototype.remove = function remove (k) { - return updateOrderedMap(this, k, NOT_SET); - }; - - OrderedMap.prototype.__iterate = function __iterate (fn, reverse) { - var this$1$1 = this; - - return this._list.__iterate( - function (entry) { return entry && fn(entry[1], entry[0], this$1$1); }, - reverse - ); - }; - - OrderedMap.prototype.__iterator = function __iterator (type, reverse) { - return this._list.fromEntrySeq().__iterator(type, reverse); - }; - - OrderedMap.prototype.__ensureOwner = function __ensureOwner (ownerID) { - if (ownerID === this.__ownerID) { - return this; - } - var newMap = this._map.__ensureOwner(ownerID); - var newList = this._list.__ensureOwner(ownerID); - if (!ownerID) { - if (this.size === 0) { - return emptyOrderedMap(); - } - this.__ownerID = ownerID; - this.__altered = false; - this._map = newMap; - this._list = newList; - return this; - } - return makeOrderedMap(newMap, newList, ownerID, this.__hash); - }; - - return OrderedMap; -}(Map)); - -OrderedMap.isOrderedMap = isOrderedMap; - -OrderedMap.prototype[IS_ORDERED_SYMBOL] = true; -OrderedMap.prototype[DELETE] = OrderedMap.prototype.remove; - -function makeOrderedMap(map, list, ownerID, hash) { - var omap = Object.create(OrderedMap.prototype); - omap.size = map ? map.size : 0; - omap._map = map; - omap._list = list; - omap.__ownerID = ownerID; - omap.__hash = hash; - omap.__altered = false; - return omap; -} - -var EMPTY_ORDERED_MAP; -function emptyOrderedMap() { - return ( - EMPTY_ORDERED_MAP || - (EMPTY_ORDERED_MAP = makeOrderedMap(emptyMap(), emptyList())) - ); -} - -function updateOrderedMap(omap, k, v) { - var map = omap._map; - var list = omap._list; - var i = map.get(k); - var has = i !== undefined; - var newMap; - var newList; - if (v === NOT_SET) { - // removed - if (!has) { - return omap; - } - if (list.size >= SIZE && list.size >= map.size * 2) { - newList = list.filter(function (entry, idx) { return entry !== undefined && i !== idx; }); - newMap = newList - .toKeyedSeq() - .map(function (entry) { return entry[0]; }) - .flip() - .toMap(); - if (omap.__ownerID) { - newMap.__ownerID = newList.__ownerID = omap.__ownerID; - } - } else { - newMap = map.remove(k); - newList = i === list.size - 1 ? list.pop() : list.set(i, undefined); - } - } else if (has) { - if (v === list.get(i)[1]) { - return omap; - } - newMap = map; - newList = list.set(i, [k, v]); - } else { - newMap = map.set(k, list.size); - newList = list.set(list.size, [k, v]); - } - if (omap.__ownerID) { - omap.size = newMap.size; - omap._map = newMap; - omap._list = newList; - omap.__hash = undefined; - omap.__altered = true; - return omap; - } - return makeOrderedMap(newMap, newList); -} - -var IS_STACK_SYMBOL = '@@__IMMUTABLE_STACK__@@'; - -function isStack(maybeStack) { - return Boolean(maybeStack && maybeStack[IS_STACK_SYMBOL]); -} - -var Stack = /*@__PURE__*/(function (IndexedCollection) { - function Stack(value) { - // eslint-disable-next-line no-constructor-return - return value === undefined || value === null - ? emptyStack() - : isStack(value) - ? value - : emptyStack().pushAll(value); - } - - if ( IndexedCollection ) Stack.__proto__ = IndexedCollection; - Stack.prototype = Object.create( IndexedCollection && IndexedCollection.prototype ); - Stack.prototype.constructor = Stack; - - Stack.of = function of (/*...values*/) { - return this(arguments); - }; - - Stack.prototype.toString = function toString () { - return this.__toString('Stack [', ']'); - }; - - // @pragma Access - - Stack.prototype.get = function get (index, notSetValue) { - var head = this._head; - index = wrapIndex(this, index); - while (head && index--) { - head = head.next; - } - return head ? head.value : notSetValue; - }; - - Stack.prototype.peek = function peek () { - return this._head && this._head.value; - }; - - // @pragma Modification - - Stack.prototype.push = function push (/*...values*/) { - var arguments$1 = arguments; - - if (arguments.length === 0) { - return this; - } - var newSize = this.size + arguments.length; - var head = this._head; - for (var ii = arguments.length - 1; ii >= 0; ii--) { - head = { - value: arguments$1[ii], - next: head, - }; - } - if (this.__ownerID) { - this.size = newSize; - this._head = head; - this.__hash = undefined; - this.__altered = true; - return this; - } - return makeStack(newSize, head); - }; - - Stack.prototype.pushAll = function pushAll (iter) { - iter = IndexedCollection(iter); - if (iter.size === 0) { - return this; - } - if (this.size === 0 && isStack(iter)) { - return iter; - } - assertNotInfinite(iter.size); - var newSize = this.size; - var head = this._head; - iter.__iterate(function (value) { - newSize++; - head = { - value: value, - next: head, - }; - }, /* reverse */ true); - if (this.__ownerID) { - this.size = newSize; - this._head = head; - this.__hash = undefined; - this.__altered = true; - return this; - } - return makeStack(newSize, head); - }; - - Stack.prototype.pop = function pop () { - return this.slice(1); - }; - - Stack.prototype.clear = function clear () { - if (this.size === 0) { - return this; - } - if (this.__ownerID) { - this.size = 0; - this._head = undefined; - this.__hash = undefined; - this.__altered = true; - return this; - } - return emptyStack(); - }; - - Stack.prototype.slice = function slice (begin, end) { - if (wholeSlice(begin, end, this.size)) { - return this; - } - var resolvedBegin = resolveBegin(begin, this.size); - var resolvedEnd = resolveEnd(end, this.size); - if (resolvedEnd !== this.size) { - // super.slice(begin, end); - return IndexedCollection.prototype.slice.call(this, begin, end); - } - var newSize = this.size - resolvedBegin; - var head = this._head; - while (resolvedBegin--) { - head = head.next; - } - if (this.__ownerID) { - this.size = newSize; - this._head = head; - this.__hash = undefined; - this.__altered = true; - return this; - } - return makeStack(newSize, head); - }; - - // @pragma Mutability - - Stack.prototype.__ensureOwner = function __ensureOwner (ownerID) { - if (ownerID === this.__ownerID) { - return this; - } - if (!ownerID) { - if (this.size === 0) { - return emptyStack(); - } - this.__ownerID = ownerID; - this.__altered = false; - return this; - } - return makeStack(this.size, this._head, ownerID, this.__hash); - }; - - // @pragma Iteration - - Stack.prototype.__iterate = function __iterate (fn, reverse) { - var this$1$1 = this; - - if (reverse) { - return new ArraySeq(this.toArray()).__iterate( - function (v, k) { return fn(v, k, this$1$1); }, - reverse - ); - } - var iterations = 0; - var node = this._head; - while (node) { - if (fn(node.value, iterations++, this) === false) { - break; - } - node = node.next; - } - return iterations; - }; - - Stack.prototype.__iterator = function __iterator (type, reverse) { - if (reverse) { - return new ArraySeq(this.toArray()).__iterator(type, reverse); - } - var iterations = 0; - var node = this._head; - return new Iterator(function () { - if (node) { - var value = node.value; - node = node.next; - return iteratorValue(type, iterations++, value); - } - return iteratorDone(); - }); - }; - - return Stack; -}(IndexedCollection)); - -Stack.isStack = isStack; - -var StackPrototype = Stack.prototype; -StackPrototype[IS_STACK_SYMBOL] = true; -StackPrototype.shift = StackPrototype.pop; -StackPrototype.unshift = StackPrototype.push; -StackPrototype.unshiftAll = StackPrototype.pushAll; -StackPrototype.withMutations = withMutations; -StackPrototype.wasAltered = wasAltered; -StackPrototype.asImmutable = asImmutable; -StackPrototype['@@transducer/init'] = StackPrototype.asMutable = asMutable; -StackPrototype['@@transducer/step'] = function (result, arr) { - return result.unshift(arr); -}; -StackPrototype['@@transducer/result'] = function (obj) { - return obj.asImmutable(); -}; - -function makeStack(size, head, ownerID, hash) { - var map = Object.create(StackPrototype); - map.size = size; - map._head = head; - map.__ownerID = ownerID; - map.__hash = hash; - map.__altered = false; - return map; -} - -var EMPTY_STACK; -function emptyStack() { - return EMPTY_STACK || (EMPTY_STACK = makeStack(0)); -} - -var IS_SET_SYMBOL = '@@__IMMUTABLE_SET__@@'; - -function isSet(maybeSet) { - return Boolean(maybeSet && maybeSet[IS_SET_SYMBOL]); -} - -function isOrderedSet(maybeOrderedSet) { - return isSet(maybeOrderedSet) && isOrdered(maybeOrderedSet); -} - -function deepEqual(a, b) { - if (a === b) { - return true; - } - - if ( - !isCollection(b) || - (a.size !== undefined && b.size !== undefined && a.size !== b.size) || - (a.__hash !== undefined && - b.__hash !== undefined && - a.__hash !== b.__hash) || - isKeyed(a) !== isKeyed(b) || - isIndexed(a) !== isIndexed(b) || - isOrdered(a) !== isOrdered(b) - ) { - return false; - } - - if (a.size === 0 && b.size === 0) { - return true; - } - - var notAssociative = !isAssociative(a); - - if (isOrdered(a)) { - var entries = a.entries(); - return ( - b.every(function (v, k) { - var entry = entries.next().value; - return entry && is(entry[1], v) && (notAssociative || is(entry[0], k)); - }) && entries.next().done - ); - } - - var flipped = false; - - if (a.size === undefined) { - if (b.size === undefined) { - if (typeof a.cacheResult === 'function') { - a.cacheResult(); - } - } else { - flipped = true; - var _ = a; - a = b; - b = _; - } - } - - var allEqual = true; - var bSize = b.__iterate(function (v, k) { - if ( - notAssociative - ? !a.has(v) - : flipped - ? !is(v, a.get(k, NOT_SET)) - : !is(a.get(k, NOT_SET), v) - ) { - allEqual = false; - return false; - } - }); - - return allEqual && a.size === bSize; -} - -function mixin(ctor, methods) { - var keyCopier = function (key) { - ctor.prototype[key] = methods[key]; - }; - Object.keys(methods).forEach(keyCopier); - Object.getOwnPropertySymbols && - Object.getOwnPropertySymbols(methods).forEach(keyCopier); - return ctor; -} - -function toJS(value) { - if (!value || typeof value !== 'object') { - return value; - } - if (!isCollection(value)) { - if (!isDataStructure(value)) { - return value; - } - value = Seq(value); - } - if (isKeyed(value)) { - var result$1 = {}; - value.__iterate(function (v, k) { - result$1[k] = toJS(v); - }); - return result$1; - } - var result = []; - value.__iterate(function (v) { - result.push(toJS(v)); - }); - return result; -} - -var Set = /*@__PURE__*/(function (SetCollection) { - function Set(value) { - // eslint-disable-next-line no-constructor-return - return value === undefined || value === null - ? emptySet() - : isSet(value) && !isOrdered(value) - ? value - : emptySet().withMutations(function (set) { - var iter = SetCollection(value); - assertNotInfinite(iter.size); - iter.forEach(function (v) { return set.add(v); }); - }); - } - - if ( SetCollection ) Set.__proto__ = SetCollection; - Set.prototype = Object.create( SetCollection && SetCollection.prototype ); - Set.prototype.constructor = Set; - - Set.of = function of (/*...values*/) { - return this(arguments); - }; - - Set.fromKeys = function fromKeys (value) { - return this(KeyedCollection(value).keySeq()); - }; - - Set.intersect = function intersect (sets) { - sets = Collection(sets).toArray(); - return sets.length - ? SetPrototype.intersect.apply(Set(sets.pop()), sets) - : emptySet(); - }; - - Set.union = function union (sets) { - sets = Collection(sets).toArray(); - return sets.length - ? SetPrototype.union.apply(Set(sets.pop()), sets) - : emptySet(); - }; - - Set.prototype.toString = function toString () { - return this.__toString('Set {', '}'); - }; - - // @pragma Access - - Set.prototype.has = function has (value) { - return this._map.has(value); - }; - - // @pragma Modification - - Set.prototype.add = function add (value) { - return updateSet(this, this._map.set(value, value)); - }; - - Set.prototype.remove = function remove (value) { - return updateSet(this, this._map.remove(value)); - }; - - Set.prototype.clear = function clear () { - return updateSet(this, this._map.clear()); - }; - - // @pragma Composition - - Set.prototype.map = function map (mapper, context) { - var this$1$1 = this; - - // keep track if the set is altered by the map function - var didChanges = false; - - var newMap = updateSet( - this, - this._map.mapEntries(function (ref) { - var v = ref[1]; - - var mapped = mapper.call(context, v, v, this$1$1); - - if (mapped !== v) { - didChanges = true; - } - - return [mapped, mapped]; - }, context) - ); - - return didChanges ? newMap : this; - }; - - Set.prototype.union = function union () { - var iters = [], len = arguments.length; - while ( len-- ) iters[ len ] = arguments[ len ]; - - iters = iters.filter(function (x) { return x.size !== 0; }); - if (iters.length === 0) { - return this; - } - if (this.size === 0 && !this.__ownerID && iters.length === 1) { - return this.constructor(iters[0]); - } - return this.withMutations(function (set) { - for (var ii = 0; ii < iters.length; ii++) { - if (typeof iters[ii] === 'string') { - set.add(iters[ii]); - } else { - SetCollection(iters[ii]).forEach(function (value) { return set.add(value); }); - } - } - }); - }; - - Set.prototype.intersect = function intersect () { - var iters = [], len = arguments.length; - while ( len-- ) iters[ len ] = arguments[ len ]; - - if (iters.length === 0) { - return this; - } - iters = iters.map(function (iter) { return SetCollection(iter); }); - var toRemove = []; - this.forEach(function (value) { - if (!iters.every(function (iter) { return iter.includes(value); })) { - toRemove.push(value); - } - }); - return this.withMutations(function (set) { - toRemove.forEach(function (value) { - set.remove(value); - }); - }); - }; - - Set.prototype.subtract = function subtract () { - var iters = [], len = arguments.length; - while ( len-- ) iters[ len ] = arguments[ len ]; - - if (iters.length === 0) { - return this; - } - iters = iters.map(function (iter) { return SetCollection(iter); }); - var toRemove = []; - this.forEach(function (value) { - if (iters.some(function (iter) { return iter.includes(value); })) { - toRemove.push(value); - } - }); - return this.withMutations(function (set) { - toRemove.forEach(function (value) { - set.remove(value); - }); - }); - }; - - Set.prototype.sort = function sort (comparator) { - // Late binding - return OrderedSet(sortFactory(this, comparator)); - }; - - Set.prototype.sortBy = function sortBy (mapper, comparator) { - // Late binding - return OrderedSet(sortFactory(this, comparator, mapper)); - }; - - Set.prototype.wasAltered = function wasAltered () { - return this._map.wasAltered(); - }; - - Set.prototype.__iterate = function __iterate (fn, reverse) { - var this$1$1 = this; - - return this._map.__iterate(function (k) { return fn(k, k, this$1$1); }, reverse); - }; - - Set.prototype.__iterator = function __iterator (type, reverse) { - return this._map.__iterator(type, reverse); - }; - - Set.prototype.__ensureOwner = function __ensureOwner (ownerID) { - if (ownerID === this.__ownerID) { - return this; - } - var newMap = this._map.__ensureOwner(ownerID); - if (!ownerID) { - if (this.size === 0) { - return this.__empty(); - } - this.__ownerID = ownerID; - this._map = newMap; - return this; - } - return this.__make(newMap, ownerID); - }; - - return Set; -}(SetCollection)); - -Set.isSet = isSet; - -var SetPrototype = Set.prototype; -SetPrototype[IS_SET_SYMBOL] = true; -SetPrototype[DELETE] = SetPrototype.remove; -SetPrototype.merge = SetPrototype.concat = SetPrototype.union; -SetPrototype.withMutations = withMutations; -SetPrototype.asImmutable = asImmutable; -SetPrototype['@@transducer/init'] = SetPrototype.asMutable = asMutable; -SetPrototype['@@transducer/step'] = function (result, arr) { - return result.add(arr); -}; -SetPrototype['@@transducer/result'] = function (obj) { - return obj.asImmutable(); -}; - -SetPrototype.__empty = emptySet; -SetPrototype.__make = makeSet; - -function updateSet(set, newMap) { - if (set.__ownerID) { - set.size = newMap.size; - set._map = newMap; - return set; - } - return newMap === set._map - ? set - : newMap.size === 0 - ? set.__empty() - : set.__make(newMap); -} - -function makeSet(map, ownerID) { - var set = Object.create(SetPrototype); - set.size = map ? map.size : 0; - set._map = map; - set.__ownerID = ownerID; - return set; -} - -var EMPTY_SET; -function emptySet() { - return EMPTY_SET || (EMPTY_SET = makeSet(emptyMap())); -} - -/** - * Returns a lazy seq of nums from start (inclusive) to end - * (exclusive), by step, where start defaults to 0, step to 1, and end to - * infinity. When start is equal to end, returns empty list. - */ -var Range = /*@__PURE__*/(function (IndexedSeq) { - function Range(start, end, step) { - if (!(this instanceof Range)) { - // eslint-disable-next-line no-constructor-return - return new Range(start, end, step); - } - invariant(step !== 0, 'Cannot step a Range by 0'); - start = start || 0; - if (end === undefined) { - end = Infinity; - } - step = step === undefined ? 1 : Math.abs(step); - if (end < start) { - step = -step; - } - this._start = start; - this._end = end; - this._step = step; - this.size = Math.max(0, Math.ceil((end - start) / step - 1) + 1); - if (this.size === 0) { - if (EMPTY_RANGE) { - // eslint-disable-next-line no-constructor-return - return EMPTY_RANGE; - } - EMPTY_RANGE = this; - } - } - - if ( IndexedSeq ) Range.__proto__ = IndexedSeq; - Range.prototype = Object.create( IndexedSeq && IndexedSeq.prototype ); - Range.prototype.constructor = Range; - - Range.prototype.toString = function toString () { - if (this.size === 0) { - return 'Range []'; - } - return ( - 'Range [ ' + - this._start + - '...' + - this._end + - (this._step !== 1 ? ' by ' + this._step : '') + - ' ]' - ); - }; - - Range.prototype.get = function get (index, notSetValue) { - return this.has(index) - ? this._start + wrapIndex(this, index) * this._step - : notSetValue; - }; - - Range.prototype.includes = function includes (searchValue) { - var possibleIndex = (searchValue - this._start) / this._step; - return ( - possibleIndex >= 0 && - possibleIndex < this.size && - possibleIndex === Math.floor(possibleIndex) - ); - }; - - Range.prototype.slice = function slice (begin, end) { - if (wholeSlice(begin, end, this.size)) { - return this; - } - begin = resolveBegin(begin, this.size); - end = resolveEnd(end, this.size); - if (end <= begin) { - return new Range(0, 0); - } - return new Range( - this.get(begin, this._end), - this.get(end, this._end), - this._step - ); - }; - - Range.prototype.indexOf = function indexOf (searchValue) { - var offsetValue = searchValue - this._start; - if (offsetValue % this._step === 0) { - var index = offsetValue / this._step; - if (index >= 0 && index < this.size) { - return index; - } - } - return -1; - }; - - Range.prototype.lastIndexOf = function lastIndexOf (searchValue) { - return this.indexOf(searchValue); - }; - - Range.prototype.__iterate = function __iterate (fn, reverse) { - var size = this.size; - var step = this._step; - var value = reverse ? this._start + (size - 1) * step : this._start; - var i = 0; - while (i !== size) { - if (fn(value, reverse ? size - ++i : i++, this) === false) { - break; - } - value += reverse ? -step : step; - } - return i; - }; - - Range.prototype.__iterator = function __iterator (type, reverse) { - var size = this.size; - var step = this._step; - var value = reverse ? this._start + (size - 1) * step : this._start; - var i = 0; - return new Iterator(function () { - if (i === size) { - return iteratorDone(); - } - var v = value; - value += reverse ? -step : step; - return iteratorValue(type, reverse ? size - ++i : i++, v); - }); - }; - - Range.prototype.equals = function equals (other) { - return other instanceof Range - ? this._start === other._start && - this._end === other._end && - this._step === other._step - : deepEqual(this, other); - }; - - return Range; -}(IndexedSeq)); - -var EMPTY_RANGE; - -function getIn$1(collection, searchKeyPath, notSetValue) { - var keyPath = coerceKeyPath(searchKeyPath); - var i = 0; - while (i !== keyPath.length) { - collection = get(collection, keyPath[i++], NOT_SET); - if (collection === NOT_SET) { - return notSetValue; - } - } - return collection; -} - -function getIn(searchKeyPath, notSetValue) { - return getIn$1(this, searchKeyPath, notSetValue); -} - -function hasIn$1(collection, keyPath) { - return getIn$1(collection, keyPath, NOT_SET) !== NOT_SET; -} - -function hasIn(searchKeyPath) { - return hasIn$1(this, searchKeyPath); -} - -function toObject() { - assertNotInfinite(this.size); - var object = {}; - this.__iterate(function (v, k) { - object[k] = v; - }); - return object; -} - -// Note: all of these methods are deprecated. -Collection.isIterable = isCollection; -Collection.isKeyed = isKeyed; -Collection.isIndexed = isIndexed; -Collection.isAssociative = isAssociative; -Collection.isOrdered = isOrdered; - -Collection.Iterator = Iterator; - -mixin(Collection, { - // ### Conversion to other types - - toArray: function toArray() { - assertNotInfinite(this.size); - var array = new Array(this.size || 0); - var useTuples = isKeyed(this); - var i = 0; - this.__iterate(function (v, k) { - // Keyed collections produce an array of tuples. - array[i++] = useTuples ? [k, v] : v; - }); - return array; - }, - - toIndexedSeq: function toIndexedSeq() { - return new ToIndexedSequence(this); - }, - - toJS: function toJS$1() { - return toJS(this); - }, - - toKeyedSeq: function toKeyedSeq() { - return new ToKeyedSequence(this, true); - }, - - toMap: function toMap() { - // Use Late Binding here to solve the circular dependency. - return Map(this.toKeyedSeq()); - }, - - toObject: toObject, - - toOrderedMap: function toOrderedMap() { - // Use Late Binding here to solve the circular dependency. - return OrderedMap(this.toKeyedSeq()); - }, - - toOrderedSet: function toOrderedSet() { - // Use Late Binding here to solve the circular dependency. - return OrderedSet(isKeyed(this) ? this.valueSeq() : this); - }, - - toSet: function toSet() { - // Use Late Binding here to solve the circular dependency. - return Set(isKeyed(this) ? this.valueSeq() : this); - }, - - toSetSeq: function toSetSeq() { - return new ToSetSequence(this); - }, - - toSeq: function toSeq() { - return isIndexed(this) - ? this.toIndexedSeq() - : isKeyed(this) - ? this.toKeyedSeq() - : this.toSetSeq(); - }, - - toStack: function toStack() { - // Use Late Binding here to solve the circular dependency. - return Stack(isKeyed(this) ? this.valueSeq() : this); - }, - - toList: function toList() { - // Use Late Binding here to solve the circular dependency. - return List(isKeyed(this) ? this.valueSeq() : this); - }, - - // ### Common JavaScript methods and properties - - toString: function toString() { - return '[Collection]'; - }, - - __toString: function __toString(head, tail) { - if (this.size === 0) { - return head + tail; - } - return ( - head + - ' ' + - this.toSeq().map(this.__toStringMapper).join(', ') + - ' ' + - tail - ); - }, - - // ### ES6 Collection methods (ES6 Array and Map) - - concat: function concat() { - var values = [], len = arguments.length; - while ( len-- ) values[ len ] = arguments[ len ]; - - return reify(this, concatFactory(this, values)); - }, - - includes: function includes(searchValue) { - return this.some(function (value) { return is(value, searchValue); }); - }, - - entries: function entries() { - return this.__iterator(ITERATE_ENTRIES); - }, - - every: function every(predicate, context) { - assertNotInfinite(this.size); - var returnValue = true; - this.__iterate(function (v, k, c) { - if (!predicate.call(context, v, k, c)) { - returnValue = false; - return false; - } - }); - return returnValue; - }, - - filter: function filter(predicate, context) { - return reify(this, filterFactory(this, predicate, context, true)); - }, - - partition: function partition(predicate, context) { - return partitionFactory(this, predicate, context); - }, - - find: function find(predicate, context, notSetValue) { - var entry = this.findEntry(predicate, context); - return entry ? entry[1] : notSetValue; - }, - - forEach: function forEach(sideEffect, context) { - assertNotInfinite(this.size); - return this.__iterate(context ? sideEffect.bind(context) : sideEffect); - }, - - join: function join(separator) { - assertNotInfinite(this.size); - separator = separator !== undefined ? '' + separator : ','; - var joined = ''; - var isFirst = true; - this.__iterate(function (v) { - isFirst ? (isFirst = false) : (joined += separator); - joined += v !== null && v !== undefined ? v.toString() : ''; - }); - return joined; - }, - - keys: function keys() { - return this.__iterator(ITERATE_KEYS); - }, - - map: function map(mapper, context) { - return reify(this, mapFactory(this, mapper, context)); - }, - - reduce: function reduce$1(reducer, initialReduction, context) { - return reduce( - this, - reducer, - initialReduction, - context, - arguments.length < 2, - false - ); - }, - - reduceRight: function reduceRight(reducer, initialReduction, context) { - return reduce( - this, - reducer, - initialReduction, - context, - arguments.length < 2, - true - ); - }, - - reverse: function reverse() { - return reify(this, reverseFactory(this, true)); - }, - - slice: function slice(begin, end) { - return reify(this, sliceFactory(this, begin, end, true)); - }, - - some: function some(predicate, context) { - assertNotInfinite(this.size); - var returnValue = false; - this.__iterate(function (v, k, c) { - if (predicate.call(context, v, k, c)) { - returnValue = true; - return false; - } - }); - return returnValue; - }, - - sort: function sort(comparator) { - return reify(this, sortFactory(this, comparator)); - }, - - values: function values() { - return this.__iterator(ITERATE_VALUES); - }, - - // ### More sequential methods - - butLast: function butLast() { - return this.slice(0, -1); - }, - - isEmpty: function isEmpty() { - return this.size !== undefined ? this.size === 0 : !this.some(function () { return true; }); - }, - - count: function count(predicate, context) { - return ensureSize( - predicate ? this.toSeq().filter(predicate, context) : this - ); - }, - - countBy: function countBy(grouper, context) { - return countByFactory(this, grouper, context); - }, - - equals: function equals(other) { - return deepEqual(this, other); - }, - - entrySeq: function entrySeq() { - var collection = this; - if (collection._cache) { - // We cache as an entries array, so we can just return the cache! - return new ArraySeq(collection._cache); - } - var entriesSequence = collection.toSeq().map(entryMapper).toIndexedSeq(); - entriesSequence.fromEntrySeq = function () { return collection.toSeq(); }; - return entriesSequence; - }, - - filterNot: function filterNot(predicate, context) { - return this.filter(not(predicate), context); - }, - - findEntry: function findEntry(predicate, context, notSetValue) { - var found = notSetValue; - this.__iterate(function (v, k, c) { - if (predicate.call(context, v, k, c)) { - found = [k, v]; - return false; - } - }); - return found; - }, - - findKey: function findKey(predicate, context) { - var entry = this.findEntry(predicate, context); - return entry && entry[0]; - }, - - findLast: function findLast(predicate, context, notSetValue) { - return this.toKeyedSeq().reverse().find(predicate, context, notSetValue); - }, - - findLastEntry: function findLastEntry(predicate, context, notSetValue) { - return this.toKeyedSeq() - .reverse() - .findEntry(predicate, context, notSetValue); - }, - - findLastKey: function findLastKey(predicate, context) { - return this.toKeyedSeq().reverse().findKey(predicate, context); - }, - - first: function first(notSetValue) { - return this.find(returnTrue, null, notSetValue); - }, - - flatMap: function flatMap(mapper, context) { - return reify(this, flatMapFactory(this, mapper, context)); - }, - - flatten: function flatten(depth) { - return reify(this, flattenFactory(this, depth, true)); - }, - - fromEntrySeq: function fromEntrySeq() { - return new FromEntriesSequence(this); - }, - - get: function get(searchKey, notSetValue) { - return this.find(function (_, key) { return is(key, searchKey); }, undefined, notSetValue); - }, - - getIn: getIn, - - groupBy: function groupBy(grouper, context) { - return groupByFactory(this, grouper, context); - }, - - has: function has(searchKey) { - return this.get(searchKey, NOT_SET) !== NOT_SET; - }, - - hasIn: hasIn, - - isSubset: function isSubset(iter) { - iter = typeof iter.includes === 'function' ? iter : Collection(iter); - return this.every(function (value) { return iter.includes(value); }); - }, - - isSuperset: function isSuperset(iter) { - iter = typeof iter.isSubset === 'function' ? iter : Collection(iter); - return iter.isSubset(this); - }, - - keyOf: function keyOf(searchValue) { - return this.findKey(function (value) { return is(value, searchValue); }); - }, - - keySeq: function keySeq() { - return this.toSeq().map(keyMapper).toIndexedSeq(); - }, - - last: function last(notSetValue) { - return this.toSeq().reverse().first(notSetValue); - }, - - lastKeyOf: function lastKeyOf(searchValue) { - return this.toKeyedSeq().reverse().keyOf(searchValue); - }, - - max: function max(comparator) { - return maxFactory(this, comparator); - }, - - maxBy: function maxBy(mapper, comparator) { - return maxFactory(this, comparator, mapper); - }, - - min: function min(comparator) { - return maxFactory( - this, - comparator ? neg(comparator) : defaultNegComparator - ); - }, - - minBy: function minBy(mapper, comparator) { - return maxFactory( - this, - comparator ? neg(comparator) : defaultNegComparator, - mapper - ); - }, - - rest: function rest() { - return this.slice(1); - }, - - skip: function skip(amount) { - return amount === 0 ? this : this.slice(Math.max(0, amount)); - }, - - skipLast: function skipLast(amount) { - return amount === 0 ? this : this.slice(0, -Math.max(0, amount)); - }, - - skipWhile: function skipWhile(predicate, context) { - return reify(this, skipWhileFactory(this, predicate, context, true)); - }, - - skipUntil: function skipUntil(predicate, context) { - return this.skipWhile(not(predicate), context); - }, - - sortBy: function sortBy(mapper, comparator) { - return reify(this, sortFactory(this, comparator, mapper)); - }, - - take: function take(amount) { - return this.slice(0, Math.max(0, amount)); - }, - - takeLast: function takeLast(amount) { - return this.slice(-Math.max(0, amount)); - }, - - takeWhile: function takeWhile(predicate, context) { - return reify(this, takeWhileFactory(this, predicate, context)); - }, - - takeUntil: function takeUntil(predicate, context) { - return this.takeWhile(not(predicate), context); - }, - - update: function update(fn) { - return fn(this); - }, - - valueSeq: function valueSeq() { - return this.toIndexedSeq(); - }, - - // ### Hashable Object - - hashCode: function hashCode() { - return this.__hash || (this.__hash = hashCollection(this)); - }, - - // ### Internal - - // abstract __iterate(fn, reverse) - - // abstract __iterator(type, reverse) -}); - -var CollectionPrototype = Collection.prototype; -CollectionPrototype[IS_COLLECTION_SYMBOL] = true; -CollectionPrototype[ITERATOR_SYMBOL] = CollectionPrototype.values; -CollectionPrototype.toJSON = CollectionPrototype.toArray; -CollectionPrototype.__toStringMapper = quoteString; -CollectionPrototype.inspect = CollectionPrototype.toSource = function () { - return this.toString(); -}; -CollectionPrototype.chain = CollectionPrototype.flatMap; -CollectionPrototype.contains = CollectionPrototype.includes; - -mixin(KeyedCollection, { - // ### More sequential methods - - flip: function flip() { - return reify(this, flipFactory(this)); - }, - - mapEntries: function mapEntries(mapper, context) { - var this$1$1 = this; - - var iterations = 0; - return reify( - this, - this.toSeq() - .map(function (v, k) { return mapper.call(context, [k, v], iterations++, this$1$1); }) - .fromEntrySeq() - ); - }, - - mapKeys: function mapKeys(mapper, context) { - var this$1$1 = this; - - return reify( - this, - this.toSeq() - .flip() - .map(function (k, v) { return mapper.call(context, k, v, this$1$1); }) - .flip() - ); - }, -}); - -var KeyedCollectionPrototype = KeyedCollection.prototype; -KeyedCollectionPrototype[IS_KEYED_SYMBOL] = true; -KeyedCollectionPrototype[ITERATOR_SYMBOL] = CollectionPrototype.entries; -KeyedCollectionPrototype.toJSON = toObject; -KeyedCollectionPrototype.__toStringMapper = function (v, k) { return quoteString(k) + ': ' + quoteString(v); }; - -mixin(IndexedCollection, { - // ### Conversion to other types - - toKeyedSeq: function toKeyedSeq() { - return new ToKeyedSequence(this, false); - }, - - // ### ES6 Collection methods (ES6 Array and Map) - - filter: function filter(predicate, context) { - return reify(this, filterFactory(this, predicate, context, false)); - }, - - findIndex: function findIndex(predicate, context) { - var entry = this.findEntry(predicate, context); - return entry ? entry[0] : -1; - }, - - indexOf: function indexOf(searchValue) { - var key = this.keyOf(searchValue); - return key === undefined ? -1 : key; - }, - - lastIndexOf: function lastIndexOf(searchValue) { - var key = this.lastKeyOf(searchValue); - return key === undefined ? -1 : key; - }, - - reverse: function reverse() { - return reify(this, reverseFactory(this, false)); - }, - - slice: function slice(begin, end) { - return reify(this, sliceFactory(this, begin, end, false)); - }, - - splice: function splice(index, removeNum /*, ...values*/) { - var numArgs = arguments.length; - removeNum = Math.max(removeNum || 0, 0); - if (numArgs === 0 || (numArgs === 2 && !removeNum)) { - return this; - } - // If index is negative, it should resolve relative to the size of the - // collection. However size may be expensive to compute if not cached, so - // only call count() if the number is in fact negative. - index = resolveBegin(index, index < 0 ? this.count() : this.size); - var spliced = this.slice(0, index); - return reify( - this, - numArgs === 1 - ? spliced - : spliced.concat(arrCopy(arguments, 2), this.slice(index + removeNum)) - ); - }, - - // ### More collection methods - - findLastIndex: function findLastIndex(predicate, context) { - var entry = this.findLastEntry(predicate, context); - return entry ? entry[0] : -1; - }, - - first: function first(notSetValue) { - return this.get(0, notSetValue); - }, - - flatten: function flatten(depth) { - return reify(this, flattenFactory(this, depth, false)); - }, - - get: function get(index, notSetValue) { - index = wrapIndex(this, index); - return index < 0 || - this.size === Infinity || - (this.size !== undefined && index > this.size) - ? notSetValue - : this.find(function (_, key) { return key === index; }, undefined, notSetValue); - }, - - has: function has(index) { - index = wrapIndex(this, index); - return ( - index >= 0 && - (this.size !== undefined - ? this.size === Infinity || index < this.size - : this.indexOf(index) !== -1) - ); - }, - - interpose: function interpose(separator) { - return reify(this, interposeFactory(this, separator)); - }, - - interleave: function interleave(/*...collections*/) { - var collections = [this].concat(arrCopy(arguments)); - var zipped = zipWithFactory(this.toSeq(), IndexedSeq.of, collections); - var interleaved = zipped.flatten(true); - if (zipped.size) { - interleaved.size = zipped.size * collections.length; - } - return reify(this, interleaved); - }, - - keySeq: function keySeq() { - return Range(0, this.size); - }, - - last: function last(notSetValue) { - return this.get(-1, notSetValue); - }, - - skipWhile: function skipWhile(predicate, context) { - return reify(this, skipWhileFactory(this, predicate, context, false)); - }, - - zip: function zip(/*, ...collections */) { - var collections = [this].concat(arrCopy(arguments)); - return reify(this, zipWithFactory(this, defaultZipper, collections)); - }, - - zipAll: function zipAll(/*, ...collections */) { - var collections = [this].concat(arrCopy(arguments)); - return reify(this, zipWithFactory(this, defaultZipper, collections, true)); - }, - - zipWith: function zipWith(zipper /*, ...collections */) { - var collections = arrCopy(arguments); - collections[0] = this; - return reify(this, zipWithFactory(this, zipper, collections)); - }, -}); - -var IndexedCollectionPrototype = IndexedCollection.prototype; -IndexedCollectionPrototype[IS_INDEXED_SYMBOL] = true; -IndexedCollectionPrototype[IS_ORDERED_SYMBOL] = true; - -mixin(SetCollection, { - // ### ES6 Collection methods (ES6 Array and Map) - - get: function get(value, notSetValue) { - return this.has(value) ? value : notSetValue; - }, - - includes: function includes(value) { - return this.has(value); - }, - - // ### More sequential methods - - keySeq: function keySeq() { - return this.valueSeq(); - }, -}); - -var SetCollectionPrototype = SetCollection.prototype; -SetCollectionPrototype.has = CollectionPrototype.includes; -SetCollectionPrototype.contains = SetCollectionPrototype.includes; -SetCollectionPrototype.keys = SetCollectionPrototype.values; - -// Mixin subclasses - -mixin(KeyedSeq, KeyedCollectionPrototype); -mixin(IndexedSeq, IndexedCollectionPrototype); -mixin(SetSeq, SetCollectionPrototype); - -// #pragma Helper functions - -function reduce(collection, reducer, reduction, context, useFirst, reverse) { - assertNotInfinite(collection.size); - collection.__iterate(function (v, k, c) { - if (useFirst) { - useFirst = false; - reduction = v; - } else { - reduction = reducer.call(context, reduction, v, k, c); - } - }, reverse); - return reduction; -} - -function keyMapper(v, k) { - return k; -} - -function entryMapper(v, k) { - return [k, v]; -} - -function not(predicate) { - return function () { - return !predicate.apply(this, arguments); - }; -} - -function neg(predicate) { - return function () { - return -predicate.apply(this, arguments); - }; -} - -function defaultZipper() { - return arrCopy(arguments); -} - -function defaultNegComparator(a, b) { - return a < b ? 1 : a > b ? -1 : 0; -} - -function hashCollection(collection) { - if (collection.size === Infinity) { - return 0; - } - var ordered = isOrdered(collection); - var keyed = isKeyed(collection); - var h = ordered ? 1 : 0; - var size = collection.__iterate( - keyed - ? ordered - ? function (v, k) { - h = (31 * h + hashMerge(hash(v), hash(k))) | 0; - } - : function (v, k) { - h = (h + hashMerge(hash(v), hash(k))) | 0; - } - : ordered - ? function (v) { - h = (31 * h + hash(v)) | 0; - } - : function (v) { - h = (h + hash(v)) | 0; - } - ); - return murmurHashOfSize(size, h); -} - -function murmurHashOfSize(size, h) { - h = imul(h, 0xcc9e2d51); - h = imul((h << 15) | (h >>> -15), 0x1b873593); - h = imul((h << 13) | (h >>> -13), 5); - h = ((h + 0xe6546b64) | 0) ^ size; - h = imul(h ^ (h >>> 16), 0x85ebca6b); - h = imul(h ^ (h >>> 13), 0xc2b2ae35); - h = smi(h ^ (h >>> 16)); - return h; -} - -function hashMerge(a, b) { - return (a ^ (b + 0x9e3779b9 + (a << 6) + (a >> 2))) | 0; // int -} - -var OrderedSet = /*@__PURE__*/(function (Set) { - function OrderedSet(value) { - // eslint-disable-next-line no-constructor-return - return value === undefined || value === null - ? emptyOrderedSet() - : isOrderedSet(value) - ? value - : emptyOrderedSet().withMutations(function (set) { - var iter = SetCollection(value); - assertNotInfinite(iter.size); - iter.forEach(function (v) { return set.add(v); }); - }); - } - - if ( Set ) OrderedSet.__proto__ = Set; - OrderedSet.prototype = Object.create( Set && Set.prototype ); - OrderedSet.prototype.constructor = OrderedSet; - - OrderedSet.of = function of (/*...values*/) { - return this(arguments); - }; - - OrderedSet.fromKeys = function fromKeys (value) { - return this(KeyedCollection(value).keySeq()); - }; - - OrderedSet.prototype.toString = function toString () { - return this.__toString('OrderedSet {', '}'); - }; - - return OrderedSet; -}(Set)); - -OrderedSet.isOrderedSet = isOrderedSet; - -var OrderedSetPrototype = OrderedSet.prototype; -OrderedSetPrototype[IS_ORDERED_SYMBOL] = true; -OrderedSetPrototype.zip = IndexedCollectionPrototype.zip; -OrderedSetPrototype.zipWith = IndexedCollectionPrototype.zipWith; -OrderedSetPrototype.zipAll = IndexedCollectionPrototype.zipAll; - -OrderedSetPrototype.__empty = emptyOrderedSet; -OrderedSetPrototype.__make = makeOrderedSet; - -function makeOrderedSet(map, ownerID) { - var set = Object.create(OrderedSetPrototype); - set.size = map ? map.size : 0; - set._map = map; - set.__ownerID = ownerID; - return set; -} - -var EMPTY_ORDERED_SET; -function emptyOrderedSet() { - return ( - EMPTY_ORDERED_SET || (EMPTY_ORDERED_SET = makeOrderedSet(emptyOrderedMap())) - ); -} - -var PairSorting = { - LeftThenRight: -1, - RightThenLeft: +1, -}; - -function throwOnInvalidDefaultValues(defaultValues) { - if (isRecord(defaultValues)) { - throw new Error( - 'Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.' - ); - } - - if (isImmutable(defaultValues)) { - throw new Error( - 'Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.' - ); - } - - if (defaultValues === null || typeof defaultValues !== 'object') { - throw new Error( - 'Can not call `Record` with a non-object as default values. Use a plain javascript object instead.' - ); - } -} - -var Record = function Record(defaultValues, name) { - var hasInitialized; - - throwOnInvalidDefaultValues(defaultValues); - - var RecordType = function Record(values) { - var this$1$1 = this; - - if (values instanceof RecordType) { - return values; - } - if (!(this instanceof RecordType)) { - return new RecordType(values); - } - if (!hasInitialized) { - hasInitialized = true; - var keys = Object.keys(defaultValues); - var indices = (RecordTypePrototype._indices = {}); - // Deprecated: left to attempt not to break any external code which - // relies on a ._name property existing on record instances. - // Use Record.getDescriptiveName() instead - RecordTypePrototype._name = name; - RecordTypePrototype._keys = keys; - RecordTypePrototype._defaultValues = defaultValues; - for (var i = 0; i < keys.length; i++) { - var propName = keys[i]; - indices[propName] = i; - if (RecordTypePrototype[propName]) { - /* eslint-disable no-console */ - typeof console === 'object' && - console.warn && - console.warn( - 'Cannot define ' + - recordName(this) + - ' with property "' + - propName + - '" since that property name is part of the Record API.' - ); - /* eslint-enable no-console */ - } else { - setProp(RecordTypePrototype, propName); - } - } - } - this.__ownerID = undefined; - this._values = List().withMutations(function (l) { - l.setSize(this$1$1._keys.length); - KeyedCollection(values).forEach(function (v, k) { - l.set(this$1$1._indices[k], v === this$1$1._defaultValues[k] ? undefined : v); - }); - }); - return this; - }; - - var RecordTypePrototype = (RecordType.prototype = - Object.create(RecordPrototype)); - RecordTypePrototype.constructor = RecordType; - - if (name) { - RecordType.displayName = name; - } - - // eslint-disable-next-line no-constructor-return - return RecordType; -}; - -Record.prototype.toString = function toString () { - var str = recordName(this) + ' { '; - var keys = this._keys; - var k; - for (var i = 0, l = keys.length; i !== l; i++) { - k = keys[i]; - str += (i ? ', ' : '') + k + ': ' + quoteString(this.get(k)); - } - return str + ' }'; -}; - -Record.prototype.equals = function equals (other) { - return ( - this === other || - (isRecord(other) && recordSeq(this).equals(recordSeq(other))) - ); -}; - -Record.prototype.hashCode = function hashCode () { - return recordSeq(this).hashCode(); -}; - -// @pragma Access - -Record.prototype.has = function has (k) { - return this._indices.hasOwnProperty(k); -}; - -Record.prototype.get = function get (k, notSetValue) { - if (!this.has(k)) { - return notSetValue; - } - var index = this._indices[k]; - var value = this._values.get(index); - return value === undefined ? this._defaultValues[k] : value; -}; - -// @pragma Modification - -Record.prototype.set = function set (k, v) { - if (this.has(k)) { - var newValues = this._values.set( - this._indices[k], - v === this._defaultValues[k] ? undefined : v - ); - if (newValues !== this._values && !this.__ownerID) { - return makeRecord(this, newValues); - } - } - return this; -}; - -Record.prototype.remove = function remove (k) { - return this.set(k); -}; - -Record.prototype.clear = function clear () { - var newValues = this._values.clear().setSize(this._keys.length); - - return this.__ownerID ? this : makeRecord(this, newValues); -}; - -Record.prototype.wasAltered = function wasAltered () { - return this._values.wasAltered(); -}; - -Record.prototype.toSeq = function toSeq () { - return recordSeq(this); -}; - -Record.prototype.toJS = function toJS$1 () { - return toJS(this); -}; - -Record.prototype.entries = function entries () { - return this.__iterator(ITERATE_ENTRIES); -}; - -Record.prototype.__iterator = function __iterator (type, reverse) { - return recordSeq(this).__iterator(type, reverse); -}; - -Record.prototype.__iterate = function __iterate (fn, reverse) { - return recordSeq(this).__iterate(fn, reverse); -}; - -Record.prototype.__ensureOwner = function __ensureOwner (ownerID) { - if (ownerID === this.__ownerID) { - return this; - } - var newValues = this._values.__ensureOwner(ownerID); - if (!ownerID) { - this.__ownerID = ownerID; - this._values = newValues; - return this; - } - return makeRecord(this, newValues, ownerID); -}; - -Record.isRecord = isRecord; -Record.getDescriptiveName = recordName; -var RecordPrototype = Record.prototype; -RecordPrototype[IS_RECORD_SYMBOL] = true; -RecordPrototype[DELETE] = RecordPrototype.remove; -RecordPrototype.deleteIn = RecordPrototype.removeIn = deleteIn; -RecordPrototype.getIn = getIn; -RecordPrototype.hasIn = CollectionPrototype.hasIn; -RecordPrototype.merge = merge$1; -RecordPrototype.mergeWith = mergeWith$1; -RecordPrototype.mergeIn = mergeIn; -RecordPrototype.mergeDeep = mergeDeep; -RecordPrototype.mergeDeepWith = mergeDeepWith; -RecordPrototype.mergeDeepIn = mergeDeepIn; -RecordPrototype.setIn = setIn; -RecordPrototype.update = update; -RecordPrototype.updateIn = updateIn; -RecordPrototype.withMutations = withMutations; -RecordPrototype.asMutable = asMutable; -RecordPrototype.asImmutable = asImmutable; -RecordPrototype[ITERATOR_SYMBOL] = RecordPrototype.entries; -RecordPrototype.toJSON = RecordPrototype.toObject = - CollectionPrototype.toObject; -RecordPrototype.inspect = RecordPrototype.toSource = function () { - return this.toString(); -}; - -function makeRecord(likeRecord, values, ownerID) { - var record = Object.create(Object.getPrototypeOf(likeRecord)); - record._values = values; - record.__ownerID = ownerID; - return record; -} - -function recordName(record) { - return record.constructor.displayName || record.constructor.name || 'Record'; -} - -function recordSeq(record) { - return keyedSeqFromValue(record._keys.map(function (k) { return [k, record.get(k)]; })); -} - -function setProp(prototype, name) { - try { - Object.defineProperty(prototype, name, { - get: function () { - return this.get(name); - }, - set: function (value) { - invariant(this.__ownerID, 'Cannot set on an immutable record.'); - this.set(name, value); - }, - }); - } catch (error) { - // Object.defineProperty failed. Probably IE8. - } -} - -/** - * Returns a lazy Seq of `value` repeated `times` times. When `times` is - * undefined, returns an infinite sequence of `value`. - */ -var Repeat = /*@__PURE__*/(function (IndexedSeq) { - function Repeat(value, times) { - if (!(this instanceof Repeat)) { - // eslint-disable-next-line no-constructor-return - return new Repeat(value, times); - } - this._value = value; - this.size = times === undefined ? Infinity : Math.max(0, times); - if (this.size === 0) { - if (EMPTY_REPEAT) { - // eslint-disable-next-line no-constructor-return - return EMPTY_REPEAT; - } - EMPTY_REPEAT = this; - } - } - - if ( IndexedSeq ) Repeat.__proto__ = IndexedSeq; - Repeat.prototype = Object.create( IndexedSeq && IndexedSeq.prototype ); - Repeat.prototype.constructor = Repeat; - - Repeat.prototype.toString = function toString () { - if (this.size === 0) { - return 'Repeat []'; - } - return 'Repeat [ ' + this._value + ' ' + this.size + ' times ]'; - }; - - Repeat.prototype.get = function get (index, notSetValue) { - return this.has(index) ? this._value : notSetValue; - }; - - Repeat.prototype.includes = function includes (searchValue) { - return is(this._value, searchValue); - }; - - Repeat.prototype.slice = function slice (begin, end) { - var size = this.size; - return wholeSlice(begin, end, size) - ? this - : new Repeat( - this._value, - resolveEnd(end, size) - resolveBegin(begin, size) - ); - }; - - Repeat.prototype.reverse = function reverse () { - return this; - }; - - Repeat.prototype.indexOf = function indexOf (searchValue) { - if (is(this._value, searchValue)) { - return 0; - } - return -1; - }; - - Repeat.prototype.lastIndexOf = function lastIndexOf (searchValue) { - if (is(this._value, searchValue)) { - return this.size; - } - return -1; - }; - - Repeat.prototype.__iterate = function __iterate (fn, reverse) { - var size = this.size; - var i = 0; - while (i !== size) { - if (fn(this._value, reverse ? size - ++i : i++, this) === false) { - break; - } - } - return i; - }; - - Repeat.prototype.__iterator = function __iterator (type, reverse) { - var this$1$1 = this; - - var size = this.size; - var i = 0; - return new Iterator(function () { return i === size - ? iteratorDone() - : iteratorValue(type, reverse ? size - ++i : i++, this$1$1._value); } - ); - }; - - Repeat.prototype.equals = function equals (other) { - return other instanceof Repeat - ? is(this._value, other._value) - : deepEqual(this, other); - }; - - return Repeat; -}(IndexedSeq)); - -var EMPTY_REPEAT; - -function fromJS(value, converter) { - return fromJSWith( - [], - converter || defaultConverter, - value, - '', - converter && converter.length > 2 ? [] : undefined, - { '': value } - ); -} - -function fromJSWith(stack, converter, value, key, keyPath, parentValue) { - if ( - typeof value !== 'string' && - !isImmutable(value) && - (isArrayLike(value) || hasIterator(value) || isPlainObject(value)) - ) { - if (~stack.indexOf(value)) { - throw new TypeError('Cannot convert circular structure to Immutable'); - } - stack.push(value); - keyPath && key !== '' && keyPath.push(key); - var converted = converter.call( - parentValue, - key, - Seq(value).map(function (v, k) { return fromJSWith(stack, converter, v, k, keyPath, value); } - ), - keyPath && keyPath.slice() - ); - stack.pop(); - keyPath && keyPath.pop(); - return converted; - } - return value; -} - -function defaultConverter(k, v) { - // Effectively the opposite of "Collection.toSeq()" - return isIndexed(v) ? v.toList() : isKeyed(v) ? v.toMap() : v.toSet(); -} - -var version = "4.3.7"; - -var Immutable = { - version: version, - - Collection: Collection, - // Note: Iterable is deprecated - Iterable: Collection, - - Seq: Seq, - Map: Map, - OrderedMap: OrderedMap, - List: List, - Stack: Stack, - Set: Set, - OrderedSet: OrderedSet, - PairSorting: PairSorting, - - Record: Record, - Range: Range, - Repeat: Repeat, - - is: is, - fromJS: fromJS, - hash: hash, - - isImmutable: isImmutable, - isCollection: isCollection, - isKeyed: isKeyed, - isIndexed: isIndexed, - isAssociative: isAssociative, - isOrdered: isOrdered, - isValueObject: isValueObject, - isPlainObject: isPlainObject, - isSeq: isSeq, - isList: isList, - isMap: isMap, - isOrderedMap: isOrderedMap, - isStack: isStack, - isSet: isSet, - isOrderedSet: isOrderedSet, - isRecord: isRecord, - - get: get, - getIn: getIn$1, - has: has, - hasIn: hasIn$1, - merge: merge, - mergeDeep: mergeDeep$1, - mergeWith: mergeWith, - mergeDeepWith: mergeDeepWith$1, - remove: remove, - removeIn: removeIn, - set: set, - setIn: setIn$1, - update: update$1, - updateIn: updateIn$1, -}; - -// Note: Iterable is deprecated -var Iterable = Collection; - -export default Immutable; -export { Collection, Iterable, List, Map, OrderedMap, OrderedSet, PairSorting, Range, Record, Repeat, Seq, Set, Stack, fromJS, get, getIn$1 as getIn, has, hasIn$1 as hasIn, hash, is, isAssociative, isCollection, isImmutable, isIndexed, isKeyed, isList, isMap, isOrdered, isOrderedMap, isOrderedSet, isPlainObject, isRecord, isSeq, isSet, isStack, isValueObject, merge, mergeDeep$1 as mergeDeep, mergeDeepWith$1 as mergeDeepWith, mergeWith, remove, removeIn, set, setIn$1 as setIn, update$1 as update, updateIn$1 as updateIn, version }; diff --git a/dist/immutable.js b/dist/immutable.js index 61aa251039..d1abd9ff4f 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -1,4 +1,5 @@ /** + * @license * MIT License * * Copyright (c) 2014-present, Lee Byron and other contributors. @@ -25,8 +26,9 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Immutable = {})); -}(this, (function (exports) { 'use strict'; +})(this, (function (exports) { 'use strict'; + // Used for setting prototype methods that IE8 chokes on. var DELETE = 'delete'; // Constants describing the size of trie nodes. @@ -118,6 +120,7 @@ return value < 0 || (value === 0 && 1 / value === -Infinity); } + // Note: value is unchanged to not break immutable-devtools. var IS_COLLECTION_SYMBOL = '@@__IMMUTABLE_ITERABLE__@@'; function isCollection(maybeCollection) { @@ -1943,6 +1946,7 @@ return a > b ? 1 : a < b ? -1 : 0; } + // http://jsperf.com/copy-array-inline function arrCopy(arr, offset) { offset = offset || 0; var len = Math.max(0, arr.length - offset); @@ -2014,6 +2018,9 @@ ); } + /** + * Converts a value to a string, adding quotes if a string was provided. + */ function quoteString(value) { try { return typeof value === 'string' ? JSON.stringify(value) : String(value); @@ -2406,20 +2413,6 @@ Map.prototype = Object.create( KeyedCollection && KeyedCollection.prototype ); Map.prototype.constructor = Map; - Map.of = function of () { - var keyValues = [], len = arguments.length; - while ( len-- ) keyValues[ len ] = arguments[ len ]; - - return emptyMap().withMutations(function (map) { - for (var i = 0; i < keyValues.length; i += 2) { - if (i + 1 >= keyValues.length) { - throw new Error('Missing value for key: ' + keyValues[i]); - } - map.set(keyValues[i], keyValues[i + 1]); - } - }); - }; - Map.prototype.toString = function toString () { return this.__toString('Map {', '}'); }; @@ -2909,7 +2902,7 @@ } }; - // eslint-disable-next-line no-unused-vars + // eslint-disable-next-line @typescript-eslint/no-unused-vars ValueNode.prototype.iterate = function (fn, reverse) { return fn(this.entry); }; @@ -4305,6 +4298,9 @@ return allEqual && a.size === bSize; } + /** + * Contributes additional methods to a constructor + */ function mixin(ctor, methods) { var keyCopier = function (key) { ctor.prototype[key] = methods[key]; @@ -4588,16 +4584,23 @@ */ var Range = /*@__PURE__*/(function (IndexedSeq) { function Range(start, end, step) { + if ( step === void 0 ) step = 1; + if (!(this instanceof Range)) { // eslint-disable-next-line no-constructor-return return new Range(start, end, step); } invariant(step !== 0, 'Cannot step a Range by 0'); - start = start || 0; - if (end === undefined) { - end = Infinity; - } - step = step === undefined ? 1 : Math.abs(step); + invariant( + start !== undefined, + 'You must define a start value when using Range' + ); + invariant( + end !== undefined, + 'You must define an end value when using Range' + ); + + step = Math.abs(step); if (end < start) { step = -step; } @@ -4610,6 +4613,7 @@ // eslint-disable-next-line no-constructor-return return EMPTY_RANGE; } + // eslint-disable-next-line @typescript-eslint/no-this-alias EMPTY_RANGE = this; } } @@ -4753,13 +4757,6 @@ return object; } - // Note: all of these methods are deprecated. - Collection.isIterable = isCollection; - Collection.isKeyed = isKeyed; - Collection.isIndexed = isIndexed; - Collection.isAssociative = isAssociative; - Collection.isOrdered = isOrdered; - Collection.Iterator = Iterator; mixin(Collection, { @@ -4994,6 +4991,7 @@ }, entrySeq: function entrySeq() { + // eslint-disable-next-line @typescript-eslint/no-this-alias var collection = this; if (collection._cache) { // We cache as an entries array, so we can just return the cache! @@ -5444,7 +5442,8 @@ var ordered = isOrdered(collection); var keyed = isKeyed(collection); var h = ordered ? 1 : 0; - var size = collection.__iterate( + + collection.__iterate( keyed ? ordered ? function (v, k) { @@ -5461,7 +5460,8 @@ h = (h + hash(v)) | 0; } ); - return murmurHashOfSize(size, h); + + return murmurHashOfSize(collection.size, h); } function murmurHashOfSize(size, h) { @@ -5803,6 +5803,7 @@ // eslint-disable-next-line no-constructor-return return EMPTY_REPEAT; } + // eslint-disable-next-line @typescript-eslint/no-this-alias EMPTY_REPEAT = this; } } @@ -5928,64 +5929,7 @@ return isIndexed(v) ? v.toList() : isKeyed(v) ? v.toMap() : v.toSet(); } - var version = "4.3.7"; - - var Immutable = { - version: version, - - Collection: Collection, - // Note: Iterable is deprecated - Iterable: Collection, - - Seq: Seq, - Map: Map, - OrderedMap: OrderedMap, - List: List, - Stack: Stack, - Set: Set, - OrderedSet: OrderedSet, - PairSorting: PairSorting, - - Record: Record, - Range: Range, - Repeat: Repeat, - - is: is, - fromJS: fromJS, - hash: hash, - - isImmutable: isImmutable, - isCollection: isCollection, - isKeyed: isKeyed, - isIndexed: isIndexed, - isAssociative: isAssociative, - isOrdered: isOrdered, - isValueObject: isValueObject, - isPlainObject: isPlainObject, - isSeq: isSeq, - isList: isList, - isMap: isMap, - isOrderedMap: isOrderedMap, - isStack: isStack, - isSet: isSet, - isOrderedSet: isOrderedSet, - isRecord: isRecord, - - get: get, - getIn: getIn$1, - has: has, - hasIn: hasIn$1, - merge: merge, - mergeDeep: mergeDeep$1, - mergeWith: mergeWith, - mergeDeepWith: mergeDeepWith$1, - remove: remove, - removeIn: removeIn, - set: set, - setIn: setIn$1, - update: update$1, - updateIn: updateIn$1, - }; + var version = "5.0.0-rc.1"; // Note: Iterable is deprecated var Iterable = Collection; @@ -6003,7 +5947,6 @@ exports.Seq = Seq; exports.Set = Set; exports.Stack = Stack; - exports.default = Immutable; exports.fromJS = fromJS; exports.get = get; exports.getIn = getIn$1; @@ -6039,6 +5982,4 @@ exports.updateIn = updateIn$1; exports.version = version; - Object.defineProperty(exports, '__esModule', { value: true }); - -}))); +})); diff --git a/dist/immutable.js.flow b/dist/immutable.js.flow index 67a496f29c..22422909be 100644 --- a/dist/immutable.js.flow +++ b/dist/immutable.js.flow @@ -76,8 +76,10 @@ declare class _Collection implements ValueObject { has(key: K): boolean; includes(value: V): boolean; contains(value: V): boolean; - first(notSetValue?: NSV): V | NSV; - last(notSetValue?: NSV): V | NSV; + first(): V | void; + first(notSetValue: NSV): V | NSV; + last(): V | void; + last(notSetValue: NSV): V | NSV; hasIn(keyPath: Iterable): boolean; @@ -218,16 +220,16 @@ declare class _Collection implements ValueObject { context?: mixed ): Map; - find( + find( predicate: (value: V, key: K, iter: this) => mixed, context?: mixed, - notSetValue?: NSV - ): V | NSV; - findLast( + notSetValue?: V + ): V | void; + findLast( predicate: (value: V, key: K, iter: this) => mixed, context?: mixed, - notSetValue?: NSV - ): V | NSV; + notSetValue?: V + ): V | void; findEntry(predicate: (value: V, key: K, iter: this) => mixed): [K, V] | void; findLastEntry( diff --git a/dist/immutable.min.js b/dist/immutable.min.js index 641cdbe205..a63e28f5e5 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -1,4 +1,5 @@ /** + * @license * MIT License * * Copyright (c) 2014-present, Lee Byron and other contributors. @@ -21,35 +22,4 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).Immutable={})}(this,function(t){"use strict";var e="delete",d=5,l=1<>>0;if(""+r!==e||4294967295==r)return NaN;e=r}return e<0?c(t)+e:e}function r(){return!0}function p(t,e,r){return(0===t&&!i(t)||void 0!==r&&t<=-r)&&(void 0===e||void 0!==r&&r<=e)}function y(t,e){return n(t,e,0)}function w(t,e){return n(t,e,e)}function n(t,e,r){return void 0===t?r:i(t)?e===1/0?e:0|Math.max(0,e+t):void 0===e||e===t?t:0|Math.min(e,t)}function i(t){return t<0||0===t&&1/t==-1/0}var o="@@__IMMUTABLE_ITERABLE__@@";function f(t){return!(!t||!t[o])}var s="@@__IMMUTABLE_KEYED__@@";function a(t){return!(!t||!t[s])}var S="@@__IMMUTABLE_INDEXED__@@";function z(t){return!(!t||!t[S])}function b(t){return a(t)||z(t)}function I(t){return f(t)?t:F(t)}var O=function(t){function e(t){return a(t)?t:G(t)}return e.__proto__=t,(e.prototype=Object.create(t.prototype)).constructor=e}(I),E=function(t){function e(t){return z(t)?t:Z(t)}return e.__proto__=t,(e.prototype=Object.create(t.prototype)).constructor=e}(I),j=function(t){function e(t){return f(t)&&!b(t)?t:$(t)}return e.__proto__=t,(e.prototype=Object.create(t.prototype)).constructor=e}(I);I.Keyed=O,I.Indexed=E,I.Set=j;var q="@@__IMMUTABLE_SEQ__@@";function M(t){return!(!t||!t[q])}var D="@@__IMMUTABLE_RECORD__@@";function x(t){return!(!t||!t[D])}function A(t){return f(t)||x(t)}var k="@@__IMMUTABLE_ORDERED__@@";function R(t){return!(!t||!t[k])}var U=0,T=1,K=2,L="function"==typeof Symbol&&Symbol.iterator,C="@@iterator",B=L||C,P=function(t){this.next=t};function W(t,e,r,n){r=0===t?e:1===t?r:[e,r];return n?n.value=r:n={value:r,done:!1},n}function N(){return{value:void 0,done:!0}}function H(t){return Array.isArray(t -)||Y(t)}function J(t){return t&&"function"==typeof t.next}function V(t){var e=Y(t);return e&&e.call(t)}function Y(t){t=t&&(L&&t[L]||t[C]);if("function"==typeof t)return t}P.prototype.toString=function(){return"[Iterator]"},P.KEYS=U,P.VALUES=T,P.ENTRIES=K,P.prototype.inspect=P.prototype.toSource=function(){return""+this},P.prototype[B]=function(){return this};var Q=Object.prototype.hasOwnProperty;function X(t){return Array.isArray(t)||"string"==typeof t||t&&"object"==typeof t&&Number.isInteger(t.length)&&0<=t.length&&(0===t.length?1===Object.keys(t).length:t.hasOwnProperty(t.length-1))}var F=function(t){function e(t){return null==t?it():A(t)?t.toSeq():function(t){var e=st(t);if(e)return function(t){var e=Y(t);return e&&e===t.entries}(t)?e.fromEntrySeq():function(t){var e=Y(t);return e&&e===t.keys}(t)?e.toSetSeq():e;if("object"!=typeof t)throw new TypeError("Expected Array or collection object of values, or keyed object: "+t);return new et(t)}(t)}return e.__proto__=t,((e.prototype=Object.create(t.prototype)).constructor=e).prototype.toSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq {","}")},e.prototype.cacheResult=function(){return!this._cache&&this.__iterateUncached&&(this._cache=this.entrySeq().toArray(),this.size=this._cache.length),this},e.prototype.__iterate=function(t,e){var r=this._cache;if(r){for(var n=r.length,i=0;i!==n;){var o=r[e?n-++i:i++];if(!1===t(o[1],o[0],this))break}return i}return this.__iterateUncached(t,e)},e.prototype.__iterator=function(e,r){var n=this._cache;if(n){var i=n.length,o=0;return new P(function(){if(o===i)return N();var t=n[r?i-++o:o++];return W(e,t[0],t[1])})}return this.__iteratorUncached(e,r)},e}(I),G=function(t){function e(t){return null==t?it().toKeyedSeq():f(t)?a(t)?t.toSeq():t.fromEntrySeq():x(t)?t.toSeq():ot(t)}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).prototype.toKeyedSeq=function(){return this},e}(F),Z=function(t){function e(t){return null==t?it():f(t)?a(t)?t.entrySeq():t.toIndexedSeq():x(t -)?t.toSeq().entrySeq():ut(t)}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).of=function(){return e(arguments)},e.prototype.toIndexedSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq [","]")},e}(F),$=function(t){function e(t){return(f(t)&&!b(t)?t:Z(t)).toSetSeq()}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).of=function(){return e(arguments)},e.prototype.toSetSeq=function(){return this},e}(F);F.isSeq=M,F.Keyed=G,F.Set=$,F.Indexed=Z,F.prototype[q]=!0;var tt=function(t){function e(t){this._array=t,this.size=t.length}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).prototype.get=function(t,e){return this.has(t)?this._array[h(this,t)]:e},e.prototype.__iterate=function(t,e){for(var r=this._array,n=r.length,i=0;i!==n;){var o=e?n-++i:i++;if(!1===t(r[o],o,this))break}return i},e.prototype.__iterator=function(e,r){var n=this._array,i=n.length,o=0;return new P(function(){if(o===i)return N();var t=r?i-++o:o++;return W(e,t,n[t])})},e}(Z),et=function(t){function e(t){var e=Object.keys(t).concat(Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(t):[]);this._object=t,this._keys=e,this.size=e.length}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).prototype.get=function(t,e){return void 0===e||this.has(t)?this._object[t]:e},e.prototype.has=function(t){return Q.call(this._object,t)},e.prototype.__iterate=function(t,e){for(var r=this._object,n=this._keys,i=n.length,o=0;o!==i;){var u=n[e?i-++o:o++];if(!1===t(r[u],u,this))break}return o},e.prototype.__iterator=function(e,r){var n=this._object,i=this._keys,o=i.length,u=0;return new P(function(){if(u===o)return N();var t=i[r?o-++u:u++];return W(e,t,n[t])})},e}(G);et.prototype[k]=!0;var rt,nt=function(t){function e(t){this._collection=t,this.size=t.length||t.size}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).prototype.__iterateUncached=function(t,e){ -if(e)return this.cacheResult().__iterate(t,e);var r,n=V(this._collection),i=0;if(J(n))for(;!(r=n.next()).done&&!1!==t(r.value,i++,this););return i},e.prototype.__iteratorUncached=function(e,t){if(t)return this.cacheResult().__iterator(e,t);var r=V(this._collection);if(!J(r))return new P(N);var n=0;return new P(function(){var t=r.next();return t.done?t:W(e,n++,t.value)})},e}(Z);function it(){return rt=rt||new tt([])}function ot(t){var e=st(t);if(e)return e.fromEntrySeq();if("object"==typeof t)return new et(t);throw new TypeError("Expected Array or collection object of [k, v] entries, or keyed object: "+t)}function ut(t){var e=st(t);if(e)return e;throw new TypeError("Expected Array or collection object of values: "+t)}function st(t){return X(t)?new tt(t):H(t)?new nt(t):void 0}var at="@@__IMMUTABLE_MAP__@@";function ct(t){return!(!t||!t[at])}function ft(t){return ct(t)&&R(t)}function ht(t){return!(!t||"function"!=typeof t.equals||"function"!=typeof t.hashCode)}function _t(t,e){if(t===e||t!=t&&e!=e)return!0;if(!t||!e)return!1;if("function"==typeof t.valueOf&&"function"==typeof e.valueOf){if((t=t.valueOf())===(e=e.valueOf())||t!=t&&e!=e)return!0;if(!t||!e)return!1}return!!(ht(t)&&ht(e)&&t.equals(e))}var pt="function"==typeof Math.imul&&-2==Math.imul(4294967295,2)?Math.imul:function(t,e){var r=65535&(t|=0),n=65535&(e|=0);return r*n+((t>>>16)*n+r*(e>>>16)<<16>>>0)|0};function lt(t){return t>>>1&1073741824|3221225471&t}var vt=Object.prototype.valueOf;function yt(t){if(null==t)return dt(t);if("function"==typeof t.hashCode)return lt(t.hashCode(t));var e,r=(e=t).valueOf!==vt&&"function"==typeof e.valueOf?e.valueOf(e):e;if(null==r)return dt(r);switch(typeof r){case"boolean":return r?1108378657:1108378656;case"number":return function(t){if(t!=t||t===1/0)return 0;var e=0|t;e!==t&&(e^=4294967295*t);for(;4294967295c)return N();var t=r.next();return a||e===T||t.done?t:W(e,i-1,e===U?void 0:t.value[1],t)})},r}function Bt(e,c,f,h){var t=Xt(e);return t.__iterateUncached=function(n,t){var i=this;if(t)return this.cacheResult().__iterate(n,t);var o=!0,u=0;return e.__iterate(function(t,e,r){if(!(o=o&&c.call(f,t,e,r)))return u++,n(t,h?e:u-1,i)}),u},t.__iteratorUncached=function(i,t){var o=this;if(t)return this.cacheResult().__iterator(i,t);var u=e.__iterator(K,t),s=!0,a=0;return new P(function(){var t;do{if((t=u.next()).done)return h||i===T?t:W(i,a++,i===U?void 0:t.value[1],t);var e=t.value,r=e[0],n=e[1];s=s&&c.call(f,n,r,o)}while(s);return i===K?t:W(i,r,n,t)})},t}function Pt(t,s,a){var c=Xt(t);return c.__iterateUncached=function(i,e){if(e)return this.cacheResult().__iterate(i,e);var o=0,u=!1;return function r(t,n){t.__iterate(function(t,e){return(!s||n>>t)&g),o=this.bitmap;return 0==(o&i)?n:this.nodes[$e(o&i-1)].get(t+d,e,r,n)},Ce.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=yt(n));var s=(0===e?r:r>>>e)&g,a=1<>>=1)u[s]=1&r?e[o++]:void 0;return u[n]=i,new Be(t,o+1,u)}(t,_,c,s,u);if(f&&!u&&2===_.length&&Ge(_[1^h]))return _[1^h];if(f&&u&&1===_.length&&Ge(u))return u;s=t&&t===this.ownerID,a=f?u?c:c^a:c|a,u=f?u?tr(_,h,u,s):function(t,e,r){var n=t.length-1;if(r&&e===n)return t.pop(),t;for(var i=Array(n),o=0,u=0;u>>t)&g];return i?i.get(t+d,e,r,n):n},Be.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=yt(n));var s=(0===e?r:r>>>e)&g,a=this.nodes,c=a[s];if(i===v&&!c)return this;o=Fe(c,t,e+d,r,n,i,o,u);if(o===c)return this;u=this.count;if(c){if(!o&&--u>>r)&g,u=(0===r?n:n>>>r)&g,t=o==u?[Ze(t,e,r+d,n,i)]:(i=new We(e,n,i),o>1&1431655765))+(t>>2&858993459))+(t>>4)&252645135,t+=t>>8,127&(t+=t>>16)}function tr(t,e,r,n){t=n?t:Zt(t);return t[e]=r,t}var er=l/4,rr=l/2,nr=l/4,ir="@@__IMMUTABLE_LIST__@@";function or(t){return!(!t||!t[ir])}var ur=function(o){function t(t){var e=pr();if(null==t)return e;if(or(t))return t;var n=o(t),i=n.size;return 0===i?e:(te(i),0=gr(t._capacity)?n=lr(n,t.__ownerID,0,e,r,o):i=lr(i,t.__ownerID,t._level,e,r,o);if(!o.value)return t;if(t.__ownerID)return t._root=i,t._tail=n,t.__hash=void 0,t.__altered=!0,t;return _r(t._origin,t._capacity,t._level,i,n)}(this,t,e)},t.prototype.remove=function(t){return this.has(t)?0===t?this.shift():t===this.size-1?this.pop():this.splice(t,1):this},t.prototype.insert=function(t,e){return this.splice(t,0,e)},t.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=this._origin=this._capacity=0,this._level=d,this._root=this._tail=this.__hash=void 0,this.__altered=!0,this):pr()},t.prototype.push=function(){var r=arguments,n=this.size;return this.withMutations(function(t){dr(t,0,n+r.length);for(var e=0;e>>e&g;if(this.array.length<=n)return new ar([],t);var i=0==n;if(0>>e&g;if(this.array.length<=n)return this;if(0>e,u=1+(c-r>>e);l>>r&g,a=t&&s=gr(t._capacity))return t._tail;if(e<1<>>n&g],n-=d;return r}}function dr(t,e,r){void 0!==e&&(e|=0),void 0!==r&&(r|=0);var n=t.__ownerID||new m,i=t._origin,o=t._capacity,u=i+e,s=void 0===r?o:r<0?o+r:i+r;if(u===i&&s===o)return t;if(s<=u)return t.clear();for(var a=t._level,c=t._root,f=0;u+f<0;)c=new ar(c&&c.array.length?[void 0,c]:[],n),f+=1<<(a+=d);f&&(u+=f,i+=f,s+=f,o+=f);for(var h=gr(o),_=gr(s);1<>>l&g,p=p.array[v]=vr(p.array[v],n);p.array[h>>>d&g]=e}if(s>>a&g;if(y!=_>>>a&g)break;y&&(f+=(1<>>d<>>-15,461845907),e=pt(e<<13|e>>>-13,5),e=pt((e=(e+3864292196|0)^t)^e>>>16,2246822507),e=lt((e=pt(e^e>>>13,3266489909))^e>>>16)}(t.__iterate(r?e?function(t,e){n=31*n+sn(yt(t),yt(e))|0}:function(t,e){n=n+sn(yt(t),yt(e))|0}:e?function(t){n=31*n+yt(t)|0}:function(t){n=n+yt(t)|0}),n)}(this))}});var Xr=I.prototype;Xr[o]=!0,Xr[B]=Xr.values,Xr.toJSON=Xr.toArray,Xr.__toStringMapper=oe,Xr.inspect=Xr.toSource=function(){return""+this},Xr.chain=Xr.flatMap,Xr.contains=Xr.includes,Ur(O,{flip:function(){return Vt(this,Ut(this))},mapEntries:function(r,n){var i=this,o=0;return Vt(this,this.toSeq().map(function(t,e){return r.call(n,[e,t],o++,i)}).fromEntrySeq())},mapKeys:function(r,n){var i=this;return Vt(this,this.toSeq().flip().map(function(t,e){return r.call(n,t,e,i)}).flip())}});var Fr=O.prototype;Fr[s]=!0,Fr[B]=Xr.entries,Fr.toJSON=Qr,Fr.__toStringMapper=function(t,e){return oe(e)+": "+oe(t)},Ur(E,{toKeyedSeq:function(){return new xt(this,!1)},filter:function(t,e){return Vt(this,Lt(this,t,e,!1))},findIndex:function(t,e){e=this.findEntry(t,e);return e?e[0]:-1},indexOf:function(t){t=this.keyOf(t);return void 0===t?-1:t},lastIndexOf:function(t){t=this.lastKeyOf(t);return void 0===t?-1:t},reverse:function(){return Vt(this,Kt(this,!1))},slice:function(t,e){return Vt(this,Ct(this,t,e,!1))},splice:function(t,e){ -var r=arguments.length;if(e=Math.max(e||0,0),0===r||2===r&&!e)return this;t=y(t,t<0?this.count():this.size);var n=this.slice(0,t);return Vt(this,1===r?n:n.concat(Zt(arguments,2),this.slice(t+e)))},findLastIndex:function(t,e){e=this.findLastEntry(t,e);return e?e[0]:-1},first:function(t){return this.get(0,t)},flatten:function(t){return Vt(this,Pt(this,t,!1))},get:function(r,t){return(r=h(this,r))<0||this.size===1/0||void 0!==this.size&&this.size>2)|0}Zr.has=Xr.includes,Zr.contains=Zr.includes,Zr.keys=Zr.values,Ur(G,Fr),Ur(Z,Gr),Ur($,Zr);var an=function(t){function e(r){return null==r?_n():kr(r)?r:_n().withMutations(function(e){var t=j(r);te(t.size),t.forEach(function(t){return e.add(t)})})}return t&&(e.__proto__=t),((e.prototype=Object.create(t&&t.prototype)).constructor=e).of=function(){return this(arguments)},e.fromKeys=function(t){return this(O(t).keySeq())},e.prototype.toString=function(){return this.__toString("OrderedSet {","}")},e}(Kr);an.isOrderedSet=kr;var cn,fn=an.prototype;function hn(t,e){var r=Object.create(fn);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function _n(){return cn=cn||hn(zr())}fn[k]=!0,fn.zip=Gr.zip,fn.zipWith=Gr.zipWith,fn.zipAll=Gr.zipAll,fn.__empty=_n,fn.__make=hn;Zr={LeftThenRight:-1,RightThenLeft:1};Gr=function(u,s){var a;!function(t){if(x(t))throw Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(A(t))throw Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(null===t||"object"!=typeof t)throw Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}(u);var c=function(t){var n=this;if(t instanceof c)return t;if(!(this instanceof c))return new c(t);if(!a){a=!0;var e=Object.keys(u),r=f._indices={};f._name=s,f._keys=e,f._defaultValues=u;for(var i=0;i>>0;if(""+r!==e||4294967295===r)return NaN;e=r}return e<0?a(t)+e:e}function f(){return!0}function h(t,e,r){return(0===t&&!v(t)||void 0!==r&&t<=-r)&&(void 0===e||void 0!==r&&e>=r)}function p(t,e){return l(t,e,0)}function _(t,e){return l(t,e,e)}function l(t,e,r){return void 0===t?r:v(t)?e===1/0?e:0|Math.max(0,e+t):void 0===e||e===t?t:0|Math.min(e,t)}function v(t){return t<0||0===t&&1/t==-1/0}var y="@@__IMMUTABLE_ITERABLE__@@";function d(t){return Boolean(t&&t[y])}var g="@@__IMMUTABLE_KEYED__@@";function w(t){return Boolean(t&&t[g])}var m="@@__IMMUTABLE_INDEXED__@@";function z(t){return Boolean(t&&t[m])}function S(t){return w(t)||z(t)}var b=function(t){return d(t)?t:X(t)},I=function(t){function e(t){return w(t)?t:F(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(b),O=function(t){function e(t){return z(t)?t:G(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(b),E=function(t){function e(t){return d(t)&&!S(t)?t:Z(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(b);b.Keyed=I,b.Indexed=O,b.Set=E;var q="@@__IMMUTABLE_SEQ__@@";function j(t){return Boolean(t&&t[q])}var M="@@__IMMUTABLE_RECORD__@@";function D(t){return Boolean(t&&t[M])}function x(t){return d(t)||D(t)}var A="@@__IMMUTABLE_ORDERED__@@";function k(t){return Boolean(t&&t[A])}var R=0,U=1,T=2,B="function"==typeof Symbol&&Symbol.iterator,K="@@iterator",L=B||K,C=function(t){this.next=t};function P(t,e,r,n){var i=0===t?e:1===t?r:[e,r];return n?n.value=i:n={value:i,done:!1},n}function W(){return{value:void 0,done:!0}}function N(t){return!!Array.isArray(t)||!!V(t)}function H(t){return t&&"function"==typeof t.next}function J(t){var e=V(t);return e&&e.call(t)}function V(t){var e=t&&(B&&t[B]||t[K]);if("function"==typeof e)return e}C.prototype.toString=function(){return"[Iterator]"},C.KEYS=R,C.VALUES=U,C.ENTRIES=T,C.prototype.inspect=C.prototype.toSource=function(){return this.toString()},C.prototype[L]=function(){return this};var Y=Object.prototype.hasOwnProperty;function Q(t){return!(!Array.isArray(t)&&"string"!=typeof t)||t&&"object"==typeof t&&Number.isInteger(t.length)&&t.length>=0&&(0===t.length?1===Object.keys(t).length:t.hasOwnProperty(t.length-1))}var X=function(t){function e(t){return null==t?nt():x(t)?t.toSeq():function(t){var e=ut(t);if(e)return(n=V(r=t))&&n===r.entries?e.fromEntrySeq():function(t){var e=V(t);return e&&e===t.keys}(t)?e.toSetSeq():e;var r,n;if("object"==typeof t)return new tt(t);throw new TypeError("Expected Array or collection object of values, or keyed object: "+t)}(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq {","}")},e.prototype.cacheResult=function(){return!this._cache&&this.__iterateUncached&&(this._cache=this.entrySeq().toArray(),this.size=this._cache.length),this},e.prototype.__iterate=function(t,e){var r=this._cache;if(r){for(var n=r.length,i=0;i!==n;){var o=r[e?n-++i:i++];if(!1===t(o[1],o[0],this))break}return i}return this.__iterateUncached(t,e)},e.prototype.__iterator=function(t,e){var r=this._cache;if(r){var n=r.length,i=0;return new C((function(){if(i===n)return{value:void 0,done:!0};var o=r[e?n-++i:i++];return P(t,o[0],o[1])}))}return this.__iteratorUncached(t,e)},e}(b),F=function(t){function e(t){return null==t?nt().toKeyedSeq():d(t)?w(t)?t.toSeq():t.fromEntrySeq():D(t)?t.toSeq():it(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toKeyedSeq=function(){return this},e}(X),G=function(t){function e(t){return null==t?nt():d(t)?w(t)?t.entrySeq():t.toIndexedSeq():D(t)?t.toSeq().entrySeq():ot(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return e(arguments)},e.prototype.toIndexedSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq [","]")},e}(X),Z=function(t){function e(t){return(d(t)&&!S(t)?t:G(t)).toSetSeq()}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return e(arguments)},e.prototype.toSetSeq=function(){return this},e}(X);X.isSeq=j,X.Keyed=F,X.Set=Z,X.Indexed=G,X.prototype[q]=!0;var $=function(t){function e(t){this._array=t,this.size=t.length}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t,e){return this.has(t)?this._array[c(this,t)]:e},e.prototype.__iterate=function(t,e){for(var r=this._array,n=r.length,i=0;i!==n;){var o=e?n-++i:i++;if(!1===t(r[o],o,this))break}return i},e.prototype.__iterator=function(t,e){var r=this._array,n=r.length,i=0;return new C((function(){if(i===n)return{value:void 0,done:!0};var o=e?n-++i:i++;return P(t,o,r[o])}))},e}(G),tt=function(t){function e(t){var e=Object.keys(t).concat(Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(t):[]);this._object=t,this._keys=e,this.size=e.length}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t,e){return void 0===e||this.has(t)?this._object[t]:e},e.prototype.has=function(t){return Y.call(this._object,t)},e.prototype.__iterate=function(t,e){for(var r=this._object,n=this._keys,i=n.length,o=0;o!==i;){var u=n[e?i-++o:o++];if(!1===t(r[u],u,this))break}return o},e.prototype.__iterator=function(t,e){var r=this._object,n=this._keys,i=n.length,o=0;return new C((function(){if(o===i)return{value:void 0,done:!0};var u=n[e?i-++o:o++];return P(t,u,r[u])}))},e}(F);tt.prototype[A]=!0;var et,rt=function(t){function e(t){this._collection=t,this.size=t.length||t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.__iterateUncached=function(t,e){if(e)return this.cacheResult().__iterate(t,e);var r=J(this._collection),n=0;if(H(r))for(var i;!(i=r.next()).done&&!1!==t(i.value,n++,this););return n},e.prototype.__iteratorUncached=function(t,e){if(e)return this.cacheResult().__iterator(t,e);var r=J(this._collection);if(!H(r))return new C(W);var n=0;return new C((function(){var e=r.next();return e.done?e:P(t,n++,e.value)}))},e}(G);function nt(){return et||(et=new $([]))}function it(t){var e=ut(t);if(e)return e.fromEntrySeq();if("object"==typeof t)return new tt(t);throw new TypeError("Expected Array or collection object of [k, v] entries, or keyed object: "+t)}function ot(t){var e=ut(t);if(e)return e;throw new TypeError("Expected Array or collection object of values: "+t)}function ut(t){return Q(t)?new $(t):N(t)?new rt(t):void 0}var st="@@__IMMUTABLE_MAP__@@";function at(t){return Boolean(t&&t[st])}function ct(t){return at(t)&&k(t)}function ft(t){return Boolean(t&&"function"==typeof t.equals&&"function"==typeof t.hashCode)}function ht(t,e){if(t===e||t!=t&&e!=e)return!0;if(!t||!e)return!1;if("function"==typeof t.valueOf&&"function"==typeof e.valueOf){if((t=t.valueOf())===(e=e.valueOf())||t!=t&&e!=e)return!0;if(!t||!e)return!1}return!!(ft(t)&&ft(e)&&t.equals(e))}var pt="function"==typeof Math.imul&&-2===Math.imul(4294967295,2)?Math.imul:function(t,e){var r=65535&(t|=0),n=65535&(e|=0);return r*n+((t>>>16)*n+r*(e>>>16)<<16>>>0)|0};function _t(t){return t>>>1&1073741824|3221225471&t}var lt=Object.prototype.valueOf;function vt(t){if(null==t)return yt(t);if("function"==typeof t.hashCode)return _t(t.hashCode(t));var e,r=(e=t).valueOf!==lt&&"function"==typeof e.valueOf?e.valueOf(e):e;if(null==r)return yt(r);switch(typeof r){case"boolean":return r?1108378657:1108378656;case"number":return function(t){if(t!=t||t===1/0)return 0;var e=0|t;e!==t&&(e^=4294967295*t);for(;t>4294967295;)e^=t/=4294967295;return _t(e)}(r);case"string":return r.length>Et?function(t){var e=Mt[t];void 0===e&&(e=dt(t),jt===qt&&(jt=0,Mt={}),jt++,Mt[t]=e);return e}(r):dt(r);case"object":case"function":return function(t){var e;if(St&&void 0!==(e=zt.get(t)))return e;if(e=t[Ot],void 0!==e)return e;if(!wt){if(void 0!==(e=t.propertyIsEnumerable&&t.propertyIsEnumerable[Ot]))return e;if(void 0!==(e=function(t){if(t&&t.nodeType>0)switch(t.nodeType){case 1:return t.uniqueID;case 9:return t.documentElement&&t.documentElement.uniqueID}}(t)))return e}if(e=mt(),St)zt.set(t,e);else{if(void 0!==gt&&!1===gt(t))throw new Error("Non-extensible objects are not allowed as keys.");if(wt)Object.defineProperty(t,Ot,{enumerable:!1,configurable:!1,writable:!1,value:e});else if(void 0!==t.propertyIsEnumerable&&t.propertyIsEnumerable===t.constructor.prototype.propertyIsEnumerable)t.propertyIsEnumerable=function(){return this.constructor.prototype.propertyIsEnumerable.apply(this,arguments)},t.propertyIsEnumerable[Ot]=e;else{if(void 0===t.nodeType)throw new Error("Unable to set a non-enumerable property on object.");t[Ot]=e}}return e}(r);case"symbol":return function(t){var e=bt[t];if(void 0!==e)return e;return e=mt(),bt[t]=e,e}(r);default:if("function"==typeof r.toString)return dt(r.toString());throw new Error("Value type "+typeof r+" cannot be hashed.")}}function yt(t){return null===t?1108378658:1108378659}function dt(t){for(var e=0,r=0;r=0&&(a.get=function(e,r){return(e=c(this,e))>=0&&eo)return{value:void 0,done:!0};var t=i.next();return n||e===U||t.done?t:P(e,a-1,e===R?void 0:t.value[1],t)}))},a}function Lt(t,e,r,n){var i=Qt(t);return i.__iterateUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterate(i,o);var s=!0,a=0;return t.__iterate((function(t,o,c){if(!s||!(s=e.call(r,t,o,c)))return a++,i(t,n?o:a-1,u)})),a},i.__iteratorUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterator(i,o);var s=t.__iterator(T,o),a=!0,c=0;return new C((function(){var t,o,f;do{if((t=s.next()).done)return n||i===U?t:P(i,c++,i===R?void 0:t.value[1],t);var h=t.value;o=h[0],f=h[1],a&&(a=e.call(r,f,o,u))}while(a);return i===T?t:P(i,o,f,t)}))},i}function Ct(t,e,r){var n=Qt(t);return n.__iterateUncached=function(i,o){if(o)return this.cacheResult().__iterate(i,o);var u=0,s=!1;return function t(a,c){a.__iterate((function(o,a){return(!e||c0}function Ht(t,e,r,n){var i=Qt(t),o=new $(r).map((function(t){return t.size}));return i.size=n?o.max():o.min(),i.__iterate=function(t,e){for(var r,n=this.__iterator(U,e),i=0;!(r=n.next()).done&&!1!==t(r.value,i++,this););return i},i.__iteratorUncached=function(t,i){var o=r.map((function(t){return t=b(t),J(i?t.reverse():t)})),u=0,s=!1;return new C((function(){var r;return s||(r=o.map((function(t){return t.next()})),s=n?r.every((function(t){return t.done})):r.some((function(t){return t.done}))),s?{value:void 0,done:!0}:P(t,u++,e.apply(null,r.map((function(t){return t.value}))))}))},i}function Jt(t,e){return t===e?t:j(t)?e:t.constructor(e)}function Vt(t){if(t!==Object(t))throw new TypeError("Expected [K, V] tuple: "+t)}function Yt(t){return w(t)?I:z(t)?O:E}function Qt(t){return Object.create((w(t)?F:z(t)?G:Z).prototype)}function Xt(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size,this):X.prototype.cacheResult.call(this)}function Ft(t,e){return void 0===t&&void 0===e?0:void 0===t?1:void 0===e?-1:t>e?1:t0;)e[r]=arguments[r+1];if("function"!=typeof t)throw new TypeError("Invalid merger function: "+t);return ze(this,e,t)}function ze(t,e,r){for(var n=[],i=0;i0;)e[r]=arguments[r+1];return Se(this,e,t)}function Ee(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return fe(this,t,He(),(function(t){return be(t,e)}))}function qe(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return fe(this,t,He(),(function(t){return Se(t,e)}))}function je(t){var e=this.asMutable();return t(e),e.wasAltered()?e.__ensureOwner(this.__ownerID):this}function Me(){return this.__ownerID?this:this.__ensureOwner(new s)}function De(){return this.__ensureOwner()}function xe(){return this.__altered}var Ae=function(t){function e(e){return null==e?He():at(e)&&!k(e)?e:He().withMutations((function(r){var n=t(e);$t(n.size),n.forEach((function(t,e){return r.set(e,t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toString=function(){return this.__toString("Map {","}")},e.prototype.get=function(t,e){return this._root?this._root.get(0,void 0,t,e):e},e.prototype.set=function(t,e){return Je(this,t,e)},e.prototype.remove=function(t){return Je(this,t,o)},e.prototype.deleteAll=function(t){var e=b(t);return 0===e.size?this:this.withMutations((function(t){e.forEach((function(e){return t.remove(e)}))}))},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):He()},e.prototype.sort=function(t){return yr(Pt(this,t))},e.prototype.sortBy=function(t,e){return yr(Pt(this,e,t))},e.prototype.map=function(t,e){var r=this;return this.withMutations((function(n){n.forEach((function(i,o){n.set(o,t.call(e,i,o,r))}))}))},e.prototype.__iterator=function(t,e){return new Ce(this,t,e)},e.prototype.__iterate=function(t,e){var r=this,n=0;return this._root&&this._root.iterate((function(e){return n++,t(e[1],e[0],r)}),e),n},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Ne(this.size,this._root,t,this.__hash):0===this.size?He():(this.__ownerID=t,this.__altered=!1,this)},e}(I);Ae.isMap=at;var ke=Ae.prototype;ke[st]=!0,ke[e]=ke.remove,ke.removeAll=ke.deleteAll,ke.setIn=_e,ke.removeIn=ke.deleteIn=ve,ke.update=de,ke.updateIn=ge,ke.merge=ke.concat=we,ke.mergeWith=me,ke.mergeDeep=Ie,ke.mergeDeepWith=Oe,ke.mergeIn=Ee,ke.mergeDeepIn=qe,ke.withMutations=je,ke.wasAltered=xe,ke.asImmutable=De,ke["@@transducer/init"]=ke.asMutable=Me,ke["@@transducer/step"]=function(t,e){return t.set(e[0],e[1])},ke["@@transducer/result"]=function(t){return t.asImmutable()};var Re=function(t,e){this.ownerID=t,this.entries=e};Re.prototype.get=function(t,e,r,n){for(var i=this.entries,o=0,u=i.length;o=Ge)return function(t,e,r,n){t||(t=new s);for(var i=new Ke(t,vt(r),[r,n]),o=0;o>>t)&i),s=this.bitmap;return 0==(s&u)?o:this.nodes[Xe(s&u-1)].get(t+r,e,n,o)},Ue.prototype.update=function(t,e,u,s,a,c,f){void 0===u&&(u=vt(s));var h=(0===e?u:u>>>e)&i,p=1<=Ze)return function(t,e,r,i,o){for(var u=0,s=new Array(n),a=0;0!==r;a++,r>>>=1)s[a]=1&r?e[u++]:void 0;return s[i]=o,new Te(t,u+1,s)}(t,y,_,h,g);if(l&&!g&&2===y.length&&Ye(y[1^v]))return y[1^v];if(l&&g&&1===y.length&&Ye(g))return g;var w=t&&t===this.ownerID,m=l?g?_:_^p:_|p,z=l?g?Fe(y,v,g,w):function(t,e,r){var n=t.length-1;if(r&&e===n)return t.pop(),t;for(var i=new Array(n),o=0,u=0;u>>t)&i,s=this.nodes[u];return s?s.get(t+r,e,n,o):o},Te.prototype.update=function(t,e,n,u,s,a,c){void 0===n&&(n=vt(u));var f=(0===e?n:n>>>e)&i,h=s===o,p=this.nodes,_=p[f];if(h&&!_)return this;var l=Ve(_,t,e+r,n,u,s,a,c);if(l===_)return this;var v=this.count;if(_){if(!l&&--v<$e)return function(t,e,r,n){for(var i=0,o=0,u=new Array(r),s=0,a=1,c=e.length;s>>n)&i,c=(0===n?o:o>>>n)&i,f=a===c?[Qe(t,e,n+r,o,u)]:(s=new Ke(e,o,u),a>1&1431655765))+(t>>2&858993459))+(t>>4)&252645135,t+=t>>8,127&(t+=t>>16)}function Fe(t,e,r,n){var i=n?t:Gt(t);return i[e]=r,i}var Ge=n/4,Ze=n/2,$e=n/4,tr="@@__IMMUTABLE_LIST__@@";function er(t){return Boolean(t&&t[tr])}var rr=function(t){function e(e){var i=cr();if(null==e)return i;if(er(e))return e;var o=t(e),u=o.size;return 0===u?i:($t(u),u>0&&u=0&&t=t.size||e<0)return t.withMutations((function(t){e<0?_r(t,e).set(0,r):_r(t,0,e+1).set(e,r)}));e+=t._origin;var n=t._tail,i=t._root,o={value:!1};e>=lr(t._capacity)?n=fr(n,t.__ownerID,0,e,r,o):i=fr(i,t.__ownerID,t._level,e,r,o);if(!o.value)return t;if(t.__ownerID)return t._root=i,t._tail=n,t.__hash=void 0,t.__altered=!0,t;return ar(t._origin,t._capacity,t._level,i,n)}(this,t,e)},e.prototype.remove=function(t){return this.has(t)?0===t?this.shift():t===this.size-1?this.pop():this.splice(t,1):this},e.prototype.insert=function(t,e){return this.splice(t,0,e)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=this._origin=this._capacity=0,this._level=r,this._root=this._tail=this.__hash=void 0,this.__altered=!0,this):cr()},e.prototype.push=function(){var t=arguments,e=this.size;return this.withMutations((function(r){_r(r,0,e+t.length);for(var n=0;n>>e&i;if(o>=this.array.length)return new ir([],t);var u,s=0===o;if(e>0){var a=this.array[o];if((u=a&&a.removeBefore(t,e-r,n))===a&&s)return this}if(s&&!u)return this;var c=hr(this,t);if(!s)for(var f=0;f>>e&i;if(u>=this.array.length)return this;if(e>0){var s=this.array[u];if((o=s&&s.removeAfter(t,e-r,n))===s&&u===this.array.length-1)return this}var a=hr(this,t);return a.array.splice(u+1),o&&(a.array[u]=o),a};var or,ur={};function sr(t,e){var i=t._origin,o=t._capacity,u=lr(o),s=t._tail;return a(t._root,t._level,0);function a(t,c,f){return 0===c?function(t,r){var a=r===u?s&&s.array:t&&t.array,c=r>i?0:i-r,f=o-r;f>n&&(f=n);return function(){if(c===f)return ur;var t=e?--f:c++;return a&&a[t]}}(t,f):function(t,u,s){var c,f=t&&t.array,h=s>i?0:i-s>>u,p=1+(o-s>>u);p>n&&(p=n);return function(){for(;;){if(c){var t=c();if(t!==ur)return t;c=null}if(h===p)return ur;var n=e?--p:h++;c=a(f&&f[n],u-r,s+(n<>>n&i,h=t&&f0){var p=t&&t.array[f],_=fr(p,e,n-r,o,s,a);return _===p?t:((c=hr(t,e)).array[f]=_,c)}return h&&t.array[f]===s?t:(a&&u(a),c=hr(t,e),void 0===s&&f===c.array.length-1?c.array.pop():c.array[f]=s,c)}function hr(t,e){return e&&t&&e===t.ownerID?t:new ir(t?t.array.slice():[],e)}function pr(t,e){if(e>=lr(t._capacity))return t._tail;if(e<1<0;)n=n.array[e>>>o&i],o-=r;return n}}function _r(t,e,n){void 0!==e&&(e|=0),void 0!==n&&(n|=0);var o=t.__ownerID||new s,u=t._origin,a=t._capacity,c=u+e,f=void 0===n?a:n<0?a+n:u+n;if(c===u&&f===a)return t;if(c>=f)return t.clear();for(var h=t._level,p=t._root,_=0;c+_<0;)p=new ir(p&&p.array.length?[void 0,p]:[],o),_+=1<<(h+=r);_&&(c+=_,u+=_,f+=_,a+=_);for(var l=lr(a),v=lr(f);v>=1<l?new ir([],o):y;if(y&&v>l&&cr;w-=r){var m=l>>>w&i;g=g.array[m]=hr(g.array[m],o)}g.array[l>>>r&i]=y}if(f=v)c-=v,f-=v,h=r,p=null,d=d&&d.removeBefore(o,0,c);else if(c>u||v>>h&i;if(z!==v>>>h&i)break;z&&(_+=(1<u&&(p=p.removeBefore(o,h,c-_)),p&&v>>r<=n&&a.size>=2*s.size?(i=(u=a.filter((function(t,e){return void 0!==t&&c!==e}))).toKeyedSeq().map((function(t){return t[0]})).flip().toMap(),t.__ownerID&&(i.__ownerID=u.__ownerID=t.__ownerID)):(i=s.remove(e),u=c===a.size-1?a.pop():a.set(c,void 0))}else if(f){if(r===a.get(c)[1])return t;i=s,u=a.set(c,[e,r])}else i=s.set(e,a.size),u=a.set(a.size,[e,r]);return t.__ownerID?(t.size=i.size,t._map=i,t._list=u,t.__hash=void 0,t.__altered=!0,t):dr(i,u)}yr.isOrderedMap=ct,yr.prototype[A]=!0,yr.prototype[e]=yr.prototype.remove;var mr="@@__IMMUTABLE_STACK__@@";function zr(t){return Boolean(t&&t[mr])}var Sr=function(t){function e(t){return null==t?Er():zr(t)?t:Er().pushAll(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("Stack [","]")},e.prototype.get=function(t,e){var r=this._head;for(t=c(this,t);r&&t--;)r=r.next;return r?r.value:e},e.prototype.peek=function(){return this._head&&this._head.value},e.prototype.push=function(){var t=arguments;if(0===arguments.length)return this;for(var e=this.size+arguments.length,r=this._head,n=arguments.length-1;n>=0;n--)r={value:t[n],next:r};return this.__ownerID?(this.size=e,this._head=r,this.__hash=void 0,this.__altered=!0,this):Or(e,r)},e.prototype.pushAll=function(e){if(0===(e=t(e)).size)return this;if(0===this.size&&zr(e))return e;$t(e.size);var r=this.size,n=this._head;return e.__iterate((function(t){r++,n={value:t,next:n}}),!0),this.__ownerID?(this.size=r,this._head=n,this.__hash=void 0,this.__altered=!0,this):Or(r,n)},e.prototype.pop=function(){return this.slice(1)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):Er()},e.prototype.slice=function(e,r){if(h(e,r,this.size))return this;var n=p(e,this.size);if(_(r,this.size)!==this.size)return t.prototype.slice.call(this,e,r);for(var i=this.size-n,o=this._head;n--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):Or(i,o)},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Or(this.size,this._head,t,this.__hash):0===this.size?Er():(this.__ownerID=t,this.__altered=!1,this)},e.prototype.__iterate=function(t,e){var r=this;if(e)return new $(this.toArray()).__iterate((function(e,n){return t(e,n,r)}),e);for(var n=0,i=this._head;i&&!1!==t(i.value,n++,this);)i=i.next;return n},e.prototype.__iterator=function(t,e){if(e)return new $(this.toArray()).__iterator(t,e);var r=0,n=this._head;return new C((function(){if(n){var e=n.value;return n=n.next,P(t,r++,e)}return{value:void 0,done:!0}}))},e}(O);Sr.isStack=zr;var br,Ir=Sr.prototype;function Or(t,e,r,n){var i=Object.create(Ir);return i.size=t,i._head=e,i.__ownerID=r,i.__hash=n,i.__altered=!1,i}function Er(){return br||(br=Or(0))}Ir[mr]=!0,Ir.shift=Ir.pop,Ir.unshift=Ir.push,Ir.unshiftAll=Ir.pushAll,Ir.withMutations=je,Ir.wasAltered=xe,Ir.asImmutable=De,Ir["@@transducer/init"]=Ir.asMutable=Me,Ir["@@transducer/step"]=function(t,e){return t.unshift(e)},Ir["@@transducer/result"]=function(t){return t.asImmutable()};var qr="@@__IMMUTABLE_SET__@@";function jr(t){return Boolean(t&&t[qr])}function Mr(t){return jr(t)&&k(t)}function Dr(t,e){if(t===e)return!0;if(!d(e)||void 0!==t.size&&void 0!==e.size&&t.size!==e.size||void 0!==t.__hash&&void 0!==e.__hash&&t.__hash!==e.__hash||w(t)!==w(e)||z(t)!==z(e)||k(t)!==k(e))return!1;if(0===t.size&&0===e.size)return!0;var r=!S(t);if(k(t)){var n=t.entries();return e.every((function(t,e){var i=n.next().value;return i&&ht(i[1],t)&&(r||ht(i[0],e))}))&&n.next().done}var i=!1;if(void 0===t.size)if(void 0===e.size)"function"==typeof t.cacheResult&&t.cacheResult();else{i=!0;var u=t;t=e,e=u}var s=!0,a=e.__iterate((function(e,n){if(r?!t.has(e):i?!ht(e,t.get(n,o)):!ht(t.get(n,o),e))return s=!1,!1}));return s&&t.size===a}function xr(t,e){var r=function(r){t.prototype[r]=e[r]};return Object.keys(e).forEach(r),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(e).forEach(r),t}function Ar(t){if(!t||"object"!=typeof t)return t;if(!d(t)){if(!ne(t))return t;t=X(t)}if(w(t)){var e={};return t.__iterate((function(t,r){e[r]=Ar(t)})),e}var r=[];return t.__iterate((function(t){r.push(Ar(t))})),r}var kr=function(t){function e(e){return null==e?Kr():jr(e)&&!k(e)?e:Kr().withMutations((function(r){var n=t(e);$t(n.size),n.forEach((function(t){return r.add(t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(I(t).keySeq())},e.intersect=function(t){return(t=b(t).toArray()).length?Ur.intersect.apply(e(t.pop()),t):Kr()},e.union=function(t){return(t=b(t).toArray()).length?Ur.union.apply(e(t.pop()),t):Kr()},e.prototype.toString=function(){return this.__toString("Set {","}")},e.prototype.has=function(t){return this._map.has(t)},e.prototype.add=function(t){return Tr(this,this._map.set(t,t))},e.prototype.remove=function(t){return Tr(this,this._map.remove(t))},e.prototype.clear=function(){return Tr(this,this._map.clear())},e.prototype.map=function(t,e){var r=this,n=!1,i=Tr(this,this._map.mapEntries((function(i){var o=i[1],u=t.call(e,o,o,r);return u!==o&&(n=!0),[u,u]}),e));return n?i:this},e.prototype.union=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return 0===(e=e.filter((function(t){return 0!==t.size}))).length?this:0!==this.size||this.__ownerID||1!==e.length?this.withMutations((function(r){for(var n=0;n=0&&e=0&&r>>-15,461845907),e=pt(e<<13|e>>>-13,5),e=pt((e=(e+3864292196|0)^t)^e>>>16,2246822507),e=_t((e=pt(e^e>>>13,3266489909))^e>>>16)}(t.size,n)}(this))}});var Jr=b.prototype;Jr[y]=!0,Jr[L]=Jr.values,Jr.toJSON=Jr.toArray,Jr.__toStringMapper=ie,Jr.inspect=Jr.toSource=function(){return this.toString()},Jr.chain=Jr.flatMap,Jr.contains=Jr.includes,xr(I,{flip:function(){return Jt(this,Rt(this))},mapEntries:function(t,e){var r=this,n=0;return Jt(this,this.toSeq().map((function(i,o){return t.call(e,[o,i],n++,r)})).fromEntrySeq())},mapKeys:function(t,e){var r=this;return Jt(this,this.toSeq().flip().map((function(n,i){return t.call(e,n,i,r)})).flip())}});var Vr=I.prototype;Vr[g]=!0,Vr[L]=Jr.entries,Vr.toJSON=Hr,Vr.__toStringMapper=function(t,e){return ie(e)+": "+ie(t)},xr(O,{toKeyedSeq:function(){return new Dt(this,!1)},filter:function(t,e){return Jt(this,Bt(this,t,e,!1))},findIndex:function(t,e){var r=this.findEntry(t,e);return r?r[0]:-1},indexOf:function(t){var e=this.keyOf(t);return void 0===e?-1:e},lastIndexOf:function(t){var e=this.lastKeyOf(t);return void 0===e?-1:e},reverse:function(){return Jt(this,Tt(this,!1))},slice:function(t,e){return Jt(this,Kt(this,t,e,!1))},splice:function(t,e){var r=arguments.length;if(e=Math.max(e||0,0),0===r||2===r&&!e)return this;t=p(t,t<0?this.count():this.size);var n=this.slice(0,t);return Jt(this,1===r?n:n.concat(Gt(arguments,2),this.slice(t+e)))},findLastIndex:function(t,e){var r=this.findLastEntry(t,e);return r?r[0]:-1},first:function(t){return this.get(0,t)},flatten:function(t){return Jt(this,Ct(this,t,!1))},get:function(t,e){return(t=c(this,t))<0||this.size===1/0||void 0!==this.size&&t>this.size?e:this.find((function(e,r){return r===t}),void 0,e)},has:function(t){return(t=c(this,t))>=0&&(void 0!==this.size?this.size===1/0||te?-1:0}function rn(t,e){return t^e+2654435769+(t<<6)+(t>>2)|0}Qr.has=Jr.includes,Qr.contains=Qr.includes,Qr.keys=Qr.values,xr(F,Vr),xr(G,Yr),xr(Z,Qr);var nn=function(t){function e(t){return null==t?an():Mr(t)?t:an().withMutations((function(e){var r=E(t);$t(r.size),r.forEach((function(t){return e.add(t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(I(t).keySeq())},e.prototype.toString=function(){return this.__toString("OrderedSet {","}")},e}(kr);nn.isOrderedSet=Mr;var on,un=nn.prototype;function sn(t,e){var r=Object.create(un);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function an(){return on||(on=sn(gr()))}un[A]=!0,un.zip=Yr.zip,un.zipWith=Yr.zipWith,un.zipAll=Yr.zipAll,un.__empty=an,un.__make=sn;var cn=function(t,e){var r;!function(t){if(D(t))throw new Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(x(t))throw new Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(null===t||"object"!=typeof t)throw new Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}(t);var n=function(o){var u=this;if(o instanceof n)return o;if(!(this instanceof n))return new n(o);if(!r){r=!0;var s=Object.keys(t),a=i._indices={};i._name=e,i._keys=s,i._defaultValues=t;for(var c=0;c2?[]:void 0,{"":t})},t.get=ue,t.getIn=Pr,t.has=oe,t.hasIn=Nr,t.hash=vt,t.is=ht,t.isAssociative=S,t.isCollection=d,t.isImmutable=x,t.isIndexed=z,t.isKeyed=w,t.isList=er,t.isMap=at,t.isOrdered=k,t.isOrderedMap=ct,t.isOrderedSet=Mr,t.isPlainObject=re,t.isRecord=D,t.isSeq=j,t.isSet=jr,t.isStack=zr,t.isValueObject=ft,t.merge=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return be(t,e)},t.mergeDeep=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Se(t,e)},t.mergeDeepWith=function(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];return Se(e,r,t)},t.mergeWith=function(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];return be(e,r,t)},t.remove=ae,t.removeIn=le,t.set=ce,t.setIn=pe,t.update=ye,t.updateIn=fe,t.version="5.0.0-rc.1"})); diff --git a/package.json b/package.json index e380730f6d..7a9f05049d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "immutable", - "version": "4.3.7", + "version": "5.0.0-rc.1", "description": "Immutable Data Collections", "license": "MIT", "homepage": "https://immutable-js.com", @@ -16,8 +16,7 @@ "url": "https://github.com/immutable-js/immutable-js/issues" }, "main": "dist/immutable.js", - "module": "dist/immutable.es.js", - "sideEffects": false, + "module": "dist/es/Immutable.js", "types": "dist/immutable.d.ts", "files": [ "dist", From c24050e15e09495a206a028535b876fd41696755 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 17 Oct 2024 22:12:22 +0000 Subject: [PATCH 213/242] deploy: 20214179670f62c74beff03d41a1e8db8c3df20e --- dist/immutable.d.ts | 118 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 118 insertions(+) diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index d0d804dec4..b27aac2a74 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -1591,6 +1591,65 @@ declare namespace Immutable { * @see Collection.Keyed.flip */ flip(): Map; + + /** + * Returns an OrderedMap of the same type which includes the same entries, + * stably sorted by using a `comparator`. + * + * If a `comparator` is not provided, a default comparator uses `<` and `>`. + * + * `comparator(valueA, valueB)`: + * + * * Returns `0` if the elements should not be swapped. + * * Returns `-1` (or any negative number) if `valueA` comes before `valueB` + * * Returns `1` (or any positive number) if `valueA` comes after `valueB` + * * Alternatively, can return a value of the `PairSorting` enum type + * * Is pure, i.e. it must always return the same value for the same pair + * of values. + * + * + * ```js + * const { Map } = require('immutable') + * Map({ "c": 3, "a": 1, "b": 2 }).sort((a, b) => { + * if (a < b) { return -1; } + * if (a > b) { return 1; } + * if (a === b) { return 0; } + * }); + * // OrderedMap { "a": 1, "b": 2, "c": 3 } + * ``` + * + * Note: `sort()` Always returns a new instance, even if the original was + * already sorted. + * + * Note: This is always an eager operation. + */ + sort(comparator?: Comparator): this & OrderedMap; + + /** + * Like `sort`, but also accepts a `comparatorValueMapper` which allows for + * sorting by more sophisticated means: + * + * + * ```js + * const { Map } = require('immutable') + * const beattles = Map({ + * John: { name: "Lennon" }, + * Paul: { name: "McCartney" }, + * George: { name: "Harrison" }, + * Ringo: { name: "Starr" }, + * }); + * beattles.sortBy(member => member.name); + * ``` + * + * Note: `sortBy()` Always returns a new instance, even if the original was + * already sorted. + * + * Note: This is always an eager operation. + */ + sortBy( + comparatorValueMapper: (value: V, key: K, iter: this) => C, + comparator?: (valueA: C, valueB: C) => number + ): this & OrderedMap; } /** @@ -2012,6 +2071,65 @@ declare namespace Immutable { predicate: (this: C, value: T, key: T, iter: this) => unknown, context?: C ): [this, this]; + + /** + * Returns an OrderedSet of the same type which includes the same entries, + * stably sorted by using a `comparator`. + * + * If a `comparator` is not provided, a default comparator uses `<` and `>`. + * + * `comparator(valueA, valueB)`: + * + * * Returns `0` if the elements should not be swapped. + * * Returns `-1` (or any negative number) if `valueA` comes before `valueB` + * * Returns `1` (or any positive number) if `valueA` comes after `valueB` + * * Alternatively, can return a value of the `PairSorting` enum type + * * Is pure, i.e. it must always return the same value for the same pair + * of values. + * + * + * ```js + * const { Set } = require('immutable') + * Set(['b', 'a', 'c']).sort((a, b) => { + * if (a < b) { return -1; } + * if (a > b) { return 1; } + * if (a === b) { return 0; } + * }); + * // OrderedSet { "a":, "b", "c" } + * ``` + * + * Note: `sort()` Always returns a new instance, even if the original was + * already sorted. + * + * Note: This is always an eager operation. + */ + sort(comparator?: Comparator): this & OrderedSet; + + /** + * Like `sort`, but also accepts a `comparatorValueMapper` which allows for + * sorting by more sophisticated means: + * + * + * ```js + * const { Set } = require('immutable') + * const beattles = Set([ + * { name: "Lennon" }, + * { name: "McCartney" }, + * { name: "Harrison" }, + * { name: "Starr" }, + * ]); + * beattles.sortBy(member => member.name); + * ``` + * + * Note: `sortBy()` Always returns a new instance, even if the original was + * already sorted. + * + * Note: This is always an eager operation. + */ + sortBy( + comparatorValueMapper: (value: T, key: T, iter: this) => C, + comparator?: (valueA: C, valueB: C) => number + ): this & OrderedSet; } /** From 3f7d2acd287f76ff4a4c97b477579499de47229d Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 17 Oct 2024 22:41:39 +0000 Subject: [PATCH 214/242] deploy: c056df9f7781d7fa7e1611aef135d11079bbcbb9 --- dist/es/List.js | 3 +-- dist/immutable.js | 3 +-- dist/immutable.min.js | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/dist/es/List.js b/dist/es/List.js index 096ccb871f..9dff60b0aa 100644 --- a/dist/es/List.js +++ b/dist/es/List.js @@ -426,9 +426,8 @@ function makeList(origin, capacity, level, root, tail, ownerID, hash) { return list; } -var EMPTY_LIST; function emptyList() { - return EMPTY_LIST || (EMPTY_LIST = makeList(0, 0, SHIFT)); + return makeList(0, 0, SHIFT); } function updateList(list, index, value) { diff --git a/dist/immutable.js b/dist/immutable.js index d1abd9ff4f..248c251473 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -3560,9 +3560,8 @@ return list; } - var EMPTY_LIST; function emptyList() { - return EMPTY_LIST || (EMPTY_LIST = makeList(0, 0, SHIFT)); + return makeList(0, 0, SHIFT); } function updateList(list, index, value) { diff --git a/dist/immutable.min.js b/dist/immutable.min.js index a63e28f5e5..a3c0672b6e 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -22,4 +22,4 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).Immutable={})}(this,(function(t){"use strict";var e="delete",r=5,n=1<>>0;if(""+r!==e||4294967295===r)return NaN;e=r}return e<0?a(t)+e:e}function f(){return!0}function h(t,e,r){return(0===t&&!v(t)||void 0!==r&&t<=-r)&&(void 0===e||void 0!==r&&e>=r)}function p(t,e){return l(t,e,0)}function _(t,e){return l(t,e,e)}function l(t,e,r){return void 0===t?r:v(t)?e===1/0?e:0|Math.max(0,e+t):void 0===e||e===t?t:0|Math.min(e,t)}function v(t){return t<0||0===t&&1/t==-1/0}var y="@@__IMMUTABLE_ITERABLE__@@";function d(t){return Boolean(t&&t[y])}var g="@@__IMMUTABLE_KEYED__@@";function w(t){return Boolean(t&&t[g])}var m="@@__IMMUTABLE_INDEXED__@@";function z(t){return Boolean(t&&t[m])}function S(t){return w(t)||z(t)}var b=function(t){return d(t)?t:X(t)},I=function(t){function e(t){return w(t)?t:F(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(b),O=function(t){function e(t){return z(t)?t:G(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(b),E=function(t){function e(t){return d(t)&&!S(t)?t:Z(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(b);b.Keyed=I,b.Indexed=O,b.Set=E;var q="@@__IMMUTABLE_SEQ__@@";function j(t){return Boolean(t&&t[q])}var M="@@__IMMUTABLE_RECORD__@@";function D(t){return Boolean(t&&t[M])}function x(t){return d(t)||D(t)}var A="@@__IMMUTABLE_ORDERED__@@";function k(t){return Boolean(t&&t[A])}var R=0,U=1,T=2,B="function"==typeof Symbol&&Symbol.iterator,K="@@iterator",L=B||K,C=function(t){this.next=t};function P(t,e,r,n){var i=0===t?e:1===t?r:[e,r];return n?n.value=i:n={value:i,done:!1},n}function W(){return{value:void 0,done:!0}}function N(t){return!!Array.isArray(t)||!!V(t)}function H(t){return t&&"function"==typeof t.next}function J(t){var e=V(t);return e&&e.call(t)}function V(t){var e=t&&(B&&t[B]||t[K]);if("function"==typeof e)return e}C.prototype.toString=function(){return"[Iterator]"},C.KEYS=R,C.VALUES=U,C.ENTRIES=T,C.prototype.inspect=C.prototype.toSource=function(){return this.toString()},C.prototype[L]=function(){return this};var Y=Object.prototype.hasOwnProperty;function Q(t){return!(!Array.isArray(t)&&"string"!=typeof t)||t&&"object"==typeof t&&Number.isInteger(t.length)&&t.length>=0&&(0===t.length?1===Object.keys(t).length:t.hasOwnProperty(t.length-1))}var X=function(t){function e(t){return null==t?nt():x(t)?t.toSeq():function(t){var e=ut(t);if(e)return(n=V(r=t))&&n===r.entries?e.fromEntrySeq():function(t){var e=V(t);return e&&e===t.keys}(t)?e.toSetSeq():e;var r,n;if("object"==typeof t)return new tt(t);throw new TypeError("Expected Array or collection object of values, or keyed object: "+t)}(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq {","}")},e.prototype.cacheResult=function(){return!this._cache&&this.__iterateUncached&&(this._cache=this.entrySeq().toArray(),this.size=this._cache.length),this},e.prototype.__iterate=function(t,e){var r=this._cache;if(r){for(var n=r.length,i=0;i!==n;){var o=r[e?n-++i:i++];if(!1===t(o[1],o[0],this))break}return i}return this.__iterateUncached(t,e)},e.prototype.__iterator=function(t,e){var r=this._cache;if(r){var n=r.length,i=0;return new C((function(){if(i===n)return{value:void 0,done:!0};var o=r[e?n-++i:i++];return P(t,o[0],o[1])}))}return this.__iteratorUncached(t,e)},e}(b),F=function(t){function e(t){return null==t?nt().toKeyedSeq():d(t)?w(t)?t.toSeq():t.fromEntrySeq():D(t)?t.toSeq():it(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toKeyedSeq=function(){return this},e}(X),G=function(t){function e(t){return null==t?nt():d(t)?w(t)?t.entrySeq():t.toIndexedSeq():D(t)?t.toSeq().entrySeq():ot(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return e(arguments)},e.prototype.toIndexedSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq [","]")},e}(X),Z=function(t){function e(t){return(d(t)&&!S(t)?t:G(t)).toSetSeq()}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return e(arguments)},e.prototype.toSetSeq=function(){return this},e}(X);X.isSeq=j,X.Keyed=F,X.Set=Z,X.Indexed=G,X.prototype[q]=!0;var $=function(t){function e(t){this._array=t,this.size=t.length}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t,e){return this.has(t)?this._array[c(this,t)]:e},e.prototype.__iterate=function(t,e){for(var r=this._array,n=r.length,i=0;i!==n;){var o=e?n-++i:i++;if(!1===t(r[o],o,this))break}return i},e.prototype.__iterator=function(t,e){var r=this._array,n=r.length,i=0;return new C((function(){if(i===n)return{value:void 0,done:!0};var o=e?n-++i:i++;return P(t,o,r[o])}))},e}(G),tt=function(t){function e(t){var e=Object.keys(t).concat(Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(t):[]);this._object=t,this._keys=e,this.size=e.length}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t,e){return void 0===e||this.has(t)?this._object[t]:e},e.prototype.has=function(t){return Y.call(this._object,t)},e.prototype.__iterate=function(t,e){for(var r=this._object,n=this._keys,i=n.length,o=0;o!==i;){var u=n[e?i-++o:o++];if(!1===t(r[u],u,this))break}return o},e.prototype.__iterator=function(t,e){var r=this._object,n=this._keys,i=n.length,o=0;return new C((function(){if(o===i)return{value:void 0,done:!0};var u=n[e?i-++o:o++];return P(t,u,r[u])}))},e}(F);tt.prototype[A]=!0;var et,rt=function(t){function e(t){this._collection=t,this.size=t.length||t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.__iterateUncached=function(t,e){if(e)return this.cacheResult().__iterate(t,e);var r=J(this._collection),n=0;if(H(r))for(var i;!(i=r.next()).done&&!1!==t(i.value,n++,this););return n},e.prototype.__iteratorUncached=function(t,e){if(e)return this.cacheResult().__iterator(t,e);var r=J(this._collection);if(!H(r))return new C(W);var n=0;return new C((function(){var e=r.next();return e.done?e:P(t,n++,e.value)}))},e}(G);function nt(){return et||(et=new $([]))}function it(t){var e=ut(t);if(e)return e.fromEntrySeq();if("object"==typeof t)return new tt(t);throw new TypeError("Expected Array or collection object of [k, v] entries, or keyed object: "+t)}function ot(t){var e=ut(t);if(e)return e;throw new TypeError("Expected Array or collection object of values: "+t)}function ut(t){return Q(t)?new $(t):N(t)?new rt(t):void 0}var st="@@__IMMUTABLE_MAP__@@";function at(t){return Boolean(t&&t[st])}function ct(t){return at(t)&&k(t)}function ft(t){return Boolean(t&&"function"==typeof t.equals&&"function"==typeof t.hashCode)}function ht(t,e){if(t===e||t!=t&&e!=e)return!0;if(!t||!e)return!1;if("function"==typeof t.valueOf&&"function"==typeof e.valueOf){if((t=t.valueOf())===(e=e.valueOf())||t!=t&&e!=e)return!0;if(!t||!e)return!1}return!!(ft(t)&&ft(e)&&t.equals(e))}var pt="function"==typeof Math.imul&&-2===Math.imul(4294967295,2)?Math.imul:function(t,e){var r=65535&(t|=0),n=65535&(e|=0);return r*n+((t>>>16)*n+r*(e>>>16)<<16>>>0)|0};function _t(t){return t>>>1&1073741824|3221225471&t}var lt=Object.prototype.valueOf;function vt(t){if(null==t)return yt(t);if("function"==typeof t.hashCode)return _t(t.hashCode(t));var e,r=(e=t).valueOf!==lt&&"function"==typeof e.valueOf?e.valueOf(e):e;if(null==r)return yt(r);switch(typeof r){case"boolean":return r?1108378657:1108378656;case"number":return function(t){if(t!=t||t===1/0)return 0;var e=0|t;e!==t&&(e^=4294967295*t);for(;t>4294967295;)e^=t/=4294967295;return _t(e)}(r);case"string":return r.length>Et?function(t){var e=Mt[t];void 0===e&&(e=dt(t),jt===qt&&(jt=0,Mt={}),jt++,Mt[t]=e);return e}(r):dt(r);case"object":case"function":return function(t){var e;if(St&&void 0!==(e=zt.get(t)))return e;if(e=t[Ot],void 0!==e)return e;if(!wt){if(void 0!==(e=t.propertyIsEnumerable&&t.propertyIsEnumerable[Ot]))return e;if(void 0!==(e=function(t){if(t&&t.nodeType>0)switch(t.nodeType){case 1:return t.uniqueID;case 9:return t.documentElement&&t.documentElement.uniqueID}}(t)))return e}if(e=mt(),St)zt.set(t,e);else{if(void 0!==gt&&!1===gt(t))throw new Error("Non-extensible objects are not allowed as keys.");if(wt)Object.defineProperty(t,Ot,{enumerable:!1,configurable:!1,writable:!1,value:e});else if(void 0!==t.propertyIsEnumerable&&t.propertyIsEnumerable===t.constructor.prototype.propertyIsEnumerable)t.propertyIsEnumerable=function(){return this.constructor.prototype.propertyIsEnumerable.apply(this,arguments)},t.propertyIsEnumerable[Ot]=e;else{if(void 0===t.nodeType)throw new Error("Unable to set a non-enumerable property on object.");t[Ot]=e}}return e}(r);case"symbol":return function(t){var e=bt[t];if(void 0!==e)return e;return e=mt(),bt[t]=e,e}(r);default:if("function"==typeof r.toString)return dt(r.toString());throw new Error("Value type "+typeof r+" cannot be hashed.")}}function yt(t){return null===t?1108378658:1108378659}function dt(t){for(var e=0,r=0;r=0&&(a.get=function(e,r){return(e=c(this,e))>=0&&eo)return{value:void 0,done:!0};var t=i.next();return n||e===U||t.done?t:P(e,a-1,e===R?void 0:t.value[1],t)}))},a}function Lt(t,e,r,n){var i=Qt(t);return i.__iterateUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterate(i,o);var s=!0,a=0;return t.__iterate((function(t,o,c){if(!s||!(s=e.call(r,t,o,c)))return a++,i(t,n?o:a-1,u)})),a},i.__iteratorUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterator(i,o);var s=t.__iterator(T,o),a=!0,c=0;return new C((function(){var t,o,f;do{if((t=s.next()).done)return n||i===U?t:P(i,c++,i===R?void 0:t.value[1],t);var h=t.value;o=h[0],f=h[1],a&&(a=e.call(r,f,o,u))}while(a);return i===T?t:P(i,o,f,t)}))},i}function Ct(t,e,r){var n=Qt(t);return n.__iterateUncached=function(i,o){if(o)return this.cacheResult().__iterate(i,o);var u=0,s=!1;return function t(a,c){a.__iterate((function(o,a){return(!e||c0}function Ht(t,e,r,n){var i=Qt(t),o=new $(r).map((function(t){return t.size}));return i.size=n?o.max():o.min(),i.__iterate=function(t,e){for(var r,n=this.__iterator(U,e),i=0;!(r=n.next()).done&&!1!==t(r.value,i++,this););return i},i.__iteratorUncached=function(t,i){var o=r.map((function(t){return t=b(t),J(i?t.reverse():t)})),u=0,s=!1;return new C((function(){var r;return s||(r=o.map((function(t){return t.next()})),s=n?r.every((function(t){return t.done})):r.some((function(t){return t.done}))),s?{value:void 0,done:!0}:P(t,u++,e.apply(null,r.map((function(t){return t.value}))))}))},i}function Jt(t,e){return t===e?t:j(t)?e:t.constructor(e)}function Vt(t){if(t!==Object(t))throw new TypeError("Expected [K, V] tuple: "+t)}function Yt(t){return w(t)?I:z(t)?O:E}function Qt(t){return Object.create((w(t)?F:z(t)?G:Z).prototype)}function Xt(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size,this):X.prototype.cacheResult.call(this)}function Ft(t,e){return void 0===t&&void 0===e?0:void 0===t?1:void 0===e?-1:t>e?1:t0;)e[r]=arguments[r+1];if("function"!=typeof t)throw new TypeError("Invalid merger function: "+t);return ze(this,e,t)}function ze(t,e,r){for(var n=[],i=0;i0;)e[r]=arguments[r+1];return Se(this,e,t)}function Ee(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return fe(this,t,He(),(function(t){return be(t,e)}))}function qe(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return fe(this,t,He(),(function(t){return Se(t,e)}))}function je(t){var e=this.asMutable();return t(e),e.wasAltered()?e.__ensureOwner(this.__ownerID):this}function Me(){return this.__ownerID?this:this.__ensureOwner(new s)}function De(){return this.__ensureOwner()}function xe(){return this.__altered}var Ae=function(t){function e(e){return null==e?He():at(e)&&!k(e)?e:He().withMutations((function(r){var n=t(e);$t(n.size),n.forEach((function(t,e){return r.set(e,t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toString=function(){return this.__toString("Map {","}")},e.prototype.get=function(t,e){return this._root?this._root.get(0,void 0,t,e):e},e.prototype.set=function(t,e){return Je(this,t,e)},e.prototype.remove=function(t){return Je(this,t,o)},e.prototype.deleteAll=function(t){var e=b(t);return 0===e.size?this:this.withMutations((function(t){e.forEach((function(e){return t.remove(e)}))}))},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):He()},e.prototype.sort=function(t){return yr(Pt(this,t))},e.prototype.sortBy=function(t,e){return yr(Pt(this,e,t))},e.prototype.map=function(t,e){var r=this;return this.withMutations((function(n){n.forEach((function(i,o){n.set(o,t.call(e,i,o,r))}))}))},e.prototype.__iterator=function(t,e){return new Ce(this,t,e)},e.prototype.__iterate=function(t,e){var r=this,n=0;return this._root&&this._root.iterate((function(e){return n++,t(e[1],e[0],r)}),e),n},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Ne(this.size,this._root,t,this.__hash):0===this.size?He():(this.__ownerID=t,this.__altered=!1,this)},e}(I);Ae.isMap=at;var ke=Ae.prototype;ke[st]=!0,ke[e]=ke.remove,ke.removeAll=ke.deleteAll,ke.setIn=_e,ke.removeIn=ke.deleteIn=ve,ke.update=de,ke.updateIn=ge,ke.merge=ke.concat=we,ke.mergeWith=me,ke.mergeDeep=Ie,ke.mergeDeepWith=Oe,ke.mergeIn=Ee,ke.mergeDeepIn=qe,ke.withMutations=je,ke.wasAltered=xe,ke.asImmutable=De,ke["@@transducer/init"]=ke.asMutable=Me,ke["@@transducer/step"]=function(t,e){return t.set(e[0],e[1])},ke["@@transducer/result"]=function(t){return t.asImmutable()};var Re=function(t,e){this.ownerID=t,this.entries=e};Re.prototype.get=function(t,e,r,n){for(var i=this.entries,o=0,u=i.length;o=Ge)return function(t,e,r,n){t||(t=new s);for(var i=new Ke(t,vt(r),[r,n]),o=0;o>>t)&i),s=this.bitmap;return 0==(s&u)?o:this.nodes[Xe(s&u-1)].get(t+r,e,n,o)},Ue.prototype.update=function(t,e,u,s,a,c,f){void 0===u&&(u=vt(s));var h=(0===e?u:u>>>e)&i,p=1<=Ze)return function(t,e,r,i,o){for(var u=0,s=new Array(n),a=0;0!==r;a++,r>>>=1)s[a]=1&r?e[u++]:void 0;return s[i]=o,new Te(t,u+1,s)}(t,y,_,h,g);if(l&&!g&&2===y.length&&Ye(y[1^v]))return y[1^v];if(l&&g&&1===y.length&&Ye(g))return g;var w=t&&t===this.ownerID,m=l?g?_:_^p:_|p,z=l?g?Fe(y,v,g,w):function(t,e,r){var n=t.length-1;if(r&&e===n)return t.pop(),t;for(var i=new Array(n),o=0,u=0;u>>t)&i,s=this.nodes[u];return s?s.get(t+r,e,n,o):o},Te.prototype.update=function(t,e,n,u,s,a,c){void 0===n&&(n=vt(u));var f=(0===e?n:n>>>e)&i,h=s===o,p=this.nodes,_=p[f];if(h&&!_)return this;var l=Ve(_,t,e+r,n,u,s,a,c);if(l===_)return this;var v=this.count;if(_){if(!l&&--v<$e)return function(t,e,r,n){for(var i=0,o=0,u=new Array(r),s=0,a=1,c=e.length;s>>n)&i,c=(0===n?o:o>>>n)&i,f=a===c?[Qe(t,e,n+r,o,u)]:(s=new Ke(e,o,u),a>1&1431655765))+(t>>2&858993459))+(t>>4)&252645135,t+=t>>8,127&(t+=t>>16)}function Fe(t,e,r,n){var i=n?t:Gt(t);return i[e]=r,i}var Ge=n/4,Ze=n/2,$e=n/4,tr="@@__IMMUTABLE_LIST__@@";function er(t){return Boolean(t&&t[tr])}var rr=function(t){function e(e){var i=cr();if(null==e)return i;if(er(e))return e;var o=t(e),u=o.size;return 0===u?i:($t(u),u>0&&u=0&&t=t.size||e<0)return t.withMutations((function(t){e<0?_r(t,e).set(0,r):_r(t,0,e+1).set(e,r)}));e+=t._origin;var n=t._tail,i=t._root,o={value:!1};e>=lr(t._capacity)?n=fr(n,t.__ownerID,0,e,r,o):i=fr(i,t.__ownerID,t._level,e,r,o);if(!o.value)return t;if(t.__ownerID)return t._root=i,t._tail=n,t.__hash=void 0,t.__altered=!0,t;return ar(t._origin,t._capacity,t._level,i,n)}(this,t,e)},e.prototype.remove=function(t){return this.has(t)?0===t?this.shift():t===this.size-1?this.pop():this.splice(t,1):this},e.prototype.insert=function(t,e){return this.splice(t,0,e)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=this._origin=this._capacity=0,this._level=r,this._root=this._tail=this.__hash=void 0,this.__altered=!0,this):cr()},e.prototype.push=function(){var t=arguments,e=this.size;return this.withMutations((function(r){_r(r,0,e+t.length);for(var n=0;n>>e&i;if(o>=this.array.length)return new ir([],t);var u,s=0===o;if(e>0){var a=this.array[o];if((u=a&&a.removeBefore(t,e-r,n))===a&&s)return this}if(s&&!u)return this;var c=hr(this,t);if(!s)for(var f=0;f>>e&i;if(u>=this.array.length)return this;if(e>0){var s=this.array[u];if((o=s&&s.removeAfter(t,e-r,n))===s&&u===this.array.length-1)return this}var a=hr(this,t);return a.array.splice(u+1),o&&(a.array[u]=o),a};var or,ur={};function sr(t,e){var i=t._origin,o=t._capacity,u=lr(o),s=t._tail;return a(t._root,t._level,0);function a(t,c,f){return 0===c?function(t,r){var a=r===u?s&&s.array:t&&t.array,c=r>i?0:i-r,f=o-r;f>n&&(f=n);return function(){if(c===f)return ur;var t=e?--f:c++;return a&&a[t]}}(t,f):function(t,u,s){var c,f=t&&t.array,h=s>i?0:i-s>>u,p=1+(o-s>>u);p>n&&(p=n);return function(){for(;;){if(c){var t=c();if(t!==ur)return t;c=null}if(h===p)return ur;var n=e?--p:h++;c=a(f&&f[n],u-r,s+(n<>>n&i,h=t&&f0){var p=t&&t.array[f],_=fr(p,e,n-r,o,s,a);return _===p?t:((c=hr(t,e)).array[f]=_,c)}return h&&t.array[f]===s?t:(a&&u(a),c=hr(t,e),void 0===s&&f===c.array.length-1?c.array.pop():c.array[f]=s,c)}function hr(t,e){return e&&t&&e===t.ownerID?t:new ir(t?t.array.slice():[],e)}function pr(t,e){if(e>=lr(t._capacity))return t._tail;if(e<1<0;)n=n.array[e>>>o&i],o-=r;return n}}function _r(t,e,n){void 0!==e&&(e|=0),void 0!==n&&(n|=0);var o=t.__ownerID||new s,u=t._origin,a=t._capacity,c=u+e,f=void 0===n?a:n<0?a+n:u+n;if(c===u&&f===a)return t;if(c>=f)return t.clear();for(var h=t._level,p=t._root,_=0;c+_<0;)p=new ir(p&&p.array.length?[void 0,p]:[],o),_+=1<<(h+=r);_&&(c+=_,u+=_,f+=_,a+=_);for(var l=lr(a),v=lr(f);v>=1<l?new ir([],o):y;if(y&&v>l&&cr;w-=r){var m=l>>>w&i;g=g.array[m]=hr(g.array[m],o)}g.array[l>>>r&i]=y}if(f=v)c-=v,f-=v,h=r,p=null,d=d&&d.removeBefore(o,0,c);else if(c>u||v>>h&i;if(z!==v>>>h&i)break;z&&(_+=(1<u&&(p=p.removeBefore(o,h,c-_)),p&&v>>r<=n&&a.size>=2*s.size?(i=(u=a.filter((function(t,e){return void 0!==t&&c!==e}))).toKeyedSeq().map((function(t){return t[0]})).flip().toMap(),t.__ownerID&&(i.__ownerID=u.__ownerID=t.__ownerID)):(i=s.remove(e),u=c===a.size-1?a.pop():a.set(c,void 0))}else if(f){if(r===a.get(c)[1])return t;i=s,u=a.set(c,[e,r])}else i=s.set(e,a.size),u=a.set(a.size,[e,r]);return t.__ownerID?(t.size=i.size,t._map=i,t._list=u,t.__hash=void 0,t.__altered=!0,t):dr(i,u)}yr.isOrderedMap=ct,yr.prototype[A]=!0,yr.prototype[e]=yr.prototype.remove;var mr="@@__IMMUTABLE_STACK__@@";function zr(t){return Boolean(t&&t[mr])}var Sr=function(t){function e(t){return null==t?Er():zr(t)?t:Er().pushAll(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("Stack [","]")},e.prototype.get=function(t,e){var r=this._head;for(t=c(this,t);r&&t--;)r=r.next;return r?r.value:e},e.prototype.peek=function(){return this._head&&this._head.value},e.prototype.push=function(){var t=arguments;if(0===arguments.length)return this;for(var e=this.size+arguments.length,r=this._head,n=arguments.length-1;n>=0;n--)r={value:t[n],next:r};return this.__ownerID?(this.size=e,this._head=r,this.__hash=void 0,this.__altered=!0,this):Or(e,r)},e.prototype.pushAll=function(e){if(0===(e=t(e)).size)return this;if(0===this.size&&zr(e))return e;$t(e.size);var r=this.size,n=this._head;return e.__iterate((function(t){r++,n={value:t,next:n}}),!0),this.__ownerID?(this.size=r,this._head=n,this.__hash=void 0,this.__altered=!0,this):Or(r,n)},e.prototype.pop=function(){return this.slice(1)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):Er()},e.prototype.slice=function(e,r){if(h(e,r,this.size))return this;var n=p(e,this.size);if(_(r,this.size)!==this.size)return t.prototype.slice.call(this,e,r);for(var i=this.size-n,o=this._head;n--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):Or(i,o)},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Or(this.size,this._head,t,this.__hash):0===this.size?Er():(this.__ownerID=t,this.__altered=!1,this)},e.prototype.__iterate=function(t,e){var r=this;if(e)return new $(this.toArray()).__iterate((function(e,n){return t(e,n,r)}),e);for(var n=0,i=this._head;i&&!1!==t(i.value,n++,this);)i=i.next;return n},e.prototype.__iterator=function(t,e){if(e)return new $(this.toArray()).__iterator(t,e);var r=0,n=this._head;return new C((function(){if(n){var e=n.value;return n=n.next,P(t,r++,e)}return{value:void 0,done:!0}}))},e}(O);Sr.isStack=zr;var br,Ir=Sr.prototype;function Or(t,e,r,n){var i=Object.create(Ir);return i.size=t,i._head=e,i.__ownerID=r,i.__hash=n,i.__altered=!1,i}function Er(){return br||(br=Or(0))}Ir[mr]=!0,Ir.shift=Ir.pop,Ir.unshift=Ir.push,Ir.unshiftAll=Ir.pushAll,Ir.withMutations=je,Ir.wasAltered=xe,Ir.asImmutable=De,Ir["@@transducer/init"]=Ir.asMutable=Me,Ir["@@transducer/step"]=function(t,e){return t.unshift(e)},Ir["@@transducer/result"]=function(t){return t.asImmutable()};var qr="@@__IMMUTABLE_SET__@@";function jr(t){return Boolean(t&&t[qr])}function Mr(t){return jr(t)&&k(t)}function Dr(t,e){if(t===e)return!0;if(!d(e)||void 0!==t.size&&void 0!==e.size&&t.size!==e.size||void 0!==t.__hash&&void 0!==e.__hash&&t.__hash!==e.__hash||w(t)!==w(e)||z(t)!==z(e)||k(t)!==k(e))return!1;if(0===t.size&&0===e.size)return!0;var r=!S(t);if(k(t)){var n=t.entries();return e.every((function(t,e){var i=n.next().value;return i&&ht(i[1],t)&&(r||ht(i[0],e))}))&&n.next().done}var i=!1;if(void 0===t.size)if(void 0===e.size)"function"==typeof t.cacheResult&&t.cacheResult();else{i=!0;var u=t;t=e,e=u}var s=!0,a=e.__iterate((function(e,n){if(r?!t.has(e):i?!ht(e,t.get(n,o)):!ht(t.get(n,o),e))return s=!1,!1}));return s&&t.size===a}function xr(t,e){var r=function(r){t.prototype[r]=e[r]};return Object.keys(e).forEach(r),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(e).forEach(r),t}function Ar(t){if(!t||"object"!=typeof t)return t;if(!d(t)){if(!ne(t))return t;t=X(t)}if(w(t)){var e={};return t.__iterate((function(t,r){e[r]=Ar(t)})),e}var r=[];return t.__iterate((function(t){r.push(Ar(t))})),r}var kr=function(t){function e(e){return null==e?Kr():jr(e)&&!k(e)?e:Kr().withMutations((function(r){var n=t(e);$t(n.size),n.forEach((function(t){return r.add(t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(I(t).keySeq())},e.intersect=function(t){return(t=b(t).toArray()).length?Ur.intersect.apply(e(t.pop()),t):Kr()},e.union=function(t){return(t=b(t).toArray()).length?Ur.union.apply(e(t.pop()),t):Kr()},e.prototype.toString=function(){return this.__toString("Set {","}")},e.prototype.has=function(t){return this._map.has(t)},e.prototype.add=function(t){return Tr(this,this._map.set(t,t))},e.prototype.remove=function(t){return Tr(this,this._map.remove(t))},e.prototype.clear=function(){return Tr(this,this._map.clear())},e.prototype.map=function(t,e){var r=this,n=!1,i=Tr(this,this._map.mapEntries((function(i){var o=i[1],u=t.call(e,o,o,r);return u!==o&&(n=!0),[u,u]}),e));return n?i:this},e.prototype.union=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return 0===(e=e.filter((function(t){return 0!==t.size}))).length?this:0!==this.size||this.__ownerID||1!==e.length?this.withMutations((function(r){for(var n=0;n=0&&e=0&&r>>-15,461845907),e=pt(e<<13|e>>>-13,5),e=pt((e=(e+3864292196|0)^t)^e>>>16,2246822507),e=_t((e=pt(e^e>>>13,3266489909))^e>>>16)}(t.size,n)}(this))}});var Jr=b.prototype;Jr[y]=!0,Jr[L]=Jr.values,Jr.toJSON=Jr.toArray,Jr.__toStringMapper=ie,Jr.inspect=Jr.toSource=function(){return this.toString()},Jr.chain=Jr.flatMap,Jr.contains=Jr.includes,xr(I,{flip:function(){return Jt(this,Rt(this))},mapEntries:function(t,e){var r=this,n=0;return Jt(this,this.toSeq().map((function(i,o){return t.call(e,[o,i],n++,r)})).fromEntrySeq())},mapKeys:function(t,e){var r=this;return Jt(this,this.toSeq().flip().map((function(n,i){return t.call(e,n,i,r)})).flip())}});var Vr=I.prototype;Vr[g]=!0,Vr[L]=Jr.entries,Vr.toJSON=Hr,Vr.__toStringMapper=function(t,e){return ie(e)+": "+ie(t)},xr(O,{toKeyedSeq:function(){return new Dt(this,!1)},filter:function(t,e){return Jt(this,Bt(this,t,e,!1))},findIndex:function(t,e){var r=this.findEntry(t,e);return r?r[0]:-1},indexOf:function(t){var e=this.keyOf(t);return void 0===e?-1:e},lastIndexOf:function(t){var e=this.lastKeyOf(t);return void 0===e?-1:e},reverse:function(){return Jt(this,Tt(this,!1))},slice:function(t,e){return Jt(this,Kt(this,t,e,!1))},splice:function(t,e){var r=arguments.length;if(e=Math.max(e||0,0),0===r||2===r&&!e)return this;t=p(t,t<0?this.count():this.size);var n=this.slice(0,t);return Jt(this,1===r?n:n.concat(Gt(arguments,2),this.slice(t+e)))},findLastIndex:function(t,e){var r=this.findLastEntry(t,e);return r?r[0]:-1},first:function(t){return this.get(0,t)},flatten:function(t){return Jt(this,Ct(this,t,!1))},get:function(t,e){return(t=c(this,t))<0||this.size===1/0||void 0!==this.size&&t>this.size?e:this.find((function(e,r){return r===t}),void 0,e)},has:function(t){return(t=c(this,t))>=0&&(void 0!==this.size?this.size===1/0||te?-1:0}function rn(t,e){return t^e+2654435769+(t<<6)+(t>>2)|0}Qr.has=Jr.includes,Qr.contains=Qr.includes,Qr.keys=Qr.values,xr(F,Vr),xr(G,Yr),xr(Z,Qr);var nn=function(t){function e(t){return null==t?an():Mr(t)?t:an().withMutations((function(e){var r=E(t);$t(r.size),r.forEach((function(t){return e.add(t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(I(t).keySeq())},e.prototype.toString=function(){return this.__toString("OrderedSet {","}")},e}(kr);nn.isOrderedSet=Mr;var on,un=nn.prototype;function sn(t,e){var r=Object.create(un);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function an(){return on||(on=sn(gr()))}un[A]=!0,un.zip=Yr.zip,un.zipWith=Yr.zipWith,un.zipAll=Yr.zipAll,un.__empty=an,un.__make=sn;var cn=function(t,e){var r;!function(t){if(D(t))throw new Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(x(t))throw new Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(null===t||"object"!=typeof t)throw new Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}(t);var n=function(o){var u=this;if(o instanceof n)return o;if(!(this instanceof n))return new n(o);if(!r){r=!0;var s=Object.keys(t),a=i._indices={};i._name=e,i._keys=s,i._defaultValues=t;for(var c=0;c2?[]:void 0,{"":t})},t.get=ue,t.getIn=Pr,t.has=oe,t.hasIn=Nr,t.hash=vt,t.is=ht,t.isAssociative=S,t.isCollection=d,t.isImmutable=x,t.isIndexed=z,t.isKeyed=w,t.isList=er,t.isMap=at,t.isOrdered=k,t.isOrderedMap=ct,t.isOrderedSet=Mr,t.isPlainObject=re,t.isRecord=D,t.isSeq=j,t.isSet=jr,t.isStack=zr,t.isValueObject=ft,t.merge=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return be(t,e)},t.mergeDeep=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Se(t,e)},t.mergeDeepWith=function(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];return Se(e,r,t)},t.mergeWith=function(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];return be(e,r,t)},t.remove=ae,t.removeIn=le,t.set=ce,t.setIn=pe,t.update=ye,t.updateIn=fe,t.version="5.0.0-rc.1"})); +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).Immutable={})}(this,(function(t){"use strict";var e="delete",r=5,n=1<>>0;if(""+r!==e||4294967295===r)return NaN;e=r}return e<0?a(t)+e:e}function f(){return!0}function h(t,e,r){return(0===t&&!v(t)||void 0!==r&&t<=-r)&&(void 0===e||void 0!==r&&e>=r)}function p(t,e){return l(t,e,0)}function _(t,e){return l(t,e,e)}function l(t,e,r){return void 0===t?r:v(t)?e===1/0?e:0|Math.max(0,e+t):void 0===e||e===t?t:0|Math.min(e,t)}function v(t){return t<0||0===t&&1/t==-1/0}var y="@@__IMMUTABLE_ITERABLE__@@";function d(t){return Boolean(t&&t[y])}var g="@@__IMMUTABLE_KEYED__@@";function w(t){return Boolean(t&&t[g])}var m="@@__IMMUTABLE_INDEXED__@@";function z(t){return Boolean(t&&t[m])}function S(t){return w(t)||z(t)}var b=function(t){return d(t)?t:X(t)},I=function(t){function e(t){return w(t)?t:F(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(b),O=function(t){function e(t){return z(t)?t:G(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(b),E=function(t){function e(t){return d(t)&&!S(t)?t:Z(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(b);b.Keyed=I,b.Indexed=O,b.Set=E;var q="@@__IMMUTABLE_SEQ__@@";function j(t){return Boolean(t&&t[q])}var M="@@__IMMUTABLE_RECORD__@@";function D(t){return Boolean(t&&t[M])}function x(t){return d(t)||D(t)}var A="@@__IMMUTABLE_ORDERED__@@";function k(t){return Boolean(t&&t[A])}var R=0,U=1,T=2,B="function"==typeof Symbol&&Symbol.iterator,K="@@iterator",L=B||K,C=function(t){this.next=t};function P(t,e,r,n){var i=0===t?e:1===t?r:[e,r];return n?n.value=i:n={value:i,done:!1},n}function W(){return{value:void 0,done:!0}}function N(t){return!!Array.isArray(t)||!!V(t)}function H(t){return t&&"function"==typeof t.next}function J(t){var e=V(t);return e&&e.call(t)}function V(t){var e=t&&(B&&t[B]||t[K]);if("function"==typeof e)return e}C.prototype.toString=function(){return"[Iterator]"},C.KEYS=R,C.VALUES=U,C.ENTRIES=T,C.prototype.inspect=C.prototype.toSource=function(){return this.toString()},C.prototype[L]=function(){return this};var Y=Object.prototype.hasOwnProperty;function Q(t){return!(!Array.isArray(t)&&"string"!=typeof t)||t&&"object"==typeof t&&Number.isInteger(t.length)&&t.length>=0&&(0===t.length?1===Object.keys(t).length:t.hasOwnProperty(t.length-1))}var X=function(t){function e(t){return null==t?nt():x(t)?t.toSeq():function(t){var e=ut(t);if(e)return(n=V(r=t))&&n===r.entries?e.fromEntrySeq():function(t){var e=V(t);return e&&e===t.keys}(t)?e.toSetSeq():e;var r,n;if("object"==typeof t)return new tt(t);throw new TypeError("Expected Array or collection object of values, or keyed object: "+t)}(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq {","}")},e.prototype.cacheResult=function(){return!this._cache&&this.__iterateUncached&&(this._cache=this.entrySeq().toArray(),this.size=this._cache.length),this},e.prototype.__iterate=function(t,e){var r=this._cache;if(r){for(var n=r.length,i=0;i!==n;){var o=r[e?n-++i:i++];if(!1===t(o[1],o[0],this))break}return i}return this.__iterateUncached(t,e)},e.prototype.__iterator=function(t,e){var r=this._cache;if(r){var n=r.length,i=0;return new C((function(){if(i===n)return{value:void 0,done:!0};var o=r[e?n-++i:i++];return P(t,o[0],o[1])}))}return this.__iteratorUncached(t,e)},e}(b),F=function(t){function e(t){return null==t?nt().toKeyedSeq():d(t)?w(t)?t.toSeq():t.fromEntrySeq():D(t)?t.toSeq():it(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toKeyedSeq=function(){return this},e}(X),G=function(t){function e(t){return null==t?nt():d(t)?w(t)?t.entrySeq():t.toIndexedSeq():D(t)?t.toSeq().entrySeq():ot(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return e(arguments)},e.prototype.toIndexedSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq [","]")},e}(X),Z=function(t){function e(t){return(d(t)&&!S(t)?t:G(t)).toSetSeq()}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return e(arguments)},e.prototype.toSetSeq=function(){return this},e}(X);X.isSeq=j,X.Keyed=F,X.Set=Z,X.Indexed=G,X.prototype[q]=!0;var $=function(t){function e(t){this._array=t,this.size=t.length}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t,e){return this.has(t)?this._array[c(this,t)]:e},e.prototype.__iterate=function(t,e){for(var r=this._array,n=r.length,i=0;i!==n;){var o=e?n-++i:i++;if(!1===t(r[o],o,this))break}return i},e.prototype.__iterator=function(t,e){var r=this._array,n=r.length,i=0;return new C((function(){if(i===n)return{value:void 0,done:!0};var o=e?n-++i:i++;return P(t,o,r[o])}))},e}(G),tt=function(t){function e(t){var e=Object.keys(t).concat(Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(t):[]);this._object=t,this._keys=e,this.size=e.length}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t,e){return void 0===e||this.has(t)?this._object[t]:e},e.prototype.has=function(t){return Y.call(this._object,t)},e.prototype.__iterate=function(t,e){for(var r=this._object,n=this._keys,i=n.length,o=0;o!==i;){var u=n[e?i-++o:o++];if(!1===t(r[u],u,this))break}return o},e.prototype.__iterator=function(t,e){var r=this._object,n=this._keys,i=n.length,o=0;return new C((function(){if(o===i)return{value:void 0,done:!0};var u=n[e?i-++o:o++];return P(t,u,r[u])}))},e}(F);tt.prototype[A]=!0;var et,rt=function(t){function e(t){this._collection=t,this.size=t.length||t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.__iterateUncached=function(t,e){if(e)return this.cacheResult().__iterate(t,e);var r=J(this._collection),n=0;if(H(r))for(var i;!(i=r.next()).done&&!1!==t(i.value,n++,this););return n},e.prototype.__iteratorUncached=function(t,e){if(e)return this.cacheResult().__iterator(t,e);var r=J(this._collection);if(!H(r))return new C(W);var n=0;return new C((function(){var e=r.next();return e.done?e:P(t,n++,e.value)}))},e}(G);function nt(){return et||(et=new $([]))}function it(t){var e=ut(t);if(e)return e.fromEntrySeq();if("object"==typeof t)return new tt(t);throw new TypeError("Expected Array or collection object of [k, v] entries, or keyed object: "+t)}function ot(t){var e=ut(t);if(e)return e;throw new TypeError("Expected Array or collection object of values: "+t)}function ut(t){return Q(t)?new $(t):N(t)?new rt(t):void 0}var st="@@__IMMUTABLE_MAP__@@";function at(t){return Boolean(t&&t[st])}function ct(t){return at(t)&&k(t)}function ft(t){return Boolean(t&&"function"==typeof t.equals&&"function"==typeof t.hashCode)}function ht(t,e){if(t===e||t!=t&&e!=e)return!0;if(!t||!e)return!1;if("function"==typeof t.valueOf&&"function"==typeof e.valueOf){if((t=t.valueOf())===(e=e.valueOf())||t!=t&&e!=e)return!0;if(!t||!e)return!1}return!!(ft(t)&&ft(e)&&t.equals(e))}var pt="function"==typeof Math.imul&&-2===Math.imul(4294967295,2)?Math.imul:function(t,e){var r=65535&(t|=0),n=65535&(e|=0);return r*n+((t>>>16)*n+r*(e>>>16)<<16>>>0)|0};function _t(t){return t>>>1&1073741824|3221225471&t}var lt=Object.prototype.valueOf;function vt(t){if(null==t)return yt(t);if("function"==typeof t.hashCode)return _t(t.hashCode(t));var e,r=(e=t).valueOf!==lt&&"function"==typeof e.valueOf?e.valueOf(e):e;if(null==r)return yt(r);switch(typeof r){case"boolean":return r?1108378657:1108378656;case"number":return function(t){if(t!=t||t===1/0)return 0;var e=0|t;e!==t&&(e^=4294967295*t);for(;t>4294967295;)e^=t/=4294967295;return _t(e)}(r);case"string":return r.length>Et?function(t){var e=Mt[t];void 0===e&&(e=dt(t),jt===qt&&(jt=0,Mt={}),jt++,Mt[t]=e);return e}(r):dt(r);case"object":case"function":return function(t){var e;if(St&&void 0!==(e=zt.get(t)))return e;if(e=t[Ot],void 0!==e)return e;if(!wt){if(void 0!==(e=t.propertyIsEnumerable&&t.propertyIsEnumerable[Ot]))return e;if(void 0!==(e=function(t){if(t&&t.nodeType>0)switch(t.nodeType){case 1:return t.uniqueID;case 9:return t.documentElement&&t.documentElement.uniqueID}}(t)))return e}if(e=mt(),St)zt.set(t,e);else{if(void 0!==gt&&!1===gt(t))throw new Error("Non-extensible objects are not allowed as keys.");if(wt)Object.defineProperty(t,Ot,{enumerable:!1,configurable:!1,writable:!1,value:e});else if(void 0!==t.propertyIsEnumerable&&t.propertyIsEnumerable===t.constructor.prototype.propertyIsEnumerable)t.propertyIsEnumerable=function(){return this.constructor.prototype.propertyIsEnumerable.apply(this,arguments)},t.propertyIsEnumerable[Ot]=e;else{if(void 0===t.nodeType)throw new Error("Unable to set a non-enumerable property on object.");t[Ot]=e}}return e}(r);case"symbol":return function(t){var e=bt[t];if(void 0!==e)return e;return e=mt(),bt[t]=e,e}(r);default:if("function"==typeof r.toString)return dt(r.toString());throw new Error("Value type "+typeof r+" cannot be hashed.")}}function yt(t){return null===t?1108378658:1108378659}function dt(t){for(var e=0,r=0;r=0&&(a.get=function(e,r){return(e=c(this,e))>=0&&eo)return{value:void 0,done:!0};var t=i.next();return n||e===U||t.done?t:P(e,a-1,e===R?void 0:t.value[1],t)}))},a}function Lt(t,e,r,n){var i=Qt(t);return i.__iterateUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterate(i,o);var s=!0,a=0;return t.__iterate((function(t,o,c){if(!s||!(s=e.call(r,t,o,c)))return a++,i(t,n?o:a-1,u)})),a},i.__iteratorUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterator(i,o);var s=t.__iterator(T,o),a=!0,c=0;return new C((function(){var t,o,f;do{if((t=s.next()).done)return n||i===U?t:P(i,c++,i===R?void 0:t.value[1],t);var h=t.value;o=h[0],f=h[1],a&&(a=e.call(r,f,o,u))}while(a);return i===T?t:P(i,o,f,t)}))},i}function Ct(t,e,r){var n=Qt(t);return n.__iterateUncached=function(i,o){if(o)return this.cacheResult().__iterate(i,o);var u=0,s=!1;return function t(a,c){a.__iterate((function(o,a){return(!e||c0}function Ht(t,e,r,n){var i=Qt(t),o=new $(r).map((function(t){return t.size}));return i.size=n?o.max():o.min(),i.__iterate=function(t,e){for(var r,n=this.__iterator(U,e),i=0;!(r=n.next()).done&&!1!==t(r.value,i++,this););return i},i.__iteratorUncached=function(t,i){var o=r.map((function(t){return t=b(t),J(i?t.reverse():t)})),u=0,s=!1;return new C((function(){var r;return s||(r=o.map((function(t){return t.next()})),s=n?r.every((function(t){return t.done})):r.some((function(t){return t.done}))),s?{value:void 0,done:!0}:P(t,u++,e.apply(null,r.map((function(t){return t.value}))))}))},i}function Jt(t,e){return t===e?t:j(t)?e:t.constructor(e)}function Vt(t){if(t!==Object(t))throw new TypeError("Expected [K, V] tuple: "+t)}function Yt(t){return w(t)?I:z(t)?O:E}function Qt(t){return Object.create((w(t)?F:z(t)?G:Z).prototype)}function Xt(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size,this):X.prototype.cacheResult.call(this)}function Ft(t,e){return void 0===t&&void 0===e?0:void 0===t?1:void 0===e?-1:t>e?1:t0;)e[r]=arguments[r+1];if("function"!=typeof t)throw new TypeError("Invalid merger function: "+t);return ze(this,e,t)}function ze(t,e,r){for(var n=[],i=0;i0;)e[r]=arguments[r+1];return Se(this,e,t)}function Ee(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return fe(this,t,He(),(function(t){return be(t,e)}))}function qe(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return fe(this,t,He(),(function(t){return Se(t,e)}))}function je(t){var e=this.asMutable();return t(e),e.wasAltered()?e.__ensureOwner(this.__ownerID):this}function Me(){return this.__ownerID?this:this.__ensureOwner(new s)}function De(){return this.__ensureOwner()}function xe(){return this.__altered}var Ae=function(t){function e(e){return null==e?He():at(e)&&!k(e)?e:He().withMutations((function(r){var n=t(e);$t(n.size),n.forEach((function(t,e){return r.set(e,t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toString=function(){return this.__toString("Map {","}")},e.prototype.get=function(t,e){return this._root?this._root.get(0,void 0,t,e):e},e.prototype.set=function(t,e){return Je(this,t,e)},e.prototype.remove=function(t){return Je(this,t,o)},e.prototype.deleteAll=function(t){var e=b(t);return 0===e.size?this:this.withMutations((function(t){e.forEach((function(e){return t.remove(e)}))}))},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):He()},e.prototype.sort=function(t){return vr(Pt(this,t))},e.prototype.sortBy=function(t,e){return vr(Pt(this,e,t))},e.prototype.map=function(t,e){var r=this;return this.withMutations((function(n){n.forEach((function(i,o){n.set(o,t.call(e,i,o,r))}))}))},e.prototype.__iterator=function(t,e){return new Ce(this,t,e)},e.prototype.__iterate=function(t,e){var r=this,n=0;return this._root&&this._root.iterate((function(e){return n++,t(e[1],e[0],r)}),e),n},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Ne(this.size,this._root,t,this.__hash):0===this.size?He():(this.__ownerID=t,this.__altered=!1,this)},e}(I);Ae.isMap=at;var ke=Ae.prototype;ke[st]=!0,ke[e]=ke.remove,ke.removeAll=ke.deleteAll,ke.setIn=_e,ke.removeIn=ke.deleteIn=ve,ke.update=de,ke.updateIn=ge,ke.merge=ke.concat=we,ke.mergeWith=me,ke.mergeDeep=Ie,ke.mergeDeepWith=Oe,ke.mergeIn=Ee,ke.mergeDeepIn=qe,ke.withMutations=je,ke.wasAltered=xe,ke.asImmutable=De,ke["@@transducer/init"]=ke.asMutable=Me,ke["@@transducer/step"]=function(t,e){return t.set(e[0],e[1])},ke["@@transducer/result"]=function(t){return t.asImmutable()};var Re=function(t,e){this.ownerID=t,this.entries=e};Re.prototype.get=function(t,e,r,n){for(var i=this.entries,o=0,u=i.length;o=Ge)return function(t,e,r,n){t||(t=new s);for(var i=new Ke(t,vt(r),[r,n]),o=0;o>>t)&i),s=this.bitmap;return 0==(s&u)?o:this.nodes[Xe(s&u-1)].get(t+r,e,n,o)},Ue.prototype.update=function(t,e,u,s,a,c,f){void 0===u&&(u=vt(s));var h=(0===e?u:u>>>e)&i,p=1<=Ze)return function(t,e,r,i,o){for(var u=0,s=new Array(n),a=0;0!==r;a++,r>>>=1)s[a]=1&r?e[u++]:void 0;return s[i]=o,new Te(t,u+1,s)}(t,y,_,h,g);if(l&&!g&&2===y.length&&Ye(y[1^v]))return y[1^v];if(l&&g&&1===y.length&&Ye(g))return g;var w=t&&t===this.ownerID,m=l?g?_:_^p:_|p,z=l?g?Fe(y,v,g,w):function(t,e,r){var n=t.length-1;if(r&&e===n)return t.pop(),t;for(var i=new Array(n),o=0,u=0;u>>t)&i,s=this.nodes[u];return s?s.get(t+r,e,n,o):o},Te.prototype.update=function(t,e,n,u,s,a,c){void 0===n&&(n=vt(u));var f=(0===e?n:n>>>e)&i,h=s===o,p=this.nodes,_=p[f];if(h&&!_)return this;var l=Ve(_,t,e+r,n,u,s,a,c);if(l===_)return this;var v=this.count;if(_){if(!l&&--v<$e)return function(t,e,r,n){for(var i=0,o=0,u=new Array(r),s=0,a=1,c=e.length;s>>n)&i,c=(0===n?o:o>>>n)&i,f=a===c?[Qe(t,e,n+r,o,u)]:(s=new Ke(e,o,u),a>1&1431655765))+(t>>2&858993459))+(t>>4)&252645135,t+=t>>8,127&(t+=t>>16)}function Fe(t,e,r,n){var i=n?t:Gt(t);return i[e]=r,i}var Ge=n/4,Ze=n/2,$e=n/4,tr="@@__IMMUTABLE_LIST__@@";function er(t){return Boolean(t&&t[tr])}var rr=function(t){function e(e){var i=ar();if(null==e)return i;if(er(e))return e;var o=t(e),u=o.size;return 0===u?i:($t(u),u>0&&u=0&&t=t.size||e<0)return t.withMutations((function(t){e<0?pr(t,e).set(0,r):pr(t,0,e+1).set(e,r)}));e+=t._origin;var n=t._tail,i=t._root,o={value:!1};e>=_r(t._capacity)?n=cr(n,t.__ownerID,0,e,r,o):i=cr(i,t.__ownerID,t._level,e,r,o);if(!o.value)return t;if(t.__ownerID)return t._root=i,t._tail=n,t.__hash=void 0,t.__altered=!0,t;return sr(t._origin,t._capacity,t._level,i,n)}(this,t,e)},e.prototype.remove=function(t){return this.has(t)?0===t?this.shift():t===this.size-1?this.pop():this.splice(t,1):this},e.prototype.insert=function(t,e){return this.splice(t,0,e)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=this._origin=this._capacity=0,this._level=r,this._root=this._tail=this.__hash=void 0,this.__altered=!0,this):ar()},e.prototype.push=function(){var t=arguments,e=this.size;return this.withMutations((function(r){pr(r,0,e+t.length);for(var n=0;n>>e&i;if(o>=this.array.length)return new ir([],t);var u,s=0===o;if(e>0){var a=this.array[o];if((u=a&&a.removeBefore(t,e-r,n))===a&&s)return this}if(s&&!u)return this;var c=fr(this,t);if(!s)for(var f=0;f>>e&i;if(u>=this.array.length)return this;if(e>0){var s=this.array[u];if((o=s&&s.removeAfter(t,e-r,n))===s&&u===this.array.length-1)return this}var a=fr(this,t);return a.array.splice(u+1),o&&(a.array[u]=o),a};var or={};function ur(t,e){var i=t._origin,o=t._capacity,u=_r(o),s=t._tail;return a(t._root,t._level,0);function a(t,c,f){return 0===c?function(t,r){var a=r===u?s&&s.array:t&&t.array,c=r>i?0:i-r,f=o-r;f>n&&(f=n);return function(){if(c===f)return or;var t=e?--f:c++;return a&&a[t]}}(t,f):function(t,u,s){var c,f=t&&t.array,h=s>i?0:i-s>>u,p=1+(o-s>>u);p>n&&(p=n);return function(){for(;;){if(c){var t=c();if(t!==or)return t;c=null}if(h===p)return or;var n=e?--p:h++;c=a(f&&f[n],u-r,s+(n<>>n&i,h=t&&f0){var p=t&&t.array[f],_=cr(p,e,n-r,o,s,a);return _===p?t:((c=fr(t,e)).array[f]=_,c)}return h&&t.array[f]===s?t:(a&&u(a),c=fr(t,e),void 0===s&&f===c.array.length-1?c.array.pop():c.array[f]=s,c)}function fr(t,e){return e&&t&&e===t.ownerID?t:new ir(t?t.array.slice():[],e)}function hr(t,e){if(e>=_r(t._capacity))return t._tail;if(e<1<0;)n=n.array[e>>>o&i],o-=r;return n}}function pr(t,e,n){void 0!==e&&(e|=0),void 0!==n&&(n|=0);var o=t.__ownerID||new s,u=t._origin,a=t._capacity,c=u+e,f=void 0===n?a:n<0?a+n:u+n;if(c===u&&f===a)return t;if(c>=f)return t.clear();for(var h=t._level,p=t._root,_=0;c+_<0;)p=new ir(p&&p.array.length?[void 0,p]:[],o),_+=1<<(h+=r);_&&(c+=_,u+=_,f+=_,a+=_);for(var l=_r(a),v=_r(f);v>=1<l?new ir([],o):y;if(y&&v>l&&cr;w-=r){var m=l>>>w&i;g=g.array[m]=fr(g.array[m],o)}g.array[l>>>r&i]=y}if(f=v)c-=v,f-=v,h=r,p=null,d=d&&d.removeBefore(o,0,c);else if(c>u||v>>h&i;if(z!==v>>>h&i)break;z&&(_+=(1<u&&(p=p.removeBefore(o,h,c-_)),p&&v>>r<=n&&a.size>=2*s.size?(i=(u=a.filter((function(t,e){return void 0!==t&&c!==e}))).toKeyedSeq().map((function(t){return t[0]})).flip().toMap(),t.__ownerID&&(i.__ownerID=u.__ownerID=t.__ownerID)):(i=s.remove(e),u=c===a.size-1?a.pop():a.set(c,void 0))}else if(f){if(r===a.get(c)[1])return t;i=s,u=a.set(c,[e,r])}else i=s.set(e,a.size),u=a.set(a.size,[e,r]);return t.__ownerID?(t.size=i.size,t._map=i,t._list=u,t.__hash=void 0,t.__altered=!0,t):yr(i,u)}vr.isOrderedMap=ct,vr.prototype[A]=!0,vr.prototype[e]=vr.prototype.remove;var wr="@@__IMMUTABLE_STACK__@@";function mr(t){return Boolean(t&&t[wr])}var zr=function(t){function e(t){return null==t?Or():mr(t)?t:Or().pushAll(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("Stack [","]")},e.prototype.get=function(t,e){var r=this._head;for(t=c(this,t);r&&t--;)r=r.next;return r?r.value:e},e.prototype.peek=function(){return this._head&&this._head.value},e.prototype.push=function(){var t=arguments;if(0===arguments.length)return this;for(var e=this.size+arguments.length,r=this._head,n=arguments.length-1;n>=0;n--)r={value:t[n],next:r};return this.__ownerID?(this.size=e,this._head=r,this.__hash=void 0,this.__altered=!0,this):Ir(e,r)},e.prototype.pushAll=function(e){if(0===(e=t(e)).size)return this;if(0===this.size&&mr(e))return e;$t(e.size);var r=this.size,n=this._head;return e.__iterate((function(t){r++,n={value:t,next:n}}),!0),this.__ownerID?(this.size=r,this._head=n,this.__hash=void 0,this.__altered=!0,this):Ir(r,n)},e.prototype.pop=function(){return this.slice(1)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):Or()},e.prototype.slice=function(e,r){if(h(e,r,this.size))return this;var n=p(e,this.size);if(_(r,this.size)!==this.size)return t.prototype.slice.call(this,e,r);for(var i=this.size-n,o=this._head;n--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):Ir(i,o)},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Ir(this.size,this._head,t,this.__hash):0===this.size?Or():(this.__ownerID=t,this.__altered=!1,this)},e.prototype.__iterate=function(t,e){var r=this;if(e)return new $(this.toArray()).__iterate((function(e,n){return t(e,n,r)}),e);for(var n=0,i=this._head;i&&!1!==t(i.value,n++,this);)i=i.next;return n},e.prototype.__iterator=function(t,e){if(e)return new $(this.toArray()).__iterator(t,e);var r=0,n=this._head;return new C((function(){if(n){var e=n.value;return n=n.next,P(t,r++,e)}return{value:void 0,done:!0}}))},e}(O);zr.isStack=mr;var Sr,br=zr.prototype;function Ir(t,e,r,n){var i=Object.create(br);return i.size=t,i._head=e,i.__ownerID=r,i.__hash=n,i.__altered=!1,i}function Or(){return Sr||(Sr=Ir(0))}br[wr]=!0,br.shift=br.pop,br.unshift=br.push,br.unshiftAll=br.pushAll,br.withMutations=je,br.wasAltered=xe,br.asImmutable=De,br["@@transducer/init"]=br.asMutable=Me,br["@@transducer/step"]=function(t,e){return t.unshift(e)},br["@@transducer/result"]=function(t){return t.asImmutable()};var Er="@@__IMMUTABLE_SET__@@";function qr(t){return Boolean(t&&t[Er])}function jr(t){return qr(t)&&k(t)}function Mr(t,e){if(t===e)return!0;if(!d(e)||void 0!==t.size&&void 0!==e.size&&t.size!==e.size||void 0!==t.__hash&&void 0!==e.__hash&&t.__hash!==e.__hash||w(t)!==w(e)||z(t)!==z(e)||k(t)!==k(e))return!1;if(0===t.size&&0===e.size)return!0;var r=!S(t);if(k(t)){var n=t.entries();return e.every((function(t,e){var i=n.next().value;return i&&ht(i[1],t)&&(r||ht(i[0],e))}))&&n.next().done}var i=!1;if(void 0===t.size)if(void 0===e.size)"function"==typeof t.cacheResult&&t.cacheResult();else{i=!0;var u=t;t=e,e=u}var s=!0,a=e.__iterate((function(e,n){if(r?!t.has(e):i?!ht(e,t.get(n,o)):!ht(t.get(n,o),e))return s=!1,!1}));return s&&t.size===a}function Dr(t,e){var r=function(r){t.prototype[r]=e[r]};return Object.keys(e).forEach(r),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(e).forEach(r),t}function xr(t){if(!t||"object"!=typeof t)return t;if(!d(t)){if(!ne(t))return t;t=X(t)}if(w(t)){var e={};return t.__iterate((function(t,r){e[r]=xr(t)})),e}var r=[];return t.__iterate((function(t){r.push(xr(t))})),r}var Ar=function(t){function e(e){return null==e?Br():qr(e)&&!k(e)?e:Br().withMutations((function(r){var n=t(e);$t(n.size),n.forEach((function(t){return r.add(t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(I(t).keySeq())},e.intersect=function(t){return(t=b(t).toArray()).length?Rr.intersect.apply(e(t.pop()),t):Br()},e.union=function(t){return(t=b(t).toArray()).length?Rr.union.apply(e(t.pop()),t):Br()},e.prototype.toString=function(){return this.__toString("Set {","}")},e.prototype.has=function(t){return this._map.has(t)},e.prototype.add=function(t){return Ur(this,this._map.set(t,t))},e.prototype.remove=function(t){return Ur(this,this._map.remove(t))},e.prototype.clear=function(){return Ur(this,this._map.clear())},e.prototype.map=function(t,e){var r=this,n=!1,i=Ur(this,this._map.mapEntries((function(i){var o=i[1],u=t.call(e,o,o,r);return u!==o&&(n=!0),[u,u]}),e));return n?i:this},e.prototype.union=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return 0===(e=e.filter((function(t){return 0!==t.size}))).length?this:0!==this.size||this.__ownerID||1!==e.length?this.withMutations((function(r){for(var n=0;n=0&&e=0&&r>>-15,461845907),e=pt(e<<13|e>>>-13,5),e=pt((e=(e+3864292196|0)^t)^e>>>16,2246822507),e=_t((e=pt(e^e>>>13,3266489909))^e>>>16)}(t.size,n)}(this))}});var Hr=b.prototype;Hr[y]=!0,Hr[L]=Hr.values,Hr.toJSON=Hr.toArray,Hr.__toStringMapper=ie,Hr.inspect=Hr.toSource=function(){return this.toString()},Hr.chain=Hr.flatMap,Hr.contains=Hr.includes,Dr(I,{flip:function(){return Jt(this,Rt(this))},mapEntries:function(t,e){var r=this,n=0;return Jt(this,this.toSeq().map((function(i,o){return t.call(e,[o,i],n++,r)})).fromEntrySeq())},mapKeys:function(t,e){var r=this;return Jt(this,this.toSeq().flip().map((function(n,i){return t.call(e,n,i,r)})).flip())}});var Jr=I.prototype;Jr[g]=!0,Jr[L]=Hr.entries,Jr.toJSON=Nr,Jr.__toStringMapper=function(t,e){return ie(e)+": "+ie(t)},Dr(O,{toKeyedSeq:function(){return new Dt(this,!1)},filter:function(t,e){return Jt(this,Bt(this,t,e,!1))},findIndex:function(t,e){var r=this.findEntry(t,e);return r?r[0]:-1},indexOf:function(t){var e=this.keyOf(t);return void 0===e?-1:e},lastIndexOf:function(t){var e=this.lastKeyOf(t);return void 0===e?-1:e},reverse:function(){return Jt(this,Tt(this,!1))},slice:function(t,e){return Jt(this,Kt(this,t,e,!1))},splice:function(t,e){var r=arguments.length;if(e=Math.max(e||0,0),0===r||2===r&&!e)return this;t=p(t,t<0?this.count():this.size);var n=this.slice(0,t);return Jt(this,1===r?n:n.concat(Gt(arguments,2),this.slice(t+e)))},findLastIndex:function(t,e){var r=this.findLastEntry(t,e);return r?r[0]:-1},first:function(t){return this.get(0,t)},flatten:function(t){return Jt(this,Ct(this,t,!1))},get:function(t,e){return(t=c(this,t))<0||this.size===1/0||void 0!==this.size&&t>this.size?e:this.find((function(e,r){return r===t}),void 0,e)},has:function(t){return(t=c(this,t))>=0&&(void 0!==this.size?this.size===1/0||te?-1:0}function en(t,e){return t^e+2654435769+(t<<6)+(t>>2)|0}Yr.has=Hr.includes,Yr.contains=Yr.includes,Yr.keys=Yr.values,Dr(F,Jr),Dr(G,Vr),Dr(Z,Yr);var rn=function(t){function e(t){return null==t?sn():jr(t)?t:sn().withMutations((function(e){var r=E(t);$t(r.size),r.forEach((function(t){return e.add(t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(I(t).keySeq())},e.prototype.toString=function(){return this.__toString("OrderedSet {","}")},e}(Ar);rn.isOrderedSet=jr;var nn,on=rn.prototype;function un(t,e){var r=Object.create(on);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function sn(){return nn||(nn=un(dr()))}on[A]=!0,on.zip=Vr.zip,on.zipWith=Vr.zipWith,on.zipAll=Vr.zipAll,on.__empty=sn,on.__make=un;var an=function(t,e){var r;!function(t){if(D(t))throw new Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(x(t))throw new Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(null===t||"object"!=typeof t)throw new Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}(t);var n=function(o){var u=this;if(o instanceof n)return o;if(!(this instanceof n))return new n(o);if(!r){r=!0;var s=Object.keys(t),a=i._indices={};i._name=e,i._keys=s,i._defaultValues=t;for(var c=0;c2?[]:void 0,{"":t})},t.get=ue,t.getIn=Cr,t.has=oe,t.hasIn=Wr,t.hash=vt,t.is=ht,t.isAssociative=S,t.isCollection=d,t.isImmutable=x,t.isIndexed=z,t.isKeyed=w,t.isList=er,t.isMap=at,t.isOrdered=k,t.isOrderedMap=ct,t.isOrderedSet=jr,t.isPlainObject=re,t.isRecord=D,t.isSeq=j,t.isSet=qr,t.isStack=mr,t.isValueObject=ft,t.merge=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return be(t,e)},t.mergeDeep=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Se(t,e)},t.mergeDeepWith=function(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];return Se(e,r,t)},t.mergeWith=function(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];return be(e,r,t)},t.remove=ae,t.removeIn=le,t.set=ce,t.setIn=pe,t.update=ye,t.updateIn=fe,t.version="5.0.0-rc.1"})); From 8f2e531bb7f22f4e3f96fcc5da76a4063abe6c6a Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 17 Oct 2024 23:17:14 +0000 Subject: [PATCH 215/242] deploy: 9591b293982fc4b3ac798d2607cf1e7cc9311c57 --- bower.json | 2 +- dist/es/package.json.js | 2 +- dist/immutable.js | 2 +- dist/immutable.min.js | 2 +- package.json | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/bower.json b/bower.json index 7a9f05049d..02f475aebd 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "immutable", - "version": "5.0.0-rc.1", + "version": "5.0.0-rc.2", "description": "Immutable Data Collections", "license": "MIT", "homepage": "https://immutable-js.com", diff --git a/dist/es/package.json.js b/dist/es/package.json.js index 2688d81805..0ef90db74b 100644 --- a/dist/es/package.json.js +++ b/dist/es/package.json.js @@ -22,6 +22,6 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -var version = "5.0.0-rc.1"; +var version = "5.0.0-rc.2"; export { version }; diff --git a/dist/immutable.js b/dist/immutable.js index 248c251473..6b4536465d 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -5928,7 +5928,7 @@ return isIndexed(v) ? v.toList() : isKeyed(v) ? v.toMap() : v.toSet(); } - var version = "5.0.0-rc.1"; + var version = "5.0.0-rc.2"; // Note: Iterable is deprecated var Iterable = Collection; diff --git a/dist/immutable.min.js b/dist/immutable.min.js index a3c0672b6e..05f62e5ee7 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -22,4 +22,4 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).Immutable={})}(this,(function(t){"use strict";var e="delete",r=5,n=1<>>0;if(""+r!==e||4294967295===r)return NaN;e=r}return e<0?a(t)+e:e}function f(){return!0}function h(t,e,r){return(0===t&&!v(t)||void 0!==r&&t<=-r)&&(void 0===e||void 0!==r&&e>=r)}function p(t,e){return l(t,e,0)}function _(t,e){return l(t,e,e)}function l(t,e,r){return void 0===t?r:v(t)?e===1/0?e:0|Math.max(0,e+t):void 0===e||e===t?t:0|Math.min(e,t)}function v(t){return t<0||0===t&&1/t==-1/0}var y="@@__IMMUTABLE_ITERABLE__@@";function d(t){return Boolean(t&&t[y])}var g="@@__IMMUTABLE_KEYED__@@";function w(t){return Boolean(t&&t[g])}var m="@@__IMMUTABLE_INDEXED__@@";function z(t){return Boolean(t&&t[m])}function S(t){return w(t)||z(t)}var b=function(t){return d(t)?t:X(t)},I=function(t){function e(t){return w(t)?t:F(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(b),O=function(t){function e(t){return z(t)?t:G(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(b),E=function(t){function e(t){return d(t)&&!S(t)?t:Z(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(b);b.Keyed=I,b.Indexed=O,b.Set=E;var q="@@__IMMUTABLE_SEQ__@@";function j(t){return Boolean(t&&t[q])}var M="@@__IMMUTABLE_RECORD__@@";function D(t){return Boolean(t&&t[M])}function x(t){return d(t)||D(t)}var A="@@__IMMUTABLE_ORDERED__@@";function k(t){return Boolean(t&&t[A])}var R=0,U=1,T=2,B="function"==typeof Symbol&&Symbol.iterator,K="@@iterator",L=B||K,C=function(t){this.next=t};function P(t,e,r,n){var i=0===t?e:1===t?r:[e,r];return n?n.value=i:n={value:i,done:!1},n}function W(){return{value:void 0,done:!0}}function N(t){return!!Array.isArray(t)||!!V(t)}function H(t){return t&&"function"==typeof t.next}function J(t){var e=V(t);return e&&e.call(t)}function V(t){var e=t&&(B&&t[B]||t[K]);if("function"==typeof e)return e}C.prototype.toString=function(){return"[Iterator]"},C.KEYS=R,C.VALUES=U,C.ENTRIES=T,C.prototype.inspect=C.prototype.toSource=function(){return this.toString()},C.prototype[L]=function(){return this};var Y=Object.prototype.hasOwnProperty;function Q(t){return!(!Array.isArray(t)&&"string"!=typeof t)||t&&"object"==typeof t&&Number.isInteger(t.length)&&t.length>=0&&(0===t.length?1===Object.keys(t).length:t.hasOwnProperty(t.length-1))}var X=function(t){function e(t){return null==t?nt():x(t)?t.toSeq():function(t){var e=ut(t);if(e)return(n=V(r=t))&&n===r.entries?e.fromEntrySeq():function(t){var e=V(t);return e&&e===t.keys}(t)?e.toSetSeq():e;var r,n;if("object"==typeof t)return new tt(t);throw new TypeError("Expected Array or collection object of values, or keyed object: "+t)}(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq {","}")},e.prototype.cacheResult=function(){return!this._cache&&this.__iterateUncached&&(this._cache=this.entrySeq().toArray(),this.size=this._cache.length),this},e.prototype.__iterate=function(t,e){var r=this._cache;if(r){for(var n=r.length,i=0;i!==n;){var o=r[e?n-++i:i++];if(!1===t(o[1],o[0],this))break}return i}return this.__iterateUncached(t,e)},e.prototype.__iterator=function(t,e){var r=this._cache;if(r){var n=r.length,i=0;return new C((function(){if(i===n)return{value:void 0,done:!0};var o=r[e?n-++i:i++];return P(t,o[0],o[1])}))}return this.__iteratorUncached(t,e)},e}(b),F=function(t){function e(t){return null==t?nt().toKeyedSeq():d(t)?w(t)?t.toSeq():t.fromEntrySeq():D(t)?t.toSeq():it(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toKeyedSeq=function(){return this},e}(X),G=function(t){function e(t){return null==t?nt():d(t)?w(t)?t.entrySeq():t.toIndexedSeq():D(t)?t.toSeq().entrySeq():ot(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return e(arguments)},e.prototype.toIndexedSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq [","]")},e}(X),Z=function(t){function e(t){return(d(t)&&!S(t)?t:G(t)).toSetSeq()}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return e(arguments)},e.prototype.toSetSeq=function(){return this},e}(X);X.isSeq=j,X.Keyed=F,X.Set=Z,X.Indexed=G,X.prototype[q]=!0;var $=function(t){function e(t){this._array=t,this.size=t.length}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t,e){return this.has(t)?this._array[c(this,t)]:e},e.prototype.__iterate=function(t,e){for(var r=this._array,n=r.length,i=0;i!==n;){var o=e?n-++i:i++;if(!1===t(r[o],o,this))break}return i},e.prototype.__iterator=function(t,e){var r=this._array,n=r.length,i=0;return new C((function(){if(i===n)return{value:void 0,done:!0};var o=e?n-++i:i++;return P(t,o,r[o])}))},e}(G),tt=function(t){function e(t){var e=Object.keys(t).concat(Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(t):[]);this._object=t,this._keys=e,this.size=e.length}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t,e){return void 0===e||this.has(t)?this._object[t]:e},e.prototype.has=function(t){return Y.call(this._object,t)},e.prototype.__iterate=function(t,e){for(var r=this._object,n=this._keys,i=n.length,o=0;o!==i;){var u=n[e?i-++o:o++];if(!1===t(r[u],u,this))break}return o},e.prototype.__iterator=function(t,e){var r=this._object,n=this._keys,i=n.length,o=0;return new C((function(){if(o===i)return{value:void 0,done:!0};var u=n[e?i-++o:o++];return P(t,u,r[u])}))},e}(F);tt.prototype[A]=!0;var et,rt=function(t){function e(t){this._collection=t,this.size=t.length||t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.__iterateUncached=function(t,e){if(e)return this.cacheResult().__iterate(t,e);var r=J(this._collection),n=0;if(H(r))for(var i;!(i=r.next()).done&&!1!==t(i.value,n++,this););return n},e.prototype.__iteratorUncached=function(t,e){if(e)return this.cacheResult().__iterator(t,e);var r=J(this._collection);if(!H(r))return new C(W);var n=0;return new C((function(){var e=r.next();return e.done?e:P(t,n++,e.value)}))},e}(G);function nt(){return et||(et=new $([]))}function it(t){var e=ut(t);if(e)return e.fromEntrySeq();if("object"==typeof t)return new tt(t);throw new TypeError("Expected Array or collection object of [k, v] entries, or keyed object: "+t)}function ot(t){var e=ut(t);if(e)return e;throw new TypeError("Expected Array or collection object of values: "+t)}function ut(t){return Q(t)?new $(t):N(t)?new rt(t):void 0}var st="@@__IMMUTABLE_MAP__@@";function at(t){return Boolean(t&&t[st])}function ct(t){return at(t)&&k(t)}function ft(t){return Boolean(t&&"function"==typeof t.equals&&"function"==typeof t.hashCode)}function ht(t,e){if(t===e||t!=t&&e!=e)return!0;if(!t||!e)return!1;if("function"==typeof t.valueOf&&"function"==typeof e.valueOf){if((t=t.valueOf())===(e=e.valueOf())||t!=t&&e!=e)return!0;if(!t||!e)return!1}return!!(ft(t)&&ft(e)&&t.equals(e))}var pt="function"==typeof Math.imul&&-2===Math.imul(4294967295,2)?Math.imul:function(t,e){var r=65535&(t|=0),n=65535&(e|=0);return r*n+((t>>>16)*n+r*(e>>>16)<<16>>>0)|0};function _t(t){return t>>>1&1073741824|3221225471&t}var lt=Object.prototype.valueOf;function vt(t){if(null==t)return yt(t);if("function"==typeof t.hashCode)return _t(t.hashCode(t));var e,r=(e=t).valueOf!==lt&&"function"==typeof e.valueOf?e.valueOf(e):e;if(null==r)return yt(r);switch(typeof r){case"boolean":return r?1108378657:1108378656;case"number":return function(t){if(t!=t||t===1/0)return 0;var e=0|t;e!==t&&(e^=4294967295*t);for(;t>4294967295;)e^=t/=4294967295;return _t(e)}(r);case"string":return r.length>Et?function(t){var e=Mt[t];void 0===e&&(e=dt(t),jt===qt&&(jt=0,Mt={}),jt++,Mt[t]=e);return e}(r):dt(r);case"object":case"function":return function(t){var e;if(St&&void 0!==(e=zt.get(t)))return e;if(e=t[Ot],void 0!==e)return e;if(!wt){if(void 0!==(e=t.propertyIsEnumerable&&t.propertyIsEnumerable[Ot]))return e;if(void 0!==(e=function(t){if(t&&t.nodeType>0)switch(t.nodeType){case 1:return t.uniqueID;case 9:return t.documentElement&&t.documentElement.uniqueID}}(t)))return e}if(e=mt(),St)zt.set(t,e);else{if(void 0!==gt&&!1===gt(t))throw new Error("Non-extensible objects are not allowed as keys.");if(wt)Object.defineProperty(t,Ot,{enumerable:!1,configurable:!1,writable:!1,value:e});else if(void 0!==t.propertyIsEnumerable&&t.propertyIsEnumerable===t.constructor.prototype.propertyIsEnumerable)t.propertyIsEnumerable=function(){return this.constructor.prototype.propertyIsEnumerable.apply(this,arguments)},t.propertyIsEnumerable[Ot]=e;else{if(void 0===t.nodeType)throw new Error("Unable to set a non-enumerable property on object.");t[Ot]=e}}return e}(r);case"symbol":return function(t){var e=bt[t];if(void 0!==e)return e;return e=mt(),bt[t]=e,e}(r);default:if("function"==typeof r.toString)return dt(r.toString());throw new Error("Value type "+typeof r+" cannot be hashed.")}}function yt(t){return null===t?1108378658:1108378659}function dt(t){for(var e=0,r=0;r=0&&(a.get=function(e,r){return(e=c(this,e))>=0&&eo)return{value:void 0,done:!0};var t=i.next();return n||e===U||t.done?t:P(e,a-1,e===R?void 0:t.value[1],t)}))},a}function Lt(t,e,r,n){var i=Qt(t);return i.__iterateUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterate(i,o);var s=!0,a=0;return t.__iterate((function(t,o,c){if(!s||!(s=e.call(r,t,o,c)))return a++,i(t,n?o:a-1,u)})),a},i.__iteratorUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterator(i,o);var s=t.__iterator(T,o),a=!0,c=0;return new C((function(){var t,o,f;do{if((t=s.next()).done)return n||i===U?t:P(i,c++,i===R?void 0:t.value[1],t);var h=t.value;o=h[0],f=h[1],a&&(a=e.call(r,f,o,u))}while(a);return i===T?t:P(i,o,f,t)}))},i}function Ct(t,e,r){var n=Qt(t);return n.__iterateUncached=function(i,o){if(o)return this.cacheResult().__iterate(i,o);var u=0,s=!1;return function t(a,c){a.__iterate((function(o,a){return(!e||c0}function Ht(t,e,r,n){var i=Qt(t),o=new $(r).map((function(t){return t.size}));return i.size=n?o.max():o.min(),i.__iterate=function(t,e){for(var r,n=this.__iterator(U,e),i=0;!(r=n.next()).done&&!1!==t(r.value,i++,this););return i},i.__iteratorUncached=function(t,i){var o=r.map((function(t){return t=b(t),J(i?t.reverse():t)})),u=0,s=!1;return new C((function(){var r;return s||(r=o.map((function(t){return t.next()})),s=n?r.every((function(t){return t.done})):r.some((function(t){return t.done}))),s?{value:void 0,done:!0}:P(t,u++,e.apply(null,r.map((function(t){return t.value}))))}))},i}function Jt(t,e){return t===e?t:j(t)?e:t.constructor(e)}function Vt(t){if(t!==Object(t))throw new TypeError("Expected [K, V] tuple: "+t)}function Yt(t){return w(t)?I:z(t)?O:E}function Qt(t){return Object.create((w(t)?F:z(t)?G:Z).prototype)}function Xt(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size,this):X.prototype.cacheResult.call(this)}function Ft(t,e){return void 0===t&&void 0===e?0:void 0===t?1:void 0===e?-1:t>e?1:t0;)e[r]=arguments[r+1];if("function"!=typeof t)throw new TypeError("Invalid merger function: "+t);return ze(this,e,t)}function ze(t,e,r){for(var n=[],i=0;i0;)e[r]=arguments[r+1];return Se(this,e,t)}function Ee(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return fe(this,t,He(),(function(t){return be(t,e)}))}function qe(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return fe(this,t,He(),(function(t){return Se(t,e)}))}function je(t){var e=this.asMutable();return t(e),e.wasAltered()?e.__ensureOwner(this.__ownerID):this}function Me(){return this.__ownerID?this:this.__ensureOwner(new s)}function De(){return this.__ensureOwner()}function xe(){return this.__altered}var Ae=function(t){function e(e){return null==e?He():at(e)&&!k(e)?e:He().withMutations((function(r){var n=t(e);$t(n.size),n.forEach((function(t,e){return r.set(e,t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toString=function(){return this.__toString("Map {","}")},e.prototype.get=function(t,e){return this._root?this._root.get(0,void 0,t,e):e},e.prototype.set=function(t,e){return Je(this,t,e)},e.prototype.remove=function(t){return Je(this,t,o)},e.prototype.deleteAll=function(t){var e=b(t);return 0===e.size?this:this.withMutations((function(t){e.forEach((function(e){return t.remove(e)}))}))},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):He()},e.prototype.sort=function(t){return vr(Pt(this,t))},e.prototype.sortBy=function(t,e){return vr(Pt(this,e,t))},e.prototype.map=function(t,e){var r=this;return this.withMutations((function(n){n.forEach((function(i,o){n.set(o,t.call(e,i,o,r))}))}))},e.prototype.__iterator=function(t,e){return new Ce(this,t,e)},e.prototype.__iterate=function(t,e){var r=this,n=0;return this._root&&this._root.iterate((function(e){return n++,t(e[1],e[0],r)}),e),n},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Ne(this.size,this._root,t,this.__hash):0===this.size?He():(this.__ownerID=t,this.__altered=!1,this)},e}(I);Ae.isMap=at;var ke=Ae.prototype;ke[st]=!0,ke[e]=ke.remove,ke.removeAll=ke.deleteAll,ke.setIn=_e,ke.removeIn=ke.deleteIn=ve,ke.update=de,ke.updateIn=ge,ke.merge=ke.concat=we,ke.mergeWith=me,ke.mergeDeep=Ie,ke.mergeDeepWith=Oe,ke.mergeIn=Ee,ke.mergeDeepIn=qe,ke.withMutations=je,ke.wasAltered=xe,ke.asImmutable=De,ke["@@transducer/init"]=ke.asMutable=Me,ke["@@transducer/step"]=function(t,e){return t.set(e[0],e[1])},ke["@@transducer/result"]=function(t){return t.asImmutable()};var Re=function(t,e){this.ownerID=t,this.entries=e};Re.prototype.get=function(t,e,r,n){for(var i=this.entries,o=0,u=i.length;o=Ge)return function(t,e,r,n){t||(t=new s);for(var i=new Ke(t,vt(r),[r,n]),o=0;o>>t)&i),s=this.bitmap;return 0==(s&u)?o:this.nodes[Xe(s&u-1)].get(t+r,e,n,o)},Ue.prototype.update=function(t,e,u,s,a,c,f){void 0===u&&(u=vt(s));var h=(0===e?u:u>>>e)&i,p=1<=Ze)return function(t,e,r,i,o){for(var u=0,s=new Array(n),a=0;0!==r;a++,r>>>=1)s[a]=1&r?e[u++]:void 0;return s[i]=o,new Te(t,u+1,s)}(t,y,_,h,g);if(l&&!g&&2===y.length&&Ye(y[1^v]))return y[1^v];if(l&&g&&1===y.length&&Ye(g))return g;var w=t&&t===this.ownerID,m=l?g?_:_^p:_|p,z=l?g?Fe(y,v,g,w):function(t,e,r){var n=t.length-1;if(r&&e===n)return t.pop(),t;for(var i=new Array(n),o=0,u=0;u>>t)&i,s=this.nodes[u];return s?s.get(t+r,e,n,o):o},Te.prototype.update=function(t,e,n,u,s,a,c){void 0===n&&(n=vt(u));var f=(0===e?n:n>>>e)&i,h=s===o,p=this.nodes,_=p[f];if(h&&!_)return this;var l=Ve(_,t,e+r,n,u,s,a,c);if(l===_)return this;var v=this.count;if(_){if(!l&&--v<$e)return function(t,e,r,n){for(var i=0,o=0,u=new Array(r),s=0,a=1,c=e.length;s>>n)&i,c=(0===n?o:o>>>n)&i,f=a===c?[Qe(t,e,n+r,o,u)]:(s=new Ke(e,o,u),a>1&1431655765))+(t>>2&858993459))+(t>>4)&252645135,t+=t>>8,127&(t+=t>>16)}function Fe(t,e,r,n){var i=n?t:Gt(t);return i[e]=r,i}var Ge=n/4,Ze=n/2,$e=n/4,tr="@@__IMMUTABLE_LIST__@@";function er(t){return Boolean(t&&t[tr])}var rr=function(t){function e(e){var i=ar();if(null==e)return i;if(er(e))return e;var o=t(e),u=o.size;return 0===u?i:($t(u),u>0&&u=0&&t=t.size||e<0)return t.withMutations((function(t){e<0?pr(t,e).set(0,r):pr(t,0,e+1).set(e,r)}));e+=t._origin;var n=t._tail,i=t._root,o={value:!1};e>=_r(t._capacity)?n=cr(n,t.__ownerID,0,e,r,o):i=cr(i,t.__ownerID,t._level,e,r,o);if(!o.value)return t;if(t.__ownerID)return t._root=i,t._tail=n,t.__hash=void 0,t.__altered=!0,t;return sr(t._origin,t._capacity,t._level,i,n)}(this,t,e)},e.prototype.remove=function(t){return this.has(t)?0===t?this.shift():t===this.size-1?this.pop():this.splice(t,1):this},e.prototype.insert=function(t,e){return this.splice(t,0,e)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=this._origin=this._capacity=0,this._level=r,this._root=this._tail=this.__hash=void 0,this.__altered=!0,this):ar()},e.prototype.push=function(){var t=arguments,e=this.size;return this.withMutations((function(r){pr(r,0,e+t.length);for(var n=0;n>>e&i;if(o>=this.array.length)return new ir([],t);var u,s=0===o;if(e>0){var a=this.array[o];if((u=a&&a.removeBefore(t,e-r,n))===a&&s)return this}if(s&&!u)return this;var c=fr(this,t);if(!s)for(var f=0;f>>e&i;if(u>=this.array.length)return this;if(e>0){var s=this.array[u];if((o=s&&s.removeAfter(t,e-r,n))===s&&u===this.array.length-1)return this}var a=fr(this,t);return a.array.splice(u+1),o&&(a.array[u]=o),a};var or={};function ur(t,e){var i=t._origin,o=t._capacity,u=_r(o),s=t._tail;return a(t._root,t._level,0);function a(t,c,f){return 0===c?function(t,r){var a=r===u?s&&s.array:t&&t.array,c=r>i?0:i-r,f=o-r;f>n&&(f=n);return function(){if(c===f)return or;var t=e?--f:c++;return a&&a[t]}}(t,f):function(t,u,s){var c,f=t&&t.array,h=s>i?0:i-s>>u,p=1+(o-s>>u);p>n&&(p=n);return function(){for(;;){if(c){var t=c();if(t!==or)return t;c=null}if(h===p)return or;var n=e?--p:h++;c=a(f&&f[n],u-r,s+(n<>>n&i,h=t&&f0){var p=t&&t.array[f],_=cr(p,e,n-r,o,s,a);return _===p?t:((c=fr(t,e)).array[f]=_,c)}return h&&t.array[f]===s?t:(a&&u(a),c=fr(t,e),void 0===s&&f===c.array.length-1?c.array.pop():c.array[f]=s,c)}function fr(t,e){return e&&t&&e===t.ownerID?t:new ir(t?t.array.slice():[],e)}function hr(t,e){if(e>=_r(t._capacity))return t._tail;if(e<1<0;)n=n.array[e>>>o&i],o-=r;return n}}function pr(t,e,n){void 0!==e&&(e|=0),void 0!==n&&(n|=0);var o=t.__ownerID||new s,u=t._origin,a=t._capacity,c=u+e,f=void 0===n?a:n<0?a+n:u+n;if(c===u&&f===a)return t;if(c>=f)return t.clear();for(var h=t._level,p=t._root,_=0;c+_<0;)p=new ir(p&&p.array.length?[void 0,p]:[],o),_+=1<<(h+=r);_&&(c+=_,u+=_,f+=_,a+=_);for(var l=_r(a),v=_r(f);v>=1<l?new ir([],o):y;if(y&&v>l&&cr;w-=r){var m=l>>>w&i;g=g.array[m]=fr(g.array[m],o)}g.array[l>>>r&i]=y}if(f=v)c-=v,f-=v,h=r,p=null,d=d&&d.removeBefore(o,0,c);else if(c>u||v>>h&i;if(z!==v>>>h&i)break;z&&(_+=(1<u&&(p=p.removeBefore(o,h,c-_)),p&&v>>r<=n&&a.size>=2*s.size?(i=(u=a.filter((function(t,e){return void 0!==t&&c!==e}))).toKeyedSeq().map((function(t){return t[0]})).flip().toMap(),t.__ownerID&&(i.__ownerID=u.__ownerID=t.__ownerID)):(i=s.remove(e),u=c===a.size-1?a.pop():a.set(c,void 0))}else if(f){if(r===a.get(c)[1])return t;i=s,u=a.set(c,[e,r])}else i=s.set(e,a.size),u=a.set(a.size,[e,r]);return t.__ownerID?(t.size=i.size,t._map=i,t._list=u,t.__hash=void 0,t.__altered=!0,t):yr(i,u)}vr.isOrderedMap=ct,vr.prototype[A]=!0,vr.prototype[e]=vr.prototype.remove;var wr="@@__IMMUTABLE_STACK__@@";function mr(t){return Boolean(t&&t[wr])}var zr=function(t){function e(t){return null==t?Or():mr(t)?t:Or().pushAll(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("Stack [","]")},e.prototype.get=function(t,e){var r=this._head;for(t=c(this,t);r&&t--;)r=r.next;return r?r.value:e},e.prototype.peek=function(){return this._head&&this._head.value},e.prototype.push=function(){var t=arguments;if(0===arguments.length)return this;for(var e=this.size+arguments.length,r=this._head,n=arguments.length-1;n>=0;n--)r={value:t[n],next:r};return this.__ownerID?(this.size=e,this._head=r,this.__hash=void 0,this.__altered=!0,this):Ir(e,r)},e.prototype.pushAll=function(e){if(0===(e=t(e)).size)return this;if(0===this.size&&mr(e))return e;$t(e.size);var r=this.size,n=this._head;return e.__iterate((function(t){r++,n={value:t,next:n}}),!0),this.__ownerID?(this.size=r,this._head=n,this.__hash=void 0,this.__altered=!0,this):Ir(r,n)},e.prototype.pop=function(){return this.slice(1)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):Or()},e.prototype.slice=function(e,r){if(h(e,r,this.size))return this;var n=p(e,this.size);if(_(r,this.size)!==this.size)return t.prototype.slice.call(this,e,r);for(var i=this.size-n,o=this._head;n--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):Ir(i,o)},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Ir(this.size,this._head,t,this.__hash):0===this.size?Or():(this.__ownerID=t,this.__altered=!1,this)},e.prototype.__iterate=function(t,e){var r=this;if(e)return new $(this.toArray()).__iterate((function(e,n){return t(e,n,r)}),e);for(var n=0,i=this._head;i&&!1!==t(i.value,n++,this);)i=i.next;return n},e.prototype.__iterator=function(t,e){if(e)return new $(this.toArray()).__iterator(t,e);var r=0,n=this._head;return new C((function(){if(n){var e=n.value;return n=n.next,P(t,r++,e)}return{value:void 0,done:!0}}))},e}(O);zr.isStack=mr;var Sr,br=zr.prototype;function Ir(t,e,r,n){var i=Object.create(br);return i.size=t,i._head=e,i.__ownerID=r,i.__hash=n,i.__altered=!1,i}function Or(){return Sr||(Sr=Ir(0))}br[wr]=!0,br.shift=br.pop,br.unshift=br.push,br.unshiftAll=br.pushAll,br.withMutations=je,br.wasAltered=xe,br.asImmutable=De,br["@@transducer/init"]=br.asMutable=Me,br["@@transducer/step"]=function(t,e){return t.unshift(e)},br["@@transducer/result"]=function(t){return t.asImmutable()};var Er="@@__IMMUTABLE_SET__@@";function qr(t){return Boolean(t&&t[Er])}function jr(t){return qr(t)&&k(t)}function Mr(t,e){if(t===e)return!0;if(!d(e)||void 0!==t.size&&void 0!==e.size&&t.size!==e.size||void 0!==t.__hash&&void 0!==e.__hash&&t.__hash!==e.__hash||w(t)!==w(e)||z(t)!==z(e)||k(t)!==k(e))return!1;if(0===t.size&&0===e.size)return!0;var r=!S(t);if(k(t)){var n=t.entries();return e.every((function(t,e){var i=n.next().value;return i&&ht(i[1],t)&&(r||ht(i[0],e))}))&&n.next().done}var i=!1;if(void 0===t.size)if(void 0===e.size)"function"==typeof t.cacheResult&&t.cacheResult();else{i=!0;var u=t;t=e,e=u}var s=!0,a=e.__iterate((function(e,n){if(r?!t.has(e):i?!ht(e,t.get(n,o)):!ht(t.get(n,o),e))return s=!1,!1}));return s&&t.size===a}function Dr(t,e){var r=function(r){t.prototype[r]=e[r]};return Object.keys(e).forEach(r),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(e).forEach(r),t}function xr(t){if(!t||"object"!=typeof t)return t;if(!d(t)){if(!ne(t))return t;t=X(t)}if(w(t)){var e={};return t.__iterate((function(t,r){e[r]=xr(t)})),e}var r=[];return t.__iterate((function(t){r.push(xr(t))})),r}var Ar=function(t){function e(e){return null==e?Br():qr(e)&&!k(e)?e:Br().withMutations((function(r){var n=t(e);$t(n.size),n.forEach((function(t){return r.add(t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(I(t).keySeq())},e.intersect=function(t){return(t=b(t).toArray()).length?Rr.intersect.apply(e(t.pop()),t):Br()},e.union=function(t){return(t=b(t).toArray()).length?Rr.union.apply(e(t.pop()),t):Br()},e.prototype.toString=function(){return this.__toString("Set {","}")},e.prototype.has=function(t){return this._map.has(t)},e.prototype.add=function(t){return Ur(this,this._map.set(t,t))},e.prototype.remove=function(t){return Ur(this,this._map.remove(t))},e.prototype.clear=function(){return Ur(this,this._map.clear())},e.prototype.map=function(t,e){var r=this,n=!1,i=Ur(this,this._map.mapEntries((function(i){var o=i[1],u=t.call(e,o,o,r);return u!==o&&(n=!0),[u,u]}),e));return n?i:this},e.prototype.union=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return 0===(e=e.filter((function(t){return 0!==t.size}))).length?this:0!==this.size||this.__ownerID||1!==e.length?this.withMutations((function(r){for(var n=0;n=0&&e=0&&r>>-15,461845907),e=pt(e<<13|e>>>-13,5),e=pt((e=(e+3864292196|0)^t)^e>>>16,2246822507),e=_t((e=pt(e^e>>>13,3266489909))^e>>>16)}(t.size,n)}(this))}});var Hr=b.prototype;Hr[y]=!0,Hr[L]=Hr.values,Hr.toJSON=Hr.toArray,Hr.__toStringMapper=ie,Hr.inspect=Hr.toSource=function(){return this.toString()},Hr.chain=Hr.flatMap,Hr.contains=Hr.includes,Dr(I,{flip:function(){return Jt(this,Rt(this))},mapEntries:function(t,e){var r=this,n=0;return Jt(this,this.toSeq().map((function(i,o){return t.call(e,[o,i],n++,r)})).fromEntrySeq())},mapKeys:function(t,e){var r=this;return Jt(this,this.toSeq().flip().map((function(n,i){return t.call(e,n,i,r)})).flip())}});var Jr=I.prototype;Jr[g]=!0,Jr[L]=Hr.entries,Jr.toJSON=Nr,Jr.__toStringMapper=function(t,e){return ie(e)+": "+ie(t)},Dr(O,{toKeyedSeq:function(){return new Dt(this,!1)},filter:function(t,e){return Jt(this,Bt(this,t,e,!1))},findIndex:function(t,e){var r=this.findEntry(t,e);return r?r[0]:-1},indexOf:function(t){var e=this.keyOf(t);return void 0===e?-1:e},lastIndexOf:function(t){var e=this.lastKeyOf(t);return void 0===e?-1:e},reverse:function(){return Jt(this,Tt(this,!1))},slice:function(t,e){return Jt(this,Kt(this,t,e,!1))},splice:function(t,e){var r=arguments.length;if(e=Math.max(e||0,0),0===r||2===r&&!e)return this;t=p(t,t<0?this.count():this.size);var n=this.slice(0,t);return Jt(this,1===r?n:n.concat(Gt(arguments,2),this.slice(t+e)))},findLastIndex:function(t,e){var r=this.findLastEntry(t,e);return r?r[0]:-1},first:function(t){return this.get(0,t)},flatten:function(t){return Jt(this,Ct(this,t,!1))},get:function(t,e){return(t=c(this,t))<0||this.size===1/0||void 0!==this.size&&t>this.size?e:this.find((function(e,r){return r===t}),void 0,e)},has:function(t){return(t=c(this,t))>=0&&(void 0!==this.size?this.size===1/0||te?-1:0}function en(t,e){return t^e+2654435769+(t<<6)+(t>>2)|0}Yr.has=Hr.includes,Yr.contains=Yr.includes,Yr.keys=Yr.values,Dr(F,Jr),Dr(G,Vr),Dr(Z,Yr);var rn=function(t){function e(t){return null==t?sn():jr(t)?t:sn().withMutations((function(e){var r=E(t);$t(r.size),r.forEach((function(t){return e.add(t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(I(t).keySeq())},e.prototype.toString=function(){return this.__toString("OrderedSet {","}")},e}(Ar);rn.isOrderedSet=jr;var nn,on=rn.prototype;function un(t,e){var r=Object.create(on);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function sn(){return nn||(nn=un(dr()))}on[A]=!0,on.zip=Vr.zip,on.zipWith=Vr.zipWith,on.zipAll=Vr.zipAll,on.__empty=sn,on.__make=un;var an=function(t,e){var r;!function(t){if(D(t))throw new Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(x(t))throw new Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(null===t||"object"!=typeof t)throw new Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}(t);var n=function(o){var u=this;if(o instanceof n)return o;if(!(this instanceof n))return new n(o);if(!r){r=!0;var s=Object.keys(t),a=i._indices={};i._name=e,i._keys=s,i._defaultValues=t;for(var c=0;c2?[]:void 0,{"":t})},t.get=ue,t.getIn=Cr,t.has=oe,t.hasIn=Wr,t.hash=vt,t.is=ht,t.isAssociative=S,t.isCollection=d,t.isImmutable=x,t.isIndexed=z,t.isKeyed=w,t.isList=er,t.isMap=at,t.isOrdered=k,t.isOrderedMap=ct,t.isOrderedSet=jr,t.isPlainObject=re,t.isRecord=D,t.isSeq=j,t.isSet=qr,t.isStack=mr,t.isValueObject=ft,t.merge=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return be(t,e)},t.mergeDeep=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Se(t,e)},t.mergeDeepWith=function(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];return Se(e,r,t)},t.mergeWith=function(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];return be(e,r,t)},t.remove=ae,t.removeIn=le,t.set=ce,t.setIn=pe,t.update=ye,t.updateIn=fe,t.version="5.0.0-rc.1"})); +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).Immutable={})}(this,(function(t){"use strict";var e="delete",r=5,n=1<>>0;if(""+r!==e||4294967295===r)return NaN;e=r}return e<0?a(t)+e:e}function f(){return!0}function h(t,e,r){return(0===t&&!v(t)||void 0!==r&&t<=-r)&&(void 0===e||void 0!==r&&e>=r)}function p(t,e){return l(t,e,0)}function _(t,e){return l(t,e,e)}function l(t,e,r){return void 0===t?r:v(t)?e===1/0?e:0|Math.max(0,e+t):void 0===e||e===t?t:0|Math.min(e,t)}function v(t){return t<0||0===t&&1/t==-1/0}var y="@@__IMMUTABLE_ITERABLE__@@";function d(t){return Boolean(t&&t[y])}var g="@@__IMMUTABLE_KEYED__@@";function w(t){return Boolean(t&&t[g])}var m="@@__IMMUTABLE_INDEXED__@@";function z(t){return Boolean(t&&t[m])}function S(t){return w(t)||z(t)}var b=function(t){return d(t)?t:X(t)},I=function(t){function e(t){return w(t)?t:F(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(b),O=function(t){function e(t){return z(t)?t:G(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(b),E=function(t){function e(t){return d(t)&&!S(t)?t:Z(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(b);b.Keyed=I,b.Indexed=O,b.Set=E;var q="@@__IMMUTABLE_SEQ__@@";function j(t){return Boolean(t&&t[q])}var M="@@__IMMUTABLE_RECORD__@@";function D(t){return Boolean(t&&t[M])}function x(t){return d(t)||D(t)}var A="@@__IMMUTABLE_ORDERED__@@";function k(t){return Boolean(t&&t[A])}var R=0,U=1,T=2,B="function"==typeof Symbol&&Symbol.iterator,K="@@iterator",L=B||K,C=function(t){this.next=t};function P(t,e,r,n){var i=0===t?e:1===t?r:[e,r];return n?n.value=i:n={value:i,done:!1},n}function W(){return{value:void 0,done:!0}}function N(t){return!!Array.isArray(t)||!!V(t)}function H(t){return t&&"function"==typeof t.next}function J(t){var e=V(t);return e&&e.call(t)}function V(t){var e=t&&(B&&t[B]||t[K]);if("function"==typeof e)return e}C.prototype.toString=function(){return"[Iterator]"},C.KEYS=R,C.VALUES=U,C.ENTRIES=T,C.prototype.inspect=C.prototype.toSource=function(){return this.toString()},C.prototype[L]=function(){return this};var Y=Object.prototype.hasOwnProperty;function Q(t){return!(!Array.isArray(t)&&"string"!=typeof t)||t&&"object"==typeof t&&Number.isInteger(t.length)&&t.length>=0&&(0===t.length?1===Object.keys(t).length:t.hasOwnProperty(t.length-1))}var X=function(t){function e(t){return null==t?nt():x(t)?t.toSeq():function(t){var e=ut(t);if(e)return(n=V(r=t))&&n===r.entries?e.fromEntrySeq():function(t){var e=V(t);return e&&e===t.keys}(t)?e.toSetSeq():e;var r,n;if("object"==typeof t)return new tt(t);throw new TypeError("Expected Array or collection object of values, or keyed object: "+t)}(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq {","}")},e.prototype.cacheResult=function(){return!this._cache&&this.__iterateUncached&&(this._cache=this.entrySeq().toArray(),this.size=this._cache.length),this},e.prototype.__iterate=function(t,e){var r=this._cache;if(r){for(var n=r.length,i=0;i!==n;){var o=r[e?n-++i:i++];if(!1===t(o[1],o[0],this))break}return i}return this.__iterateUncached(t,e)},e.prototype.__iterator=function(t,e){var r=this._cache;if(r){var n=r.length,i=0;return new C((function(){if(i===n)return{value:void 0,done:!0};var o=r[e?n-++i:i++];return P(t,o[0],o[1])}))}return this.__iteratorUncached(t,e)},e}(b),F=function(t){function e(t){return null==t?nt().toKeyedSeq():d(t)?w(t)?t.toSeq():t.fromEntrySeq():D(t)?t.toSeq():it(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toKeyedSeq=function(){return this},e}(X),G=function(t){function e(t){return null==t?nt():d(t)?w(t)?t.entrySeq():t.toIndexedSeq():D(t)?t.toSeq().entrySeq():ot(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return e(arguments)},e.prototype.toIndexedSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq [","]")},e}(X),Z=function(t){function e(t){return(d(t)&&!S(t)?t:G(t)).toSetSeq()}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return e(arguments)},e.prototype.toSetSeq=function(){return this},e}(X);X.isSeq=j,X.Keyed=F,X.Set=Z,X.Indexed=G,X.prototype[q]=!0;var $=function(t){function e(t){this._array=t,this.size=t.length}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t,e){return this.has(t)?this._array[c(this,t)]:e},e.prototype.__iterate=function(t,e){for(var r=this._array,n=r.length,i=0;i!==n;){var o=e?n-++i:i++;if(!1===t(r[o],o,this))break}return i},e.prototype.__iterator=function(t,e){var r=this._array,n=r.length,i=0;return new C((function(){if(i===n)return{value:void 0,done:!0};var o=e?n-++i:i++;return P(t,o,r[o])}))},e}(G),tt=function(t){function e(t){var e=Object.keys(t).concat(Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(t):[]);this._object=t,this._keys=e,this.size=e.length}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t,e){return void 0===e||this.has(t)?this._object[t]:e},e.prototype.has=function(t){return Y.call(this._object,t)},e.prototype.__iterate=function(t,e){for(var r=this._object,n=this._keys,i=n.length,o=0;o!==i;){var u=n[e?i-++o:o++];if(!1===t(r[u],u,this))break}return o},e.prototype.__iterator=function(t,e){var r=this._object,n=this._keys,i=n.length,o=0;return new C((function(){if(o===i)return{value:void 0,done:!0};var u=n[e?i-++o:o++];return P(t,u,r[u])}))},e}(F);tt.prototype[A]=!0;var et,rt=function(t){function e(t){this._collection=t,this.size=t.length||t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.__iterateUncached=function(t,e){if(e)return this.cacheResult().__iterate(t,e);var r=J(this._collection),n=0;if(H(r))for(var i;!(i=r.next()).done&&!1!==t(i.value,n++,this););return n},e.prototype.__iteratorUncached=function(t,e){if(e)return this.cacheResult().__iterator(t,e);var r=J(this._collection);if(!H(r))return new C(W);var n=0;return new C((function(){var e=r.next();return e.done?e:P(t,n++,e.value)}))},e}(G);function nt(){return et||(et=new $([]))}function it(t){var e=ut(t);if(e)return e.fromEntrySeq();if("object"==typeof t)return new tt(t);throw new TypeError("Expected Array or collection object of [k, v] entries, or keyed object: "+t)}function ot(t){var e=ut(t);if(e)return e;throw new TypeError("Expected Array or collection object of values: "+t)}function ut(t){return Q(t)?new $(t):N(t)?new rt(t):void 0}var st="@@__IMMUTABLE_MAP__@@";function at(t){return Boolean(t&&t[st])}function ct(t){return at(t)&&k(t)}function ft(t){return Boolean(t&&"function"==typeof t.equals&&"function"==typeof t.hashCode)}function ht(t,e){if(t===e||t!=t&&e!=e)return!0;if(!t||!e)return!1;if("function"==typeof t.valueOf&&"function"==typeof e.valueOf){if((t=t.valueOf())===(e=e.valueOf())||t!=t&&e!=e)return!0;if(!t||!e)return!1}return!!(ft(t)&&ft(e)&&t.equals(e))}var pt="function"==typeof Math.imul&&-2===Math.imul(4294967295,2)?Math.imul:function(t,e){var r=65535&(t|=0),n=65535&(e|=0);return r*n+((t>>>16)*n+r*(e>>>16)<<16>>>0)|0};function _t(t){return t>>>1&1073741824|3221225471&t}var lt=Object.prototype.valueOf;function vt(t){if(null==t)return yt(t);if("function"==typeof t.hashCode)return _t(t.hashCode(t));var e,r=(e=t).valueOf!==lt&&"function"==typeof e.valueOf?e.valueOf(e):e;if(null==r)return yt(r);switch(typeof r){case"boolean":return r?1108378657:1108378656;case"number":return function(t){if(t!=t||t===1/0)return 0;var e=0|t;e!==t&&(e^=4294967295*t);for(;t>4294967295;)e^=t/=4294967295;return _t(e)}(r);case"string":return r.length>Et?function(t){var e=Mt[t];void 0===e&&(e=dt(t),jt===qt&&(jt=0,Mt={}),jt++,Mt[t]=e);return e}(r):dt(r);case"object":case"function":return function(t){var e;if(St&&void 0!==(e=zt.get(t)))return e;if(e=t[Ot],void 0!==e)return e;if(!wt){if(void 0!==(e=t.propertyIsEnumerable&&t.propertyIsEnumerable[Ot]))return e;if(void 0!==(e=function(t){if(t&&t.nodeType>0)switch(t.nodeType){case 1:return t.uniqueID;case 9:return t.documentElement&&t.documentElement.uniqueID}}(t)))return e}if(e=mt(),St)zt.set(t,e);else{if(void 0!==gt&&!1===gt(t))throw new Error("Non-extensible objects are not allowed as keys.");if(wt)Object.defineProperty(t,Ot,{enumerable:!1,configurable:!1,writable:!1,value:e});else if(void 0!==t.propertyIsEnumerable&&t.propertyIsEnumerable===t.constructor.prototype.propertyIsEnumerable)t.propertyIsEnumerable=function(){return this.constructor.prototype.propertyIsEnumerable.apply(this,arguments)},t.propertyIsEnumerable[Ot]=e;else{if(void 0===t.nodeType)throw new Error("Unable to set a non-enumerable property on object.");t[Ot]=e}}return e}(r);case"symbol":return function(t){var e=bt[t];if(void 0!==e)return e;return e=mt(),bt[t]=e,e}(r);default:if("function"==typeof r.toString)return dt(r.toString());throw new Error("Value type "+typeof r+" cannot be hashed.")}}function yt(t){return null===t?1108378658:1108378659}function dt(t){for(var e=0,r=0;r=0&&(a.get=function(e,r){return(e=c(this,e))>=0&&eo)return{value:void 0,done:!0};var t=i.next();return n||e===U||t.done?t:P(e,a-1,e===R?void 0:t.value[1],t)}))},a}function Lt(t,e,r,n){var i=Qt(t);return i.__iterateUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterate(i,o);var s=!0,a=0;return t.__iterate((function(t,o,c){if(!s||!(s=e.call(r,t,o,c)))return a++,i(t,n?o:a-1,u)})),a},i.__iteratorUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterator(i,o);var s=t.__iterator(T,o),a=!0,c=0;return new C((function(){var t,o,f;do{if((t=s.next()).done)return n||i===U?t:P(i,c++,i===R?void 0:t.value[1],t);var h=t.value;o=h[0],f=h[1],a&&(a=e.call(r,f,o,u))}while(a);return i===T?t:P(i,o,f,t)}))},i}function Ct(t,e,r){var n=Qt(t);return n.__iterateUncached=function(i,o){if(o)return this.cacheResult().__iterate(i,o);var u=0,s=!1;return function t(a,c){a.__iterate((function(o,a){return(!e||c0}function Ht(t,e,r,n){var i=Qt(t),o=new $(r).map((function(t){return t.size}));return i.size=n?o.max():o.min(),i.__iterate=function(t,e){for(var r,n=this.__iterator(U,e),i=0;!(r=n.next()).done&&!1!==t(r.value,i++,this););return i},i.__iteratorUncached=function(t,i){var o=r.map((function(t){return t=b(t),J(i?t.reverse():t)})),u=0,s=!1;return new C((function(){var r;return s||(r=o.map((function(t){return t.next()})),s=n?r.every((function(t){return t.done})):r.some((function(t){return t.done}))),s?{value:void 0,done:!0}:P(t,u++,e.apply(null,r.map((function(t){return t.value}))))}))},i}function Jt(t,e){return t===e?t:j(t)?e:t.constructor(e)}function Vt(t){if(t!==Object(t))throw new TypeError("Expected [K, V] tuple: "+t)}function Yt(t){return w(t)?I:z(t)?O:E}function Qt(t){return Object.create((w(t)?F:z(t)?G:Z).prototype)}function Xt(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size,this):X.prototype.cacheResult.call(this)}function Ft(t,e){return void 0===t&&void 0===e?0:void 0===t?1:void 0===e?-1:t>e?1:t0;)e[r]=arguments[r+1];if("function"!=typeof t)throw new TypeError("Invalid merger function: "+t);return ze(this,e,t)}function ze(t,e,r){for(var n=[],i=0;i0;)e[r]=arguments[r+1];return Se(this,e,t)}function Ee(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return fe(this,t,He(),(function(t){return be(t,e)}))}function qe(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return fe(this,t,He(),(function(t){return Se(t,e)}))}function je(t){var e=this.asMutable();return t(e),e.wasAltered()?e.__ensureOwner(this.__ownerID):this}function Me(){return this.__ownerID?this:this.__ensureOwner(new s)}function De(){return this.__ensureOwner()}function xe(){return this.__altered}var Ae=function(t){function e(e){return null==e?He():at(e)&&!k(e)?e:He().withMutations((function(r){var n=t(e);$t(n.size),n.forEach((function(t,e){return r.set(e,t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toString=function(){return this.__toString("Map {","}")},e.prototype.get=function(t,e){return this._root?this._root.get(0,void 0,t,e):e},e.prototype.set=function(t,e){return Je(this,t,e)},e.prototype.remove=function(t){return Je(this,t,o)},e.prototype.deleteAll=function(t){var e=b(t);return 0===e.size?this:this.withMutations((function(t){e.forEach((function(e){return t.remove(e)}))}))},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):He()},e.prototype.sort=function(t){return vr(Pt(this,t))},e.prototype.sortBy=function(t,e){return vr(Pt(this,e,t))},e.prototype.map=function(t,e){var r=this;return this.withMutations((function(n){n.forEach((function(i,o){n.set(o,t.call(e,i,o,r))}))}))},e.prototype.__iterator=function(t,e){return new Ce(this,t,e)},e.prototype.__iterate=function(t,e){var r=this,n=0;return this._root&&this._root.iterate((function(e){return n++,t(e[1],e[0],r)}),e),n},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Ne(this.size,this._root,t,this.__hash):0===this.size?He():(this.__ownerID=t,this.__altered=!1,this)},e}(I);Ae.isMap=at;var ke=Ae.prototype;ke[st]=!0,ke[e]=ke.remove,ke.removeAll=ke.deleteAll,ke.setIn=_e,ke.removeIn=ke.deleteIn=ve,ke.update=de,ke.updateIn=ge,ke.merge=ke.concat=we,ke.mergeWith=me,ke.mergeDeep=Ie,ke.mergeDeepWith=Oe,ke.mergeIn=Ee,ke.mergeDeepIn=qe,ke.withMutations=je,ke.wasAltered=xe,ke.asImmutable=De,ke["@@transducer/init"]=ke.asMutable=Me,ke["@@transducer/step"]=function(t,e){return t.set(e[0],e[1])},ke["@@transducer/result"]=function(t){return t.asImmutable()};var Re=function(t,e){this.ownerID=t,this.entries=e};Re.prototype.get=function(t,e,r,n){for(var i=this.entries,o=0,u=i.length;o=Ge)return function(t,e,r,n){t||(t=new s);for(var i=new Ke(t,vt(r),[r,n]),o=0;o>>t)&i),s=this.bitmap;return 0==(s&u)?o:this.nodes[Xe(s&u-1)].get(t+r,e,n,o)},Ue.prototype.update=function(t,e,u,s,a,c,f){void 0===u&&(u=vt(s));var h=(0===e?u:u>>>e)&i,p=1<=Ze)return function(t,e,r,i,o){for(var u=0,s=new Array(n),a=0;0!==r;a++,r>>>=1)s[a]=1&r?e[u++]:void 0;return s[i]=o,new Te(t,u+1,s)}(t,y,_,h,g);if(l&&!g&&2===y.length&&Ye(y[1^v]))return y[1^v];if(l&&g&&1===y.length&&Ye(g))return g;var w=t&&t===this.ownerID,m=l?g?_:_^p:_|p,z=l?g?Fe(y,v,g,w):function(t,e,r){var n=t.length-1;if(r&&e===n)return t.pop(),t;for(var i=new Array(n),o=0,u=0;u>>t)&i,s=this.nodes[u];return s?s.get(t+r,e,n,o):o},Te.prototype.update=function(t,e,n,u,s,a,c){void 0===n&&(n=vt(u));var f=(0===e?n:n>>>e)&i,h=s===o,p=this.nodes,_=p[f];if(h&&!_)return this;var l=Ve(_,t,e+r,n,u,s,a,c);if(l===_)return this;var v=this.count;if(_){if(!l&&--v<$e)return function(t,e,r,n){for(var i=0,o=0,u=new Array(r),s=0,a=1,c=e.length;s>>n)&i,c=(0===n?o:o>>>n)&i,f=a===c?[Qe(t,e,n+r,o,u)]:(s=new Ke(e,o,u),a>1&1431655765))+(t>>2&858993459))+(t>>4)&252645135,t+=t>>8,127&(t+=t>>16)}function Fe(t,e,r,n){var i=n?t:Gt(t);return i[e]=r,i}var Ge=n/4,Ze=n/2,$e=n/4,tr="@@__IMMUTABLE_LIST__@@";function er(t){return Boolean(t&&t[tr])}var rr=function(t){function e(e){var i=ar();if(null==e)return i;if(er(e))return e;var o=t(e),u=o.size;return 0===u?i:($t(u),u>0&&u=0&&t=t.size||e<0)return t.withMutations((function(t){e<0?pr(t,e).set(0,r):pr(t,0,e+1).set(e,r)}));e+=t._origin;var n=t._tail,i=t._root,o={value:!1};e>=_r(t._capacity)?n=cr(n,t.__ownerID,0,e,r,o):i=cr(i,t.__ownerID,t._level,e,r,o);if(!o.value)return t;if(t.__ownerID)return t._root=i,t._tail=n,t.__hash=void 0,t.__altered=!0,t;return sr(t._origin,t._capacity,t._level,i,n)}(this,t,e)},e.prototype.remove=function(t){return this.has(t)?0===t?this.shift():t===this.size-1?this.pop():this.splice(t,1):this},e.prototype.insert=function(t,e){return this.splice(t,0,e)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=this._origin=this._capacity=0,this._level=r,this._root=this._tail=this.__hash=void 0,this.__altered=!0,this):ar()},e.prototype.push=function(){var t=arguments,e=this.size;return this.withMutations((function(r){pr(r,0,e+t.length);for(var n=0;n>>e&i;if(o>=this.array.length)return new ir([],t);var u,s=0===o;if(e>0){var a=this.array[o];if((u=a&&a.removeBefore(t,e-r,n))===a&&s)return this}if(s&&!u)return this;var c=fr(this,t);if(!s)for(var f=0;f>>e&i;if(u>=this.array.length)return this;if(e>0){var s=this.array[u];if((o=s&&s.removeAfter(t,e-r,n))===s&&u===this.array.length-1)return this}var a=fr(this,t);return a.array.splice(u+1),o&&(a.array[u]=o),a};var or={};function ur(t,e){var i=t._origin,o=t._capacity,u=_r(o),s=t._tail;return a(t._root,t._level,0);function a(t,c,f){return 0===c?function(t,r){var a=r===u?s&&s.array:t&&t.array,c=r>i?0:i-r,f=o-r;f>n&&(f=n);return function(){if(c===f)return or;var t=e?--f:c++;return a&&a[t]}}(t,f):function(t,u,s){var c,f=t&&t.array,h=s>i?0:i-s>>u,p=1+(o-s>>u);p>n&&(p=n);return function(){for(;;){if(c){var t=c();if(t!==or)return t;c=null}if(h===p)return or;var n=e?--p:h++;c=a(f&&f[n],u-r,s+(n<>>n&i,h=t&&f0){var p=t&&t.array[f],_=cr(p,e,n-r,o,s,a);return _===p?t:((c=fr(t,e)).array[f]=_,c)}return h&&t.array[f]===s?t:(a&&u(a),c=fr(t,e),void 0===s&&f===c.array.length-1?c.array.pop():c.array[f]=s,c)}function fr(t,e){return e&&t&&e===t.ownerID?t:new ir(t?t.array.slice():[],e)}function hr(t,e){if(e>=_r(t._capacity))return t._tail;if(e<1<0;)n=n.array[e>>>o&i],o-=r;return n}}function pr(t,e,n){void 0!==e&&(e|=0),void 0!==n&&(n|=0);var o=t.__ownerID||new s,u=t._origin,a=t._capacity,c=u+e,f=void 0===n?a:n<0?a+n:u+n;if(c===u&&f===a)return t;if(c>=f)return t.clear();for(var h=t._level,p=t._root,_=0;c+_<0;)p=new ir(p&&p.array.length?[void 0,p]:[],o),_+=1<<(h+=r);_&&(c+=_,u+=_,f+=_,a+=_);for(var l=_r(a),v=_r(f);v>=1<l?new ir([],o):y;if(y&&v>l&&cr;w-=r){var m=l>>>w&i;g=g.array[m]=fr(g.array[m],o)}g.array[l>>>r&i]=y}if(f=v)c-=v,f-=v,h=r,p=null,d=d&&d.removeBefore(o,0,c);else if(c>u||v>>h&i;if(z!==v>>>h&i)break;z&&(_+=(1<u&&(p=p.removeBefore(o,h,c-_)),p&&v>>r<=n&&a.size>=2*s.size?(i=(u=a.filter((function(t,e){return void 0!==t&&c!==e}))).toKeyedSeq().map((function(t){return t[0]})).flip().toMap(),t.__ownerID&&(i.__ownerID=u.__ownerID=t.__ownerID)):(i=s.remove(e),u=c===a.size-1?a.pop():a.set(c,void 0))}else if(f){if(r===a.get(c)[1])return t;i=s,u=a.set(c,[e,r])}else i=s.set(e,a.size),u=a.set(a.size,[e,r]);return t.__ownerID?(t.size=i.size,t._map=i,t._list=u,t.__hash=void 0,t.__altered=!0,t):yr(i,u)}vr.isOrderedMap=ct,vr.prototype[A]=!0,vr.prototype[e]=vr.prototype.remove;var wr="@@__IMMUTABLE_STACK__@@";function mr(t){return Boolean(t&&t[wr])}var zr=function(t){function e(t){return null==t?Or():mr(t)?t:Or().pushAll(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("Stack [","]")},e.prototype.get=function(t,e){var r=this._head;for(t=c(this,t);r&&t--;)r=r.next;return r?r.value:e},e.prototype.peek=function(){return this._head&&this._head.value},e.prototype.push=function(){var t=arguments;if(0===arguments.length)return this;for(var e=this.size+arguments.length,r=this._head,n=arguments.length-1;n>=0;n--)r={value:t[n],next:r};return this.__ownerID?(this.size=e,this._head=r,this.__hash=void 0,this.__altered=!0,this):Ir(e,r)},e.prototype.pushAll=function(e){if(0===(e=t(e)).size)return this;if(0===this.size&&mr(e))return e;$t(e.size);var r=this.size,n=this._head;return e.__iterate((function(t){r++,n={value:t,next:n}}),!0),this.__ownerID?(this.size=r,this._head=n,this.__hash=void 0,this.__altered=!0,this):Ir(r,n)},e.prototype.pop=function(){return this.slice(1)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):Or()},e.prototype.slice=function(e,r){if(h(e,r,this.size))return this;var n=p(e,this.size);if(_(r,this.size)!==this.size)return t.prototype.slice.call(this,e,r);for(var i=this.size-n,o=this._head;n--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):Ir(i,o)},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Ir(this.size,this._head,t,this.__hash):0===this.size?Or():(this.__ownerID=t,this.__altered=!1,this)},e.prototype.__iterate=function(t,e){var r=this;if(e)return new $(this.toArray()).__iterate((function(e,n){return t(e,n,r)}),e);for(var n=0,i=this._head;i&&!1!==t(i.value,n++,this);)i=i.next;return n},e.prototype.__iterator=function(t,e){if(e)return new $(this.toArray()).__iterator(t,e);var r=0,n=this._head;return new C((function(){if(n){var e=n.value;return n=n.next,P(t,r++,e)}return{value:void 0,done:!0}}))},e}(O);zr.isStack=mr;var Sr,br=zr.prototype;function Ir(t,e,r,n){var i=Object.create(br);return i.size=t,i._head=e,i.__ownerID=r,i.__hash=n,i.__altered=!1,i}function Or(){return Sr||(Sr=Ir(0))}br[wr]=!0,br.shift=br.pop,br.unshift=br.push,br.unshiftAll=br.pushAll,br.withMutations=je,br.wasAltered=xe,br.asImmutable=De,br["@@transducer/init"]=br.asMutable=Me,br["@@transducer/step"]=function(t,e){return t.unshift(e)},br["@@transducer/result"]=function(t){return t.asImmutable()};var Er="@@__IMMUTABLE_SET__@@";function qr(t){return Boolean(t&&t[Er])}function jr(t){return qr(t)&&k(t)}function Mr(t,e){if(t===e)return!0;if(!d(e)||void 0!==t.size&&void 0!==e.size&&t.size!==e.size||void 0!==t.__hash&&void 0!==e.__hash&&t.__hash!==e.__hash||w(t)!==w(e)||z(t)!==z(e)||k(t)!==k(e))return!1;if(0===t.size&&0===e.size)return!0;var r=!S(t);if(k(t)){var n=t.entries();return e.every((function(t,e){var i=n.next().value;return i&&ht(i[1],t)&&(r||ht(i[0],e))}))&&n.next().done}var i=!1;if(void 0===t.size)if(void 0===e.size)"function"==typeof t.cacheResult&&t.cacheResult();else{i=!0;var u=t;t=e,e=u}var s=!0,a=e.__iterate((function(e,n){if(r?!t.has(e):i?!ht(e,t.get(n,o)):!ht(t.get(n,o),e))return s=!1,!1}));return s&&t.size===a}function Dr(t,e){var r=function(r){t.prototype[r]=e[r]};return Object.keys(e).forEach(r),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(e).forEach(r),t}function xr(t){if(!t||"object"!=typeof t)return t;if(!d(t)){if(!ne(t))return t;t=X(t)}if(w(t)){var e={};return t.__iterate((function(t,r){e[r]=xr(t)})),e}var r=[];return t.__iterate((function(t){r.push(xr(t))})),r}var Ar=function(t){function e(e){return null==e?Br():qr(e)&&!k(e)?e:Br().withMutations((function(r){var n=t(e);$t(n.size),n.forEach((function(t){return r.add(t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(I(t).keySeq())},e.intersect=function(t){return(t=b(t).toArray()).length?Rr.intersect.apply(e(t.pop()),t):Br()},e.union=function(t){return(t=b(t).toArray()).length?Rr.union.apply(e(t.pop()),t):Br()},e.prototype.toString=function(){return this.__toString("Set {","}")},e.prototype.has=function(t){return this._map.has(t)},e.prototype.add=function(t){return Ur(this,this._map.set(t,t))},e.prototype.remove=function(t){return Ur(this,this._map.remove(t))},e.prototype.clear=function(){return Ur(this,this._map.clear())},e.prototype.map=function(t,e){var r=this,n=!1,i=Ur(this,this._map.mapEntries((function(i){var o=i[1],u=t.call(e,o,o,r);return u!==o&&(n=!0),[u,u]}),e));return n?i:this},e.prototype.union=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return 0===(e=e.filter((function(t){return 0!==t.size}))).length?this:0!==this.size||this.__ownerID||1!==e.length?this.withMutations((function(r){for(var n=0;n=0&&e=0&&r>>-15,461845907),e=pt(e<<13|e>>>-13,5),e=pt((e=(e+3864292196|0)^t)^e>>>16,2246822507),e=_t((e=pt(e^e>>>13,3266489909))^e>>>16)}(t.size,n)}(this))}});var Hr=b.prototype;Hr[y]=!0,Hr[L]=Hr.values,Hr.toJSON=Hr.toArray,Hr.__toStringMapper=ie,Hr.inspect=Hr.toSource=function(){return this.toString()},Hr.chain=Hr.flatMap,Hr.contains=Hr.includes,Dr(I,{flip:function(){return Jt(this,Rt(this))},mapEntries:function(t,e){var r=this,n=0;return Jt(this,this.toSeq().map((function(i,o){return t.call(e,[o,i],n++,r)})).fromEntrySeq())},mapKeys:function(t,e){var r=this;return Jt(this,this.toSeq().flip().map((function(n,i){return t.call(e,n,i,r)})).flip())}});var Jr=I.prototype;Jr[g]=!0,Jr[L]=Hr.entries,Jr.toJSON=Nr,Jr.__toStringMapper=function(t,e){return ie(e)+": "+ie(t)},Dr(O,{toKeyedSeq:function(){return new Dt(this,!1)},filter:function(t,e){return Jt(this,Bt(this,t,e,!1))},findIndex:function(t,e){var r=this.findEntry(t,e);return r?r[0]:-1},indexOf:function(t){var e=this.keyOf(t);return void 0===e?-1:e},lastIndexOf:function(t){var e=this.lastKeyOf(t);return void 0===e?-1:e},reverse:function(){return Jt(this,Tt(this,!1))},slice:function(t,e){return Jt(this,Kt(this,t,e,!1))},splice:function(t,e){var r=arguments.length;if(e=Math.max(e||0,0),0===r||2===r&&!e)return this;t=p(t,t<0?this.count():this.size);var n=this.slice(0,t);return Jt(this,1===r?n:n.concat(Gt(arguments,2),this.slice(t+e)))},findLastIndex:function(t,e){var r=this.findLastEntry(t,e);return r?r[0]:-1},first:function(t){return this.get(0,t)},flatten:function(t){return Jt(this,Ct(this,t,!1))},get:function(t,e){return(t=c(this,t))<0||this.size===1/0||void 0!==this.size&&t>this.size?e:this.find((function(e,r){return r===t}),void 0,e)},has:function(t){return(t=c(this,t))>=0&&(void 0!==this.size?this.size===1/0||te?-1:0}function en(t,e){return t^e+2654435769+(t<<6)+(t>>2)|0}Yr.has=Hr.includes,Yr.contains=Yr.includes,Yr.keys=Yr.values,Dr(F,Jr),Dr(G,Vr),Dr(Z,Yr);var rn=function(t){function e(t){return null==t?sn():jr(t)?t:sn().withMutations((function(e){var r=E(t);$t(r.size),r.forEach((function(t){return e.add(t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(I(t).keySeq())},e.prototype.toString=function(){return this.__toString("OrderedSet {","}")},e}(Ar);rn.isOrderedSet=jr;var nn,on=rn.prototype;function un(t,e){var r=Object.create(on);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function sn(){return nn||(nn=un(dr()))}on[A]=!0,on.zip=Vr.zip,on.zipWith=Vr.zipWith,on.zipAll=Vr.zipAll,on.__empty=sn,on.__make=un;var an=function(t,e){var r;!function(t){if(D(t))throw new Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(x(t))throw new Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(null===t||"object"!=typeof t)throw new Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}(t);var n=function(o){var u=this;if(o instanceof n)return o;if(!(this instanceof n))return new n(o);if(!r){r=!0;var s=Object.keys(t),a=i._indices={};i._name=e,i._keys=s,i._defaultValues=t;for(var c=0;c2?[]:void 0,{"":t})},t.get=ue,t.getIn=Cr,t.has=oe,t.hasIn=Wr,t.hash=vt,t.is=ht,t.isAssociative=S,t.isCollection=d,t.isImmutable=x,t.isIndexed=z,t.isKeyed=w,t.isList=er,t.isMap=at,t.isOrdered=k,t.isOrderedMap=ct,t.isOrderedSet=jr,t.isPlainObject=re,t.isRecord=D,t.isSeq=j,t.isSet=qr,t.isStack=mr,t.isValueObject=ft,t.merge=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return be(t,e)},t.mergeDeep=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Se(t,e)},t.mergeDeepWith=function(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];return Se(e,r,t)},t.mergeWith=function(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];return be(e,r,t)},t.remove=ae,t.removeIn=le,t.set=ce,t.setIn=pe,t.update=ye,t.updateIn=fe,t.version="5.0.0-rc.2"})); diff --git a/package.json b/package.json index 7a9f05049d..02f475aebd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "immutable", - "version": "5.0.0-rc.1", + "version": "5.0.0-rc.2", "description": "Immutable Data Collections", "license": "MIT", "homepage": "https://immutable-js.com", From cc044493d91555e431c6ebb14cc9c15e880eddce Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sun, 3 Nov 2024 22:59:46 +0000 Subject: [PATCH 216/242] deploy: 5f0de66fccc33435c88477560869768229845ed3 --- bower.json | 2 +- dist/es/package.json.js | 2 +- dist/immutable.js | 2 +- dist/immutable.js.flow | 6 +++--- dist/immutable.min.js | 2 +- package.json | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/bower.json b/bower.json index 02f475aebd..d96362aa14 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "immutable", - "version": "5.0.0-rc.2", + "version": "5.0.0", "description": "Immutable Data Collections", "license": "MIT", "homepage": "https://immutable-js.com", diff --git a/dist/es/package.json.js b/dist/es/package.json.js index 0ef90db74b..2e261e336c 100644 --- a/dist/es/package.json.js +++ b/dist/es/package.json.js @@ -22,6 +22,6 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -var version = "5.0.0-rc.2"; +var version = "5.0.0"; export { version }; diff --git a/dist/immutable.js b/dist/immutable.js index 6b4536465d..b5c27224ff 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -5928,7 +5928,7 @@ return isIndexed(v) ? v.toList() : isKeyed(v) ? v.toMap() : v.toSet(); } - var version = "5.0.0-rc.2"; + var version = "5.0.0"; // Note: Iterable is deprecated var Iterable = Collection; diff --git a/dist/immutable.js.flow b/dist/immutable.js.flow index 22422909be..afb87e0da9 100644 --- a/dist/immutable.js.flow +++ b/dist/immutable.js.flow @@ -938,7 +938,7 @@ declare class List<+T> extends IndexedCollection mixins UpdatableInCollection { - static (collection?: Iterable): List; + static (collection?: Iterable): List; static of(...values: T[]): List; @@ -1310,8 +1310,8 @@ declare class Set<+T> extends SetCollection { values: Iterable<[T, mixed]> | PlainObjInput ): Set; - static intersect(sets: Iterable>): Set; - static union(sets: Iterable>): Set; + static intersect(sets: Iterable>): Set; + static union(sets: Iterable>): Set; static isSet: typeof isSet; diff --git a/dist/immutable.min.js b/dist/immutable.min.js index 05f62e5ee7..95932dea7f 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -22,4 +22,4 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).Immutable={})}(this,(function(t){"use strict";var e="delete",r=5,n=1<>>0;if(""+r!==e||4294967295===r)return NaN;e=r}return e<0?a(t)+e:e}function f(){return!0}function h(t,e,r){return(0===t&&!v(t)||void 0!==r&&t<=-r)&&(void 0===e||void 0!==r&&e>=r)}function p(t,e){return l(t,e,0)}function _(t,e){return l(t,e,e)}function l(t,e,r){return void 0===t?r:v(t)?e===1/0?e:0|Math.max(0,e+t):void 0===e||e===t?t:0|Math.min(e,t)}function v(t){return t<0||0===t&&1/t==-1/0}var y="@@__IMMUTABLE_ITERABLE__@@";function d(t){return Boolean(t&&t[y])}var g="@@__IMMUTABLE_KEYED__@@";function w(t){return Boolean(t&&t[g])}var m="@@__IMMUTABLE_INDEXED__@@";function z(t){return Boolean(t&&t[m])}function S(t){return w(t)||z(t)}var b=function(t){return d(t)?t:X(t)},I=function(t){function e(t){return w(t)?t:F(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(b),O=function(t){function e(t){return z(t)?t:G(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(b),E=function(t){function e(t){return d(t)&&!S(t)?t:Z(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(b);b.Keyed=I,b.Indexed=O,b.Set=E;var q="@@__IMMUTABLE_SEQ__@@";function j(t){return Boolean(t&&t[q])}var M="@@__IMMUTABLE_RECORD__@@";function D(t){return Boolean(t&&t[M])}function x(t){return d(t)||D(t)}var A="@@__IMMUTABLE_ORDERED__@@";function k(t){return Boolean(t&&t[A])}var R=0,U=1,T=2,B="function"==typeof Symbol&&Symbol.iterator,K="@@iterator",L=B||K,C=function(t){this.next=t};function P(t,e,r,n){var i=0===t?e:1===t?r:[e,r];return n?n.value=i:n={value:i,done:!1},n}function W(){return{value:void 0,done:!0}}function N(t){return!!Array.isArray(t)||!!V(t)}function H(t){return t&&"function"==typeof t.next}function J(t){var e=V(t);return e&&e.call(t)}function V(t){var e=t&&(B&&t[B]||t[K]);if("function"==typeof e)return e}C.prototype.toString=function(){return"[Iterator]"},C.KEYS=R,C.VALUES=U,C.ENTRIES=T,C.prototype.inspect=C.prototype.toSource=function(){return this.toString()},C.prototype[L]=function(){return this};var Y=Object.prototype.hasOwnProperty;function Q(t){return!(!Array.isArray(t)&&"string"!=typeof t)||t&&"object"==typeof t&&Number.isInteger(t.length)&&t.length>=0&&(0===t.length?1===Object.keys(t).length:t.hasOwnProperty(t.length-1))}var X=function(t){function e(t){return null==t?nt():x(t)?t.toSeq():function(t){var e=ut(t);if(e)return(n=V(r=t))&&n===r.entries?e.fromEntrySeq():function(t){var e=V(t);return e&&e===t.keys}(t)?e.toSetSeq():e;var r,n;if("object"==typeof t)return new tt(t);throw new TypeError("Expected Array or collection object of values, or keyed object: "+t)}(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq {","}")},e.prototype.cacheResult=function(){return!this._cache&&this.__iterateUncached&&(this._cache=this.entrySeq().toArray(),this.size=this._cache.length),this},e.prototype.__iterate=function(t,e){var r=this._cache;if(r){for(var n=r.length,i=0;i!==n;){var o=r[e?n-++i:i++];if(!1===t(o[1],o[0],this))break}return i}return this.__iterateUncached(t,e)},e.prototype.__iterator=function(t,e){var r=this._cache;if(r){var n=r.length,i=0;return new C((function(){if(i===n)return{value:void 0,done:!0};var o=r[e?n-++i:i++];return P(t,o[0],o[1])}))}return this.__iteratorUncached(t,e)},e}(b),F=function(t){function e(t){return null==t?nt().toKeyedSeq():d(t)?w(t)?t.toSeq():t.fromEntrySeq():D(t)?t.toSeq():it(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toKeyedSeq=function(){return this},e}(X),G=function(t){function e(t){return null==t?nt():d(t)?w(t)?t.entrySeq():t.toIndexedSeq():D(t)?t.toSeq().entrySeq():ot(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return e(arguments)},e.prototype.toIndexedSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq [","]")},e}(X),Z=function(t){function e(t){return(d(t)&&!S(t)?t:G(t)).toSetSeq()}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return e(arguments)},e.prototype.toSetSeq=function(){return this},e}(X);X.isSeq=j,X.Keyed=F,X.Set=Z,X.Indexed=G,X.prototype[q]=!0;var $=function(t){function e(t){this._array=t,this.size=t.length}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t,e){return this.has(t)?this._array[c(this,t)]:e},e.prototype.__iterate=function(t,e){for(var r=this._array,n=r.length,i=0;i!==n;){var o=e?n-++i:i++;if(!1===t(r[o],o,this))break}return i},e.prototype.__iterator=function(t,e){var r=this._array,n=r.length,i=0;return new C((function(){if(i===n)return{value:void 0,done:!0};var o=e?n-++i:i++;return P(t,o,r[o])}))},e}(G),tt=function(t){function e(t){var e=Object.keys(t).concat(Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(t):[]);this._object=t,this._keys=e,this.size=e.length}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t,e){return void 0===e||this.has(t)?this._object[t]:e},e.prototype.has=function(t){return Y.call(this._object,t)},e.prototype.__iterate=function(t,e){for(var r=this._object,n=this._keys,i=n.length,o=0;o!==i;){var u=n[e?i-++o:o++];if(!1===t(r[u],u,this))break}return o},e.prototype.__iterator=function(t,e){var r=this._object,n=this._keys,i=n.length,o=0;return new C((function(){if(o===i)return{value:void 0,done:!0};var u=n[e?i-++o:o++];return P(t,u,r[u])}))},e}(F);tt.prototype[A]=!0;var et,rt=function(t){function e(t){this._collection=t,this.size=t.length||t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.__iterateUncached=function(t,e){if(e)return this.cacheResult().__iterate(t,e);var r=J(this._collection),n=0;if(H(r))for(var i;!(i=r.next()).done&&!1!==t(i.value,n++,this););return n},e.prototype.__iteratorUncached=function(t,e){if(e)return this.cacheResult().__iterator(t,e);var r=J(this._collection);if(!H(r))return new C(W);var n=0;return new C((function(){var e=r.next();return e.done?e:P(t,n++,e.value)}))},e}(G);function nt(){return et||(et=new $([]))}function it(t){var e=ut(t);if(e)return e.fromEntrySeq();if("object"==typeof t)return new tt(t);throw new TypeError("Expected Array or collection object of [k, v] entries, or keyed object: "+t)}function ot(t){var e=ut(t);if(e)return e;throw new TypeError("Expected Array or collection object of values: "+t)}function ut(t){return Q(t)?new $(t):N(t)?new rt(t):void 0}var st="@@__IMMUTABLE_MAP__@@";function at(t){return Boolean(t&&t[st])}function ct(t){return at(t)&&k(t)}function ft(t){return Boolean(t&&"function"==typeof t.equals&&"function"==typeof t.hashCode)}function ht(t,e){if(t===e||t!=t&&e!=e)return!0;if(!t||!e)return!1;if("function"==typeof t.valueOf&&"function"==typeof e.valueOf){if((t=t.valueOf())===(e=e.valueOf())||t!=t&&e!=e)return!0;if(!t||!e)return!1}return!!(ft(t)&&ft(e)&&t.equals(e))}var pt="function"==typeof Math.imul&&-2===Math.imul(4294967295,2)?Math.imul:function(t,e){var r=65535&(t|=0),n=65535&(e|=0);return r*n+((t>>>16)*n+r*(e>>>16)<<16>>>0)|0};function _t(t){return t>>>1&1073741824|3221225471&t}var lt=Object.prototype.valueOf;function vt(t){if(null==t)return yt(t);if("function"==typeof t.hashCode)return _t(t.hashCode(t));var e,r=(e=t).valueOf!==lt&&"function"==typeof e.valueOf?e.valueOf(e):e;if(null==r)return yt(r);switch(typeof r){case"boolean":return r?1108378657:1108378656;case"number":return function(t){if(t!=t||t===1/0)return 0;var e=0|t;e!==t&&(e^=4294967295*t);for(;t>4294967295;)e^=t/=4294967295;return _t(e)}(r);case"string":return r.length>Et?function(t){var e=Mt[t];void 0===e&&(e=dt(t),jt===qt&&(jt=0,Mt={}),jt++,Mt[t]=e);return e}(r):dt(r);case"object":case"function":return function(t){var e;if(St&&void 0!==(e=zt.get(t)))return e;if(e=t[Ot],void 0!==e)return e;if(!wt){if(void 0!==(e=t.propertyIsEnumerable&&t.propertyIsEnumerable[Ot]))return e;if(void 0!==(e=function(t){if(t&&t.nodeType>0)switch(t.nodeType){case 1:return t.uniqueID;case 9:return t.documentElement&&t.documentElement.uniqueID}}(t)))return e}if(e=mt(),St)zt.set(t,e);else{if(void 0!==gt&&!1===gt(t))throw new Error("Non-extensible objects are not allowed as keys.");if(wt)Object.defineProperty(t,Ot,{enumerable:!1,configurable:!1,writable:!1,value:e});else if(void 0!==t.propertyIsEnumerable&&t.propertyIsEnumerable===t.constructor.prototype.propertyIsEnumerable)t.propertyIsEnumerable=function(){return this.constructor.prototype.propertyIsEnumerable.apply(this,arguments)},t.propertyIsEnumerable[Ot]=e;else{if(void 0===t.nodeType)throw new Error("Unable to set a non-enumerable property on object.");t[Ot]=e}}return e}(r);case"symbol":return function(t){var e=bt[t];if(void 0!==e)return e;return e=mt(),bt[t]=e,e}(r);default:if("function"==typeof r.toString)return dt(r.toString());throw new Error("Value type "+typeof r+" cannot be hashed.")}}function yt(t){return null===t?1108378658:1108378659}function dt(t){for(var e=0,r=0;r=0&&(a.get=function(e,r){return(e=c(this,e))>=0&&eo)return{value:void 0,done:!0};var t=i.next();return n||e===U||t.done?t:P(e,a-1,e===R?void 0:t.value[1],t)}))},a}function Lt(t,e,r,n){var i=Qt(t);return i.__iterateUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterate(i,o);var s=!0,a=0;return t.__iterate((function(t,o,c){if(!s||!(s=e.call(r,t,o,c)))return a++,i(t,n?o:a-1,u)})),a},i.__iteratorUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterator(i,o);var s=t.__iterator(T,o),a=!0,c=0;return new C((function(){var t,o,f;do{if((t=s.next()).done)return n||i===U?t:P(i,c++,i===R?void 0:t.value[1],t);var h=t.value;o=h[0],f=h[1],a&&(a=e.call(r,f,o,u))}while(a);return i===T?t:P(i,o,f,t)}))},i}function Ct(t,e,r){var n=Qt(t);return n.__iterateUncached=function(i,o){if(o)return this.cacheResult().__iterate(i,o);var u=0,s=!1;return function t(a,c){a.__iterate((function(o,a){return(!e||c0}function Ht(t,e,r,n){var i=Qt(t),o=new $(r).map((function(t){return t.size}));return i.size=n?o.max():o.min(),i.__iterate=function(t,e){for(var r,n=this.__iterator(U,e),i=0;!(r=n.next()).done&&!1!==t(r.value,i++,this););return i},i.__iteratorUncached=function(t,i){var o=r.map((function(t){return t=b(t),J(i?t.reverse():t)})),u=0,s=!1;return new C((function(){var r;return s||(r=o.map((function(t){return t.next()})),s=n?r.every((function(t){return t.done})):r.some((function(t){return t.done}))),s?{value:void 0,done:!0}:P(t,u++,e.apply(null,r.map((function(t){return t.value}))))}))},i}function Jt(t,e){return t===e?t:j(t)?e:t.constructor(e)}function Vt(t){if(t!==Object(t))throw new TypeError("Expected [K, V] tuple: "+t)}function Yt(t){return w(t)?I:z(t)?O:E}function Qt(t){return Object.create((w(t)?F:z(t)?G:Z).prototype)}function Xt(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size,this):X.prototype.cacheResult.call(this)}function Ft(t,e){return void 0===t&&void 0===e?0:void 0===t?1:void 0===e?-1:t>e?1:t0;)e[r]=arguments[r+1];if("function"!=typeof t)throw new TypeError("Invalid merger function: "+t);return ze(this,e,t)}function ze(t,e,r){for(var n=[],i=0;i0;)e[r]=arguments[r+1];return Se(this,e,t)}function Ee(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return fe(this,t,He(),(function(t){return be(t,e)}))}function qe(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return fe(this,t,He(),(function(t){return Se(t,e)}))}function je(t){var e=this.asMutable();return t(e),e.wasAltered()?e.__ensureOwner(this.__ownerID):this}function Me(){return this.__ownerID?this:this.__ensureOwner(new s)}function De(){return this.__ensureOwner()}function xe(){return this.__altered}var Ae=function(t){function e(e){return null==e?He():at(e)&&!k(e)?e:He().withMutations((function(r){var n=t(e);$t(n.size),n.forEach((function(t,e){return r.set(e,t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toString=function(){return this.__toString("Map {","}")},e.prototype.get=function(t,e){return this._root?this._root.get(0,void 0,t,e):e},e.prototype.set=function(t,e){return Je(this,t,e)},e.prototype.remove=function(t){return Je(this,t,o)},e.prototype.deleteAll=function(t){var e=b(t);return 0===e.size?this:this.withMutations((function(t){e.forEach((function(e){return t.remove(e)}))}))},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):He()},e.prototype.sort=function(t){return vr(Pt(this,t))},e.prototype.sortBy=function(t,e){return vr(Pt(this,e,t))},e.prototype.map=function(t,e){var r=this;return this.withMutations((function(n){n.forEach((function(i,o){n.set(o,t.call(e,i,o,r))}))}))},e.prototype.__iterator=function(t,e){return new Ce(this,t,e)},e.prototype.__iterate=function(t,e){var r=this,n=0;return this._root&&this._root.iterate((function(e){return n++,t(e[1],e[0],r)}),e),n},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Ne(this.size,this._root,t,this.__hash):0===this.size?He():(this.__ownerID=t,this.__altered=!1,this)},e}(I);Ae.isMap=at;var ke=Ae.prototype;ke[st]=!0,ke[e]=ke.remove,ke.removeAll=ke.deleteAll,ke.setIn=_e,ke.removeIn=ke.deleteIn=ve,ke.update=de,ke.updateIn=ge,ke.merge=ke.concat=we,ke.mergeWith=me,ke.mergeDeep=Ie,ke.mergeDeepWith=Oe,ke.mergeIn=Ee,ke.mergeDeepIn=qe,ke.withMutations=je,ke.wasAltered=xe,ke.asImmutable=De,ke["@@transducer/init"]=ke.asMutable=Me,ke["@@transducer/step"]=function(t,e){return t.set(e[0],e[1])},ke["@@transducer/result"]=function(t){return t.asImmutable()};var Re=function(t,e){this.ownerID=t,this.entries=e};Re.prototype.get=function(t,e,r,n){for(var i=this.entries,o=0,u=i.length;o=Ge)return function(t,e,r,n){t||(t=new s);for(var i=new Ke(t,vt(r),[r,n]),o=0;o>>t)&i),s=this.bitmap;return 0==(s&u)?o:this.nodes[Xe(s&u-1)].get(t+r,e,n,o)},Ue.prototype.update=function(t,e,u,s,a,c,f){void 0===u&&(u=vt(s));var h=(0===e?u:u>>>e)&i,p=1<=Ze)return function(t,e,r,i,o){for(var u=0,s=new Array(n),a=0;0!==r;a++,r>>>=1)s[a]=1&r?e[u++]:void 0;return s[i]=o,new Te(t,u+1,s)}(t,y,_,h,g);if(l&&!g&&2===y.length&&Ye(y[1^v]))return y[1^v];if(l&&g&&1===y.length&&Ye(g))return g;var w=t&&t===this.ownerID,m=l?g?_:_^p:_|p,z=l?g?Fe(y,v,g,w):function(t,e,r){var n=t.length-1;if(r&&e===n)return t.pop(),t;for(var i=new Array(n),o=0,u=0;u>>t)&i,s=this.nodes[u];return s?s.get(t+r,e,n,o):o},Te.prototype.update=function(t,e,n,u,s,a,c){void 0===n&&(n=vt(u));var f=(0===e?n:n>>>e)&i,h=s===o,p=this.nodes,_=p[f];if(h&&!_)return this;var l=Ve(_,t,e+r,n,u,s,a,c);if(l===_)return this;var v=this.count;if(_){if(!l&&--v<$e)return function(t,e,r,n){for(var i=0,o=0,u=new Array(r),s=0,a=1,c=e.length;s>>n)&i,c=(0===n?o:o>>>n)&i,f=a===c?[Qe(t,e,n+r,o,u)]:(s=new Ke(e,o,u),a>1&1431655765))+(t>>2&858993459))+(t>>4)&252645135,t+=t>>8,127&(t+=t>>16)}function Fe(t,e,r,n){var i=n?t:Gt(t);return i[e]=r,i}var Ge=n/4,Ze=n/2,$e=n/4,tr="@@__IMMUTABLE_LIST__@@";function er(t){return Boolean(t&&t[tr])}var rr=function(t){function e(e){var i=ar();if(null==e)return i;if(er(e))return e;var o=t(e),u=o.size;return 0===u?i:($t(u),u>0&&u=0&&t=t.size||e<0)return t.withMutations((function(t){e<0?pr(t,e).set(0,r):pr(t,0,e+1).set(e,r)}));e+=t._origin;var n=t._tail,i=t._root,o={value:!1};e>=_r(t._capacity)?n=cr(n,t.__ownerID,0,e,r,o):i=cr(i,t.__ownerID,t._level,e,r,o);if(!o.value)return t;if(t.__ownerID)return t._root=i,t._tail=n,t.__hash=void 0,t.__altered=!0,t;return sr(t._origin,t._capacity,t._level,i,n)}(this,t,e)},e.prototype.remove=function(t){return this.has(t)?0===t?this.shift():t===this.size-1?this.pop():this.splice(t,1):this},e.prototype.insert=function(t,e){return this.splice(t,0,e)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=this._origin=this._capacity=0,this._level=r,this._root=this._tail=this.__hash=void 0,this.__altered=!0,this):ar()},e.prototype.push=function(){var t=arguments,e=this.size;return this.withMutations((function(r){pr(r,0,e+t.length);for(var n=0;n>>e&i;if(o>=this.array.length)return new ir([],t);var u,s=0===o;if(e>0){var a=this.array[o];if((u=a&&a.removeBefore(t,e-r,n))===a&&s)return this}if(s&&!u)return this;var c=fr(this,t);if(!s)for(var f=0;f>>e&i;if(u>=this.array.length)return this;if(e>0){var s=this.array[u];if((o=s&&s.removeAfter(t,e-r,n))===s&&u===this.array.length-1)return this}var a=fr(this,t);return a.array.splice(u+1),o&&(a.array[u]=o),a};var or={};function ur(t,e){var i=t._origin,o=t._capacity,u=_r(o),s=t._tail;return a(t._root,t._level,0);function a(t,c,f){return 0===c?function(t,r){var a=r===u?s&&s.array:t&&t.array,c=r>i?0:i-r,f=o-r;f>n&&(f=n);return function(){if(c===f)return or;var t=e?--f:c++;return a&&a[t]}}(t,f):function(t,u,s){var c,f=t&&t.array,h=s>i?0:i-s>>u,p=1+(o-s>>u);p>n&&(p=n);return function(){for(;;){if(c){var t=c();if(t!==or)return t;c=null}if(h===p)return or;var n=e?--p:h++;c=a(f&&f[n],u-r,s+(n<>>n&i,h=t&&f0){var p=t&&t.array[f],_=cr(p,e,n-r,o,s,a);return _===p?t:((c=fr(t,e)).array[f]=_,c)}return h&&t.array[f]===s?t:(a&&u(a),c=fr(t,e),void 0===s&&f===c.array.length-1?c.array.pop():c.array[f]=s,c)}function fr(t,e){return e&&t&&e===t.ownerID?t:new ir(t?t.array.slice():[],e)}function hr(t,e){if(e>=_r(t._capacity))return t._tail;if(e<1<0;)n=n.array[e>>>o&i],o-=r;return n}}function pr(t,e,n){void 0!==e&&(e|=0),void 0!==n&&(n|=0);var o=t.__ownerID||new s,u=t._origin,a=t._capacity,c=u+e,f=void 0===n?a:n<0?a+n:u+n;if(c===u&&f===a)return t;if(c>=f)return t.clear();for(var h=t._level,p=t._root,_=0;c+_<0;)p=new ir(p&&p.array.length?[void 0,p]:[],o),_+=1<<(h+=r);_&&(c+=_,u+=_,f+=_,a+=_);for(var l=_r(a),v=_r(f);v>=1<l?new ir([],o):y;if(y&&v>l&&cr;w-=r){var m=l>>>w&i;g=g.array[m]=fr(g.array[m],o)}g.array[l>>>r&i]=y}if(f=v)c-=v,f-=v,h=r,p=null,d=d&&d.removeBefore(o,0,c);else if(c>u||v>>h&i;if(z!==v>>>h&i)break;z&&(_+=(1<u&&(p=p.removeBefore(o,h,c-_)),p&&v>>r<=n&&a.size>=2*s.size?(i=(u=a.filter((function(t,e){return void 0!==t&&c!==e}))).toKeyedSeq().map((function(t){return t[0]})).flip().toMap(),t.__ownerID&&(i.__ownerID=u.__ownerID=t.__ownerID)):(i=s.remove(e),u=c===a.size-1?a.pop():a.set(c,void 0))}else if(f){if(r===a.get(c)[1])return t;i=s,u=a.set(c,[e,r])}else i=s.set(e,a.size),u=a.set(a.size,[e,r]);return t.__ownerID?(t.size=i.size,t._map=i,t._list=u,t.__hash=void 0,t.__altered=!0,t):yr(i,u)}vr.isOrderedMap=ct,vr.prototype[A]=!0,vr.prototype[e]=vr.prototype.remove;var wr="@@__IMMUTABLE_STACK__@@";function mr(t){return Boolean(t&&t[wr])}var zr=function(t){function e(t){return null==t?Or():mr(t)?t:Or().pushAll(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("Stack [","]")},e.prototype.get=function(t,e){var r=this._head;for(t=c(this,t);r&&t--;)r=r.next;return r?r.value:e},e.prototype.peek=function(){return this._head&&this._head.value},e.prototype.push=function(){var t=arguments;if(0===arguments.length)return this;for(var e=this.size+arguments.length,r=this._head,n=arguments.length-1;n>=0;n--)r={value:t[n],next:r};return this.__ownerID?(this.size=e,this._head=r,this.__hash=void 0,this.__altered=!0,this):Ir(e,r)},e.prototype.pushAll=function(e){if(0===(e=t(e)).size)return this;if(0===this.size&&mr(e))return e;$t(e.size);var r=this.size,n=this._head;return e.__iterate((function(t){r++,n={value:t,next:n}}),!0),this.__ownerID?(this.size=r,this._head=n,this.__hash=void 0,this.__altered=!0,this):Ir(r,n)},e.prototype.pop=function(){return this.slice(1)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):Or()},e.prototype.slice=function(e,r){if(h(e,r,this.size))return this;var n=p(e,this.size);if(_(r,this.size)!==this.size)return t.prototype.slice.call(this,e,r);for(var i=this.size-n,o=this._head;n--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):Ir(i,o)},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Ir(this.size,this._head,t,this.__hash):0===this.size?Or():(this.__ownerID=t,this.__altered=!1,this)},e.prototype.__iterate=function(t,e){var r=this;if(e)return new $(this.toArray()).__iterate((function(e,n){return t(e,n,r)}),e);for(var n=0,i=this._head;i&&!1!==t(i.value,n++,this);)i=i.next;return n},e.prototype.__iterator=function(t,e){if(e)return new $(this.toArray()).__iterator(t,e);var r=0,n=this._head;return new C((function(){if(n){var e=n.value;return n=n.next,P(t,r++,e)}return{value:void 0,done:!0}}))},e}(O);zr.isStack=mr;var Sr,br=zr.prototype;function Ir(t,e,r,n){var i=Object.create(br);return i.size=t,i._head=e,i.__ownerID=r,i.__hash=n,i.__altered=!1,i}function Or(){return Sr||(Sr=Ir(0))}br[wr]=!0,br.shift=br.pop,br.unshift=br.push,br.unshiftAll=br.pushAll,br.withMutations=je,br.wasAltered=xe,br.asImmutable=De,br["@@transducer/init"]=br.asMutable=Me,br["@@transducer/step"]=function(t,e){return t.unshift(e)},br["@@transducer/result"]=function(t){return t.asImmutable()};var Er="@@__IMMUTABLE_SET__@@";function qr(t){return Boolean(t&&t[Er])}function jr(t){return qr(t)&&k(t)}function Mr(t,e){if(t===e)return!0;if(!d(e)||void 0!==t.size&&void 0!==e.size&&t.size!==e.size||void 0!==t.__hash&&void 0!==e.__hash&&t.__hash!==e.__hash||w(t)!==w(e)||z(t)!==z(e)||k(t)!==k(e))return!1;if(0===t.size&&0===e.size)return!0;var r=!S(t);if(k(t)){var n=t.entries();return e.every((function(t,e){var i=n.next().value;return i&&ht(i[1],t)&&(r||ht(i[0],e))}))&&n.next().done}var i=!1;if(void 0===t.size)if(void 0===e.size)"function"==typeof t.cacheResult&&t.cacheResult();else{i=!0;var u=t;t=e,e=u}var s=!0,a=e.__iterate((function(e,n){if(r?!t.has(e):i?!ht(e,t.get(n,o)):!ht(t.get(n,o),e))return s=!1,!1}));return s&&t.size===a}function Dr(t,e){var r=function(r){t.prototype[r]=e[r]};return Object.keys(e).forEach(r),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(e).forEach(r),t}function xr(t){if(!t||"object"!=typeof t)return t;if(!d(t)){if(!ne(t))return t;t=X(t)}if(w(t)){var e={};return t.__iterate((function(t,r){e[r]=xr(t)})),e}var r=[];return t.__iterate((function(t){r.push(xr(t))})),r}var Ar=function(t){function e(e){return null==e?Br():qr(e)&&!k(e)?e:Br().withMutations((function(r){var n=t(e);$t(n.size),n.forEach((function(t){return r.add(t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(I(t).keySeq())},e.intersect=function(t){return(t=b(t).toArray()).length?Rr.intersect.apply(e(t.pop()),t):Br()},e.union=function(t){return(t=b(t).toArray()).length?Rr.union.apply(e(t.pop()),t):Br()},e.prototype.toString=function(){return this.__toString("Set {","}")},e.prototype.has=function(t){return this._map.has(t)},e.prototype.add=function(t){return Ur(this,this._map.set(t,t))},e.prototype.remove=function(t){return Ur(this,this._map.remove(t))},e.prototype.clear=function(){return Ur(this,this._map.clear())},e.prototype.map=function(t,e){var r=this,n=!1,i=Ur(this,this._map.mapEntries((function(i){var o=i[1],u=t.call(e,o,o,r);return u!==o&&(n=!0),[u,u]}),e));return n?i:this},e.prototype.union=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return 0===(e=e.filter((function(t){return 0!==t.size}))).length?this:0!==this.size||this.__ownerID||1!==e.length?this.withMutations((function(r){for(var n=0;n=0&&e=0&&r>>-15,461845907),e=pt(e<<13|e>>>-13,5),e=pt((e=(e+3864292196|0)^t)^e>>>16,2246822507),e=_t((e=pt(e^e>>>13,3266489909))^e>>>16)}(t.size,n)}(this))}});var Hr=b.prototype;Hr[y]=!0,Hr[L]=Hr.values,Hr.toJSON=Hr.toArray,Hr.__toStringMapper=ie,Hr.inspect=Hr.toSource=function(){return this.toString()},Hr.chain=Hr.flatMap,Hr.contains=Hr.includes,Dr(I,{flip:function(){return Jt(this,Rt(this))},mapEntries:function(t,e){var r=this,n=0;return Jt(this,this.toSeq().map((function(i,o){return t.call(e,[o,i],n++,r)})).fromEntrySeq())},mapKeys:function(t,e){var r=this;return Jt(this,this.toSeq().flip().map((function(n,i){return t.call(e,n,i,r)})).flip())}});var Jr=I.prototype;Jr[g]=!0,Jr[L]=Hr.entries,Jr.toJSON=Nr,Jr.__toStringMapper=function(t,e){return ie(e)+": "+ie(t)},Dr(O,{toKeyedSeq:function(){return new Dt(this,!1)},filter:function(t,e){return Jt(this,Bt(this,t,e,!1))},findIndex:function(t,e){var r=this.findEntry(t,e);return r?r[0]:-1},indexOf:function(t){var e=this.keyOf(t);return void 0===e?-1:e},lastIndexOf:function(t){var e=this.lastKeyOf(t);return void 0===e?-1:e},reverse:function(){return Jt(this,Tt(this,!1))},slice:function(t,e){return Jt(this,Kt(this,t,e,!1))},splice:function(t,e){var r=arguments.length;if(e=Math.max(e||0,0),0===r||2===r&&!e)return this;t=p(t,t<0?this.count():this.size);var n=this.slice(0,t);return Jt(this,1===r?n:n.concat(Gt(arguments,2),this.slice(t+e)))},findLastIndex:function(t,e){var r=this.findLastEntry(t,e);return r?r[0]:-1},first:function(t){return this.get(0,t)},flatten:function(t){return Jt(this,Ct(this,t,!1))},get:function(t,e){return(t=c(this,t))<0||this.size===1/0||void 0!==this.size&&t>this.size?e:this.find((function(e,r){return r===t}),void 0,e)},has:function(t){return(t=c(this,t))>=0&&(void 0!==this.size?this.size===1/0||te?-1:0}function en(t,e){return t^e+2654435769+(t<<6)+(t>>2)|0}Yr.has=Hr.includes,Yr.contains=Yr.includes,Yr.keys=Yr.values,Dr(F,Jr),Dr(G,Vr),Dr(Z,Yr);var rn=function(t){function e(t){return null==t?sn():jr(t)?t:sn().withMutations((function(e){var r=E(t);$t(r.size),r.forEach((function(t){return e.add(t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(I(t).keySeq())},e.prototype.toString=function(){return this.__toString("OrderedSet {","}")},e}(Ar);rn.isOrderedSet=jr;var nn,on=rn.prototype;function un(t,e){var r=Object.create(on);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function sn(){return nn||(nn=un(dr()))}on[A]=!0,on.zip=Vr.zip,on.zipWith=Vr.zipWith,on.zipAll=Vr.zipAll,on.__empty=sn,on.__make=un;var an=function(t,e){var r;!function(t){if(D(t))throw new Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(x(t))throw new Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(null===t||"object"!=typeof t)throw new Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}(t);var n=function(o){var u=this;if(o instanceof n)return o;if(!(this instanceof n))return new n(o);if(!r){r=!0;var s=Object.keys(t),a=i._indices={};i._name=e,i._keys=s,i._defaultValues=t;for(var c=0;c2?[]:void 0,{"":t})},t.get=ue,t.getIn=Cr,t.has=oe,t.hasIn=Wr,t.hash=vt,t.is=ht,t.isAssociative=S,t.isCollection=d,t.isImmutable=x,t.isIndexed=z,t.isKeyed=w,t.isList=er,t.isMap=at,t.isOrdered=k,t.isOrderedMap=ct,t.isOrderedSet=jr,t.isPlainObject=re,t.isRecord=D,t.isSeq=j,t.isSet=qr,t.isStack=mr,t.isValueObject=ft,t.merge=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return be(t,e)},t.mergeDeep=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Se(t,e)},t.mergeDeepWith=function(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];return Se(e,r,t)},t.mergeWith=function(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];return be(e,r,t)},t.remove=ae,t.removeIn=le,t.set=ce,t.setIn=pe,t.update=ye,t.updateIn=fe,t.version="5.0.0-rc.2"})); +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).Immutable={})}(this,(function(t){"use strict";var e="delete",r=5,n=1<>>0;if(""+r!==e||4294967295===r)return NaN;e=r}return e<0?a(t)+e:e}function f(){return!0}function h(t,e,r){return(0===t&&!v(t)||void 0!==r&&t<=-r)&&(void 0===e||void 0!==r&&e>=r)}function p(t,e){return l(t,e,0)}function _(t,e){return l(t,e,e)}function l(t,e,r){return void 0===t?r:v(t)?e===1/0?e:0|Math.max(0,e+t):void 0===e||e===t?t:0|Math.min(e,t)}function v(t){return t<0||0===t&&1/t==-1/0}var y="@@__IMMUTABLE_ITERABLE__@@";function d(t){return Boolean(t&&t[y])}var g="@@__IMMUTABLE_KEYED__@@";function w(t){return Boolean(t&&t[g])}var m="@@__IMMUTABLE_INDEXED__@@";function z(t){return Boolean(t&&t[m])}function S(t){return w(t)||z(t)}var b=function(t){return d(t)?t:X(t)},I=function(t){function e(t){return w(t)?t:F(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(b),O=function(t){function e(t){return z(t)?t:G(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(b),E=function(t){function e(t){return d(t)&&!S(t)?t:Z(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(b);b.Keyed=I,b.Indexed=O,b.Set=E;var q="@@__IMMUTABLE_SEQ__@@";function j(t){return Boolean(t&&t[q])}var M="@@__IMMUTABLE_RECORD__@@";function D(t){return Boolean(t&&t[M])}function x(t){return d(t)||D(t)}var A="@@__IMMUTABLE_ORDERED__@@";function k(t){return Boolean(t&&t[A])}var R=0,U=1,T=2,B="function"==typeof Symbol&&Symbol.iterator,K="@@iterator",L=B||K,C=function(t){this.next=t};function P(t,e,r,n){var i=0===t?e:1===t?r:[e,r];return n?n.value=i:n={value:i,done:!1},n}function W(){return{value:void 0,done:!0}}function N(t){return!!Array.isArray(t)||!!V(t)}function H(t){return t&&"function"==typeof t.next}function J(t){var e=V(t);return e&&e.call(t)}function V(t){var e=t&&(B&&t[B]||t[K]);if("function"==typeof e)return e}C.prototype.toString=function(){return"[Iterator]"},C.KEYS=R,C.VALUES=U,C.ENTRIES=T,C.prototype.inspect=C.prototype.toSource=function(){return this.toString()},C.prototype[L]=function(){return this};var Y=Object.prototype.hasOwnProperty;function Q(t){return!(!Array.isArray(t)&&"string"!=typeof t)||t&&"object"==typeof t&&Number.isInteger(t.length)&&t.length>=0&&(0===t.length?1===Object.keys(t).length:t.hasOwnProperty(t.length-1))}var X=function(t){function e(t){return null==t?nt():x(t)?t.toSeq():function(t){var e=ut(t);if(e)return(n=V(r=t))&&n===r.entries?e.fromEntrySeq():function(t){var e=V(t);return e&&e===t.keys}(t)?e.toSetSeq():e;var r,n;if("object"==typeof t)return new tt(t);throw new TypeError("Expected Array or collection object of values, or keyed object: "+t)}(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq {","}")},e.prototype.cacheResult=function(){return!this._cache&&this.__iterateUncached&&(this._cache=this.entrySeq().toArray(),this.size=this._cache.length),this},e.prototype.__iterate=function(t,e){var r=this._cache;if(r){for(var n=r.length,i=0;i!==n;){var o=r[e?n-++i:i++];if(!1===t(o[1],o[0],this))break}return i}return this.__iterateUncached(t,e)},e.prototype.__iterator=function(t,e){var r=this._cache;if(r){var n=r.length,i=0;return new C((function(){if(i===n)return{value:void 0,done:!0};var o=r[e?n-++i:i++];return P(t,o[0],o[1])}))}return this.__iteratorUncached(t,e)},e}(b),F=function(t){function e(t){return null==t?nt().toKeyedSeq():d(t)?w(t)?t.toSeq():t.fromEntrySeq():D(t)?t.toSeq():it(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toKeyedSeq=function(){return this},e}(X),G=function(t){function e(t){return null==t?nt():d(t)?w(t)?t.entrySeq():t.toIndexedSeq():D(t)?t.toSeq().entrySeq():ot(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return e(arguments)},e.prototype.toIndexedSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq [","]")},e}(X),Z=function(t){function e(t){return(d(t)&&!S(t)?t:G(t)).toSetSeq()}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return e(arguments)},e.prototype.toSetSeq=function(){return this},e}(X);X.isSeq=j,X.Keyed=F,X.Set=Z,X.Indexed=G,X.prototype[q]=!0;var $=function(t){function e(t){this._array=t,this.size=t.length}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t,e){return this.has(t)?this._array[c(this,t)]:e},e.prototype.__iterate=function(t,e){for(var r=this._array,n=r.length,i=0;i!==n;){var o=e?n-++i:i++;if(!1===t(r[o],o,this))break}return i},e.prototype.__iterator=function(t,e){var r=this._array,n=r.length,i=0;return new C((function(){if(i===n)return{value:void 0,done:!0};var o=e?n-++i:i++;return P(t,o,r[o])}))},e}(G),tt=function(t){function e(t){var e=Object.keys(t).concat(Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(t):[]);this._object=t,this._keys=e,this.size=e.length}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t,e){return void 0===e||this.has(t)?this._object[t]:e},e.prototype.has=function(t){return Y.call(this._object,t)},e.prototype.__iterate=function(t,e){for(var r=this._object,n=this._keys,i=n.length,o=0;o!==i;){var u=n[e?i-++o:o++];if(!1===t(r[u],u,this))break}return o},e.prototype.__iterator=function(t,e){var r=this._object,n=this._keys,i=n.length,o=0;return new C((function(){if(o===i)return{value:void 0,done:!0};var u=n[e?i-++o:o++];return P(t,u,r[u])}))},e}(F);tt.prototype[A]=!0;var et,rt=function(t){function e(t){this._collection=t,this.size=t.length||t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.__iterateUncached=function(t,e){if(e)return this.cacheResult().__iterate(t,e);var r=J(this._collection),n=0;if(H(r))for(var i;!(i=r.next()).done&&!1!==t(i.value,n++,this););return n},e.prototype.__iteratorUncached=function(t,e){if(e)return this.cacheResult().__iterator(t,e);var r=J(this._collection);if(!H(r))return new C(W);var n=0;return new C((function(){var e=r.next();return e.done?e:P(t,n++,e.value)}))},e}(G);function nt(){return et||(et=new $([]))}function it(t){var e=ut(t);if(e)return e.fromEntrySeq();if("object"==typeof t)return new tt(t);throw new TypeError("Expected Array or collection object of [k, v] entries, or keyed object: "+t)}function ot(t){var e=ut(t);if(e)return e;throw new TypeError("Expected Array or collection object of values: "+t)}function ut(t){return Q(t)?new $(t):N(t)?new rt(t):void 0}var st="@@__IMMUTABLE_MAP__@@";function at(t){return Boolean(t&&t[st])}function ct(t){return at(t)&&k(t)}function ft(t){return Boolean(t&&"function"==typeof t.equals&&"function"==typeof t.hashCode)}function ht(t,e){if(t===e||t!=t&&e!=e)return!0;if(!t||!e)return!1;if("function"==typeof t.valueOf&&"function"==typeof e.valueOf){if((t=t.valueOf())===(e=e.valueOf())||t!=t&&e!=e)return!0;if(!t||!e)return!1}return!!(ft(t)&&ft(e)&&t.equals(e))}var pt="function"==typeof Math.imul&&-2===Math.imul(4294967295,2)?Math.imul:function(t,e){var r=65535&(t|=0),n=65535&(e|=0);return r*n+((t>>>16)*n+r*(e>>>16)<<16>>>0)|0};function _t(t){return t>>>1&1073741824|3221225471&t}var lt=Object.prototype.valueOf;function vt(t){if(null==t)return yt(t);if("function"==typeof t.hashCode)return _t(t.hashCode(t));var e,r=(e=t).valueOf!==lt&&"function"==typeof e.valueOf?e.valueOf(e):e;if(null==r)return yt(r);switch(typeof r){case"boolean":return r?1108378657:1108378656;case"number":return function(t){if(t!=t||t===1/0)return 0;var e=0|t;e!==t&&(e^=4294967295*t);for(;t>4294967295;)e^=t/=4294967295;return _t(e)}(r);case"string":return r.length>Et?function(t){var e=Mt[t];void 0===e&&(e=dt(t),jt===qt&&(jt=0,Mt={}),jt++,Mt[t]=e);return e}(r):dt(r);case"object":case"function":return function(t){var e;if(St&&void 0!==(e=zt.get(t)))return e;if(e=t[Ot],void 0!==e)return e;if(!wt){if(void 0!==(e=t.propertyIsEnumerable&&t.propertyIsEnumerable[Ot]))return e;if(void 0!==(e=function(t){if(t&&t.nodeType>0)switch(t.nodeType){case 1:return t.uniqueID;case 9:return t.documentElement&&t.documentElement.uniqueID}}(t)))return e}if(e=mt(),St)zt.set(t,e);else{if(void 0!==gt&&!1===gt(t))throw new Error("Non-extensible objects are not allowed as keys.");if(wt)Object.defineProperty(t,Ot,{enumerable:!1,configurable:!1,writable:!1,value:e});else if(void 0!==t.propertyIsEnumerable&&t.propertyIsEnumerable===t.constructor.prototype.propertyIsEnumerable)t.propertyIsEnumerable=function(){return this.constructor.prototype.propertyIsEnumerable.apply(this,arguments)},t.propertyIsEnumerable[Ot]=e;else{if(void 0===t.nodeType)throw new Error("Unable to set a non-enumerable property on object.");t[Ot]=e}}return e}(r);case"symbol":return function(t){var e=bt[t];if(void 0!==e)return e;return e=mt(),bt[t]=e,e}(r);default:if("function"==typeof r.toString)return dt(r.toString());throw new Error("Value type "+typeof r+" cannot be hashed.")}}function yt(t){return null===t?1108378658:1108378659}function dt(t){for(var e=0,r=0;r=0&&(a.get=function(e,r){return(e=c(this,e))>=0&&eo)return{value:void 0,done:!0};var t=i.next();return n||e===U||t.done?t:P(e,a-1,e===R?void 0:t.value[1],t)}))},a}function Lt(t,e,r,n){var i=Qt(t);return i.__iterateUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterate(i,o);var s=!0,a=0;return t.__iterate((function(t,o,c){if(!s||!(s=e.call(r,t,o,c)))return a++,i(t,n?o:a-1,u)})),a},i.__iteratorUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterator(i,o);var s=t.__iterator(T,o),a=!0,c=0;return new C((function(){var t,o,f;do{if((t=s.next()).done)return n||i===U?t:P(i,c++,i===R?void 0:t.value[1],t);var h=t.value;o=h[0],f=h[1],a&&(a=e.call(r,f,o,u))}while(a);return i===T?t:P(i,o,f,t)}))},i}function Ct(t,e,r){var n=Qt(t);return n.__iterateUncached=function(i,o){if(o)return this.cacheResult().__iterate(i,o);var u=0,s=!1;return function t(a,c){a.__iterate((function(o,a){return(!e||c0}function Ht(t,e,r,n){var i=Qt(t),o=new $(r).map((function(t){return t.size}));return i.size=n?o.max():o.min(),i.__iterate=function(t,e){for(var r,n=this.__iterator(U,e),i=0;!(r=n.next()).done&&!1!==t(r.value,i++,this););return i},i.__iteratorUncached=function(t,i){var o=r.map((function(t){return t=b(t),J(i?t.reverse():t)})),u=0,s=!1;return new C((function(){var r;return s||(r=o.map((function(t){return t.next()})),s=n?r.every((function(t){return t.done})):r.some((function(t){return t.done}))),s?{value:void 0,done:!0}:P(t,u++,e.apply(null,r.map((function(t){return t.value}))))}))},i}function Jt(t,e){return t===e?t:j(t)?e:t.constructor(e)}function Vt(t){if(t!==Object(t))throw new TypeError("Expected [K, V] tuple: "+t)}function Yt(t){return w(t)?I:z(t)?O:E}function Qt(t){return Object.create((w(t)?F:z(t)?G:Z).prototype)}function Xt(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size,this):X.prototype.cacheResult.call(this)}function Ft(t,e){return void 0===t&&void 0===e?0:void 0===t?1:void 0===e?-1:t>e?1:t0;)e[r]=arguments[r+1];if("function"!=typeof t)throw new TypeError("Invalid merger function: "+t);return ze(this,e,t)}function ze(t,e,r){for(var n=[],i=0;i0;)e[r]=arguments[r+1];return Se(this,e,t)}function Ee(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return fe(this,t,He(),(function(t){return be(t,e)}))}function qe(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return fe(this,t,He(),(function(t){return Se(t,e)}))}function je(t){var e=this.asMutable();return t(e),e.wasAltered()?e.__ensureOwner(this.__ownerID):this}function Me(){return this.__ownerID?this:this.__ensureOwner(new s)}function De(){return this.__ensureOwner()}function xe(){return this.__altered}var Ae=function(t){function e(e){return null==e?He():at(e)&&!k(e)?e:He().withMutations((function(r){var n=t(e);$t(n.size),n.forEach((function(t,e){return r.set(e,t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toString=function(){return this.__toString("Map {","}")},e.prototype.get=function(t,e){return this._root?this._root.get(0,void 0,t,e):e},e.prototype.set=function(t,e){return Je(this,t,e)},e.prototype.remove=function(t){return Je(this,t,o)},e.prototype.deleteAll=function(t){var e=b(t);return 0===e.size?this:this.withMutations((function(t){e.forEach((function(e){return t.remove(e)}))}))},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):He()},e.prototype.sort=function(t){return vr(Pt(this,t))},e.prototype.sortBy=function(t,e){return vr(Pt(this,e,t))},e.prototype.map=function(t,e){var r=this;return this.withMutations((function(n){n.forEach((function(i,o){n.set(o,t.call(e,i,o,r))}))}))},e.prototype.__iterator=function(t,e){return new Ce(this,t,e)},e.prototype.__iterate=function(t,e){var r=this,n=0;return this._root&&this._root.iterate((function(e){return n++,t(e[1],e[0],r)}),e),n},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Ne(this.size,this._root,t,this.__hash):0===this.size?He():(this.__ownerID=t,this.__altered=!1,this)},e}(I);Ae.isMap=at;var ke=Ae.prototype;ke[st]=!0,ke[e]=ke.remove,ke.removeAll=ke.deleteAll,ke.setIn=_e,ke.removeIn=ke.deleteIn=ve,ke.update=de,ke.updateIn=ge,ke.merge=ke.concat=we,ke.mergeWith=me,ke.mergeDeep=Ie,ke.mergeDeepWith=Oe,ke.mergeIn=Ee,ke.mergeDeepIn=qe,ke.withMutations=je,ke.wasAltered=xe,ke.asImmutable=De,ke["@@transducer/init"]=ke.asMutable=Me,ke["@@transducer/step"]=function(t,e){return t.set(e[0],e[1])},ke["@@transducer/result"]=function(t){return t.asImmutable()};var Re=function(t,e){this.ownerID=t,this.entries=e};Re.prototype.get=function(t,e,r,n){for(var i=this.entries,o=0,u=i.length;o=Ge)return function(t,e,r,n){t||(t=new s);for(var i=new Ke(t,vt(r),[r,n]),o=0;o>>t)&i),s=this.bitmap;return 0==(s&u)?o:this.nodes[Xe(s&u-1)].get(t+r,e,n,o)},Ue.prototype.update=function(t,e,u,s,a,c,f){void 0===u&&(u=vt(s));var h=(0===e?u:u>>>e)&i,p=1<=Ze)return function(t,e,r,i,o){for(var u=0,s=new Array(n),a=0;0!==r;a++,r>>>=1)s[a]=1&r?e[u++]:void 0;return s[i]=o,new Te(t,u+1,s)}(t,y,_,h,g);if(l&&!g&&2===y.length&&Ye(y[1^v]))return y[1^v];if(l&&g&&1===y.length&&Ye(g))return g;var w=t&&t===this.ownerID,m=l?g?_:_^p:_|p,z=l?g?Fe(y,v,g,w):function(t,e,r){var n=t.length-1;if(r&&e===n)return t.pop(),t;for(var i=new Array(n),o=0,u=0;u>>t)&i,s=this.nodes[u];return s?s.get(t+r,e,n,o):o},Te.prototype.update=function(t,e,n,u,s,a,c){void 0===n&&(n=vt(u));var f=(0===e?n:n>>>e)&i,h=s===o,p=this.nodes,_=p[f];if(h&&!_)return this;var l=Ve(_,t,e+r,n,u,s,a,c);if(l===_)return this;var v=this.count;if(_){if(!l&&--v<$e)return function(t,e,r,n){for(var i=0,o=0,u=new Array(r),s=0,a=1,c=e.length;s>>n)&i,c=(0===n?o:o>>>n)&i,f=a===c?[Qe(t,e,n+r,o,u)]:(s=new Ke(e,o,u),a>1&1431655765))+(t>>2&858993459))+(t>>4)&252645135,t+=t>>8,127&(t+=t>>16)}function Fe(t,e,r,n){var i=n?t:Gt(t);return i[e]=r,i}var Ge=n/4,Ze=n/2,$e=n/4,tr="@@__IMMUTABLE_LIST__@@";function er(t){return Boolean(t&&t[tr])}var rr=function(t){function e(e){var i=ar();if(null==e)return i;if(er(e))return e;var o=t(e),u=o.size;return 0===u?i:($t(u),u>0&&u=0&&t=t.size||e<0)return t.withMutations((function(t){e<0?pr(t,e).set(0,r):pr(t,0,e+1).set(e,r)}));e+=t._origin;var n=t._tail,i=t._root,o={value:!1};e>=_r(t._capacity)?n=cr(n,t.__ownerID,0,e,r,o):i=cr(i,t.__ownerID,t._level,e,r,o);if(!o.value)return t;if(t.__ownerID)return t._root=i,t._tail=n,t.__hash=void 0,t.__altered=!0,t;return sr(t._origin,t._capacity,t._level,i,n)}(this,t,e)},e.prototype.remove=function(t){return this.has(t)?0===t?this.shift():t===this.size-1?this.pop():this.splice(t,1):this},e.prototype.insert=function(t,e){return this.splice(t,0,e)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=this._origin=this._capacity=0,this._level=r,this._root=this._tail=this.__hash=void 0,this.__altered=!0,this):ar()},e.prototype.push=function(){var t=arguments,e=this.size;return this.withMutations((function(r){pr(r,0,e+t.length);for(var n=0;n>>e&i;if(o>=this.array.length)return new ir([],t);var u,s=0===o;if(e>0){var a=this.array[o];if((u=a&&a.removeBefore(t,e-r,n))===a&&s)return this}if(s&&!u)return this;var c=fr(this,t);if(!s)for(var f=0;f>>e&i;if(u>=this.array.length)return this;if(e>0){var s=this.array[u];if((o=s&&s.removeAfter(t,e-r,n))===s&&u===this.array.length-1)return this}var a=fr(this,t);return a.array.splice(u+1),o&&(a.array[u]=o),a};var or={};function ur(t,e){var i=t._origin,o=t._capacity,u=_r(o),s=t._tail;return a(t._root,t._level,0);function a(t,c,f){return 0===c?function(t,r){var a=r===u?s&&s.array:t&&t.array,c=r>i?0:i-r,f=o-r;f>n&&(f=n);return function(){if(c===f)return or;var t=e?--f:c++;return a&&a[t]}}(t,f):function(t,u,s){var c,f=t&&t.array,h=s>i?0:i-s>>u,p=1+(o-s>>u);p>n&&(p=n);return function(){for(;;){if(c){var t=c();if(t!==or)return t;c=null}if(h===p)return or;var n=e?--p:h++;c=a(f&&f[n],u-r,s+(n<>>n&i,h=t&&f0){var p=t&&t.array[f],_=cr(p,e,n-r,o,s,a);return _===p?t:((c=fr(t,e)).array[f]=_,c)}return h&&t.array[f]===s?t:(a&&u(a),c=fr(t,e),void 0===s&&f===c.array.length-1?c.array.pop():c.array[f]=s,c)}function fr(t,e){return e&&t&&e===t.ownerID?t:new ir(t?t.array.slice():[],e)}function hr(t,e){if(e>=_r(t._capacity))return t._tail;if(e<1<0;)n=n.array[e>>>o&i],o-=r;return n}}function pr(t,e,n){void 0!==e&&(e|=0),void 0!==n&&(n|=0);var o=t.__ownerID||new s,u=t._origin,a=t._capacity,c=u+e,f=void 0===n?a:n<0?a+n:u+n;if(c===u&&f===a)return t;if(c>=f)return t.clear();for(var h=t._level,p=t._root,_=0;c+_<0;)p=new ir(p&&p.array.length?[void 0,p]:[],o),_+=1<<(h+=r);_&&(c+=_,u+=_,f+=_,a+=_);for(var l=_r(a),v=_r(f);v>=1<l?new ir([],o):y;if(y&&v>l&&cr;w-=r){var m=l>>>w&i;g=g.array[m]=fr(g.array[m],o)}g.array[l>>>r&i]=y}if(f=v)c-=v,f-=v,h=r,p=null,d=d&&d.removeBefore(o,0,c);else if(c>u||v>>h&i;if(z!==v>>>h&i)break;z&&(_+=(1<u&&(p=p.removeBefore(o,h,c-_)),p&&v>>r<=n&&a.size>=2*s.size?(i=(u=a.filter((function(t,e){return void 0!==t&&c!==e}))).toKeyedSeq().map((function(t){return t[0]})).flip().toMap(),t.__ownerID&&(i.__ownerID=u.__ownerID=t.__ownerID)):(i=s.remove(e),u=c===a.size-1?a.pop():a.set(c,void 0))}else if(f){if(r===a.get(c)[1])return t;i=s,u=a.set(c,[e,r])}else i=s.set(e,a.size),u=a.set(a.size,[e,r]);return t.__ownerID?(t.size=i.size,t._map=i,t._list=u,t.__hash=void 0,t.__altered=!0,t):yr(i,u)}vr.isOrderedMap=ct,vr.prototype[A]=!0,vr.prototype[e]=vr.prototype.remove;var wr="@@__IMMUTABLE_STACK__@@";function mr(t){return Boolean(t&&t[wr])}var zr=function(t){function e(t){return null==t?Or():mr(t)?t:Or().pushAll(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("Stack [","]")},e.prototype.get=function(t,e){var r=this._head;for(t=c(this,t);r&&t--;)r=r.next;return r?r.value:e},e.prototype.peek=function(){return this._head&&this._head.value},e.prototype.push=function(){var t=arguments;if(0===arguments.length)return this;for(var e=this.size+arguments.length,r=this._head,n=arguments.length-1;n>=0;n--)r={value:t[n],next:r};return this.__ownerID?(this.size=e,this._head=r,this.__hash=void 0,this.__altered=!0,this):Ir(e,r)},e.prototype.pushAll=function(e){if(0===(e=t(e)).size)return this;if(0===this.size&&mr(e))return e;$t(e.size);var r=this.size,n=this._head;return e.__iterate((function(t){r++,n={value:t,next:n}}),!0),this.__ownerID?(this.size=r,this._head=n,this.__hash=void 0,this.__altered=!0,this):Ir(r,n)},e.prototype.pop=function(){return this.slice(1)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):Or()},e.prototype.slice=function(e,r){if(h(e,r,this.size))return this;var n=p(e,this.size);if(_(r,this.size)!==this.size)return t.prototype.slice.call(this,e,r);for(var i=this.size-n,o=this._head;n--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):Ir(i,o)},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Ir(this.size,this._head,t,this.__hash):0===this.size?Or():(this.__ownerID=t,this.__altered=!1,this)},e.prototype.__iterate=function(t,e){var r=this;if(e)return new $(this.toArray()).__iterate((function(e,n){return t(e,n,r)}),e);for(var n=0,i=this._head;i&&!1!==t(i.value,n++,this);)i=i.next;return n},e.prototype.__iterator=function(t,e){if(e)return new $(this.toArray()).__iterator(t,e);var r=0,n=this._head;return new C((function(){if(n){var e=n.value;return n=n.next,P(t,r++,e)}return{value:void 0,done:!0}}))},e}(O);zr.isStack=mr;var Sr,br=zr.prototype;function Ir(t,e,r,n){var i=Object.create(br);return i.size=t,i._head=e,i.__ownerID=r,i.__hash=n,i.__altered=!1,i}function Or(){return Sr||(Sr=Ir(0))}br[wr]=!0,br.shift=br.pop,br.unshift=br.push,br.unshiftAll=br.pushAll,br.withMutations=je,br.wasAltered=xe,br.asImmutable=De,br["@@transducer/init"]=br.asMutable=Me,br["@@transducer/step"]=function(t,e){return t.unshift(e)},br["@@transducer/result"]=function(t){return t.asImmutable()};var Er="@@__IMMUTABLE_SET__@@";function qr(t){return Boolean(t&&t[Er])}function jr(t){return qr(t)&&k(t)}function Mr(t,e){if(t===e)return!0;if(!d(e)||void 0!==t.size&&void 0!==e.size&&t.size!==e.size||void 0!==t.__hash&&void 0!==e.__hash&&t.__hash!==e.__hash||w(t)!==w(e)||z(t)!==z(e)||k(t)!==k(e))return!1;if(0===t.size&&0===e.size)return!0;var r=!S(t);if(k(t)){var n=t.entries();return e.every((function(t,e){var i=n.next().value;return i&&ht(i[1],t)&&(r||ht(i[0],e))}))&&n.next().done}var i=!1;if(void 0===t.size)if(void 0===e.size)"function"==typeof t.cacheResult&&t.cacheResult();else{i=!0;var u=t;t=e,e=u}var s=!0,a=e.__iterate((function(e,n){if(r?!t.has(e):i?!ht(e,t.get(n,o)):!ht(t.get(n,o),e))return s=!1,!1}));return s&&t.size===a}function Dr(t,e){var r=function(r){t.prototype[r]=e[r]};return Object.keys(e).forEach(r),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(e).forEach(r),t}function xr(t){if(!t||"object"!=typeof t)return t;if(!d(t)){if(!ne(t))return t;t=X(t)}if(w(t)){var e={};return t.__iterate((function(t,r){e[r]=xr(t)})),e}var r=[];return t.__iterate((function(t){r.push(xr(t))})),r}var Ar=function(t){function e(e){return null==e?Br():qr(e)&&!k(e)?e:Br().withMutations((function(r){var n=t(e);$t(n.size),n.forEach((function(t){return r.add(t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(I(t).keySeq())},e.intersect=function(t){return(t=b(t).toArray()).length?Rr.intersect.apply(e(t.pop()),t):Br()},e.union=function(t){return(t=b(t).toArray()).length?Rr.union.apply(e(t.pop()),t):Br()},e.prototype.toString=function(){return this.__toString("Set {","}")},e.prototype.has=function(t){return this._map.has(t)},e.prototype.add=function(t){return Ur(this,this._map.set(t,t))},e.prototype.remove=function(t){return Ur(this,this._map.remove(t))},e.prototype.clear=function(){return Ur(this,this._map.clear())},e.prototype.map=function(t,e){var r=this,n=!1,i=Ur(this,this._map.mapEntries((function(i){var o=i[1],u=t.call(e,o,o,r);return u!==o&&(n=!0),[u,u]}),e));return n?i:this},e.prototype.union=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return 0===(e=e.filter((function(t){return 0!==t.size}))).length?this:0!==this.size||this.__ownerID||1!==e.length?this.withMutations((function(r){for(var n=0;n=0&&e=0&&r>>-15,461845907),e=pt(e<<13|e>>>-13,5),e=pt((e=(e+3864292196|0)^t)^e>>>16,2246822507),e=_t((e=pt(e^e>>>13,3266489909))^e>>>16)}(t.size,n)}(this))}});var Hr=b.prototype;Hr[y]=!0,Hr[L]=Hr.values,Hr.toJSON=Hr.toArray,Hr.__toStringMapper=ie,Hr.inspect=Hr.toSource=function(){return this.toString()},Hr.chain=Hr.flatMap,Hr.contains=Hr.includes,Dr(I,{flip:function(){return Jt(this,Rt(this))},mapEntries:function(t,e){var r=this,n=0;return Jt(this,this.toSeq().map((function(i,o){return t.call(e,[o,i],n++,r)})).fromEntrySeq())},mapKeys:function(t,e){var r=this;return Jt(this,this.toSeq().flip().map((function(n,i){return t.call(e,n,i,r)})).flip())}});var Jr=I.prototype;Jr[g]=!0,Jr[L]=Hr.entries,Jr.toJSON=Nr,Jr.__toStringMapper=function(t,e){return ie(e)+": "+ie(t)},Dr(O,{toKeyedSeq:function(){return new Dt(this,!1)},filter:function(t,e){return Jt(this,Bt(this,t,e,!1))},findIndex:function(t,e){var r=this.findEntry(t,e);return r?r[0]:-1},indexOf:function(t){var e=this.keyOf(t);return void 0===e?-1:e},lastIndexOf:function(t){var e=this.lastKeyOf(t);return void 0===e?-1:e},reverse:function(){return Jt(this,Tt(this,!1))},slice:function(t,e){return Jt(this,Kt(this,t,e,!1))},splice:function(t,e){var r=arguments.length;if(e=Math.max(e||0,0),0===r||2===r&&!e)return this;t=p(t,t<0?this.count():this.size);var n=this.slice(0,t);return Jt(this,1===r?n:n.concat(Gt(arguments,2),this.slice(t+e)))},findLastIndex:function(t,e){var r=this.findLastEntry(t,e);return r?r[0]:-1},first:function(t){return this.get(0,t)},flatten:function(t){return Jt(this,Ct(this,t,!1))},get:function(t,e){return(t=c(this,t))<0||this.size===1/0||void 0!==this.size&&t>this.size?e:this.find((function(e,r){return r===t}),void 0,e)},has:function(t){return(t=c(this,t))>=0&&(void 0!==this.size?this.size===1/0||te?-1:0}function en(t,e){return t^e+2654435769+(t<<6)+(t>>2)|0}Yr.has=Hr.includes,Yr.contains=Yr.includes,Yr.keys=Yr.values,Dr(F,Jr),Dr(G,Vr),Dr(Z,Yr);var rn=function(t){function e(t){return null==t?sn():jr(t)?t:sn().withMutations((function(e){var r=E(t);$t(r.size),r.forEach((function(t){return e.add(t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(I(t).keySeq())},e.prototype.toString=function(){return this.__toString("OrderedSet {","}")},e}(Ar);rn.isOrderedSet=jr;var nn,on=rn.prototype;function un(t,e){var r=Object.create(on);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function sn(){return nn||(nn=un(dr()))}on[A]=!0,on.zip=Vr.zip,on.zipWith=Vr.zipWith,on.zipAll=Vr.zipAll,on.__empty=sn,on.__make=un;var an=function(t,e){var r;!function(t){if(D(t))throw new Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(x(t))throw new Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(null===t||"object"!=typeof t)throw new Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}(t);var n=function(o){var u=this;if(o instanceof n)return o;if(!(this instanceof n))return new n(o);if(!r){r=!0;var s=Object.keys(t),a=i._indices={};i._name=e,i._keys=s,i._defaultValues=t;for(var c=0;c2?[]:void 0,{"":t})},t.get=ue,t.getIn=Cr,t.has=oe,t.hasIn=Wr,t.hash=vt,t.is=ht,t.isAssociative=S,t.isCollection=d,t.isImmutable=x,t.isIndexed=z,t.isKeyed=w,t.isList=er,t.isMap=at,t.isOrdered=k,t.isOrderedMap=ct,t.isOrderedSet=jr,t.isPlainObject=re,t.isRecord=D,t.isSeq=j,t.isSet=qr,t.isStack=mr,t.isValueObject=ft,t.merge=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return be(t,e)},t.mergeDeep=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Se(t,e)},t.mergeDeepWith=function(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];return Se(e,r,t)},t.mergeWith=function(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];return be(e,r,t)},t.remove=ae,t.removeIn=le,t.set=ce,t.setIn=pe,t.update=ye,t.updateIn=fe,t.version="5.0.0"})); diff --git a/package.json b/package.json index 02f475aebd..d96362aa14 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "immutable", - "version": "5.0.0-rc.2", + "version": "5.0.0", "description": "Immutable Data Collections", "license": "MIT", "homepage": "https://immutable-js.com", From b0a2c1276332aba162797bdde28ed3c2fe74abd4 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 8 Nov 2024 00:16:58 +0000 Subject: [PATCH 217/242] deploy: 879f42893cebbad6fcf4fad5425c408ac08a57b5 --- bower.json | 4 +- dist/es/Collection.js | 79 - dist/es/CollectionImpl.js | 776 ---- dist/es/Hash.js | 260 -- dist/es/Immutable.js | 73 - dist/es/Iterator.js | 106 - dist/es/List.js | 696 ---- dist/es/Map.js | 820 ---- dist/es/Math.js | 45 - dist/es/Operations.js | 953 ----- dist/es/OrderedMap.js | 196 - dist/es/OrderedSet.js | 92 - dist/es/PairSorting.js | 30 - dist/es/Range.js | 178 - dist/es/Record.js | 292 -- dist/es/Repeat.js | 133 - dist/es/Seq.js | 401 -- dist/es/Set.js | 279 -- dist/es/Stack.js | 261 -- dist/es/TrieUtils.js | 117 - dist/es/fromJS.js | 74 - dist/es/functional/get.js | 38 - dist/es/functional/getIn.js | 41 - dist/es/functional/has.js | 35 - dist/es/functional/hasIn.js | 32 - dist/es/functional/merge.js | 137 - dist/es/functional/remove.js | 56 - dist/es/functional/removeIn.js | 32 - dist/es/functional/set.js | 52 - dist/es/functional/setIn.js | 32 - dist/es/functional/update.js | 31 - dist/es/functional/updateIn.js | 94 - dist/es/is.js | 108 - dist/es/methods/asImmutable.js | 29 - dist/es/methods/asMutable.js | 31 - dist/es/methods/deleteIn.js | 31 - dist/es/methods/getIn.js | 31 - dist/es/methods/hasIn.js | 31 - dist/es/methods/merge.js | 79 - dist/es/methods/mergeDeep.js | 41 - dist/es/methods/mergeDeepIn.js | 37 - dist/es/methods/mergeIn.js | 36 - dist/es/methods/setIn.js | 31 - dist/es/methods/toObject.js | 36 - dist/es/methods/update.js | 33 - dist/es/methods/updateIn.js | 31 - dist/es/methods/wasAltered.js | 29 - dist/es/methods/withMutations.js | 31 - dist/es/package.json.js | 27 - dist/es/predicates/isAssociative.js | 32 - dist/es/predicates/isCollection.js | 32 - dist/es/predicates/isImmutable.js | 32 - dist/es/predicates/isIndexed.js | 31 - dist/es/predicates/isKeyed.js | 31 - dist/es/predicates/isList.js | 31 - dist/es/predicates/isMap.js | 31 - dist/es/predicates/isOrdered.js | 31 - dist/es/predicates/isOrderedMap.js | 32 - dist/es/predicates/isOrderedSet.js | 32 - dist/es/predicates/isRecord.js | 31 - dist/es/predicates/isSeq.js | 31 - dist/es/predicates/isSet.js | 31 - dist/es/predicates/isStack.js | 31 - dist/es/predicates/isValueObject.js | 33 - dist/es/toJS.js | 54 - dist/es/utils/arrCopy.js | 36 - dist/es/utils/assertNotInfinite.js | 34 - dist/es/utils/coerceKeyPath.js | 40 - dist/es/utils/deepEqual.js | 99 - dist/es/utils/hasOwnProperty.js | 27 - dist/es/utils/invariant.js | 29 - dist/es/utils/isArrayLike.js | 44 - dist/es/utils/isDataStructure.js | 39 - dist/es/utils/isPlainObj.js | 52 - dist/es/utils/mixin.js | 38 - dist/es/utils/quoteString.js | 36 - dist/es/utils/shallowCopy.js | 41 - dist/immutable.es.js | 5930 +++++++++++++++++++++++++++ dist/immutable.js | 2 +- dist/immutable.min.js | 2 +- package.json | 4 +- 81 files changed, 5936 insertions(+), 8160 deletions(-) delete mode 100644 dist/es/Collection.js delete mode 100644 dist/es/CollectionImpl.js delete mode 100644 dist/es/Hash.js delete mode 100644 dist/es/Immutable.js delete mode 100644 dist/es/Iterator.js delete mode 100644 dist/es/List.js delete mode 100644 dist/es/Map.js delete mode 100644 dist/es/Math.js delete mode 100644 dist/es/Operations.js delete mode 100644 dist/es/OrderedMap.js delete mode 100644 dist/es/OrderedSet.js delete mode 100644 dist/es/PairSorting.js delete mode 100644 dist/es/Range.js delete mode 100644 dist/es/Record.js delete mode 100644 dist/es/Repeat.js delete mode 100644 dist/es/Seq.js delete mode 100644 dist/es/Set.js delete mode 100644 dist/es/Stack.js delete mode 100644 dist/es/TrieUtils.js delete mode 100644 dist/es/fromJS.js delete mode 100644 dist/es/functional/get.js delete mode 100644 dist/es/functional/getIn.js delete mode 100644 dist/es/functional/has.js delete mode 100644 dist/es/functional/hasIn.js delete mode 100644 dist/es/functional/merge.js delete mode 100644 dist/es/functional/remove.js delete mode 100644 dist/es/functional/removeIn.js delete mode 100644 dist/es/functional/set.js delete mode 100644 dist/es/functional/setIn.js delete mode 100644 dist/es/functional/update.js delete mode 100644 dist/es/functional/updateIn.js delete mode 100644 dist/es/is.js delete mode 100644 dist/es/methods/asImmutable.js delete mode 100644 dist/es/methods/asMutable.js delete mode 100644 dist/es/methods/deleteIn.js delete mode 100644 dist/es/methods/getIn.js delete mode 100644 dist/es/methods/hasIn.js delete mode 100644 dist/es/methods/merge.js delete mode 100644 dist/es/methods/mergeDeep.js delete mode 100644 dist/es/methods/mergeDeepIn.js delete mode 100644 dist/es/methods/mergeIn.js delete mode 100644 dist/es/methods/setIn.js delete mode 100644 dist/es/methods/toObject.js delete mode 100644 dist/es/methods/update.js delete mode 100644 dist/es/methods/updateIn.js delete mode 100644 dist/es/methods/wasAltered.js delete mode 100644 dist/es/methods/withMutations.js delete mode 100644 dist/es/package.json.js delete mode 100644 dist/es/predicates/isAssociative.js delete mode 100644 dist/es/predicates/isCollection.js delete mode 100644 dist/es/predicates/isImmutable.js delete mode 100644 dist/es/predicates/isIndexed.js delete mode 100644 dist/es/predicates/isKeyed.js delete mode 100644 dist/es/predicates/isList.js delete mode 100644 dist/es/predicates/isMap.js delete mode 100644 dist/es/predicates/isOrdered.js delete mode 100644 dist/es/predicates/isOrderedMap.js delete mode 100644 dist/es/predicates/isOrderedSet.js delete mode 100644 dist/es/predicates/isRecord.js delete mode 100644 dist/es/predicates/isSeq.js delete mode 100644 dist/es/predicates/isSet.js delete mode 100644 dist/es/predicates/isStack.js delete mode 100644 dist/es/predicates/isValueObject.js delete mode 100644 dist/es/toJS.js delete mode 100644 dist/es/utils/arrCopy.js delete mode 100644 dist/es/utils/assertNotInfinite.js delete mode 100644 dist/es/utils/coerceKeyPath.js delete mode 100644 dist/es/utils/deepEqual.js delete mode 100644 dist/es/utils/hasOwnProperty.js delete mode 100644 dist/es/utils/invariant.js delete mode 100644 dist/es/utils/isArrayLike.js delete mode 100644 dist/es/utils/isDataStructure.js delete mode 100644 dist/es/utils/isPlainObj.js delete mode 100644 dist/es/utils/mixin.js delete mode 100644 dist/es/utils/quoteString.js delete mode 100644 dist/es/utils/shallowCopy.js create mode 100644 dist/immutable.es.js diff --git a/bower.json b/bower.json index d96362aa14..2976df5118 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "immutable", - "version": "5.0.0", + "version": "5.0.2", "description": "Immutable Data Collections", "license": "MIT", "homepage": "https://immutable-js.com", @@ -16,7 +16,7 @@ "url": "https://github.com/immutable-js/immutable-js/issues" }, "main": "dist/immutable.js", - "module": "dist/es/Immutable.js", + "module": "dist/immutable.es.js", "types": "dist/immutable.d.ts", "files": [ "dist", diff --git a/dist/es/Collection.js b/dist/es/Collection.js deleted file mode 100644 index 0b6f921efc..0000000000 --- a/dist/es/Collection.js +++ /dev/null @@ -1,79 +0,0 @@ -/** - * @license - * MIT License - * - * Copyright (c) 2014-present, Lee Byron and other contributors. - * - * 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: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -import { Seq, KeyedSeq, IndexedSeq, SetSeq } from './Seq.js'; -import { isCollection } from './predicates/isCollection.js'; -import { isKeyed } from './predicates/isKeyed.js'; -import { isIndexed } from './predicates/isIndexed.js'; -import { isAssociative } from './predicates/isAssociative.js'; - -var Collection = function Collection(value) { - // eslint-disable-next-line no-constructor-return - return isCollection(value) ? value : Seq(value); -}; - -var KeyedCollection = /*@__PURE__*/(function (Collection) { - function KeyedCollection(value) { - // eslint-disable-next-line no-constructor-return - return isKeyed(value) ? value : KeyedSeq(value); - } - - if ( Collection ) KeyedCollection.__proto__ = Collection; - KeyedCollection.prototype = Object.create( Collection && Collection.prototype ); - KeyedCollection.prototype.constructor = KeyedCollection; - - return KeyedCollection; -}(Collection)); - -var IndexedCollection = /*@__PURE__*/(function (Collection) { - function IndexedCollection(value) { - // eslint-disable-next-line no-constructor-return - return isIndexed(value) ? value : IndexedSeq(value); - } - - if ( Collection ) IndexedCollection.__proto__ = Collection; - IndexedCollection.prototype = Object.create( Collection && Collection.prototype ); - IndexedCollection.prototype.constructor = IndexedCollection; - - return IndexedCollection; -}(Collection)); - -var SetCollection = /*@__PURE__*/(function (Collection) { - function SetCollection(value) { - // eslint-disable-next-line no-constructor-return - return isCollection(value) && !isAssociative(value) ? value : SetSeq(value); - } - - if ( Collection ) SetCollection.__proto__ = Collection; - SetCollection.prototype = Object.create( Collection && Collection.prototype ); - SetCollection.prototype.constructor = SetCollection; - - return SetCollection; -}(Collection)); - -Collection.Keyed = KeyedCollection; -Collection.Indexed = IndexedCollection; -Collection.Set = SetCollection; - -export { Collection, IndexedCollection, KeyedCollection, SetCollection }; diff --git a/dist/es/CollectionImpl.js b/dist/es/CollectionImpl.js deleted file mode 100644 index 2040320a58..0000000000 --- a/dist/es/CollectionImpl.js +++ /dev/null @@ -1,776 +0,0 @@ -/** - * @license - * MIT License - * - * Copyright (c) 2014-present, Lee Byron and other contributors. - * - * 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: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -import { Collection, KeyedCollection, IndexedCollection, SetCollection } from './Collection.js'; -import { IS_COLLECTION_SYMBOL } from './predicates/isCollection.js'; -import { isKeyed, IS_KEYED_SYMBOL } from './predicates/isKeyed.js'; -import { isIndexed, IS_INDEXED_SYMBOL } from './predicates/isIndexed.js'; -import { IS_ORDERED_SYMBOL, isOrdered } from './predicates/isOrdered.js'; -import { is } from './is.js'; -import { ensureSize, returnTrue, NOT_SET, resolveBegin, wrapIndex } from './TrieUtils.js'; -import { hash } from './Hash.js'; -import { imul, smi } from './Math.js'; -import { ITERATE_ENTRIES, ITERATE_KEYS, ITERATE_VALUES, ITERATOR_SYMBOL, Iterator } from './Iterator.js'; -import arrCopy from './utils/arrCopy.js'; -import assertNotInfinite from './utils/assertNotInfinite.js'; -import deepEqual from './utils/deepEqual.js'; -import mixin from './utils/mixin.js'; -import quoteString from './utils/quoteString.js'; -import { toJS } from './toJS.js'; -import { Map } from './Map.js'; -import { OrderedMap } from './OrderedMap.js'; -import { List } from './List.js'; -import { Set } from './Set.js'; -import { OrderedSet } from './OrderedSet.js'; -import { Stack } from './Stack.js'; -import { Range } from './Range.js'; -import { ArraySeq, IndexedSeq, KeyedSeq, SetSeq } from './Seq.js'; -import { ToIndexedSequence, ToKeyedSequence, ToSetSequence, reify, concatFactory, filterFactory, partitionFactory, mapFactory, reverseFactory, sliceFactory, sortFactory, countByFactory, flatMapFactory, flattenFactory, FromEntriesSequence, groupByFactory, maxFactory, skipWhileFactory, takeWhileFactory, flipFactory, interposeFactory, zipWithFactory } from './Operations.js'; -import { getIn } from './methods/getIn.js'; -import { hasIn } from './methods/hasIn.js'; -import { toObject } from './methods/toObject.js'; - -Collection.Iterator = Iterator; - -mixin(Collection, { - // ### Conversion to other types - - toArray: function toArray() { - assertNotInfinite(this.size); - var array = new Array(this.size || 0); - var useTuples = isKeyed(this); - var i = 0; - this.__iterate(function (v, k) { - // Keyed collections produce an array of tuples. - array[i++] = useTuples ? [k, v] : v; - }); - return array; - }, - - toIndexedSeq: function toIndexedSeq() { - return new ToIndexedSequence(this); - }, - - toJS: function toJS$1() { - return toJS(this); - }, - - toKeyedSeq: function toKeyedSeq() { - return new ToKeyedSequence(this, true); - }, - - toMap: function toMap() { - // Use Late Binding here to solve the circular dependency. - return Map(this.toKeyedSeq()); - }, - - toObject: toObject, - - toOrderedMap: function toOrderedMap() { - // Use Late Binding here to solve the circular dependency. - return OrderedMap(this.toKeyedSeq()); - }, - - toOrderedSet: function toOrderedSet() { - // Use Late Binding here to solve the circular dependency. - return OrderedSet(isKeyed(this) ? this.valueSeq() : this); - }, - - toSet: function toSet() { - // Use Late Binding here to solve the circular dependency. - return Set(isKeyed(this) ? this.valueSeq() : this); - }, - - toSetSeq: function toSetSeq() { - return new ToSetSequence(this); - }, - - toSeq: function toSeq() { - return isIndexed(this) - ? this.toIndexedSeq() - : isKeyed(this) - ? this.toKeyedSeq() - : this.toSetSeq(); - }, - - toStack: function toStack() { - // Use Late Binding here to solve the circular dependency. - return Stack(isKeyed(this) ? this.valueSeq() : this); - }, - - toList: function toList() { - // Use Late Binding here to solve the circular dependency. - return List(isKeyed(this) ? this.valueSeq() : this); - }, - - // ### Common JavaScript methods and properties - - toString: function toString() { - return '[Collection]'; - }, - - __toString: function __toString(head, tail) { - if (this.size === 0) { - return head + tail; - } - return ( - head + - ' ' + - this.toSeq().map(this.__toStringMapper).join(', ') + - ' ' + - tail - ); - }, - - // ### ES6 Collection methods (ES6 Array and Map) - - concat: function concat() { - var values = [], len = arguments.length; - while ( len-- ) values[ len ] = arguments[ len ]; - - return reify(this, concatFactory(this, values)); - }, - - includes: function includes(searchValue) { - return this.some(function (value) { return is(value, searchValue); }); - }, - - entries: function entries() { - return this.__iterator(ITERATE_ENTRIES); - }, - - every: function every(predicate, context) { - assertNotInfinite(this.size); - var returnValue = true; - this.__iterate(function (v, k, c) { - if (!predicate.call(context, v, k, c)) { - returnValue = false; - return false; - } - }); - return returnValue; - }, - - filter: function filter(predicate, context) { - return reify(this, filterFactory(this, predicate, context, true)); - }, - - partition: function partition(predicate, context) { - return partitionFactory(this, predicate, context); - }, - - find: function find(predicate, context, notSetValue) { - var entry = this.findEntry(predicate, context); - return entry ? entry[1] : notSetValue; - }, - - forEach: function forEach(sideEffect, context) { - assertNotInfinite(this.size); - return this.__iterate(context ? sideEffect.bind(context) : sideEffect); - }, - - join: function join(separator) { - assertNotInfinite(this.size); - separator = separator !== undefined ? '' + separator : ','; - var joined = ''; - var isFirst = true; - this.__iterate(function (v) { - isFirst ? (isFirst = false) : (joined += separator); - joined += v !== null && v !== undefined ? v.toString() : ''; - }); - return joined; - }, - - keys: function keys() { - return this.__iterator(ITERATE_KEYS); - }, - - map: function map(mapper, context) { - return reify(this, mapFactory(this, mapper, context)); - }, - - reduce: function reduce$1(reducer, initialReduction, context) { - return reduce( - this, - reducer, - initialReduction, - context, - arguments.length < 2, - false - ); - }, - - reduceRight: function reduceRight(reducer, initialReduction, context) { - return reduce( - this, - reducer, - initialReduction, - context, - arguments.length < 2, - true - ); - }, - - reverse: function reverse() { - return reify(this, reverseFactory(this, true)); - }, - - slice: function slice(begin, end) { - return reify(this, sliceFactory(this, begin, end, true)); - }, - - some: function some(predicate, context) { - assertNotInfinite(this.size); - var returnValue = false; - this.__iterate(function (v, k, c) { - if (predicate.call(context, v, k, c)) { - returnValue = true; - return false; - } - }); - return returnValue; - }, - - sort: function sort(comparator) { - return reify(this, sortFactory(this, comparator)); - }, - - values: function values() { - return this.__iterator(ITERATE_VALUES); - }, - - // ### More sequential methods - - butLast: function butLast() { - return this.slice(0, -1); - }, - - isEmpty: function isEmpty() { - return this.size !== undefined ? this.size === 0 : !this.some(function () { return true; }); - }, - - count: function count(predicate, context) { - return ensureSize( - predicate ? this.toSeq().filter(predicate, context) : this - ); - }, - - countBy: function countBy(grouper, context) { - return countByFactory(this, grouper, context); - }, - - equals: function equals(other) { - return deepEqual(this, other); - }, - - entrySeq: function entrySeq() { - // eslint-disable-next-line @typescript-eslint/no-this-alias - var collection = this; - if (collection._cache) { - // We cache as an entries array, so we can just return the cache! - return new ArraySeq(collection._cache); - } - var entriesSequence = collection.toSeq().map(entryMapper).toIndexedSeq(); - entriesSequence.fromEntrySeq = function () { return collection.toSeq(); }; - return entriesSequence; - }, - - filterNot: function filterNot(predicate, context) { - return this.filter(not(predicate), context); - }, - - findEntry: function findEntry(predicate, context, notSetValue) { - var found = notSetValue; - this.__iterate(function (v, k, c) { - if (predicate.call(context, v, k, c)) { - found = [k, v]; - return false; - } - }); - return found; - }, - - findKey: function findKey(predicate, context) { - var entry = this.findEntry(predicate, context); - return entry && entry[0]; - }, - - findLast: function findLast(predicate, context, notSetValue) { - return this.toKeyedSeq().reverse().find(predicate, context, notSetValue); - }, - - findLastEntry: function findLastEntry(predicate, context, notSetValue) { - return this.toKeyedSeq() - .reverse() - .findEntry(predicate, context, notSetValue); - }, - - findLastKey: function findLastKey(predicate, context) { - return this.toKeyedSeq().reverse().findKey(predicate, context); - }, - - first: function first(notSetValue) { - return this.find(returnTrue, null, notSetValue); - }, - - flatMap: function flatMap(mapper, context) { - return reify(this, flatMapFactory(this, mapper, context)); - }, - - flatten: function flatten(depth) { - return reify(this, flattenFactory(this, depth, true)); - }, - - fromEntrySeq: function fromEntrySeq() { - return new FromEntriesSequence(this); - }, - - get: function get(searchKey, notSetValue) { - return this.find(function (_, key) { return is(key, searchKey); }, undefined, notSetValue); - }, - - getIn: getIn, - - groupBy: function groupBy(grouper, context) { - return groupByFactory(this, grouper, context); - }, - - has: function has(searchKey) { - return this.get(searchKey, NOT_SET) !== NOT_SET; - }, - - hasIn: hasIn, - - isSubset: function isSubset(iter) { - iter = typeof iter.includes === 'function' ? iter : Collection(iter); - return this.every(function (value) { return iter.includes(value); }); - }, - - isSuperset: function isSuperset(iter) { - iter = typeof iter.isSubset === 'function' ? iter : Collection(iter); - return iter.isSubset(this); - }, - - keyOf: function keyOf(searchValue) { - return this.findKey(function (value) { return is(value, searchValue); }); - }, - - keySeq: function keySeq() { - return this.toSeq().map(keyMapper).toIndexedSeq(); - }, - - last: function last(notSetValue) { - return this.toSeq().reverse().first(notSetValue); - }, - - lastKeyOf: function lastKeyOf(searchValue) { - return this.toKeyedSeq().reverse().keyOf(searchValue); - }, - - max: function max(comparator) { - return maxFactory(this, comparator); - }, - - maxBy: function maxBy(mapper, comparator) { - return maxFactory(this, comparator, mapper); - }, - - min: function min(comparator) { - return maxFactory( - this, - comparator ? neg(comparator) : defaultNegComparator - ); - }, - - minBy: function minBy(mapper, comparator) { - return maxFactory( - this, - comparator ? neg(comparator) : defaultNegComparator, - mapper - ); - }, - - rest: function rest() { - return this.slice(1); - }, - - skip: function skip(amount) { - return amount === 0 ? this : this.slice(Math.max(0, amount)); - }, - - skipLast: function skipLast(amount) { - return amount === 0 ? this : this.slice(0, -Math.max(0, amount)); - }, - - skipWhile: function skipWhile(predicate, context) { - return reify(this, skipWhileFactory(this, predicate, context, true)); - }, - - skipUntil: function skipUntil(predicate, context) { - return this.skipWhile(not(predicate), context); - }, - - sortBy: function sortBy(mapper, comparator) { - return reify(this, sortFactory(this, comparator, mapper)); - }, - - take: function take(amount) { - return this.slice(0, Math.max(0, amount)); - }, - - takeLast: function takeLast(amount) { - return this.slice(-Math.max(0, amount)); - }, - - takeWhile: function takeWhile(predicate, context) { - return reify(this, takeWhileFactory(this, predicate, context)); - }, - - takeUntil: function takeUntil(predicate, context) { - return this.takeWhile(not(predicate), context); - }, - - update: function update(fn) { - return fn(this); - }, - - valueSeq: function valueSeq() { - return this.toIndexedSeq(); - }, - - // ### Hashable Object - - hashCode: function hashCode() { - return this.__hash || (this.__hash = hashCollection(this)); - }, - - // ### Internal - - // abstract __iterate(fn, reverse) - - // abstract __iterator(type, reverse) -}); - -var CollectionPrototype = Collection.prototype; -CollectionPrototype[IS_COLLECTION_SYMBOL] = true; -CollectionPrototype[ITERATOR_SYMBOL] = CollectionPrototype.values; -CollectionPrototype.toJSON = CollectionPrototype.toArray; -CollectionPrototype.__toStringMapper = quoteString; -CollectionPrototype.inspect = CollectionPrototype.toSource = function () { - return this.toString(); -}; -CollectionPrototype.chain = CollectionPrototype.flatMap; -CollectionPrototype.contains = CollectionPrototype.includes; - -mixin(KeyedCollection, { - // ### More sequential methods - - flip: function flip() { - return reify(this, flipFactory(this)); - }, - - mapEntries: function mapEntries(mapper, context) { - var this$1$1 = this; - - var iterations = 0; - return reify( - this, - this.toSeq() - .map(function (v, k) { return mapper.call(context, [k, v], iterations++, this$1$1); }) - .fromEntrySeq() - ); - }, - - mapKeys: function mapKeys(mapper, context) { - var this$1$1 = this; - - return reify( - this, - this.toSeq() - .flip() - .map(function (k, v) { return mapper.call(context, k, v, this$1$1); }) - .flip() - ); - }, -}); - -var KeyedCollectionPrototype = KeyedCollection.prototype; -KeyedCollectionPrototype[IS_KEYED_SYMBOL] = true; -KeyedCollectionPrototype[ITERATOR_SYMBOL] = CollectionPrototype.entries; -KeyedCollectionPrototype.toJSON = toObject; -KeyedCollectionPrototype.__toStringMapper = function (v, k) { return quoteString(k) + ': ' + quoteString(v); }; - -mixin(IndexedCollection, { - // ### Conversion to other types - - toKeyedSeq: function toKeyedSeq() { - return new ToKeyedSequence(this, false); - }, - - // ### ES6 Collection methods (ES6 Array and Map) - - filter: function filter(predicate, context) { - return reify(this, filterFactory(this, predicate, context, false)); - }, - - findIndex: function findIndex(predicate, context) { - var entry = this.findEntry(predicate, context); - return entry ? entry[0] : -1; - }, - - indexOf: function indexOf(searchValue) { - var key = this.keyOf(searchValue); - return key === undefined ? -1 : key; - }, - - lastIndexOf: function lastIndexOf(searchValue) { - var key = this.lastKeyOf(searchValue); - return key === undefined ? -1 : key; - }, - - reverse: function reverse() { - return reify(this, reverseFactory(this, false)); - }, - - slice: function slice(begin, end) { - return reify(this, sliceFactory(this, begin, end, false)); - }, - - splice: function splice(index, removeNum /*, ...values*/) { - var numArgs = arguments.length; - removeNum = Math.max(removeNum || 0, 0); - if (numArgs === 0 || (numArgs === 2 && !removeNum)) { - return this; - } - // If index is negative, it should resolve relative to the size of the - // collection. However size may be expensive to compute if not cached, so - // only call count() if the number is in fact negative. - index = resolveBegin(index, index < 0 ? this.count() : this.size); - var spliced = this.slice(0, index); - return reify( - this, - numArgs === 1 - ? spliced - : spliced.concat(arrCopy(arguments, 2), this.slice(index + removeNum)) - ); - }, - - // ### More collection methods - - findLastIndex: function findLastIndex(predicate, context) { - var entry = this.findLastEntry(predicate, context); - return entry ? entry[0] : -1; - }, - - first: function first(notSetValue) { - return this.get(0, notSetValue); - }, - - flatten: function flatten(depth) { - return reify(this, flattenFactory(this, depth, false)); - }, - - get: function get(index, notSetValue) { - index = wrapIndex(this, index); - return index < 0 || - this.size === Infinity || - (this.size !== undefined && index > this.size) - ? notSetValue - : this.find(function (_, key) { return key === index; }, undefined, notSetValue); - }, - - has: function has(index) { - index = wrapIndex(this, index); - return ( - index >= 0 && - (this.size !== undefined - ? this.size === Infinity || index < this.size - : this.indexOf(index) !== -1) - ); - }, - - interpose: function interpose(separator) { - return reify(this, interposeFactory(this, separator)); - }, - - interleave: function interleave(/*...collections*/) { - var collections = [this].concat(arrCopy(arguments)); - var zipped = zipWithFactory(this.toSeq(), IndexedSeq.of, collections); - var interleaved = zipped.flatten(true); - if (zipped.size) { - interleaved.size = zipped.size * collections.length; - } - return reify(this, interleaved); - }, - - keySeq: function keySeq() { - return Range(0, this.size); - }, - - last: function last(notSetValue) { - return this.get(-1, notSetValue); - }, - - skipWhile: function skipWhile(predicate, context) { - return reify(this, skipWhileFactory(this, predicate, context, false)); - }, - - zip: function zip(/*, ...collections */) { - var collections = [this].concat(arrCopy(arguments)); - return reify(this, zipWithFactory(this, defaultZipper, collections)); - }, - - zipAll: function zipAll(/*, ...collections */) { - var collections = [this].concat(arrCopy(arguments)); - return reify(this, zipWithFactory(this, defaultZipper, collections, true)); - }, - - zipWith: function zipWith(zipper /*, ...collections */) { - var collections = arrCopy(arguments); - collections[0] = this; - return reify(this, zipWithFactory(this, zipper, collections)); - }, -}); - -var IndexedCollectionPrototype = IndexedCollection.prototype; -IndexedCollectionPrototype[IS_INDEXED_SYMBOL] = true; -IndexedCollectionPrototype[IS_ORDERED_SYMBOL] = true; - -mixin(SetCollection, { - // ### ES6 Collection methods (ES6 Array and Map) - - get: function get(value, notSetValue) { - return this.has(value) ? value : notSetValue; - }, - - includes: function includes(value) { - return this.has(value); - }, - - // ### More sequential methods - - keySeq: function keySeq() { - return this.valueSeq(); - }, -}); - -var SetCollectionPrototype = SetCollection.prototype; -SetCollectionPrototype.has = CollectionPrototype.includes; -SetCollectionPrototype.contains = SetCollectionPrototype.includes; -SetCollectionPrototype.keys = SetCollectionPrototype.values; - -// Mixin subclasses - -mixin(KeyedSeq, KeyedCollectionPrototype); -mixin(IndexedSeq, IndexedCollectionPrototype); -mixin(SetSeq, SetCollectionPrototype); - -// #pragma Helper functions - -function reduce(collection, reducer, reduction, context, useFirst, reverse) { - assertNotInfinite(collection.size); - collection.__iterate(function (v, k, c) { - if (useFirst) { - useFirst = false; - reduction = v; - } else { - reduction = reducer.call(context, reduction, v, k, c); - } - }, reverse); - return reduction; -} - -function keyMapper(v, k) { - return k; -} - -function entryMapper(v, k) { - return [k, v]; -} - -function not(predicate) { - return function () { - return !predicate.apply(this, arguments); - }; -} - -function neg(predicate) { - return function () { - return -predicate.apply(this, arguments); - }; -} - -function defaultZipper() { - return arrCopy(arguments); -} - -function defaultNegComparator(a, b) { - return a < b ? 1 : a > b ? -1 : 0; -} - -function hashCollection(collection) { - if (collection.size === Infinity) { - return 0; - } - var ordered = isOrdered(collection); - var keyed = isKeyed(collection); - var h = ordered ? 1 : 0; - - collection.__iterate( - keyed - ? ordered - ? function (v, k) { - h = (31 * h + hashMerge(hash(v), hash(k))) | 0; - } - : function (v, k) { - h = (h + hashMerge(hash(v), hash(k))) | 0; - } - : ordered - ? function (v) { - h = (31 * h + hash(v)) | 0; - } - : function (v) { - h = (h + hash(v)) | 0; - } - ); - - return murmurHashOfSize(collection.size, h); -} - -function murmurHashOfSize(size, h) { - h = imul(h, 0xcc9e2d51); - h = imul((h << 15) | (h >>> -15), 0x1b873593); - h = imul((h << 13) | (h >>> -13), 5); - h = ((h + 0xe6546b64) | 0) ^ size; - h = imul(h ^ (h >>> 16), 0x85ebca6b); - h = imul(h ^ (h >>> 13), 0xc2b2ae35); - h = smi(h ^ (h >>> 16)); - return h; -} - -function hashMerge(a, b) { - return (a ^ (b + 0x9e3779b9 + (a << 6) + (a >> 2))) | 0; // int -} - -export { Collection, CollectionPrototype, IndexedCollectionPrototype }; diff --git a/dist/es/Hash.js b/dist/es/Hash.js deleted file mode 100644 index 3fc7909aa2..0000000000 --- a/dist/es/Hash.js +++ /dev/null @@ -1,260 +0,0 @@ -/** - * @license - * MIT License - * - * Copyright (c) 2014-present, Lee Byron and other contributors. - * - * 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: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -import { smi } from './Math.js'; - -var defaultValueOf = Object.prototype.valueOf; - -function hash(o) { - if (o == null) { - return hashNullish(o); - } - - if (typeof o.hashCode === 'function') { - // Drop any high bits from accidentally long hash codes. - return smi(o.hashCode(o)); - } - - var v = valueOf(o); - - if (v == null) { - return hashNullish(v); - } - - switch (typeof v) { - case 'boolean': - // The hash values for built-in constants are a 1 value for each 5-byte - // shift region expect for the first, which encodes the value. This - // reduces the odds of a hash collision for these common values. - return v ? 0x42108421 : 0x42108420; - case 'number': - return hashNumber(v); - case 'string': - return v.length > STRING_HASH_CACHE_MIN_STRLEN - ? cachedHashString(v) - : hashString(v); - case 'object': - case 'function': - return hashJSObj(v); - case 'symbol': - return hashSymbol(v); - default: - if (typeof v.toString === 'function') { - return hashString(v.toString()); - } - throw new Error('Value type ' + typeof v + ' cannot be hashed.'); - } -} - -function hashNullish(nullish) { - return nullish === null ? 0x42108422 : /* undefined */ 0x42108423; -} - -// Compress arbitrarily large numbers into smi hashes. -function hashNumber(n) { - if (n !== n || n === Infinity) { - return 0; - } - var hash = n | 0; - if (hash !== n) { - hash ^= n * 0xffffffff; - } - while (n > 0xffffffff) { - n /= 0xffffffff; - hash ^= n; - } - return smi(hash); -} - -function cachedHashString(string) { - var hashed = stringHashCache[string]; - if (hashed === undefined) { - hashed = hashString(string); - if (STRING_HASH_CACHE_SIZE === STRING_HASH_CACHE_MAX_SIZE) { - STRING_HASH_CACHE_SIZE = 0; - stringHashCache = {}; - } - STRING_HASH_CACHE_SIZE++; - stringHashCache[string] = hashed; - } - return hashed; -} - -// http://jsperf.com/hashing-strings -function hashString(string) { - // This is the hash from JVM - // The hash code for a string is computed as - // s[0] * 31 ^ (n - 1) + s[1] * 31 ^ (n - 2) + ... + s[n - 1], - // where s[i] is the ith character of the string and n is the length of - // the string. We "mod" the result to make it between 0 (inclusive) and 2^31 - // (exclusive) by dropping high bits. - var hashed = 0; - for (var ii = 0; ii < string.length; ii++) { - hashed = (31 * hashed + string.charCodeAt(ii)) | 0; - } - return smi(hashed); -} - -function hashSymbol(sym) { - var hashed = symbolMap[sym]; - if (hashed !== undefined) { - return hashed; - } - - hashed = nextHash(); - - symbolMap[sym] = hashed; - - return hashed; -} - -function hashJSObj(obj) { - var hashed; - if (usingWeakMap) { - hashed = weakMap.get(obj); - if (hashed !== undefined) { - return hashed; - } - } - - hashed = obj[UID_HASH_KEY]; - if (hashed !== undefined) { - return hashed; - } - - if (!canDefineProperty) { - hashed = obj.propertyIsEnumerable && obj.propertyIsEnumerable[UID_HASH_KEY]; - if (hashed !== undefined) { - return hashed; - } - - hashed = getIENodeHash(obj); - if (hashed !== undefined) { - return hashed; - } - } - - hashed = nextHash(); - - if (usingWeakMap) { - weakMap.set(obj, hashed); - } else if (isExtensible !== undefined && isExtensible(obj) === false) { - throw new Error('Non-extensible objects are not allowed as keys.'); - } else if (canDefineProperty) { - Object.defineProperty(obj, UID_HASH_KEY, { - enumerable: false, - configurable: false, - writable: false, - value: hashed, - }); - } else if ( - obj.propertyIsEnumerable !== undefined && - obj.propertyIsEnumerable === obj.constructor.prototype.propertyIsEnumerable - ) { - // Since we can't define a non-enumerable property on the object - // we'll hijack one of the less-used non-enumerable properties to - // save our hash on it. Since this is a function it will not show up in - // `JSON.stringify` which is what we want. - obj.propertyIsEnumerable = function () { - return this.constructor.prototype.propertyIsEnumerable.apply( - this, - arguments - ); - }; - obj.propertyIsEnumerable[UID_HASH_KEY] = hashed; - } else if (obj.nodeType !== undefined) { - // At this point we couldn't get the IE `uniqueID` to use as a hash - // and we couldn't use a non-enumerable property to exploit the - // dontEnum bug so we simply add the `UID_HASH_KEY` on the node - // itself. - obj[UID_HASH_KEY] = hashed; - } else { - throw new Error('Unable to set a non-enumerable property on object.'); - } - - return hashed; -} - -// Get references to ES5 object methods. -var isExtensible = Object.isExtensible; - -// True if Object.defineProperty works as expected. IE8 fails this test. -var canDefineProperty = (function () { - try { - Object.defineProperty({}, '@', {}); - return true; - } catch (e) { - return false; - } -})(); - -// IE has a `uniqueID` property on DOM nodes. We can construct the hash from it -// and avoid memory leaks from the IE cloneNode bug. -function getIENodeHash(node) { - if (node && node.nodeType > 0) { - switch (node.nodeType) { - case 1: // Element - return node.uniqueID; - case 9: // Document - return node.documentElement && node.documentElement.uniqueID; - } - } -} - -function valueOf(obj) { - return obj.valueOf !== defaultValueOf && typeof obj.valueOf === 'function' - ? obj.valueOf(obj) - : obj; -} - -function nextHash() { - var nextHash = ++_objHashUID; - if (_objHashUID & 0x40000000) { - _objHashUID = 0; - } - return nextHash; -} - -// If possible, use a WeakMap. -var usingWeakMap = typeof WeakMap === 'function'; -var weakMap; -if (usingWeakMap) { - weakMap = new WeakMap(); -} - -var symbolMap = Object.create(null); - -var _objHashUID = 0; - -var UID_HASH_KEY = '__immutablehash__'; -if (typeof Symbol === 'function') { - UID_HASH_KEY = Symbol(UID_HASH_KEY); -} - -var STRING_HASH_CACHE_MIN_STRLEN = 16; -var STRING_HASH_CACHE_MAX_SIZE = 255; -var STRING_HASH_CACHE_SIZE = 0; -var stringHashCache = {}; - -export { hash }; diff --git a/dist/es/Immutable.js b/dist/es/Immutable.js deleted file mode 100644 index 59bbd81179..0000000000 --- a/dist/es/Immutable.js +++ /dev/null @@ -1,73 +0,0 @@ -/** - * @license - * MIT License - * - * Copyright (c) 2014-present, Lee Byron and other contributors. - * - * 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: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -export { Seq } from './Seq.js'; -export { OrderedMap } from './OrderedMap.js'; -export { List } from './List.js'; -export { Map } from './Map.js'; -export { Stack } from './Stack.js'; -export { OrderedSet } from './OrderedSet.js'; -export { PairSorting } from './PairSorting.js'; -export { Set } from './Set.js'; -export { Record } from './Record.js'; -export { Range } from './Range.js'; -export { Repeat } from './Repeat.js'; -export { is } from './is.js'; -export { fromJS } from './fromJS.js'; -export { default as isPlainObject } from './utils/isPlainObj.js'; -export { isImmutable } from './predicates/isImmutable.js'; -export { isCollection } from './predicates/isCollection.js'; -export { isKeyed } from './predicates/isKeyed.js'; -export { isIndexed } from './predicates/isIndexed.js'; -export { isAssociative } from './predicates/isAssociative.js'; -export { isOrdered } from './predicates/isOrdered.js'; -export { isValueObject } from './predicates/isValueObject.js'; -export { isSeq } from './predicates/isSeq.js'; -export { isList } from './predicates/isList.js'; -export { isMap } from './predicates/isMap.js'; -export { isOrderedMap } from './predicates/isOrderedMap.js'; -export { isStack } from './predicates/isStack.js'; -export { isSet } from './predicates/isSet.js'; -export { isOrderedSet } from './predicates/isOrderedSet.js'; -export { isRecord } from './predicates/isRecord.js'; -import './CollectionImpl.js'; -export { hash } from './Hash.js'; -export { get } from './functional/get.js'; -export { getIn } from './functional/getIn.js'; -export { has } from './functional/has.js'; -export { hasIn } from './functional/hasIn.js'; -export { merge, mergeDeep, mergeDeepWith, mergeWith } from './functional/merge.js'; -export { remove } from './functional/remove.js'; -export { removeIn } from './functional/removeIn.js'; -export { set } from './functional/set.js'; -export { setIn } from './functional/setIn.js'; -export { update } from './functional/update.js'; -export { updateIn } from './functional/updateIn.js'; -export { version } from './package.json.js'; -import { Collection } from './Collection.js'; - -// Note: Iterable is deprecated -var Iterable = Collection; - -export { Collection, Iterable }; diff --git a/dist/es/Iterator.js b/dist/es/Iterator.js deleted file mode 100644 index 94de58f316..0000000000 --- a/dist/es/Iterator.js +++ /dev/null @@ -1,106 +0,0 @@ -/** - * @license - * MIT License - * - * Copyright (c) 2014-present, Lee Byron and other contributors. - * - * 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: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -var ITERATE_KEYS = 0; -var ITERATE_VALUES = 1; -var ITERATE_ENTRIES = 2; - -var REAL_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator; -var FAUX_ITERATOR_SYMBOL = '@@iterator'; - -var ITERATOR_SYMBOL = REAL_ITERATOR_SYMBOL || FAUX_ITERATOR_SYMBOL; - -var Iterator = function Iterator(next) { - this.next = next; -}; - -Iterator.prototype.toString = function toString () { - return '[Iterator]'; -}; - -Iterator.KEYS = ITERATE_KEYS; -Iterator.VALUES = ITERATE_VALUES; -Iterator.ENTRIES = ITERATE_ENTRIES; - -Iterator.prototype.inspect = Iterator.prototype.toSource = function () { - return this.toString(); -}; -Iterator.prototype[ITERATOR_SYMBOL] = function () { - return this; -}; - -function iteratorValue(type, k, v, iteratorResult) { - var value = type === 0 ? k : type === 1 ? v : [k, v]; - iteratorResult - ? (iteratorResult.value = value) - : (iteratorResult = { - value: value, - done: false, - }); - return iteratorResult; -} - -function iteratorDone() { - return { value: undefined, done: true }; -} - -function hasIterator(maybeIterable) { - if (Array.isArray(maybeIterable)) { - // IE11 trick as it does not support `Symbol.iterator` - return true; - } - - return !!getIteratorFn(maybeIterable); -} - -function isIterator(maybeIterator) { - return maybeIterator && typeof maybeIterator.next === 'function'; -} - -function getIterator(iterable) { - var iteratorFn = getIteratorFn(iterable); - return iteratorFn && iteratorFn.call(iterable); -} - -function getIteratorFn(iterable) { - var iteratorFn = - iterable && - ((REAL_ITERATOR_SYMBOL && iterable[REAL_ITERATOR_SYMBOL]) || - iterable[FAUX_ITERATOR_SYMBOL]); - if (typeof iteratorFn === 'function') { - return iteratorFn; - } -} - -function isEntriesIterable(maybeIterable) { - var iteratorFn = getIteratorFn(maybeIterable); - return iteratorFn && iteratorFn === maybeIterable.entries; -} - -function isKeysIterable(maybeIterable) { - var iteratorFn = getIteratorFn(maybeIterable); - return iteratorFn && iteratorFn === maybeIterable.keys; -} - -export { ITERATE_ENTRIES, ITERATE_KEYS, ITERATE_VALUES, ITERATOR_SYMBOL, Iterator, getIterator, hasIterator, isEntriesIterable, isIterator, isKeysIterable, iteratorDone, iteratorValue }; diff --git a/dist/es/List.js b/dist/es/List.js deleted file mode 100644 index 9dff60b0aa..0000000000 --- a/dist/es/List.js +++ /dev/null @@ -1,696 +0,0 @@ -/** - * @license - * MIT License - * - * Copyright (c) 2014-present, Lee Byron and other contributors. - * - * 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: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -import { wrapIndex, MASK, SHIFT, wholeSlice, DELETE, SetRef, OwnerID, SIZE, MakeRef, resolveEnd, resolveBegin } from './TrieUtils.js'; -import { isList, IS_LIST_SYMBOL } from './predicates/isList.js'; -import { IndexedCollection } from './Collection.js'; -import { hasIterator, Iterator, iteratorDone, iteratorValue } from './Iterator.js'; -import { setIn } from './methods/setIn.js'; -import { deleteIn } from './methods/deleteIn.js'; -import { update } from './methods/update.js'; -import { updateIn } from './methods/updateIn.js'; -import { mergeIn } from './methods/mergeIn.js'; -import { mergeDeepIn } from './methods/mergeDeepIn.js'; -import { withMutations } from './methods/withMutations.js'; -import { asMutable } from './methods/asMutable.js'; -import { asImmutable } from './methods/asImmutable.js'; -import { wasAltered } from './methods/wasAltered.js'; -import assertNotInfinite from './utils/assertNotInfinite.js'; - -var List = /*@__PURE__*/(function (IndexedCollection) { - function List(value) { - var empty = emptyList(); - if (value === undefined || value === null) { - // eslint-disable-next-line no-constructor-return - return empty; - } - if (isList(value)) { - // eslint-disable-next-line no-constructor-return - return value; - } - var iter = IndexedCollection(value); - var size = iter.size; - if (size === 0) { - // eslint-disable-next-line no-constructor-return - return empty; - } - assertNotInfinite(size); - if (size > 0 && size < SIZE) { - // eslint-disable-next-line no-constructor-return - return makeList(0, size, SHIFT, null, new VNode(iter.toArray())); - } - // eslint-disable-next-line no-constructor-return - return empty.withMutations(function (list) { - list.setSize(size); - iter.forEach(function (v, i) { return list.set(i, v); }); - }); - } - - if ( IndexedCollection ) List.__proto__ = IndexedCollection; - List.prototype = Object.create( IndexedCollection && IndexedCollection.prototype ); - List.prototype.constructor = List; - - List.of = function of (/*...values*/) { - return this(arguments); - }; - - List.prototype.toString = function toString () { - return this.__toString('List [', ']'); - }; - - // @pragma Access - - List.prototype.get = function get (index, notSetValue) { - index = wrapIndex(this, index); - if (index >= 0 && index < this.size) { - index += this._origin; - var node = listNodeFor(this, index); - return node && node.array[index & MASK]; - } - return notSetValue; - }; - - // @pragma Modification - - List.prototype.set = function set (index, value) { - return updateList(this, index, value); - }; - - List.prototype.remove = function remove (index) { - return !this.has(index) - ? this - : index === 0 - ? this.shift() - : index === this.size - 1 - ? this.pop() - : this.splice(index, 1); - }; - - List.prototype.insert = function insert (index, value) { - return this.splice(index, 0, value); - }; - - List.prototype.clear = function clear () { - if (this.size === 0) { - return this; - } - if (this.__ownerID) { - this.size = this._origin = this._capacity = 0; - this._level = SHIFT; - this._root = this._tail = this.__hash = undefined; - this.__altered = true; - return this; - } - return emptyList(); - }; - - List.prototype.push = function push (/*...values*/) { - var values = arguments; - var oldSize = this.size; - return this.withMutations(function (list) { - setListBounds(list, 0, oldSize + values.length); - for (var ii = 0; ii < values.length; ii++) { - list.set(oldSize + ii, values[ii]); - } - }); - }; - - List.prototype.pop = function pop () { - return setListBounds(this, 0, -1); - }; - - List.prototype.unshift = function unshift (/*...values*/) { - var values = arguments; - return this.withMutations(function (list) { - setListBounds(list, -values.length); - for (var ii = 0; ii < values.length; ii++) { - list.set(ii, values[ii]); - } - }); - }; - - List.prototype.shift = function shift () { - return setListBounds(this, 1); - }; - - // @pragma Composition - - List.prototype.concat = function concat (/*...collections*/) { - var arguments$1 = arguments; - - var seqs = []; - for (var i = 0; i < arguments.length; i++) { - var argument = arguments$1[i]; - var seq = IndexedCollection( - typeof argument !== 'string' && hasIterator(argument) - ? argument - : [argument] - ); - if (seq.size !== 0) { - seqs.push(seq); - } - } - if (seqs.length === 0) { - return this; - } - if (this.size === 0 && !this.__ownerID && seqs.length === 1) { - return this.constructor(seqs[0]); - } - return this.withMutations(function (list) { - seqs.forEach(function (seq) { return seq.forEach(function (value) { return list.push(value); }); }); - }); - }; - - List.prototype.setSize = function setSize (size) { - return setListBounds(this, 0, size); - }; - - List.prototype.map = function map (mapper, context) { - var this$1$1 = this; - - return this.withMutations(function (list) { - for (var i = 0; i < this$1$1.size; i++) { - list.set(i, mapper.call(context, list.get(i), i, this$1$1)); - } - }); - }; - - // @pragma Iteration - - List.prototype.slice = function slice (begin, end) { - var size = this.size; - if (wholeSlice(begin, end, size)) { - return this; - } - return setListBounds( - this, - resolveBegin(begin, size), - resolveEnd(end, size) - ); - }; - - List.prototype.__iterator = function __iterator (type, reverse) { - var index = reverse ? this.size : 0; - var values = iterateList(this, reverse); - return new Iterator(function () { - var value = values(); - return value === DONE - ? iteratorDone() - : iteratorValue(type, reverse ? --index : index++, value); - }); - }; - - List.prototype.__iterate = function __iterate (fn, reverse) { - var index = reverse ? this.size : 0; - var values = iterateList(this, reverse); - var value; - while ((value = values()) !== DONE) { - if (fn(value, reverse ? --index : index++, this) === false) { - break; - } - } - return index; - }; - - List.prototype.__ensureOwner = function __ensureOwner (ownerID) { - if (ownerID === this.__ownerID) { - return this; - } - if (!ownerID) { - if (this.size === 0) { - return emptyList(); - } - this.__ownerID = ownerID; - this.__altered = false; - return this; - } - return makeList( - this._origin, - this._capacity, - this._level, - this._root, - this._tail, - ownerID, - this.__hash - ); - }; - - return List; -}(IndexedCollection)); - -List.isList = isList; - -var ListPrototype = List.prototype; -ListPrototype[IS_LIST_SYMBOL] = true; -ListPrototype[DELETE] = ListPrototype.remove; -ListPrototype.merge = ListPrototype.concat; -ListPrototype.setIn = setIn; -ListPrototype.deleteIn = ListPrototype.removeIn = deleteIn; -ListPrototype.update = update; -ListPrototype.updateIn = updateIn; -ListPrototype.mergeIn = mergeIn; -ListPrototype.mergeDeepIn = mergeDeepIn; -ListPrototype.withMutations = withMutations; -ListPrototype.wasAltered = wasAltered; -ListPrototype.asImmutable = asImmutable; -ListPrototype['@@transducer/init'] = ListPrototype.asMutable = asMutable; -ListPrototype['@@transducer/step'] = function (result, arr) { - return result.push(arr); -}; -ListPrototype['@@transducer/result'] = function (obj) { - return obj.asImmutable(); -}; - -var VNode = function VNode(array, ownerID) { - this.array = array; - this.ownerID = ownerID; -}; - -// TODO: seems like these methods are very similar - -VNode.prototype.removeBefore = function removeBefore (ownerID, level, index) { - if (index === level ? 1 << level : this.array.length === 0) { - return this; - } - var originIndex = (index >>> level) & MASK; - if (originIndex >= this.array.length) { - return new VNode([], ownerID); - } - var removingFirst = originIndex === 0; - var newChild; - if (level > 0) { - var oldChild = this.array[originIndex]; - newChild = - oldChild && oldChild.removeBefore(ownerID, level - SHIFT, index); - if (newChild === oldChild && removingFirst) { - return this; - } - } - if (removingFirst && !newChild) { - return this; - } - var editable = editableVNode(this, ownerID); - if (!removingFirst) { - for (var ii = 0; ii < originIndex; ii++) { - editable.array[ii] = undefined; - } - } - if (newChild) { - editable.array[originIndex] = newChild; - } - return editable; -}; - -VNode.prototype.removeAfter = function removeAfter (ownerID, level, index) { - if (index === (level ? 1 << level : 0) || this.array.length === 0) { - return this; - } - var sizeIndex = ((index - 1) >>> level) & MASK; - if (sizeIndex >= this.array.length) { - return this; - } - - var newChild; - if (level > 0) { - var oldChild = this.array[sizeIndex]; - newChild = - oldChild && oldChild.removeAfter(ownerID, level - SHIFT, index); - if (newChild === oldChild && sizeIndex === this.array.length - 1) { - return this; - } - } - - var editable = editableVNode(this, ownerID); - editable.array.splice(sizeIndex + 1); - if (newChild) { - editable.array[sizeIndex] = newChild; - } - return editable; -}; - -var DONE = {}; - -function iterateList(list, reverse) { - var left = list._origin; - var right = list._capacity; - var tailPos = getTailOffset(right); - var tail = list._tail; - - return iterateNodeOrLeaf(list._root, list._level, 0); - - function iterateNodeOrLeaf(node, level, offset) { - return level === 0 - ? iterateLeaf(node, offset) - : iterateNode(node, level, offset); - } - - function iterateLeaf(node, offset) { - var array = offset === tailPos ? tail && tail.array : node && node.array; - var from = offset > left ? 0 : left - offset; - var to = right - offset; - if (to > SIZE) { - to = SIZE; - } - return function () { - if (from === to) { - return DONE; - } - var idx = reverse ? --to : from++; - return array && array[idx]; - }; - } - - function iterateNode(node, level, offset) { - var values; - var array = node && node.array; - var from = offset > left ? 0 : (left - offset) >> level; - var to = ((right - offset) >> level) + 1; - if (to > SIZE) { - to = SIZE; - } - return function () { - while (true) { - if (values) { - var value = values(); - if (value !== DONE) { - return value; - } - values = null; - } - if (from === to) { - return DONE; - } - var idx = reverse ? --to : from++; - values = iterateNodeOrLeaf( - array && array[idx], - level - SHIFT, - offset + (idx << level) - ); - } - }; - } -} - -function makeList(origin, capacity, level, root, tail, ownerID, hash) { - var list = Object.create(ListPrototype); - list.size = capacity - origin; - list._origin = origin; - list._capacity = capacity; - list._level = level; - list._root = root; - list._tail = tail; - list.__ownerID = ownerID; - list.__hash = hash; - list.__altered = false; - return list; -} - -function emptyList() { - return makeList(0, 0, SHIFT); -} - -function updateList(list, index, value) { - index = wrapIndex(list, index); - - if (index !== index) { - return list; - } - - if (index >= list.size || index < 0) { - return list.withMutations(function (list) { - index < 0 - ? setListBounds(list, index).set(0, value) - : setListBounds(list, 0, index + 1).set(index, value); - }); - } - - index += list._origin; - - var newTail = list._tail; - var newRoot = list._root; - var didAlter = MakeRef(); - if (index >= getTailOffset(list._capacity)) { - newTail = updateVNode(newTail, list.__ownerID, 0, index, value, didAlter); - } else { - newRoot = updateVNode( - newRoot, - list.__ownerID, - list._level, - index, - value, - didAlter - ); - } - - if (!didAlter.value) { - return list; - } - - if (list.__ownerID) { - list._root = newRoot; - list._tail = newTail; - list.__hash = undefined; - list.__altered = true; - return list; - } - return makeList(list._origin, list._capacity, list._level, newRoot, newTail); -} - -function updateVNode(node, ownerID, level, index, value, didAlter) { - var idx = (index >>> level) & MASK; - var nodeHas = node && idx < node.array.length; - if (!nodeHas && value === undefined) { - return node; - } - - var newNode; - - if (level > 0) { - var lowerNode = node && node.array[idx]; - var newLowerNode = updateVNode( - lowerNode, - ownerID, - level - SHIFT, - index, - value, - didAlter - ); - if (newLowerNode === lowerNode) { - return node; - } - newNode = editableVNode(node, ownerID); - newNode.array[idx] = newLowerNode; - return newNode; - } - - if (nodeHas && node.array[idx] === value) { - return node; - } - - if (didAlter) { - SetRef(didAlter); - } - - newNode = editableVNode(node, ownerID); - if (value === undefined && idx === newNode.array.length - 1) { - newNode.array.pop(); - } else { - newNode.array[idx] = value; - } - return newNode; -} - -function editableVNode(node, ownerID) { - if (ownerID && node && ownerID === node.ownerID) { - return node; - } - return new VNode(node ? node.array.slice() : [], ownerID); -} - -function listNodeFor(list, rawIndex) { - if (rawIndex >= getTailOffset(list._capacity)) { - return list._tail; - } - if (rawIndex < 1 << (list._level + SHIFT)) { - var node = list._root; - var level = list._level; - while (node && level > 0) { - node = node.array[(rawIndex >>> level) & MASK]; - level -= SHIFT; - } - return node; - } -} - -function setListBounds(list, begin, end) { - // Sanitize begin & end using this shorthand for ToInt32(argument) - // http://www.ecma-international.org/ecma-262/6.0/#sec-toint32 - if (begin !== undefined) { - begin |= 0; - } - if (end !== undefined) { - end |= 0; - } - var owner = list.__ownerID || new OwnerID(); - var oldOrigin = list._origin; - var oldCapacity = list._capacity; - var newOrigin = oldOrigin + begin; - var newCapacity = - end === undefined - ? oldCapacity - : end < 0 - ? oldCapacity + end - : oldOrigin + end; - if (newOrigin === oldOrigin && newCapacity === oldCapacity) { - return list; - } - - // If it's going to end after it starts, it's empty. - if (newOrigin >= newCapacity) { - return list.clear(); - } - - var newLevel = list._level; - var newRoot = list._root; - - // New origin might need creating a higher root. - var offsetShift = 0; - while (newOrigin + offsetShift < 0) { - newRoot = new VNode( - newRoot && newRoot.array.length ? [undefined, newRoot] : [], - owner - ); - newLevel += SHIFT; - offsetShift += 1 << newLevel; - } - if (offsetShift) { - newOrigin += offsetShift; - oldOrigin += offsetShift; - newCapacity += offsetShift; - oldCapacity += offsetShift; - } - - var oldTailOffset = getTailOffset(oldCapacity); - var newTailOffset = getTailOffset(newCapacity); - - // New size might need creating a higher root. - while (newTailOffset >= 1 << (newLevel + SHIFT)) { - newRoot = new VNode( - newRoot && newRoot.array.length ? [newRoot] : [], - owner - ); - newLevel += SHIFT; - } - - // Locate or create the new tail. - var oldTail = list._tail; - var newTail = - newTailOffset < oldTailOffset - ? listNodeFor(list, newCapacity - 1) - : newTailOffset > oldTailOffset - ? new VNode([], owner) - : oldTail; - - // Merge Tail into tree. - if ( - oldTail && - newTailOffset > oldTailOffset && - newOrigin < oldCapacity && - oldTail.array.length - ) { - newRoot = editableVNode(newRoot, owner); - var node = newRoot; - for (var level = newLevel; level > SHIFT; level -= SHIFT) { - var idx = (oldTailOffset >>> level) & MASK; - node = node.array[idx] = editableVNode(node.array[idx], owner); - } - node.array[(oldTailOffset >>> SHIFT) & MASK] = oldTail; - } - - // If the size has been reduced, there's a chance the tail needs to be trimmed. - if (newCapacity < oldCapacity) { - newTail = newTail && newTail.removeAfter(owner, 0, newCapacity); - } - - // If the new origin is within the tail, then we do not need a root. - if (newOrigin >= newTailOffset) { - newOrigin -= newTailOffset; - newCapacity -= newTailOffset; - newLevel = SHIFT; - newRoot = null; - newTail = newTail && newTail.removeBefore(owner, 0, newOrigin); - - // Otherwise, if the root has been trimmed, garbage collect. - } else if (newOrigin > oldOrigin || newTailOffset < oldTailOffset) { - offsetShift = 0; - - // Identify the new top root node of the subtree of the old root. - while (newRoot) { - var beginIndex = (newOrigin >>> newLevel) & MASK; - if ((beginIndex !== newTailOffset >>> newLevel) & MASK) { - break; - } - if (beginIndex) { - offsetShift += (1 << newLevel) * beginIndex; - } - newLevel -= SHIFT; - newRoot = newRoot.array[beginIndex]; - } - - // Trim the new sides of the new root. - if (newRoot && newOrigin > oldOrigin) { - newRoot = newRoot.removeBefore(owner, newLevel, newOrigin - offsetShift); - } - if (newRoot && newTailOffset < oldTailOffset) { - newRoot = newRoot.removeAfter( - owner, - newLevel, - newTailOffset - offsetShift - ); - } - if (offsetShift) { - newOrigin -= offsetShift; - newCapacity -= offsetShift; - } - } - - if (list.__ownerID) { - list.size = newCapacity - newOrigin; - list._origin = newOrigin; - list._capacity = newCapacity; - list._level = newLevel; - list._root = newRoot; - list._tail = newTail; - list.__hash = undefined; - list.__altered = true; - return list; - } - return makeList(newOrigin, newCapacity, newLevel, newRoot, newTail); -} - -function getTailOffset(size) { - return size < SIZE ? 0 : ((size - 1) >>> SHIFT) << SHIFT; -} - -export { List, emptyList }; diff --git a/dist/es/Map.js b/dist/es/Map.js deleted file mode 100644 index 3bce552c03..0000000000 --- a/dist/es/Map.js +++ /dev/null @@ -1,820 +0,0 @@ -/** - * @license - * MIT License - * - * Copyright (c) 2014-present, Lee Byron and other contributors. - * - * 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: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -import { is } from './is.js'; -import { Collection, KeyedCollection } from './Collection.js'; -import { isMap, IS_MAP_SYMBOL } from './predicates/isMap.js'; -import { isOrdered } from './predicates/isOrdered.js'; -import { DELETE, NOT_SET, SetRef, MakeRef, MASK, SHIFT, SIZE, OwnerID } from './TrieUtils.js'; -import { hash } from './Hash.js'; -import { iteratorDone, Iterator, iteratorValue } from './Iterator.js'; -import { sortFactory } from './Operations.js'; -import arrCopy from './utils/arrCopy.js'; -import assertNotInfinite from './utils/assertNotInfinite.js'; -import { setIn } from './methods/setIn.js'; -import { deleteIn } from './methods/deleteIn.js'; -import { update } from './methods/update.js'; -import { updateIn } from './methods/updateIn.js'; -import { merge, mergeWith } from './methods/merge.js'; -import { mergeDeep, mergeDeepWith } from './methods/mergeDeep.js'; -import { mergeIn } from './methods/mergeIn.js'; -import { mergeDeepIn } from './methods/mergeDeepIn.js'; -import { withMutations } from './methods/withMutations.js'; -import { asMutable } from './methods/asMutable.js'; -import { asImmutable } from './methods/asImmutable.js'; -import { wasAltered } from './methods/wasAltered.js'; -import { OrderedMap } from './OrderedMap.js'; - -var Map = /*@__PURE__*/(function (KeyedCollection) { - function Map(value) { - // eslint-disable-next-line no-constructor-return - return value === undefined || value === null - ? emptyMap() - : isMap(value) && !isOrdered(value) - ? value - : emptyMap().withMutations(function (map) { - var iter = KeyedCollection(value); - assertNotInfinite(iter.size); - iter.forEach(function (v, k) { return map.set(k, v); }); - }); - } - - if ( KeyedCollection ) Map.__proto__ = KeyedCollection; - Map.prototype = Object.create( KeyedCollection && KeyedCollection.prototype ); - Map.prototype.constructor = Map; - - Map.prototype.toString = function toString () { - return this.__toString('Map {', '}'); - }; - - // @pragma Access - - Map.prototype.get = function get (k, notSetValue) { - return this._root - ? this._root.get(0, undefined, k, notSetValue) - : notSetValue; - }; - - // @pragma Modification - - Map.prototype.set = function set (k, v) { - return updateMap(this, k, v); - }; - - Map.prototype.remove = function remove (k) { - return updateMap(this, k, NOT_SET); - }; - - Map.prototype.deleteAll = function deleteAll (keys) { - var collection = Collection(keys); - - if (collection.size === 0) { - return this; - } - - return this.withMutations(function (map) { - collection.forEach(function (key) { return map.remove(key); }); - }); - }; - - Map.prototype.clear = function clear () { - if (this.size === 0) { - return this; - } - if (this.__ownerID) { - this.size = 0; - this._root = null; - this.__hash = undefined; - this.__altered = true; - return this; - } - return emptyMap(); - }; - - // @pragma Composition - - Map.prototype.sort = function sort (comparator) { - // Late binding - return OrderedMap(sortFactory(this, comparator)); - }; - - Map.prototype.sortBy = function sortBy (mapper, comparator) { - // Late binding - return OrderedMap(sortFactory(this, comparator, mapper)); - }; - - Map.prototype.map = function map (mapper, context) { - var this$1$1 = this; - - return this.withMutations(function (map) { - map.forEach(function (value, key) { - map.set(key, mapper.call(context, value, key, this$1$1)); - }); - }); - }; - - // @pragma Mutability - - Map.prototype.__iterator = function __iterator (type, reverse) { - return new MapIterator(this, type, reverse); - }; - - Map.prototype.__iterate = function __iterate (fn, reverse) { - var this$1$1 = this; - - var iterations = 0; - this._root && - this._root.iterate(function (entry) { - iterations++; - return fn(entry[1], entry[0], this$1$1); - }, reverse); - return iterations; - }; - - Map.prototype.__ensureOwner = function __ensureOwner (ownerID) { - if (ownerID === this.__ownerID) { - return this; - } - if (!ownerID) { - if (this.size === 0) { - return emptyMap(); - } - this.__ownerID = ownerID; - this.__altered = false; - return this; - } - return makeMap(this.size, this._root, ownerID, this.__hash); - }; - - return Map; -}(KeyedCollection)); - -Map.isMap = isMap; - -var MapPrototype = Map.prototype; -MapPrototype[IS_MAP_SYMBOL] = true; -MapPrototype[DELETE] = MapPrototype.remove; -MapPrototype.removeAll = MapPrototype.deleteAll; -MapPrototype.setIn = setIn; -MapPrototype.removeIn = MapPrototype.deleteIn = deleteIn; -MapPrototype.update = update; -MapPrototype.updateIn = updateIn; -MapPrototype.merge = MapPrototype.concat = merge; -MapPrototype.mergeWith = mergeWith; -MapPrototype.mergeDeep = mergeDeep; -MapPrototype.mergeDeepWith = mergeDeepWith; -MapPrototype.mergeIn = mergeIn; -MapPrototype.mergeDeepIn = mergeDeepIn; -MapPrototype.withMutations = withMutations; -MapPrototype.wasAltered = wasAltered; -MapPrototype.asImmutable = asImmutable; -MapPrototype['@@transducer/init'] = MapPrototype.asMutable = asMutable; -MapPrototype['@@transducer/step'] = function (result, arr) { - return result.set(arr[0], arr[1]); -}; -MapPrototype['@@transducer/result'] = function (obj) { - return obj.asImmutable(); -}; - -// #pragma Trie Nodes - -var ArrayMapNode = function ArrayMapNode(ownerID, entries) { - this.ownerID = ownerID; - this.entries = entries; -}; - -ArrayMapNode.prototype.get = function get (shift, keyHash, key, notSetValue) { - var entries = this.entries; - for (var ii = 0, len = entries.length; ii < len; ii++) { - if (is(key, entries[ii][0])) { - return entries[ii][1]; - } - } - return notSetValue; -}; - -ArrayMapNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { - var removed = value === NOT_SET; - - var entries = this.entries; - var idx = 0; - var len = entries.length; - for (; idx < len; idx++) { - if (is(key, entries[idx][0])) { - break; - } - } - var exists = idx < len; - - if (exists ? entries[idx][1] === value : removed) { - return this; - } - - SetRef(didAlter); - (removed || !exists) && SetRef(didChangeSize); - - if (removed && entries.length === 1) { - return; // undefined - } - - if (!exists && !removed && entries.length >= MAX_ARRAY_MAP_SIZE) { - return createNodes(ownerID, entries, key, value); - } - - var isEditable = ownerID && ownerID === this.ownerID; - var newEntries = isEditable ? entries : arrCopy(entries); - - if (exists) { - if (removed) { - idx === len - 1 - ? newEntries.pop() - : (newEntries[idx] = newEntries.pop()); - } else { - newEntries[idx] = [key, value]; - } - } else { - newEntries.push([key, value]); - } - - if (isEditable) { - this.entries = newEntries; - return this; - } - - return new ArrayMapNode(ownerID, newEntries); -}; - -var BitmapIndexedNode = function BitmapIndexedNode(ownerID, bitmap, nodes) { - this.ownerID = ownerID; - this.bitmap = bitmap; - this.nodes = nodes; -}; - -BitmapIndexedNode.prototype.get = function get (shift, keyHash, key, notSetValue) { - if (keyHash === undefined) { - keyHash = hash(key); - } - var bit = 1 << ((shift === 0 ? keyHash : keyHash >>> shift) & MASK); - var bitmap = this.bitmap; - return (bitmap & bit) === 0 - ? notSetValue - : this.nodes[popCount(bitmap & (bit - 1))].get( - shift + SHIFT, - keyHash, - key, - notSetValue - ); -}; - -BitmapIndexedNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { - if (keyHash === undefined) { - keyHash = hash(key); - } - var keyHashFrag = (shift === 0 ? keyHash : keyHash >>> shift) & MASK; - var bit = 1 << keyHashFrag; - var bitmap = this.bitmap; - var exists = (bitmap & bit) !== 0; - - if (!exists && value === NOT_SET) { - return this; - } - - var idx = popCount(bitmap & (bit - 1)); - var nodes = this.nodes; - var node = exists ? nodes[idx] : undefined; - var newNode = updateNode( - node, - ownerID, - shift + SHIFT, - keyHash, - key, - value, - didChangeSize, - didAlter - ); - - if (newNode === node) { - return this; - } - - if (!exists && newNode && nodes.length >= MAX_BITMAP_INDEXED_SIZE) { - return expandNodes(ownerID, nodes, bitmap, keyHashFrag, newNode); - } - - if ( - exists && - !newNode && - nodes.length === 2 && - isLeafNode(nodes[idx ^ 1]) - ) { - return nodes[idx ^ 1]; - } - - if (exists && newNode && nodes.length === 1 && isLeafNode(newNode)) { - return newNode; - } - - var isEditable = ownerID && ownerID === this.ownerID; - var newBitmap = exists ? (newNode ? bitmap : bitmap ^ bit) : bitmap | bit; - var newNodes = exists - ? newNode - ? setAt(nodes, idx, newNode, isEditable) - : spliceOut(nodes, idx, isEditable) - : spliceIn(nodes, idx, newNode, isEditable); - - if (isEditable) { - this.bitmap = newBitmap; - this.nodes = newNodes; - return this; - } - - return new BitmapIndexedNode(ownerID, newBitmap, newNodes); -}; - -var HashArrayMapNode = function HashArrayMapNode(ownerID, count, nodes) { - this.ownerID = ownerID; - this.count = count; - this.nodes = nodes; -}; - -HashArrayMapNode.prototype.get = function get (shift, keyHash, key, notSetValue) { - if (keyHash === undefined) { - keyHash = hash(key); - } - var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK; - var node = this.nodes[idx]; - return node - ? node.get(shift + SHIFT, keyHash, key, notSetValue) - : notSetValue; -}; - -HashArrayMapNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { - if (keyHash === undefined) { - keyHash = hash(key); - } - var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK; - var removed = value === NOT_SET; - var nodes = this.nodes; - var node = nodes[idx]; - - if (removed && !node) { - return this; - } - - var newNode = updateNode( - node, - ownerID, - shift + SHIFT, - keyHash, - key, - value, - didChangeSize, - didAlter - ); - if (newNode === node) { - return this; - } - - var newCount = this.count; - if (!node) { - newCount++; - } else if (!newNode) { - newCount--; - if (newCount < MIN_HASH_ARRAY_MAP_SIZE) { - return packNodes(ownerID, nodes, newCount, idx); - } - } - - var isEditable = ownerID && ownerID === this.ownerID; - var newNodes = setAt(nodes, idx, newNode, isEditable); - - if (isEditable) { - this.count = newCount; - this.nodes = newNodes; - return this; - } - - return new HashArrayMapNode(ownerID, newCount, newNodes); -}; - -var HashCollisionNode = function HashCollisionNode(ownerID, keyHash, entries) { - this.ownerID = ownerID; - this.keyHash = keyHash; - this.entries = entries; -}; - -HashCollisionNode.prototype.get = function get (shift, keyHash, key, notSetValue) { - var entries = this.entries; - for (var ii = 0, len = entries.length; ii < len; ii++) { - if (is(key, entries[ii][0])) { - return entries[ii][1]; - } - } - return notSetValue; -}; - -HashCollisionNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { - if (keyHash === undefined) { - keyHash = hash(key); - } - - var removed = value === NOT_SET; - - if (keyHash !== this.keyHash) { - if (removed) { - return this; - } - SetRef(didAlter); - SetRef(didChangeSize); - return mergeIntoNode(this, ownerID, shift, keyHash, [key, value]); - } - - var entries = this.entries; - var idx = 0; - var len = entries.length; - for (; idx < len; idx++) { - if (is(key, entries[idx][0])) { - break; - } - } - var exists = idx < len; - - if (exists ? entries[idx][1] === value : removed) { - return this; - } - - SetRef(didAlter); - (removed || !exists) && SetRef(didChangeSize); - - if (removed && len === 2) { - return new ValueNode(ownerID, this.keyHash, entries[idx ^ 1]); - } - - var isEditable = ownerID && ownerID === this.ownerID; - var newEntries = isEditable ? entries : arrCopy(entries); - - if (exists) { - if (removed) { - idx === len - 1 - ? newEntries.pop() - : (newEntries[idx] = newEntries.pop()); - } else { - newEntries[idx] = [key, value]; - } - } else { - newEntries.push([key, value]); - } - - if (isEditable) { - this.entries = newEntries; - return this; - } - - return new HashCollisionNode(ownerID, this.keyHash, newEntries); -}; - -var ValueNode = function ValueNode(ownerID, keyHash, entry) { - this.ownerID = ownerID; - this.keyHash = keyHash; - this.entry = entry; -}; - -ValueNode.prototype.get = function get (shift, keyHash, key, notSetValue) { - return is(key, this.entry[0]) ? this.entry[1] : notSetValue; -}; - -ValueNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { - var removed = value === NOT_SET; - var keyMatch = is(key, this.entry[0]); - if (keyMatch ? value === this.entry[1] : removed) { - return this; - } - - SetRef(didAlter); - - if (removed) { - SetRef(didChangeSize); - return; // undefined - } - - if (keyMatch) { - if (ownerID && ownerID === this.ownerID) { - this.entry[1] = value; - return this; - } - return new ValueNode(ownerID, this.keyHash, [key, value]); - } - - SetRef(didChangeSize); - return mergeIntoNode(this, ownerID, shift, hash(key), [key, value]); -}; - -// #pragma Iterators - -ArrayMapNode.prototype.iterate = HashCollisionNode.prototype.iterate = - function (fn, reverse) { - var entries = this.entries; - for (var ii = 0, maxIndex = entries.length - 1; ii <= maxIndex; ii++) { - if (fn(entries[reverse ? maxIndex - ii : ii]) === false) { - return false; - } - } - }; - -BitmapIndexedNode.prototype.iterate = HashArrayMapNode.prototype.iterate = - function (fn, reverse) { - var nodes = this.nodes; - for (var ii = 0, maxIndex = nodes.length - 1; ii <= maxIndex; ii++) { - var node = nodes[reverse ? maxIndex - ii : ii]; - if (node && node.iterate(fn, reverse) === false) { - return false; - } - } - }; - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -ValueNode.prototype.iterate = function (fn, reverse) { - return fn(this.entry); -}; - -var MapIterator = /*@__PURE__*/(function (Iterator) { - function MapIterator(map, type, reverse) { - this._type = type; - this._reverse = reverse; - this._stack = map._root && mapIteratorFrame(map._root); - } - - if ( Iterator ) MapIterator.__proto__ = Iterator; - MapIterator.prototype = Object.create( Iterator && Iterator.prototype ); - MapIterator.prototype.constructor = MapIterator; - - MapIterator.prototype.next = function next () { - var type = this._type; - var stack = this._stack; - while (stack) { - var node = stack.node; - var index = stack.index++; - var maxIndex = (void 0); - if (node.entry) { - if (index === 0) { - return mapIteratorValue(type, node.entry); - } - } else if (node.entries) { - maxIndex = node.entries.length - 1; - if (index <= maxIndex) { - return mapIteratorValue( - type, - node.entries[this._reverse ? maxIndex - index : index] - ); - } - } else { - maxIndex = node.nodes.length - 1; - if (index <= maxIndex) { - var subNode = node.nodes[this._reverse ? maxIndex - index : index]; - if (subNode) { - if (subNode.entry) { - return mapIteratorValue(type, subNode.entry); - } - stack = this._stack = mapIteratorFrame(subNode, stack); - } - continue; - } - } - stack = this._stack = this._stack.__prev; - } - return iteratorDone(); - }; - - return MapIterator; -}(Iterator)); - -function mapIteratorValue(type, entry) { - return iteratorValue(type, entry[0], entry[1]); -} - -function mapIteratorFrame(node, prev) { - return { - node: node, - index: 0, - __prev: prev, - }; -} - -function makeMap(size, root, ownerID, hash) { - var map = Object.create(MapPrototype); - map.size = size; - map._root = root; - map.__ownerID = ownerID; - map.__hash = hash; - map.__altered = false; - return map; -} - -var EMPTY_MAP; -function emptyMap() { - return EMPTY_MAP || (EMPTY_MAP = makeMap(0)); -} - -function updateMap(map, k, v) { - var newRoot; - var newSize; - if (!map._root) { - if (v === NOT_SET) { - return map; - } - newSize = 1; - newRoot = new ArrayMapNode(map.__ownerID, [[k, v]]); - } else { - var didChangeSize = MakeRef(); - var didAlter = MakeRef(); - newRoot = updateNode( - map._root, - map.__ownerID, - 0, - undefined, - k, - v, - didChangeSize, - didAlter - ); - if (!didAlter.value) { - return map; - } - newSize = map.size + (didChangeSize.value ? (v === NOT_SET ? -1 : 1) : 0); - } - if (map.__ownerID) { - map.size = newSize; - map._root = newRoot; - map.__hash = undefined; - map.__altered = true; - return map; - } - return newRoot ? makeMap(newSize, newRoot) : emptyMap(); -} - -function updateNode( - node, - ownerID, - shift, - keyHash, - key, - value, - didChangeSize, - didAlter -) { - if (!node) { - if (value === NOT_SET) { - return node; - } - SetRef(didAlter); - SetRef(didChangeSize); - return new ValueNode(ownerID, keyHash, [key, value]); - } - return node.update( - ownerID, - shift, - keyHash, - key, - value, - didChangeSize, - didAlter - ); -} - -function isLeafNode(node) { - return ( - node.constructor === ValueNode || node.constructor === HashCollisionNode - ); -} - -function mergeIntoNode(node, ownerID, shift, keyHash, entry) { - if (node.keyHash === keyHash) { - return new HashCollisionNode(ownerID, keyHash, [node.entry, entry]); - } - - var idx1 = (shift === 0 ? node.keyHash : node.keyHash >>> shift) & MASK; - var idx2 = (shift === 0 ? keyHash : keyHash >>> shift) & MASK; - - var newNode; - var nodes = - idx1 === idx2 - ? [mergeIntoNode(node, ownerID, shift + SHIFT, keyHash, entry)] - : ((newNode = new ValueNode(ownerID, keyHash, entry)), - idx1 < idx2 ? [node, newNode] : [newNode, node]); - - return new BitmapIndexedNode(ownerID, (1 << idx1) | (1 << idx2), nodes); -} - -function createNodes(ownerID, entries, key, value) { - if (!ownerID) { - ownerID = new OwnerID(); - } - var node = new ValueNode(ownerID, hash(key), [key, value]); - for (var ii = 0; ii < entries.length; ii++) { - var entry = entries[ii]; - node = node.update(ownerID, 0, undefined, entry[0], entry[1]); - } - return node; -} - -function packNodes(ownerID, nodes, count, excluding) { - var bitmap = 0; - var packedII = 0; - var packedNodes = new Array(count); - for (var ii = 0, bit = 1, len = nodes.length; ii < len; ii++, bit <<= 1) { - var node = nodes[ii]; - if (node !== undefined && ii !== excluding) { - bitmap |= bit; - packedNodes[packedII++] = node; - } - } - return new BitmapIndexedNode(ownerID, bitmap, packedNodes); -} - -function expandNodes(ownerID, nodes, bitmap, including, node) { - var count = 0; - var expandedNodes = new Array(SIZE); - for (var ii = 0; bitmap !== 0; ii++, bitmap >>>= 1) { - expandedNodes[ii] = bitmap & 1 ? nodes[count++] : undefined; - } - expandedNodes[including] = node; - return new HashArrayMapNode(ownerID, count + 1, expandedNodes); -} - -function popCount(x) { - x -= (x >> 1) & 0x55555555; - x = (x & 0x33333333) + ((x >> 2) & 0x33333333); - x = (x + (x >> 4)) & 0x0f0f0f0f; - x += x >> 8; - x += x >> 16; - return x & 0x7f; -} - -function setAt(array, idx, val, canEdit) { - var newArray = canEdit ? array : arrCopy(array); - newArray[idx] = val; - return newArray; -} - -function spliceIn(array, idx, val, canEdit) { - var newLen = array.length + 1; - if (canEdit && idx + 1 === newLen) { - array[idx] = val; - return array; - } - var newArray = new Array(newLen); - var after = 0; - for (var ii = 0; ii < newLen; ii++) { - if (ii === idx) { - newArray[ii] = val; - after = -1; - } else { - newArray[ii] = array[ii + after]; - } - } - return newArray; -} - -function spliceOut(array, idx, canEdit) { - var newLen = array.length - 1; - if (canEdit && idx === newLen) { - array.pop(); - return array; - } - var newArray = new Array(newLen); - var after = 0; - for (var ii = 0; ii < newLen; ii++) { - if (ii === idx) { - after = 1; - } - newArray[ii] = array[ii + after]; - } - return newArray; -} - -var MAX_ARRAY_MAP_SIZE = SIZE / 4; -var MAX_BITMAP_INDEXED_SIZE = SIZE / 2; -var MIN_HASH_ARRAY_MAP_SIZE = SIZE / 4; - -export { Map, emptyMap }; diff --git a/dist/es/Math.js b/dist/es/Math.js deleted file mode 100644 index ffc262ee6b..0000000000 --- a/dist/es/Math.js +++ /dev/null @@ -1,45 +0,0 @@ -/** - * @license - * MIT License - * - * Copyright (c) 2014-present, Lee Byron and other contributors. - * - * 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: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -var imul = - typeof Math.imul === 'function' && Math.imul(0xffffffff, 2) === -2 - ? Math.imul - : function imul(a, b) { - a |= 0; // int - b |= 0; // int - var c = a & 0xffff; - var d = b & 0xffff; - // Shift by 0 fixes the sign on the high part. - return (c * d + ((((a >>> 16) * d + c * (b >>> 16)) << 16) >>> 0)) | 0; // int - }; - -// v8 has an optimization for storing 31-bit signed numbers. -// Values which have either 00 or 11 as the high order bits qualify. -// This function drops the highest order bit in a signed number, maintaining -// the sign bit. -function smi(i32) { - return ((i32 >>> 1) & 0x40000000) | (i32 & 0xbfffffff); -} - -export { imul, smi }; diff --git a/dist/es/Operations.js b/dist/es/Operations.js deleted file mode 100644 index a4c5cf9fa5..0000000000 --- a/dist/es/Operations.js +++ /dev/null @@ -1,953 +0,0 @@ -/** - * @license - * MIT License - * - * Copyright (c) 2014-present, Lee Byron and other contributors. - * - * 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: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -import { ensureSize, NOT_SET, wholeSlice, wrapIndex, resolveBegin, resolveEnd } from './TrieUtils.js'; -import { KeyedCollection, Collection, IndexedCollection, SetCollection } from './Collection.js'; -import { isCollection } from './predicates/isCollection.js'; -import { isKeyed } from './predicates/isKeyed.js'; -import { isIndexed } from './predicates/isIndexed.js'; -import { IS_ORDERED_SYMBOL, isOrdered } from './predicates/isOrdered.js'; -import { isSeq } from './predicates/isSeq.js'; -import { ITERATE_VALUES, Iterator, iteratorValue, ITERATE_ENTRIES, ITERATE_KEYS, iteratorDone, getIterator } from './Iterator.js'; -import { KeyedSeq, IndexedSeq, SetSeq, keyedSeqFromValue, indexedSeqFromValue, ArraySeq, Seq } from './Seq.js'; -import { Map } from './Map.js'; -import { OrderedMap } from './OrderedMap.js'; - -var ToKeyedSequence = /*@__PURE__*/(function (KeyedSeq) { - function ToKeyedSequence(indexed, useKeys) { - this._iter = indexed; - this._useKeys = useKeys; - this.size = indexed.size; - } - - if ( KeyedSeq ) ToKeyedSequence.__proto__ = KeyedSeq; - ToKeyedSequence.prototype = Object.create( KeyedSeq && KeyedSeq.prototype ); - ToKeyedSequence.prototype.constructor = ToKeyedSequence; - - ToKeyedSequence.prototype.get = function get (key, notSetValue) { - return this._iter.get(key, notSetValue); - }; - - ToKeyedSequence.prototype.has = function has (key) { - return this._iter.has(key); - }; - - ToKeyedSequence.prototype.valueSeq = function valueSeq () { - return this._iter.valueSeq(); - }; - - ToKeyedSequence.prototype.reverse = function reverse () { - var this$1$1 = this; - - var reversedSequence = reverseFactory(this, true); - if (!this._useKeys) { - reversedSequence.valueSeq = function () { return this$1$1._iter.toSeq().reverse(); }; - } - return reversedSequence; - }; - - ToKeyedSequence.prototype.map = function map (mapper, context) { - var this$1$1 = this; - - var mappedSequence = mapFactory(this, mapper, context); - if (!this._useKeys) { - mappedSequence.valueSeq = function () { return this$1$1._iter.toSeq().map(mapper, context); }; - } - return mappedSequence; - }; - - ToKeyedSequence.prototype.__iterate = function __iterate (fn, reverse) { - var this$1$1 = this; - - return this._iter.__iterate(function (v, k) { return fn(v, k, this$1$1); }, reverse); - }; - - ToKeyedSequence.prototype.__iterator = function __iterator (type, reverse) { - return this._iter.__iterator(type, reverse); - }; - - return ToKeyedSequence; -}(KeyedSeq)); -ToKeyedSequence.prototype[IS_ORDERED_SYMBOL] = true; - -var ToIndexedSequence = /*@__PURE__*/(function (IndexedSeq) { - function ToIndexedSequence(iter) { - this._iter = iter; - this.size = iter.size; - } - - if ( IndexedSeq ) ToIndexedSequence.__proto__ = IndexedSeq; - ToIndexedSequence.prototype = Object.create( IndexedSeq && IndexedSeq.prototype ); - ToIndexedSequence.prototype.constructor = ToIndexedSequence; - - ToIndexedSequence.prototype.includes = function includes (value) { - return this._iter.includes(value); - }; - - ToIndexedSequence.prototype.__iterate = function __iterate (fn, reverse) { - var this$1$1 = this; - - var i = 0; - reverse && ensureSize(this); - return this._iter.__iterate( - function (v) { return fn(v, reverse ? this$1$1.size - ++i : i++, this$1$1); }, - reverse - ); - }; - - ToIndexedSequence.prototype.__iterator = function __iterator (type, reverse) { - var this$1$1 = this; - - var iterator = this._iter.__iterator(ITERATE_VALUES, reverse); - var i = 0; - reverse && ensureSize(this); - return new Iterator(function () { - var step = iterator.next(); - return step.done - ? step - : iteratorValue( - type, - reverse ? this$1$1.size - ++i : i++, - step.value, - step - ); - }); - }; - - return ToIndexedSequence; -}(IndexedSeq)); - -var ToSetSequence = /*@__PURE__*/(function (SetSeq) { - function ToSetSequence(iter) { - this._iter = iter; - this.size = iter.size; - } - - if ( SetSeq ) ToSetSequence.__proto__ = SetSeq; - ToSetSequence.prototype = Object.create( SetSeq && SetSeq.prototype ); - ToSetSequence.prototype.constructor = ToSetSequence; - - ToSetSequence.prototype.has = function has (key) { - return this._iter.includes(key); - }; - - ToSetSequence.prototype.__iterate = function __iterate (fn, reverse) { - var this$1$1 = this; - - return this._iter.__iterate(function (v) { return fn(v, v, this$1$1); }, reverse); - }; - - ToSetSequence.prototype.__iterator = function __iterator (type, reverse) { - var iterator = this._iter.__iterator(ITERATE_VALUES, reverse); - return new Iterator(function () { - var step = iterator.next(); - return step.done - ? step - : iteratorValue(type, step.value, step.value, step); - }); - }; - - return ToSetSequence; -}(SetSeq)); - -var FromEntriesSequence = /*@__PURE__*/(function (KeyedSeq) { - function FromEntriesSequence(entries) { - this._iter = entries; - this.size = entries.size; - } - - if ( KeyedSeq ) FromEntriesSequence.__proto__ = KeyedSeq; - FromEntriesSequence.prototype = Object.create( KeyedSeq && KeyedSeq.prototype ); - FromEntriesSequence.prototype.constructor = FromEntriesSequence; - - FromEntriesSequence.prototype.entrySeq = function entrySeq () { - return this._iter.toSeq(); - }; - - FromEntriesSequence.prototype.__iterate = function __iterate (fn, reverse) { - var this$1$1 = this; - - return this._iter.__iterate(function (entry) { - // Check if entry exists first so array access doesn't throw for holes - // in the parent iteration. - if (entry) { - validateEntry(entry); - var indexedCollection = isCollection(entry); - return fn( - indexedCollection ? entry.get(1) : entry[1], - indexedCollection ? entry.get(0) : entry[0], - this$1$1 - ); - } - }, reverse); - }; - - FromEntriesSequence.prototype.__iterator = function __iterator (type, reverse) { - var iterator = this._iter.__iterator(ITERATE_VALUES, reverse); - return new Iterator(function () { - while (true) { - var step = iterator.next(); - if (step.done) { - return step; - } - var entry = step.value; - // Check if entry exists first so array access doesn't throw for holes - // in the parent iteration. - if (entry) { - validateEntry(entry); - var indexedCollection = isCollection(entry); - return iteratorValue( - type, - indexedCollection ? entry.get(0) : entry[0], - indexedCollection ? entry.get(1) : entry[1], - step - ); - } - } - }); - }; - - return FromEntriesSequence; -}(KeyedSeq)); - -ToIndexedSequence.prototype.cacheResult = - ToKeyedSequence.prototype.cacheResult = - ToSetSequence.prototype.cacheResult = - FromEntriesSequence.prototype.cacheResult = - cacheResultThrough; - -function flipFactory(collection) { - var flipSequence = makeSequence(collection); - flipSequence._iter = collection; - flipSequence.size = collection.size; - flipSequence.flip = function () { return collection; }; - flipSequence.reverse = function () { - var reversedSequence = collection.reverse.apply(this); // super.reverse() - reversedSequence.flip = function () { return collection.reverse(); }; - return reversedSequence; - }; - flipSequence.has = function (key) { return collection.includes(key); }; - flipSequence.includes = function (key) { return collection.has(key); }; - flipSequence.cacheResult = cacheResultThrough; - flipSequence.__iterateUncached = function (fn, reverse) { - var this$1$1 = this; - - return collection.__iterate(function (v, k) { return fn(k, v, this$1$1) !== false; }, reverse); - }; - flipSequence.__iteratorUncached = function (type, reverse) { - if (type === ITERATE_ENTRIES) { - var iterator = collection.__iterator(type, reverse); - return new Iterator(function () { - var step = iterator.next(); - if (!step.done) { - var k = step.value[0]; - step.value[0] = step.value[1]; - step.value[1] = k; - } - return step; - }); - } - return collection.__iterator( - type === ITERATE_VALUES ? ITERATE_KEYS : ITERATE_VALUES, - reverse - ); - }; - return flipSequence; -} - -function mapFactory(collection, mapper, context) { - var mappedSequence = makeSequence(collection); - mappedSequence.size = collection.size; - mappedSequence.has = function (key) { return collection.has(key); }; - mappedSequence.get = function (key, notSetValue) { - var v = collection.get(key, NOT_SET); - return v === NOT_SET - ? notSetValue - : mapper.call(context, v, key, collection); - }; - mappedSequence.__iterateUncached = function (fn, reverse) { - var this$1$1 = this; - - return collection.__iterate( - function (v, k, c) { return fn(mapper.call(context, v, k, c), k, this$1$1) !== false; }, - reverse - ); - }; - mappedSequence.__iteratorUncached = function (type, reverse) { - var iterator = collection.__iterator(ITERATE_ENTRIES, reverse); - return new Iterator(function () { - var step = iterator.next(); - if (step.done) { - return step; - } - var entry = step.value; - var key = entry[0]; - return iteratorValue( - type, - key, - mapper.call(context, entry[1], key, collection), - step - ); - }); - }; - return mappedSequence; -} - -function reverseFactory(collection, useKeys) { - var this$1$1 = this; - - var reversedSequence = makeSequence(collection); - reversedSequence._iter = collection; - reversedSequence.size = collection.size; - reversedSequence.reverse = function () { return collection; }; - if (collection.flip) { - reversedSequence.flip = function () { - var flipSequence = flipFactory(collection); - flipSequence.reverse = function () { return collection.flip(); }; - return flipSequence; - }; - } - reversedSequence.get = function (key, notSetValue) { return collection.get(useKeys ? key : -1 - key, notSetValue); }; - reversedSequence.has = function (key) { return collection.has(useKeys ? key : -1 - key); }; - reversedSequence.includes = function (value) { return collection.includes(value); }; - reversedSequence.cacheResult = cacheResultThrough; - reversedSequence.__iterate = function (fn, reverse) { - var this$1$1 = this; - - var i = 0; - reverse && ensureSize(collection); - return collection.__iterate( - function (v, k) { return fn(v, useKeys ? k : reverse ? this$1$1.size - ++i : i++, this$1$1); }, - !reverse - ); - }; - reversedSequence.__iterator = function (type, reverse) { - var i = 0; - reverse && ensureSize(collection); - var iterator = collection.__iterator(ITERATE_ENTRIES, !reverse); - return new Iterator(function () { - var step = iterator.next(); - if (step.done) { - return step; - } - var entry = step.value; - return iteratorValue( - type, - useKeys ? entry[0] : reverse ? this$1$1.size - ++i : i++, - entry[1], - step - ); - }); - }; - return reversedSequence; -} - -function filterFactory(collection, predicate, context, useKeys) { - var filterSequence = makeSequence(collection); - if (useKeys) { - filterSequence.has = function (key) { - var v = collection.get(key, NOT_SET); - return v !== NOT_SET && !!predicate.call(context, v, key, collection); - }; - filterSequence.get = function (key, notSetValue) { - var v = collection.get(key, NOT_SET); - return v !== NOT_SET && predicate.call(context, v, key, collection) - ? v - : notSetValue; - }; - } - filterSequence.__iterateUncached = function (fn, reverse) { - var this$1$1 = this; - - var iterations = 0; - collection.__iterate(function (v, k, c) { - if (predicate.call(context, v, k, c)) { - iterations++; - return fn(v, useKeys ? k : iterations - 1, this$1$1); - } - }, reverse); - return iterations; - }; - filterSequence.__iteratorUncached = function (type, reverse) { - var iterator = collection.__iterator(ITERATE_ENTRIES, reverse); - var iterations = 0; - return new Iterator(function () { - while (true) { - var step = iterator.next(); - if (step.done) { - return step; - } - var entry = step.value; - var key = entry[0]; - var value = entry[1]; - if (predicate.call(context, value, key, collection)) { - return iteratorValue(type, useKeys ? key : iterations++, value, step); - } - } - }); - }; - return filterSequence; -} - -function countByFactory(collection, grouper, context) { - var groups = Map().asMutable(); - collection.__iterate(function (v, k) { - groups.update(grouper.call(context, v, k, collection), 0, function (a) { return a + 1; }); - }); - return groups.asImmutable(); -} - -function groupByFactory(collection, grouper, context) { - var isKeyedIter = isKeyed(collection); - var groups = (isOrdered(collection) ? OrderedMap() : Map()).asMutable(); - collection.__iterate(function (v, k) { - groups.update( - grouper.call(context, v, k, collection), - function (a) { return ((a = a || []), a.push(isKeyedIter ? [k, v] : v), a); } - ); - }); - var coerce = collectionClass(collection); - return groups.map(function (arr) { return reify(collection, coerce(arr)); }).asImmutable(); -} - -function partitionFactory(collection, predicate, context) { - var isKeyedIter = isKeyed(collection); - var groups = [[], []]; - collection.__iterate(function (v, k) { - groups[predicate.call(context, v, k, collection) ? 1 : 0].push( - isKeyedIter ? [k, v] : v - ); - }); - var coerce = collectionClass(collection); - return groups.map(function (arr) { return reify(collection, coerce(arr)); }); -} - -function sliceFactory(collection, begin, end, useKeys) { - var originalSize = collection.size; - - if (wholeSlice(begin, end, originalSize)) { - return collection; - } - - // begin or end can not be resolved if they were provided as negative numbers and - // this collection's size is unknown. In that case, cache first so there is - // a known size and these do not resolve to NaN. - if (typeof originalSize === 'undefined' && (begin < 0 || end < 0)) { - return sliceFactory(collection.toSeq().cacheResult(), begin, end, useKeys); - } - - var resolvedBegin = resolveBegin(begin, originalSize); - var resolvedEnd = resolveEnd(end, originalSize); - - // Note: resolvedEnd is undefined when the original sequence's length is - // unknown and this slice did not supply an end and should contain all - // elements after resolvedBegin. - // In that case, resolvedSize will be NaN and sliceSize will remain undefined. - var resolvedSize = resolvedEnd - resolvedBegin; - var sliceSize; - if (resolvedSize === resolvedSize) { - sliceSize = resolvedSize < 0 ? 0 : resolvedSize; - } - - var sliceSeq = makeSequence(collection); - - // If collection.size is undefined, the size of the realized sliceSeq is - // unknown at this point unless the number of items to slice is 0 - sliceSeq.size = - sliceSize === 0 ? sliceSize : (collection.size && sliceSize) || undefined; - - if (!useKeys && isSeq(collection) && sliceSize >= 0) { - sliceSeq.get = function (index, notSetValue) { - index = wrapIndex(this, index); - return index >= 0 && index < sliceSize - ? collection.get(index + resolvedBegin, notSetValue) - : notSetValue; - }; - } - - sliceSeq.__iterateUncached = function (fn, reverse) { - var this$1$1 = this; - - if (sliceSize === 0) { - return 0; - } - if (reverse) { - return this.cacheResult().__iterate(fn, reverse); - } - var skipped = 0; - var isSkipping = true; - var iterations = 0; - collection.__iterate(function (v, k) { - if (!(isSkipping && (isSkipping = skipped++ < resolvedBegin))) { - iterations++; - return ( - fn(v, useKeys ? k : iterations - 1, this$1$1) !== false && - iterations !== sliceSize - ); - } - }); - return iterations; - }; - - sliceSeq.__iteratorUncached = function (type, reverse) { - if (sliceSize !== 0 && reverse) { - return this.cacheResult().__iterator(type, reverse); - } - // Don't bother instantiating parent iterator if taking 0. - if (sliceSize === 0) { - return new Iterator(iteratorDone); - } - var iterator = collection.__iterator(type, reverse); - var skipped = 0; - var iterations = 0; - return new Iterator(function () { - while (skipped++ < resolvedBegin) { - iterator.next(); - } - if (++iterations > sliceSize) { - return iteratorDone(); - } - var step = iterator.next(); - if (useKeys || type === ITERATE_VALUES || step.done) { - return step; - } - if (type === ITERATE_KEYS) { - return iteratorValue(type, iterations - 1, undefined, step); - } - return iteratorValue(type, iterations - 1, step.value[1], step); - }); - }; - - return sliceSeq; -} - -function takeWhileFactory(collection, predicate, context) { - var takeSequence = makeSequence(collection); - takeSequence.__iterateUncached = function (fn, reverse) { - var this$1$1 = this; - - if (reverse) { - return this.cacheResult().__iterate(fn, reverse); - } - var iterations = 0; - collection.__iterate( - function (v, k, c) { return predicate.call(context, v, k, c) && ++iterations && fn(v, k, this$1$1); } - ); - return iterations; - }; - takeSequence.__iteratorUncached = function (type, reverse) { - var this$1$1 = this; - - if (reverse) { - return this.cacheResult().__iterator(type, reverse); - } - var iterator = collection.__iterator(ITERATE_ENTRIES, reverse); - var iterating = true; - return new Iterator(function () { - if (!iterating) { - return iteratorDone(); - } - var step = iterator.next(); - if (step.done) { - return step; - } - var entry = step.value; - var k = entry[0]; - var v = entry[1]; - if (!predicate.call(context, v, k, this$1$1)) { - iterating = false; - return iteratorDone(); - } - return type === ITERATE_ENTRIES ? step : iteratorValue(type, k, v, step); - }); - }; - return takeSequence; -} - -function skipWhileFactory(collection, predicate, context, useKeys) { - var skipSequence = makeSequence(collection); - skipSequence.__iterateUncached = function (fn, reverse) { - var this$1$1 = this; - - if (reverse) { - return this.cacheResult().__iterate(fn, reverse); - } - var isSkipping = true; - var iterations = 0; - collection.__iterate(function (v, k, c) { - if (!(isSkipping && (isSkipping = predicate.call(context, v, k, c)))) { - iterations++; - return fn(v, useKeys ? k : iterations - 1, this$1$1); - } - }); - return iterations; - }; - skipSequence.__iteratorUncached = function (type, reverse) { - var this$1$1 = this; - - if (reverse) { - return this.cacheResult().__iterator(type, reverse); - } - var iterator = collection.__iterator(ITERATE_ENTRIES, reverse); - var skipping = true; - var iterations = 0; - return new Iterator(function () { - var step; - var k; - var v; - do { - step = iterator.next(); - if (step.done) { - if (useKeys || type === ITERATE_VALUES) { - return step; - } - if (type === ITERATE_KEYS) { - return iteratorValue(type, iterations++, undefined, step); - } - return iteratorValue(type, iterations++, step.value[1], step); - } - var entry = step.value; - k = entry[0]; - v = entry[1]; - skipping && (skipping = predicate.call(context, v, k, this$1$1)); - } while (skipping); - return type === ITERATE_ENTRIES ? step : iteratorValue(type, k, v, step); - }); - }; - return skipSequence; -} - -function concatFactory(collection, values) { - var isKeyedCollection = isKeyed(collection); - var iters = [collection] - .concat(values) - .map(function (v) { - if (!isCollection(v)) { - v = isKeyedCollection - ? keyedSeqFromValue(v) - : indexedSeqFromValue(Array.isArray(v) ? v : [v]); - } else if (isKeyedCollection) { - v = KeyedCollection(v); - } - return v; - }) - .filter(function (v) { return v.size !== 0; }); - - if (iters.length === 0) { - return collection; - } - - if (iters.length === 1) { - var singleton = iters[0]; - if ( - singleton === collection || - (isKeyedCollection && isKeyed(singleton)) || - (isIndexed(collection) && isIndexed(singleton)) - ) { - return singleton; - } - } - - var concatSeq = new ArraySeq(iters); - if (isKeyedCollection) { - concatSeq = concatSeq.toKeyedSeq(); - } else if (!isIndexed(collection)) { - concatSeq = concatSeq.toSetSeq(); - } - concatSeq = concatSeq.flatten(true); - concatSeq.size = iters.reduce(function (sum, seq) { - if (sum !== undefined) { - var size = seq.size; - if (size !== undefined) { - return sum + size; - } - } - }, 0); - return concatSeq; -} - -function flattenFactory(collection, depth, useKeys) { - var flatSequence = makeSequence(collection); - flatSequence.__iterateUncached = function (fn, reverse) { - if (reverse) { - return this.cacheResult().__iterate(fn, reverse); - } - var iterations = 0; - var stopped = false; - function flatDeep(iter, currentDepth) { - iter.__iterate(function (v, k) { - if ((!depth || currentDepth < depth) && isCollection(v)) { - flatDeep(v, currentDepth + 1); - } else { - iterations++; - if (fn(v, useKeys ? k : iterations - 1, flatSequence) === false) { - stopped = true; - } - } - return !stopped; - }, reverse); - } - flatDeep(collection, 0); - return iterations; - }; - flatSequence.__iteratorUncached = function (type, reverse) { - if (reverse) { - return this.cacheResult().__iterator(type, reverse); - } - var iterator = collection.__iterator(type, reverse); - var stack = []; - var iterations = 0; - return new Iterator(function () { - while (iterator) { - var step = iterator.next(); - if (step.done !== false) { - iterator = stack.pop(); - continue; - } - var v = step.value; - if (type === ITERATE_ENTRIES) { - v = v[1]; - } - if ((!depth || stack.length < depth) && isCollection(v)) { - stack.push(iterator); - iterator = v.__iterator(type, reverse); - } else { - return useKeys ? step : iteratorValue(type, iterations++, v, step); - } - } - return iteratorDone(); - }); - }; - return flatSequence; -} - -function flatMapFactory(collection, mapper, context) { - var coerce = collectionClass(collection); - return collection - .toSeq() - .map(function (v, k) { return coerce(mapper.call(context, v, k, collection)); }) - .flatten(true); -} - -function interposeFactory(collection, separator) { - var interposedSequence = makeSequence(collection); - interposedSequence.size = collection.size && collection.size * 2 - 1; - interposedSequence.__iterateUncached = function (fn, reverse) { - var this$1$1 = this; - - var iterations = 0; - collection.__iterate( - function (v) { return (!iterations || fn(separator, iterations++, this$1$1) !== false) && - fn(v, iterations++, this$1$1) !== false; }, - reverse - ); - return iterations; - }; - interposedSequence.__iteratorUncached = function (type, reverse) { - var iterator = collection.__iterator(ITERATE_VALUES, reverse); - var iterations = 0; - var step; - return new Iterator(function () { - if (!step || iterations % 2) { - step = iterator.next(); - if (step.done) { - return step; - } - } - return iterations % 2 - ? iteratorValue(type, iterations++, separator) - : iteratorValue(type, iterations++, step.value, step); - }); - }; - return interposedSequence; -} - -function sortFactory(collection, comparator, mapper) { - if (!comparator) { - comparator = defaultComparator; - } - var isKeyedCollection = isKeyed(collection); - var index = 0; - var entries = collection - .toSeq() - .map(function (v, k) { return [k, v, index++, mapper ? mapper(v, k, collection) : v]; }) - .valueSeq() - .toArray(); - entries - .sort(function (a, b) { return comparator(a[3], b[3]) || a[2] - b[2]; }) - .forEach( - isKeyedCollection - ? function (v, i) { - entries[i].length = 2; - } - : function (v, i) { - entries[i] = v[1]; - } - ); - return isKeyedCollection - ? KeyedSeq(entries) - : isIndexed(collection) - ? IndexedSeq(entries) - : SetSeq(entries); -} - -function maxFactory(collection, comparator, mapper) { - if (!comparator) { - comparator = defaultComparator; - } - if (mapper) { - var entry = collection - .toSeq() - .map(function (v, k) { return [v, mapper(v, k, collection)]; }) - .reduce(function (a, b) { return (maxCompare(comparator, a[1], b[1]) ? b : a); }); - return entry && entry[0]; - } - return collection.reduce(function (a, b) { return (maxCompare(comparator, a, b) ? b : a); }); -} - -function maxCompare(comparator, a, b) { - var comp = comparator(b, a); - // b is considered the new max if the comparator declares them equal, but - // they are not equal and b is in fact a nullish value. - return ( - (comp === 0 && b !== a && (b === undefined || b === null || b !== b)) || - comp > 0 - ); -} - -function zipWithFactory(keyIter, zipper, iters, zipAll) { - var zipSequence = makeSequence(keyIter); - var sizes = new ArraySeq(iters).map(function (i) { return i.size; }); - zipSequence.size = zipAll ? sizes.max() : sizes.min(); - // Note: this a generic base implementation of __iterate in terms of - // __iterator which may be more generically useful in the future. - zipSequence.__iterate = function (fn, reverse) { - /* generic: - var iterator = this.__iterator(ITERATE_ENTRIES, reverse); - var step; - var iterations = 0; - while (!(step = iterator.next()).done) { - iterations++; - if (fn(step.value[1], step.value[0], this) === false) { - break; - } - } - return iterations; - */ - // indexed: - var iterator = this.__iterator(ITERATE_VALUES, reverse); - var step; - var iterations = 0; - while (!(step = iterator.next()).done) { - if (fn(step.value, iterations++, this) === false) { - break; - } - } - return iterations; - }; - zipSequence.__iteratorUncached = function (type, reverse) { - var iterators = iters.map( - function (i) { return ((i = Collection(i)), getIterator(reverse ? i.reverse() : i)); } - ); - var iterations = 0; - var isDone = false; - return new Iterator(function () { - var steps; - if (!isDone) { - steps = iterators.map(function (i) { return i.next(); }); - isDone = zipAll ? steps.every(function (s) { return s.done; }) : steps.some(function (s) { return s.done; }); - } - if (isDone) { - return iteratorDone(); - } - return iteratorValue( - type, - iterations++, - zipper.apply( - null, - steps.map(function (s) { return s.value; }) - ) - ); - }); - }; - return zipSequence; -} - -// #pragma Helper Functions - -function reify(iter, seq) { - return iter === seq ? iter : isSeq(iter) ? seq : iter.constructor(seq); -} - -function validateEntry(entry) { - if (entry !== Object(entry)) { - throw new TypeError('Expected [K, V] tuple: ' + entry); - } -} - -function collectionClass(collection) { - return isKeyed(collection) - ? KeyedCollection - : isIndexed(collection) - ? IndexedCollection - : SetCollection; -} - -function makeSequence(collection) { - return Object.create( - (isKeyed(collection) - ? KeyedSeq - : isIndexed(collection) - ? IndexedSeq - : SetSeq - ).prototype - ); -} - -function cacheResultThrough() { - if (this._iter.cacheResult) { - this._iter.cacheResult(); - this.size = this._iter.size; - return this; - } - return Seq.prototype.cacheResult.call(this); -} - -function defaultComparator(a, b) { - if (a === undefined && b === undefined) { - return 0; - } - - if (a === undefined) { - return 1; - } - - if (b === undefined) { - return -1; - } - - return a > b ? 1 : a < b ? -1 : 0; -} - -export { FromEntriesSequence, ToIndexedSequence, ToKeyedSequence, ToSetSequence, concatFactory, countByFactory, filterFactory, flatMapFactory, flattenFactory, flipFactory, groupByFactory, interposeFactory, mapFactory, maxFactory, partitionFactory, reify, reverseFactory, skipWhileFactory, sliceFactory, sortFactory, takeWhileFactory, zipWithFactory }; diff --git a/dist/es/OrderedMap.js b/dist/es/OrderedMap.js deleted file mode 100644 index 09562161a3..0000000000 --- a/dist/es/OrderedMap.js +++ /dev/null @@ -1,196 +0,0 @@ -/** - * @license - * MIT License - * - * Copyright (c) 2014-present, Lee Byron and other contributors. - * - * 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: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -import { KeyedCollection } from './Collection.js'; -import { IS_ORDERED_SYMBOL } from './predicates/isOrdered.js'; -import { isOrderedMap } from './predicates/isOrderedMap.js'; -import { Map, emptyMap } from './Map.js'; -import { emptyList } from './List.js'; -import { DELETE, NOT_SET, SIZE } from './TrieUtils.js'; -import assertNotInfinite from './utils/assertNotInfinite.js'; - -var OrderedMap = /*@__PURE__*/(function (Map) { - function OrderedMap(value) { - // eslint-disable-next-line no-constructor-return - return value === undefined || value === null - ? emptyOrderedMap() - : isOrderedMap(value) - ? value - : emptyOrderedMap().withMutations(function (map) { - var iter = KeyedCollection(value); - assertNotInfinite(iter.size); - iter.forEach(function (v, k) { return map.set(k, v); }); - }); - } - - if ( Map ) OrderedMap.__proto__ = Map; - OrderedMap.prototype = Object.create( Map && Map.prototype ); - OrderedMap.prototype.constructor = OrderedMap; - - OrderedMap.of = function of (/*...values*/) { - return this(arguments); - }; - - OrderedMap.prototype.toString = function toString () { - return this.__toString('OrderedMap {', '}'); - }; - - // @pragma Access - - OrderedMap.prototype.get = function get (k, notSetValue) { - var index = this._map.get(k); - return index !== undefined ? this._list.get(index)[1] : notSetValue; - }; - - // @pragma Modification - - OrderedMap.prototype.clear = function clear () { - if (this.size === 0) { - return this; - } - if (this.__ownerID) { - this.size = 0; - this._map.clear(); - this._list.clear(); - this.__altered = true; - return this; - } - return emptyOrderedMap(); - }; - - OrderedMap.prototype.set = function set (k, v) { - return updateOrderedMap(this, k, v); - }; - - OrderedMap.prototype.remove = function remove (k) { - return updateOrderedMap(this, k, NOT_SET); - }; - - OrderedMap.prototype.__iterate = function __iterate (fn, reverse) { - var this$1$1 = this; - - return this._list.__iterate( - function (entry) { return entry && fn(entry[1], entry[0], this$1$1); }, - reverse - ); - }; - - OrderedMap.prototype.__iterator = function __iterator (type, reverse) { - return this._list.fromEntrySeq().__iterator(type, reverse); - }; - - OrderedMap.prototype.__ensureOwner = function __ensureOwner (ownerID) { - if (ownerID === this.__ownerID) { - return this; - } - var newMap = this._map.__ensureOwner(ownerID); - var newList = this._list.__ensureOwner(ownerID); - if (!ownerID) { - if (this.size === 0) { - return emptyOrderedMap(); - } - this.__ownerID = ownerID; - this.__altered = false; - this._map = newMap; - this._list = newList; - return this; - } - return makeOrderedMap(newMap, newList, ownerID, this.__hash); - }; - - return OrderedMap; -}(Map)); - -OrderedMap.isOrderedMap = isOrderedMap; - -OrderedMap.prototype[IS_ORDERED_SYMBOL] = true; -OrderedMap.prototype[DELETE] = OrderedMap.prototype.remove; - -function makeOrderedMap(map, list, ownerID, hash) { - var omap = Object.create(OrderedMap.prototype); - omap.size = map ? map.size : 0; - omap._map = map; - omap._list = list; - omap.__ownerID = ownerID; - omap.__hash = hash; - omap.__altered = false; - return omap; -} - -var EMPTY_ORDERED_MAP; -function emptyOrderedMap() { - return ( - EMPTY_ORDERED_MAP || - (EMPTY_ORDERED_MAP = makeOrderedMap(emptyMap(), emptyList())) - ); -} - -function updateOrderedMap(omap, k, v) { - var map = omap._map; - var list = omap._list; - var i = map.get(k); - var has = i !== undefined; - var newMap; - var newList; - if (v === NOT_SET) { - // removed - if (!has) { - return omap; - } - if (list.size >= SIZE && list.size >= map.size * 2) { - newList = list.filter(function (entry, idx) { return entry !== undefined && i !== idx; }); - newMap = newList - .toKeyedSeq() - .map(function (entry) { return entry[0]; }) - .flip() - .toMap(); - if (omap.__ownerID) { - newMap.__ownerID = newList.__ownerID = omap.__ownerID; - } - } else { - newMap = map.remove(k); - newList = i === list.size - 1 ? list.pop() : list.set(i, undefined); - } - } else if (has) { - if (v === list.get(i)[1]) { - return omap; - } - newMap = map; - newList = list.set(i, [k, v]); - } else { - newMap = map.set(k, list.size); - newList = list.set(list.size, [k, v]); - } - if (omap.__ownerID) { - omap.size = newMap.size; - omap._map = newMap; - omap._list = newList; - omap.__hash = undefined; - omap.__altered = true; - return omap; - } - return makeOrderedMap(newMap, newList); -} - -export { OrderedMap, emptyOrderedMap }; diff --git a/dist/es/OrderedSet.js b/dist/es/OrderedSet.js deleted file mode 100644 index b314a86493..0000000000 --- a/dist/es/OrderedSet.js +++ /dev/null @@ -1,92 +0,0 @@ -/** - * @license - * MIT License - * - * Copyright (c) 2014-present, Lee Byron and other contributors. - * - * 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: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -import { KeyedCollection, SetCollection } from './Collection.js'; -import { IS_ORDERED_SYMBOL } from './predicates/isOrdered.js'; -import { isOrderedSet } from './predicates/isOrderedSet.js'; -import { IndexedCollectionPrototype } from './CollectionImpl.js'; -import { Set } from './Set.js'; -import { emptyOrderedMap } from './OrderedMap.js'; -import assertNotInfinite from './utils/assertNotInfinite.js'; - -var OrderedSet = /*@__PURE__*/(function (Set) { - function OrderedSet(value) { - // eslint-disable-next-line no-constructor-return - return value === undefined || value === null - ? emptyOrderedSet() - : isOrderedSet(value) - ? value - : emptyOrderedSet().withMutations(function (set) { - var iter = SetCollection(value); - assertNotInfinite(iter.size); - iter.forEach(function (v) { return set.add(v); }); - }); - } - - if ( Set ) OrderedSet.__proto__ = Set; - OrderedSet.prototype = Object.create( Set && Set.prototype ); - OrderedSet.prototype.constructor = OrderedSet; - - OrderedSet.of = function of (/*...values*/) { - return this(arguments); - }; - - OrderedSet.fromKeys = function fromKeys (value) { - return this(KeyedCollection(value).keySeq()); - }; - - OrderedSet.prototype.toString = function toString () { - return this.__toString('OrderedSet {', '}'); - }; - - return OrderedSet; -}(Set)); - -OrderedSet.isOrderedSet = isOrderedSet; - -var OrderedSetPrototype = OrderedSet.prototype; -OrderedSetPrototype[IS_ORDERED_SYMBOL] = true; -OrderedSetPrototype.zip = IndexedCollectionPrototype.zip; -OrderedSetPrototype.zipWith = IndexedCollectionPrototype.zipWith; -OrderedSetPrototype.zipAll = IndexedCollectionPrototype.zipAll; - -OrderedSetPrototype.__empty = emptyOrderedSet; -OrderedSetPrototype.__make = makeOrderedSet; - -function makeOrderedSet(map, ownerID) { - var set = Object.create(OrderedSetPrototype); - set.size = map ? map.size : 0; - set._map = map; - set.__ownerID = ownerID; - return set; -} - -var EMPTY_ORDERED_SET; -function emptyOrderedSet() { - return ( - EMPTY_ORDERED_SET || (EMPTY_ORDERED_SET = makeOrderedSet(emptyOrderedMap())) - ); -} - -export { OrderedSet }; diff --git a/dist/es/PairSorting.js b/dist/es/PairSorting.js deleted file mode 100644 index 30b24ed7ed..0000000000 --- a/dist/es/PairSorting.js +++ /dev/null @@ -1,30 +0,0 @@ -/** - * @license - * MIT License - * - * Copyright (c) 2014-present, Lee Byron and other contributors. - * - * 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: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -var PairSorting = { - LeftThenRight: -1, - RightThenLeft: +1, -}; - -export { PairSorting }; diff --git a/dist/es/Range.js b/dist/es/Range.js deleted file mode 100644 index f890d72a57..0000000000 --- a/dist/es/Range.js +++ /dev/null @@ -1,178 +0,0 @@ -/** - * @license - * MIT License - * - * Copyright (c) 2014-present, Lee Byron and other contributors. - * - * 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: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -import { wrapIndex, wholeSlice, resolveBegin, resolveEnd } from './TrieUtils.js'; -import { IndexedSeq } from './Seq.js'; -import { Iterator, iteratorDone, iteratorValue } from './Iterator.js'; -import invariant from './utils/invariant.js'; -import deepEqual from './utils/deepEqual.js'; - -/** - * Returns a lazy seq of nums from start (inclusive) to end - * (exclusive), by step, where start defaults to 0, step to 1, and end to - * infinity. When start is equal to end, returns empty list. - */ -var Range = /*@__PURE__*/(function (IndexedSeq) { - function Range(start, end, step) { - if ( step === void 0 ) step = 1; - - if (!(this instanceof Range)) { - // eslint-disable-next-line no-constructor-return - return new Range(start, end, step); - } - invariant(step !== 0, 'Cannot step a Range by 0'); - invariant( - start !== undefined, - 'You must define a start value when using Range' - ); - invariant( - end !== undefined, - 'You must define an end value when using Range' - ); - - step = Math.abs(step); - if (end < start) { - step = -step; - } - this._start = start; - this._end = end; - this._step = step; - this.size = Math.max(0, Math.ceil((end - start) / step - 1) + 1); - if (this.size === 0) { - if (EMPTY_RANGE) { - // eslint-disable-next-line no-constructor-return - return EMPTY_RANGE; - } - // eslint-disable-next-line @typescript-eslint/no-this-alias - EMPTY_RANGE = this; - } - } - - if ( IndexedSeq ) Range.__proto__ = IndexedSeq; - Range.prototype = Object.create( IndexedSeq && IndexedSeq.prototype ); - Range.prototype.constructor = Range; - - Range.prototype.toString = function toString () { - if (this.size === 0) { - return 'Range []'; - } - return ( - 'Range [ ' + - this._start + - '...' + - this._end + - (this._step !== 1 ? ' by ' + this._step : '') + - ' ]' - ); - }; - - Range.prototype.get = function get (index, notSetValue) { - return this.has(index) - ? this._start + wrapIndex(this, index) * this._step - : notSetValue; - }; - - Range.prototype.includes = function includes (searchValue) { - var possibleIndex = (searchValue - this._start) / this._step; - return ( - possibleIndex >= 0 && - possibleIndex < this.size && - possibleIndex === Math.floor(possibleIndex) - ); - }; - - Range.prototype.slice = function slice (begin, end) { - if (wholeSlice(begin, end, this.size)) { - return this; - } - begin = resolveBegin(begin, this.size); - end = resolveEnd(end, this.size); - if (end <= begin) { - return new Range(0, 0); - } - return new Range( - this.get(begin, this._end), - this.get(end, this._end), - this._step - ); - }; - - Range.prototype.indexOf = function indexOf (searchValue) { - var offsetValue = searchValue - this._start; - if (offsetValue % this._step === 0) { - var index = offsetValue / this._step; - if (index >= 0 && index < this.size) { - return index; - } - } - return -1; - }; - - Range.prototype.lastIndexOf = function lastIndexOf (searchValue) { - return this.indexOf(searchValue); - }; - - Range.prototype.__iterate = function __iterate (fn, reverse) { - var size = this.size; - var step = this._step; - var value = reverse ? this._start + (size - 1) * step : this._start; - var i = 0; - while (i !== size) { - if (fn(value, reverse ? size - ++i : i++, this) === false) { - break; - } - value += reverse ? -step : step; - } - return i; - }; - - Range.prototype.__iterator = function __iterator (type, reverse) { - var size = this.size; - var step = this._step; - var value = reverse ? this._start + (size - 1) * step : this._start; - var i = 0; - return new Iterator(function () { - if (i === size) { - return iteratorDone(); - } - var v = value; - value += reverse ? -step : step; - return iteratorValue(type, reverse ? size - ++i : i++, v); - }); - }; - - Range.prototype.equals = function equals (other) { - return other instanceof Range - ? this._start === other._start && - this._end === other._end && - this._step === other._step - : deepEqual(this, other); - }; - - return Range; -}(IndexedSeq)); - -var EMPTY_RANGE; - -export { Range }; diff --git a/dist/es/Record.js b/dist/es/Record.js deleted file mode 100644 index 7053e011b6..0000000000 --- a/dist/es/Record.js +++ /dev/null @@ -1,292 +0,0 @@ -/** - * @license - * MIT License - * - * Copyright (c) 2014-present, Lee Byron and other contributors. - * - * 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: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -import { toJS } from './toJS.js'; -import { KeyedCollection } from './Collection.js'; -import { keyedSeqFromValue } from './Seq.js'; -import { List } from './List.js'; -import { ITERATOR_SYMBOL, ITERATE_ENTRIES } from './Iterator.js'; -import { isRecord, IS_RECORD_SYMBOL } from './predicates/isRecord.js'; -import { CollectionPrototype } from './CollectionImpl.js'; -import { DELETE } from './TrieUtils.js'; -import { getIn } from './methods/getIn.js'; -import { setIn } from './methods/setIn.js'; -import { deleteIn } from './methods/deleteIn.js'; -import { update } from './methods/update.js'; -import { updateIn } from './methods/updateIn.js'; -import { merge, mergeWith } from './methods/merge.js'; -import { mergeDeep, mergeDeepWith } from './methods/mergeDeep.js'; -import { mergeIn } from './methods/mergeIn.js'; -import { mergeDeepIn } from './methods/mergeDeepIn.js'; -import { withMutations } from './methods/withMutations.js'; -import { asMutable } from './methods/asMutable.js'; -import { asImmutable } from './methods/asImmutable.js'; -import invariant from './utils/invariant.js'; -import quoteString from './utils/quoteString.js'; -import { isImmutable } from './predicates/isImmutable.js'; - -function throwOnInvalidDefaultValues(defaultValues) { - if (isRecord(defaultValues)) { - throw new Error( - 'Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.' - ); - } - - if (isImmutable(defaultValues)) { - throw new Error( - 'Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.' - ); - } - - if (defaultValues === null || typeof defaultValues !== 'object') { - throw new Error( - 'Can not call `Record` with a non-object as default values. Use a plain javascript object instead.' - ); - } -} - -var Record = function Record(defaultValues, name) { - var hasInitialized; - - throwOnInvalidDefaultValues(defaultValues); - - var RecordType = function Record(values) { - var this$1$1 = this; - - if (values instanceof RecordType) { - return values; - } - if (!(this instanceof RecordType)) { - return new RecordType(values); - } - if (!hasInitialized) { - hasInitialized = true; - var keys = Object.keys(defaultValues); - var indices = (RecordTypePrototype._indices = {}); - // Deprecated: left to attempt not to break any external code which - // relies on a ._name property existing on record instances. - // Use Record.getDescriptiveName() instead - RecordTypePrototype._name = name; - RecordTypePrototype._keys = keys; - RecordTypePrototype._defaultValues = defaultValues; - for (var i = 0; i < keys.length; i++) { - var propName = keys[i]; - indices[propName] = i; - if (RecordTypePrototype[propName]) { - /* eslint-disable no-console */ - typeof console === 'object' && - console.warn && - console.warn( - 'Cannot define ' + - recordName(this) + - ' with property "' + - propName + - '" since that property name is part of the Record API.' - ); - /* eslint-enable no-console */ - } else { - setProp(RecordTypePrototype, propName); - } - } - } - this.__ownerID = undefined; - this._values = List().withMutations(function (l) { - l.setSize(this$1$1._keys.length); - KeyedCollection(values).forEach(function (v, k) { - l.set(this$1$1._indices[k], v === this$1$1._defaultValues[k] ? undefined : v); - }); - }); - return this; - }; - - var RecordTypePrototype = (RecordType.prototype = - Object.create(RecordPrototype)); - RecordTypePrototype.constructor = RecordType; - - if (name) { - RecordType.displayName = name; - } - - // eslint-disable-next-line no-constructor-return - return RecordType; -}; - -Record.prototype.toString = function toString () { - var str = recordName(this) + ' { '; - var keys = this._keys; - var k; - for (var i = 0, l = keys.length; i !== l; i++) { - k = keys[i]; - str += (i ? ', ' : '') + k + ': ' + quoteString(this.get(k)); - } - return str + ' }'; -}; - -Record.prototype.equals = function equals (other) { - return ( - this === other || - (isRecord(other) && recordSeq(this).equals(recordSeq(other))) - ); -}; - -Record.prototype.hashCode = function hashCode () { - return recordSeq(this).hashCode(); -}; - -// @pragma Access - -Record.prototype.has = function has (k) { - return this._indices.hasOwnProperty(k); -}; - -Record.prototype.get = function get (k, notSetValue) { - if (!this.has(k)) { - return notSetValue; - } - var index = this._indices[k]; - var value = this._values.get(index); - return value === undefined ? this._defaultValues[k] : value; -}; - -// @pragma Modification - -Record.prototype.set = function set (k, v) { - if (this.has(k)) { - var newValues = this._values.set( - this._indices[k], - v === this._defaultValues[k] ? undefined : v - ); - if (newValues !== this._values && !this.__ownerID) { - return makeRecord(this, newValues); - } - } - return this; -}; - -Record.prototype.remove = function remove (k) { - return this.set(k); -}; - -Record.prototype.clear = function clear () { - var newValues = this._values.clear().setSize(this._keys.length); - - return this.__ownerID ? this : makeRecord(this, newValues); -}; - -Record.prototype.wasAltered = function wasAltered () { - return this._values.wasAltered(); -}; - -Record.prototype.toSeq = function toSeq () { - return recordSeq(this); -}; - -Record.prototype.toJS = function toJS$1 () { - return toJS(this); -}; - -Record.prototype.entries = function entries () { - return this.__iterator(ITERATE_ENTRIES); -}; - -Record.prototype.__iterator = function __iterator (type, reverse) { - return recordSeq(this).__iterator(type, reverse); -}; - -Record.prototype.__iterate = function __iterate (fn, reverse) { - return recordSeq(this).__iterate(fn, reverse); -}; - -Record.prototype.__ensureOwner = function __ensureOwner (ownerID) { - if (ownerID === this.__ownerID) { - return this; - } - var newValues = this._values.__ensureOwner(ownerID); - if (!ownerID) { - this.__ownerID = ownerID; - this._values = newValues; - return this; - } - return makeRecord(this, newValues, ownerID); -}; - -Record.isRecord = isRecord; -Record.getDescriptiveName = recordName; -var RecordPrototype = Record.prototype; -RecordPrototype[IS_RECORD_SYMBOL] = true; -RecordPrototype[DELETE] = RecordPrototype.remove; -RecordPrototype.deleteIn = RecordPrototype.removeIn = deleteIn; -RecordPrototype.getIn = getIn; -RecordPrototype.hasIn = CollectionPrototype.hasIn; -RecordPrototype.merge = merge; -RecordPrototype.mergeWith = mergeWith; -RecordPrototype.mergeIn = mergeIn; -RecordPrototype.mergeDeep = mergeDeep; -RecordPrototype.mergeDeepWith = mergeDeepWith; -RecordPrototype.mergeDeepIn = mergeDeepIn; -RecordPrototype.setIn = setIn; -RecordPrototype.update = update; -RecordPrototype.updateIn = updateIn; -RecordPrototype.withMutations = withMutations; -RecordPrototype.asMutable = asMutable; -RecordPrototype.asImmutable = asImmutable; -RecordPrototype[ITERATOR_SYMBOL] = RecordPrototype.entries; -RecordPrototype.toJSON = RecordPrototype.toObject = - CollectionPrototype.toObject; -RecordPrototype.inspect = RecordPrototype.toSource = function () { - return this.toString(); -}; - -function makeRecord(likeRecord, values, ownerID) { - var record = Object.create(Object.getPrototypeOf(likeRecord)); - record._values = values; - record.__ownerID = ownerID; - return record; -} - -function recordName(record) { - return record.constructor.displayName || record.constructor.name || 'Record'; -} - -function recordSeq(record) { - return keyedSeqFromValue(record._keys.map(function (k) { return [k, record.get(k)]; })); -} - -function setProp(prototype, name) { - try { - Object.defineProperty(prototype, name, { - get: function () { - return this.get(name); - }, - set: function (value) { - invariant(this.__ownerID, 'Cannot set on an immutable record.'); - this.set(name, value); - }, - }); - } catch (error) { - // Object.defineProperty failed. Probably IE8. - } -} - -export { Record }; diff --git a/dist/es/Repeat.js b/dist/es/Repeat.js deleted file mode 100644 index 964ddb95fe..0000000000 --- a/dist/es/Repeat.js +++ /dev/null @@ -1,133 +0,0 @@ -/** - * @license - * MIT License - * - * Copyright (c) 2014-present, Lee Byron and other contributors. - * - * 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: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -import { wholeSlice, resolveEnd, resolveBegin } from './TrieUtils.js'; -import { IndexedSeq } from './Seq.js'; -import { is } from './is.js'; -import { Iterator, iteratorDone, iteratorValue } from './Iterator.js'; -import deepEqual from './utils/deepEqual.js'; - -/** - * Returns a lazy Seq of `value` repeated `times` times. When `times` is - * undefined, returns an infinite sequence of `value`. - */ -var Repeat = /*@__PURE__*/(function (IndexedSeq) { - function Repeat(value, times) { - if (!(this instanceof Repeat)) { - // eslint-disable-next-line no-constructor-return - return new Repeat(value, times); - } - this._value = value; - this.size = times === undefined ? Infinity : Math.max(0, times); - if (this.size === 0) { - if (EMPTY_REPEAT) { - // eslint-disable-next-line no-constructor-return - return EMPTY_REPEAT; - } - // eslint-disable-next-line @typescript-eslint/no-this-alias - EMPTY_REPEAT = this; - } - } - - if ( IndexedSeq ) Repeat.__proto__ = IndexedSeq; - Repeat.prototype = Object.create( IndexedSeq && IndexedSeq.prototype ); - Repeat.prototype.constructor = Repeat; - - Repeat.prototype.toString = function toString () { - if (this.size === 0) { - return 'Repeat []'; - } - return 'Repeat [ ' + this._value + ' ' + this.size + ' times ]'; - }; - - Repeat.prototype.get = function get (index, notSetValue) { - return this.has(index) ? this._value : notSetValue; - }; - - Repeat.prototype.includes = function includes (searchValue) { - return is(this._value, searchValue); - }; - - Repeat.prototype.slice = function slice (begin, end) { - var size = this.size; - return wholeSlice(begin, end, size) - ? this - : new Repeat( - this._value, - resolveEnd(end, size) - resolveBegin(begin, size) - ); - }; - - Repeat.prototype.reverse = function reverse () { - return this; - }; - - Repeat.prototype.indexOf = function indexOf (searchValue) { - if (is(this._value, searchValue)) { - return 0; - } - return -1; - }; - - Repeat.prototype.lastIndexOf = function lastIndexOf (searchValue) { - if (is(this._value, searchValue)) { - return this.size; - } - return -1; - }; - - Repeat.prototype.__iterate = function __iterate (fn, reverse) { - var size = this.size; - var i = 0; - while (i !== size) { - if (fn(this._value, reverse ? size - ++i : i++, this) === false) { - break; - } - } - return i; - }; - - Repeat.prototype.__iterator = function __iterator (type, reverse) { - var this$1$1 = this; - - var size = this.size; - var i = 0; - return new Iterator(function () { return i === size - ? iteratorDone() - : iteratorValue(type, reverse ? size - ++i : i++, this$1$1._value); } - ); - }; - - Repeat.prototype.equals = function equals (other) { - return other instanceof Repeat - ? is(this._value, other._value) - : deepEqual(this, other); - }; - - return Repeat; -}(IndexedSeq)); - -var EMPTY_REPEAT; - -export { Repeat }; diff --git a/dist/es/Seq.js b/dist/es/Seq.js deleted file mode 100644 index daffb3c7c1..0000000000 --- a/dist/es/Seq.js +++ /dev/null @@ -1,401 +0,0 @@ -/** - * @license - * MIT License - * - * Copyright (c) 2014-present, Lee Byron and other contributors. - * - * 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: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -import { wrapIndex } from './TrieUtils.js'; -import { Collection } from './Collection.js'; -import { isSeq, IS_SEQ_SYMBOL } from './predicates/isSeq.js'; -import { isImmutable } from './predicates/isImmutable.js'; -import { isCollection } from './predicates/isCollection.js'; -import { isKeyed } from './predicates/isKeyed.js'; -import { isAssociative } from './predicates/isAssociative.js'; -import { isRecord } from './predicates/isRecord.js'; -import { IS_ORDERED_SYMBOL } from './predicates/isOrdered.js'; -import { Iterator, iteratorDone, iteratorValue, isEntriesIterable, isKeysIterable, hasIterator, getIterator, isIterator } from './Iterator.js'; -import hasOwnProperty from './utils/hasOwnProperty.js'; -import isArrayLike from './utils/isArrayLike.js'; - -var Seq = /*@__PURE__*/(function (Collection) { - function Seq(value) { - // eslint-disable-next-line no-constructor-return - return value === undefined || value === null - ? emptySequence() - : isImmutable(value) - ? value.toSeq() - : seqFromValue(value); - } - - if ( Collection ) Seq.__proto__ = Collection; - Seq.prototype = Object.create( Collection && Collection.prototype ); - Seq.prototype.constructor = Seq; - - Seq.prototype.toSeq = function toSeq () { - return this; - }; - - Seq.prototype.toString = function toString () { - return this.__toString('Seq {', '}'); - }; - - Seq.prototype.cacheResult = function cacheResult () { - if (!this._cache && this.__iterateUncached) { - this._cache = this.entrySeq().toArray(); - this.size = this._cache.length; - } - return this; - }; - - // abstract __iterateUncached(fn, reverse) - - Seq.prototype.__iterate = function __iterate (fn, reverse) { - var cache = this._cache; - if (cache) { - var size = cache.length; - var i = 0; - while (i !== size) { - var entry = cache[reverse ? size - ++i : i++]; - if (fn(entry[1], entry[0], this) === false) { - break; - } - } - return i; - } - return this.__iterateUncached(fn, reverse); - }; - - // abstract __iteratorUncached(type, reverse) - - Seq.prototype.__iterator = function __iterator (type, reverse) { - var cache = this._cache; - if (cache) { - var size = cache.length; - var i = 0; - return new Iterator(function () { - if (i === size) { - return iteratorDone(); - } - var entry = cache[reverse ? size - ++i : i++]; - return iteratorValue(type, entry[0], entry[1]); - }); - } - return this.__iteratorUncached(type, reverse); - }; - - return Seq; -}(Collection)); - -var KeyedSeq = /*@__PURE__*/(function (Seq) { - function KeyedSeq(value) { - // eslint-disable-next-line no-constructor-return - return value === undefined || value === null - ? emptySequence().toKeyedSeq() - : isCollection(value) - ? isKeyed(value) - ? value.toSeq() - : value.fromEntrySeq() - : isRecord(value) - ? value.toSeq() - : keyedSeqFromValue(value); - } - - if ( Seq ) KeyedSeq.__proto__ = Seq; - KeyedSeq.prototype = Object.create( Seq && Seq.prototype ); - KeyedSeq.prototype.constructor = KeyedSeq; - - KeyedSeq.prototype.toKeyedSeq = function toKeyedSeq () { - return this; - }; - - return KeyedSeq; -}(Seq)); - -var IndexedSeq = /*@__PURE__*/(function (Seq) { - function IndexedSeq(value) { - // eslint-disable-next-line no-constructor-return - return value === undefined || value === null - ? emptySequence() - : isCollection(value) - ? isKeyed(value) - ? value.entrySeq() - : value.toIndexedSeq() - : isRecord(value) - ? value.toSeq().entrySeq() - : indexedSeqFromValue(value); - } - - if ( Seq ) IndexedSeq.__proto__ = Seq; - IndexedSeq.prototype = Object.create( Seq && Seq.prototype ); - IndexedSeq.prototype.constructor = IndexedSeq; - - IndexedSeq.of = function of (/*...values*/) { - return IndexedSeq(arguments); - }; - - IndexedSeq.prototype.toIndexedSeq = function toIndexedSeq () { - return this; - }; - - IndexedSeq.prototype.toString = function toString () { - return this.__toString('Seq [', ']'); - }; - - return IndexedSeq; -}(Seq)); - -var SetSeq = /*@__PURE__*/(function (Seq) { - function SetSeq(value) { - // eslint-disable-next-line no-constructor-return - return ( - isCollection(value) && !isAssociative(value) ? value : IndexedSeq(value) - ).toSetSeq(); - } - - if ( Seq ) SetSeq.__proto__ = Seq; - SetSeq.prototype = Object.create( Seq && Seq.prototype ); - SetSeq.prototype.constructor = SetSeq; - - SetSeq.of = function of (/*...values*/) { - return SetSeq(arguments); - }; - - SetSeq.prototype.toSetSeq = function toSetSeq () { - return this; - }; - - return SetSeq; -}(Seq)); - -Seq.isSeq = isSeq; -Seq.Keyed = KeyedSeq; -Seq.Set = SetSeq; -Seq.Indexed = IndexedSeq; - -Seq.prototype[IS_SEQ_SYMBOL] = true; - -// #pragma Root Sequences - -var ArraySeq = /*@__PURE__*/(function (IndexedSeq) { - function ArraySeq(array) { - this._array = array; - this.size = array.length; - } - - if ( IndexedSeq ) ArraySeq.__proto__ = IndexedSeq; - ArraySeq.prototype = Object.create( IndexedSeq && IndexedSeq.prototype ); - ArraySeq.prototype.constructor = ArraySeq; - - ArraySeq.prototype.get = function get (index, notSetValue) { - return this.has(index) ? this._array[wrapIndex(this, index)] : notSetValue; - }; - - ArraySeq.prototype.__iterate = function __iterate (fn, reverse) { - var array = this._array; - var size = array.length; - var i = 0; - while (i !== size) { - var ii = reverse ? size - ++i : i++; - if (fn(array[ii], ii, this) === false) { - break; - } - } - return i; - }; - - ArraySeq.prototype.__iterator = function __iterator (type, reverse) { - var array = this._array; - var size = array.length; - var i = 0; - return new Iterator(function () { - if (i === size) { - return iteratorDone(); - } - var ii = reverse ? size - ++i : i++; - return iteratorValue(type, ii, array[ii]); - }); - }; - - return ArraySeq; -}(IndexedSeq)); - -var ObjectSeq = /*@__PURE__*/(function (KeyedSeq) { - function ObjectSeq(object) { - var keys = Object.keys(object).concat( - Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(object) : [] - ); - this._object = object; - this._keys = keys; - this.size = keys.length; - } - - if ( KeyedSeq ) ObjectSeq.__proto__ = KeyedSeq; - ObjectSeq.prototype = Object.create( KeyedSeq && KeyedSeq.prototype ); - ObjectSeq.prototype.constructor = ObjectSeq; - - ObjectSeq.prototype.get = function get (key, notSetValue) { - if (notSetValue !== undefined && !this.has(key)) { - return notSetValue; - } - return this._object[key]; - }; - - ObjectSeq.prototype.has = function has (key) { - return hasOwnProperty.call(this._object, key); - }; - - ObjectSeq.prototype.__iterate = function __iterate (fn, reverse) { - var object = this._object; - var keys = this._keys; - var size = keys.length; - var i = 0; - while (i !== size) { - var key = keys[reverse ? size - ++i : i++]; - if (fn(object[key], key, this) === false) { - break; - } - } - return i; - }; - - ObjectSeq.prototype.__iterator = function __iterator (type, reverse) { - var object = this._object; - var keys = this._keys; - var size = keys.length; - var i = 0; - return new Iterator(function () { - if (i === size) { - return iteratorDone(); - } - var key = keys[reverse ? size - ++i : i++]; - return iteratorValue(type, key, object[key]); - }); - }; - - return ObjectSeq; -}(KeyedSeq)); -ObjectSeq.prototype[IS_ORDERED_SYMBOL] = true; - -var CollectionSeq = /*@__PURE__*/(function (IndexedSeq) { - function CollectionSeq(collection) { - this._collection = collection; - this.size = collection.length || collection.size; - } - - if ( IndexedSeq ) CollectionSeq.__proto__ = IndexedSeq; - CollectionSeq.prototype = Object.create( IndexedSeq && IndexedSeq.prototype ); - CollectionSeq.prototype.constructor = CollectionSeq; - - CollectionSeq.prototype.__iterateUncached = function __iterateUncached (fn, reverse) { - if (reverse) { - return this.cacheResult().__iterate(fn, reverse); - } - var collection = this._collection; - var iterator = getIterator(collection); - var iterations = 0; - if (isIterator(iterator)) { - var step; - while (!(step = iterator.next()).done) { - if (fn(step.value, iterations++, this) === false) { - break; - } - } - } - return iterations; - }; - - CollectionSeq.prototype.__iteratorUncached = function __iteratorUncached (type, reverse) { - if (reverse) { - return this.cacheResult().__iterator(type, reverse); - } - var collection = this._collection; - var iterator = getIterator(collection); - if (!isIterator(iterator)) { - return new Iterator(iteratorDone); - } - var iterations = 0; - return new Iterator(function () { - var step = iterator.next(); - return step.done ? step : iteratorValue(type, iterations++, step.value); - }); - }; - - return CollectionSeq; -}(IndexedSeq)); - -// # pragma Helper functions - -var EMPTY_SEQ; - -function emptySequence() { - return EMPTY_SEQ || (EMPTY_SEQ = new ArraySeq([])); -} - -function keyedSeqFromValue(value) { - var seq = maybeIndexedSeqFromValue(value); - if (seq) { - return seq.fromEntrySeq(); - } - if (typeof value === 'object') { - return new ObjectSeq(value); - } - throw new TypeError( - 'Expected Array or collection object of [k, v] entries, or keyed object: ' + - value - ); -} - -function indexedSeqFromValue(value) { - var seq = maybeIndexedSeqFromValue(value); - if (seq) { - return seq; - } - throw new TypeError( - 'Expected Array or collection object of values: ' + value - ); -} - -function seqFromValue(value) { - var seq = maybeIndexedSeqFromValue(value); - if (seq) { - return isEntriesIterable(value) - ? seq.fromEntrySeq() - : isKeysIterable(value) - ? seq.toSetSeq() - : seq; - } - if (typeof value === 'object') { - return new ObjectSeq(value); - } - throw new TypeError( - 'Expected Array or collection object of values, or keyed object: ' + value - ); -} - -function maybeIndexedSeqFromValue(value) { - return isArrayLike(value) - ? new ArraySeq(value) - : hasIterator(value) - ? new CollectionSeq(value) - : undefined; -} - -export { ArraySeq, IndexedSeq, KeyedSeq, Seq, SetSeq, indexedSeqFromValue, keyedSeqFromValue }; diff --git a/dist/es/Set.js b/dist/es/Set.js deleted file mode 100644 index e61ed85d92..0000000000 --- a/dist/es/Set.js +++ /dev/null @@ -1,279 +0,0 @@ -/** - * @license - * MIT License - * - * Copyright (c) 2014-present, Lee Byron and other contributors. - * - * 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: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -import { KeyedCollection, Collection, SetCollection } from './Collection.js'; -import { isOrdered } from './predicates/isOrdered.js'; -import { isSet, IS_SET_SYMBOL } from './predicates/isSet.js'; -import { emptyMap } from './Map.js'; -import { DELETE } from './TrieUtils.js'; -import { sortFactory } from './Operations.js'; -import assertNotInfinite from './utils/assertNotInfinite.js'; -import { asImmutable } from './methods/asImmutable.js'; -import { asMutable } from './methods/asMutable.js'; -import { withMutations } from './methods/withMutations.js'; -import { OrderedSet } from './OrderedSet.js'; - -var Set = /*@__PURE__*/(function (SetCollection) { - function Set(value) { - // eslint-disable-next-line no-constructor-return - return value === undefined || value === null - ? emptySet() - : isSet(value) && !isOrdered(value) - ? value - : emptySet().withMutations(function (set) { - var iter = SetCollection(value); - assertNotInfinite(iter.size); - iter.forEach(function (v) { return set.add(v); }); - }); - } - - if ( SetCollection ) Set.__proto__ = SetCollection; - Set.prototype = Object.create( SetCollection && SetCollection.prototype ); - Set.prototype.constructor = Set; - - Set.of = function of (/*...values*/) { - return this(arguments); - }; - - Set.fromKeys = function fromKeys (value) { - return this(KeyedCollection(value).keySeq()); - }; - - Set.intersect = function intersect (sets) { - sets = Collection(sets).toArray(); - return sets.length - ? SetPrototype.intersect.apply(Set(sets.pop()), sets) - : emptySet(); - }; - - Set.union = function union (sets) { - sets = Collection(sets).toArray(); - return sets.length - ? SetPrototype.union.apply(Set(sets.pop()), sets) - : emptySet(); - }; - - Set.prototype.toString = function toString () { - return this.__toString('Set {', '}'); - }; - - // @pragma Access - - Set.prototype.has = function has (value) { - return this._map.has(value); - }; - - // @pragma Modification - - Set.prototype.add = function add (value) { - return updateSet(this, this._map.set(value, value)); - }; - - Set.prototype.remove = function remove (value) { - return updateSet(this, this._map.remove(value)); - }; - - Set.prototype.clear = function clear () { - return updateSet(this, this._map.clear()); - }; - - // @pragma Composition - - Set.prototype.map = function map (mapper, context) { - var this$1$1 = this; - - // keep track if the set is altered by the map function - var didChanges = false; - - var newMap = updateSet( - this, - this._map.mapEntries(function (ref) { - var v = ref[1]; - - var mapped = mapper.call(context, v, v, this$1$1); - - if (mapped !== v) { - didChanges = true; - } - - return [mapped, mapped]; - }, context) - ); - - return didChanges ? newMap : this; - }; - - Set.prototype.union = function union () { - var iters = [], len = arguments.length; - while ( len-- ) iters[ len ] = arguments[ len ]; - - iters = iters.filter(function (x) { return x.size !== 0; }); - if (iters.length === 0) { - return this; - } - if (this.size === 0 && !this.__ownerID && iters.length === 1) { - return this.constructor(iters[0]); - } - return this.withMutations(function (set) { - for (var ii = 0; ii < iters.length; ii++) { - if (typeof iters[ii] === 'string') { - set.add(iters[ii]); - } else { - SetCollection(iters[ii]).forEach(function (value) { return set.add(value); }); - } - } - }); - }; - - Set.prototype.intersect = function intersect () { - var iters = [], len = arguments.length; - while ( len-- ) iters[ len ] = arguments[ len ]; - - if (iters.length === 0) { - return this; - } - iters = iters.map(function (iter) { return SetCollection(iter); }); - var toRemove = []; - this.forEach(function (value) { - if (!iters.every(function (iter) { return iter.includes(value); })) { - toRemove.push(value); - } - }); - return this.withMutations(function (set) { - toRemove.forEach(function (value) { - set.remove(value); - }); - }); - }; - - Set.prototype.subtract = function subtract () { - var iters = [], len = arguments.length; - while ( len-- ) iters[ len ] = arguments[ len ]; - - if (iters.length === 0) { - return this; - } - iters = iters.map(function (iter) { return SetCollection(iter); }); - var toRemove = []; - this.forEach(function (value) { - if (iters.some(function (iter) { return iter.includes(value); })) { - toRemove.push(value); - } - }); - return this.withMutations(function (set) { - toRemove.forEach(function (value) { - set.remove(value); - }); - }); - }; - - Set.prototype.sort = function sort (comparator) { - // Late binding - return OrderedSet(sortFactory(this, comparator)); - }; - - Set.prototype.sortBy = function sortBy (mapper, comparator) { - // Late binding - return OrderedSet(sortFactory(this, comparator, mapper)); - }; - - Set.prototype.wasAltered = function wasAltered () { - return this._map.wasAltered(); - }; - - Set.prototype.__iterate = function __iterate (fn, reverse) { - var this$1$1 = this; - - return this._map.__iterate(function (k) { return fn(k, k, this$1$1); }, reverse); - }; - - Set.prototype.__iterator = function __iterator (type, reverse) { - return this._map.__iterator(type, reverse); - }; - - Set.prototype.__ensureOwner = function __ensureOwner (ownerID) { - if (ownerID === this.__ownerID) { - return this; - } - var newMap = this._map.__ensureOwner(ownerID); - if (!ownerID) { - if (this.size === 0) { - return this.__empty(); - } - this.__ownerID = ownerID; - this._map = newMap; - return this; - } - return this.__make(newMap, ownerID); - }; - - return Set; -}(SetCollection)); - -Set.isSet = isSet; - -var SetPrototype = Set.prototype; -SetPrototype[IS_SET_SYMBOL] = true; -SetPrototype[DELETE] = SetPrototype.remove; -SetPrototype.merge = SetPrototype.concat = SetPrototype.union; -SetPrototype.withMutations = withMutations; -SetPrototype.asImmutable = asImmutable; -SetPrototype['@@transducer/init'] = SetPrototype.asMutable = asMutable; -SetPrototype['@@transducer/step'] = function (result, arr) { - return result.add(arr); -}; -SetPrototype['@@transducer/result'] = function (obj) { - return obj.asImmutable(); -}; - -SetPrototype.__empty = emptySet; -SetPrototype.__make = makeSet; - -function updateSet(set, newMap) { - if (set.__ownerID) { - set.size = newMap.size; - set._map = newMap; - return set; - } - return newMap === set._map - ? set - : newMap.size === 0 - ? set.__empty() - : set.__make(newMap); -} - -function makeSet(map, ownerID) { - var set = Object.create(SetPrototype); - set.size = map ? map.size : 0; - set._map = map; - set.__ownerID = ownerID; - return set; -} - -var EMPTY_SET; -function emptySet() { - return EMPTY_SET || (EMPTY_SET = makeSet(emptyMap())); -} - -export { Set }; diff --git a/dist/es/Stack.js b/dist/es/Stack.js deleted file mode 100644 index 0a39641d73..0000000000 --- a/dist/es/Stack.js +++ /dev/null @@ -1,261 +0,0 @@ -/** - * @license - * MIT License - * - * Copyright (c) 2014-present, Lee Byron and other contributors. - * - * 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: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -import { wrapIndex, wholeSlice, resolveBegin, resolveEnd } from './TrieUtils.js'; -import { IndexedCollection } from './Collection.js'; -import { ArraySeq } from './Seq.js'; -import { Iterator, iteratorValue, iteratorDone } from './Iterator.js'; -import { isStack, IS_STACK_SYMBOL } from './predicates/isStack.js'; -import assertNotInfinite from './utils/assertNotInfinite.js'; -import { asImmutable } from './methods/asImmutable.js'; -import { asMutable } from './methods/asMutable.js'; -import { wasAltered } from './methods/wasAltered.js'; -import { withMutations } from './methods/withMutations.js'; - -var Stack = /*@__PURE__*/(function (IndexedCollection) { - function Stack(value) { - // eslint-disable-next-line no-constructor-return - return value === undefined || value === null - ? emptyStack() - : isStack(value) - ? value - : emptyStack().pushAll(value); - } - - if ( IndexedCollection ) Stack.__proto__ = IndexedCollection; - Stack.prototype = Object.create( IndexedCollection && IndexedCollection.prototype ); - Stack.prototype.constructor = Stack; - - Stack.of = function of (/*...values*/) { - return this(arguments); - }; - - Stack.prototype.toString = function toString () { - return this.__toString('Stack [', ']'); - }; - - // @pragma Access - - Stack.prototype.get = function get (index, notSetValue) { - var head = this._head; - index = wrapIndex(this, index); - while (head && index--) { - head = head.next; - } - return head ? head.value : notSetValue; - }; - - Stack.prototype.peek = function peek () { - return this._head && this._head.value; - }; - - // @pragma Modification - - Stack.prototype.push = function push (/*...values*/) { - var arguments$1 = arguments; - - if (arguments.length === 0) { - return this; - } - var newSize = this.size + arguments.length; - var head = this._head; - for (var ii = arguments.length - 1; ii >= 0; ii--) { - head = { - value: arguments$1[ii], - next: head, - }; - } - if (this.__ownerID) { - this.size = newSize; - this._head = head; - this.__hash = undefined; - this.__altered = true; - return this; - } - return makeStack(newSize, head); - }; - - Stack.prototype.pushAll = function pushAll (iter) { - iter = IndexedCollection(iter); - if (iter.size === 0) { - return this; - } - if (this.size === 0 && isStack(iter)) { - return iter; - } - assertNotInfinite(iter.size); - var newSize = this.size; - var head = this._head; - iter.__iterate(function (value) { - newSize++; - head = { - value: value, - next: head, - }; - }, /* reverse */ true); - if (this.__ownerID) { - this.size = newSize; - this._head = head; - this.__hash = undefined; - this.__altered = true; - return this; - } - return makeStack(newSize, head); - }; - - Stack.prototype.pop = function pop () { - return this.slice(1); - }; - - Stack.prototype.clear = function clear () { - if (this.size === 0) { - return this; - } - if (this.__ownerID) { - this.size = 0; - this._head = undefined; - this.__hash = undefined; - this.__altered = true; - return this; - } - return emptyStack(); - }; - - Stack.prototype.slice = function slice (begin, end) { - if (wholeSlice(begin, end, this.size)) { - return this; - } - var resolvedBegin = resolveBegin(begin, this.size); - var resolvedEnd = resolveEnd(end, this.size); - if (resolvedEnd !== this.size) { - // super.slice(begin, end); - return IndexedCollection.prototype.slice.call(this, begin, end); - } - var newSize = this.size - resolvedBegin; - var head = this._head; - while (resolvedBegin--) { - head = head.next; - } - if (this.__ownerID) { - this.size = newSize; - this._head = head; - this.__hash = undefined; - this.__altered = true; - return this; - } - return makeStack(newSize, head); - }; - - // @pragma Mutability - - Stack.prototype.__ensureOwner = function __ensureOwner (ownerID) { - if (ownerID === this.__ownerID) { - return this; - } - if (!ownerID) { - if (this.size === 0) { - return emptyStack(); - } - this.__ownerID = ownerID; - this.__altered = false; - return this; - } - return makeStack(this.size, this._head, ownerID, this.__hash); - }; - - // @pragma Iteration - - Stack.prototype.__iterate = function __iterate (fn, reverse) { - var this$1$1 = this; - - if (reverse) { - return new ArraySeq(this.toArray()).__iterate( - function (v, k) { return fn(v, k, this$1$1); }, - reverse - ); - } - var iterations = 0; - var node = this._head; - while (node) { - if (fn(node.value, iterations++, this) === false) { - break; - } - node = node.next; - } - return iterations; - }; - - Stack.prototype.__iterator = function __iterator (type, reverse) { - if (reverse) { - return new ArraySeq(this.toArray()).__iterator(type, reverse); - } - var iterations = 0; - var node = this._head; - return new Iterator(function () { - if (node) { - var value = node.value; - node = node.next; - return iteratorValue(type, iterations++, value); - } - return iteratorDone(); - }); - }; - - return Stack; -}(IndexedCollection)); - -Stack.isStack = isStack; - -var StackPrototype = Stack.prototype; -StackPrototype[IS_STACK_SYMBOL] = true; -StackPrototype.shift = StackPrototype.pop; -StackPrototype.unshift = StackPrototype.push; -StackPrototype.unshiftAll = StackPrototype.pushAll; -StackPrototype.withMutations = withMutations; -StackPrototype.wasAltered = wasAltered; -StackPrototype.asImmutable = asImmutable; -StackPrototype['@@transducer/init'] = StackPrototype.asMutable = asMutable; -StackPrototype['@@transducer/step'] = function (result, arr) { - return result.unshift(arr); -}; -StackPrototype['@@transducer/result'] = function (obj) { - return obj.asImmutable(); -}; - -function makeStack(size, head, ownerID, hash) { - var map = Object.create(StackPrototype); - map.size = size; - map._head = head; - map.__ownerID = ownerID; - map.__hash = hash; - map.__altered = false; - return map; -} - -var EMPTY_STACK; -function emptyStack() { - return EMPTY_STACK || (EMPTY_STACK = makeStack(0)); -} - -export { Stack }; diff --git a/dist/es/TrieUtils.js b/dist/es/TrieUtils.js deleted file mode 100644 index e22c3accff..0000000000 --- a/dist/es/TrieUtils.js +++ /dev/null @@ -1,117 +0,0 @@ -/** - * @license - * MIT License - * - * Copyright (c) 2014-present, Lee Byron and other contributors. - * - * 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: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -// Used for setting prototype methods that IE8 chokes on. -var DELETE = 'delete'; - -// Constants describing the size of trie nodes. -var SHIFT = 5; // Resulted in best performance after ______? -var SIZE = 1 << SHIFT; -var MASK = SIZE - 1; - -// A consistent shared value representing "not set" which equals nothing other -// than itself, and nothing that could be provided externally. -var NOT_SET = {}; - -// Boolean references, Rough equivalent of `bool &`. -function MakeRef() { - return { value: false }; -} - -function SetRef(ref) { - if (ref) { - ref.value = true; - } -} - -// A function which returns a value representing an "owner" for transient writes -// to tries. The return value will only ever equal itself, and will not equal -// the return of any subsequent call of this function. -function OwnerID() {} - -function ensureSize(iter) { - if (iter.size === undefined) { - iter.size = iter.__iterate(returnTrue); - } - return iter.size; -} - -function wrapIndex(iter, index) { - // This implements "is array index" which the ECMAString spec defines as: - // - // A String property name P is an array index if and only if - // ToString(ToUint32(P)) is equal to P and ToUint32(P) is not equal - // to 2^32−1. - // - // http://www.ecma-international.org/ecma-262/6.0/#sec-array-exotic-objects - if (typeof index !== 'number') { - var uint32Index = index >>> 0; // N >>> 0 is shorthand for ToUint32 - if ('' + uint32Index !== index || uint32Index === 4294967295) { - return NaN; - } - index = uint32Index; - } - return index < 0 ? ensureSize(iter) + index : index; -} - -function returnTrue() { - return true; -} - -function wholeSlice(begin, end, size) { - return ( - ((begin === 0 && !isNeg(begin)) || - (size !== undefined && begin <= -size)) && - (end === undefined || (size !== undefined && end >= size)) - ); -} - -function resolveBegin(begin, size) { - return resolveIndex(begin, size, 0); -} - -function resolveEnd(end, size) { - return resolveIndex(end, size, size); -} - -function resolveIndex(index, size, defaultIndex) { - // Sanitize indices using this shorthand for ToInt32(argument) - // http://www.ecma-international.org/ecma-262/6.0/#sec-toint32 - return index === undefined - ? defaultIndex - : isNeg(index) - ? size === Infinity - ? size - : Math.max(0, size + index) | 0 - : size === undefined || size === index - ? index - : Math.min(size, index) | 0; -} - -function isNeg(value) { - // Account for -0 which is negative, but not less than 0. - return value < 0 || (value === 0 && 1 / value === -Infinity); -} - -export { DELETE, MASK, MakeRef, NOT_SET, OwnerID, SHIFT, SIZE, SetRef, ensureSize, resolveBegin, resolveEnd, returnTrue, wholeSlice, wrapIndex }; diff --git a/dist/es/fromJS.js b/dist/es/fromJS.js deleted file mode 100644 index c6860d3af1..0000000000 --- a/dist/es/fromJS.js +++ /dev/null @@ -1,74 +0,0 @@ -/** - * @license - * MIT License - * - * Copyright (c) 2014-present, Lee Byron and other contributors. - * - * 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: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -import { Seq } from './Seq.js'; -import { hasIterator } from './Iterator.js'; -import { isImmutable } from './predicates/isImmutable.js'; -import { isIndexed } from './predicates/isIndexed.js'; -import { isKeyed } from './predicates/isKeyed.js'; -import isArrayLike from './utils/isArrayLike.js'; -import isPlainObject from './utils/isPlainObj.js'; - -function fromJS(value, converter) { - return fromJSWith( - [], - converter || defaultConverter, - value, - '', - converter && converter.length > 2 ? [] : undefined, - { '': value } - ); -} - -function fromJSWith(stack, converter, value, key, keyPath, parentValue) { - if ( - typeof value !== 'string' && - !isImmutable(value) && - (isArrayLike(value) || hasIterator(value) || isPlainObject(value)) - ) { - if (~stack.indexOf(value)) { - throw new TypeError('Cannot convert circular structure to Immutable'); - } - stack.push(value); - keyPath && key !== '' && keyPath.push(key); - var converted = converter.call( - parentValue, - key, - Seq(value).map(function (v, k) { return fromJSWith(stack, converter, v, k, keyPath, value); } - ), - keyPath && keyPath.slice() - ); - stack.pop(); - keyPath && keyPath.pop(); - return converted; - } - return value; -} - -function defaultConverter(k, v) { - // Effectively the opposite of "Collection.toSeq()" - return isIndexed(v) ? v.toList() : isKeyed(v) ? v.toMap() : v.toSet(); -} - -export { fromJS }; diff --git a/dist/es/functional/get.js b/dist/es/functional/get.js deleted file mode 100644 index aaf3cbdf01..0000000000 --- a/dist/es/functional/get.js +++ /dev/null @@ -1,38 +0,0 @@ -/** - * @license - * MIT License - * - * Copyright (c) 2014-present, Lee Byron and other contributors. - * - * 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: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -import { isImmutable } from '../predicates/isImmutable.js'; -import { has } from './has.js'; - -function get(collection, key, notSetValue) { - return isImmutable(collection) - ? collection.get(key, notSetValue) - : !has(collection, key) - ? notSetValue - : typeof collection.get === 'function' - ? collection.get(key) - : collection[key]; -} - -export { get }; diff --git a/dist/es/functional/getIn.js b/dist/es/functional/getIn.js deleted file mode 100644 index 4b1dc9dd31..0000000000 --- a/dist/es/functional/getIn.js +++ /dev/null @@ -1,41 +0,0 @@ -/** - * @license - * MIT License - * - * Copyright (c) 2014-present, Lee Byron and other contributors. - * - * 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: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -import coerceKeyPath from '../utils/coerceKeyPath.js'; -import { NOT_SET } from '../TrieUtils.js'; -import { get } from './get.js'; - -function getIn(collection, searchKeyPath, notSetValue) { - var keyPath = coerceKeyPath(searchKeyPath); - var i = 0; - while (i !== keyPath.length) { - collection = get(collection, keyPath[i++], NOT_SET); - if (collection === NOT_SET) { - return notSetValue; - } - } - return collection; -} - -export { getIn }; diff --git a/dist/es/functional/has.js b/dist/es/functional/has.js deleted file mode 100644 index 7a1a7f2e0a..0000000000 --- a/dist/es/functional/has.js +++ /dev/null @@ -1,35 +0,0 @@ -/** - * @license - * MIT License - * - * Copyright (c) 2014-present, Lee Byron and other contributors. - * - * 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: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -import { isImmutable } from '../predicates/isImmutable.js'; -import hasOwnProperty from '../utils/hasOwnProperty.js'; -import isDataStructure from '../utils/isDataStructure.js'; - -function has(collection, key) { - return isImmutable(collection) - ? collection.has(key) - : isDataStructure(collection) && hasOwnProperty.call(collection, key); -} - -export { has }; diff --git a/dist/es/functional/hasIn.js b/dist/es/functional/hasIn.js deleted file mode 100644 index 011501129d..0000000000 --- a/dist/es/functional/hasIn.js +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @license - * MIT License - * - * Copyright (c) 2014-present, Lee Byron and other contributors. - * - * 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: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -import { getIn } from './getIn.js'; -import { NOT_SET } from '../TrieUtils.js'; - -function hasIn(collection, keyPath) { - return getIn(collection, keyPath, NOT_SET) !== NOT_SET; -} - -export { hasIn }; diff --git a/dist/es/functional/merge.js b/dist/es/functional/merge.js deleted file mode 100644 index 947ea2619c..0000000000 --- a/dist/es/functional/merge.js +++ /dev/null @@ -1,137 +0,0 @@ -/** - * @license - * MIT License - * - * Copyright (c) 2014-present, Lee Byron and other contributors. - * - * 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: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -import { isImmutable } from '../predicates/isImmutable.js'; -import { isIndexed } from '../predicates/isIndexed.js'; -import { isKeyed } from '../predicates/isKeyed.js'; -import { IndexedCollection, KeyedCollection } from '../Collection.js'; -import { Seq } from '../Seq.js'; -import hasOwnProperty from '../utils/hasOwnProperty.js'; -import isDataStructure from '../utils/isDataStructure.js'; -import shallowCopy from '../utils/shallowCopy.js'; - -function merge(collection) { - var sources = [], len = arguments.length - 1; - while ( len-- > 0 ) sources[ len ] = arguments[ len + 1 ]; - - return mergeWithSources(collection, sources); -} - -function mergeWith(merger, collection) { - var sources = [], len = arguments.length - 2; - while ( len-- > 0 ) sources[ len ] = arguments[ len + 2 ]; - - return mergeWithSources(collection, sources, merger); -} - -function mergeDeep(collection) { - var sources = [], len = arguments.length - 1; - while ( len-- > 0 ) sources[ len ] = arguments[ len + 1 ]; - - return mergeDeepWithSources(collection, sources); -} - -function mergeDeepWith(merger, collection) { - var sources = [], len = arguments.length - 2; - while ( len-- > 0 ) sources[ len ] = arguments[ len + 2 ]; - - return mergeDeepWithSources(collection, sources, merger); -} - -function mergeDeepWithSources(collection, sources, merger) { - return mergeWithSources(collection, sources, deepMergerWith(merger)); -} - -function mergeWithSources(collection, sources, merger) { - if (!isDataStructure(collection)) { - throw new TypeError( - 'Cannot merge into non-data-structure value: ' + collection - ); - } - if (isImmutable(collection)) { - return typeof merger === 'function' && collection.mergeWith - ? collection.mergeWith.apply(collection, [ merger ].concat( sources )) - : collection.merge - ? collection.merge.apply(collection, sources) - : collection.concat.apply(collection, sources); - } - var isArray = Array.isArray(collection); - var merged = collection; - var Collection = isArray ? IndexedCollection : KeyedCollection; - var mergeItem = isArray - ? function (value) { - // Copy on write - if (merged === collection) { - merged = shallowCopy(merged); - } - merged.push(value); - } - : function (value, key) { - var hasVal = hasOwnProperty.call(merged, key); - var nextVal = - hasVal && merger ? merger(merged[key], value, key) : value; - if (!hasVal || nextVal !== merged[key]) { - // Copy on write - if (merged === collection) { - merged = shallowCopy(merged); - } - merged[key] = nextVal; - } - }; - for (var i = 0; i < sources.length; i++) { - Collection(sources[i]).forEach(mergeItem); - } - return merged; -} - -function deepMergerWith(merger) { - function deepMerger(oldValue, newValue, key) { - return isDataStructure(oldValue) && - isDataStructure(newValue) && - areMergeable(oldValue, newValue) - ? mergeWithSources(oldValue, [newValue], deepMerger) - : merger - ? merger(oldValue, newValue, key) - : newValue; - } - return deepMerger; -} - -/** - * It's unclear what the desired behavior is for merging two collections that - * fall into separate categories between keyed, indexed, or set-like, so we only - * consider them mergeable if they fall into the same category. - */ -function areMergeable(oldDataStructure, newDataStructure) { - var oldSeq = Seq(oldDataStructure); - var newSeq = Seq(newDataStructure); - // This logic assumes that a sequence can only fall into one of the three - // categories mentioned above (since there's no `isSetLike()` method). - return ( - isIndexed(oldSeq) === isIndexed(newSeq) && - isKeyed(oldSeq) === isKeyed(newSeq) - ); -} - -export { merge, mergeDeep, mergeDeepWith, mergeDeepWithSources, mergeWith, mergeWithSources }; diff --git a/dist/es/functional/remove.js b/dist/es/functional/remove.js deleted file mode 100644 index 29bd9aba86..0000000000 --- a/dist/es/functional/remove.js +++ /dev/null @@ -1,56 +0,0 @@ -/** - * @license - * MIT License - * - * Copyright (c) 2014-present, Lee Byron and other contributors. - * - * 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: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -import { isImmutable } from '../predicates/isImmutable.js'; -import hasOwnProperty from '../utils/hasOwnProperty.js'; -import isDataStructure from '../utils/isDataStructure.js'; -import shallowCopy from '../utils/shallowCopy.js'; - -function remove(collection, key) { - if (!isDataStructure(collection)) { - throw new TypeError( - 'Cannot update non-data-structure value: ' + collection - ); - } - if (isImmutable(collection)) { - if (!collection.remove) { - throw new TypeError( - 'Cannot update immutable value without .remove() method: ' + collection - ); - } - return collection.remove(key); - } - if (!hasOwnProperty.call(collection, key)) { - return collection; - } - var collectionCopy = shallowCopy(collection); - if (Array.isArray(collectionCopy)) { - collectionCopy.splice(key, 1); - } else { - delete collectionCopy[key]; - } - return collectionCopy; -} - -export { remove }; diff --git a/dist/es/functional/removeIn.js b/dist/es/functional/removeIn.js deleted file mode 100644 index 4ef2a02205..0000000000 --- a/dist/es/functional/removeIn.js +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @license - * MIT License - * - * Copyright (c) 2014-present, Lee Byron and other contributors. - * - * 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: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -import { updateIn } from './updateIn.js'; -import { NOT_SET } from '../TrieUtils.js'; - -function removeIn(collection, keyPath) { - return updateIn(collection, keyPath, function () { return NOT_SET; }); -} - -export { removeIn }; diff --git a/dist/es/functional/set.js b/dist/es/functional/set.js deleted file mode 100644 index d571aac11e..0000000000 --- a/dist/es/functional/set.js +++ /dev/null @@ -1,52 +0,0 @@ -/** - * @license - * MIT License - * - * Copyright (c) 2014-present, Lee Byron and other contributors. - * - * 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: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -import { isImmutable } from '../predicates/isImmutable.js'; -import hasOwnProperty from '../utils/hasOwnProperty.js'; -import isDataStructure from '../utils/isDataStructure.js'; -import shallowCopy from '../utils/shallowCopy.js'; - -function set(collection, key, value) { - if (!isDataStructure(collection)) { - throw new TypeError( - 'Cannot update non-data-structure value: ' + collection - ); - } - if (isImmutable(collection)) { - if (!collection.set) { - throw new TypeError( - 'Cannot update immutable value without .set() method: ' + collection - ); - } - return collection.set(key, value); - } - if (hasOwnProperty.call(collection, key) && value === collection[key]) { - return collection; - } - var collectionCopy = shallowCopy(collection); - collectionCopy[key] = value; - return collectionCopy; -} - -export { set }; diff --git a/dist/es/functional/setIn.js b/dist/es/functional/setIn.js deleted file mode 100644 index 1c5bfbfcb2..0000000000 --- a/dist/es/functional/setIn.js +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @license - * MIT License - * - * Copyright (c) 2014-present, Lee Byron and other contributors. - * - * 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: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -import { updateIn } from './updateIn.js'; -import { NOT_SET } from '../TrieUtils.js'; - -function setIn(collection, keyPath, value) { - return updateIn(collection, keyPath, NOT_SET, function () { return value; }); -} - -export { setIn }; diff --git a/dist/es/functional/update.js b/dist/es/functional/update.js deleted file mode 100644 index e24f89c554..0000000000 --- a/dist/es/functional/update.js +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * MIT License - * - * Copyright (c) 2014-present, Lee Byron and other contributors. - * - * 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: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -import { updateIn } from './updateIn.js'; - -function update(collection, key, notSetValue, updater) { - return updateIn(collection, [key], notSetValue, updater); -} - -export { update }; diff --git a/dist/es/functional/updateIn.js b/dist/es/functional/updateIn.js deleted file mode 100644 index 8b66e52273..0000000000 --- a/dist/es/functional/updateIn.js +++ /dev/null @@ -1,94 +0,0 @@ -/** - * @license - * MIT License - * - * Copyright (c) 2014-present, Lee Byron and other contributors. - * - * 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: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -import { isImmutable } from '../predicates/isImmutable.js'; -import coerceKeyPath from '../utils/coerceKeyPath.js'; -import isDataStructure from '../utils/isDataStructure.js'; -import quoteString from '../utils/quoteString.js'; -import { NOT_SET } from '../TrieUtils.js'; -import { emptyMap } from '../Map.js'; -import { get } from './get.js'; -import { remove } from './remove.js'; -import { set } from './set.js'; - -function updateIn(collection, keyPath, notSetValue, updater) { - if (!updater) { - updater = notSetValue; - notSetValue = undefined; - } - var updatedValue = updateInDeeply( - isImmutable(collection), - collection, - coerceKeyPath(keyPath), - 0, - notSetValue, - updater - ); - return updatedValue === NOT_SET ? notSetValue : updatedValue; -} - -function updateInDeeply( - inImmutable, - existing, - keyPath, - i, - notSetValue, - updater -) { - var wasNotSet = existing === NOT_SET; - if (i === keyPath.length) { - var existingValue = wasNotSet ? notSetValue : existing; - var newValue = updater(existingValue); - return newValue === existingValue ? existing : newValue; - } - if (!wasNotSet && !isDataStructure(existing)) { - throw new TypeError( - 'Cannot update within non-data-structure value in path [' + - keyPath.slice(0, i).map(quoteString) + - ']: ' + - existing - ); - } - var key = keyPath[i]; - var nextExisting = wasNotSet ? NOT_SET : get(existing, key, NOT_SET); - var nextUpdated = updateInDeeply( - nextExisting === NOT_SET ? inImmutable : isImmutable(nextExisting), - nextExisting, - keyPath, - i + 1, - notSetValue, - updater - ); - return nextUpdated === nextExisting - ? existing - : nextUpdated === NOT_SET - ? remove(existing, key) - : set( - wasNotSet ? (inImmutable ? emptyMap() : {}) : existing, - key, - nextUpdated - ); -} - -export { updateIn }; diff --git a/dist/es/is.js b/dist/es/is.js deleted file mode 100644 index 95dcac8c19..0000000000 --- a/dist/es/is.js +++ /dev/null @@ -1,108 +0,0 @@ -/** - * @license - * MIT License - * - * Copyright (c) 2014-present, Lee Byron and other contributors. - * - * 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: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -import { isValueObject } from './predicates/isValueObject.js'; - -/** - * An extension of the "same-value" algorithm as [described for use by ES6 Map - * and Set](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map#Key_equality) - * - * NaN is considered the same as NaN, however -0 and 0 are considered the same - * value, which is different from the algorithm described by - * [`Object.is`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is). - * - * This is extended further to allow Objects to describe the values they - * represent, by way of `valueOf` or `equals` (and `hashCode`). - * - * Note: because of this extension, the key equality of Immutable.Map and the - * value equality of Immutable.Set will differ from ES6 Map and Set. - * - * ### Defining custom values - * - * The easiest way to describe the value an object represents is by implementing - * `valueOf`. For example, `Date` represents a value by returning a unix - * timestamp for `valueOf`: - * - * var date1 = new Date(1234567890000); // Fri Feb 13 2009 ... - * var date2 = new Date(1234567890000); - * date1.valueOf(); // 1234567890000 - * assert( date1 !== date2 ); - * assert( Immutable.is( date1, date2 ) ); - * - * Note: overriding `valueOf` may have other implications if you use this object - * where JavaScript expects a primitive, such as implicit string coercion. - * - * For more complex types, especially collections, implementing `valueOf` may - * not be performant. An alternative is to implement `equals` and `hashCode`. - * - * `equals` takes another object, presumably of similar type, and returns true - * if it is equal. Equality is symmetrical, so the same result should be - * returned if this and the argument are flipped. - * - * assert( a.equals(b) === b.equals(a) ); - * - * `hashCode` returns a 32bit integer number representing the object which will - * be used to determine how to store the value object in a Map or Set. You must - * provide both or neither methods, one must not exist without the other. - * - * Also, an important relationship between these methods must be upheld: if two - * values are equal, they *must* return the same hashCode. If the values are not - * equal, they might have the same hashCode; this is called a hash collision, - * and while undesirable for performance reasons, it is acceptable. - * - * if (a.equals(b)) { - * assert( a.hashCode() === b.hashCode() ); - * } - * - * All Immutable collections are Value Objects: they implement `equals()` - * and `hashCode()`. - */ -function is(valueA, valueB) { - if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) { - return true; - } - if (!valueA || !valueB) { - return false; - } - if ( - typeof valueA.valueOf === 'function' && - typeof valueB.valueOf === 'function' - ) { - valueA = valueA.valueOf(); - valueB = valueB.valueOf(); - if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) { - return true; - } - if (!valueA || !valueB) { - return false; - } - } - return !!( - isValueObject(valueA) && - isValueObject(valueB) && - valueA.equals(valueB) - ); -} - -export { is }; diff --git a/dist/es/methods/asImmutable.js b/dist/es/methods/asImmutable.js deleted file mode 100644 index a634b40ac8..0000000000 --- a/dist/es/methods/asImmutable.js +++ /dev/null @@ -1,29 +0,0 @@ -/** - * @license - * MIT License - * - * Copyright (c) 2014-present, Lee Byron and other contributors. - * - * 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: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -function asImmutable() { - return this.__ensureOwner(); -} - -export { asImmutable }; diff --git a/dist/es/methods/asMutable.js b/dist/es/methods/asMutable.js deleted file mode 100644 index 1d2fbb1e59..0000000000 --- a/dist/es/methods/asMutable.js +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * MIT License - * - * Copyright (c) 2014-present, Lee Byron and other contributors. - * - * 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: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -import { OwnerID } from '../TrieUtils.js'; - -function asMutable() { - return this.__ownerID ? this : this.__ensureOwner(new OwnerID()); -} - -export { asMutable }; diff --git a/dist/es/methods/deleteIn.js b/dist/es/methods/deleteIn.js deleted file mode 100644 index 6b289d201d..0000000000 --- a/dist/es/methods/deleteIn.js +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * MIT License - * - * Copyright (c) 2014-present, Lee Byron and other contributors. - * - * 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: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -import { removeIn } from '../functional/removeIn.js'; - -function deleteIn(keyPath) { - return removeIn(this, keyPath); -} - -export { deleteIn }; diff --git a/dist/es/methods/getIn.js b/dist/es/methods/getIn.js deleted file mode 100644 index c3c46a199f..0000000000 --- a/dist/es/methods/getIn.js +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * MIT License - * - * Copyright (c) 2014-present, Lee Byron and other contributors. - * - * 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: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -import { getIn as getIn$1 } from '../functional/getIn.js'; - -function getIn(searchKeyPath, notSetValue) { - return getIn$1(this, searchKeyPath, notSetValue); -} - -export { getIn }; diff --git a/dist/es/methods/hasIn.js b/dist/es/methods/hasIn.js deleted file mode 100644 index 31d523ccb1..0000000000 --- a/dist/es/methods/hasIn.js +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * MIT License - * - * Copyright (c) 2014-present, Lee Byron and other contributors. - * - * 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: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -import { hasIn as hasIn$1 } from '../functional/hasIn.js'; - -function hasIn(searchKeyPath) { - return hasIn$1(this, searchKeyPath); -} - -export { hasIn }; diff --git a/dist/es/methods/merge.js b/dist/es/methods/merge.js deleted file mode 100644 index 05d3708244..0000000000 --- a/dist/es/methods/merge.js +++ /dev/null @@ -1,79 +0,0 @@ -/** - * @license - * MIT License - * - * Copyright (c) 2014-present, Lee Byron and other contributors. - * - * 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: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -import { KeyedCollection } from '../Collection.js'; -import { NOT_SET } from '../TrieUtils.js'; -import { update } from '../functional/update.js'; - -function merge() { - var iters = [], len = arguments.length; - while ( len-- ) iters[ len ] = arguments[ len ]; - - return mergeIntoKeyedWith(this, iters); -} - -function mergeWith(merger) { - var iters = [], len = arguments.length - 1; - while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; - - if (typeof merger !== 'function') { - throw new TypeError('Invalid merger function: ' + merger); - } - return mergeIntoKeyedWith(this, iters, merger); -} - -function mergeIntoKeyedWith(collection, collections, merger) { - var iters = []; - for (var ii = 0; ii < collections.length; ii++) { - var collection$1 = KeyedCollection(collections[ii]); - if (collection$1.size !== 0) { - iters.push(collection$1); - } - } - if (iters.length === 0) { - return collection; - } - if ( - collection.toSeq().size === 0 && - !collection.__ownerID && - iters.length === 1 - ) { - return collection.constructor(iters[0]); - } - return collection.withMutations(function (collection) { - var mergeIntoCollection = merger - ? function (value, key) { - update(collection, key, NOT_SET, function (oldVal) { return oldVal === NOT_SET ? value : merger(oldVal, value, key); } - ); - } - : function (value, key) { - collection.set(key, value); - }; - for (var ii = 0; ii < iters.length; ii++) { - iters[ii].forEach(mergeIntoCollection); - } - }); -} - -export { merge, mergeWith }; diff --git a/dist/es/methods/mergeDeep.js b/dist/es/methods/mergeDeep.js deleted file mode 100644 index 22b25d1ca1..0000000000 --- a/dist/es/methods/mergeDeep.js +++ /dev/null @@ -1,41 +0,0 @@ -/** - * @license - * MIT License - * - * Copyright (c) 2014-present, Lee Byron and other contributors. - * - * 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: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -import { mergeDeepWithSources } from '../functional/merge.js'; - -function mergeDeep() { - var iters = [], len = arguments.length; - while ( len-- ) iters[ len ] = arguments[ len ]; - - return mergeDeepWithSources(this, iters); -} - -function mergeDeepWith(merger) { - var iters = [], len = arguments.length - 1; - while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; - - return mergeDeepWithSources(this, iters, merger); -} - -export { mergeDeep, mergeDeepWith }; diff --git a/dist/es/methods/mergeDeepIn.js b/dist/es/methods/mergeDeepIn.js deleted file mode 100644 index 3c487586b7..0000000000 --- a/dist/es/methods/mergeDeepIn.js +++ /dev/null @@ -1,37 +0,0 @@ -/** - * @license - * MIT License - * - * Copyright (c) 2014-present, Lee Byron and other contributors. - * - * 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: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -import { mergeDeepWithSources } from '../functional/merge.js'; -import { updateIn } from '../functional/updateIn.js'; -import { emptyMap } from '../Map.js'; - -function mergeDeepIn(keyPath) { - var iters = [], len = arguments.length - 1; - while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; - - return updateIn(this, keyPath, emptyMap(), function (m) { return mergeDeepWithSources(m, iters); } - ); -} - -export { mergeDeepIn }; diff --git a/dist/es/methods/mergeIn.js b/dist/es/methods/mergeIn.js deleted file mode 100644 index 9c2e51ece0..0000000000 --- a/dist/es/methods/mergeIn.js +++ /dev/null @@ -1,36 +0,0 @@ -/** - * @license - * MIT License - * - * Copyright (c) 2014-present, Lee Byron and other contributors. - * - * 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: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -import { mergeWithSources } from '../functional/merge.js'; -import { updateIn } from '../functional/updateIn.js'; -import { emptyMap } from '../Map.js'; - -function mergeIn(keyPath) { - var iters = [], len = arguments.length - 1; - while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; - - return updateIn(this, keyPath, emptyMap(), function (m) { return mergeWithSources(m, iters); }); -} - -export { mergeIn }; diff --git a/dist/es/methods/setIn.js b/dist/es/methods/setIn.js deleted file mode 100644 index 5227a88b05..0000000000 --- a/dist/es/methods/setIn.js +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * MIT License - * - * Copyright (c) 2014-present, Lee Byron and other contributors. - * - * 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: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -import { setIn as setIn$1 } from '../functional/setIn.js'; - -function setIn(keyPath, v) { - return setIn$1(this, keyPath, v); -} - -export { setIn }; diff --git a/dist/es/methods/toObject.js b/dist/es/methods/toObject.js deleted file mode 100644 index 364bbb0746..0000000000 --- a/dist/es/methods/toObject.js +++ /dev/null @@ -1,36 +0,0 @@ -/** - * @license - * MIT License - * - * Copyright (c) 2014-present, Lee Byron and other contributors. - * - * 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: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -import assertNotInfinite from '../utils/assertNotInfinite.js'; - -function toObject() { - assertNotInfinite(this.size); - var object = {}; - this.__iterate(function (v, k) { - object[k] = v; - }); - return object; -} - -export { toObject }; diff --git a/dist/es/methods/update.js b/dist/es/methods/update.js deleted file mode 100644 index f09c0c5f03..0000000000 --- a/dist/es/methods/update.js +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @license - * MIT License - * - * Copyright (c) 2014-present, Lee Byron and other contributors. - * - * 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: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -import { update as update$1 } from '../functional/update.js'; - -function update(key, notSetValue, updater) { - return arguments.length === 1 - ? key(this) - : update$1(this, key, notSetValue, updater); -} - -export { update }; diff --git a/dist/es/methods/updateIn.js b/dist/es/methods/updateIn.js deleted file mode 100644 index bd7c957f78..0000000000 --- a/dist/es/methods/updateIn.js +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * MIT License - * - * Copyright (c) 2014-present, Lee Byron and other contributors. - * - * 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: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -import { updateIn as updateIn$1 } from '../functional/updateIn.js'; - -function updateIn(keyPath, notSetValue, updater) { - return updateIn$1(this, keyPath, notSetValue, updater); -} - -export { updateIn }; diff --git a/dist/es/methods/wasAltered.js b/dist/es/methods/wasAltered.js deleted file mode 100644 index 44cec027d1..0000000000 --- a/dist/es/methods/wasAltered.js +++ /dev/null @@ -1,29 +0,0 @@ -/** - * @license - * MIT License - * - * Copyright (c) 2014-present, Lee Byron and other contributors. - * - * 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: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -function wasAltered() { - return this.__altered; -} - -export { wasAltered }; diff --git a/dist/es/methods/withMutations.js b/dist/es/methods/withMutations.js deleted file mode 100644 index a447af7709..0000000000 --- a/dist/es/methods/withMutations.js +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * MIT License - * - * Copyright (c) 2014-present, Lee Byron and other contributors. - * - * 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: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -function withMutations(fn) { - var mutable = this.asMutable(); - fn(mutable); - return mutable.wasAltered() ? mutable.__ensureOwner(this.__ownerID) : this; -} - -export { withMutations }; diff --git a/dist/es/package.json.js b/dist/es/package.json.js deleted file mode 100644 index 2e261e336c..0000000000 --- a/dist/es/package.json.js +++ /dev/null @@ -1,27 +0,0 @@ -/** - * @license - * MIT License - * - * Copyright (c) 2014-present, Lee Byron and other contributors. - * - * 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: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -var version = "5.0.0"; - -export { version }; diff --git a/dist/es/predicates/isAssociative.js b/dist/es/predicates/isAssociative.js deleted file mode 100644 index 1a1686bf87..0000000000 --- a/dist/es/predicates/isAssociative.js +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @license - * MIT License - * - * Copyright (c) 2014-present, Lee Byron and other contributors. - * - * 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: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -import { isKeyed } from './isKeyed.js'; -import { isIndexed } from './isIndexed.js'; - -function isAssociative(maybeAssociative) { - return isKeyed(maybeAssociative) || isIndexed(maybeAssociative); -} - -export { isAssociative }; diff --git a/dist/es/predicates/isCollection.js b/dist/es/predicates/isCollection.js deleted file mode 100644 index ba73d2cdbd..0000000000 --- a/dist/es/predicates/isCollection.js +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @license - * MIT License - * - * Copyright (c) 2014-present, Lee Byron and other contributors. - * - * 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: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -// Note: value is unchanged to not break immutable-devtools. -var IS_COLLECTION_SYMBOL = '@@__IMMUTABLE_ITERABLE__@@'; - -function isCollection(maybeCollection) { - return Boolean(maybeCollection && maybeCollection[IS_COLLECTION_SYMBOL]); -} - -export { IS_COLLECTION_SYMBOL, isCollection }; diff --git a/dist/es/predicates/isImmutable.js b/dist/es/predicates/isImmutable.js deleted file mode 100644 index e4a99af392..0000000000 --- a/dist/es/predicates/isImmutable.js +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @license - * MIT License - * - * Copyright (c) 2014-present, Lee Byron and other contributors. - * - * 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: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -import { isCollection } from './isCollection.js'; -import { isRecord } from './isRecord.js'; - -function isImmutable(maybeImmutable) { - return isCollection(maybeImmutable) || isRecord(maybeImmutable); -} - -export { isImmutable }; diff --git a/dist/es/predicates/isIndexed.js b/dist/es/predicates/isIndexed.js deleted file mode 100644 index 3a13eb537c..0000000000 --- a/dist/es/predicates/isIndexed.js +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * MIT License - * - * Copyright (c) 2014-present, Lee Byron and other contributors. - * - * 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: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -var IS_INDEXED_SYMBOL = '@@__IMMUTABLE_INDEXED__@@'; - -function isIndexed(maybeIndexed) { - return Boolean(maybeIndexed && maybeIndexed[IS_INDEXED_SYMBOL]); -} - -export { IS_INDEXED_SYMBOL, isIndexed }; diff --git a/dist/es/predicates/isKeyed.js b/dist/es/predicates/isKeyed.js deleted file mode 100644 index c932aa17e9..0000000000 --- a/dist/es/predicates/isKeyed.js +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * MIT License - * - * Copyright (c) 2014-present, Lee Byron and other contributors. - * - * 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: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -var IS_KEYED_SYMBOL = '@@__IMMUTABLE_KEYED__@@'; - -function isKeyed(maybeKeyed) { - return Boolean(maybeKeyed && maybeKeyed[IS_KEYED_SYMBOL]); -} - -export { IS_KEYED_SYMBOL, isKeyed }; diff --git a/dist/es/predicates/isList.js b/dist/es/predicates/isList.js deleted file mode 100644 index bba54d714e..0000000000 --- a/dist/es/predicates/isList.js +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * MIT License - * - * Copyright (c) 2014-present, Lee Byron and other contributors. - * - * 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: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -var IS_LIST_SYMBOL = '@@__IMMUTABLE_LIST__@@'; - -function isList(maybeList) { - return Boolean(maybeList && maybeList[IS_LIST_SYMBOL]); -} - -export { IS_LIST_SYMBOL, isList }; diff --git a/dist/es/predicates/isMap.js b/dist/es/predicates/isMap.js deleted file mode 100644 index b23db2ef36..0000000000 --- a/dist/es/predicates/isMap.js +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * MIT License - * - * Copyright (c) 2014-present, Lee Byron and other contributors. - * - * 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: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -var IS_MAP_SYMBOL = '@@__IMMUTABLE_MAP__@@'; - -function isMap(maybeMap) { - return Boolean(maybeMap && maybeMap[IS_MAP_SYMBOL]); -} - -export { IS_MAP_SYMBOL, isMap }; diff --git a/dist/es/predicates/isOrdered.js b/dist/es/predicates/isOrdered.js deleted file mode 100644 index b490caaf23..0000000000 --- a/dist/es/predicates/isOrdered.js +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * MIT License - * - * Copyright (c) 2014-present, Lee Byron and other contributors. - * - * 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: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -var IS_ORDERED_SYMBOL = '@@__IMMUTABLE_ORDERED__@@'; - -function isOrdered(maybeOrdered) { - return Boolean(maybeOrdered && maybeOrdered[IS_ORDERED_SYMBOL]); -} - -export { IS_ORDERED_SYMBOL, isOrdered }; diff --git a/dist/es/predicates/isOrderedMap.js b/dist/es/predicates/isOrderedMap.js deleted file mode 100644 index bd7f751cf4..0000000000 --- a/dist/es/predicates/isOrderedMap.js +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @license - * MIT License - * - * Copyright (c) 2014-present, Lee Byron and other contributors. - * - * 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: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -import { isMap } from './isMap.js'; -import { isOrdered } from './isOrdered.js'; - -function isOrderedMap(maybeOrderedMap) { - return isMap(maybeOrderedMap) && isOrdered(maybeOrderedMap); -} - -export { isOrderedMap }; diff --git a/dist/es/predicates/isOrderedSet.js b/dist/es/predicates/isOrderedSet.js deleted file mode 100644 index 1accc1de17..0000000000 --- a/dist/es/predicates/isOrderedSet.js +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @license - * MIT License - * - * Copyright (c) 2014-present, Lee Byron and other contributors. - * - * 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: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -import { isSet } from './isSet.js'; -import { isOrdered } from './isOrdered.js'; - -function isOrderedSet(maybeOrderedSet) { - return isSet(maybeOrderedSet) && isOrdered(maybeOrderedSet); -} - -export { isOrderedSet }; diff --git a/dist/es/predicates/isRecord.js b/dist/es/predicates/isRecord.js deleted file mode 100644 index 158bdf8212..0000000000 --- a/dist/es/predicates/isRecord.js +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * MIT License - * - * Copyright (c) 2014-present, Lee Byron and other contributors. - * - * 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: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -var IS_RECORD_SYMBOL = '@@__IMMUTABLE_RECORD__@@'; - -function isRecord(maybeRecord) { - return Boolean(maybeRecord && maybeRecord[IS_RECORD_SYMBOL]); -} - -export { IS_RECORD_SYMBOL, isRecord }; diff --git a/dist/es/predicates/isSeq.js b/dist/es/predicates/isSeq.js deleted file mode 100644 index e1979aed49..0000000000 --- a/dist/es/predicates/isSeq.js +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * MIT License - * - * Copyright (c) 2014-present, Lee Byron and other contributors. - * - * 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: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -var IS_SEQ_SYMBOL = '@@__IMMUTABLE_SEQ__@@'; - -function isSeq(maybeSeq) { - return Boolean(maybeSeq && maybeSeq[IS_SEQ_SYMBOL]); -} - -export { IS_SEQ_SYMBOL, isSeq }; diff --git a/dist/es/predicates/isSet.js b/dist/es/predicates/isSet.js deleted file mode 100644 index ddc509d269..0000000000 --- a/dist/es/predicates/isSet.js +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * MIT License - * - * Copyright (c) 2014-present, Lee Byron and other contributors. - * - * 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: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -var IS_SET_SYMBOL = '@@__IMMUTABLE_SET__@@'; - -function isSet(maybeSet) { - return Boolean(maybeSet && maybeSet[IS_SET_SYMBOL]); -} - -export { IS_SET_SYMBOL, isSet }; diff --git a/dist/es/predicates/isStack.js b/dist/es/predicates/isStack.js deleted file mode 100644 index 7409eb64ea..0000000000 --- a/dist/es/predicates/isStack.js +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @license - * MIT License - * - * Copyright (c) 2014-present, Lee Byron and other contributors. - * - * 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: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -var IS_STACK_SYMBOL = '@@__IMMUTABLE_STACK__@@'; - -function isStack(maybeStack) { - return Boolean(maybeStack && maybeStack[IS_STACK_SYMBOL]); -} - -export { IS_STACK_SYMBOL, isStack }; diff --git a/dist/es/predicates/isValueObject.js b/dist/es/predicates/isValueObject.js deleted file mode 100644 index 3ef2f0e6a8..0000000000 --- a/dist/es/predicates/isValueObject.js +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @license - * MIT License - * - * Copyright (c) 2014-present, Lee Byron and other contributors. - * - * 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: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -function isValueObject(maybeValue) { - return Boolean( - maybeValue && - typeof maybeValue.equals === 'function' && - typeof maybeValue.hashCode === 'function' - ); -} - -export { isValueObject }; diff --git a/dist/es/toJS.js b/dist/es/toJS.js deleted file mode 100644 index bb79094756..0000000000 --- a/dist/es/toJS.js +++ /dev/null @@ -1,54 +0,0 @@ -/** - * @license - * MIT License - * - * Copyright (c) 2014-present, Lee Byron and other contributors. - * - * 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: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -import { Seq } from './Seq.js'; -import { isCollection } from './predicates/isCollection.js'; -import { isKeyed } from './predicates/isKeyed.js'; -import isDataStructure from './utils/isDataStructure.js'; - -function toJS(value) { - if (!value || typeof value !== 'object') { - return value; - } - if (!isCollection(value)) { - if (!isDataStructure(value)) { - return value; - } - value = Seq(value); - } - if (isKeyed(value)) { - var result$1 = {}; - value.__iterate(function (v, k) { - result$1[k] = toJS(v); - }); - return result$1; - } - var result = []; - value.__iterate(function (v) { - result.push(toJS(v)); - }); - return result; -} - -export { toJS }; diff --git a/dist/es/utils/arrCopy.js b/dist/es/utils/arrCopy.js deleted file mode 100644 index 8e173f05d4..0000000000 --- a/dist/es/utils/arrCopy.js +++ /dev/null @@ -1,36 +0,0 @@ -/** - * @license - * MIT License - * - * Copyright (c) 2014-present, Lee Byron and other contributors. - * - * 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: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -// http://jsperf.com/copy-array-inline -function arrCopy(arr, offset) { - offset = offset || 0; - var len = Math.max(0, arr.length - offset); - var newArr = new Array(len); - for (var ii = 0; ii < len; ii++) { - newArr[ii] = arr[ii + offset]; - } - return newArr; -} - -export { arrCopy as default }; diff --git a/dist/es/utils/assertNotInfinite.js b/dist/es/utils/assertNotInfinite.js deleted file mode 100644 index 0f49cb6e99..0000000000 --- a/dist/es/utils/assertNotInfinite.js +++ /dev/null @@ -1,34 +0,0 @@ -/** - * @license - * MIT License - * - * Copyright (c) 2014-present, Lee Byron and other contributors. - * - * 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: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -import invariant from './invariant.js'; - -function assertNotInfinite(size) { - invariant( - size !== Infinity, - 'Cannot perform this action with an infinite size.' - ); -} - -export { assertNotInfinite as default }; diff --git a/dist/es/utils/coerceKeyPath.js b/dist/es/utils/coerceKeyPath.js deleted file mode 100644 index f9dbd0143e..0000000000 --- a/dist/es/utils/coerceKeyPath.js +++ /dev/null @@ -1,40 +0,0 @@ -/** - * @license - * MIT License - * - * Copyright (c) 2014-present, Lee Byron and other contributors. - * - * 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: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -import { isOrdered } from '../predicates/isOrdered.js'; -import isArrayLike from './isArrayLike.js'; - -function coerceKeyPath(keyPath) { - if (isArrayLike(keyPath) && typeof keyPath !== 'string') { - return keyPath; - } - if (isOrdered(keyPath)) { - return keyPath.toArray(); - } - throw new TypeError( - 'Invalid keyPath: expected Ordered Collection or Array: ' + keyPath - ); -} - -export { coerceKeyPath as default }; diff --git a/dist/es/utils/deepEqual.js b/dist/es/utils/deepEqual.js deleted file mode 100644 index c79a31e3a5..0000000000 --- a/dist/es/utils/deepEqual.js +++ /dev/null @@ -1,99 +0,0 @@ -/** - * @license - * MIT License - * - * Copyright (c) 2014-present, Lee Byron and other contributors. - * - * 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: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -import { is } from '../is.js'; -import { NOT_SET } from '../TrieUtils.js'; -import { isCollection } from '../predicates/isCollection.js'; -import { isKeyed } from '../predicates/isKeyed.js'; -import { isIndexed } from '../predicates/isIndexed.js'; -import { isAssociative } from '../predicates/isAssociative.js'; -import { isOrdered } from '../predicates/isOrdered.js'; - -function deepEqual(a, b) { - if (a === b) { - return true; - } - - if ( - !isCollection(b) || - (a.size !== undefined && b.size !== undefined && a.size !== b.size) || - (a.__hash !== undefined && - b.__hash !== undefined && - a.__hash !== b.__hash) || - isKeyed(a) !== isKeyed(b) || - isIndexed(a) !== isIndexed(b) || - isOrdered(a) !== isOrdered(b) - ) { - return false; - } - - if (a.size === 0 && b.size === 0) { - return true; - } - - var notAssociative = !isAssociative(a); - - if (isOrdered(a)) { - var entries = a.entries(); - return ( - b.every(function (v, k) { - var entry = entries.next().value; - return entry && is(entry[1], v) && (notAssociative || is(entry[0], k)); - }) && entries.next().done - ); - } - - var flipped = false; - - if (a.size === undefined) { - if (b.size === undefined) { - if (typeof a.cacheResult === 'function') { - a.cacheResult(); - } - } else { - flipped = true; - var _ = a; - a = b; - b = _; - } - } - - var allEqual = true; - var bSize = b.__iterate(function (v, k) { - if ( - notAssociative - ? !a.has(v) - : flipped - ? !is(v, a.get(k, NOT_SET)) - : !is(a.get(k, NOT_SET), v) - ) { - allEqual = false; - return false; - } - }); - - return allEqual && a.size === bSize; -} - -export { deepEqual as default }; diff --git a/dist/es/utils/hasOwnProperty.js b/dist/es/utils/hasOwnProperty.js deleted file mode 100644 index f5befa4b04..0000000000 --- a/dist/es/utils/hasOwnProperty.js +++ /dev/null @@ -1,27 +0,0 @@ -/** - * @license - * MIT License - * - * Copyright (c) 2014-present, Lee Byron and other contributors. - * - * 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: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -var hasOwnProperty = Object.prototype.hasOwnProperty; - -export { hasOwnProperty as default }; diff --git a/dist/es/utils/invariant.js b/dist/es/utils/invariant.js deleted file mode 100644 index 1495de43c6..0000000000 --- a/dist/es/utils/invariant.js +++ /dev/null @@ -1,29 +0,0 @@ -/** - * @license - * MIT License - * - * Copyright (c) 2014-present, Lee Byron and other contributors. - * - * 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: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -function invariant(condition, error) { - if (!condition) { throw new Error(error); } -} - -export { invariant as default }; diff --git a/dist/es/utils/isArrayLike.js b/dist/es/utils/isArrayLike.js deleted file mode 100644 index d1a26b09c1..0000000000 --- a/dist/es/utils/isArrayLike.js +++ /dev/null @@ -1,44 +0,0 @@ -/** - * @license - * MIT License - * - * Copyright (c) 2014-present, Lee Byron and other contributors. - * - * 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: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -function isArrayLike(value) { - if (Array.isArray(value) || typeof value === 'string') { - return true; - } - - return ( - value && - typeof value === 'object' && - Number.isInteger(value.length) && - value.length >= 0 && - (value.length === 0 - ? // Only {length: 0} is considered Array-like. - Object.keys(value).length === 1 - : // An object is only Array-like if it has a property where the last value - // in the array-like may be found (which could be undefined). - value.hasOwnProperty(value.length - 1)) - ); -} - -export { isArrayLike as default }; diff --git a/dist/es/utils/isDataStructure.js b/dist/es/utils/isDataStructure.js deleted file mode 100644 index 9f8e8d5663..0000000000 --- a/dist/es/utils/isDataStructure.js +++ /dev/null @@ -1,39 +0,0 @@ -/** - * @license - * MIT License - * - * Copyright (c) 2014-present, Lee Byron and other contributors. - * - * 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: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -import { isImmutable } from '../predicates/isImmutable.js'; -import isPlainObject from './isPlainObj.js'; - -/** - * Returns true if the value is a potentially-persistent data structure, either - * provided by Immutable.js or a plain Array or Object. - */ -function isDataStructure(value) { - return ( - typeof value === 'object' && - (isImmutable(value) || Array.isArray(value) || isPlainObject(value)) - ); -} - -export { isDataStructure as default }; diff --git a/dist/es/utils/isPlainObj.js b/dist/es/utils/isPlainObj.js deleted file mode 100644 index 02df7f16f8..0000000000 --- a/dist/es/utils/isPlainObj.js +++ /dev/null @@ -1,52 +0,0 @@ -/** - * @license - * MIT License - * - * Copyright (c) 2014-present, Lee Byron and other contributors. - * - * 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: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -var toString = Object.prototype.toString; - -function isPlainObject(value) { - // The base prototype's toString deals with Argument objects and native namespaces like Math - if ( - !value || - typeof value !== 'object' || - toString.call(value) !== '[object Object]' - ) { - return false; - } - - var proto = Object.getPrototypeOf(value); - if (proto === null) { - return true; - } - - // Iteratively going up the prototype chain is needed for cross-realm environments (differing contexts, iframes, etc) - var parentProto = proto; - var nextProto = Object.getPrototypeOf(proto); - while (nextProto !== null) { - parentProto = nextProto; - nextProto = Object.getPrototypeOf(parentProto); - } - return parentProto === proto; -} - -export { isPlainObject as default }; diff --git a/dist/es/utils/mixin.js b/dist/es/utils/mixin.js deleted file mode 100644 index 35fbe82d97..0000000000 --- a/dist/es/utils/mixin.js +++ /dev/null @@ -1,38 +0,0 @@ -/** - * @license - * MIT License - * - * Copyright (c) 2014-present, Lee Byron and other contributors. - * - * 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: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -/** - * Contributes additional methods to a constructor - */ -function mixin(ctor, methods) { - var keyCopier = function (key) { - ctor.prototype[key] = methods[key]; - }; - Object.keys(methods).forEach(keyCopier); - Object.getOwnPropertySymbols && - Object.getOwnPropertySymbols(methods).forEach(keyCopier); - return ctor; -} - -export { mixin as default }; diff --git a/dist/es/utils/quoteString.js b/dist/es/utils/quoteString.js deleted file mode 100644 index 4059262460..0000000000 --- a/dist/es/utils/quoteString.js +++ /dev/null @@ -1,36 +0,0 @@ -/** - * @license - * MIT License - * - * Copyright (c) 2014-present, Lee Byron and other contributors. - * - * 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: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -/** - * Converts a value to a string, adding quotes if a string was provided. - */ -function quoteString(value) { - try { - return typeof value === 'string' ? JSON.stringify(value) : String(value); - } catch (_ignoreError) { - return JSON.stringify(value); - } -} - -export { quoteString as default }; diff --git a/dist/es/utils/shallowCopy.js b/dist/es/utils/shallowCopy.js deleted file mode 100644 index 4f791ac40c..0000000000 --- a/dist/es/utils/shallowCopy.js +++ /dev/null @@ -1,41 +0,0 @@ -/** - * @license - * MIT License - * - * Copyright (c) 2014-present, Lee Byron and other contributors. - * - * 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: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -import arrCopy from './arrCopy.js'; -import hasOwnProperty from './hasOwnProperty.js'; - -function shallowCopy(from) { - if (Array.isArray(from)) { - return arrCopy(from); - } - var to = {}; - for (var key in from) { - if (hasOwnProperty.call(from, key)) { - to[key] = from[key]; - } - } - return to; -} - -export { shallowCopy as default }; diff --git a/dist/immutable.es.js b/dist/immutable.es.js new file mode 100644 index 0000000000..bdfb3ad72f --- /dev/null +++ b/dist/immutable.es.js @@ -0,0 +1,5930 @@ +/** + * @license + * MIT License + * + * Copyright (c) 2014-present, Lee Byron and other contributors. + * + * 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: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +// Used for setting prototype methods that IE8 chokes on. +var DELETE = 'delete'; + +// Constants describing the size of trie nodes. +var SHIFT = 5; // Resulted in best performance after ______? +var SIZE = 1 << SHIFT; +var MASK = SIZE - 1; + +// A consistent shared value representing "not set" which equals nothing other +// than itself, and nothing that could be provided externally. +var NOT_SET = {}; + +// Boolean references, Rough equivalent of `bool &`. +function MakeRef() { + return { value: false }; +} + +function SetRef(ref) { + if (ref) { + ref.value = true; + } +} + +// A function which returns a value representing an "owner" for transient writes +// to tries. The return value will only ever equal itself, and will not equal +// the return of any subsequent call of this function. +function OwnerID() {} + +function ensureSize(iter) { + if (iter.size === undefined) { + iter.size = iter.__iterate(returnTrue); + } + return iter.size; +} + +function wrapIndex(iter, index) { + // This implements "is array index" which the ECMAString spec defines as: + // + // A String property name P is an array index if and only if + // ToString(ToUint32(P)) is equal to P and ToUint32(P) is not equal + // to 2^32−1. + // + // http://www.ecma-international.org/ecma-262/6.0/#sec-array-exotic-objects + if (typeof index !== 'number') { + var uint32Index = index >>> 0; // N >>> 0 is shorthand for ToUint32 + if ('' + uint32Index !== index || uint32Index === 4294967295) { + return NaN; + } + index = uint32Index; + } + return index < 0 ? ensureSize(iter) + index : index; +} + +function returnTrue() { + return true; +} + +function wholeSlice(begin, end, size) { + return ( + ((begin === 0 && !isNeg(begin)) || + (size !== undefined && begin <= -size)) && + (end === undefined || (size !== undefined && end >= size)) + ); +} + +function resolveBegin(begin, size) { + return resolveIndex(begin, size, 0); +} + +function resolveEnd(end, size) { + return resolveIndex(end, size, size); +} + +function resolveIndex(index, size, defaultIndex) { + // Sanitize indices using this shorthand for ToInt32(argument) + // http://www.ecma-international.org/ecma-262/6.0/#sec-toint32 + return index === undefined + ? defaultIndex + : isNeg(index) + ? size === Infinity + ? size + : Math.max(0, size + index) | 0 + : size === undefined || size === index + ? index + : Math.min(size, index) | 0; +} + +function isNeg(value) { + // Account for -0 which is negative, but not less than 0. + return value < 0 || (value === 0 && 1 / value === -Infinity); +} + +// Note: value is unchanged to not break immutable-devtools. +var IS_COLLECTION_SYMBOL = '@@__IMMUTABLE_ITERABLE__@@'; + +function isCollection(maybeCollection) { + return Boolean(maybeCollection && maybeCollection[IS_COLLECTION_SYMBOL]); +} + +var IS_KEYED_SYMBOL = '@@__IMMUTABLE_KEYED__@@'; + +function isKeyed(maybeKeyed) { + return Boolean(maybeKeyed && maybeKeyed[IS_KEYED_SYMBOL]); +} + +var IS_INDEXED_SYMBOL = '@@__IMMUTABLE_INDEXED__@@'; + +function isIndexed(maybeIndexed) { + return Boolean(maybeIndexed && maybeIndexed[IS_INDEXED_SYMBOL]); +} + +function isAssociative(maybeAssociative) { + return isKeyed(maybeAssociative) || isIndexed(maybeAssociative); +} + +var Collection = function Collection(value) { + // eslint-disable-next-line no-constructor-return + return isCollection(value) ? value : Seq(value); +}; + +var KeyedCollection = /*@__PURE__*/(function (Collection) { + function KeyedCollection(value) { + // eslint-disable-next-line no-constructor-return + return isKeyed(value) ? value : KeyedSeq(value); + } + + if ( Collection ) KeyedCollection.__proto__ = Collection; + KeyedCollection.prototype = Object.create( Collection && Collection.prototype ); + KeyedCollection.prototype.constructor = KeyedCollection; + + return KeyedCollection; +}(Collection)); + +var IndexedCollection = /*@__PURE__*/(function (Collection) { + function IndexedCollection(value) { + // eslint-disable-next-line no-constructor-return + return isIndexed(value) ? value : IndexedSeq(value); + } + + if ( Collection ) IndexedCollection.__proto__ = Collection; + IndexedCollection.prototype = Object.create( Collection && Collection.prototype ); + IndexedCollection.prototype.constructor = IndexedCollection; + + return IndexedCollection; +}(Collection)); + +var SetCollection = /*@__PURE__*/(function (Collection) { + function SetCollection(value) { + // eslint-disable-next-line no-constructor-return + return isCollection(value) && !isAssociative(value) ? value : SetSeq(value); + } + + if ( Collection ) SetCollection.__proto__ = Collection; + SetCollection.prototype = Object.create( Collection && Collection.prototype ); + SetCollection.prototype.constructor = SetCollection; + + return SetCollection; +}(Collection)); + +Collection.Keyed = KeyedCollection; +Collection.Indexed = IndexedCollection; +Collection.Set = SetCollection; + +var IS_SEQ_SYMBOL = '@@__IMMUTABLE_SEQ__@@'; + +function isSeq(maybeSeq) { + return Boolean(maybeSeq && maybeSeq[IS_SEQ_SYMBOL]); +} + +var IS_RECORD_SYMBOL = '@@__IMMUTABLE_RECORD__@@'; + +function isRecord(maybeRecord) { + return Boolean(maybeRecord && maybeRecord[IS_RECORD_SYMBOL]); +} + +function isImmutable(maybeImmutable) { + return isCollection(maybeImmutable) || isRecord(maybeImmutable); +} + +var IS_ORDERED_SYMBOL = '@@__IMMUTABLE_ORDERED__@@'; + +function isOrdered(maybeOrdered) { + return Boolean(maybeOrdered && maybeOrdered[IS_ORDERED_SYMBOL]); +} + +var ITERATE_KEYS = 0; +var ITERATE_VALUES = 1; +var ITERATE_ENTRIES = 2; + +var REAL_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator; +var FAUX_ITERATOR_SYMBOL = '@@iterator'; + +var ITERATOR_SYMBOL = REAL_ITERATOR_SYMBOL || FAUX_ITERATOR_SYMBOL; + +var Iterator = function Iterator(next) { + this.next = next; +}; + +Iterator.prototype.toString = function toString () { + return '[Iterator]'; +}; + +Iterator.KEYS = ITERATE_KEYS; +Iterator.VALUES = ITERATE_VALUES; +Iterator.ENTRIES = ITERATE_ENTRIES; + +Iterator.prototype.inspect = Iterator.prototype.toSource = function () { + return this.toString(); +}; +Iterator.prototype[ITERATOR_SYMBOL] = function () { + return this; +}; + +function iteratorValue(type, k, v, iteratorResult) { + var value = type === 0 ? k : type === 1 ? v : [k, v]; + iteratorResult + ? (iteratorResult.value = value) + : (iteratorResult = { + value: value, + done: false, + }); + return iteratorResult; +} + +function iteratorDone() { + return { value: undefined, done: true }; +} + +function hasIterator(maybeIterable) { + if (Array.isArray(maybeIterable)) { + // IE11 trick as it does not support `Symbol.iterator` + return true; + } + + return !!getIteratorFn(maybeIterable); +} + +function isIterator(maybeIterator) { + return maybeIterator && typeof maybeIterator.next === 'function'; +} + +function getIterator(iterable) { + var iteratorFn = getIteratorFn(iterable); + return iteratorFn && iteratorFn.call(iterable); +} + +function getIteratorFn(iterable) { + var iteratorFn = + iterable && + ((REAL_ITERATOR_SYMBOL && iterable[REAL_ITERATOR_SYMBOL]) || + iterable[FAUX_ITERATOR_SYMBOL]); + if (typeof iteratorFn === 'function') { + return iteratorFn; + } +} + +function isEntriesIterable(maybeIterable) { + var iteratorFn = getIteratorFn(maybeIterable); + return iteratorFn && iteratorFn === maybeIterable.entries; +} + +function isKeysIterable(maybeIterable) { + var iteratorFn = getIteratorFn(maybeIterable); + return iteratorFn && iteratorFn === maybeIterable.keys; +} + +var hasOwnProperty = Object.prototype.hasOwnProperty; + +function isArrayLike(value) { + if (Array.isArray(value) || typeof value === 'string') { + return true; + } + + return ( + value && + typeof value === 'object' && + Number.isInteger(value.length) && + value.length >= 0 && + (value.length === 0 + ? // Only {length: 0} is considered Array-like. + Object.keys(value).length === 1 + : // An object is only Array-like if it has a property where the last value + // in the array-like may be found (which could be undefined). + value.hasOwnProperty(value.length - 1)) + ); +} + +var Seq = /*@__PURE__*/(function (Collection) { + function Seq(value) { + // eslint-disable-next-line no-constructor-return + return value === undefined || value === null + ? emptySequence() + : isImmutable(value) + ? value.toSeq() + : seqFromValue(value); + } + + if ( Collection ) Seq.__proto__ = Collection; + Seq.prototype = Object.create( Collection && Collection.prototype ); + Seq.prototype.constructor = Seq; + + Seq.prototype.toSeq = function toSeq () { + return this; + }; + + Seq.prototype.toString = function toString () { + return this.__toString('Seq {', '}'); + }; + + Seq.prototype.cacheResult = function cacheResult () { + if (!this._cache && this.__iterateUncached) { + this._cache = this.entrySeq().toArray(); + this.size = this._cache.length; + } + return this; + }; + + // abstract __iterateUncached(fn, reverse) + + Seq.prototype.__iterate = function __iterate (fn, reverse) { + var cache = this._cache; + if (cache) { + var size = cache.length; + var i = 0; + while (i !== size) { + var entry = cache[reverse ? size - ++i : i++]; + if (fn(entry[1], entry[0], this) === false) { + break; + } + } + return i; + } + return this.__iterateUncached(fn, reverse); + }; + + // abstract __iteratorUncached(type, reverse) + + Seq.prototype.__iterator = function __iterator (type, reverse) { + var cache = this._cache; + if (cache) { + var size = cache.length; + var i = 0; + return new Iterator(function () { + if (i === size) { + return iteratorDone(); + } + var entry = cache[reverse ? size - ++i : i++]; + return iteratorValue(type, entry[0], entry[1]); + }); + } + return this.__iteratorUncached(type, reverse); + }; + + return Seq; +}(Collection)); + +var KeyedSeq = /*@__PURE__*/(function (Seq) { + function KeyedSeq(value) { + // eslint-disable-next-line no-constructor-return + return value === undefined || value === null + ? emptySequence().toKeyedSeq() + : isCollection(value) + ? isKeyed(value) + ? value.toSeq() + : value.fromEntrySeq() + : isRecord(value) + ? value.toSeq() + : keyedSeqFromValue(value); + } + + if ( Seq ) KeyedSeq.__proto__ = Seq; + KeyedSeq.prototype = Object.create( Seq && Seq.prototype ); + KeyedSeq.prototype.constructor = KeyedSeq; + + KeyedSeq.prototype.toKeyedSeq = function toKeyedSeq () { + return this; + }; + + return KeyedSeq; +}(Seq)); + +var IndexedSeq = /*@__PURE__*/(function (Seq) { + function IndexedSeq(value) { + // eslint-disable-next-line no-constructor-return + return value === undefined || value === null + ? emptySequence() + : isCollection(value) + ? isKeyed(value) + ? value.entrySeq() + : value.toIndexedSeq() + : isRecord(value) + ? value.toSeq().entrySeq() + : indexedSeqFromValue(value); + } + + if ( Seq ) IndexedSeq.__proto__ = Seq; + IndexedSeq.prototype = Object.create( Seq && Seq.prototype ); + IndexedSeq.prototype.constructor = IndexedSeq; + + IndexedSeq.of = function of (/*...values*/) { + return IndexedSeq(arguments); + }; + + IndexedSeq.prototype.toIndexedSeq = function toIndexedSeq () { + return this; + }; + + IndexedSeq.prototype.toString = function toString () { + return this.__toString('Seq [', ']'); + }; + + return IndexedSeq; +}(Seq)); + +var SetSeq = /*@__PURE__*/(function (Seq) { + function SetSeq(value) { + // eslint-disable-next-line no-constructor-return + return ( + isCollection(value) && !isAssociative(value) ? value : IndexedSeq(value) + ).toSetSeq(); + } + + if ( Seq ) SetSeq.__proto__ = Seq; + SetSeq.prototype = Object.create( Seq && Seq.prototype ); + SetSeq.prototype.constructor = SetSeq; + + SetSeq.of = function of (/*...values*/) { + return SetSeq(arguments); + }; + + SetSeq.prototype.toSetSeq = function toSetSeq () { + return this; + }; + + return SetSeq; +}(Seq)); + +Seq.isSeq = isSeq; +Seq.Keyed = KeyedSeq; +Seq.Set = SetSeq; +Seq.Indexed = IndexedSeq; + +Seq.prototype[IS_SEQ_SYMBOL] = true; + +// #pragma Root Sequences + +var ArraySeq = /*@__PURE__*/(function (IndexedSeq) { + function ArraySeq(array) { + this._array = array; + this.size = array.length; + } + + if ( IndexedSeq ) ArraySeq.__proto__ = IndexedSeq; + ArraySeq.prototype = Object.create( IndexedSeq && IndexedSeq.prototype ); + ArraySeq.prototype.constructor = ArraySeq; + + ArraySeq.prototype.get = function get (index, notSetValue) { + return this.has(index) ? this._array[wrapIndex(this, index)] : notSetValue; + }; + + ArraySeq.prototype.__iterate = function __iterate (fn, reverse) { + var array = this._array; + var size = array.length; + var i = 0; + while (i !== size) { + var ii = reverse ? size - ++i : i++; + if (fn(array[ii], ii, this) === false) { + break; + } + } + return i; + }; + + ArraySeq.prototype.__iterator = function __iterator (type, reverse) { + var array = this._array; + var size = array.length; + var i = 0; + return new Iterator(function () { + if (i === size) { + return iteratorDone(); + } + var ii = reverse ? size - ++i : i++; + return iteratorValue(type, ii, array[ii]); + }); + }; + + return ArraySeq; +}(IndexedSeq)); + +var ObjectSeq = /*@__PURE__*/(function (KeyedSeq) { + function ObjectSeq(object) { + var keys = Object.keys(object).concat( + Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(object) : [] + ); + this._object = object; + this._keys = keys; + this.size = keys.length; + } + + if ( KeyedSeq ) ObjectSeq.__proto__ = KeyedSeq; + ObjectSeq.prototype = Object.create( KeyedSeq && KeyedSeq.prototype ); + ObjectSeq.prototype.constructor = ObjectSeq; + + ObjectSeq.prototype.get = function get (key, notSetValue) { + if (notSetValue !== undefined && !this.has(key)) { + return notSetValue; + } + return this._object[key]; + }; + + ObjectSeq.prototype.has = function has (key) { + return hasOwnProperty.call(this._object, key); + }; + + ObjectSeq.prototype.__iterate = function __iterate (fn, reverse) { + var object = this._object; + var keys = this._keys; + var size = keys.length; + var i = 0; + while (i !== size) { + var key = keys[reverse ? size - ++i : i++]; + if (fn(object[key], key, this) === false) { + break; + } + } + return i; + }; + + ObjectSeq.prototype.__iterator = function __iterator (type, reverse) { + var object = this._object; + var keys = this._keys; + var size = keys.length; + var i = 0; + return new Iterator(function () { + if (i === size) { + return iteratorDone(); + } + var key = keys[reverse ? size - ++i : i++]; + return iteratorValue(type, key, object[key]); + }); + }; + + return ObjectSeq; +}(KeyedSeq)); +ObjectSeq.prototype[IS_ORDERED_SYMBOL] = true; + +var CollectionSeq = /*@__PURE__*/(function (IndexedSeq) { + function CollectionSeq(collection) { + this._collection = collection; + this.size = collection.length || collection.size; + } + + if ( IndexedSeq ) CollectionSeq.__proto__ = IndexedSeq; + CollectionSeq.prototype = Object.create( IndexedSeq && IndexedSeq.prototype ); + CollectionSeq.prototype.constructor = CollectionSeq; + + CollectionSeq.prototype.__iterateUncached = function __iterateUncached (fn, reverse) { + if (reverse) { + return this.cacheResult().__iterate(fn, reverse); + } + var collection = this._collection; + var iterator = getIterator(collection); + var iterations = 0; + if (isIterator(iterator)) { + var step; + while (!(step = iterator.next()).done) { + if (fn(step.value, iterations++, this) === false) { + break; + } + } + } + return iterations; + }; + + CollectionSeq.prototype.__iteratorUncached = function __iteratorUncached (type, reverse) { + if (reverse) { + return this.cacheResult().__iterator(type, reverse); + } + var collection = this._collection; + var iterator = getIterator(collection); + if (!isIterator(iterator)) { + return new Iterator(iteratorDone); + } + var iterations = 0; + return new Iterator(function () { + var step = iterator.next(); + return step.done ? step : iteratorValue(type, iterations++, step.value); + }); + }; + + return CollectionSeq; +}(IndexedSeq)); + +// # pragma Helper functions + +var EMPTY_SEQ; + +function emptySequence() { + return EMPTY_SEQ || (EMPTY_SEQ = new ArraySeq([])); +} + +function keyedSeqFromValue(value) { + var seq = maybeIndexedSeqFromValue(value); + if (seq) { + return seq.fromEntrySeq(); + } + if (typeof value === 'object') { + return new ObjectSeq(value); + } + throw new TypeError( + 'Expected Array or collection object of [k, v] entries, or keyed object: ' + + value + ); +} + +function indexedSeqFromValue(value) { + var seq = maybeIndexedSeqFromValue(value); + if (seq) { + return seq; + } + throw new TypeError( + 'Expected Array or collection object of values: ' + value + ); +} + +function seqFromValue(value) { + var seq = maybeIndexedSeqFromValue(value); + if (seq) { + return isEntriesIterable(value) + ? seq.fromEntrySeq() + : isKeysIterable(value) + ? seq.toSetSeq() + : seq; + } + if (typeof value === 'object') { + return new ObjectSeq(value); + } + throw new TypeError( + 'Expected Array or collection object of values, or keyed object: ' + value + ); +} + +function maybeIndexedSeqFromValue(value) { + return isArrayLike(value) + ? new ArraySeq(value) + : hasIterator(value) + ? new CollectionSeq(value) + : undefined; +} + +var IS_MAP_SYMBOL = '@@__IMMUTABLE_MAP__@@'; + +function isMap(maybeMap) { + return Boolean(maybeMap && maybeMap[IS_MAP_SYMBOL]); +} + +function isOrderedMap(maybeOrderedMap) { + return isMap(maybeOrderedMap) && isOrdered(maybeOrderedMap); +} + +function isValueObject(maybeValue) { + return Boolean( + maybeValue && + typeof maybeValue.equals === 'function' && + typeof maybeValue.hashCode === 'function' + ); +} + +/** + * An extension of the "same-value" algorithm as [described for use by ES6 Map + * and Set](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map#Key_equality) + * + * NaN is considered the same as NaN, however -0 and 0 are considered the same + * value, which is different from the algorithm described by + * [`Object.is`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is). + * + * This is extended further to allow Objects to describe the values they + * represent, by way of `valueOf` or `equals` (and `hashCode`). + * + * Note: because of this extension, the key equality of Immutable.Map and the + * value equality of Immutable.Set will differ from ES6 Map and Set. + * + * ### Defining custom values + * + * The easiest way to describe the value an object represents is by implementing + * `valueOf`. For example, `Date` represents a value by returning a unix + * timestamp for `valueOf`: + * + * var date1 = new Date(1234567890000); // Fri Feb 13 2009 ... + * var date2 = new Date(1234567890000); + * date1.valueOf(); // 1234567890000 + * assert( date1 !== date2 ); + * assert( Immutable.is( date1, date2 ) ); + * + * Note: overriding `valueOf` may have other implications if you use this object + * where JavaScript expects a primitive, such as implicit string coercion. + * + * For more complex types, especially collections, implementing `valueOf` may + * not be performant. An alternative is to implement `equals` and `hashCode`. + * + * `equals` takes another object, presumably of similar type, and returns true + * if it is equal. Equality is symmetrical, so the same result should be + * returned if this and the argument are flipped. + * + * assert( a.equals(b) === b.equals(a) ); + * + * `hashCode` returns a 32bit integer number representing the object which will + * be used to determine how to store the value object in a Map or Set. You must + * provide both or neither methods, one must not exist without the other. + * + * Also, an important relationship between these methods must be upheld: if two + * values are equal, they *must* return the same hashCode. If the values are not + * equal, they might have the same hashCode; this is called a hash collision, + * and while undesirable for performance reasons, it is acceptable. + * + * if (a.equals(b)) { + * assert( a.hashCode() === b.hashCode() ); + * } + * + * All Immutable collections are Value Objects: they implement `equals()` + * and `hashCode()`. + */ +function is(valueA, valueB) { + if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) { + return true; + } + if (!valueA || !valueB) { + return false; + } + if ( + typeof valueA.valueOf === 'function' && + typeof valueB.valueOf === 'function' + ) { + valueA = valueA.valueOf(); + valueB = valueB.valueOf(); + if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) { + return true; + } + if (!valueA || !valueB) { + return false; + } + } + return !!( + isValueObject(valueA) && + isValueObject(valueB) && + valueA.equals(valueB) + ); +} + +var imul = + typeof Math.imul === 'function' && Math.imul(0xffffffff, 2) === -2 + ? Math.imul + : function imul(a, b) { + a |= 0; // int + b |= 0; // int + var c = a & 0xffff; + var d = b & 0xffff; + // Shift by 0 fixes the sign on the high part. + return (c * d + ((((a >>> 16) * d + c * (b >>> 16)) << 16) >>> 0)) | 0; // int + }; + +// v8 has an optimization for storing 31-bit signed numbers. +// Values which have either 00 or 11 as the high order bits qualify. +// This function drops the highest order bit in a signed number, maintaining +// the sign bit. +function smi(i32) { + return ((i32 >>> 1) & 0x40000000) | (i32 & 0xbfffffff); +} + +var defaultValueOf = Object.prototype.valueOf; + +function hash(o) { + if (o == null) { + return hashNullish(o); + } + + if (typeof o.hashCode === 'function') { + // Drop any high bits from accidentally long hash codes. + return smi(o.hashCode(o)); + } + + var v = valueOf(o); + + if (v == null) { + return hashNullish(v); + } + + switch (typeof v) { + case 'boolean': + // The hash values for built-in constants are a 1 value for each 5-byte + // shift region expect for the first, which encodes the value. This + // reduces the odds of a hash collision for these common values. + return v ? 0x42108421 : 0x42108420; + case 'number': + return hashNumber(v); + case 'string': + return v.length > STRING_HASH_CACHE_MIN_STRLEN + ? cachedHashString(v) + : hashString(v); + case 'object': + case 'function': + return hashJSObj(v); + case 'symbol': + return hashSymbol(v); + default: + if (typeof v.toString === 'function') { + return hashString(v.toString()); + } + throw new Error('Value type ' + typeof v + ' cannot be hashed.'); + } +} + +function hashNullish(nullish) { + return nullish === null ? 0x42108422 : /* undefined */ 0x42108423; +} + +// Compress arbitrarily large numbers into smi hashes. +function hashNumber(n) { + if (n !== n || n === Infinity) { + return 0; + } + var hash = n | 0; + if (hash !== n) { + hash ^= n * 0xffffffff; + } + while (n > 0xffffffff) { + n /= 0xffffffff; + hash ^= n; + } + return smi(hash); +} + +function cachedHashString(string) { + var hashed = stringHashCache[string]; + if (hashed === undefined) { + hashed = hashString(string); + if (STRING_HASH_CACHE_SIZE === STRING_HASH_CACHE_MAX_SIZE) { + STRING_HASH_CACHE_SIZE = 0; + stringHashCache = {}; + } + STRING_HASH_CACHE_SIZE++; + stringHashCache[string] = hashed; + } + return hashed; +} + +// http://jsperf.com/hashing-strings +function hashString(string) { + // This is the hash from JVM + // The hash code for a string is computed as + // s[0] * 31 ^ (n - 1) + s[1] * 31 ^ (n - 2) + ... + s[n - 1], + // where s[i] is the ith character of the string and n is the length of + // the string. We "mod" the result to make it between 0 (inclusive) and 2^31 + // (exclusive) by dropping high bits. + var hashed = 0; + for (var ii = 0; ii < string.length; ii++) { + hashed = (31 * hashed + string.charCodeAt(ii)) | 0; + } + return smi(hashed); +} + +function hashSymbol(sym) { + var hashed = symbolMap[sym]; + if (hashed !== undefined) { + return hashed; + } + + hashed = nextHash(); + + symbolMap[sym] = hashed; + + return hashed; +} + +function hashJSObj(obj) { + var hashed; + if (usingWeakMap) { + hashed = weakMap.get(obj); + if (hashed !== undefined) { + return hashed; + } + } + + hashed = obj[UID_HASH_KEY]; + if (hashed !== undefined) { + return hashed; + } + + if (!canDefineProperty) { + hashed = obj.propertyIsEnumerable && obj.propertyIsEnumerable[UID_HASH_KEY]; + if (hashed !== undefined) { + return hashed; + } + + hashed = getIENodeHash(obj); + if (hashed !== undefined) { + return hashed; + } + } + + hashed = nextHash(); + + if (usingWeakMap) { + weakMap.set(obj, hashed); + } else if (isExtensible !== undefined && isExtensible(obj) === false) { + throw new Error('Non-extensible objects are not allowed as keys.'); + } else if (canDefineProperty) { + Object.defineProperty(obj, UID_HASH_KEY, { + enumerable: false, + configurable: false, + writable: false, + value: hashed, + }); + } else if ( + obj.propertyIsEnumerable !== undefined && + obj.propertyIsEnumerable === obj.constructor.prototype.propertyIsEnumerable + ) { + // Since we can't define a non-enumerable property on the object + // we'll hijack one of the less-used non-enumerable properties to + // save our hash on it. Since this is a function it will not show up in + // `JSON.stringify` which is what we want. + obj.propertyIsEnumerable = function () { + return this.constructor.prototype.propertyIsEnumerable.apply( + this, + arguments + ); + }; + obj.propertyIsEnumerable[UID_HASH_KEY] = hashed; + } else if (obj.nodeType !== undefined) { + // At this point we couldn't get the IE `uniqueID` to use as a hash + // and we couldn't use a non-enumerable property to exploit the + // dontEnum bug so we simply add the `UID_HASH_KEY` on the node + // itself. + obj[UID_HASH_KEY] = hashed; + } else { + throw new Error('Unable to set a non-enumerable property on object.'); + } + + return hashed; +} + +// Get references to ES5 object methods. +var isExtensible = Object.isExtensible; + +// True if Object.defineProperty works as expected. IE8 fails this test. +var canDefineProperty = (function () { + try { + Object.defineProperty({}, '@', {}); + return true; + } catch (e) { + return false; + } +})(); + +// IE has a `uniqueID` property on DOM nodes. We can construct the hash from it +// and avoid memory leaks from the IE cloneNode bug. +function getIENodeHash(node) { + if (node && node.nodeType > 0) { + switch (node.nodeType) { + case 1: // Element + return node.uniqueID; + case 9: // Document + return node.documentElement && node.documentElement.uniqueID; + } + } +} + +function valueOf(obj) { + return obj.valueOf !== defaultValueOf && typeof obj.valueOf === 'function' + ? obj.valueOf(obj) + : obj; +} + +function nextHash() { + var nextHash = ++_objHashUID; + if (_objHashUID & 0x40000000) { + _objHashUID = 0; + } + return nextHash; +} + +// If possible, use a WeakMap. +var usingWeakMap = typeof WeakMap === 'function'; +var weakMap; +if (usingWeakMap) { + weakMap = new WeakMap(); +} + +var symbolMap = Object.create(null); + +var _objHashUID = 0; + +var UID_HASH_KEY = '__immutablehash__'; +if (typeof Symbol === 'function') { + UID_HASH_KEY = Symbol(UID_HASH_KEY); +} + +var STRING_HASH_CACHE_MIN_STRLEN = 16; +var STRING_HASH_CACHE_MAX_SIZE = 255; +var STRING_HASH_CACHE_SIZE = 0; +var stringHashCache = {}; + +var ToKeyedSequence = /*@__PURE__*/(function (KeyedSeq) { + function ToKeyedSequence(indexed, useKeys) { + this._iter = indexed; + this._useKeys = useKeys; + this.size = indexed.size; + } + + if ( KeyedSeq ) ToKeyedSequence.__proto__ = KeyedSeq; + ToKeyedSequence.prototype = Object.create( KeyedSeq && KeyedSeq.prototype ); + ToKeyedSequence.prototype.constructor = ToKeyedSequence; + + ToKeyedSequence.prototype.get = function get (key, notSetValue) { + return this._iter.get(key, notSetValue); + }; + + ToKeyedSequence.prototype.has = function has (key) { + return this._iter.has(key); + }; + + ToKeyedSequence.prototype.valueSeq = function valueSeq () { + return this._iter.valueSeq(); + }; + + ToKeyedSequence.prototype.reverse = function reverse () { + var this$1$1 = this; + + var reversedSequence = reverseFactory(this, true); + if (!this._useKeys) { + reversedSequence.valueSeq = function () { return this$1$1._iter.toSeq().reverse(); }; + } + return reversedSequence; + }; + + ToKeyedSequence.prototype.map = function map (mapper, context) { + var this$1$1 = this; + + var mappedSequence = mapFactory(this, mapper, context); + if (!this._useKeys) { + mappedSequence.valueSeq = function () { return this$1$1._iter.toSeq().map(mapper, context); }; + } + return mappedSequence; + }; + + ToKeyedSequence.prototype.__iterate = function __iterate (fn, reverse) { + var this$1$1 = this; + + return this._iter.__iterate(function (v, k) { return fn(v, k, this$1$1); }, reverse); + }; + + ToKeyedSequence.prototype.__iterator = function __iterator (type, reverse) { + return this._iter.__iterator(type, reverse); + }; + + return ToKeyedSequence; +}(KeyedSeq)); +ToKeyedSequence.prototype[IS_ORDERED_SYMBOL] = true; + +var ToIndexedSequence = /*@__PURE__*/(function (IndexedSeq) { + function ToIndexedSequence(iter) { + this._iter = iter; + this.size = iter.size; + } + + if ( IndexedSeq ) ToIndexedSequence.__proto__ = IndexedSeq; + ToIndexedSequence.prototype = Object.create( IndexedSeq && IndexedSeq.prototype ); + ToIndexedSequence.prototype.constructor = ToIndexedSequence; + + ToIndexedSequence.prototype.includes = function includes (value) { + return this._iter.includes(value); + }; + + ToIndexedSequence.prototype.__iterate = function __iterate (fn, reverse) { + var this$1$1 = this; + + var i = 0; + reverse && ensureSize(this); + return this._iter.__iterate( + function (v) { return fn(v, reverse ? this$1$1.size - ++i : i++, this$1$1); }, + reverse + ); + }; + + ToIndexedSequence.prototype.__iterator = function __iterator (type, reverse) { + var this$1$1 = this; + + var iterator = this._iter.__iterator(ITERATE_VALUES, reverse); + var i = 0; + reverse && ensureSize(this); + return new Iterator(function () { + var step = iterator.next(); + return step.done + ? step + : iteratorValue( + type, + reverse ? this$1$1.size - ++i : i++, + step.value, + step + ); + }); + }; + + return ToIndexedSequence; +}(IndexedSeq)); + +var ToSetSequence = /*@__PURE__*/(function (SetSeq) { + function ToSetSequence(iter) { + this._iter = iter; + this.size = iter.size; + } + + if ( SetSeq ) ToSetSequence.__proto__ = SetSeq; + ToSetSequence.prototype = Object.create( SetSeq && SetSeq.prototype ); + ToSetSequence.prototype.constructor = ToSetSequence; + + ToSetSequence.prototype.has = function has (key) { + return this._iter.includes(key); + }; + + ToSetSequence.prototype.__iterate = function __iterate (fn, reverse) { + var this$1$1 = this; + + return this._iter.__iterate(function (v) { return fn(v, v, this$1$1); }, reverse); + }; + + ToSetSequence.prototype.__iterator = function __iterator (type, reverse) { + var iterator = this._iter.__iterator(ITERATE_VALUES, reverse); + return new Iterator(function () { + var step = iterator.next(); + return step.done + ? step + : iteratorValue(type, step.value, step.value, step); + }); + }; + + return ToSetSequence; +}(SetSeq)); + +var FromEntriesSequence = /*@__PURE__*/(function (KeyedSeq) { + function FromEntriesSequence(entries) { + this._iter = entries; + this.size = entries.size; + } + + if ( KeyedSeq ) FromEntriesSequence.__proto__ = KeyedSeq; + FromEntriesSequence.prototype = Object.create( KeyedSeq && KeyedSeq.prototype ); + FromEntriesSequence.prototype.constructor = FromEntriesSequence; + + FromEntriesSequence.prototype.entrySeq = function entrySeq () { + return this._iter.toSeq(); + }; + + FromEntriesSequence.prototype.__iterate = function __iterate (fn, reverse) { + var this$1$1 = this; + + return this._iter.__iterate(function (entry) { + // Check if entry exists first so array access doesn't throw for holes + // in the parent iteration. + if (entry) { + validateEntry(entry); + var indexedCollection = isCollection(entry); + return fn( + indexedCollection ? entry.get(1) : entry[1], + indexedCollection ? entry.get(0) : entry[0], + this$1$1 + ); + } + }, reverse); + }; + + FromEntriesSequence.prototype.__iterator = function __iterator (type, reverse) { + var iterator = this._iter.__iterator(ITERATE_VALUES, reverse); + return new Iterator(function () { + while (true) { + var step = iterator.next(); + if (step.done) { + return step; + } + var entry = step.value; + // Check if entry exists first so array access doesn't throw for holes + // in the parent iteration. + if (entry) { + validateEntry(entry); + var indexedCollection = isCollection(entry); + return iteratorValue( + type, + indexedCollection ? entry.get(0) : entry[0], + indexedCollection ? entry.get(1) : entry[1], + step + ); + } + } + }); + }; + + return FromEntriesSequence; +}(KeyedSeq)); + +ToIndexedSequence.prototype.cacheResult = + ToKeyedSequence.prototype.cacheResult = + ToSetSequence.prototype.cacheResult = + FromEntriesSequence.prototype.cacheResult = + cacheResultThrough; + +function flipFactory(collection) { + var flipSequence = makeSequence(collection); + flipSequence._iter = collection; + flipSequence.size = collection.size; + flipSequence.flip = function () { return collection; }; + flipSequence.reverse = function () { + var reversedSequence = collection.reverse.apply(this); // super.reverse() + reversedSequence.flip = function () { return collection.reverse(); }; + return reversedSequence; + }; + flipSequence.has = function (key) { return collection.includes(key); }; + flipSequence.includes = function (key) { return collection.has(key); }; + flipSequence.cacheResult = cacheResultThrough; + flipSequence.__iterateUncached = function (fn, reverse) { + var this$1$1 = this; + + return collection.__iterate(function (v, k) { return fn(k, v, this$1$1) !== false; }, reverse); + }; + flipSequence.__iteratorUncached = function (type, reverse) { + if (type === ITERATE_ENTRIES) { + var iterator = collection.__iterator(type, reverse); + return new Iterator(function () { + var step = iterator.next(); + if (!step.done) { + var k = step.value[0]; + step.value[0] = step.value[1]; + step.value[1] = k; + } + return step; + }); + } + return collection.__iterator( + type === ITERATE_VALUES ? ITERATE_KEYS : ITERATE_VALUES, + reverse + ); + }; + return flipSequence; +} + +function mapFactory(collection, mapper, context) { + var mappedSequence = makeSequence(collection); + mappedSequence.size = collection.size; + mappedSequence.has = function (key) { return collection.has(key); }; + mappedSequence.get = function (key, notSetValue) { + var v = collection.get(key, NOT_SET); + return v === NOT_SET + ? notSetValue + : mapper.call(context, v, key, collection); + }; + mappedSequence.__iterateUncached = function (fn, reverse) { + var this$1$1 = this; + + return collection.__iterate( + function (v, k, c) { return fn(mapper.call(context, v, k, c), k, this$1$1) !== false; }, + reverse + ); + }; + mappedSequence.__iteratorUncached = function (type, reverse) { + var iterator = collection.__iterator(ITERATE_ENTRIES, reverse); + return new Iterator(function () { + var step = iterator.next(); + if (step.done) { + return step; + } + var entry = step.value; + var key = entry[0]; + return iteratorValue( + type, + key, + mapper.call(context, entry[1], key, collection), + step + ); + }); + }; + return mappedSequence; +} + +function reverseFactory(collection, useKeys) { + var this$1$1 = this; + + var reversedSequence = makeSequence(collection); + reversedSequence._iter = collection; + reversedSequence.size = collection.size; + reversedSequence.reverse = function () { return collection; }; + if (collection.flip) { + reversedSequence.flip = function () { + var flipSequence = flipFactory(collection); + flipSequence.reverse = function () { return collection.flip(); }; + return flipSequence; + }; + } + reversedSequence.get = function (key, notSetValue) { return collection.get(useKeys ? key : -1 - key, notSetValue); }; + reversedSequence.has = function (key) { return collection.has(useKeys ? key : -1 - key); }; + reversedSequence.includes = function (value) { return collection.includes(value); }; + reversedSequence.cacheResult = cacheResultThrough; + reversedSequence.__iterate = function (fn, reverse) { + var this$1$1 = this; + + var i = 0; + reverse && ensureSize(collection); + return collection.__iterate( + function (v, k) { return fn(v, useKeys ? k : reverse ? this$1$1.size - ++i : i++, this$1$1); }, + !reverse + ); + }; + reversedSequence.__iterator = function (type, reverse) { + var i = 0; + reverse && ensureSize(collection); + var iterator = collection.__iterator(ITERATE_ENTRIES, !reverse); + return new Iterator(function () { + var step = iterator.next(); + if (step.done) { + return step; + } + var entry = step.value; + return iteratorValue( + type, + useKeys ? entry[0] : reverse ? this$1$1.size - ++i : i++, + entry[1], + step + ); + }); + }; + return reversedSequence; +} + +function filterFactory(collection, predicate, context, useKeys) { + var filterSequence = makeSequence(collection); + if (useKeys) { + filterSequence.has = function (key) { + var v = collection.get(key, NOT_SET); + return v !== NOT_SET && !!predicate.call(context, v, key, collection); + }; + filterSequence.get = function (key, notSetValue) { + var v = collection.get(key, NOT_SET); + return v !== NOT_SET && predicate.call(context, v, key, collection) + ? v + : notSetValue; + }; + } + filterSequence.__iterateUncached = function (fn, reverse) { + var this$1$1 = this; + + var iterations = 0; + collection.__iterate(function (v, k, c) { + if (predicate.call(context, v, k, c)) { + iterations++; + return fn(v, useKeys ? k : iterations - 1, this$1$1); + } + }, reverse); + return iterations; + }; + filterSequence.__iteratorUncached = function (type, reverse) { + var iterator = collection.__iterator(ITERATE_ENTRIES, reverse); + var iterations = 0; + return new Iterator(function () { + while (true) { + var step = iterator.next(); + if (step.done) { + return step; + } + var entry = step.value; + var key = entry[0]; + var value = entry[1]; + if (predicate.call(context, value, key, collection)) { + return iteratorValue(type, useKeys ? key : iterations++, value, step); + } + } + }); + }; + return filterSequence; +} + +function countByFactory(collection, grouper, context) { + var groups = Map().asMutable(); + collection.__iterate(function (v, k) { + groups.update(grouper.call(context, v, k, collection), 0, function (a) { return a + 1; }); + }); + return groups.asImmutable(); +} + +function groupByFactory(collection, grouper, context) { + var isKeyedIter = isKeyed(collection); + var groups = (isOrdered(collection) ? OrderedMap() : Map()).asMutable(); + collection.__iterate(function (v, k) { + groups.update( + grouper.call(context, v, k, collection), + function (a) { return ((a = a || []), a.push(isKeyedIter ? [k, v] : v), a); } + ); + }); + var coerce = collectionClass(collection); + return groups.map(function (arr) { return reify(collection, coerce(arr)); }).asImmutable(); +} + +function partitionFactory(collection, predicate, context) { + var isKeyedIter = isKeyed(collection); + var groups = [[], []]; + collection.__iterate(function (v, k) { + groups[predicate.call(context, v, k, collection) ? 1 : 0].push( + isKeyedIter ? [k, v] : v + ); + }); + var coerce = collectionClass(collection); + return groups.map(function (arr) { return reify(collection, coerce(arr)); }); +} + +function sliceFactory(collection, begin, end, useKeys) { + var originalSize = collection.size; + + if (wholeSlice(begin, end, originalSize)) { + return collection; + } + + // begin or end can not be resolved if they were provided as negative numbers and + // this collection's size is unknown. In that case, cache first so there is + // a known size and these do not resolve to NaN. + if (typeof originalSize === 'undefined' && (begin < 0 || end < 0)) { + return sliceFactory(collection.toSeq().cacheResult(), begin, end, useKeys); + } + + var resolvedBegin = resolveBegin(begin, originalSize); + var resolvedEnd = resolveEnd(end, originalSize); + + // Note: resolvedEnd is undefined when the original sequence's length is + // unknown and this slice did not supply an end and should contain all + // elements after resolvedBegin. + // In that case, resolvedSize will be NaN and sliceSize will remain undefined. + var resolvedSize = resolvedEnd - resolvedBegin; + var sliceSize; + if (resolvedSize === resolvedSize) { + sliceSize = resolvedSize < 0 ? 0 : resolvedSize; + } + + var sliceSeq = makeSequence(collection); + + // If collection.size is undefined, the size of the realized sliceSeq is + // unknown at this point unless the number of items to slice is 0 + sliceSeq.size = + sliceSize === 0 ? sliceSize : (collection.size && sliceSize) || undefined; + + if (!useKeys && isSeq(collection) && sliceSize >= 0) { + sliceSeq.get = function (index, notSetValue) { + index = wrapIndex(this, index); + return index >= 0 && index < sliceSize + ? collection.get(index + resolvedBegin, notSetValue) + : notSetValue; + }; + } + + sliceSeq.__iterateUncached = function (fn, reverse) { + var this$1$1 = this; + + if (sliceSize === 0) { + return 0; + } + if (reverse) { + return this.cacheResult().__iterate(fn, reverse); + } + var skipped = 0; + var isSkipping = true; + var iterations = 0; + collection.__iterate(function (v, k) { + if (!(isSkipping && (isSkipping = skipped++ < resolvedBegin))) { + iterations++; + return ( + fn(v, useKeys ? k : iterations - 1, this$1$1) !== false && + iterations !== sliceSize + ); + } + }); + return iterations; + }; + + sliceSeq.__iteratorUncached = function (type, reverse) { + if (sliceSize !== 0 && reverse) { + return this.cacheResult().__iterator(type, reverse); + } + // Don't bother instantiating parent iterator if taking 0. + if (sliceSize === 0) { + return new Iterator(iteratorDone); + } + var iterator = collection.__iterator(type, reverse); + var skipped = 0; + var iterations = 0; + return new Iterator(function () { + while (skipped++ < resolvedBegin) { + iterator.next(); + } + if (++iterations > sliceSize) { + return iteratorDone(); + } + var step = iterator.next(); + if (useKeys || type === ITERATE_VALUES || step.done) { + return step; + } + if (type === ITERATE_KEYS) { + return iteratorValue(type, iterations - 1, undefined, step); + } + return iteratorValue(type, iterations - 1, step.value[1], step); + }); + }; + + return sliceSeq; +} + +function takeWhileFactory(collection, predicate, context) { + var takeSequence = makeSequence(collection); + takeSequence.__iterateUncached = function (fn, reverse) { + var this$1$1 = this; + + if (reverse) { + return this.cacheResult().__iterate(fn, reverse); + } + var iterations = 0; + collection.__iterate( + function (v, k, c) { return predicate.call(context, v, k, c) && ++iterations && fn(v, k, this$1$1); } + ); + return iterations; + }; + takeSequence.__iteratorUncached = function (type, reverse) { + var this$1$1 = this; + + if (reverse) { + return this.cacheResult().__iterator(type, reverse); + } + var iterator = collection.__iterator(ITERATE_ENTRIES, reverse); + var iterating = true; + return new Iterator(function () { + if (!iterating) { + return iteratorDone(); + } + var step = iterator.next(); + if (step.done) { + return step; + } + var entry = step.value; + var k = entry[0]; + var v = entry[1]; + if (!predicate.call(context, v, k, this$1$1)) { + iterating = false; + return iteratorDone(); + } + return type === ITERATE_ENTRIES ? step : iteratorValue(type, k, v, step); + }); + }; + return takeSequence; +} + +function skipWhileFactory(collection, predicate, context, useKeys) { + var skipSequence = makeSequence(collection); + skipSequence.__iterateUncached = function (fn, reverse) { + var this$1$1 = this; + + if (reverse) { + return this.cacheResult().__iterate(fn, reverse); + } + var isSkipping = true; + var iterations = 0; + collection.__iterate(function (v, k, c) { + if (!(isSkipping && (isSkipping = predicate.call(context, v, k, c)))) { + iterations++; + return fn(v, useKeys ? k : iterations - 1, this$1$1); + } + }); + return iterations; + }; + skipSequence.__iteratorUncached = function (type, reverse) { + var this$1$1 = this; + + if (reverse) { + return this.cacheResult().__iterator(type, reverse); + } + var iterator = collection.__iterator(ITERATE_ENTRIES, reverse); + var skipping = true; + var iterations = 0; + return new Iterator(function () { + var step; + var k; + var v; + do { + step = iterator.next(); + if (step.done) { + if (useKeys || type === ITERATE_VALUES) { + return step; + } + if (type === ITERATE_KEYS) { + return iteratorValue(type, iterations++, undefined, step); + } + return iteratorValue(type, iterations++, step.value[1], step); + } + var entry = step.value; + k = entry[0]; + v = entry[1]; + skipping && (skipping = predicate.call(context, v, k, this$1$1)); + } while (skipping); + return type === ITERATE_ENTRIES ? step : iteratorValue(type, k, v, step); + }); + }; + return skipSequence; +} + +function concatFactory(collection, values) { + var isKeyedCollection = isKeyed(collection); + var iters = [collection] + .concat(values) + .map(function (v) { + if (!isCollection(v)) { + v = isKeyedCollection + ? keyedSeqFromValue(v) + : indexedSeqFromValue(Array.isArray(v) ? v : [v]); + } else if (isKeyedCollection) { + v = KeyedCollection(v); + } + return v; + }) + .filter(function (v) { return v.size !== 0; }); + + if (iters.length === 0) { + return collection; + } + + if (iters.length === 1) { + var singleton = iters[0]; + if ( + singleton === collection || + (isKeyedCollection && isKeyed(singleton)) || + (isIndexed(collection) && isIndexed(singleton)) + ) { + return singleton; + } + } + + var concatSeq = new ArraySeq(iters); + if (isKeyedCollection) { + concatSeq = concatSeq.toKeyedSeq(); + } else if (!isIndexed(collection)) { + concatSeq = concatSeq.toSetSeq(); + } + concatSeq = concatSeq.flatten(true); + concatSeq.size = iters.reduce(function (sum, seq) { + if (sum !== undefined) { + var size = seq.size; + if (size !== undefined) { + return sum + size; + } + } + }, 0); + return concatSeq; +} + +function flattenFactory(collection, depth, useKeys) { + var flatSequence = makeSequence(collection); + flatSequence.__iterateUncached = function (fn, reverse) { + if (reverse) { + return this.cacheResult().__iterate(fn, reverse); + } + var iterations = 0; + var stopped = false; + function flatDeep(iter, currentDepth) { + iter.__iterate(function (v, k) { + if ((!depth || currentDepth < depth) && isCollection(v)) { + flatDeep(v, currentDepth + 1); + } else { + iterations++; + if (fn(v, useKeys ? k : iterations - 1, flatSequence) === false) { + stopped = true; + } + } + return !stopped; + }, reverse); + } + flatDeep(collection, 0); + return iterations; + }; + flatSequence.__iteratorUncached = function (type, reverse) { + if (reverse) { + return this.cacheResult().__iterator(type, reverse); + } + var iterator = collection.__iterator(type, reverse); + var stack = []; + var iterations = 0; + return new Iterator(function () { + while (iterator) { + var step = iterator.next(); + if (step.done !== false) { + iterator = stack.pop(); + continue; + } + var v = step.value; + if (type === ITERATE_ENTRIES) { + v = v[1]; + } + if ((!depth || stack.length < depth) && isCollection(v)) { + stack.push(iterator); + iterator = v.__iterator(type, reverse); + } else { + return useKeys ? step : iteratorValue(type, iterations++, v, step); + } + } + return iteratorDone(); + }); + }; + return flatSequence; +} + +function flatMapFactory(collection, mapper, context) { + var coerce = collectionClass(collection); + return collection + .toSeq() + .map(function (v, k) { return coerce(mapper.call(context, v, k, collection)); }) + .flatten(true); +} + +function interposeFactory(collection, separator) { + var interposedSequence = makeSequence(collection); + interposedSequence.size = collection.size && collection.size * 2 - 1; + interposedSequence.__iterateUncached = function (fn, reverse) { + var this$1$1 = this; + + var iterations = 0; + collection.__iterate( + function (v) { return (!iterations || fn(separator, iterations++, this$1$1) !== false) && + fn(v, iterations++, this$1$1) !== false; }, + reverse + ); + return iterations; + }; + interposedSequence.__iteratorUncached = function (type, reverse) { + var iterator = collection.__iterator(ITERATE_VALUES, reverse); + var iterations = 0; + var step; + return new Iterator(function () { + if (!step || iterations % 2) { + step = iterator.next(); + if (step.done) { + return step; + } + } + return iterations % 2 + ? iteratorValue(type, iterations++, separator) + : iteratorValue(type, iterations++, step.value, step); + }); + }; + return interposedSequence; +} + +function sortFactory(collection, comparator, mapper) { + if (!comparator) { + comparator = defaultComparator; + } + var isKeyedCollection = isKeyed(collection); + var index = 0; + var entries = collection + .toSeq() + .map(function (v, k) { return [k, v, index++, mapper ? mapper(v, k, collection) : v]; }) + .valueSeq() + .toArray(); + entries + .sort(function (a, b) { return comparator(a[3], b[3]) || a[2] - b[2]; }) + .forEach( + isKeyedCollection + ? function (v, i) { + entries[i].length = 2; + } + : function (v, i) { + entries[i] = v[1]; + } + ); + return isKeyedCollection + ? KeyedSeq(entries) + : isIndexed(collection) + ? IndexedSeq(entries) + : SetSeq(entries); +} + +function maxFactory(collection, comparator, mapper) { + if (!comparator) { + comparator = defaultComparator; + } + if (mapper) { + var entry = collection + .toSeq() + .map(function (v, k) { return [v, mapper(v, k, collection)]; }) + .reduce(function (a, b) { return (maxCompare(comparator, a[1], b[1]) ? b : a); }); + return entry && entry[0]; + } + return collection.reduce(function (a, b) { return (maxCompare(comparator, a, b) ? b : a); }); +} + +function maxCompare(comparator, a, b) { + var comp = comparator(b, a); + // b is considered the new max if the comparator declares them equal, but + // they are not equal and b is in fact a nullish value. + return ( + (comp === 0 && b !== a && (b === undefined || b === null || b !== b)) || + comp > 0 + ); +} + +function zipWithFactory(keyIter, zipper, iters, zipAll) { + var zipSequence = makeSequence(keyIter); + var sizes = new ArraySeq(iters).map(function (i) { return i.size; }); + zipSequence.size = zipAll ? sizes.max() : sizes.min(); + // Note: this a generic base implementation of __iterate in terms of + // __iterator which may be more generically useful in the future. + zipSequence.__iterate = function (fn, reverse) { + /* generic: + var iterator = this.__iterator(ITERATE_ENTRIES, reverse); + var step; + var iterations = 0; + while (!(step = iterator.next()).done) { + iterations++; + if (fn(step.value[1], step.value[0], this) === false) { + break; + } + } + return iterations; + */ + // indexed: + var iterator = this.__iterator(ITERATE_VALUES, reverse); + var step; + var iterations = 0; + while (!(step = iterator.next()).done) { + if (fn(step.value, iterations++, this) === false) { + break; + } + } + return iterations; + }; + zipSequence.__iteratorUncached = function (type, reverse) { + var iterators = iters.map( + function (i) { return ((i = Collection(i)), getIterator(reverse ? i.reverse() : i)); } + ); + var iterations = 0; + var isDone = false; + return new Iterator(function () { + var steps; + if (!isDone) { + steps = iterators.map(function (i) { return i.next(); }); + isDone = zipAll ? steps.every(function (s) { return s.done; }) : steps.some(function (s) { return s.done; }); + } + if (isDone) { + return iteratorDone(); + } + return iteratorValue( + type, + iterations++, + zipper.apply( + null, + steps.map(function (s) { return s.value; }) + ) + ); + }); + }; + return zipSequence; +} + +// #pragma Helper Functions + +function reify(iter, seq) { + return iter === seq ? iter : isSeq(iter) ? seq : iter.constructor(seq); +} + +function validateEntry(entry) { + if (entry !== Object(entry)) { + throw new TypeError('Expected [K, V] tuple: ' + entry); + } +} + +function collectionClass(collection) { + return isKeyed(collection) + ? KeyedCollection + : isIndexed(collection) + ? IndexedCollection + : SetCollection; +} + +function makeSequence(collection) { + return Object.create( + (isKeyed(collection) + ? KeyedSeq + : isIndexed(collection) + ? IndexedSeq + : SetSeq + ).prototype + ); +} + +function cacheResultThrough() { + if (this._iter.cacheResult) { + this._iter.cacheResult(); + this.size = this._iter.size; + return this; + } + return Seq.prototype.cacheResult.call(this); +} + +function defaultComparator(a, b) { + if (a === undefined && b === undefined) { + return 0; + } + + if (a === undefined) { + return 1; + } + + if (b === undefined) { + return -1; + } + + return a > b ? 1 : a < b ? -1 : 0; +} + +// http://jsperf.com/copy-array-inline +function arrCopy(arr, offset) { + offset = offset || 0; + var len = Math.max(0, arr.length - offset); + var newArr = new Array(len); + for (var ii = 0; ii < len; ii++) { + newArr[ii] = arr[ii + offset]; + } + return newArr; +} + +function invariant(condition, error) { + if (!condition) { throw new Error(error); } +} + +function assertNotInfinite(size) { + invariant( + size !== Infinity, + 'Cannot perform this action with an infinite size.' + ); +} + +function coerceKeyPath(keyPath) { + if (isArrayLike(keyPath) && typeof keyPath !== 'string') { + return keyPath; + } + if (isOrdered(keyPath)) { + return keyPath.toArray(); + } + throw new TypeError( + 'Invalid keyPath: expected Ordered Collection or Array: ' + keyPath + ); +} + +var toString = Object.prototype.toString; + +function isPlainObject(value) { + // The base prototype's toString deals with Argument objects and native namespaces like Math + if ( + !value || + typeof value !== 'object' || + toString.call(value) !== '[object Object]' + ) { + return false; + } + + var proto = Object.getPrototypeOf(value); + if (proto === null) { + return true; + } + + // Iteratively going up the prototype chain is needed for cross-realm environments (differing contexts, iframes, etc) + var parentProto = proto; + var nextProto = Object.getPrototypeOf(proto); + while (nextProto !== null) { + parentProto = nextProto; + nextProto = Object.getPrototypeOf(parentProto); + } + return parentProto === proto; +} + +/** + * Returns true if the value is a potentially-persistent data structure, either + * provided by Immutable.js or a plain Array or Object. + */ +function isDataStructure(value) { + return ( + typeof value === 'object' && + (isImmutable(value) || Array.isArray(value) || isPlainObject(value)) + ); +} + +/** + * Converts a value to a string, adding quotes if a string was provided. + */ +function quoteString(value) { + try { + return typeof value === 'string' ? JSON.stringify(value) : String(value); + } catch (_ignoreError) { + return JSON.stringify(value); + } +} + +function has(collection, key) { + return isImmutable(collection) + ? collection.has(key) + : isDataStructure(collection) && hasOwnProperty.call(collection, key); +} + +function get(collection, key, notSetValue) { + return isImmutable(collection) + ? collection.get(key, notSetValue) + : !has(collection, key) + ? notSetValue + : typeof collection.get === 'function' + ? collection.get(key) + : collection[key]; +} + +function shallowCopy(from) { + if (Array.isArray(from)) { + return arrCopy(from); + } + var to = {}; + for (var key in from) { + if (hasOwnProperty.call(from, key)) { + to[key] = from[key]; + } + } + return to; +} + +function remove(collection, key) { + if (!isDataStructure(collection)) { + throw new TypeError( + 'Cannot update non-data-structure value: ' + collection + ); + } + if (isImmutable(collection)) { + if (!collection.remove) { + throw new TypeError( + 'Cannot update immutable value without .remove() method: ' + collection + ); + } + return collection.remove(key); + } + if (!hasOwnProperty.call(collection, key)) { + return collection; + } + var collectionCopy = shallowCopy(collection); + if (Array.isArray(collectionCopy)) { + collectionCopy.splice(key, 1); + } else { + delete collectionCopy[key]; + } + return collectionCopy; +} + +function set(collection, key, value) { + if (!isDataStructure(collection)) { + throw new TypeError( + 'Cannot update non-data-structure value: ' + collection + ); + } + if (isImmutable(collection)) { + if (!collection.set) { + throw new TypeError( + 'Cannot update immutable value without .set() method: ' + collection + ); + } + return collection.set(key, value); + } + if (hasOwnProperty.call(collection, key) && value === collection[key]) { + return collection; + } + var collectionCopy = shallowCopy(collection); + collectionCopy[key] = value; + return collectionCopy; +} + +function updateIn$1(collection, keyPath, notSetValue, updater) { + if (!updater) { + updater = notSetValue; + notSetValue = undefined; + } + var updatedValue = updateInDeeply( + isImmutable(collection), + collection, + coerceKeyPath(keyPath), + 0, + notSetValue, + updater + ); + return updatedValue === NOT_SET ? notSetValue : updatedValue; +} + +function updateInDeeply( + inImmutable, + existing, + keyPath, + i, + notSetValue, + updater +) { + var wasNotSet = existing === NOT_SET; + if (i === keyPath.length) { + var existingValue = wasNotSet ? notSetValue : existing; + var newValue = updater(existingValue); + return newValue === existingValue ? existing : newValue; + } + if (!wasNotSet && !isDataStructure(existing)) { + throw new TypeError( + 'Cannot update within non-data-structure value in path [' + + keyPath.slice(0, i).map(quoteString) + + ']: ' + + existing + ); + } + var key = keyPath[i]; + var nextExisting = wasNotSet ? NOT_SET : get(existing, key, NOT_SET); + var nextUpdated = updateInDeeply( + nextExisting === NOT_SET ? inImmutable : isImmutable(nextExisting), + nextExisting, + keyPath, + i + 1, + notSetValue, + updater + ); + return nextUpdated === nextExisting + ? existing + : nextUpdated === NOT_SET + ? remove(existing, key) + : set( + wasNotSet ? (inImmutable ? emptyMap() : {}) : existing, + key, + nextUpdated + ); +} + +function setIn$1(collection, keyPath, value) { + return updateIn$1(collection, keyPath, NOT_SET, function () { return value; }); +} + +function setIn(keyPath, v) { + return setIn$1(this, keyPath, v); +} + +function removeIn(collection, keyPath) { + return updateIn$1(collection, keyPath, function () { return NOT_SET; }); +} + +function deleteIn(keyPath) { + return removeIn(this, keyPath); +} + +function update$1(collection, key, notSetValue, updater) { + return updateIn$1(collection, [key], notSetValue, updater); +} + +function update(key, notSetValue, updater) { + return arguments.length === 1 + ? key(this) + : update$1(this, key, notSetValue, updater); +} + +function updateIn(keyPath, notSetValue, updater) { + return updateIn$1(this, keyPath, notSetValue, updater); +} + +function merge$1() { + var iters = [], len = arguments.length; + while ( len-- ) iters[ len ] = arguments[ len ]; + + return mergeIntoKeyedWith(this, iters); +} + +function mergeWith$1(merger) { + var iters = [], len = arguments.length - 1; + while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; + + if (typeof merger !== 'function') { + throw new TypeError('Invalid merger function: ' + merger); + } + return mergeIntoKeyedWith(this, iters, merger); +} + +function mergeIntoKeyedWith(collection, collections, merger) { + var iters = []; + for (var ii = 0; ii < collections.length; ii++) { + var collection$1 = KeyedCollection(collections[ii]); + if (collection$1.size !== 0) { + iters.push(collection$1); + } + } + if (iters.length === 0) { + return collection; + } + if ( + collection.toSeq().size === 0 && + !collection.__ownerID && + iters.length === 1 + ) { + return collection.constructor(iters[0]); + } + return collection.withMutations(function (collection) { + var mergeIntoCollection = merger + ? function (value, key) { + update$1(collection, key, NOT_SET, function (oldVal) { return oldVal === NOT_SET ? value : merger(oldVal, value, key); } + ); + } + : function (value, key) { + collection.set(key, value); + }; + for (var ii = 0; ii < iters.length; ii++) { + iters[ii].forEach(mergeIntoCollection); + } + }); +} + +function merge(collection) { + var sources = [], len = arguments.length - 1; + while ( len-- > 0 ) sources[ len ] = arguments[ len + 1 ]; + + return mergeWithSources(collection, sources); +} + +function mergeWith(merger, collection) { + var sources = [], len = arguments.length - 2; + while ( len-- > 0 ) sources[ len ] = arguments[ len + 2 ]; + + return mergeWithSources(collection, sources, merger); +} + +function mergeDeep$1(collection) { + var sources = [], len = arguments.length - 1; + while ( len-- > 0 ) sources[ len ] = arguments[ len + 1 ]; + + return mergeDeepWithSources(collection, sources); +} + +function mergeDeepWith$1(merger, collection) { + var sources = [], len = arguments.length - 2; + while ( len-- > 0 ) sources[ len ] = arguments[ len + 2 ]; + + return mergeDeepWithSources(collection, sources, merger); +} + +function mergeDeepWithSources(collection, sources, merger) { + return mergeWithSources(collection, sources, deepMergerWith(merger)); +} + +function mergeWithSources(collection, sources, merger) { + if (!isDataStructure(collection)) { + throw new TypeError( + 'Cannot merge into non-data-structure value: ' + collection + ); + } + if (isImmutable(collection)) { + return typeof merger === 'function' && collection.mergeWith + ? collection.mergeWith.apply(collection, [ merger ].concat( sources )) + : collection.merge + ? collection.merge.apply(collection, sources) + : collection.concat.apply(collection, sources); + } + var isArray = Array.isArray(collection); + var merged = collection; + var Collection = isArray ? IndexedCollection : KeyedCollection; + var mergeItem = isArray + ? function (value) { + // Copy on write + if (merged === collection) { + merged = shallowCopy(merged); + } + merged.push(value); + } + : function (value, key) { + var hasVal = hasOwnProperty.call(merged, key); + var nextVal = + hasVal && merger ? merger(merged[key], value, key) : value; + if (!hasVal || nextVal !== merged[key]) { + // Copy on write + if (merged === collection) { + merged = shallowCopy(merged); + } + merged[key] = nextVal; + } + }; + for (var i = 0; i < sources.length; i++) { + Collection(sources[i]).forEach(mergeItem); + } + return merged; +} + +function deepMergerWith(merger) { + function deepMerger(oldValue, newValue, key) { + return isDataStructure(oldValue) && + isDataStructure(newValue) && + areMergeable(oldValue, newValue) + ? mergeWithSources(oldValue, [newValue], deepMerger) + : merger + ? merger(oldValue, newValue, key) + : newValue; + } + return deepMerger; +} + +/** + * It's unclear what the desired behavior is for merging two collections that + * fall into separate categories between keyed, indexed, or set-like, so we only + * consider them mergeable if they fall into the same category. + */ +function areMergeable(oldDataStructure, newDataStructure) { + var oldSeq = Seq(oldDataStructure); + var newSeq = Seq(newDataStructure); + // This logic assumes that a sequence can only fall into one of the three + // categories mentioned above (since there's no `isSetLike()` method). + return ( + isIndexed(oldSeq) === isIndexed(newSeq) && + isKeyed(oldSeq) === isKeyed(newSeq) + ); +} + +function mergeDeep() { + var iters = [], len = arguments.length; + while ( len-- ) iters[ len ] = arguments[ len ]; + + return mergeDeepWithSources(this, iters); +} + +function mergeDeepWith(merger) { + var iters = [], len = arguments.length - 1; + while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; + + return mergeDeepWithSources(this, iters, merger); +} + +function mergeIn(keyPath) { + var iters = [], len = arguments.length - 1; + while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; + + return updateIn$1(this, keyPath, emptyMap(), function (m) { return mergeWithSources(m, iters); }); +} + +function mergeDeepIn(keyPath) { + var iters = [], len = arguments.length - 1; + while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; + + return updateIn$1(this, keyPath, emptyMap(), function (m) { return mergeDeepWithSources(m, iters); } + ); +} + +function withMutations(fn) { + var mutable = this.asMutable(); + fn(mutable); + return mutable.wasAltered() ? mutable.__ensureOwner(this.__ownerID) : this; +} + +function asMutable() { + return this.__ownerID ? this : this.__ensureOwner(new OwnerID()); +} + +function asImmutable() { + return this.__ensureOwner(); +} + +function wasAltered() { + return this.__altered; +} + +var Map = /*@__PURE__*/(function (KeyedCollection) { + function Map(value) { + // eslint-disable-next-line no-constructor-return + return value === undefined || value === null + ? emptyMap() + : isMap(value) && !isOrdered(value) + ? value + : emptyMap().withMutations(function (map) { + var iter = KeyedCollection(value); + assertNotInfinite(iter.size); + iter.forEach(function (v, k) { return map.set(k, v); }); + }); + } + + if ( KeyedCollection ) Map.__proto__ = KeyedCollection; + Map.prototype = Object.create( KeyedCollection && KeyedCollection.prototype ); + Map.prototype.constructor = Map; + + Map.prototype.toString = function toString () { + return this.__toString('Map {', '}'); + }; + + // @pragma Access + + Map.prototype.get = function get (k, notSetValue) { + return this._root + ? this._root.get(0, undefined, k, notSetValue) + : notSetValue; + }; + + // @pragma Modification + + Map.prototype.set = function set (k, v) { + return updateMap(this, k, v); + }; + + Map.prototype.remove = function remove (k) { + return updateMap(this, k, NOT_SET); + }; + + Map.prototype.deleteAll = function deleteAll (keys) { + var collection = Collection(keys); + + if (collection.size === 0) { + return this; + } + + return this.withMutations(function (map) { + collection.forEach(function (key) { return map.remove(key); }); + }); + }; + + Map.prototype.clear = function clear () { + if (this.size === 0) { + return this; + } + if (this.__ownerID) { + this.size = 0; + this._root = null; + this.__hash = undefined; + this.__altered = true; + return this; + } + return emptyMap(); + }; + + // @pragma Composition + + Map.prototype.sort = function sort (comparator) { + // Late binding + return OrderedMap(sortFactory(this, comparator)); + }; + + Map.prototype.sortBy = function sortBy (mapper, comparator) { + // Late binding + return OrderedMap(sortFactory(this, comparator, mapper)); + }; + + Map.prototype.map = function map (mapper, context) { + var this$1$1 = this; + + return this.withMutations(function (map) { + map.forEach(function (value, key) { + map.set(key, mapper.call(context, value, key, this$1$1)); + }); + }); + }; + + // @pragma Mutability + + Map.prototype.__iterator = function __iterator (type, reverse) { + return new MapIterator(this, type, reverse); + }; + + Map.prototype.__iterate = function __iterate (fn, reverse) { + var this$1$1 = this; + + var iterations = 0; + this._root && + this._root.iterate(function (entry) { + iterations++; + return fn(entry[1], entry[0], this$1$1); + }, reverse); + return iterations; + }; + + Map.prototype.__ensureOwner = function __ensureOwner (ownerID) { + if (ownerID === this.__ownerID) { + return this; + } + if (!ownerID) { + if (this.size === 0) { + return emptyMap(); + } + this.__ownerID = ownerID; + this.__altered = false; + return this; + } + return makeMap(this.size, this._root, ownerID, this.__hash); + }; + + return Map; +}(KeyedCollection)); + +Map.isMap = isMap; + +var MapPrototype = Map.prototype; +MapPrototype[IS_MAP_SYMBOL] = true; +MapPrototype[DELETE] = MapPrototype.remove; +MapPrototype.removeAll = MapPrototype.deleteAll; +MapPrototype.setIn = setIn; +MapPrototype.removeIn = MapPrototype.deleteIn = deleteIn; +MapPrototype.update = update; +MapPrototype.updateIn = updateIn; +MapPrototype.merge = MapPrototype.concat = merge$1; +MapPrototype.mergeWith = mergeWith$1; +MapPrototype.mergeDeep = mergeDeep; +MapPrototype.mergeDeepWith = mergeDeepWith; +MapPrototype.mergeIn = mergeIn; +MapPrototype.mergeDeepIn = mergeDeepIn; +MapPrototype.withMutations = withMutations; +MapPrototype.wasAltered = wasAltered; +MapPrototype.asImmutable = asImmutable; +MapPrototype['@@transducer/init'] = MapPrototype.asMutable = asMutable; +MapPrototype['@@transducer/step'] = function (result, arr) { + return result.set(arr[0], arr[1]); +}; +MapPrototype['@@transducer/result'] = function (obj) { + return obj.asImmutable(); +}; + +// #pragma Trie Nodes + +var ArrayMapNode = function ArrayMapNode(ownerID, entries) { + this.ownerID = ownerID; + this.entries = entries; +}; + +ArrayMapNode.prototype.get = function get (shift, keyHash, key, notSetValue) { + var entries = this.entries; + for (var ii = 0, len = entries.length; ii < len; ii++) { + if (is(key, entries[ii][0])) { + return entries[ii][1]; + } + } + return notSetValue; +}; + +ArrayMapNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { + var removed = value === NOT_SET; + + var entries = this.entries; + var idx = 0; + var len = entries.length; + for (; idx < len; idx++) { + if (is(key, entries[idx][0])) { + break; + } + } + var exists = idx < len; + + if (exists ? entries[idx][1] === value : removed) { + return this; + } + + SetRef(didAlter); + (removed || !exists) && SetRef(didChangeSize); + + if (removed && entries.length === 1) { + return; // undefined + } + + if (!exists && !removed && entries.length >= MAX_ARRAY_MAP_SIZE) { + return createNodes(ownerID, entries, key, value); + } + + var isEditable = ownerID && ownerID === this.ownerID; + var newEntries = isEditable ? entries : arrCopy(entries); + + if (exists) { + if (removed) { + idx === len - 1 + ? newEntries.pop() + : (newEntries[idx] = newEntries.pop()); + } else { + newEntries[idx] = [key, value]; + } + } else { + newEntries.push([key, value]); + } + + if (isEditable) { + this.entries = newEntries; + return this; + } + + return new ArrayMapNode(ownerID, newEntries); +}; + +var BitmapIndexedNode = function BitmapIndexedNode(ownerID, bitmap, nodes) { + this.ownerID = ownerID; + this.bitmap = bitmap; + this.nodes = nodes; +}; + +BitmapIndexedNode.prototype.get = function get (shift, keyHash, key, notSetValue) { + if (keyHash === undefined) { + keyHash = hash(key); + } + var bit = 1 << ((shift === 0 ? keyHash : keyHash >>> shift) & MASK); + var bitmap = this.bitmap; + return (bitmap & bit) === 0 + ? notSetValue + : this.nodes[popCount(bitmap & (bit - 1))].get( + shift + SHIFT, + keyHash, + key, + notSetValue + ); +}; + +BitmapIndexedNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { + if (keyHash === undefined) { + keyHash = hash(key); + } + var keyHashFrag = (shift === 0 ? keyHash : keyHash >>> shift) & MASK; + var bit = 1 << keyHashFrag; + var bitmap = this.bitmap; + var exists = (bitmap & bit) !== 0; + + if (!exists && value === NOT_SET) { + return this; + } + + var idx = popCount(bitmap & (bit - 1)); + var nodes = this.nodes; + var node = exists ? nodes[idx] : undefined; + var newNode = updateNode( + node, + ownerID, + shift + SHIFT, + keyHash, + key, + value, + didChangeSize, + didAlter + ); + + if (newNode === node) { + return this; + } + + if (!exists && newNode && nodes.length >= MAX_BITMAP_INDEXED_SIZE) { + return expandNodes(ownerID, nodes, bitmap, keyHashFrag, newNode); + } + + if ( + exists && + !newNode && + nodes.length === 2 && + isLeafNode(nodes[idx ^ 1]) + ) { + return nodes[idx ^ 1]; + } + + if (exists && newNode && nodes.length === 1 && isLeafNode(newNode)) { + return newNode; + } + + var isEditable = ownerID && ownerID === this.ownerID; + var newBitmap = exists ? (newNode ? bitmap : bitmap ^ bit) : bitmap | bit; + var newNodes = exists + ? newNode + ? setAt(nodes, idx, newNode, isEditable) + : spliceOut(nodes, idx, isEditable) + : spliceIn(nodes, idx, newNode, isEditable); + + if (isEditable) { + this.bitmap = newBitmap; + this.nodes = newNodes; + return this; + } + + return new BitmapIndexedNode(ownerID, newBitmap, newNodes); +}; + +var HashArrayMapNode = function HashArrayMapNode(ownerID, count, nodes) { + this.ownerID = ownerID; + this.count = count; + this.nodes = nodes; +}; + +HashArrayMapNode.prototype.get = function get (shift, keyHash, key, notSetValue) { + if (keyHash === undefined) { + keyHash = hash(key); + } + var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK; + var node = this.nodes[idx]; + return node + ? node.get(shift + SHIFT, keyHash, key, notSetValue) + : notSetValue; +}; + +HashArrayMapNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { + if (keyHash === undefined) { + keyHash = hash(key); + } + var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK; + var removed = value === NOT_SET; + var nodes = this.nodes; + var node = nodes[idx]; + + if (removed && !node) { + return this; + } + + var newNode = updateNode( + node, + ownerID, + shift + SHIFT, + keyHash, + key, + value, + didChangeSize, + didAlter + ); + if (newNode === node) { + return this; + } + + var newCount = this.count; + if (!node) { + newCount++; + } else if (!newNode) { + newCount--; + if (newCount < MIN_HASH_ARRAY_MAP_SIZE) { + return packNodes(ownerID, nodes, newCount, idx); + } + } + + var isEditable = ownerID && ownerID === this.ownerID; + var newNodes = setAt(nodes, idx, newNode, isEditable); + + if (isEditable) { + this.count = newCount; + this.nodes = newNodes; + return this; + } + + return new HashArrayMapNode(ownerID, newCount, newNodes); +}; + +var HashCollisionNode = function HashCollisionNode(ownerID, keyHash, entries) { + this.ownerID = ownerID; + this.keyHash = keyHash; + this.entries = entries; +}; + +HashCollisionNode.prototype.get = function get (shift, keyHash, key, notSetValue) { + var entries = this.entries; + for (var ii = 0, len = entries.length; ii < len; ii++) { + if (is(key, entries[ii][0])) { + return entries[ii][1]; + } + } + return notSetValue; +}; + +HashCollisionNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { + if (keyHash === undefined) { + keyHash = hash(key); + } + + var removed = value === NOT_SET; + + if (keyHash !== this.keyHash) { + if (removed) { + return this; + } + SetRef(didAlter); + SetRef(didChangeSize); + return mergeIntoNode(this, ownerID, shift, keyHash, [key, value]); + } + + var entries = this.entries; + var idx = 0; + var len = entries.length; + for (; idx < len; idx++) { + if (is(key, entries[idx][0])) { + break; + } + } + var exists = idx < len; + + if (exists ? entries[idx][1] === value : removed) { + return this; + } + + SetRef(didAlter); + (removed || !exists) && SetRef(didChangeSize); + + if (removed && len === 2) { + return new ValueNode(ownerID, this.keyHash, entries[idx ^ 1]); + } + + var isEditable = ownerID && ownerID === this.ownerID; + var newEntries = isEditable ? entries : arrCopy(entries); + + if (exists) { + if (removed) { + idx === len - 1 + ? newEntries.pop() + : (newEntries[idx] = newEntries.pop()); + } else { + newEntries[idx] = [key, value]; + } + } else { + newEntries.push([key, value]); + } + + if (isEditable) { + this.entries = newEntries; + return this; + } + + return new HashCollisionNode(ownerID, this.keyHash, newEntries); +}; + +var ValueNode = function ValueNode(ownerID, keyHash, entry) { + this.ownerID = ownerID; + this.keyHash = keyHash; + this.entry = entry; +}; + +ValueNode.prototype.get = function get (shift, keyHash, key, notSetValue) { + return is(key, this.entry[0]) ? this.entry[1] : notSetValue; +}; + +ValueNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { + var removed = value === NOT_SET; + var keyMatch = is(key, this.entry[0]); + if (keyMatch ? value === this.entry[1] : removed) { + return this; + } + + SetRef(didAlter); + + if (removed) { + SetRef(didChangeSize); + return; // undefined + } + + if (keyMatch) { + if (ownerID && ownerID === this.ownerID) { + this.entry[1] = value; + return this; + } + return new ValueNode(ownerID, this.keyHash, [key, value]); + } + + SetRef(didChangeSize); + return mergeIntoNode(this, ownerID, shift, hash(key), [key, value]); +}; + +// #pragma Iterators + +ArrayMapNode.prototype.iterate = HashCollisionNode.prototype.iterate = + function (fn, reverse) { + var entries = this.entries; + for (var ii = 0, maxIndex = entries.length - 1; ii <= maxIndex; ii++) { + if (fn(entries[reverse ? maxIndex - ii : ii]) === false) { + return false; + } + } + }; + +BitmapIndexedNode.prototype.iterate = HashArrayMapNode.prototype.iterate = + function (fn, reverse) { + var nodes = this.nodes; + for (var ii = 0, maxIndex = nodes.length - 1; ii <= maxIndex; ii++) { + var node = nodes[reverse ? maxIndex - ii : ii]; + if (node && node.iterate(fn, reverse) === false) { + return false; + } + } + }; + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +ValueNode.prototype.iterate = function (fn, reverse) { + return fn(this.entry); +}; + +var MapIterator = /*@__PURE__*/(function (Iterator) { + function MapIterator(map, type, reverse) { + this._type = type; + this._reverse = reverse; + this._stack = map._root && mapIteratorFrame(map._root); + } + + if ( Iterator ) MapIterator.__proto__ = Iterator; + MapIterator.prototype = Object.create( Iterator && Iterator.prototype ); + MapIterator.prototype.constructor = MapIterator; + + MapIterator.prototype.next = function next () { + var type = this._type; + var stack = this._stack; + while (stack) { + var node = stack.node; + var index = stack.index++; + var maxIndex = (void 0); + if (node.entry) { + if (index === 0) { + return mapIteratorValue(type, node.entry); + } + } else if (node.entries) { + maxIndex = node.entries.length - 1; + if (index <= maxIndex) { + return mapIteratorValue( + type, + node.entries[this._reverse ? maxIndex - index : index] + ); + } + } else { + maxIndex = node.nodes.length - 1; + if (index <= maxIndex) { + var subNode = node.nodes[this._reverse ? maxIndex - index : index]; + if (subNode) { + if (subNode.entry) { + return mapIteratorValue(type, subNode.entry); + } + stack = this._stack = mapIteratorFrame(subNode, stack); + } + continue; + } + } + stack = this._stack = this._stack.__prev; + } + return iteratorDone(); + }; + + return MapIterator; +}(Iterator)); + +function mapIteratorValue(type, entry) { + return iteratorValue(type, entry[0], entry[1]); +} + +function mapIteratorFrame(node, prev) { + return { + node: node, + index: 0, + __prev: prev, + }; +} + +function makeMap(size, root, ownerID, hash) { + var map = Object.create(MapPrototype); + map.size = size; + map._root = root; + map.__ownerID = ownerID; + map.__hash = hash; + map.__altered = false; + return map; +} + +var EMPTY_MAP; +function emptyMap() { + return EMPTY_MAP || (EMPTY_MAP = makeMap(0)); +} + +function updateMap(map, k, v) { + var newRoot; + var newSize; + if (!map._root) { + if (v === NOT_SET) { + return map; + } + newSize = 1; + newRoot = new ArrayMapNode(map.__ownerID, [[k, v]]); + } else { + var didChangeSize = MakeRef(); + var didAlter = MakeRef(); + newRoot = updateNode( + map._root, + map.__ownerID, + 0, + undefined, + k, + v, + didChangeSize, + didAlter + ); + if (!didAlter.value) { + return map; + } + newSize = map.size + (didChangeSize.value ? (v === NOT_SET ? -1 : 1) : 0); + } + if (map.__ownerID) { + map.size = newSize; + map._root = newRoot; + map.__hash = undefined; + map.__altered = true; + return map; + } + return newRoot ? makeMap(newSize, newRoot) : emptyMap(); +} + +function updateNode( + node, + ownerID, + shift, + keyHash, + key, + value, + didChangeSize, + didAlter +) { + if (!node) { + if (value === NOT_SET) { + return node; + } + SetRef(didAlter); + SetRef(didChangeSize); + return new ValueNode(ownerID, keyHash, [key, value]); + } + return node.update( + ownerID, + shift, + keyHash, + key, + value, + didChangeSize, + didAlter + ); +} + +function isLeafNode(node) { + return ( + node.constructor === ValueNode || node.constructor === HashCollisionNode + ); +} + +function mergeIntoNode(node, ownerID, shift, keyHash, entry) { + if (node.keyHash === keyHash) { + return new HashCollisionNode(ownerID, keyHash, [node.entry, entry]); + } + + var idx1 = (shift === 0 ? node.keyHash : node.keyHash >>> shift) & MASK; + var idx2 = (shift === 0 ? keyHash : keyHash >>> shift) & MASK; + + var newNode; + var nodes = + idx1 === idx2 + ? [mergeIntoNode(node, ownerID, shift + SHIFT, keyHash, entry)] + : ((newNode = new ValueNode(ownerID, keyHash, entry)), + idx1 < idx2 ? [node, newNode] : [newNode, node]); + + return new BitmapIndexedNode(ownerID, (1 << idx1) | (1 << idx2), nodes); +} + +function createNodes(ownerID, entries, key, value) { + if (!ownerID) { + ownerID = new OwnerID(); + } + var node = new ValueNode(ownerID, hash(key), [key, value]); + for (var ii = 0; ii < entries.length; ii++) { + var entry = entries[ii]; + node = node.update(ownerID, 0, undefined, entry[0], entry[1]); + } + return node; +} + +function packNodes(ownerID, nodes, count, excluding) { + var bitmap = 0; + var packedII = 0; + var packedNodes = new Array(count); + for (var ii = 0, bit = 1, len = nodes.length; ii < len; ii++, bit <<= 1) { + var node = nodes[ii]; + if (node !== undefined && ii !== excluding) { + bitmap |= bit; + packedNodes[packedII++] = node; + } + } + return new BitmapIndexedNode(ownerID, bitmap, packedNodes); +} + +function expandNodes(ownerID, nodes, bitmap, including, node) { + var count = 0; + var expandedNodes = new Array(SIZE); + for (var ii = 0; bitmap !== 0; ii++, bitmap >>>= 1) { + expandedNodes[ii] = bitmap & 1 ? nodes[count++] : undefined; + } + expandedNodes[including] = node; + return new HashArrayMapNode(ownerID, count + 1, expandedNodes); +} + +function popCount(x) { + x -= (x >> 1) & 0x55555555; + x = (x & 0x33333333) + ((x >> 2) & 0x33333333); + x = (x + (x >> 4)) & 0x0f0f0f0f; + x += x >> 8; + x += x >> 16; + return x & 0x7f; +} + +function setAt(array, idx, val, canEdit) { + var newArray = canEdit ? array : arrCopy(array); + newArray[idx] = val; + return newArray; +} + +function spliceIn(array, idx, val, canEdit) { + var newLen = array.length + 1; + if (canEdit && idx + 1 === newLen) { + array[idx] = val; + return array; + } + var newArray = new Array(newLen); + var after = 0; + for (var ii = 0; ii < newLen; ii++) { + if (ii === idx) { + newArray[ii] = val; + after = -1; + } else { + newArray[ii] = array[ii + after]; + } + } + return newArray; +} + +function spliceOut(array, idx, canEdit) { + var newLen = array.length - 1; + if (canEdit && idx === newLen) { + array.pop(); + return array; + } + var newArray = new Array(newLen); + var after = 0; + for (var ii = 0; ii < newLen; ii++) { + if (ii === idx) { + after = 1; + } + newArray[ii] = array[ii + after]; + } + return newArray; +} + +var MAX_ARRAY_MAP_SIZE = SIZE / 4; +var MAX_BITMAP_INDEXED_SIZE = SIZE / 2; +var MIN_HASH_ARRAY_MAP_SIZE = SIZE / 4; + +var IS_LIST_SYMBOL = '@@__IMMUTABLE_LIST__@@'; + +function isList(maybeList) { + return Boolean(maybeList && maybeList[IS_LIST_SYMBOL]); +} + +var List = /*@__PURE__*/(function (IndexedCollection) { + function List(value) { + var empty = emptyList(); + if (value === undefined || value === null) { + // eslint-disable-next-line no-constructor-return + return empty; + } + if (isList(value)) { + // eslint-disable-next-line no-constructor-return + return value; + } + var iter = IndexedCollection(value); + var size = iter.size; + if (size === 0) { + // eslint-disable-next-line no-constructor-return + return empty; + } + assertNotInfinite(size); + if (size > 0 && size < SIZE) { + // eslint-disable-next-line no-constructor-return + return makeList(0, size, SHIFT, null, new VNode(iter.toArray())); + } + // eslint-disable-next-line no-constructor-return + return empty.withMutations(function (list) { + list.setSize(size); + iter.forEach(function (v, i) { return list.set(i, v); }); + }); + } + + if ( IndexedCollection ) List.__proto__ = IndexedCollection; + List.prototype = Object.create( IndexedCollection && IndexedCollection.prototype ); + List.prototype.constructor = List; + + List.of = function of (/*...values*/) { + return this(arguments); + }; + + List.prototype.toString = function toString () { + return this.__toString('List [', ']'); + }; + + // @pragma Access + + List.prototype.get = function get (index, notSetValue) { + index = wrapIndex(this, index); + if (index >= 0 && index < this.size) { + index += this._origin; + var node = listNodeFor(this, index); + return node && node.array[index & MASK]; + } + return notSetValue; + }; + + // @pragma Modification + + List.prototype.set = function set (index, value) { + return updateList(this, index, value); + }; + + List.prototype.remove = function remove (index) { + return !this.has(index) + ? this + : index === 0 + ? this.shift() + : index === this.size - 1 + ? this.pop() + : this.splice(index, 1); + }; + + List.prototype.insert = function insert (index, value) { + return this.splice(index, 0, value); + }; + + List.prototype.clear = function clear () { + if (this.size === 0) { + return this; + } + if (this.__ownerID) { + this.size = this._origin = this._capacity = 0; + this._level = SHIFT; + this._root = this._tail = this.__hash = undefined; + this.__altered = true; + return this; + } + return emptyList(); + }; + + List.prototype.push = function push (/*...values*/) { + var values = arguments; + var oldSize = this.size; + return this.withMutations(function (list) { + setListBounds(list, 0, oldSize + values.length); + for (var ii = 0; ii < values.length; ii++) { + list.set(oldSize + ii, values[ii]); + } + }); + }; + + List.prototype.pop = function pop () { + return setListBounds(this, 0, -1); + }; + + List.prototype.unshift = function unshift (/*...values*/) { + var values = arguments; + return this.withMutations(function (list) { + setListBounds(list, -values.length); + for (var ii = 0; ii < values.length; ii++) { + list.set(ii, values[ii]); + } + }); + }; + + List.prototype.shift = function shift () { + return setListBounds(this, 1); + }; + + // @pragma Composition + + List.prototype.concat = function concat (/*...collections*/) { + var arguments$1 = arguments; + + var seqs = []; + for (var i = 0; i < arguments.length; i++) { + var argument = arguments$1[i]; + var seq = IndexedCollection( + typeof argument !== 'string' && hasIterator(argument) + ? argument + : [argument] + ); + if (seq.size !== 0) { + seqs.push(seq); + } + } + if (seqs.length === 0) { + return this; + } + if (this.size === 0 && !this.__ownerID && seqs.length === 1) { + return this.constructor(seqs[0]); + } + return this.withMutations(function (list) { + seqs.forEach(function (seq) { return seq.forEach(function (value) { return list.push(value); }); }); + }); + }; + + List.prototype.setSize = function setSize (size) { + return setListBounds(this, 0, size); + }; + + List.prototype.map = function map (mapper, context) { + var this$1$1 = this; + + return this.withMutations(function (list) { + for (var i = 0; i < this$1$1.size; i++) { + list.set(i, mapper.call(context, list.get(i), i, this$1$1)); + } + }); + }; + + // @pragma Iteration + + List.prototype.slice = function slice (begin, end) { + var size = this.size; + if (wholeSlice(begin, end, size)) { + return this; + } + return setListBounds( + this, + resolveBegin(begin, size), + resolveEnd(end, size) + ); + }; + + List.prototype.__iterator = function __iterator (type, reverse) { + var index = reverse ? this.size : 0; + var values = iterateList(this, reverse); + return new Iterator(function () { + var value = values(); + return value === DONE + ? iteratorDone() + : iteratorValue(type, reverse ? --index : index++, value); + }); + }; + + List.prototype.__iterate = function __iterate (fn, reverse) { + var index = reverse ? this.size : 0; + var values = iterateList(this, reverse); + var value; + while ((value = values()) !== DONE) { + if (fn(value, reverse ? --index : index++, this) === false) { + break; + } + } + return index; + }; + + List.prototype.__ensureOwner = function __ensureOwner (ownerID) { + if (ownerID === this.__ownerID) { + return this; + } + if (!ownerID) { + if (this.size === 0) { + return emptyList(); + } + this.__ownerID = ownerID; + this.__altered = false; + return this; + } + return makeList( + this._origin, + this._capacity, + this._level, + this._root, + this._tail, + ownerID, + this.__hash + ); + }; + + return List; +}(IndexedCollection)); + +List.isList = isList; + +var ListPrototype = List.prototype; +ListPrototype[IS_LIST_SYMBOL] = true; +ListPrototype[DELETE] = ListPrototype.remove; +ListPrototype.merge = ListPrototype.concat; +ListPrototype.setIn = setIn; +ListPrototype.deleteIn = ListPrototype.removeIn = deleteIn; +ListPrototype.update = update; +ListPrototype.updateIn = updateIn; +ListPrototype.mergeIn = mergeIn; +ListPrototype.mergeDeepIn = mergeDeepIn; +ListPrototype.withMutations = withMutations; +ListPrototype.wasAltered = wasAltered; +ListPrototype.asImmutable = asImmutable; +ListPrototype['@@transducer/init'] = ListPrototype.asMutable = asMutable; +ListPrototype['@@transducer/step'] = function (result, arr) { + return result.push(arr); +}; +ListPrototype['@@transducer/result'] = function (obj) { + return obj.asImmutable(); +}; + +var VNode = function VNode(array, ownerID) { + this.array = array; + this.ownerID = ownerID; +}; + +// TODO: seems like these methods are very similar + +VNode.prototype.removeBefore = function removeBefore (ownerID, level, index) { + if (index === level ? 1 << level : this.array.length === 0) { + return this; + } + var originIndex = (index >>> level) & MASK; + if (originIndex >= this.array.length) { + return new VNode([], ownerID); + } + var removingFirst = originIndex === 0; + var newChild; + if (level > 0) { + var oldChild = this.array[originIndex]; + newChild = + oldChild && oldChild.removeBefore(ownerID, level - SHIFT, index); + if (newChild === oldChild && removingFirst) { + return this; + } + } + if (removingFirst && !newChild) { + return this; + } + var editable = editableVNode(this, ownerID); + if (!removingFirst) { + for (var ii = 0; ii < originIndex; ii++) { + editable.array[ii] = undefined; + } + } + if (newChild) { + editable.array[originIndex] = newChild; + } + return editable; +}; + +VNode.prototype.removeAfter = function removeAfter (ownerID, level, index) { + if (index === (level ? 1 << level : 0) || this.array.length === 0) { + return this; + } + var sizeIndex = ((index - 1) >>> level) & MASK; + if (sizeIndex >= this.array.length) { + return this; + } + + var newChild; + if (level > 0) { + var oldChild = this.array[sizeIndex]; + newChild = + oldChild && oldChild.removeAfter(ownerID, level - SHIFT, index); + if (newChild === oldChild && sizeIndex === this.array.length - 1) { + return this; + } + } + + var editable = editableVNode(this, ownerID); + editable.array.splice(sizeIndex + 1); + if (newChild) { + editable.array[sizeIndex] = newChild; + } + return editable; +}; + +var DONE = {}; + +function iterateList(list, reverse) { + var left = list._origin; + var right = list._capacity; + var tailPos = getTailOffset(right); + var tail = list._tail; + + return iterateNodeOrLeaf(list._root, list._level, 0); + + function iterateNodeOrLeaf(node, level, offset) { + return level === 0 + ? iterateLeaf(node, offset) + : iterateNode(node, level, offset); + } + + function iterateLeaf(node, offset) { + var array = offset === tailPos ? tail && tail.array : node && node.array; + var from = offset > left ? 0 : left - offset; + var to = right - offset; + if (to > SIZE) { + to = SIZE; + } + return function () { + if (from === to) { + return DONE; + } + var idx = reverse ? --to : from++; + return array && array[idx]; + }; + } + + function iterateNode(node, level, offset) { + var values; + var array = node && node.array; + var from = offset > left ? 0 : (left - offset) >> level; + var to = ((right - offset) >> level) + 1; + if (to > SIZE) { + to = SIZE; + } + return function () { + while (true) { + if (values) { + var value = values(); + if (value !== DONE) { + return value; + } + values = null; + } + if (from === to) { + return DONE; + } + var idx = reverse ? --to : from++; + values = iterateNodeOrLeaf( + array && array[idx], + level - SHIFT, + offset + (idx << level) + ); + } + }; + } +} + +function makeList(origin, capacity, level, root, tail, ownerID, hash) { + var list = Object.create(ListPrototype); + list.size = capacity - origin; + list._origin = origin; + list._capacity = capacity; + list._level = level; + list._root = root; + list._tail = tail; + list.__ownerID = ownerID; + list.__hash = hash; + list.__altered = false; + return list; +} + +function emptyList() { + return makeList(0, 0, SHIFT); +} + +function updateList(list, index, value) { + index = wrapIndex(list, index); + + if (index !== index) { + return list; + } + + if (index >= list.size || index < 0) { + return list.withMutations(function (list) { + index < 0 + ? setListBounds(list, index).set(0, value) + : setListBounds(list, 0, index + 1).set(index, value); + }); + } + + index += list._origin; + + var newTail = list._tail; + var newRoot = list._root; + var didAlter = MakeRef(); + if (index >= getTailOffset(list._capacity)) { + newTail = updateVNode(newTail, list.__ownerID, 0, index, value, didAlter); + } else { + newRoot = updateVNode( + newRoot, + list.__ownerID, + list._level, + index, + value, + didAlter + ); + } + + if (!didAlter.value) { + return list; + } + + if (list.__ownerID) { + list._root = newRoot; + list._tail = newTail; + list.__hash = undefined; + list.__altered = true; + return list; + } + return makeList(list._origin, list._capacity, list._level, newRoot, newTail); +} + +function updateVNode(node, ownerID, level, index, value, didAlter) { + var idx = (index >>> level) & MASK; + var nodeHas = node && idx < node.array.length; + if (!nodeHas && value === undefined) { + return node; + } + + var newNode; + + if (level > 0) { + var lowerNode = node && node.array[idx]; + var newLowerNode = updateVNode( + lowerNode, + ownerID, + level - SHIFT, + index, + value, + didAlter + ); + if (newLowerNode === lowerNode) { + return node; + } + newNode = editableVNode(node, ownerID); + newNode.array[idx] = newLowerNode; + return newNode; + } + + if (nodeHas && node.array[idx] === value) { + return node; + } + + if (didAlter) { + SetRef(didAlter); + } + + newNode = editableVNode(node, ownerID); + if (value === undefined && idx === newNode.array.length - 1) { + newNode.array.pop(); + } else { + newNode.array[idx] = value; + } + return newNode; +} + +function editableVNode(node, ownerID) { + if (ownerID && node && ownerID === node.ownerID) { + return node; + } + return new VNode(node ? node.array.slice() : [], ownerID); +} + +function listNodeFor(list, rawIndex) { + if (rawIndex >= getTailOffset(list._capacity)) { + return list._tail; + } + if (rawIndex < 1 << (list._level + SHIFT)) { + var node = list._root; + var level = list._level; + while (node && level > 0) { + node = node.array[(rawIndex >>> level) & MASK]; + level -= SHIFT; + } + return node; + } +} + +function setListBounds(list, begin, end) { + // Sanitize begin & end using this shorthand for ToInt32(argument) + // http://www.ecma-international.org/ecma-262/6.0/#sec-toint32 + if (begin !== undefined) { + begin |= 0; + } + if (end !== undefined) { + end |= 0; + } + var owner = list.__ownerID || new OwnerID(); + var oldOrigin = list._origin; + var oldCapacity = list._capacity; + var newOrigin = oldOrigin + begin; + var newCapacity = + end === undefined + ? oldCapacity + : end < 0 + ? oldCapacity + end + : oldOrigin + end; + if (newOrigin === oldOrigin && newCapacity === oldCapacity) { + return list; + } + + // If it's going to end after it starts, it's empty. + if (newOrigin >= newCapacity) { + return list.clear(); + } + + var newLevel = list._level; + var newRoot = list._root; + + // New origin might need creating a higher root. + var offsetShift = 0; + while (newOrigin + offsetShift < 0) { + newRoot = new VNode( + newRoot && newRoot.array.length ? [undefined, newRoot] : [], + owner + ); + newLevel += SHIFT; + offsetShift += 1 << newLevel; + } + if (offsetShift) { + newOrigin += offsetShift; + oldOrigin += offsetShift; + newCapacity += offsetShift; + oldCapacity += offsetShift; + } + + var oldTailOffset = getTailOffset(oldCapacity); + var newTailOffset = getTailOffset(newCapacity); + + // New size might need creating a higher root. + while (newTailOffset >= 1 << (newLevel + SHIFT)) { + newRoot = new VNode( + newRoot && newRoot.array.length ? [newRoot] : [], + owner + ); + newLevel += SHIFT; + } + + // Locate or create the new tail. + var oldTail = list._tail; + var newTail = + newTailOffset < oldTailOffset + ? listNodeFor(list, newCapacity - 1) + : newTailOffset > oldTailOffset + ? new VNode([], owner) + : oldTail; + + // Merge Tail into tree. + if ( + oldTail && + newTailOffset > oldTailOffset && + newOrigin < oldCapacity && + oldTail.array.length + ) { + newRoot = editableVNode(newRoot, owner); + var node = newRoot; + for (var level = newLevel; level > SHIFT; level -= SHIFT) { + var idx = (oldTailOffset >>> level) & MASK; + node = node.array[idx] = editableVNode(node.array[idx], owner); + } + node.array[(oldTailOffset >>> SHIFT) & MASK] = oldTail; + } + + // If the size has been reduced, there's a chance the tail needs to be trimmed. + if (newCapacity < oldCapacity) { + newTail = newTail && newTail.removeAfter(owner, 0, newCapacity); + } + + // If the new origin is within the tail, then we do not need a root. + if (newOrigin >= newTailOffset) { + newOrigin -= newTailOffset; + newCapacity -= newTailOffset; + newLevel = SHIFT; + newRoot = null; + newTail = newTail && newTail.removeBefore(owner, 0, newOrigin); + + // Otherwise, if the root has been trimmed, garbage collect. + } else if (newOrigin > oldOrigin || newTailOffset < oldTailOffset) { + offsetShift = 0; + + // Identify the new top root node of the subtree of the old root. + while (newRoot) { + var beginIndex = (newOrigin >>> newLevel) & MASK; + if ((beginIndex !== newTailOffset >>> newLevel) & MASK) { + break; + } + if (beginIndex) { + offsetShift += (1 << newLevel) * beginIndex; + } + newLevel -= SHIFT; + newRoot = newRoot.array[beginIndex]; + } + + // Trim the new sides of the new root. + if (newRoot && newOrigin > oldOrigin) { + newRoot = newRoot.removeBefore(owner, newLevel, newOrigin - offsetShift); + } + if (newRoot && newTailOffset < oldTailOffset) { + newRoot = newRoot.removeAfter( + owner, + newLevel, + newTailOffset - offsetShift + ); + } + if (offsetShift) { + newOrigin -= offsetShift; + newCapacity -= offsetShift; + } + } + + if (list.__ownerID) { + list.size = newCapacity - newOrigin; + list._origin = newOrigin; + list._capacity = newCapacity; + list._level = newLevel; + list._root = newRoot; + list._tail = newTail; + list.__hash = undefined; + list.__altered = true; + return list; + } + return makeList(newOrigin, newCapacity, newLevel, newRoot, newTail); +} + +function getTailOffset(size) { + return size < SIZE ? 0 : ((size - 1) >>> SHIFT) << SHIFT; +} + +var OrderedMap = /*@__PURE__*/(function (Map) { + function OrderedMap(value) { + // eslint-disable-next-line no-constructor-return + return value === undefined || value === null + ? emptyOrderedMap() + : isOrderedMap(value) + ? value + : emptyOrderedMap().withMutations(function (map) { + var iter = KeyedCollection(value); + assertNotInfinite(iter.size); + iter.forEach(function (v, k) { return map.set(k, v); }); + }); + } + + if ( Map ) OrderedMap.__proto__ = Map; + OrderedMap.prototype = Object.create( Map && Map.prototype ); + OrderedMap.prototype.constructor = OrderedMap; + + OrderedMap.of = function of (/*...values*/) { + return this(arguments); + }; + + OrderedMap.prototype.toString = function toString () { + return this.__toString('OrderedMap {', '}'); + }; + + // @pragma Access + + OrderedMap.prototype.get = function get (k, notSetValue) { + var index = this._map.get(k); + return index !== undefined ? this._list.get(index)[1] : notSetValue; + }; + + // @pragma Modification + + OrderedMap.prototype.clear = function clear () { + if (this.size === 0) { + return this; + } + if (this.__ownerID) { + this.size = 0; + this._map.clear(); + this._list.clear(); + this.__altered = true; + return this; + } + return emptyOrderedMap(); + }; + + OrderedMap.prototype.set = function set (k, v) { + return updateOrderedMap(this, k, v); + }; + + OrderedMap.prototype.remove = function remove (k) { + return updateOrderedMap(this, k, NOT_SET); + }; + + OrderedMap.prototype.__iterate = function __iterate (fn, reverse) { + var this$1$1 = this; + + return this._list.__iterate( + function (entry) { return entry && fn(entry[1], entry[0], this$1$1); }, + reverse + ); + }; + + OrderedMap.prototype.__iterator = function __iterator (type, reverse) { + return this._list.fromEntrySeq().__iterator(type, reverse); + }; + + OrderedMap.prototype.__ensureOwner = function __ensureOwner (ownerID) { + if (ownerID === this.__ownerID) { + return this; + } + var newMap = this._map.__ensureOwner(ownerID); + var newList = this._list.__ensureOwner(ownerID); + if (!ownerID) { + if (this.size === 0) { + return emptyOrderedMap(); + } + this.__ownerID = ownerID; + this.__altered = false; + this._map = newMap; + this._list = newList; + return this; + } + return makeOrderedMap(newMap, newList, ownerID, this.__hash); + }; + + return OrderedMap; +}(Map)); + +OrderedMap.isOrderedMap = isOrderedMap; + +OrderedMap.prototype[IS_ORDERED_SYMBOL] = true; +OrderedMap.prototype[DELETE] = OrderedMap.prototype.remove; + +function makeOrderedMap(map, list, ownerID, hash) { + var omap = Object.create(OrderedMap.prototype); + omap.size = map ? map.size : 0; + omap._map = map; + omap._list = list; + omap.__ownerID = ownerID; + omap.__hash = hash; + omap.__altered = false; + return omap; +} + +var EMPTY_ORDERED_MAP; +function emptyOrderedMap() { + return ( + EMPTY_ORDERED_MAP || + (EMPTY_ORDERED_MAP = makeOrderedMap(emptyMap(), emptyList())) + ); +} + +function updateOrderedMap(omap, k, v) { + var map = omap._map; + var list = omap._list; + var i = map.get(k); + var has = i !== undefined; + var newMap; + var newList; + if (v === NOT_SET) { + // removed + if (!has) { + return omap; + } + if (list.size >= SIZE && list.size >= map.size * 2) { + newList = list.filter(function (entry, idx) { return entry !== undefined && i !== idx; }); + newMap = newList + .toKeyedSeq() + .map(function (entry) { return entry[0]; }) + .flip() + .toMap(); + if (omap.__ownerID) { + newMap.__ownerID = newList.__ownerID = omap.__ownerID; + } + } else { + newMap = map.remove(k); + newList = i === list.size - 1 ? list.pop() : list.set(i, undefined); + } + } else if (has) { + if (v === list.get(i)[1]) { + return omap; + } + newMap = map; + newList = list.set(i, [k, v]); + } else { + newMap = map.set(k, list.size); + newList = list.set(list.size, [k, v]); + } + if (omap.__ownerID) { + omap.size = newMap.size; + omap._map = newMap; + omap._list = newList; + omap.__hash = undefined; + omap.__altered = true; + return omap; + } + return makeOrderedMap(newMap, newList); +} + +var IS_STACK_SYMBOL = '@@__IMMUTABLE_STACK__@@'; + +function isStack(maybeStack) { + return Boolean(maybeStack && maybeStack[IS_STACK_SYMBOL]); +} + +var Stack = /*@__PURE__*/(function (IndexedCollection) { + function Stack(value) { + // eslint-disable-next-line no-constructor-return + return value === undefined || value === null + ? emptyStack() + : isStack(value) + ? value + : emptyStack().pushAll(value); + } + + if ( IndexedCollection ) Stack.__proto__ = IndexedCollection; + Stack.prototype = Object.create( IndexedCollection && IndexedCollection.prototype ); + Stack.prototype.constructor = Stack; + + Stack.of = function of (/*...values*/) { + return this(arguments); + }; + + Stack.prototype.toString = function toString () { + return this.__toString('Stack [', ']'); + }; + + // @pragma Access + + Stack.prototype.get = function get (index, notSetValue) { + var head = this._head; + index = wrapIndex(this, index); + while (head && index--) { + head = head.next; + } + return head ? head.value : notSetValue; + }; + + Stack.prototype.peek = function peek () { + return this._head && this._head.value; + }; + + // @pragma Modification + + Stack.prototype.push = function push (/*...values*/) { + var arguments$1 = arguments; + + if (arguments.length === 0) { + return this; + } + var newSize = this.size + arguments.length; + var head = this._head; + for (var ii = arguments.length - 1; ii >= 0; ii--) { + head = { + value: arguments$1[ii], + next: head, + }; + } + if (this.__ownerID) { + this.size = newSize; + this._head = head; + this.__hash = undefined; + this.__altered = true; + return this; + } + return makeStack(newSize, head); + }; + + Stack.prototype.pushAll = function pushAll (iter) { + iter = IndexedCollection(iter); + if (iter.size === 0) { + return this; + } + if (this.size === 0 && isStack(iter)) { + return iter; + } + assertNotInfinite(iter.size); + var newSize = this.size; + var head = this._head; + iter.__iterate(function (value) { + newSize++; + head = { + value: value, + next: head, + }; + }, /* reverse */ true); + if (this.__ownerID) { + this.size = newSize; + this._head = head; + this.__hash = undefined; + this.__altered = true; + return this; + } + return makeStack(newSize, head); + }; + + Stack.prototype.pop = function pop () { + return this.slice(1); + }; + + Stack.prototype.clear = function clear () { + if (this.size === 0) { + return this; + } + if (this.__ownerID) { + this.size = 0; + this._head = undefined; + this.__hash = undefined; + this.__altered = true; + return this; + } + return emptyStack(); + }; + + Stack.prototype.slice = function slice (begin, end) { + if (wholeSlice(begin, end, this.size)) { + return this; + } + var resolvedBegin = resolveBegin(begin, this.size); + var resolvedEnd = resolveEnd(end, this.size); + if (resolvedEnd !== this.size) { + // super.slice(begin, end); + return IndexedCollection.prototype.slice.call(this, begin, end); + } + var newSize = this.size - resolvedBegin; + var head = this._head; + while (resolvedBegin--) { + head = head.next; + } + if (this.__ownerID) { + this.size = newSize; + this._head = head; + this.__hash = undefined; + this.__altered = true; + return this; + } + return makeStack(newSize, head); + }; + + // @pragma Mutability + + Stack.prototype.__ensureOwner = function __ensureOwner (ownerID) { + if (ownerID === this.__ownerID) { + return this; + } + if (!ownerID) { + if (this.size === 0) { + return emptyStack(); + } + this.__ownerID = ownerID; + this.__altered = false; + return this; + } + return makeStack(this.size, this._head, ownerID, this.__hash); + }; + + // @pragma Iteration + + Stack.prototype.__iterate = function __iterate (fn, reverse) { + var this$1$1 = this; + + if (reverse) { + return new ArraySeq(this.toArray()).__iterate( + function (v, k) { return fn(v, k, this$1$1); }, + reverse + ); + } + var iterations = 0; + var node = this._head; + while (node) { + if (fn(node.value, iterations++, this) === false) { + break; + } + node = node.next; + } + return iterations; + }; + + Stack.prototype.__iterator = function __iterator (type, reverse) { + if (reverse) { + return new ArraySeq(this.toArray()).__iterator(type, reverse); + } + var iterations = 0; + var node = this._head; + return new Iterator(function () { + if (node) { + var value = node.value; + node = node.next; + return iteratorValue(type, iterations++, value); + } + return iteratorDone(); + }); + }; + + return Stack; +}(IndexedCollection)); + +Stack.isStack = isStack; + +var StackPrototype = Stack.prototype; +StackPrototype[IS_STACK_SYMBOL] = true; +StackPrototype.shift = StackPrototype.pop; +StackPrototype.unshift = StackPrototype.push; +StackPrototype.unshiftAll = StackPrototype.pushAll; +StackPrototype.withMutations = withMutations; +StackPrototype.wasAltered = wasAltered; +StackPrototype.asImmutable = asImmutable; +StackPrototype['@@transducer/init'] = StackPrototype.asMutable = asMutable; +StackPrototype['@@transducer/step'] = function (result, arr) { + return result.unshift(arr); +}; +StackPrototype['@@transducer/result'] = function (obj) { + return obj.asImmutable(); +}; + +function makeStack(size, head, ownerID, hash) { + var map = Object.create(StackPrototype); + map.size = size; + map._head = head; + map.__ownerID = ownerID; + map.__hash = hash; + map.__altered = false; + return map; +} + +var EMPTY_STACK; +function emptyStack() { + return EMPTY_STACK || (EMPTY_STACK = makeStack(0)); +} + +var IS_SET_SYMBOL = '@@__IMMUTABLE_SET__@@'; + +function isSet(maybeSet) { + return Boolean(maybeSet && maybeSet[IS_SET_SYMBOL]); +} + +function isOrderedSet(maybeOrderedSet) { + return isSet(maybeOrderedSet) && isOrdered(maybeOrderedSet); +} + +function deepEqual(a, b) { + if (a === b) { + return true; + } + + if ( + !isCollection(b) || + (a.size !== undefined && b.size !== undefined && a.size !== b.size) || + (a.__hash !== undefined && + b.__hash !== undefined && + a.__hash !== b.__hash) || + isKeyed(a) !== isKeyed(b) || + isIndexed(a) !== isIndexed(b) || + isOrdered(a) !== isOrdered(b) + ) { + return false; + } + + if (a.size === 0 && b.size === 0) { + return true; + } + + var notAssociative = !isAssociative(a); + + if (isOrdered(a)) { + var entries = a.entries(); + return ( + b.every(function (v, k) { + var entry = entries.next().value; + return entry && is(entry[1], v) && (notAssociative || is(entry[0], k)); + }) && entries.next().done + ); + } + + var flipped = false; + + if (a.size === undefined) { + if (b.size === undefined) { + if (typeof a.cacheResult === 'function') { + a.cacheResult(); + } + } else { + flipped = true; + var _ = a; + a = b; + b = _; + } + } + + var allEqual = true; + var bSize = b.__iterate(function (v, k) { + if ( + notAssociative + ? !a.has(v) + : flipped + ? !is(v, a.get(k, NOT_SET)) + : !is(a.get(k, NOT_SET), v) + ) { + allEqual = false; + return false; + } + }); + + return allEqual && a.size === bSize; +} + +/** + * Contributes additional methods to a constructor + */ +function mixin(ctor, methods) { + var keyCopier = function (key) { + ctor.prototype[key] = methods[key]; + }; + Object.keys(methods).forEach(keyCopier); + Object.getOwnPropertySymbols && + Object.getOwnPropertySymbols(methods).forEach(keyCopier); + return ctor; +} + +function toJS(value) { + if (!value || typeof value !== 'object') { + return value; + } + if (!isCollection(value)) { + if (!isDataStructure(value)) { + return value; + } + value = Seq(value); + } + if (isKeyed(value)) { + var result$1 = {}; + value.__iterate(function (v, k) { + result$1[k] = toJS(v); + }); + return result$1; + } + var result = []; + value.__iterate(function (v) { + result.push(toJS(v)); + }); + return result; +} + +var Set = /*@__PURE__*/(function (SetCollection) { + function Set(value) { + // eslint-disable-next-line no-constructor-return + return value === undefined || value === null + ? emptySet() + : isSet(value) && !isOrdered(value) + ? value + : emptySet().withMutations(function (set) { + var iter = SetCollection(value); + assertNotInfinite(iter.size); + iter.forEach(function (v) { return set.add(v); }); + }); + } + + if ( SetCollection ) Set.__proto__ = SetCollection; + Set.prototype = Object.create( SetCollection && SetCollection.prototype ); + Set.prototype.constructor = Set; + + Set.of = function of (/*...values*/) { + return this(arguments); + }; + + Set.fromKeys = function fromKeys (value) { + return this(KeyedCollection(value).keySeq()); + }; + + Set.intersect = function intersect (sets) { + sets = Collection(sets).toArray(); + return sets.length + ? SetPrototype.intersect.apply(Set(sets.pop()), sets) + : emptySet(); + }; + + Set.union = function union (sets) { + sets = Collection(sets).toArray(); + return sets.length + ? SetPrototype.union.apply(Set(sets.pop()), sets) + : emptySet(); + }; + + Set.prototype.toString = function toString () { + return this.__toString('Set {', '}'); + }; + + // @pragma Access + + Set.prototype.has = function has (value) { + return this._map.has(value); + }; + + // @pragma Modification + + Set.prototype.add = function add (value) { + return updateSet(this, this._map.set(value, value)); + }; + + Set.prototype.remove = function remove (value) { + return updateSet(this, this._map.remove(value)); + }; + + Set.prototype.clear = function clear () { + return updateSet(this, this._map.clear()); + }; + + // @pragma Composition + + Set.prototype.map = function map (mapper, context) { + var this$1$1 = this; + + // keep track if the set is altered by the map function + var didChanges = false; + + var newMap = updateSet( + this, + this._map.mapEntries(function (ref) { + var v = ref[1]; + + var mapped = mapper.call(context, v, v, this$1$1); + + if (mapped !== v) { + didChanges = true; + } + + return [mapped, mapped]; + }, context) + ); + + return didChanges ? newMap : this; + }; + + Set.prototype.union = function union () { + var iters = [], len = arguments.length; + while ( len-- ) iters[ len ] = arguments[ len ]; + + iters = iters.filter(function (x) { return x.size !== 0; }); + if (iters.length === 0) { + return this; + } + if (this.size === 0 && !this.__ownerID && iters.length === 1) { + return this.constructor(iters[0]); + } + return this.withMutations(function (set) { + for (var ii = 0; ii < iters.length; ii++) { + if (typeof iters[ii] === 'string') { + set.add(iters[ii]); + } else { + SetCollection(iters[ii]).forEach(function (value) { return set.add(value); }); + } + } + }); + }; + + Set.prototype.intersect = function intersect () { + var iters = [], len = arguments.length; + while ( len-- ) iters[ len ] = arguments[ len ]; + + if (iters.length === 0) { + return this; + } + iters = iters.map(function (iter) { return SetCollection(iter); }); + var toRemove = []; + this.forEach(function (value) { + if (!iters.every(function (iter) { return iter.includes(value); })) { + toRemove.push(value); + } + }); + return this.withMutations(function (set) { + toRemove.forEach(function (value) { + set.remove(value); + }); + }); + }; + + Set.prototype.subtract = function subtract () { + var iters = [], len = arguments.length; + while ( len-- ) iters[ len ] = arguments[ len ]; + + if (iters.length === 0) { + return this; + } + iters = iters.map(function (iter) { return SetCollection(iter); }); + var toRemove = []; + this.forEach(function (value) { + if (iters.some(function (iter) { return iter.includes(value); })) { + toRemove.push(value); + } + }); + return this.withMutations(function (set) { + toRemove.forEach(function (value) { + set.remove(value); + }); + }); + }; + + Set.prototype.sort = function sort (comparator) { + // Late binding + return OrderedSet(sortFactory(this, comparator)); + }; + + Set.prototype.sortBy = function sortBy (mapper, comparator) { + // Late binding + return OrderedSet(sortFactory(this, comparator, mapper)); + }; + + Set.prototype.wasAltered = function wasAltered () { + return this._map.wasAltered(); + }; + + Set.prototype.__iterate = function __iterate (fn, reverse) { + var this$1$1 = this; + + return this._map.__iterate(function (k) { return fn(k, k, this$1$1); }, reverse); + }; + + Set.prototype.__iterator = function __iterator (type, reverse) { + return this._map.__iterator(type, reverse); + }; + + Set.prototype.__ensureOwner = function __ensureOwner (ownerID) { + if (ownerID === this.__ownerID) { + return this; + } + var newMap = this._map.__ensureOwner(ownerID); + if (!ownerID) { + if (this.size === 0) { + return this.__empty(); + } + this.__ownerID = ownerID; + this._map = newMap; + return this; + } + return this.__make(newMap, ownerID); + }; + + return Set; +}(SetCollection)); + +Set.isSet = isSet; + +var SetPrototype = Set.prototype; +SetPrototype[IS_SET_SYMBOL] = true; +SetPrototype[DELETE] = SetPrototype.remove; +SetPrototype.merge = SetPrototype.concat = SetPrototype.union; +SetPrototype.withMutations = withMutations; +SetPrototype.asImmutable = asImmutable; +SetPrototype['@@transducer/init'] = SetPrototype.asMutable = asMutable; +SetPrototype['@@transducer/step'] = function (result, arr) { + return result.add(arr); +}; +SetPrototype['@@transducer/result'] = function (obj) { + return obj.asImmutable(); +}; + +SetPrototype.__empty = emptySet; +SetPrototype.__make = makeSet; + +function updateSet(set, newMap) { + if (set.__ownerID) { + set.size = newMap.size; + set._map = newMap; + return set; + } + return newMap === set._map + ? set + : newMap.size === 0 + ? set.__empty() + : set.__make(newMap); +} + +function makeSet(map, ownerID) { + var set = Object.create(SetPrototype); + set.size = map ? map.size : 0; + set._map = map; + set.__ownerID = ownerID; + return set; +} + +var EMPTY_SET; +function emptySet() { + return EMPTY_SET || (EMPTY_SET = makeSet(emptyMap())); +} + +/** + * Returns a lazy seq of nums from start (inclusive) to end + * (exclusive), by step, where start defaults to 0, step to 1, and end to + * infinity. When start is equal to end, returns empty list. + */ +var Range = /*@__PURE__*/(function (IndexedSeq) { + function Range(start, end, step) { + if ( step === void 0 ) step = 1; + + if (!(this instanceof Range)) { + // eslint-disable-next-line no-constructor-return + return new Range(start, end, step); + } + invariant(step !== 0, 'Cannot step a Range by 0'); + invariant( + start !== undefined, + 'You must define a start value when using Range' + ); + invariant( + end !== undefined, + 'You must define an end value when using Range' + ); + + step = Math.abs(step); + if (end < start) { + step = -step; + } + this._start = start; + this._end = end; + this._step = step; + this.size = Math.max(0, Math.ceil((end - start) / step - 1) + 1); + if (this.size === 0) { + if (EMPTY_RANGE) { + // eslint-disable-next-line no-constructor-return + return EMPTY_RANGE; + } + // eslint-disable-next-line @typescript-eslint/no-this-alias + EMPTY_RANGE = this; + } + } + + if ( IndexedSeq ) Range.__proto__ = IndexedSeq; + Range.prototype = Object.create( IndexedSeq && IndexedSeq.prototype ); + Range.prototype.constructor = Range; + + Range.prototype.toString = function toString () { + if (this.size === 0) { + return 'Range []'; + } + return ( + 'Range [ ' + + this._start + + '...' + + this._end + + (this._step !== 1 ? ' by ' + this._step : '') + + ' ]' + ); + }; + + Range.prototype.get = function get (index, notSetValue) { + return this.has(index) + ? this._start + wrapIndex(this, index) * this._step + : notSetValue; + }; + + Range.prototype.includes = function includes (searchValue) { + var possibleIndex = (searchValue - this._start) / this._step; + return ( + possibleIndex >= 0 && + possibleIndex < this.size && + possibleIndex === Math.floor(possibleIndex) + ); + }; + + Range.prototype.slice = function slice (begin, end) { + if (wholeSlice(begin, end, this.size)) { + return this; + } + begin = resolveBegin(begin, this.size); + end = resolveEnd(end, this.size); + if (end <= begin) { + return new Range(0, 0); + } + return new Range( + this.get(begin, this._end), + this.get(end, this._end), + this._step + ); + }; + + Range.prototype.indexOf = function indexOf (searchValue) { + var offsetValue = searchValue - this._start; + if (offsetValue % this._step === 0) { + var index = offsetValue / this._step; + if (index >= 0 && index < this.size) { + return index; + } + } + return -1; + }; + + Range.prototype.lastIndexOf = function lastIndexOf (searchValue) { + return this.indexOf(searchValue); + }; + + Range.prototype.__iterate = function __iterate (fn, reverse) { + var size = this.size; + var step = this._step; + var value = reverse ? this._start + (size - 1) * step : this._start; + var i = 0; + while (i !== size) { + if (fn(value, reverse ? size - ++i : i++, this) === false) { + break; + } + value += reverse ? -step : step; + } + return i; + }; + + Range.prototype.__iterator = function __iterator (type, reverse) { + var size = this.size; + var step = this._step; + var value = reverse ? this._start + (size - 1) * step : this._start; + var i = 0; + return new Iterator(function () { + if (i === size) { + return iteratorDone(); + } + var v = value; + value += reverse ? -step : step; + return iteratorValue(type, reverse ? size - ++i : i++, v); + }); + }; + + Range.prototype.equals = function equals (other) { + return other instanceof Range + ? this._start === other._start && + this._end === other._end && + this._step === other._step + : deepEqual(this, other); + }; + + return Range; +}(IndexedSeq)); + +var EMPTY_RANGE; + +function getIn$1(collection, searchKeyPath, notSetValue) { + var keyPath = coerceKeyPath(searchKeyPath); + var i = 0; + while (i !== keyPath.length) { + collection = get(collection, keyPath[i++], NOT_SET); + if (collection === NOT_SET) { + return notSetValue; + } + } + return collection; +} + +function getIn(searchKeyPath, notSetValue) { + return getIn$1(this, searchKeyPath, notSetValue); +} + +function hasIn$1(collection, keyPath) { + return getIn$1(collection, keyPath, NOT_SET) !== NOT_SET; +} + +function hasIn(searchKeyPath) { + return hasIn$1(this, searchKeyPath); +} + +function toObject() { + assertNotInfinite(this.size); + var object = {}; + this.__iterate(function (v, k) { + object[k] = v; + }); + return object; +} + +Collection.Iterator = Iterator; + +mixin(Collection, { + // ### Conversion to other types + + toArray: function toArray() { + assertNotInfinite(this.size); + var array = new Array(this.size || 0); + var useTuples = isKeyed(this); + var i = 0; + this.__iterate(function (v, k) { + // Keyed collections produce an array of tuples. + array[i++] = useTuples ? [k, v] : v; + }); + return array; + }, + + toIndexedSeq: function toIndexedSeq() { + return new ToIndexedSequence(this); + }, + + toJS: function toJS$1() { + return toJS(this); + }, + + toKeyedSeq: function toKeyedSeq() { + return new ToKeyedSequence(this, true); + }, + + toMap: function toMap() { + // Use Late Binding here to solve the circular dependency. + return Map(this.toKeyedSeq()); + }, + + toObject: toObject, + + toOrderedMap: function toOrderedMap() { + // Use Late Binding here to solve the circular dependency. + return OrderedMap(this.toKeyedSeq()); + }, + + toOrderedSet: function toOrderedSet() { + // Use Late Binding here to solve the circular dependency. + return OrderedSet(isKeyed(this) ? this.valueSeq() : this); + }, + + toSet: function toSet() { + // Use Late Binding here to solve the circular dependency. + return Set(isKeyed(this) ? this.valueSeq() : this); + }, + + toSetSeq: function toSetSeq() { + return new ToSetSequence(this); + }, + + toSeq: function toSeq() { + return isIndexed(this) + ? this.toIndexedSeq() + : isKeyed(this) + ? this.toKeyedSeq() + : this.toSetSeq(); + }, + + toStack: function toStack() { + // Use Late Binding here to solve the circular dependency. + return Stack(isKeyed(this) ? this.valueSeq() : this); + }, + + toList: function toList() { + // Use Late Binding here to solve the circular dependency. + return List(isKeyed(this) ? this.valueSeq() : this); + }, + + // ### Common JavaScript methods and properties + + toString: function toString() { + return '[Collection]'; + }, + + __toString: function __toString(head, tail) { + if (this.size === 0) { + return head + tail; + } + return ( + head + + ' ' + + this.toSeq().map(this.__toStringMapper).join(', ') + + ' ' + + tail + ); + }, + + // ### ES6 Collection methods (ES6 Array and Map) + + concat: function concat() { + var values = [], len = arguments.length; + while ( len-- ) values[ len ] = arguments[ len ]; + + return reify(this, concatFactory(this, values)); + }, + + includes: function includes(searchValue) { + return this.some(function (value) { return is(value, searchValue); }); + }, + + entries: function entries() { + return this.__iterator(ITERATE_ENTRIES); + }, + + every: function every(predicate, context) { + assertNotInfinite(this.size); + var returnValue = true; + this.__iterate(function (v, k, c) { + if (!predicate.call(context, v, k, c)) { + returnValue = false; + return false; + } + }); + return returnValue; + }, + + filter: function filter(predicate, context) { + return reify(this, filterFactory(this, predicate, context, true)); + }, + + partition: function partition(predicate, context) { + return partitionFactory(this, predicate, context); + }, + + find: function find(predicate, context, notSetValue) { + var entry = this.findEntry(predicate, context); + return entry ? entry[1] : notSetValue; + }, + + forEach: function forEach(sideEffect, context) { + assertNotInfinite(this.size); + return this.__iterate(context ? sideEffect.bind(context) : sideEffect); + }, + + join: function join(separator) { + assertNotInfinite(this.size); + separator = separator !== undefined ? '' + separator : ','; + var joined = ''; + var isFirst = true; + this.__iterate(function (v) { + isFirst ? (isFirst = false) : (joined += separator); + joined += v !== null && v !== undefined ? v.toString() : ''; + }); + return joined; + }, + + keys: function keys() { + return this.__iterator(ITERATE_KEYS); + }, + + map: function map(mapper, context) { + return reify(this, mapFactory(this, mapper, context)); + }, + + reduce: function reduce$1(reducer, initialReduction, context) { + return reduce( + this, + reducer, + initialReduction, + context, + arguments.length < 2, + false + ); + }, + + reduceRight: function reduceRight(reducer, initialReduction, context) { + return reduce( + this, + reducer, + initialReduction, + context, + arguments.length < 2, + true + ); + }, + + reverse: function reverse() { + return reify(this, reverseFactory(this, true)); + }, + + slice: function slice(begin, end) { + return reify(this, sliceFactory(this, begin, end, true)); + }, + + some: function some(predicate, context) { + assertNotInfinite(this.size); + var returnValue = false; + this.__iterate(function (v, k, c) { + if (predicate.call(context, v, k, c)) { + returnValue = true; + return false; + } + }); + return returnValue; + }, + + sort: function sort(comparator) { + return reify(this, sortFactory(this, comparator)); + }, + + values: function values() { + return this.__iterator(ITERATE_VALUES); + }, + + // ### More sequential methods + + butLast: function butLast() { + return this.slice(0, -1); + }, + + isEmpty: function isEmpty() { + return this.size !== undefined ? this.size === 0 : !this.some(function () { return true; }); + }, + + count: function count(predicate, context) { + return ensureSize( + predicate ? this.toSeq().filter(predicate, context) : this + ); + }, + + countBy: function countBy(grouper, context) { + return countByFactory(this, grouper, context); + }, + + equals: function equals(other) { + return deepEqual(this, other); + }, + + entrySeq: function entrySeq() { + // eslint-disable-next-line @typescript-eslint/no-this-alias + var collection = this; + if (collection._cache) { + // We cache as an entries array, so we can just return the cache! + return new ArraySeq(collection._cache); + } + var entriesSequence = collection.toSeq().map(entryMapper).toIndexedSeq(); + entriesSequence.fromEntrySeq = function () { return collection.toSeq(); }; + return entriesSequence; + }, + + filterNot: function filterNot(predicate, context) { + return this.filter(not(predicate), context); + }, + + findEntry: function findEntry(predicate, context, notSetValue) { + var found = notSetValue; + this.__iterate(function (v, k, c) { + if (predicate.call(context, v, k, c)) { + found = [k, v]; + return false; + } + }); + return found; + }, + + findKey: function findKey(predicate, context) { + var entry = this.findEntry(predicate, context); + return entry && entry[0]; + }, + + findLast: function findLast(predicate, context, notSetValue) { + return this.toKeyedSeq().reverse().find(predicate, context, notSetValue); + }, + + findLastEntry: function findLastEntry(predicate, context, notSetValue) { + return this.toKeyedSeq() + .reverse() + .findEntry(predicate, context, notSetValue); + }, + + findLastKey: function findLastKey(predicate, context) { + return this.toKeyedSeq().reverse().findKey(predicate, context); + }, + + first: function first(notSetValue) { + return this.find(returnTrue, null, notSetValue); + }, + + flatMap: function flatMap(mapper, context) { + return reify(this, flatMapFactory(this, mapper, context)); + }, + + flatten: function flatten(depth) { + return reify(this, flattenFactory(this, depth, true)); + }, + + fromEntrySeq: function fromEntrySeq() { + return new FromEntriesSequence(this); + }, + + get: function get(searchKey, notSetValue) { + return this.find(function (_, key) { return is(key, searchKey); }, undefined, notSetValue); + }, + + getIn: getIn, + + groupBy: function groupBy(grouper, context) { + return groupByFactory(this, grouper, context); + }, + + has: function has(searchKey) { + return this.get(searchKey, NOT_SET) !== NOT_SET; + }, + + hasIn: hasIn, + + isSubset: function isSubset(iter) { + iter = typeof iter.includes === 'function' ? iter : Collection(iter); + return this.every(function (value) { return iter.includes(value); }); + }, + + isSuperset: function isSuperset(iter) { + iter = typeof iter.isSubset === 'function' ? iter : Collection(iter); + return iter.isSubset(this); + }, + + keyOf: function keyOf(searchValue) { + return this.findKey(function (value) { return is(value, searchValue); }); + }, + + keySeq: function keySeq() { + return this.toSeq().map(keyMapper).toIndexedSeq(); + }, + + last: function last(notSetValue) { + return this.toSeq().reverse().first(notSetValue); + }, + + lastKeyOf: function lastKeyOf(searchValue) { + return this.toKeyedSeq().reverse().keyOf(searchValue); + }, + + max: function max(comparator) { + return maxFactory(this, comparator); + }, + + maxBy: function maxBy(mapper, comparator) { + return maxFactory(this, comparator, mapper); + }, + + min: function min(comparator) { + return maxFactory( + this, + comparator ? neg(comparator) : defaultNegComparator + ); + }, + + minBy: function minBy(mapper, comparator) { + return maxFactory( + this, + comparator ? neg(comparator) : defaultNegComparator, + mapper + ); + }, + + rest: function rest() { + return this.slice(1); + }, + + skip: function skip(amount) { + return amount === 0 ? this : this.slice(Math.max(0, amount)); + }, + + skipLast: function skipLast(amount) { + return amount === 0 ? this : this.slice(0, -Math.max(0, amount)); + }, + + skipWhile: function skipWhile(predicate, context) { + return reify(this, skipWhileFactory(this, predicate, context, true)); + }, + + skipUntil: function skipUntil(predicate, context) { + return this.skipWhile(not(predicate), context); + }, + + sortBy: function sortBy(mapper, comparator) { + return reify(this, sortFactory(this, comparator, mapper)); + }, + + take: function take(amount) { + return this.slice(0, Math.max(0, amount)); + }, + + takeLast: function takeLast(amount) { + return this.slice(-Math.max(0, amount)); + }, + + takeWhile: function takeWhile(predicate, context) { + return reify(this, takeWhileFactory(this, predicate, context)); + }, + + takeUntil: function takeUntil(predicate, context) { + return this.takeWhile(not(predicate), context); + }, + + update: function update(fn) { + return fn(this); + }, + + valueSeq: function valueSeq() { + return this.toIndexedSeq(); + }, + + // ### Hashable Object + + hashCode: function hashCode() { + return this.__hash || (this.__hash = hashCollection(this)); + }, + + // ### Internal + + // abstract __iterate(fn, reverse) + + // abstract __iterator(type, reverse) +}); + +var CollectionPrototype = Collection.prototype; +CollectionPrototype[IS_COLLECTION_SYMBOL] = true; +CollectionPrototype[ITERATOR_SYMBOL] = CollectionPrototype.values; +CollectionPrototype.toJSON = CollectionPrototype.toArray; +CollectionPrototype.__toStringMapper = quoteString; +CollectionPrototype.inspect = CollectionPrototype.toSource = function () { + return this.toString(); +}; +CollectionPrototype.chain = CollectionPrototype.flatMap; +CollectionPrototype.contains = CollectionPrototype.includes; + +mixin(KeyedCollection, { + // ### More sequential methods + + flip: function flip() { + return reify(this, flipFactory(this)); + }, + + mapEntries: function mapEntries(mapper, context) { + var this$1$1 = this; + + var iterations = 0; + return reify( + this, + this.toSeq() + .map(function (v, k) { return mapper.call(context, [k, v], iterations++, this$1$1); }) + .fromEntrySeq() + ); + }, + + mapKeys: function mapKeys(mapper, context) { + var this$1$1 = this; + + return reify( + this, + this.toSeq() + .flip() + .map(function (k, v) { return mapper.call(context, k, v, this$1$1); }) + .flip() + ); + }, +}); + +var KeyedCollectionPrototype = KeyedCollection.prototype; +KeyedCollectionPrototype[IS_KEYED_SYMBOL] = true; +KeyedCollectionPrototype[ITERATOR_SYMBOL] = CollectionPrototype.entries; +KeyedCollectionPrototype.toJSON = toObject; +KeyedCollectionPrototype.__toStringMapper = function (v, k) { return quoteString(k) + ': ' + quoteString(v); }; + +mixin(IndexedCollection, { + // ### Conversion to other types + + toKeyedSeq: function toKeyedSeq() { + return new ToKeyedSequence(this, false); + }, + + // ### ES6 Collection methods (ES6 Array and Map) + + filter: function filter(predicate, context) { + return reify(this, filterFactory(this, predicate, context, false)); + }, + + findIndex: function findIndex(predicate, context) { + var entry = this.findEntry(predicate, context); + return entry ? entry[0] : -1; + }, + + indexOf: function indexOf(searchValue) { + var key = this.keyOf(searchValue); + return key === undefined ? -1 : key; + }, + + lastIndexOf: function lastIndexOf(searchValue) { + var key = this.lastKeyOf(searchValue); + return key === undefined ? -1 : key; + }, + + reverse: function reverse() { + return reify(this, reverseFactory(this, false)); + }, + + slice: function slice(begin, end) { + return reify(this, sliceFactory(this, begin, end, false)); + }, + + splice: function splice(index, removeNum /*, ...values*/) { + var numArgs = arguments.length; + removeNum = Math.max(removeNum || 0, 0); + if (numArgs === 0 || (numArgs === 2 && !removeNum)) { + return this; + } + // If index is negative, it should resolve relative to the size of the + // collection. However size may be expensive to compute if not cached, so + // only call count() if the number is in fact negative. + index = resolveBegin(index, index < 0 ? this.count() : this.size); + var spliced = this.slice(0, index); + return reify( + this, + numArgs === 1 + ? spliced + : spliced.concat(arrCopy(arguments, 2), this.slice(index + removeNum)) + ); + }, + + // ### More collection methods + + findLastIndex: function findLastIndex(predicate, context) { + var entry = this.findLastEntry(predicate, context); + return entry ? entry[0] : -1; + }, + + first: function first(notSetValue) { + return this.get(0, notSetValue); + }, + + flatten: function flatten(depth) { + return reify(this, flattenFactory(this, depth, false)); + }, + + get: function get(index, notSetValue) { + index = wrapIndex(this, index); + return index < 0 || + this.size === Infinity || + (this.size !== undefined && index > this.size) + ? notSetValue + : this.find(function (_, key) { return key === index; }, undefined, notSetValue); + }, + + has: function has(index) { + index = wrapIndex(this, index); + return ( + index >= 0 && + (this.size !== undefined + ? this.size === Infinity || index < this.size + : this.indexOf(index) !== -1) + ); + }, + + interpose: function interpose(separator) { + return reify(this, interposeFactory(this, separator)); + }, + + interleave: function interleave(/*...collections*/) { + var collections = [this].concat(arrCopy(arguments)); + var zipped = zipWithFactory(this.toSeq(), IndexedSeq.of, collections); + var interleaved = zipped.flatten(true); + if (zipped.size) { + interleaved.size = zipped.size * collections.length; + } + return reify(this, interleaved); + }, + + keySeq: function keySeq() { + return Range(0, this.size); + }, + + last: function last(notSetValue) { + return this.get(-1, notSetValue); + }, + + skipWhile: function skipWhile(predicate, context) { + return reify(this, skipWhileFactory(this, predicate, context, false)); + }, + + zip: function zip(/*, ...collections */) { + var collections = [this].concat(arrCopy(arguments)); + return reify(this, zipWithFactory(this, defaultZipper, collections)); + }, + + zipAll: function zipAll(/*, ...collections */) { + var collections = [this].concat(arrCopy(arguments)); + return reify(this, zipWithFactory(this, defaultZipper, collections, true)); + }, + + zipWith: function zipWith(zipper /*, ...collections */) { + var collections = arrCopy(arguments); + collections[0] = this; + return reify(this, zipWithFactory(this, zipper, collections)); + }, +}); + +var IndexedCollectionPrototype = IndexedCollection.prototype; +IndexedCollectionPrototype[IS_INDEXED_SYMBOL] = true; +IndexedCollectionPrototype[IS_ORDERED_SYMBOL] = true; + +mixin(SetCollection, { + // ### ES6 Collection methods (ES6 Array and Map) + + get: function get(value, notSetValue) { + return this.has(value) ? value : notSetValue; + }, + + includes: function includes(value) { + return this.has(value); + }, + + // ### More sequential methods + + keySeq: function keySeq() { + return this.valueSeq(); + }, +}); + +var SetCollectionPrototype = SetCollection.prototype; +SetCollectionPrototype.has = CollectionPrototype.includes; +SetCollectionPrototype.contains = SetCollectionPrototype.includes; +SetCollectionPrototype.keys = SetCollectionPrototype.values; + +// Mixin subclasses + +mixin(KeyedSeq, KeyedCollectionPrototype); +mixin(IndexedSeq, IndexedCollectionPrototype); +mixin(SetSeq, SetCollectionPrototype); + +// #pragma Helper functions + +function reduce(collection, reducer, reduction, context, useFirst, reverse) { + assertNotInfinite(collection.size); + collection.__iterate(function (v, k, c) { + if (useFirst) { + useFirst = false; + reduction = v; + } else { + reduction = reducer.call(context, reduction, v, k, c); + } + }, reverse); + return reduction; +} + +function keyMapper(v, k) { + return k; +} + +function entryMapper(v, k) { + return [k, v]; +} + +function not(predicate) { + return function () { + return !predicate.apply(this, arguments); + }; +} + +function neg(predicate) { + return function () { + return -predicate.apply(this, arguments); + }; +} + +function defaultZipper() { + return arrCopy(arguments); +} + +function defaultNegComparator(a, b) { + return a < b ? 1 : a > b ? -1 : 0; +} + +function hashCollection(collection) { + if (collection.size === Infinity) { + return 0; + } + var ordered = isOrdered(collection); + var keyed = isKeyed(collection); + var h = ordered ? 1 : 0; + + collection.__iterate( + keyed + ? ordered + ? function (v, k) { + h = (31 * h + hashMerge(hash(v), hash(k))) | 0; + } + : function (v, k) { + h = (h + hashMerge(hash(v), hash(k))) | 0; + } + : ordered + ? function (v) { + h = (31 * h + hash(v)) | 0; + } + : function (v) { + h = (h + hash(v)) | 0; + } + ); + + return murmurHashOfSize(collection.size, h); +} + +function murmurHashOfSize(size, h) { + h = imul(h, 0xcc9e2d51); + h = imul((h << 15) | (h >>> -15), 0x1b873593); + h = imul((h << 13) | (h >>> -13), 5); + h = ((h + 0xe6546b64) | 0) ^ size; + h = imul(h ^ (h >>> 16), 0x85ebca6b); + h = imul(h ^ (h >>> 13), 0xc2b2ae35); + h = smi(h ^ (h >>> 16)); + return h; +} + +function hashMerge(a, b) { + return (a ^ (b + 0x9e3779b9 + (a << 6) + (a >> 2))) | 0; // int +} + +var OrderedSet = /*@__PURE__*/(function (Set) { + function OrderedSet(value) { + // eslint-disable-next-line no-constructor-return + return value === undefined || value === null + ? emptyOrderedSet() + : isOrderedSet(value) + ? value + : emptyOrderedSet().withMutations(function (set) { + var iter = SetCollection(value); + assertNotInfinite(iter.size); + iter.forEach(function (v) { return set.add(v); }); + }); + } + + if ( Set ) OrderedSet.__proto__ = Set; + OrderedSet.prototype = Object.create( Set && Set.prototype ); + OrderedSet.prototype.constructor = OrderedSet; + + OrderedSet.of = function of (/*...values*/) { + return this(arguments); + }; + + OrderedSet.fromKeys = function fromKeys (value) { + return this(KeyedCollection(value).keySeq()); + }; + + OrderedSet.prototype.toString = function toString () { + return this.__toString('OrderedSet {', '}'); + }; + + return OrderedSet; +}(Set)); + +OrderedSet.isOrderedSet = isOrderedSet; + +var OrderedSetPrototype = OrderedSet.prototype; +OrderedSetPrototype[IS_ORDERED_SYMBOL] = true; +OrderedSetPrototype.zip = IndexedCollectionPrototype.zip; +OrderedSetPrototype.zipWith = IndexedCollectionPrototype.zipWith; +OrderedSetPrototype.zipAll = IndexedCollectionPrototype.zipAll; + +OrderedSetPrototype.__empty = emptyOrderedSet; +OrderedSetPrototype.__make = makeOrderedSet; + +function makeOrderedSet(map, ownerID) { + var set = Object.create(OrderedSetPrototype); + set.size = map ? map.size : 0; + set._map = map; + set.__ownerID = ownerID; + return set; +} + +var EMPTY_ORDERED_SET; +function emptyOrderedSet() { + return ( + EMPTY_ORDERED_SET || (EMPTY_ORDERED_SET = makeOrderedSet(emptyOrderedMap())) + ); +} + +var PairSorting = { + LeftThenRight: -1, + RightThenLeft: +1, +}; + +function throwOnInvalidDefaultValues(defaultValues) { + if (isRecord(defaultValues)) { + throw new Error( + 'Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.' + ); + } + + if (isImmutable(defaultValues)) { + throw new Error( + 'Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.' + ); + } + + if (defaultValues === null || typeof defaultValues !== 'object') { + throw new Error( + 'Can not call `Record` with a non-object as default values. Use a plain javascript object instead.' + ); + } +} + +var Record = function Record(defaultValues, name) { + var hasInitialized; + + throwOnInvalidDefaultValues(defaultValues); + + var RecordType = function Record(values) { + var this$1$1 = this; + + if (values instanceof RecordType) { + return values; + } + if (!(this instanceof RecordType)) { + return new RecordType(values); + } + if (!hasInitialized) { + hasInitialized = true; + var keys = Object.keys(defaultValues); + var indices = (RecordTypePrototype._indices = {}); + // Deprecated: left to attempt not to break any external code which + // relies on a ._name property existing on record instances. + // Use Record.getDescriptiveName() instead + RecordTypePrototype._name = name; + RecordTypePrototype._keys = keys; + RecordTypePrototype._defaultValues = defaultValues; + for (var i = 0; i < keys.length; i++) { + var propName = keys[i]; + indices[propName] = i; + if (RecordTypePrototype[propName]) { + /* eslint-disable no-console */ + typeof console === 'object' && + console.warn && + console.warn( + 'Cannot define ' + + recordName(this) + + ' with property "' + + propName + + '" since that property name is part of the Record API.' + ); + /* eslint-enable no-console */ + } else { + setProp(RecordTypePrototype, propName); + } + } + } + this.__ownerID = undefined; + this._values = List().withMutations(function (l) { + l.setSize(this$1$1._keys.length); + KeyedCollection(values).forEach(function (v, k) { + l.set(this$1$1._indices[k], v === this$1$1._defaultValues[k] ? undefined : v); + }); + }); + return this; + }; + + var RecordTypePrototype = (RecordType.prototype = + Object.create(RecordPrototype)); + RecordTypePrototype.constructor = RecordType; + + if (name) { + RecordType.displayName = name; + } + + // eslint-disable-next-line no-constructor-return + return RecordType; +}; + +Record.prototype.toString = function toString () { + var str = recordName(this) + ' { '; + var keys = this._keys; + var k; + for (var i = 0, l = keys.length; i !== l; i++) { + k = keys[i]; + str += (i ? ', ' : '') + k + ': ' + quoteString(this.get(k)); + } + return str + ' }'; +}; + +Record.prototype.equals = function equals (other) { + return ( + this === other || + (isRecord(other) && recordSeq(this).equals(recordSeq(other))) + ); +}; + +Record.prototype.hashCode = function hashCode () { + return recordSeq(this).hashCode(); +}; + +// @pragma Access + +Record.prototype.has = function has (k) { + return this._indices.hasOwnProperty(k); +}; + +Record.prototype.get = function get (k, notSetValue) { + if (!this.has(k)) { + return notSetValue; + } + var index = this._indices[k]; + var value = this._values.get(index); + return value === undefined ? this._defaultValues[k] : value; +}; + +// @pragma Modification + +Record.prototype.set = function set (k, v) { + if (this.has(k)) { + var newValues = this._values.set( + this._indices[k], + v === this._defaultValues[k] ? undefined : v + ); + if (newValues !== this._values && !this.__ownerID) { + return makeRecord(this, newValues); + } + } + return this; +}; + +Record.prototype.remove = function remove (k) { + return this.set(k); +}; + +Record.prototype.clear = function clear () { + var newValues = this._values.clear().setSize(this._keys.length); + + return this.__ownerID ? this : makeRecord(this, newValues); +}; + +Record.prototype.wasAltered = function wasAltered () { + return this._values.wasAltered(); +}; + +Record.prototype.toSeq = function toSeq () { + return recordSeq(this); +}; + +Record.prototype.toJS = function toJS$1 () { + return toJS(this); +}; + +Record.prototype.entries = function entries () { + return this.__iterator(ITERATE_ENTRIES); +}; + +Record.prototype.__iterator = function __iterator (type, reverse) { + return recordSeq(this).__iterator(type, reverse); +}; + +Record.prototype.__iterate = function __iterate (fn, reverse) { + return recordSeq(this).__iterate(fn, reverse); +}; + +Record.prototype.__ensureOwner = function __ensureOwner (ownerID) { + if (ownerID === this.__ownerID) { + return this; + } + var newValues = this._values.__ensureOwner(ownerID); + if (!ownerID) { + this.__ownerID = ownerID; + this._values = newValues; + return this; + } + return makeRecord(this, newValues, ownerID); +}; + +Record.isRecord = isRecord; +Record.getDescriptiveName = recordName; +var RecordPrototype = Record.prototype; +RecordPrototype[IS_RECORD_SYMBOL] = true; +RecordPrototype[DELETE] = RecordPrototype.remove; +RecordPrototype.deleteIn = RecordPrototype.removeIn = deleteIn; +RecordPrototype.getIn = getIn; +RecordPrototype.hasIn = CollectionPrototype.hasIn; +RecordPrototype.merge = merge$1; +RecordPrototype.mergeWith = mergeWith$1; +RecordPrototype.mergeIn = mergeIn; +RecordPrototype.mergeDeep = mergeDeep; +RecordPrototype.mergeDeepWith = mergeDeepWith; +RecordPrototype.mergeDeepIn = mergeDeepIn; +RecordPrototype.setIn = setIn; +RecordPrototype.update = update; +RecordPrototype.updateIn = updateIn; +RecordPrototype.withMutations = withMutations; +RecordPrototype.asMutable = asMutable; +RecordPrototype.asImmutable = asImmutable; +RecordPrototype[ITERATOR_SYMBOL] = RecordPrototype.entries; +RecordPrototype.toJSON = RecordPrototype.toObject = + CollectionPrototype.toObject; +RecordPrototype.inspect = RecordPrototype.toSource = function () { + return this.toString(); +}; + +function makeRecord(likeRecord, values, ownerID) { + var record = Object.create(Object.getPrototypeOf(likeRecord)); + record._values = values; + record.__ownerID = ownerID; + return record; +} + +function recordName(record) { + return record.constructor.displayName || record.constructor.name || 'Record'; +} + +function recordSeq(record) { + return keyedSeqFromValue(record._keys.map(function (k) { return [k, record.get(k)]; })); +} + +function setProp(prototype, name) { + try { + Object.defineProperty(prototype, name, { + get: function () { + return this.get(name); + }, + set: function (value) { + invariant(this.__ownerID, 'Cannot set on an immutable record.'); + this.set(name, value); + }, + }); + } catch (error) { + // Object.defineProperty failed. Probably IE8. + } +} + +/** + * Returns a lazy Seq of `value` repeated `times` times. When `times` is + * undefined, returns an infinite sequence of `value`. + */ +var Repeat = /*@__PURE__*/(function (IndexedSeq) { + function Repeat(value, times) { + if (!(this instanceof Repeat)) { + // eslint-disable-next-line no-constructor-return + return new Repeat(value, times); + } + this._value = value; + this.size = times === undefined ? Infinity : Math.max(0, times); + if (this.size === 0) { + if (EMPTY_REPEAT) { + // eslint-disable-next-line no-constructor-return + return EMPTY_REPEAT; + } + // eslint-disable-next-line @typescript-eslint/no-this-alias + EMPTY_REPEAT = this; + } + } + + if ( IndexedSeq ) Repeat.__proto__ = IndexedSeq; + Repeat.prototype = Object.create( IndexedSeq && IndexedSeq.prototype ); + Repeat.prototype.constructor = Repeat; + + Repeat.prototype.toString = function toString () { + if (this.size === 0) { + return 'Repeat []'; + } + return 'Repeat [ ' + this._value + ' ' + this.size + ' times ]'; + }; + + Repeat.prototype.get = function get (index, notSetValue) { + return this.has(index) ? this._value : notSetValue; + }; + + Repeat.prototype.includes = function includes (searchValue) { + return is(this._value, searchValue); + }; + + Repeat.prototype.slice = function slice (begin, end) { + var size = this.size; + return wholeSlice(begin, end, size) + ? this + : new Repeat( + this._value, + resolveEnd(end, size) - resolveBegin(begin, size) + ); + }; + + Repeat.prototype.reverse = function reverse () { + return this; + }; + + Repeat.prototype.indexOf = function indexOf (searchValue) { + if (is(this._value, searchValue)) { + return 0; + } + return -1; + }; + + Repeat.prototype.lastIndexOf = function lastIndexOf (searchValue) { + if (is(this._value, searchValue)) { + return this.size; + } + return -1; + }; + + Repeat.prototype.__iterate = function __iterate (fn, reverse) { + var size = this.size; + var i = 0; + while (i !== size) { + if (fn(this._value, reverse ? size - ++i : i++, this) === false) { + break; + } + } + return i; + }; + + Repeat.prototype.__iterator = function __iterator (type, reverse) { + var this$1$1 = this; + + var size = this.size; + var i = 0; + return new Iterator(function () { return i === size + ? iteratorDone() + : iteratorValue(type, reverse ? size - ++i : i++, this$1$1._value); } + ); + }; + + Repeat.prototype.equals = function equals (other) { + return other instanceof Repeat + ? is(this._value, other._value) + : deepEqual(this, other); + }; + + return Repeat; +}(IndexedSeq)); + +var EMPTY_REPEAT; + +function fromJS(value, converter) { + return fromJSWith( + [], + converter || defaultConverter, + value, + '', + converter && converter.length > 2 ? [] : undefined, + { '': value } + ); +} + +function fromJSWith(stack, converter, value, key, keyPath, parentValue) { + if ( + typeof value !== 'string' && + !isImmutable(value) && + (isArrayLike(value) || hasIterator(value) || isPlainObject(value)) + ) { + if (~stack.indexOf(value)) { + throw new TypeError('Cannot convert circular structure to Immutable'); + } + stack.push(value); + keyPath && key !== '' && keyPath.push(key); + var converted = converter.call( + parentValue, + key, + Seq(value).map(function (v, k) { return fromJSWith(stack, converter, v, k, keyPath, value); } + ), + keyPath && keyPath.slice() + ); + stack.pop(); + keyPath && keyPath.pop(); + return converted; + } + return value; +} + +function defaultConverter(k, v) { + // Effectively the opposite of "Collection.toSeq()" + return isIndexed(v) ? v.toList() : isKeyed(v) ? v.toMap() : v.toSet(); +} + +var version = "5.0.2"; + +// Note: Iterable is deprecated +var Iterable = Collection; + +export { Collection, Iterable, List, Map, OrderedMap, OrderedSet, PairSorting, Range, Record, Repeat, Seq, Set, Stack, fromJS, get, getIn$1 as getIn, has, hasIn$1 as hasIn, hash, is, isAssociative, isCollection, isImmutable, isIndexed, isKeyed, isList, isMap, isOrdered, isOrderedMap, isOrderedSet, isPlainObject, isRecord, isSeq, isSet, isStack, isValueObject, merge, mergeDeep$1 as mergeDeep, mergeDeepWith$1 as mergeDeepWith, mergeWith, remove, removeIn, set, setIn$1 as setIn, update$1 as update, updateIn$1 as updateIn, version }; diff --git a/dist/immutable.js b/dist/immutable.js index b5c27224ff..424c32ab67 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -5928,7 +5928,7 @@ return isIndexed(v) ? v.toList() : isKeyed(v) ? v.toMap() : v.toSet(); } - var version = "5.0.0"; + var version = "5.0.2"; // Note: Iterable is deprecated var Iterable = Collection; diff --git a/dist/immutable.min.js b/dist/immutable.min.js index 95932dea7f..00399846c4 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -22,4 +22,4 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).Immutable={})}(this,(function(t){"use strict";var e="delete",r=5,n=1<>>0;if(""+r!==e||4294967295===r)return NaN;e=r}return e<0?a(t)+e:e}function f(){return!0}function h(t,e,r){return(0===t&&!v(t)||void 0!==r&&t<=-r)&&(void 0===e||void 0!==r&&e>=r)}function p(t,e){return l(t,e,0)}function _(t,e){return l(t,e,e)}function l(t,e,r){return void 0===t?r:v(t)?e===1/0?e:0|Math.max(0,e+t):void 0===e||e===t?t:0|Math.min(e,t)}function v(t){return t<0||0===t&&1/t==-1/0}var y="@@__IMMUTABLE_ITERABLE__@@";function d(t){return Boolean(t&&t[y])}var g="@@__IMMUTABLE_KEYED__@@";function w(t){return Boolean(t&&t[g])}var m="@@__IMMUTABLE_INDEXED__@@";function z(t){return Boolean(t&&t[m])}function S(t){return w(t)||z(t)}var b=function(t){return d(t)?t:X(t)},I=function(t){function e(t){return w(t)?t:F(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(b),O=function(t){function e(t){return z(t)?t:G(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(b),E=function(t){function e(t){return d(t)&&!S(t)?t:Z(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(b);b.Keyed=I,b.Indexed=O,b.Set=E;var q="@@__IMMUTABLE_SEQ__@@";function j(t){return Boolean(t&&t[q])}var M="@@__IMMUTABLE_RECORD__@@";function D(t){return Boolean(t&&t[M])}function x(t){return d(t)||D(t)}var A="@@__IMMUTABLE_ORDERED__@@";function k(t){return Boolean(t&&t[A])}var R=0,U=1,T=2,B="function"==typeof Symbol&&Symbol.iterator,K="@@iterator",L=B||K,C=function(t){this.next=t};function P(t,e,r,n){var i=0===t?e:1===t?r:[e,r];return n?n.value=i:n={value:i,done:!1},n}function W(){return{value:void 0,done:!0}}function N(t){return!!Array.isArray(t)||!!V(t)}function H(t){return t&&"function"==typeof t.next}function J(t){var e=V(t);return e&&e.call(t)}function V(t){var e=t&&(B&&t[B]||t[K]);if("function"==typeof e)return e}C.prototype.toString=function(){return"[Iterator]"},C.KEYS=R,C.VALUES=U,C.ENTRIES=T,C.prototype.inspect=C.prototype.toSource=function(){return this.toString()},C.prototype[L]=function(){return this};var Y=Object.prototype.hasOwnProperty;function Q(t){return!(!Array.isArray(t)&&"string"!=typeof t)||t&&"object"==typeof t&&Number.isInteger(t.length)&&t.length>=0&&(0===t.length?1===Object.keys(t).length:t.hasOwnProperty(t.length-1))}var X=function(t){function e(t){return null==t?nt():x(t)?t.toSeq():function(t){var e=ut(t);if(e)return(n=V(r=t))&&n===r.entries?e.fromEntrySeq():function(t){var e=V(t);return e&&e===t.keys}(t)?e.toSetSeq():e;var r,n;if("object"==typeof t)return new tt(t);throw new TypeError("Expected Array or collection object of values, or keyed object: "+t)}(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq {","}")},e.prototype.cacheResult=function(){return!this._cache&&this.__iterateUncached&&(this._cache=this.entrySeq().toArray(),this.size=this._cache.length),this},e.prototype.__iterate=function(t,e){var r=this._cache;if(r){for(var n=r.length,i=0;i!==n;){var o=r[e?n-++i:i++];if(!1===t(o[1],o[0],this))break}return i}return this.__iterateUncached(t,e)},e.prototype.__iterator=function(t,e){var r=this._cache;if(r){var n=r.length,i=0;return new C((function(){if(i===n)return{value:void 0,done:!0};var o=r[e?n-++i:i++];return P(t,o[0],o[1])}))}return this.__iteratorUncached(t,e)},e}(b),F=function(t){function e(t){return null==t?nt().toKeyedSeq():d(t)?w(t)?t.toSeq():t.fromEntrySeq():D(t)?t.toSeq():it(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toKeyedSeq=function(){return this},e}(X),G=function(t){function e(t){return null==t?nt():d(t)?w(t)?t.entrySeq():t.toIndexedSeq():D(t)?t.toSeq().entrySeq():ot(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return e(arguments)},e.prototype.toIndexedSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq [","]")},e}(X),Z=function(t){function e(t){return(d(t)&&!S(t)?t:G(t)).toSetSeq()}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return e(arguments)},e.prototype.toSetSeq=function(){return this},e}(X);X.isSeq=j,X.Keyed=F,X.Set=Z,X.Indexed=G,X.prototype[q]=!0;var $=function(t){function e(t){this._array=t,this.size=t.length}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t,e){return this.has(t)?this._array[c(this,t)]:e},e.prototype.__iterate=function(t,e){for(var r=this._array,n=r.length,i=0;i!==n;){var o=e?n-++i:i++;if(!1===t(r[o],o,this))break}return i},e.prototype.__iterator=function(t,e){var r=this._array,n=r.length,i=0;return new C((function(){if(i===n)return{value:void 0,done:!0};var o=e?n-++i:i++;return P(t,o,r[o])}))},e}(G),tt=function(t){function e(t){var e=Object.keys(t).concat(Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(t):[]);this._object=t,this._keys=e,this.size=e.length}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t,e){return void 0===e||this.has(t)?this._object[t]:e},e.prototype.has=function(t){return Y.call(this._object,t)},e.prototype.__iterate=function(t,e){for(var r=this._object,n=this._keys,i=n.length,o=0;o!==i;){var u=n[e?i-++o:o++];if(!1===t(r[u],u,this))break}return o},e.prototype.__iterator=function(t,e){var r=this._object,n=this._keys,i=n.length,o=0;return new C((function(){if(o===i)return{value:void 0,done:!0};var u=n[e?i-++o:o++];return P(t,u,r[u])}))},e}(F);tt.prototype[A]=!0;var et,rt=function(t){function e(t){this._collection=t,this.size=t.length||t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.__iterateUncached=function(t,e){if(e)return this.cacheResult().__iterate(t,e);var r=J(this._collection),n=0;if(H(r))for(var i;!(i=r.next()).done&&!1!==t(i.value,n++,this););return n},e.prototype.__iteratorUncached=function(t,e){if(e)return this.cacheResult().__iterator(t,e);var r=J(this._collection);if(!H(r))return new C(W);var n=0;return new C((function(){var e=r.next();return e.done?e:P(t,n++,e.value)}))},e}(G);function nt(){return et||(et=new $([]))}function it(t){var e=ut(t);if(e)return e.fromEntrySeq();if("object"==typeof t)return new tt(t);throw new TypeError("Expected Array or collection object of [k, v] entries, or keyed object: "+t)}function ot(t){var e=ut(t);if(e)return e;throw new TypeError("Expected Array or collection object of values: "+t)}function ut(t){return Q(t)?new $(t):N(t)?new rt(t):void 0}var st="@@__IMMUTABLE_MAP__@@";function at(t){return Boolean(t&&t[st])}function ct(t){return at(t)&&k(t)}function ft(t){return Boolean(t&&"function"==typeof t.equals&&"function"==typeof t.hashCode)}function ht(t,e){if(t===e||t!=t&&e!=e)return!0;if(!t||!e)return!1;if("function"==typeof t.valueOf&&"function"==typeof e.valueOf){if((t=t.valueOf())===(e=e.valueOf())||t!=t&&e!=e)return!0;if(!t||!e)return!1}return!!(ft(t)&&ft(e)&&t.equals(e))}var pt="function"==typeof Math.imul&&-2===Math.imul(4294967295,2)?Math.imul:function(t,e){var r=65535&(t|=0),n=65535&(e|=0);return r*n+((t>>>16)*n+r*(e>>>16)<<16>>>0)|0};function _t(t){return t>>>1&1073741824|3221225471&t}var lt=Object.prototype.valueOf;function vt(t){if(null==t)return yt(t);if("function"==typeof t.hashCode)return _t(t.hashCode(t));var e,r=(e=t).valueOf!==lt&&"function"==typeof e.valueOf?e.valueOf(e):e;if(null==r)return yt(r);switch(typeof r){case"boolean":return r?1108378657:1108378656;case"number":return function(t){if(t!=t||t===1/0)return 0;var e=0|t;e!==t&&(e^=4294967295*t);for(;t>4294967295;)e^=t/=4294967295;return _t(e)}(r);case"string":return r.length>Et?function(t){var e=Mt[t];void 0===e&&(e=dt(t),jt===qt&&(jt=0,Mt={}),jt++,Mt[t]=e);return e}(r):dt(r);case"object":case"function":return function(t){var e;if(St&&void 0!==(e=zt.get(t)))return e;if(e=t[Ot],void 0!==e)return e;if(!wt){if(void 0!==(e=t.propertyIsEnumerable&&t.propertyIsEnumerable[Ot]))return e;if(void 0!==(e=function(t){if(t&&t.nodeType>0)switch(t.nodeType){case 1:return t.uniqueID;case 9:return t.documentElement&&t.documentElement.uniqueID}}(t)))return e}if(e=mt(),St)zt.set(t,e);else{if(void 0!==gt&&!1===gt(t))throw new Error("Non-extensible objects are not allowed as keys.");if(wt)Object.defineProperty(t,Ot,{enumerable:!1,configurable:!1,writable:!1,value:e});else if(void 0!==t.propertyIsEnumerable&&t.propertyIsEnumerable===t.constructor.prototype.propertyIsEnumerable)t.propertyIsEnumerable=function(){return this.constructor.prototype.propertyIsEnumerable.apply(this,arguments)},t.propertyIsEnumerable[Ot]=e;else{if(void 0===t.nodeType)throw new Error("Unable to set a non-enumerable property on object.");t[Ot]=e}}return e}(r);case"symbol":return function(t){var e=bt[t];if(void 0!==e)return e;return e=mt(),bt[t]=e,e}(r);default:if("function"==typeof r.toString)return dt(r.toString());throw new Error("Value type "+typeof r+" cannot be hashed.")}}function yt(t){return null===t?1108378658:1108378659}function dt(t){for(var e=0,r=0;r=0&&(a.get=function(e,r){return(e=c(this,e))>=0&&eo)return{value:void 0,done:!0};var t=i.next();return n||e===U||t.done?t:P(e,a-1,e===R?void 0:t.value[1],t)}))},a}function Lt(t,e,r,n){var i=Qt(t);return i.__iterateUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterate(i,o);var s=!0,a=0;return t.__iterate((function(t,o,c){if(!s||!(s=e.call(r,t,o,c)))return a++,i(t,n?o:a-1,u)})),a},i.__iteratorUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterator(i,o);var s=t.__iterator(T,o),a=!0,c=0;return new C((function(){var t,o,f;do{if((t=s.next()).done)return n||i===U?t:P(i,c++,i===R?void 0:t.value[1],t);var h=t.value;o=h[0],f=h[1],a&&(a=e.call(r,f,o,u))}while(a);return i===T?t:P(i,o,f,t)}))},i}function Ct(t,e,r){var n=Qt(t);return n.__iterateUncached=function(i,o){if(o)return this.cacheResult().__iterate(i,o);var u=0,s=!1;return function t(a,c){a.__iterate((function(o,a){return(!e||c0}function Ht(t,e,r,n){var i=Qt(t),o=new $(r).map((function(t){return t.size}));return i.size=n?o.max():o.min(),i.__iterate=function(t,e){for(var r,n=this.__iterator(U,e),i=0;!(r=n.next()).done&&!1!==t(r.value,i++,this););return i},i.__iteratorUncached=function(t,i){var o=r.map((function(t){return t=b(t),J(i?t.reverse():t)})),u=0,s=!1;return new C((function(){var r;return s||(r=o.map((function(t){return t.next()})),s=n?r.every((function(t){return t.done})):r.some((function(t){return t.done}))),s?{value:void 0,done:!0}:P(t,u++,e.apply(null,r.map((function(t){return t.value}))))}))},i}function Jt(t,e){return t===e?t:j(t)?e:t.constructor(e)}function Vt(t){if(t!==Object(t))throw new TypeError("Expected [K, V] tuple: "+t)}function Yt(t){return w(t)?I:z(t)?O:E}function Qt(t){return Object.create((w(t)?F:z(t)?G:Z).prototype)}function Xt(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size,this):X.prototype.cacheResult.call(this)}function Ft(t,e){return void 0===t&&void 0===e?0:void 0===t?1:void 0===e?-1:t>e?1:t0;)e[r]=arguments[r+1];if("function"!=typeof t)throw new TypeError("Invalid merger function: "+t);return ze(this,e,t)}function ze(t,e,r){for(var n=[],i=0;i0;)e[r]=arguments[r+1];return Se(this,e,t)}function Ee(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return fe(this,t,He(),(function(t){return be(t,e)}))}function qe(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return fe(this,t,He(),(function(t){return Se(t,e)}))}function je(t){var e=this.asMutable();return t(e),e.wasAltered()?e.__ensureOwner(this.__ownerID):this}function Me(){return this.__ownerID?this:this.__ensureOwner(new s)}function De(){return this.__ensureOwner()}function xe(){return this.__altered}var Ae=function(t){function e(e){return null==e?He():at(e)&&!k(e)?e:He().withMutations((function(r){var n=t(e);$t(n.size),n.forEach((function(t,e){return r.set(e,t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toString=function(){return this.__toString("Map {","}")},e.prototype.get=function(t,e){return this._root?this._root.get(0,void 0,t,e):e},e.prototype.set=function(t,e){return Je(this,t,e)},e.prototype.remove=function(t){return Je(this,t,o)},e.prototype.deleteAll=function(t){var e=b(t);return 0===e.size?this:this.withMutations((function(t){e.forEach((function(e){return t.remove(e)}))}))},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):He()},e.prototype.sort=function(t){return vr(Pt(this,t))},e.prototype.sortBy=function(t,e){return vr(Pt(this,e,t))},e.prototype.map=function(t,e){var r=this;return this.withMutations((function(n){n.forEach((function(i,o){n.set(o,t.call(e,i,o,r))}))}))},e.prototype.__iterator=function(t,e){return new Ce(this,t,e)},e.prototype.__iterate=function(t,e){var r=this,n=0;return this._root&&this._root.iterate((function(e){return n++,t(e[1],e[0],r)}),e),n},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Ne(this.size,this._root,t,this.__hash):0===this.size?He():(this.__ownerID=t,this.__altered=!1,this)},e}(I);Ae.isMap=at;var ke=Ae.prototype;ke[st]=!0,ke[e]=ke.remove,ke.removeAll=ke.deleteAll,ke.setIn=_e,ke.removeIn=ke.deleteIn=ve,ke.update=de,ke.updateIn=ge,ke.merge=ke.concat=we,ke.mergeWith=me,ke.mergeDeep=Ie,ke.mergeDeepWith=Oe,ke.mergeIn=Ee,ke.mergeDeepIn=qe,ke.withMutations=je,ke.wasAltered=xe,ke.asImmutable=De,ke["@@transducer/init"]=ke.asMutable=Me,ke["@@transducer/step"]=function(t,e){return t.set(e[0],e[1])},ke["@@transducer/result"]=function(t){return t.asImmutable()};var Re=function(t,e){this.ownerID=t,this.entries=e};Re.prototype.get=function(t,e,r,n){for(var i=this.entries,o=0,u=i.length;o=Ge)return function(t,e,r,n){t||(t=new s);for(var i=new Ke(t,vt(r),[r,n]),o=0;o>>t)&i),s=this.bitmap;return 0==(s&u)?o:this.nodes[Xe(s&u-1)].get(t+r,e,n,o)},Ue.prototype.update=function(t,e,u,s,a,c,f){void 0===u&&(u=vt(s));var h=(0===e?u:u>>>e)&i,p=1<=Ze)return function(t,e,r,i,o){for(var u=0,s=new Array(n),a=0;0!==r;a++,r>>>=1)s[a]=1&r?e[u++]:void 0;return s[i]=o,new Te(t,u+1,s)}(t,y,_,h,g);if(l&&!g&&2===y.length&&Ye(y[1^v]))return y[1^v];if(l&&g&&1===y.length&&Ye(g))return g;var w=t&&t===this.ownerID,m=l?g?_:_^p:_|p,z=l?g?Fe(y,v,g,w):function(t,e,r){var n=t.length-1;if(r&&e===n)return t.pop(),t;for(var i=new Array(n),o=0,u=0;u>>t)&i,s=this.nodes[u];return s?s.get(t+r,e,n,o):o},Te.prototype.update=function(t,e,n,u,s,a,c){void 0===n&&(n=vt(u));var f=(0===e?n:n>>>e)&i,h=s===o,p=this.nodes,_=p[f];if(h&&!_)return this;var l=Ve(_,t,e+r,n,u,s,a,c);if(l===_)return this;var v=this.count;if(_){if(!l&&--v<$e)return function(t,e,r,n){for(var i=0,o=0,u=new Array(r),s=0,a=1,c=e.length;s>>n)&i,c=(0===n?o:o>>>n)&i,f=a===c?[Qe(t,e,n+r,o,u)]:(s=new Ke(e,o,u),a>1&1431655765))+(t>>2&858993459))+(t>>4)&252645135,t+=t>>8,127&(t+=t>>16)}function Fe(t,e,r,n){var i=n?t:Gt(t);return i[e]=r,i}var Ge=n/4,Ze=n/2,$e=n/4,tr="@@__IMMUTABLE_LIST__@@";function er(t){return Boolean(t&&t[tr])}var rr=function(t){function e(e){var i=ar();if(null==e)return i;if(er(e))return e;var o=t(e),u=o.size;return 0===u?i:($t(u),u>0&&u=0&&t=t.size||e<0)return t.withMutations((function(t){e<0?pr(t,e).set(0,r):pr(t,0,e+1).set(e,r)}));e+=t._origin;var n=t._tail,i=t._root,o={value:!1};e>=_r(t._capacity)?n=cr(n,t.__ownerID,0,e,r,o):i=cr(i,t.__ownerID,t._level,e,r,o);if(!o.value)return t;if(t.__ownerID)return t._root=i,t._tail=n,t.__hash=void 0,t.__altered=!0,t;return sr(t._origin,t._capacity,t._level,i,n)}(this,t,e)},e.prototype.remove=function(t){return this.has(t)?0===t?this.shift():t===this.size-1?this.pop():this.splice(t,1):this},e.prototype.insert=function(t,e){return this.splice(t,0,e)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=this._origin=this._capacity=0,this._level=r,this._root=this._tail=this.__hash=void 0,this.__altered=!0,this):ar()},e.prototype.push=function(){var t=arguments,e=this.size;return this.withMutations((function(r){pr(r,0,e+t.length);for(var n=0;n>>e&i;if(o>=this.array.length)return new ir([],t);var u,s=0===o;if(e>0){var a=this.array[o];if((u=a&&a.removeBefore(t,e-r,n))===a&&s)return this}if(s&&!u)return this;var c=fr(this,t);if(!s)for(var f=0;f>>e&i;if(u>=this.array.length)return this;if(e>0){var s=this.array[u];if((o=s&&s.removeAfter(t,e-r,n))===s&&u===this.array.length-1)return this}var a=fr(this,t);return a.array.splice(u+1),o&&(a.array[u]=o),a};var or={};function ur(t,e){var i=t._origin,o=t._capacity,u=_r(o),s=t._tail;return a(t._root,t._level,0);function a(t,c,f){return 0===c?function(t,r){var a=r===u?s&&s.array:t&&t.array,c=r>i?0:i-r,f=o-r;f>n&&(f=n);return function(){if(c===f)return or;var t=e?--f:c++;return a&&a[t]}}(t,f):function(t,u,s){var c,f=t&&t.array,h=s>i?0:i-s>>u,p=1+(o-s>>u);p>n&&(p=n);return function(){for(;;){if(c){var t=c();if(t!==or)return t;c=null}if(h===p)return or;var n=e?--p:h++;c=a(f&&f[n],u-r,s+(n<>>n&i,h=t&&f0){var p=t&&t.array[f],_=cr(p,e,n-r,o,s,a);return _===p?t:((c=fr(t,e)).array[f]=_,c)}return h&&t.array[f]===s?t:(a&&u(a),c=fr(t,e),void 0===s&&f===c.array.length-1?c.array.pop():c.array[f]=s,c)}function fr(t,e){return e&&t&&e===t.ownerID?t:new ir(t?t.array.slice():[],e)}function hr(t,e){if(e>=_r(t._capacity))return t._tail;if(e<1<0;)n=n.array[e>>>o&i],o-=r;return n}}function pr(t,e,n){void 0!==e&&(e|=0),void 0!==n&&(n|=0);var o=t.__ownerID||new s,u=t._origin,a=t._capacity,c=u+e,f=void 0===n?a:n<0?a+n:u+n;if(c===u&&f===a)return t;if(c>=f)return t.clear();for(var h=t._level,p=t._root,_=0;c+_<0;)p=new ir(p&&p.array.length?[void 0,p]:[],o),_+=1<<(h+=r);_&&(c+=_,u+=_,f+=_,a+=_);for(var l=_r(a),v=_r(f);v>=1<l?new ir([],o):y;if(y&&v>l&&cr;w-=r){var m=l>>>w&i;g=g.array[m]=fr(g.array[m],o)}g.array[l>>>r&i]=y}if(f=v)c-=v,f-=v,h=r,p=null,d=d&&d.removeBefore(o,0,c);else if(c>u||v>>h&i;if(z!==v>>>h&i)break;z&&(_+=(1<u&&(p=p.removeBefore(o,h,c-_)),p&&v>>r<=n&&a.size>=2*s.size?(i=(u=a.filter((function(t,e){return void 0!==t&&c!==e}))).toKeyedSeq().map((function(t){return t[0]})).flip().toMap(),t.__ownerID&&(i.__ownerID=u.__ownerID=t.__ownerID)):(i=s.remove(e),u=c===a.size-1?a.pop():a.set(c,void 0))}else if(f){if(r===a.get(c)[1])return t;i=s,u=a.set(c,[e,r])}else i=s.set(e,a.size),u=a.set(a.size,[e,r]);return t.__ownerID?(t.size=i.size,t._map=i,t._list=u,t.__hash=void 0,t.__altered=!0,t):yr(i,u)}vr.isOrderedMap=ct,vr.prototype[A]=!0,vr.prototype[e]=vr.prototype.remove;var wr="@@__IMMUTABLE_STACK__@@";function mr(t){return Boolean(t&&t[wr])}var zr=function(t){function e(t){return null==t?Or():mr(t)?t:Or().pushAll(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("Stack [","]")},e.prototype.get=function(t,e){var r=this._head;for(t=c(this,t);r&&t--;)r=r.next;return r?r.value:e},e.prototype.peek=function(){return this._head&&this._head.value},e.prototype.push=function(){var t=arguments;if(0===arguments.length)return this;for(var e=this.size+arguments.length,r=this._head,n=arguments.length-1;n>=0;n--)r={value:t[n],next:r};return this.__ownerID?(this.size=e,this._head=r,this.__hash=void 0,this.__altered=!0,this):Ir(e,r)},e.prototype.pushAll=function(e){if(0===(e=t(e)).size)return this;if(0===this.size&&mr(e))return e;$t(e.size);var r=this.size,n=this._head;return e.__iterate((function(t){r++,n={value:t,next:n}}),!0),this.__ownerID?(this.size=r,this._head=n,this.__hash=void 0,this.__altered=!0,this):Ir(r,n)},e.prototype.pop=function(){return this.slice(1)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):Or()},e.prototype.slice=function(e,r){if(h(e,r,this.size))return this;var n=p(e,this.size);if(_(r,this.size)!==this.size)return t.prototype.slice.call(this,e,r);for(var i=this.size-n,o=this._head;n--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):Ir(i,o)},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Ir(this.size,this._head,t,this.__hash):0===this.size?Or():(this.__ownerID=t,this.__altered=!1,this)},e.prototype.__iterate=function(t,e){var r=this;if(e)return new $(this.toArray()).__iterate((function(e,n){return t(e,n,r)}),e);for(var n=0,i=this._head;i&&!1!==t(i.value,n++,this);)i=i.next;return n},e.prototype.__iterator=function(t,e){if(e)return new $(this.toArray()).__iterator(t,e);var r=0,n=this._head;return new C((function(){if(n){var e=n.value;return n=n.next,P(t,r++,e)}return{value:void 0,done:!0}}))},e}(O);zr.isStack=mr;var Sr,br=zr.prototype;function Ir(t,e,r,n){var i=Object.create(br);return i.size=t,i._head=e,i.__ownerID=r,i.__hash=n,i.__altered=!1,i}function Or(){return Sr||(Sr=Ir(0))}br[wr]=!0,br.shift=br.pop,br.unshift=br.push,br.unshiftAll=br.pushAll,br.withMutations=je,br.wasAltered=xe,br.asImmutable=De,br["@@transducer/init"]=br.asMutable=Me,br["@@transducer/step"]=function(t,e){return t.unshift(e)},br["@@transducer/result"]=function(t){return t.asImmutable()};var Er="@@__IMMUTABLE_SET__@@";function qr(t){return Boolean(t&&t[Er])}function jr(t){return qr(t)&&k(t)}function Mr(t,e){if(t===e)return!0;if(!d(e)||void 0!==t.size&&void 0!==e.size&&t.size!==e.size||void 0!==t.__hash&&void 0!==e.__hash&&t.__hash!==e.__hash||w(t)!==w(e)||z(t)!==z(e)||k(t)!==k(e))return!1;if(0===t.size&&0===e.size)return!0;var r=!S(t);if(k(t)){var n=t.entries();return e.every((function(t,e){var i=n.next().value;return i&&ht(i[1],t)&&(r||ht(i[0],e))}))&&n.next().done}var i=!1;if(void 0===t.size)if(void 0===e.size)"function"==typeof t.cacheResult&&t.cacheResult();else{i=!0;var u=t;t=e,e=u}var s=!0,a=e.__iterate((function(e,n){if(r?!t.has(e):i?!ht(e,t.get(n,o)):!ht(t.get(n,o),e))return s=!1,!1}));return s&&t.size===a}function Dr(t,e){var r=function(r){t.prototype[r]=e[r]};return Object.keys(e).forEach(r),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(e).forEach(r),t}function xr(t){if(!t||"object"!=typeof t)return t;if(!d(t)){if(!ne(t))return t;t=X(t)}if(w(t)){var e={};return t.__iterate((function(t,r){e[r]=xr(t)})),e}var r=[];return t.__iterate((function(t){r.push(xr(t))})),r}var Ar=function(t){function e(e){return null==e?Br():qr(e)&&!k(e)?e:Br().withMutations((function(r){var n=t(e);$t(n.size),n.forEach((function(t){return r.add(t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(I(t).keySeq())},e.intersect=function(t){return(t=b(t).toArray()).length?Rr.intersect.apply(e(t.pop()),t):Br()},e.union=function(t){return(t=b(t).toArray()).length?Rr.union.apply(e(t.pop()),t):Br()},e.prototype.toString=function(){return this.__toString("Set {","}")},e.prototype.has=function(t){return this._map.has(t)},e.prototype.add=function(t){return Ur(this,this._map.set(t,t))},e.prototype.remove=function(t){return Ur(this,this._map.remove(t))},e.prototype.clear=function(){return Ur(this,this._map.clear())},e.prototype.map=function(t,e){var r=this,n=!1,i=Ur(this,this._map.mapEntries((function(i){var o=i[1],u=t.call(e,o,o,r);return u!==o&&(n=!0),[u,u]}),e));return n?i:this},e.prototype.union=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return 0===(e=e.filter((function(t){return 0!==t.size}))).length?this:0!==this.size||this.__ownerID||1!==e.length?this.withMutations((function(r){for(var n=0;n=0&&e=0&&r>>-15,461845907),e=pt(e<<13|e>>>-13,5),e=pt((e=(e+3864292196|0)^t)^e>>>16,2246822507),e=_t((e=pt(e^e>>>13,3266489909))^e>>>16)}(t.size,n)}(this))}});var Hr=b.prototype;Hr[y]=!0,Hr[L]=Hr.values,Hr.toJSON=Hr.toArray,Hr.__toStringMapper=ie,Hr.inspect=Hr.toSource=function(){return this.toString()},Hr.chain=Hr.flatMap,Hr.contains=Hr.includes,Dr(I,{flip:function(){return Jt(this,Rt(this))},mapEntries:function(t,e){var r=this,n=0;return Jt(this,this.toSeq().map((function(i,o){return t.call(e,[o,i],n++,r)})).fromEntrySeq())},mapKeys:function(t,e){var r=this;return Jt(this,this.toSeq().flip().map((function(n,i){return t.call(e,n,i,r)})).flip())}});var Jr=I.prototype;Jr[g]=!0,Jr[L]=Hr.entries,Jr.toJSON=Nr,Jr.__toStringMapper=function(t,e){return ie(e)+": "+ie(t)},Dr(O,{toKeyedSeq:function(){return new Dt(this,!1)},filter:function(t,e){return Jt(this,Bt(this,t,e,!1))},findIndex:function(t,e){var r=this.findEntry(t,e);return r?r[0]:-1},indexOf:function(t){var e=this.keyOf(t);return void 0===e?-1:e},lastIndexOf:function(t){var e=this.lastKeyOf(t);return void 0===e?-1:e},reverse:function(){return Jt(this,Tt(this,!1))},slice:function(t,e){return Jt(this,Kt(this,t,e,!1))},splice:function(t,e){var r=arguments.length;if(e=Math.max(e||0,0),0===r||2===r&&!e)return this;t=p(t,t<0?this.count():this.size);var n=this.slice(0,t);return Jt(this,1===r?n:n.concat(Gt(arguments,2),this.slice(t+e)))},findLastIndex:function(t,e){var r=this.findLastEntry(t,e);return r?r[0]:-1},first:function(t){return this.get(0,t)},flatten:function(t){return Jt(this,Ct(this,t,!1))},get:function(t,e){return(t=c(this,t))<0||this.size===1/0||void 0!==this.size&&t>this.size?e:this.find((function(e,r){return r===t}),void 0,e)},has:function(t){return(t=c(this,t))>=0&&(void 0!==this.size?this.size===1/0||te?-1:0}function en(t,e){return t^e+2654435769+(t<<6)+(t>>2)|0}Yr.has=Hr.includes,Yr.contains=Yr.includes,Yr.keys=Yr.values,Dr(F,Jr),Dr(G,Vr),Dr(Z,Yr);var rn=function(t){function e(t){return null==t?sn():jr(t)?t:sn().withMutations((function(e){var r=E(t);$t(r.size),r.forEach((function(t){return e.add(t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(I(t).keySeq())},e.prototype.toString=function(){return this.__toString("OrderedSet {","}")},e}(Ar);rn.isOrderedSet=jr;var nn,on=rn.prototype;function un(t,e){var r=Object.create(on);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function sn(){return nn||(nn=un(dr()))}on[A]=!0,on.zip=Vr.zip,on.zipWith=Vr.zipWith,on.zipAll=Vr.zipAll,on.__empty=sn,on.__make=un;var an=function(t,e){var r;!function(t){if(D(t))throw new Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(x(t))throw new Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(null===t||"object"!=typeof t)throw new Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}(t);var n=function(o){var u=this;if(o instanceof n)return o;if(!(this instanceof n))return new n(o);if(!r){r=!0;var s=Object.keys(t),a=i._indices={};i._name=e,i._keys=s,i._defaultValues=t;for(var c=0;c2?[]:void 0,{"":t})},t.get=ue,t.getIn=Cr,t.has=oe,t.hasIn=Wr,t.hash=vt,t.is=ht,t.isAssociative=S,t.isCollection=d,t.isImmutable=x,t.isIndexed=z,t.isKeyed=w,t.isList=er,t.isMap=at,t.isOrdered=k,t.isOrderedMap=ct,t.isOrderedSet=jr,t.isPlainObject=re,t.isRecord=D,t.isSeq=j,t.isSet=qr,t.isStack=mr,t.isValueObject=ft,t.merge=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return be(t,e)},t.mergeDeep=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Se(t,e)},t.mergeDeepWith=function(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];return Se(e,r,t)},t.mergeWith=function(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];return be(e,r,t)},t.remove=ae,t.removeIn=le,t.set=ce,t.setIn=pe,t.update=ye,t.updateIn=fe,t.version="5.0.0"})); +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).Immutable={})}(this,(function(t){"use strict";var e="delete",r=5,n=1<>>0;if(""+r!==e||4294967295===r)return NaN;e=r}return e<0?a(t)+e:e}function f(){return!0}function h(t,e,r){return(0===t&&!v(t)||void 0!==r&&t<=-r)&&(void 0===e||void 0!==r&&e>=r)}function p(t,e){return l(t,e,0)}function _(t,e){return l(t,e,e)}function l(t,e,r){return void 0===t?r:v(t)?e===1/0?e:0|Math.max(0,e+t):void 0===e||e===t?t:0|Math.min(e,t)}function v(t){return t<0||0===t&&1/t==-1/0}var y="@@__IMMUTABLE_ITERABLE__@@";function d(t){return Boolean(t&&t[y])}var g="@@__IMMUTABLE_KEYED__@@";function w(t){return Boolean(t&&t[g])}var m="@@__IMMUTABLE_INDEXED__@@";function z(t){return Boolean(t&&t[m])}function S(t){return w(t)||z(t)}var b=function(t){return d(t)?t:X(t)},I=function(t){function e(t){return w(t)?t:F(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(b),O=function(t){function e(t){return z(t)?t:G(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(b),E=function(t){function e(t){return d(t)&&!S(t)?t:Z(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(b);b.Keyed=I,b.Indexed=O,b.Set=E;var q="@@__IMMUTABLE_SEQ__@@";function j(t){return Boolean(t&&t[q])}var M="@@__IMMUTABLE_RECORD__@@";function D(t){return Boolean(t&&t[M])}function x(t){return d(t)||D(t)}var A="@@__IMMUTABLE_ORDERED__@@";function k(t){return Boolean(t&&t[A])}var R=0,U=1,T=2,B="function"==typeof Symbol&&Symbol.iterator,K="@@iterator",L=B||K,C=function(t){this.next=t};function P(t,e,r,n){var i=0===t?e:1===t?r:[e,r];return n?n.value=i:n={value:i,done:!1},n}function W(){return{value:void 0,done:!0}}function N(t){return!!Array.isArray(t)||!!V(t)}function H(t){return t&&"function"==typeof t.next}function J(t){var e=V(t);return e&&e.call(t)}function V(t){var e=t&&(B&&t[B]||t[K]);if("function"==typeof e)return e}C.prototype.toString=function(){return"[Iterator]"},C.KEYS=R,C.VALUES=U,C.ENTRIES=T,C.prototype.inspect=C.prototype.toSource=function(){return this.toString()},C.prototype[L]=function(){return this};var Y=Object.prototype.hasOwnProperty;function Q(t){return!(!Array.isArray(t)&&"string"!=typeof t)||t&&"object"==typeof t&&Number.isInteger(t.length)&&t.length>=0&&(0===t.length?1===Object.keys(t).length:t.hasOwnProperty(t.length-1))}var X=function(t){function e(t){return null==t?nt():x(t)?t.toSeq():function(t){var e=ut(t);if(e)return(n=V(r=t))&&n===r.entries?e.fromEntrySeq():function(t){var e=V(t);return e&&e===t.keys}(t)?e.toSetSeq():e;var r,n;if("object"==typeof t)return new tt(t);throw new TypeError("Expected Array or collection object of values, or keyed object: "+t)}(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq {","}")},e.prototype.cacheResult=function(){return!this._cache&&this.__iterateUncached&&(this._cache=this.entrySeq().toArray(),this.size=this._cache.length),this},e.prototype.__iterate=function(t,e){var r=this._cache;if(r){for(var n=r.length,i=0;i!==n;){var o=r[e?n-++i:i++];if(!1===t(o[1],o[0],this))break}return i}return this.__iterateUncached(t,e)},e.prototype.__iterator=function(t,e){var r=this._cache;if(r){var n=r.length,i=0;return new C((function(){if(i===n)return{value:void 0,done:!0};var o=r[e?n-++i:i++];return P(t,o[0],o[1])}))}return this.__iteratorUncached(t,e)},e}(b),F=function(t){function e(t){return null==t?nt().toKeyedSeq():d(t)?w(t)?t.toSeq():t.fromEntrySeq():D(t)?t.toSeq():it(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toKeyedSeq=function(){return this},e}(X),G=function(t){function e(t){return null==t?nt():d(t)?w(t)?t.entrySeq():t.toIndexedSeq():D(t)?t.toSeq().entrySeq():ot(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return e(arguments)},e.prototype.toIndexedSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq [","]")},e}(X),Z=function(t){function e(t){return(d(t)&&!S(t)?t:G(t)).toSetSeq()}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return e(arguments)},e.prototype.toSetSeq=function(){return this},e}(X);X.isSeq=j,X.Keyed=F,X.Set=Z,X.Indexed=G,X.prototype[q]=!0;var $=function(t){function e(t){this._array=t,this.size=t.length}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t,e){return this.has(t)?this._array[c(this,t)]:e},e.prototype.__iterate=function(t,e){for(var r=this._array,n=r.length,i=0;i!==n;){var o=e?n-++i:i++;if(!1===t(r[o],o,this))break}return i},e.prototype.__iterator=function(t,e){var r=this._array,n=r.length,i=0;return new C((function(){if(i===n)return{value:void 0,done:!0};var o=e?n-++i:i++;return P(t,o,r[o])}))},e}(G),tt=function(t){function e(t){var e=Object.keys(t).concat(Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(t):[]);this._object=t,this._keys=e,this.size=e.length}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t,e){return void 0===e||this.has(t)?this._object[t]:e},e.prototype.has=function(t){return Y.call(this._object,t)},e.prototype.__iterate=function(t,e){for(var r=this._object,n=this._keys,i=n.length,o=0;o!==i;){var u=n[e?i-++o:o++];if(!1===t(r[u],u,this))break}return o},e.prototype.__iterator=function(t,e){var r=this._object,n=this._keys,i=n.length,o=0;return new C((function(){if(o===i)return{value:void 0,done:!0};var u=n[e?i-++o:o++];return P(t,u,r[u])}))},e}(F);tt.prototype[A]=!0;var et,rt=function(t){function e(t){this._collection=t,this.size=t.length||t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.__iterateUncached=function(t,e){if(e)return this.cacheResult().__iterate(t,e);var r=J(this._collection),n=0;if(H(r))for(var i;!(i=r.next()).done&&!1!==t(i.value,n++,this););return n},e.prototype.__iteratorUncached=function(t,e){if(e)return this.cacheResult().__iterator(t,e);var r=J(this._collection);if(!H(r))return new C(W);var n=0;return new C((function(){var e=r.next();return e.done?e:P(t,n++,e.value)}))},e}(G);function nt(){return et||(et=new $([]))}function it(t){var e=ut(t);if(e)return e.fromEntrySeq();if("object"==typeof t)return new tt(t);throw new TypeError("Expected Array or collection object of [k, v] entries, or keyed object: "+t)}function ot(t){var e=ut(t);if(e)return e;throw new TypeError("Expected Array or collection object of values: "+t)}function ut(t){return Q(t)?new $(t):N(t)?new rt(t):void 0}var st="@@__IMMUTABLE_MAP__@@";function at(t){return Boolean(t&&t[st])}function ct(t){return at(t)&&k(t)}function ft(t){return Boolean(t&&"function"==typeof t.equals&&"function"==typeof t.hashCode)}function ht(t,e){if(t===e||t!=t&&e!=e)return!0;if(!t||!e)return!1;if("function"==typeof t.valueOf&&"function"==typeof e.valueOf){if((t=t.valueOf())===(e=e.valueOf())||t!=t&&e!=e)return!0;if(!t||!e)return!1}return!!(ft(t)&&ft(e)&&t.equals(e))}var pt="function"==typeof Math.imul&&-2===Math.imul(4294967295,2)?Math.imul:function(t,e){var r=65535&(t|=0),n=65535&(e|=0);return r*n+((t>>>16)*n+r*(e>>>16)<<16>>>0)|0};function _t(t){return t>>>1&1073741824|3221225471&t}var lt=Object.prototype.valueOf;function vt(t){if(null==t)return yt(t);if("function"==typeof t.hashCode)return _t(t.hashCode(t));var e,r=(e=t).valueOf!==lt&&"function"==typeof e.valueOf?e.valueOf(e):e;if(null==r)return yt(r);switch(typeof r){case"boolean":return r?1108378657:1108378656;case"number":return function(t){if(t!=t||t===1/0)return 0;var e=0|t;e!==t&&(e^=4294967295*t);for(;t>4294967295;)e^=t/=4294967295;return _t(e)}(r);case"string":return r.length>Et?function(t){var e=Mt[t];void 0===e&&(e=dt(t),jt===qt&&(jt=0,Mt={}),jt++,Mt[t]=e);return e}(r):dt(r);case"object":case"function":return function(t){var e;if(St&&void 0!==(e=zt.get(t)))return e;if(e=t[Ot],void 0!==e)return e;if(!wt){if(void 0!==(e=t.propertyIsEnumerable&&t.propertyIsEnumerable[Ot]))return e;if(void 0!==(e=function(t){if(t&&t.nodeType>0)switch(t.nodeType){case 1:return t.uniqueID;case 9:return t.documentElement&&t.documentElement.uniqueID}}(t)))return e}if(e=mt(),St)zt.set(t,e);else{if(void 0!==gt&&!1===gt(t))throw new Error("Non-extensible objects are not allowed as keys.");if(wt)Object.defineProperty(t,Ot,{enumerable:!1,configurable:!1,writable:!1,value:e});else if(void 0!==t.propertyIsEnumerable&&t.propertyIsEnumerable===t.constructor.prototype.propertyIsEnumerable)t.propertyIsEnumerable=function(){return this.constructor.prototype.propertyIsEnumerable.apply(this,arguments)},t.propertyIsEnumerable[Ot]=e;else{if(void 0===t.nodeType)throw new Error("Unable to set a non-enumerable property on object.");t[Ot]=e}}return e}(r);case"symbol":return function(t){var e=bt[t];if(void 0!==e)return e;return e=mt(),bt[t]=e,e}(r);default:if("function"==typeof r.toString)return dt(r.toString());throw new Error("Value type "+typeof r+" cannot be hashed.")}}function yt(t){return null===t?1108378658:1108378659}function dt(t){for(var e=0,r=0;r=0&&(a.get=function(e,r){return(e=c(this,e))>=0&&eo)return{value:void 0,done:!0};var t=i.next();return n||e===U||t.done?t:P(e,a-1,e===R?void 0:t.value[1],t)}))},a}function Lt(t,e,r,n){var i=Qt(t);return i.__iterateUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterate(i,o);var s=!0,a=0;return t.__iterate((function(t,o,c){if(!s||!(s=e.call(r,t,o,c)))return a++,i(t,n?o:a-1,u)})),a},i.__iteratorUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterator(i,o);var s=t.__iterator(T,o),a=!0,c=0;return new C((function(){var t,o,f;do{if((t=s.next()).done)return n||i===U?t:P(i,c++,i===R?void 0:t.value[1],t);var h=t.value;o=h[0],f=h[1],a&&(a=e.call(r,f,o,u))}while(a);return i===T?t:P(i,o,f,t)}))},i}function Ct(t,e,r){var n=Qt(t);return n.__iterateUncached=function(i,o){if(o)return this.cacheResult().__iterate(i,o);var u=0,s=!1;return function t(a,c){a.__iterate((function(o,a){return(!e||c0}function Ht(t,e,r,n){var i=Qt(t),o=new $(r).map((function(t){return t.size}));return i.size=n?o.max():o.min(),i.__iterate=function(t,e){for(var r,n=this.__iterator(U,e),i=0;!(r=n.next()).done&&!1!==t(r.value,i++,this););return i},i.__iteratorUncached=function(t,i){var o=r.map((function(t){return t=b(t),J(i?t.reverse():t)})),u=0,s=!1;return new C((function(){var r;return s||(r=o.map((function(t){return t.next()})),s=n?r.every((function(t){return t.done})):r.some((function(t){return t.done}))),s?{value:void 0,done:!0}:P(t,u++,e.apply(null,r.map((function(t){return t.value}))))}))},i}function Jt(t,e){return t===e?t:j(t)?e:t.constructor(e)}function Vt(t){if(t!==Object(t))throw new TypeError("Expected [K, V] tuple: "+t)}function Yt(t){return w(t)?I:z(t)?O:E}function Qt(t){return Object.create((w(t)?F:z(t)?G:Z).prototype)}function Xt(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size,this):X.prototype.cacheResult.call(this)}function Ft(t,e){return void 0===t&&void 0===e?0:void 0===t?1:void 0===e?-1:t>e?1:t0;)e[r]=arguments[r+1];if("function"!=typeof t)throw new TypeError("Invalid merger function: "+t);return ze(this,e,t)}function ze(t,e,r){for(var n=[],i=0;i0;)e[r]=arguments[r+1];return Se(this,e,t)}function Ee(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return fe(this,t,He(),(function(t){return be(t,e)}))}function qe(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return fe(this,t,He(),(function(t){return Se(t,e)}))}function je(t){var e=this.asMutable();return t(e),e.wasAltered()?e.__ensureOwner(this.__ownerID):this}function Me(){return this.__ownerID?this:this.__ensureOwner(new s)}function De(){return this.__ensureOwner()}function xe(){return this.__altered}var Ae=function(t){function e(e){return null==e?He():at(e)&&!k(e)?e:He().withMutations((function(r){var n=t(e);$t(n.size),n.forEach((function(t,e){return r.set(e,t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toString=function(){return this.__toString("Map {","}")},e.prototype.get=function(t,e){return this._root?this._root.get(0,void 0,t,e):e},e.prototype.set=function(t,e){return Je(this,t,e)},e.prototype.remove=function(t){return Je(this,t,o)},e.prototype.deleteAll=function(t){var e=b(t);return 0===e.size?this:this.withMutations((function(t){e.forEach((function(e){return t.remove(e)}))}))},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):He()},e.prototype.sort=function(t){return vr(Pt(this,t))},e.prototype.sortBy=function(t,e){return vr(Pt(this,e,t))},e.prototype.map=function(t,e){var r=this;return this.withMutations((function(n){n.forEach((function(i,o){n.set(o,t.call(e,i,o,r))}))}))},e.prototype.__iterator=function(t,e){return new Ce(this,t,e)},e.prototype.__iterate=function(t,e){var r=this,n=0;return this._root&&this._root.iterate((function(e){return n++,t(e[1],e[0],r)}),e),n},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Ne(this.size,this._root,t,this.__hash):0===this.size?He():(this.__ownerID=t,this.__altered=!1,this)},e}(I);Ae.isMap=at;var ke=Ae.prototype;ke[st]=!0,ke[e]=ke.remove,ke.removeAll=ke.deleteAll,ke.setIn=_e,ke.removeIn=ke.deleteIn=ve,ke.update=de,ke.updateIn=ge,ke.merge=ke.concat=we,ke.mergeWith=me,ke.mergeDeep=Ie,ke.mergeDeepWith=Oe,ke.mergeIn=Ee,ke.mergeDeepIn=qe,ke.withMutations=je,ke.wasAltered=xe,ke.asImmutable=De,ke["@@transducer/init"]=ke.asMutable=Me,ke["@@transducer/step"]=function(t,e){return t.set(e[0],e[1])},ke["@@transducer/result"]=function(t){return t.asImmutable()};var Re=function(t,e){this.ownerID=t,this.entries=e};Re.prototype.get=function(t,e,r,n){for(var i=this.entries,o=0,u=i.length;o=Ge)return function(t,e,r,n){t||(t=new s);for(var i=new Ke(t,vt(r),[r,n]),o=0;o>>t)&i),s=this.bitmap;return 0==(s&u)?o:this.nodes[Xe(s&u-1)].get(t+r,e,n,o)},Ue.prototype.update=function(t,e,u,s,a,c,f){void 0===u&&(u=vt(s));var h=(0===e?u:u>>>e)&i,p=1<=Ze)return function(t,e,r,i,o){for(var u=0,s=new Array(n),a=0;0!==r;a++,r>>>=1)s[a]=1&r?e[u++]:void 0;return s[i]=o,new Te(t,u+1,s)}(t,y,_,h,g);if(l&&!g&&2===y.length&&Ye(y[1^v]))return y[1^v];if(l&&g&&1===y.length&&Ye(g))return g;var w=t&&t===this.ownerID,m=l?g?_:_^p:_|p,z=l?g?Fe(y,v,g,w):function(t,e,r){var n=t.length-1;if(r&&e===n)return t.pop(),t;for(var i=new Array(n),o=0,u=0;u>>t)&i,s=this.nodes[u];return s?s.get(t+r,e,n,o):o},Te.prototype.update=function(t,e,n,u,s,a,c){void 0===n&&(n=vt(u));var f=(0===e?n:n>>>e)&i,h=s===o,p=this.nodes,_=p[f];if(h&&!_)return this;var l=Ve(_,t,e+r,n,u,s,a,c);if(l===_)return this;var v=this.count;if(_){if(!l&&--v<$e)return function(t,e,r,n){for(var i=0,o=0,u=new Array(r),s=0,a=1,c=e.length;s>>n)&i,c=(0===n?o:o>>>n)&i,f=a===c?[Qe(t,e,n+r,o,u)]:(s=new Ke(e,o,u),a>1&1431655765))+(t>>2&858993459))+(t>>4)&252645135,t+=t>>8,127&(t+=t>>16)}function Fe(t,e,r,n){var i=n?t:Gt(t);return i[e]=r,i}var Ge=n/4,Ze=n/2,$e=n/4,tr="@@__IMMUTABLE_LIST__@@";function er(t){return Boolean(t&&t[tr])}var rr=function(t){function e(e){var i=ar();if(null==e)return i;if(er(e))return e;var o=t(e),u=o.size;return 0===u?i:($t(u),u>0&&u=0&&t=t.size||e<0)return t.withMutations((function(t){e<0?pr(t,e).set(0,r):pr(t,0,e+1).set(e,r)}));e+=t._origin;var n=t._tail,i=t._root,o={value:!1};e>=_r(t._capacity)?n=cr(n,t.__ownerID,0,e,r,o):i=cr(i,t.__ownerID,t._level,e,r,o);if(!o.value)return t;if(t.__ownerID)return t._root=i,t._tail=n,t.__hash=void 0,t.__altered=!0,t;return sr(t._origin,t._capacity,t._level,i,n)}(this,t,e)},e.prototype.remove=function(t){return this.has(t)?0===t?this.shift():t===this.size-1?this.pop():this.splice(t,1):this},e.prototype.insert=function(t,e){return this.splice(t,0,e)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=this._origin=this._capacity=0,this._level=r,this._root=this._tail=this.__hash=void 0,this.__altered=!0,this):ar()},e.prototype.push=function(){var t=arguments,e=this.size;return this.withMutations((function(r){pr(r,0,e+t.length);for(var n=0;n>>e&i;if(o>=this.array.length)return new ir([],t);var u,s=0===o;if(e>0){var a=this.array[o];if((u=a&&a.removeBefore(t,e-r,n))===a&&s)return this}if(s&&!u)return this;var c=fr(this,t);if(!s)for(var f=0;f>>e&i;if(u>=this.array.length)return this;if(e>0){var s=this.array[u];if((o=s&&s.removeAfter(t,e-r,n))===s&&u===this.array.length-1)return this}var a=fr(this,t);return a.array.splice(u+1),o&&(a.array[u]=o),a};var or={};function ur(t,e){var i=t._origin,o=t._capacity,u=_r(o),s=t._tail;return a(t._root,t._level,0);function a(t,c,f){return 0===c?function(t,r){var a=r===u?s&&s.array:t&&t.array,c=r>i?0:i-r,f=o-r;f>n&&(f=n);return function(){if(c===f)return or;var t=e?--f:c++;return a&&a[t]}}(t,f):function(t,u,s){var c,f=t&&t.array,h=s>i?0:i-s>>u,p=1+(o-s>>u);p>n&&(p=n);return function(){for(;;){if(c){var t=c();if(t!==or)return t;c=null}if(h===p)return or;var n=e?--p:h++;c=a(f&&f[n],u-r,s+(n<>>n&i,h=t&&f0){var p=t&&t.array[f],_=cr(p,e,n-r,o,s,a);return _===p?t:((c=fr(t,e)).array[f]=_,c)}return h&&t.array[f]===s?t:(a&&u(a),c=fr(t,e),void 0===s&&f===c.array.length-1?c.array.pop():c.array[f]=s,c)}function fr(t,e){return e&&t&&e===t.ownerID?t:new ir(t?t.array.slice():[],e)}function hr(t,e){if(e>=_r(t._capacity))return t._tail;if(e<1<0;)n=n.array[e>>>o&i],o-=r;return n}}function pr(t,e,n){void 0!==e&&(e|=0),void 0!==n&&(n|=0);var o=t.__ownerID||new s,u=t._origin,a=t._capacity,c=u+e,f=void 0===n?a:n<0?a+n:u+n;if(c===u&&f===a)return t;if(c>=f)return t.clear();for(var h=t._level,p=t._root,_=0;c+_<0;)p=new ir(p&&p.array.length?[void 0,p]:[],o),_+=1<<(h+=r);_&&(c+=_,u+=_,f+=_,a+=_);for(var l=_r(a),v=_r(f);v>=1<l?new ir([],o):y;if(y&&v>l&&cr;w-=r){var m=l>>>w&i;g=g.array[m]=fr(g.array[m],o)}g.array[l>>>r&i]=y}if(f=v)c-=v,f-=v,h=r,p=null,d=d&&d.removeBefore(o,0,c);else if(c>u||v>>h&i;if(z!==v>>>h&i)break;z&&(_+=(1<u&&(p=p.removeBefore(o,h,c-_)),p&&v>>r<=n&&a.size>=2*s.size?(i=(u=a.filter((function(t,e){return void 0!==t&&c!==e}))).toKeyedSeq().map((function(t){return t[0]})).flip().toMap(),t.__ownerID&&(i.__ownerID=u.__ownerID=t.__ownerID)):(i=s.remove(e),u=c===a.size-1?a.pop():a.set(c,void 0))}else if(f){if(r===a.get(c)[1])return t;i=s,u=a.set(c,[e,r])}else i=s.set(e,a.size),u=a.set(a.size,[e,r]);return t.__ownerID?(t.size=i.size,t._map=i,t._list=u,t.__hash=void 0,t.__altered=!0,t):yr(i,u)}vr.isOrderedMap=ct,vr.prototype[A]=!0,vr.prototype[e]=vr.prototype.remove;var wr="@@__IMMUTABLE_STACK__@@";function mr(t){return Boolean(t&&t[wr])}var zr=function(t){function e(t){return null==t?Or():mr(t)?t:Or().pushAll(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("Stack [","]")},e.prototype.get=function(t,e){var r=this._head;for(t=c(this,t);r&&t--;)r=r.next;return r?r.value:e},e.prototype.peek=function(){return this._head&&this._head.value},e.prototype.push=function(){var t=arguments;if(0===arguments.length)return this;for(var e=this.size+arguments.length,r=this._head,n=arguments.length-1;n>=0;n--)r={value:t[n],next:r};return this.__ownerID?(this.size=e,this._head=r,this.__hash=void 0,this.__altered=!0,this):Ir(e,r)},e.prototype.pushAll=function(e){if(0===(e=t(e)).size)return this;if(0===this.size&&mr(e))return e;$t(e.size);var r=this.size,n=this._head;return e.__iterate((function(t){r++,n={value:t,next:n}}),!0),this.__ownerID?(this.size=r,this._head=n,this.__hash=void 0,this.__altered=!0,this):Ir(r,n)},e.prototype.pop=function(){return this.slice(1)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):Or()},e.prototype.slice=function(e,r){if(h(e,r,this.size))return this;var n=p(e,this.size);if(_(r,this.size)!==this.size)return t.prototype.slice.call(this,e,r);for(var i=this.size-n,o=this._head;n--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):Ir(i,o)},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Ir(this.size,this._head,t,this.__hash):0===this.size?Or():(this.__ownerID=t,this.__altered=!1,this)},e.prototype.__iterate=function(t,e){var r=this;if(e)return new $(this.toArray()).__iterate((function(e,n){return t(e,n,r)}),e);for(var n=0,i=this._head;i&&!1!==t(i.value,n++,this);)i=i.next;return n},e.prototype.__iterator=function(t,e){if(e)return new $(this.toArray()).__iterator(t,e);var r=0,n=this._head;return new C((function(){if(n){var e=n.value;return n=n.next,P(t,r++,e)}return{value:void 0,done:!0}}))},e}(O);zr.isStack=mr;var Sr,br=zr.prototype;function Ir(t,e,r,n){var i=Object.create(br);return i.size=t,i._head=e,i.__ownerID=r,i.__hash=n,i.__altered=!1,i}function Or(){return Sr||(Sr=Ir(0))}br[wr]=!0,br.shift=br.pop,br.unshift=br.push,br.unshiftAll=br.pushAll,br.withMutations=je,br.wasAltered=xe,br.asImmutable=De,br["@@transducer/init"]=br.asMutable=Me,br["@@transducer/step"]=function(t,e){return t.unshift(e)},br["@@transducer/result"]=function(t){return t.asImmutable()};var Er="@@__IMMUTABLE_SET__@@";function qr(t){return Boolean(t&&t[Er])}function jr(t){return qr(t)&&k(t)}function Mr(t,e){if(t===e)return!0;if(!d(e)||void 0!==t.size&&void 0!==e.size&&t.size!==e.size||void 0!==t.__hash&&void 0!==e.__hash&&t.__hash!==e.__hash||w(t)!==w(e)||z(t)!==z(e)||k(t)!==k(e))return!1;if(0===t.size&&0===e.size)return!0;var r=!S(t);if(k(t)){var n=t.entries();return e.every((function(t,e){var i=n.next().value;return i&&ht(i[1],t)&&(r||ht(i[0],e))}))&&n.next().done}var i=!1;if(void 0===t.size)if(void 0===e.size)"function"==typeof t.cacheResult&&t.cacheResult();else{i=!0;var u=t;t=e,e=u}var s=!0,a=e.__iterate((function(e,n){if(r?!t.has(e):i?!ht(e,t.get(n,o)):!ht(t.get(n,o),e))return s=!1,!1}));return s&&t.size===a}function Dr(t,e){var r=function(r){t.prototype[r]=e[r]};return Object.keys(e).forEach(r),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(e).forEach(r),t}function xr(t){if(!t||"object"!=typeof t)return t;if(!d(t)){if(!ne(t))return t;t=X(t)}if(w(t)){var e={};return t.__iterate((function(t,r){e[r]=xr(t)})),e}var r=[];return t.__iterate((function(t){r.push(xr(t))})),r}var Ar=function(t){function e(e){return null==e?Br():qr(e)&&!k(e)?e:Br().withMutations((function(r){var n=t(e);$t(n.size),n.forEach((function(t){return r.add(t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(I(t).keySeq())},e.intersect=function(t){return(t=b(t).toArray()).length?Rr.intersect.apply(e(t.pop()),t):Br()},e.union=function(t){return(t=b(t).toArray()).length?Rr.union.apply(e(t.pop()),t):Br()},e.prototype.toString=function(){return this.__toString("Set {","}")},e.prototype.has=function(t){return this._map.has(t)},e.prototype.add=function(t){return Ur(this,this._map.set(t,t))},e.prototype.remove=function(t){return Ur(this,this._map.remove(t))},e.prototype.clear=function(){return Ur(this,this._map.clear())},e.prototype.map=function(t,e){var r=this,n=!1,i=Ur(this,this._map.mapEntries((function(i){var o=i[1],u=t.call(e,o,o,r);return u!==o&&(n=!0),[u,u]}),e));return n?i:this},e.prototype.union=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return 0===(e=e.filter((function(t){return 0!==t.size}))).length?this:0!==this.size||this.__ownerID||1!==e.length?this.withMutations((function(r){for(var n=0;n=0&&e=0&&r>>-15,461845907),e=pt(e<<13|e>>>-13,5),e=pt((e=(e+3864292196|0)^t)^e>>>16,2246822507),e=_t((e=pt(e^e>>>13,3266489909))^e>>>16)}(t.size,n)}(this))}});var Hr=b.prototype;Hr[y]=!0,Hr[L]=Hr.values,Hr.toJSON=Hr.toArray,Hr.__toStringMapper=ie,Hr.inspect=Hr.toSource=function(){return this.toString()},Hr.chain=Hr.flatMap,Hr.contains=Hr.includes,Dr(I,{flip:function(){return Jt(this,Rt(this))},mapEntries:function(t,e){var r=this,n=0;return Jt(this,this.toSeq().map((function(i,o){return t.call(e,[o,i],n++,r)})).fromEntrySeq())},mapKeys:function(t,e){var r=this;return Jt(this,this.toSeq().flip().map((function(n,i){return t.call(e,n,i,r)})).flip())}});var Jr=I.prototype;Jr[g]=!0,Jr[L]=Hr.entries,Jr.toJSON=Nr,Jr.__toStringMapper=function(t,e){return ie(e)+": "+ie(t)},Dr(O,{toKeyedSeq:function(){return new Dt(this,!1)},filter:function(t,e){return Jt(this,Bt(this,t,e,!1))},findIndex:function(t,e){var r=this.findEntry(t,e);return r?r[0]:-1},indexOf:function(t){var e=this.keyOf(t);return void 0===e?-1:e},lastIndexOf:function(t){var e=this.lastKeyOf(t);return void 0===e?-1:e},reverse:function(){return Jt(this,Tt(this,!1))},slice:function(t,e){return Jt(this,Kt(this,t,e,!1))},splice:function(t,e){var r=arguments.length;if(e=Math.max(e||0,0),0===r||2===r&&!e)return this;t=p(t,t<0?this.count():this.size);var n=this.slice(0,t);return Jt(this,1===r?n:n.concat(Gt(arguments,2),this.slice(t+e)))},findLastIndex:function(t,e){var r=this.findLastEntry(t,e);return r?r[0]:-1},first:function(t){return this.get(0,t)},flatten:function(t){return Jt(this,Ct(this,t,!1))},get:function(t,e){return(t=c(this,t))<0||this.size===1/0||void 0!==this.size&&t>this.size?e:this.find((function(e,r){return r===t}),void 0,e)},has:function(t){return(t=c(this,t))>=0&&(void 0!==this.size?this.size===1/0||te?-1:0}function en(t,e){return t^e+2654435769+(t<<6)+(t>>2)|0}Yr.has=Hr.includes,Yr.contains=Yr.includes,Yr.keys=Yr.values,Dr(F,Jr),Dr(G,Vr),Dr(Z,Yr);var rn=function(t){function e(t){return null==t?sn():jr(t)?t:sn().withMutations((function(e){var r=E(t);$t(r.size),r.forEach((function(t){return e.add(t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(I(t).keySeq())},e.prototype.toString=function(){return this.__toString("OrderedSet {","}")},e}(Ar);rn.isOrderedSet=jr;var nn,on=rn.prototype;function un(t,e){var r=Object.create(on);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function sn(){return nn||(nn=un(dr()))}on[A]=!0,on.zip=Vr.zip,on.zipWith=Vr.zipWith,on.zipAll=Vr.zipAll,on.__empty=sn,on.__make=un;var an=function(t,e){var r;!function(t){if(D(t))throw new Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(x(t))throw new Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(null===t||"object"!=typeof t)throw new Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}(t);var n=function(o){var u=this;if(o instanceof n)return o;if(!(this instanceof n))return new n(o);if(!r){r=!0;var s=Object.keys(t),a=i._indices={};i._name=e,i._keys=s,i._defaultValues=t;for(var c=0;c2?[]:void 0,{"":t})},t.get=ue,t.getIn=Cr,t.has=oe,t.hasIn=Wr,t.hash=vt,t.is=ht,t.isAssociative=S,t.isCollection=d,t.isImmutable=x,t.isIndexed=z,t.isKeyed=w,t.isList=er,t.isMap=at,t.isOrdered=k,t.isOrderedMap=ct,t.isOrderedSet=jr,t.isPlainObject=re,t.isRecord=D,t.isSeq=j,t.isSet=qr,t.isStack=mr,t.isValueObject=ft,t.merge=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return be(t,e)},t.mergeDeep=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Se(t,e)},t.mergeDeepWith=function(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];return Se(e,r,t)},t.mergeWith=function(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];return be(e,r,t)},t.remove=ae,t.removeIn=le,t.set=ce,t.setIn=pe,t.update=ye,t.updateIn=fe,t.version="5.0.2"})); diff --git a/package.json b/package.json index d96362aa14..2976df5118 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "immutable", - "version": "5.0.0", + "version": "5.0.2", "description": "Immutable Data Collections", "license": "MIT", "homepage": "https://immutable-js.com", @@ -16,7 +16,7 @@ "url": "https://github.com/immutable-js/immutable-js/issues" }, "main": "dist/immutable.js", - "module": "dist/es/Immutable.js", + "module": "dist/immutable.es.js", "types": "dist/immutable.d.ts", "files": [ "dist", From 9cfcc513c0383a347732b522f61772e83d24157a Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 19 Nov 2024 14:43:35 +0000 Subject: [PATCH 218/242] deploy: 95487387edb8d2a6403b6c6f118534bc0777a4e4 --- dist/immutable.es.js | 10 ++++++++-- dist/immutable.js | 10 ++++++++-- dist/immutable.min.js | 2 +- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/dist/immutable.es.js b/dist/immutable.es.js index bdfb3ad72f..59afaac5f1 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -3418,7 +3418,10 @@ var VNode = function VNode(array, ownerID) { // TODO: seems like these methods are very similar VNode.prototype.removeBefore = function removeBefore (ownerID, level, index) { - if (index === level ? 1 << level : this.array.length === 0) { + if ( + (index & ((1 << (level + SHIFT)) - 1)) === 0 || + this.array.length === 0 + ) { return this; } var originIndex = (index >>> level) & MASK; @@ -3451,7 +3454,10 @@ VNode.prototype.removeBefore = function removeBefore (ownerID, level, index) { }; VNode.prototype.removeAfter = function removeAfter (ownerID, level, index) { - if (index === (level ? 1 << level : 0) || this.array.length === 0) { + if ( + index === (level ? 1 << (level + SHIFT) : SIZE) || + this.array.length === 0 + ) { return this; } var sizeIndex = ((index - 1) >>> level) & MASK; diff --git a/dist/immutable.js b/dist/immutable.js index 424c32ab67..a64280baa8 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -3424,7 +3424,10 @@ // TODO: seems like these methods are very similar VNode.prototype.removeBefore = function removeBefore (ownerID, level, index) { - if (index === level ? 1 << level : this.array.length === 0) { + if ( + (index & ((1 << (level + SHIFT)) - 1)) === 0 || + this.array.length === 0 + ) { return this; } var originIndex = (index >>> level) & MASK; @@ -3457,7 +3460,10 @@ }; VNode.prototype.removeAfter = function removeAfter (ownerID, level, index) { - if (index === (level ? 1 << level : 0) || this.array.length === 0) { + if ( + index === (level ? 1 << (level + SHIFT) : SIZE) || + this.array.length === 0 + ) { return this; } var sizeIndex = ((index - 1) >>> level) & MASK; diff --git a/dist/immutable.min.js b/dist/immutable.min.js index 00399846c4..1e0ec159dd 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -22,4 +22,4 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).Immutable={})}(this,(function(t){"use strict";var e="delete",r=5,n=1<>>0;if(""+r!==e||4294967295===r)return NaN;e=r}return e<0?a(t)+e:e}function f(){return!0}function h(t,e,r){return(0===t&&!v(t)||void 0!==r&&t<=-r)&&(void 0===e||void 0!==r&&e>=r)}function p(t,e){return l(t,e,0)}function _(t,e){return l(t,e,e)}function l(t,e,r){return void 0===t?r:v(t)?e===1/0?e:0|Math.max(0,e+t):void 0===e||e===t?t:0|Math.min(e,t)}function v(t){return t<0||0===t&&1/t==-1/0}var y="@@__IMMUTABLE_ITERABLE__@@";function d(t){return Boolean(t&&t[y])}var g="@@__IMMUTABLE_KEYED__@@";function w(t){return Boolean(t&&t[g])}var m="@@__IMMUTABLE_INDEXED__@@";function z(t){return Boolean(t&&t[m])}function S(t){return w(t)||z(t)}var b=function(t){return d(t)?t:X(t)},I=function(t){function e(t){return w(t)?t:F(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(b),O=function(t){function e(t){return z(t)?t:G(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(b),E=function(t){function e(t){return d(t)&&!S(t)?t:Z(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(b);b.Keyed=I,b.Indexed=O,b.Set=E;var q="@@__IMMUTABLE_SEQ__@@";function j(t){return Boolean(t&&t[q])}var M="@@__IMMUTABLE_RECORD__@@";function D(t){return Boolean(t&&t[M])}function x(t){return d(t)||D(t)}var A="@@__IMMUTABLE_ORDERED__@@";function k(t){return Boolean(t&&t[A])}var R=0,U=1,T=2,B="function"==typeof Symbol&&Symbol.iterator,K="@@iterator",L=B||K,C=function(t){this.next=t};function P(t,e,r,n){var i=0===t?e:1===t?r:[e,r];return n?n.value=i:n={value:i,done:!1},n}function W(){return{value:void 0,done:!0}}function N(t){return!!Array.isArray(t)||!!V(t)}function H(t){return t&&"function"==typeof t.next}function J(t){var e=V(t);return e&&e.call(t)}function V(t){var e=t&&(B&&t[B]||t[K]);if("function"==typeof e)return e}C.prototype.toString=function(){return"[Iterator]"},C.KEYS=R,C.VALUES=U,C.ENTRIES=T,C.prototype.inspect=C.prototype.toSource=function(){return this.toString()},C.prototype[L]=function(){return this};var Y=Object.prototype.hasOwnProperty;function Q(t){return!(!Array.isArray(t)&&"string"!=typeof t)||t&&"object"==typeof t&&Number.isInteger(t.length)&&t.length>=0&&(0===t.length?1===Object.keys(t).length:t.hasOwnProperty(t.length-1))}var X=function(t){function e(t){return null==t?nt():x(t)?t.toSeq():function(t){var e=ut(t);if(e)return(n=V(r=t))&&n===r.entries?e.fromEntrySeq():function(t){var e=V(t);return e&&e===t.keys}(t)?e.toSetSeq():e;var r,n;if("object"==typeof t)return new tt(t);throw new TypeError("Expected Array or collection object of values, or keyed object: "+t)}(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq {","}")},e.prototype.cacheResult=function(){return!this._cache&&this.__iterateUncached&&(this._cache=this.entrySeq().toArray(),this.size=this._cache.length),this},e.prototype.__iterate=function(t,e){var r=this._cache;if(r){for(var n=r.length,i=0;i!==n;){var o=r[e?n-++i:i++];if(!1===t(o[1],o[0],this))break}return i}return this.__iterateUncached(t,e)},e.prototype.__iterator=function(t,e){var r=this._cache;if(r){var n=r.length,i=0;return new C((function(){if(i===n)return{value:void 0,done:!0};var o=r[e?n-++i:i++];return P(t,o[0],o[1])}))}return this.__iteratorUncached(t,e)},e}(b),F=function(t){function e(t){return null==t?nt().toKeyedSeq():d(t)?w(t)?t.toSeq():t.fromEntrySeq():D(t)?t.toSeq():it(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toKeyedSeq=function(){return this},e}(X),G=function(t){function e(t){return null==t?nt():d(t)?w(t)?t.entrySeq():t.toIndexedSeq():D(t)?t.toSeq().entrySeq():ot(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return e(arguments)},e.prototype.toIndexedSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq [","]")},e}(X),Z=function(t){function e(t){return(d(t)&&!S(t)?t:G(t)).toSetSeq()}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return e(arguments)},e.prototype.toSetSeq=function(){return this},e}(X);X.isSeq=j,X.Keyed=F,X.Set=Z,X.Indexed=G,X.prototype[q]=!0;var $=function(t){function e(t){this._array=t,this.size=t.length}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t,e){return this.has(t)?this._array[c(this,t)]:e},e.prototype.__iterate=function(t,e){for(var r=this._array,n=r.length,i=0;i!==n;){var o=e?n-++i:i++;if(!1===t(r[o],o,this))break}return i},e.prototype.__iterator=function(t,e){var r=this._array,n=r.length,i=0;return new C((function(){if(i===n)return{value:void 0,done:!0};var o=e?n-++i:i++;return P(t,o,r[o])}))},e}(G),tt=function(t){function e(t){var e=Object.keys(t).concat(Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(t):[]);this._object=t,this._keys=e,this.size=e.length}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t,e){return void 0===e||this.has(t)?this._object[t]:e},e.prototype.has=function(t){return Y.call(this._object,t)},e.prototype.__iterate=function(t,e){for(var r=this._object,n=this._keys,i=n.length,o=0;o!==i;){var u=n[e?i-++o:o++];if(!1===t(r[u],u,this))break}return o},e.prototype.__iterator=function(t,e){var r=this._object,n=this._keys,i=n.length,o=0;return new C((function(){if(o===i)return{value:void 0,done:!0};var u=n[e?i-++o:o++];return P(t,u,r[u])}))},e}(F);tt.prototype[A]=!0;var et,rt=function(t){function e(t){this._collection=t,this.size=t.length||t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.__iterateUncached=function(t,e){if(e)return this.cacheResult().__iterate(t,e);var r=J(this._collection),n=0;if(H(r))for(var i;!(i=r.next()).done&&!1!==t(i.value,n++,this););return n},e.prototype.__iteratorUncached=function(t,e){if(e)return this.cacheResult().__iterator(t,e);var r=J(this._collection);if(!H(r))return new C(W);var n=0;return new C((function(){var e=r.next();return e.done?e:P(t,n++,e.value)}))},e}(G);function nt(){return et||(et=new $([]))}function it(t){var e=ut(t);if(e)return e.fromEntrySeq();if("object"==typeof t)return new tt(t);throw new TypeError("Expected Array or collection object of [k, v] entries, or keyed object: "+t)}function ot(t){var e=ut(t);if(e)return e;throw new TypeError("Expected Array or collection object of values: "+t)}function ut(t){return Q(t)?new $(t):N(t)?new rt(t):void 0}var st="@@__IMMUTABLE_MAP__@@";function at(t){return Boolean(t&&t[st])}function ct(t){return at(t)&&k(t)}function ft(t){return Boolean(t&&"function"==typeof t.equals&&"function"==typeof t.hashCode)}function ht(t,e){if(t===e||t!=t&&e!=e)return!0;if(!t||!e)return!1;if("function"==typeof t.valueOf&&"function"==typeof e.valueOf){if((t=t.valueOf())===(e=e.valueOf())||t!=t&&e!=e)return!0;if(!t||!e)return!1}return!!(ft(t)&&ft(e)&&t.equals(e))}var pt="function"==typeof Math.imul&&-2===Math.imul(4294967295,2)?Math.imul:function(t,e){var r=65535&(t|=0),n=65535&(e|=0);return r*n+((t>>>16)*n+r*(e>>>16)<<16>>>0)|0};function _t(t){return t>>>1&1073741824|3221225471&t}var lt=Object.prototype.valueOf;function vt(t){if(null==t)return yt(t);if("function"==typeof t.hashCode)return _t(t.hashCode(t));var e,r=(e=t).valueOf!==lt&&"function"==typeof e.valueOf?e.valueOf(e):e;if(null==r)return yt(r);switch(typeof r){case"boolean":return r?1108378657:1108378656;case"number":return function(t){if(t!=t||t===1/0)return 0;var e=0|t;e!==t&&(e^=4294967295*t);for(;t>4294967295;)e^=t/=4294967295;return _t(e)}(r);case"string":return r.length>Et?function(t){var e=Mt[t];void 0===e&&(e=dt(t),jt===qt&&(jt=0,Mt={}),jt++,Mt[t]=e);return e}(r):dt(r);case"object":case"function":return function(t){var e;if(St&&void 0!==(e=zt.get(t)))return e;if(e=t[Ot],void 0!==e)return e;if(!wt){if(void 0!==(e=t.propertyIsEnumerable&&t.propertyIsEnumerable[Ot]))return e;if(void 0!==(e=function(t){if(t&&t.nodeType>0)switch(t.nodeType){case 1:return t.uniqueID;case 9:return t.documentElement&&t.documentElement.uniqueID}}(t)))return e}if(e=mt(),St)zt.set(t,e);else{if(void 0!==gt&&!1===gt(t))throw new Error("Non-extensible objects are not allowed as keys.");if(wt)Object.defineProperty(t,Ot,{enumerable:!1,configurable:!1,writable:!1,value:e});else if(void 0!==t.propertyIsEnumerable&&t.propertyIsEnumerable===t.constructor.prototype.propertyIsEnumerable)t.propertyIsEnumerable=function(){return this.constructor.prototype.propertyIsEnumerable.apply(this,arguments)},t.propertyIsEnumerable[Ot]=e;else{if(void 0===t.nodeType)throw new Error("Unable to set a non-enumerable property on object.");t[Ot]=e}}return e}(r);case"symbol":return function(t){var e=bt[t];if(void 0!==e)return e;return e=mt(),bt[t]=e,e}(r);default:if("function"==typeof r.toString)return dt(r.toString());throw new Error("Value type "+typeof r+" cannot be hashed.")}}function yt(t){return null===t?1108378658:1108378659}function dt(t){for(var e=0,r=0;r=0&&(a.get=function(e,r){return(e=c(this,e))>=0&&eo)return{value:void 0,done:!0};var t=i.next();return n||e===U||t.done?t:P(e,a-1,e===R?void 0:t.value[1],t)}))},a}function Lt(t,e,r,n){var i=Qt(t);return i.__iterateUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterate(i,o);var s=!0,a=0;return t.__iterate((function(t,o,c){if(!s||!(s=e.call(r,t,o,c)))return a++,i(t,n?o:a-1,u)})),a},i.__iteratorUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterator(i,o);var s=t.__iterator(T,o),a=!0,c=0;return new C((function(){var t,o,f;do{if((t=s.next()).done)return n||i===U?t:P(i,c++,i===R?void 0:t.value[1],t);var h=t.value;o=h[0],f=h[1],a&&(a=e.call(r,f,o,u))}while(a);return i===T?t:P(i,o,f,t)}))},i}function Ct(t,e,r){var n=Qt(t);return n.__iterateUncached=function(i,o){if(o)return this.cacheResult().__iterate(i,o);var u=0,s=!1;return function t(a,c){a.__iterate((function(o,a){return(!e||c0}function Ht(t,e,r,n){var i=Qt(t),o=new $(r).map((function(t){return t.size}));return i.size=n?o.max():o.min(),i.__iterate=function(t,e){for(var r,n=this.__iterator(U,e),i=0;!(r=n.next()).done&&!1!==t(r.value,i++,this););return i},i.__iteratorUncached=function(t,i){var o=r.map((function(t){return t=b(t),J(i?t.reverse():t)})),u=0,s=!1;return new C((function(){var r;return s||(r=o.map((function(t){return t.next()})),s=n?r.every((function(t){return t.done})):r.some((function(t){return t.done}))),s?{value:void 0,done:!0}:P(t,u++,e.apply(null,r.map((function(t){return t.value}))))}))},i}function Jt(t,e){return t===e?t:j(t)?e:t.constructor(e)}function Vt(t){if(t!==Object(t))throw new TypeError("Expected [K, V] tuple: "+t)}function Yt(t){return w(t)?I:z(t)?O:E}function Qt(t){return Object.create((w(t)?F:z(t)?G:Z).prototype)}function Xt(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size,this):X.prototype.cacheResult.call(this)}function Ft(t,e){return void 0===t&&void 0===e?0:void 0===t?1:void 0===e?-1:t>e?1:t0;)e[r]=arguments[r+1];if("function"!=typeof t)throw new TypeError("Invalid merger function: "+t);return ze(this,e,t)}function ze(t,e,r){for(var n=[],i=0;i0;)e[r]=arguments[r+1];return Se(this,e,t)}function Ee(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return fe(this,t,He(),(function(t){return be(t,e)}))}function qe(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return fe(this,t,He(),(function(t){return Se(t,e)}))}function je(t){var e=this.asMutable();return t(e),e.wasAltered()?e.__ensureOwner(this.__ownerID):this}function Me(){return this.__ownerID?this:this.__ensureOwner(new s)}function De(){return this.__ensureOwner()}function xe(){return this.__altered}var Ae=function(t){function e(e){return null==e?He():at(e)&&!k(e)?e:He().withMutations((function(r){var n=t(e);$t(n.size),n.forEach((function(t,e){return r.set(e,t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toString=function(){return this.__toString("Map {","}")},e.prototype.get=function(t,e){return this._root?this._root.get(0,void 0,t,e):e},e.prototype.set=function(t,e){return Je(this,t,e)},e.prototype.remove=function(t){return Je(this,t,o)},e.prototype.deleteAll=function(t){var e=b(t);return 0===e.size?this:this.withMutations((function(t){e.forEach((function(e){return t.remove(e)}))}))},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):He()},e.prototype.sort=function(t){return vr(Pt(this,t))},e.prototype.sortBy=function(t,e){return vr(Pt(this,e,t))},e.prototype.map=function(t,e){var r=this;return this.withMutations((function(n){n.forEach((function(i,o){n.set(o,t.call(e,i,o,r))}))}))},e.prototype.__iterator=function(t,e){return new Ce(this,t,e)},e.prototype.__iterate=function(t,e){var r=this,n=0;return this._root&&this._root.iterate((function(e){return n++,t(e[1],e[0],r)}),e),n},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Ne(this.size,this._root,t,this.__hash):0===this.size?He():(this.__ownerID=t,this.__altered=!1,this)},e}(I);Ae.isMap=at;var ke=Ae.prototype;ke[st]=!0,ke[e]=ke.remove,ke.removeAll=ke.deleteAll,ke.setIn=_e,ke.removeIn=ke.deleteIn=ve,ke.update=de,ke.updateIn=ge,ke.merge=ke.concat=we,ke.mergeWith=me,ke.mergeDeep=Ie,ke.mergeDeepWith=Oe,ke.mergeIn=Ee,ke.mergeDeepIn=qe,ke.withMutations=je,ke.wasAltered=xe,ke.asImmutable=De,ke["@@transducer/init"]=ke.asMutable=Me,ke["@@transducer/step"]=function(t,e){return t.set(e[0],e[1])},ke["@@transducer/result"]=function(t){return t.asImmutable()};var Re=function(t,e){this.ownerID=t,this.entries=e};Re.prototype.get=function(t,e,r,n){for(var i=this.entries,o=0,u=i.length;o=Ge)return function(t,e,r,n){t||(t=new s);for(var i=new Ke(t,vt(r),[r,n]),o=0;o>>t)&i),s=this.bitmap;return 0==(s&u)?o:this.nodes[Xe(s&u-1)].get(t+r,e,n,o)},Ue.prototype.update=function(t,e,u,s,a,c,f){void 0===u&&(u=vt(s));var h=(0===e?u:u>>>e)&i,p=1<=Ze)return function(t,e,r,i,o){for(var u=0,s=new Array(n),a=0;0!==r;a++,r>>>=1)s[a]=1&r?e[u++]:void 0;return s[i]=o,new Te(t,u+1,s)}(t,y,_,h,g);if(l&&!g&&2===y.length&&Ye(y[1^v]))return y[1^v];if(l&&g&&1===y.length&&Ye(g))return g;var w=t&&t===this.ownerID,m=l?g?_:_^p:_|p,z=l?g?Fe(y,v,g,w):function(t,e,r){var n=t.length-1;if(r&&e===n)return t.pop(),t;for(var i=new Array(n),o=0,u=0;u>>t)&i,s=this.nodes[u];return s?s.get(t+r,e,n,o):o},Te.prototype.update=function(t,e,n,u,s,a,c){void 0===n&&(n=vt(u));var f=(0===e?n:n>>>e)&i,h=s===o,p=this.nodes,_=p[f];if(h&&!_)return this;var l=Ve(_,t,e+r,n,u,s,a,c);if(l===_)return this;var v=this.count;if(_){if(!l&&--v<$e)return function(t,e,r,n){for(var i=0,o=0,u=new Array(r),s=0,a=1,c=e.length;s>>n)&i,c=(0===n?o:o>>>n)&i,f=a===c?[Qe(t,e,n+r,o,u)]:(s=new Ke(e,o,u),a>1&1431655765))+(t>>2&858993459))+(t>>4)&252645135,t+=t>>8,127&(t+=t>>16)}function Fe(t,e,r,n){var i=n?t:Gt(t);return i[e]=r,i}var Ge=n/4,Ze=n/2,$e=n/4,tr="@@__IMMUTABLE_LIST__@@";function er(t){return Boolean(t&&t[tr])}var rr=function(t){function e(e){var i=ar();if(null==e)return i;if(er(e))return e;var o=t(e),u=o.size;return 0===u?i:($t(u),u>0&&u=0&&t=t.size||e<0)return t.withMutations((function(t){e<0?pr(t,e).set(0,r):pr(t,0,e+1).set(e,r)}));e+=t._origin;var n=t._tail,i=t._root,o={value:!1};e>=_r(t._capacity)?n=cr(n,t.__ownerID,0,e,r,o):i=cr(i,t.__ownerID,t._level,e,r,o);if(!o.value)return t;if(t.__ownerID)return t._root=i,t._tail=n,t.__hash=void 0,t.__altered=!0,t;return sr(t._origin,t._capacity,t._level,i,n)}(this,t,e)},e.prototype.remove=function(t){return this.has(t)?0===t?this.shift():t===this.size-1?this.pop():this.splice(t,1):this},e.prototype.insert=function(t,e){return this.splice(t,0,e)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=this._origin=this._capacity=0,this._level=r,this._root=this._tail=this.__hash=void 0,this.__altered=!0,this):ar()},e.prototype.push=function(){var t=arguments,e=this.size;return this.withMutations((function(r){pr(r,0,e+t.length);for(var n=0;n>>e&i;if(o>=this.array.length)return new ir([],t);var u,s=0===o;if(e>0){var a=this.array[o];if((u=a&&a.removeBefore(t,e-r,n))===a&&s)return this}if(s&&!u)return this;var c=fr(this,t);if(!s)for(var f=0;f>>e&i;if(u>=this.array.length)return this;if(e>0){var s=this.array[u];if((o=s&&s.removeAfter(t,e-r,n))===s&&u===this.array.length-1)return this}var a=fr(this,t);return a.array.splice(u+1),o&&(a.array[u]=o),a};var or={};function ur(t,e){var i=t._origin,o=t._capacity,u=_r(o),s=t._tail;return a(t._root,t._level,0);function a(t,c,f){return 0===c?function(t,r){var a=r===u?s&&s.array:t&&t.array,c=r>i?0:i-r,f=o-r;f>n&&(f=n);return function(){if(c===f)return or;var t=e?--f:c++;return a&&a[t]}}(t,f):function(t,u,s){var c,f=t&&t.array,h=s>i?0:i-s>>u,p=1+(o-s>>u);p>n&&(p=n);return function(){for(;;){if(c){var t=c();if(t!==or)return t;c=null}if(h===p)return or;var n=e?--p:h++;c=a(f&&f[n],u-r,s+(n<>>n&i,h=t&&f0){var p=t&&t.array[f],_=cr(p,e,n-r,o,s,a);return _===p?t:((c=fr(t,e)).array[f]=_,c)}return h&&t.array[f]===s?t:(a&&u(a),c=fr(t,e),void 0===s&&f===c.array.length-1?c.array.pop():c.array[f]=s,c)}function fr(t,e){return e&&t&&e===t.ownerID?t:new ir(t?t.array.slice():[],e)}function hr(t,e){if(e>=_r(t._capacity))return t._tail;if(e<1<0;)n=n.array[e>>>o&i],o-=r;return n}}function pr(t,e,n){void 0!==e&&(e|=0),void 0!==n&&(n|=0);var o=t.__ownerID||new s,u=t._origin,a=t._capacity,c=u+e,f=void 0===n?a:n<0?a+n:u+n;if(c===u&&f===a)return t;if(c>=f)return t.clear();for(var h=t._level,p=t._root,_=0;c+_<0;)p=new ir(p&&p.array.length?[void 0,p]:[],o),_+=1<<(h+=r);_&&(c+=_,u+=_,f+=_,a+=_);for(var l=_r(a),v=_r(f);v>=1<l?new ir([],o):y;if(y&&v>l&&cr;w-=r){var m=l>>>w&i;g=g.array[m]=fr(g.array[m],o)}g.array[l>>>r&i]=y}if(f=v)c-=v,f-=v,h=r,p=null,d=d&&d.removeBefore(o,0,c);else if(c>u||v>>h&i;if(z!==v>>>h&i)break;z&&(_+=(1<u&&(p=p.removeBefore(o,h,c-_)),p&&v>>r<=n&&a.size>=2*s.size?(i=(u=a.filter((function(t,e){return void 0!==t&&c!==e}))).toKeyedSeq().map((function(t){return t[0]})).flip().toMap(),t.__ownerID&&(i.__ownerID=u.__ownerID=t.__ownerID)):(i=s.remove(e),u=c===a.size-1?a.pop():a.set(c,void 0))}else if(f){if(r===a.get(c)[1])return t;i=s,u=a.set(c,[e,r])}else i=s.set(e,a.size),u=a.set(a.size,[e,r]);return t.__ownerID?(t.size=i.size,t._map=i,t._list=u,t.__hash=void 0,t.__altered=!0,t):yr(i,u)}vr.isOrderedMap=ct,vr.prototype[A]=!0,vr.prototype[e]=vr.prototype.remove;var wr="@@__IMMUTABLE_STACK__@@";function mr(t){return Boolean(t&&t[wr])}var zr=function(t){function e(t){return null==t?Or():mr(t)?t:Or().pushAll(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("Stack [","]")},e.prototype.get=function(t,e){var r=this._head;for(t=c(this,t);r&&t--;)r=r.next;return r?r.value:e},e.prototype.peek=function(){return this._head&&this._head.value},e.prototype.push=function(){var t=arguments;if(0===arguments.length)return this;for(var e=this.size+arguments.length,r=this._head,n=arguments.length-1;n>=0;n--)r={value:t[n],next:r};return this.__ownerID?(this.size=e,this._head=r,this.__hash=void 0,this.__altered=!0,this):Ir(e,r)},e.prototype.pushAll=function(e){if(0===(e=t(e)).size)return this;if(0===this.size&&mr(e))return e;$t(e.size);var r=this.size,n=this._head;return e.__iterate((function(t){r++,n={value:t,next:n}}),!0),this.__ownerID?(this.size=r,this._head=n,this.__hash=void 0,this.__altered=!0,this):Ir(r,n)},e.prototype.pop=function(){return this.slice(1)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):Or()},e.prototype.slice=function(e,r){if(h(e,r,this.size))return this;var n=p(e,this.size);if(_(r,this.size)!==this.size)return t.prototype.slice.call(this,e,r);for(var i=this.size-n,o=this._head;n--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):Ir(i,o)},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Ir(this.size,this._head,t,this.__hash):0===this.size?Or():(this.__ownerID=t,this.__altered=!1,this)},e.prototype.__iterate=function(t,e){var r=this;if(e)return new $(this.toArray()).__iterate((function(e,n){return t(e,n,r)}),e);for(var n=0,i=this._head;i&&!1!==t(i.value,n++,this);)i=i.next;return n},e.prototype.__iterator=function(t,e){if(e)return new $(this.toArray()).__iterator(t,e);var r=0,n=this._head;return new C((function(){if(n){var e=n.value;return n=n.next,P(t,r++,e)}return{value:void 0,done:!0}}))},e}(O);zr.isStack=mr;var Sr,br=zr.prototype;function Ir(t,e,r,n){var i=Object.create(br);return i.size=t,i._head=e,i.__ownerID=r,i.__hash=n,i.__altered=!1,i}function Or(){return Sr||(Sr=Ir(0))}br[wr]=!0,br.shift=br.pop,br.unshift=br.push,br.unshiftAll=br.pushAll,br.withMutations=je,br.wasAltered=xe,br.asImmutable=De,br["@@transducer/init"]=br.asMutable=Me,br["@@transducer/step"]=function(t,e){return t.unshift(e)},br["@@transducer/result"]=function(t){return t.asImmutable()};var Er="@@__IMMUTABLE_SET__@@";function qr(t){return Boolean(t&&t[Er])}function jr(t){return qr(t)&&k(t)}function Mr(t,e){if(t===e)return!0;if(!d(e)||void 0!==t.size&&void 0!==e.size&&t.size!==e.size||void 0!==t.__hash&&void 0!==e.__hash&&t.__hash!==e.__hash||w(t)!==w(e)||z(t)!==z(e)||k(t)!==k(e))return!1;if(0===t.size&&0===e.size)return!0;var r=!S(t);if(k(t)){var n=t.entries();return e.every((function(t,e){var i=n.next().value;return i&&ht(i[1],t)&&(r||ht(i[0],e))}))&&n.next().done}var i=!1;if(void 0===t.size)if(void 0===e.size)"function"==typeof t.cacheResult&&t.cacheResult();else{i=!0;var u=t;t=e,e=u}var s=!0,a=e.__iterate((function(e,n){if(r?!t.has(e):i?!ht(e,t.get(n,o)):!ht(t.get(n,o),e))return s=!1,!1}));return s&&t.size===a}function Dr(t,e){var r=function(r){t.prototype[r]=e[r]};return Object.keys(e).forEach(r),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(e).forEach(r),t}function xr(t){if(!t||"object"!=typeof t)return t;if(!d(t)){if(!ne(t))return t;t=X(t)}if(w(t)){var e={};return t.__iterate((function(t,r){e[r]=xr(t)})),e}var r=[];return t.__iterate((function(t){r.push(xr(t))})),r}var Ar=function(t){function e(e){return null==e?Br():qr(e)&&!k(e)?e:Br().withMutations((function(r){var n=t(e);$t(n.size),n.forEach((function(t){return r.add(t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(I(t).keySeq())},e.intersect=function(t){return(t=b(t).toArray()).length?Rr.intersect.apply(e(t.pop()),t):Br()},e.union=function(t){return(t=b(t).toArray()).length?Rr.union.apply(e(t.pop()),t):Br()},e.prototype.toString=function(){return this.__toString("Set {","}")},e.prototype.has=function(t){return this._map.has(t)},e.prototype.add=function(t){return Ur(this,this._map.set(t,t))},e.prototype.remove=function(t){return Ur(this,this._map.remove(t))},e.prototype.clear=function(){return Ur(this,this._map.clear())},e.prototype.map=function(t,e){var r=this,n=!1,i=Ur(this,this._map.mapEntries((function(i){var o=i[1],u=t.call(e,o,o,r);return u!==o&&(n=!0),[u,u]}),e));return n?i:this},e.prototype.union=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return 0===(e=e.filter((function(t){return 0!==t.size}))).length?this:0!==this.size||this.__ownerID||1!==e.length?this.withMutations((function(r){for(var n=0;n=0&&e=0&&r>>-15,461845907),e=pt(e<<13|e>>>-13,5),e=pt((e=(e+3864292196|0)^t)^e>>>16,2246822507),e=_t((e=pt(e^e>>>13,3266489909))^e>>>16)}(t.size,n)}(this))}});var Hr=b.prototype;Hr[y]=!0,Hr[L]=Hr.values,Hr.toJSON=Hr.toArray,Hr.__toStringMapper=ie,Hr.inspect=Hr.toSource=function(){return this.toString()},Hr.chain=Hr.flatMap,Hr.contains=Hr.includes,Dr(I,{flip:function(){return Jt(this,Rt(this))},mapEntries:function(t,e){var r=this,n=0;return Jt(this,this.toSeq().map((function(i,o){return t.call(e,[o,i],n++,r)})).fromEntrySeq())},mapKeys:function(t,e){var r=this;return Jt(this,this.toSeq().flip().map((function(n,i){return t.call(e,n,i,r)})).flip())}});var Jr=I.prototype;Jr[g]=!0,Jr[L]=Hr.entries,Jr.toJSON=Nr,Jr.__toStringMapper=function(t,e){return ie(e)+": "+ie(t)},Dr(O,{toKeyedSeq:function(){return new Dt(this,!1)},filter:function(t,e){return Jt(this,Bt(this,t,e,!1))},findIndex:function(t,e){var r=this.findEntry(t,e);return r?r[0]:-1},indexOf:function(t){var e=this.keyOf(t);return void 0===e?-1:e},lastIndexOf:function(t){var e=this.lastKeyOf(t);return void 0===e?-1:e},reverse:function(){return Jt(this,Tt(this,!1))},slice:function(t,e){return Jt(this,Kt(this,t,e,!1))},splice:function(t,e){var r=arguments.length;if(e=Math.max(e||0,0),0===r||2===r&&!e)return this;t=p(t,t<0?this.count():this.size);var n=this.slice(0,t);return Jt(this,1===r?n:n.concat(Gt(arguments,2),this.slice(t+e)))},findLastIndex:function(t,e){var r=this.findLastEntry(t,e);return r?r[0]:-1},first:function(t){return this.get(0,t)},flatten:function(t){return Jt(this,Ct(this,t,!1))},get:function(t,e){return(t=c(this,t))<0||this.size===1/0||void 0!==this.size&&t>this.size?e:this.find((function(e,r){return r===t}),void 0,e)},has:function(t){return(t=c(this,t))>=0&&(void 0!==this.size?this.size===1/0||te?-1:0}function en(t,e){return t^e+2654435769+(t<<6)+(t>>2)|0}Yr.has=Hr.includes,Yr.contains=Yr.includes,Yr.keys=Yr.values,Dr(F,Jr),Dr(G,Vr),Dr(Z,Yr);var rn=function(t){function e(t){return null==t?sn():jr(t)?t:sn().withMutations((function(e){var r=E(t);$t(r.size),r.forEach((function(t){return e.add(t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(I(t).keySeq())},e.prototype.toString=function(){return this.__toString("OrderedSet {","}")},e}(Ar);rn.isOrderedSet=jr;var nn,on=rn.prototype;function un(t,e){var r=Object.create(on);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function sn(){return nn||(nn=un(dr()))}on[A]=!0,on.zip=Vr.zip,on.zipWith=Vr.zipWith,on.zipAll=Vr.zipAll,on.__empty=sn,on.__make=un;var an=function(t,e){var r;!function(t){if(D(t))throw new Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(x(t))throw new Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(null===t||"object"!=typeof t)throw new Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}(t);var n=function(o){var u=this;if(o instanceof n)return o;if(!(this instanceof n))return new n(o);if(!r){r=!0;var s=Object.keys(t),a=i._indices={};i._name=e,i._keys=s,i._defaultValues=t;for(var c=0;c2?[]:void 0,{"":t})},t.get=ue,t.getIn=Cr,t.has=oe,t.hasIn=Wr,t.hash=vt,t.is=ht,t.isAssociative=S,t.isCollection=d,t.isImmutable=x,t.isIndexed=z,t.isKeyed=w,t.isList=er,t.isMap=at,t.isOrdered=k,t.isOrderedMap=ct,t.isOrderedSet=jr,t.isPlainObject=re,t.isRecord=D,t.isSeq=j,t.isSet=qr,t.isStack=mr,t.isValueObject=ft,t.merge=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return be(t,e)},t.mergeDeep=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Se(t,e)},t.mergeDeepWith=function(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];return Se(e,r,t)},t.mergeWith=function(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];return be(e,r,t)},t.remove=ae,t.removeIn=le,t.set=ce,t.setIn=pe,t.update=ye,t.updateIn=fe,t.version="5.0.2"})); +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).Immutable={})}(this,(function(t){"use strict";var e="delete",r=5,n=1<>>0;if(""+r!==e||4294967295===r)return NaN;e=r}return e<0?a(t)+e:e}function f(){return!0}function h(t,e,r){return(0===t&&!v(t)||void 0!==r&&t<=-r)&&(void 0===e||void 0!==r&&e>=r)}function p(t,e){return l(t,e,0)}function _(t,e){return l(t,e,e)}function l(t,e,r){return void 0===t?r:v(t)?e===1/0?e:0|Math.max(0,e+t):void 0===e||e===t?t:0|Math.min(e,t)}function v(t){return t<0||0===t&&1/t==-1/0}var y="@@__IMMUTABLE_ITERABLE__@@";function d(t){return Boolean(t&&t[y])}var g="@@__IMMUTABLE_KEYED__@@";function w(t){return Boolean(t&&t[g])}var m="@@__IMMUTABLE_INDEXED__@@";function z(t){return Boolean(t&&t[m])}function S(t){return w(t)||z(t)}var b=function(t){return d(t)?t:X(t)},I=function(t){function e(t){return w(t)?t:F(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(b),O=function(t){function e(t){return z(t)?t:G(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(b),E=function(t){function e(t){return d(t)&&!S(t)?t:Z(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(b);b.Keyed=I,b.Indexed=O,b.Set=E;var q="@@__IMMUTABLE_SEQ__@@";function j(t){return Boolean(t&&t[q])}var M="@@__IMMUTABLE_RECORD__@@";function D(t){return Boolean(t&&t[M])}function x(t){return d(t)||D(t)}var A="@@__IMMUTABLE_ORDERED__@@";function k(t){return Boolean(t&&t[A])}var R=0,U=1,T=2,B="function"==typeof Symbol&&Symbol.iterator,K="@@iterator",L=B||K,C=function(t){this.next=t};function P(t,e,r,n){var i=0===t?e:1===t?r:[e,r];return n?n.value=i:n={value:i,done:!1},n}function W(){return{value:void 0,done:!0}}function N(t){return!!Array.isArray(t)||!!V(t)}function H(t){return t&&"function"==typeof t.next}function J(t){var e=V(t);return e&&e.call(t)}function V(t){var e=t&&(B&&t[B]||t[K]);if("function"==typeof e)return e}C.prototype.toString=function(){return"[Iterator]"},C.KEYS=R,C.VALUES=U,C.ENTRIES=T,C.prototype.inspect=C.prototype.toSource=function(){return this.toString()},C.prototype[L]=function(){return this};var Y=Object.prototype.hasOwnProperty;function Q(t){return!(!Array.isArray(t)&&"string"!=typeof t)||t&&"object"==typeof t&&Number.isInteger(t.length)&&t.length>=0&&(0===t.length?1===Object.keys(t).length:t.hasOwnProperty(t.length-1))}var X=function(t){function e(t){return null==t?nt():x(t)?t.toSeq():function(t){var e=ut(t);if(e)return(n=V(r=t))&&n===r.entries?e.fromEntrySeq():function(t){var e=V(t);return e&&e===t.keys}(t)?e.toSetSeq():e;var r,n;if("object"==typeof t)return new tt(t);throw new TypeError("Expected Array or collection object of values, or keyed object: "+t)}(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq {","}")},e.prototype.cacheResult=function(){return!this._cache&&this.__iterateUncached&&(this._cache=this.entrySeq().toArray(),this.size=this._cache.length),this},e.prototype.__iterate=function(t,e){var r=this._cache;if(r){for(var n=r.length,i=0;i!==n;){var o=r[e?n-++i:i++];if(!1===t(o[1],o[0],this))break}return i}return this.__iterateUncached(t,e)},e.prototype.__iterator=function(t,e){var r=this._cache;if(r){var n=r.length,i=0;return new C((function(){if(i===n)return{value:void 0,done:!0};var o=r[e?n-++i:i++];return P(t,o[0],o[1])}))}return this.__iteratorUncached(t,e)},e}(b),F=function(t){function e(t){return null==t?nt().toKeyedSeq():d(t)?w(t)?t.toSeq():t.fromEntrySeq():D(t)?t.toSeq():it(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toKeyedSeq=function(){return this},e}(X),G=function(t){function e(t){return null==t?nt():d(t)?w(t)?t.entrySeq():t.toIndexedSeq():D(t)?t.toSeq().entrySeq():ot(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return e(arguments)},e.prototype.toIndexedSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq [","]")},e}(X),Z=function(t){function e(t){return(d(t)&&!S(t)?t:G(t)).toSetSeq()}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return e(arguments)},e.prototype.toSetSeq=function(){return this},e}(X);X.isSeq=j,X.Keyed=F,X.Set=Z,X.Indexed=G,X.prototype[q]=!0;var $=function(t){function e(t){this._array=t,this.size=t.length}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t,e){return this.has(t)?this._array[c(this,t)]:e},e.prototype.__iterate=function(t,e){for(var r=this._array,n=r.length,i=0;i!==n;){var o=e?n-++i:i++;if(!1===t(r[o],o,this))break}return i},e.prototype.__iterator=function(t,e){var r=this._array,n=r.length,i=0;return new C((function(){if(i===n)return{value:void 0,done:!0};var o=e?n-++i:i++;return P(t,o,r[o])}))},e}(G),tt=function(t){function e(t){var e=Object.keys(t).concat(Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(t):[]);this._object=t,this._keys=e,this.size=e.length}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t,e){return void 0===e||this.has(t)?this._object[t]:e},e.prototype.has=function(t){return Y.call(this._object,t)},e.prototype.__iterate=function(t,e){for(var r=this._object,n=this._keys,i=n.length,o=0;o!==i;){var u=n[e?i-++o:o++];if(!1===t(r[u],u,this))break}return o},e.prototype.__iterator=function(t,e){var r=this._object,n=this._keys,i=n.length,o=0;return new C((function(){if(o===i)return{value:void 0,done:!0};var u=n[e?i-++o:o++];return P(t,u,r[u])}))},e}(F);tt.prototype[A]=!0;var et,rt=function(t){function e(t){this._collection=t,this.size=t.length||t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.__iterateUncached=function(t,e){if(e)return this.cacheResult().__iterate(t,e);var r=J(this._collection),n=0;if(H(r))for(var i;!(i=r.next()).done&&!1!==t(i.value,n++,this););return n},e.prototype.__iteratorUncached=function(t,e){if(e)return this.cacheResult().__iterator(t,e);var r=J(this._collection);if(!H(r))return new C(W);var n=0;return new C((function(){var e=r.next();return e.done?e:P(t,n++,e.value)}))},e}(G);function nt(){return et||(et=new $([]))}function it(t){var e=ut(t);if(e)return e.fromEntrySeq();if("object"==typeof t)return new tt(t);throw new TypeError("Expected Array or collection object of [k, v] entries, or keyed object: "+t)}function ot(t){var e=ut(t);if(e)return e;throw new TypeError("Expected Array or collection object of values: "+t)}function ut(t){return Q(t)?new $(t):N(t)?new rt(t):void 0}var st="@@__IMMUTABLE_MAP__@@";function at(t){return Boolean(t&&t[st])}function ct(t){return at(t)&&k(t)}function ft(t){return Boolean(t&&"function"==typeof t.equals&&"function"==typeof t.hashCode)}function ht(t,e){if(t===e||t!=t&&e!=e)return!0;if(!t||!e)return!1;if("function"==typeof t.valueOf&&"function"==typeof e.valueOf){if((t=t.valueOf())===(e=e.valueOf())||t!=t&&e!=e)return!0;if(!t||!e)return!1}return!!(ft(t)&&ft(e)&&t.equals(e))}var pt="function"==typeof Math.imul&&-2===Math.imul(4294967295,2)?Math.imul:function(t,e){var r=65535&(t|=0),n=65535&(e|=0);return r*n+((t>>>16)*n+r*(e>>>16)<<16>>>0)|0};function _t(t){return t>>>1&1073741824|3221225471&t}var lt=Object.prototype.valueOf;function vt(t){if(null==t)return yt(t);if("function"==typeof t.hashCode)return _t(t.hashCode(t));var e,r=(e=t).valueOf!==lt&&"function"==typeof e.valueOf?e.valueOf(e):e;if(null==r)return yt(r);switch(typeof r){case"boolean":return r?1108378657:1108378656;case"number":return function(t){if(t!=t||t===1/0)return 0;var e=0|t;e!==t&&(e^=4294967295*t);for(;t>4294967295;)e^=t/=4294967295;return _t(e)}(r);case"string":return r.length>Et?function(t){var e=Mt[t];void 0===e&&(e=dt(t),jt===qt&&(jt=0,Mt={}),jt++,Mt[t]=e);return e}(r):dt(r);case"object":case"function":return function(t){var e;if(St&&void 0!==(e=zt.get(t)))return e;if(e=t[Ot],void 0!==e)return e;if(!wt){if(void 0!==(e=t.propertyIsEnumerable&&t.propertyIsEnumerable[Ot]))return e;if(void 0!==(e=function(t){if(t&&t.nodeType>0)switch(t.nodeType){case 1:return t.uniqueID;case 9:return t.documentElement&&t.documentElement.uniqueID}}(t)))return e}if(e=mt(),St)zt.set(t,e);else{if(void 0!==gt&&!1===gt(t))throw new Error("Non-extensible objects are not allowed as keys.");if(wt)Object.defineProperty(t,Ot,{enumerable:!1,configurable:!1,writable:!1,value:e});else if(void 0!==t.propertyIsEnumerable&&t.propertyIsEnumerable===t.constructor.prototype.propertyIsEnumerable)t.propertyIsEnumerable=function(){return this.constructor.prototype.propertyIsEnumerable.apply(this,arguments)},t.propertyIsEnumerable[Ot]=e;else{if(void 0===t.nodeType)throw new Error("Unable to set a non-enumerable property on object.");t[Ot]=e}}return e}(r);case"symbol":return function(t){var e=bt[t];if(void 0!==e)return e;return e=mt(),bt[t]=e,e}(r);default:if("function"==typeof r.toString)return dt(r.toString());throw new Error("Value type "+typeof r+" cannot be hashed.")}}function yt(t){return null===t?1108378658:1108378659}function dt(t){for(var e=0,r=0;r=0&&(a.get=function(e,r){return(e=c(this,e))>=0&&eo)return{value:void 0,done:!0};var t=i.next();return n||e===U||t.done?t:P(e,a-1,e===R?void 0:t.value[1],t)}))},a}function Lt(t,e,r,n){var i=Qt(t);return i.__iterateUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterate(i,o);var s=!0,a=0;return t.__iterate((function(t,o,c){if(!s||!(s=e.call(r,t,o,c)))return a++,i(t,n?o:a-1,u)})),a},i.__iteratorUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterator(i,o);var s=t.__iterator(T,o),a=!0,c=0;return new C((function(){var t,o,f;do{if((t=s.next()).done)return n||i===U?t:P(i,c++,i===R?void 0:t.value[1],t);var h=t.value;o=h[0],f=h[1],a&&(a=e.call(r,f,o,u))}while(a);return i===T?t:P(i,o,f,t)}))},i}function Ct(t,e,r){var n=Qt(t);return n.__iterateUncached=function(i,o){if(o)return this.cacheResult().__iterate(i,o);var u=0,s=!1;return function t(a,c){a.__iterate((function(o,a){return(!e||c0}function Ht(t,e,r,n){var i=Qt(t),o=new $(r).map((function(t){return t.size}));return i.size=n?o.max():o.min(),i.__iterate=function(t,e){for(var r,n=this.__iterator(U,e),i=0;!(r=n.next()).done&&!1!==t(r.value,i++,this););return i},i.__iteratorUncached=function(t,i){var o=r.map((function(t){return t=b(t),J(i?t.reverse():t)})),u=0,s=!1;return new C((function(){var r;return s||(r=o.map((function(t){return t.next()})),s=n?r.every((function(t){return t.done})):r.some((function(t){return t.done}))),s?{value:void 0,done:!0}:P(t,u++,e.apply(null,r.map((function(t){return t.value}))))}))},i}function Jt(t,e){return t===e?t:j(t)?e:t.constructor(e)}function Vt(t){if(t!==Object(t))throw new TypeError("Expected [K, V] tuple: "+t)}function Yt(t){return w(t)?I:z(t)?O:E}function Qt(t){return Object.create((w(t)?F:z(t)?G:Z).prototype)}function Xt(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size,this):X.prototype.cacheResult.call(this)}function Ft(t,e){return void 0===t&&void 0===e?0:void 0===t?1:void 0===e?-1:t>e?1:t0;)e[r]=arguments[r+1];if("function"!=typeof t)throw new TypeError("Invalid merger function: "+t);return ze(this,e,t)}function ze(t,e,r){for(var n=[],i=0;i0;)e[r]=arguments[r+1];return Se(this,e,t)}function Ee(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return fe(this,t,He(),(function(t){return be(t,e)}))}function qe(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return fe(this,t,He(),(function(t){return Se(t,e)}))}function je(t){var e=this.asMutable();return t(e),e.wasAltered()?e.__ensureOwner(this.__ownerID):this}function Me(){return this.__ownerID?this:this.__ensureOwner(new s)}function De(){return this.__ensureOwner()}function xe(){return this.__altered}var Ae=function(t){function e(e){return null==e?He():at(e)&&!k(e)?e:He().withMutations((function(r){var n=t(e);$t(n.size),n.forEach((function(t,e){return r.set(e,t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toString=function(){return this.__toString("Map {","}")},e.prototype.get=function(t,e){return this._root?this._root.get(0,void 0,t,e):e},e.prototype.set=function(t,e){return Je(this,t,e)},e.prototype.remove=function(t){return Je(this,t,o)},e.prototype.deleteAll=function(t){var e=b(t);return 0===e.size?this:this.withMutations((function(t){e.forEach((function(e){return t.remove(e)}))}))},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):He()},e.prototype.sort=function(t){return vr(Pt(this,t))},e.prototype.sortBy=function(t,e){return vr(Pt(this,e,t))},e.prototype.map=function(t,e){var r=this;return this.withMutations((function(n){n.forEach((function(i,o){n.set(o,t.call(e,i,o,r))}))}))},e.prototype.__iterator=function(t,e){return new Ce(this,t,e)},e.prototype.__iterate=function(t,e){var r=this,n=0;return this._root&&this._root.iterate((function(e){return n++,t(e[1],e[0],r)}),e),n},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Ne(this.size,this._root,t,this.__hash):0===this.size?He():(this.__ownerID=t,this.__altered=!1,this)},e}(I);Ae.isMap=at;var ke=Ae.prototype;ke[st]=!0,ke[e]=ke.remove,ke.removeAll=ke.deleteAll,ke.setIn=_e,ke.removeIn=ke.deleteIn=ve,ke.update=de,ke.updateIn=ge,ke.merge=ke.concat=we,ke.mergeWith=me,ke.mergeDeep=Ie,ke.mergeDeepWith=Oe,ke.mergeIn=Ee,ke.mergeDeepIn=qe,ke.withMutations=je,ke.wasAltered=xe,ke.asImmutable=De,ke["@@transducer/init"]=ke.asMutable=Me,ke["@@transducer/step"]=function(t,e){return t.set(e[0],e[1])},ke["@@transducer/result"]=function(t){return t.asImmutable()};var Re=function(t,e){this.ownerID=t,this.entries=e};Re.prototype.get=function(t,e,r,n){for(var i=this.entries,o=0,u=i.length;o=Ge)return function(t,e,r,n){t||(t=new s);for(var i=new Ke(t,vt(r),[r,n]),o=0;o>>t)&i),s=this.bitmap;return 0==(s&u)?o:this.nodes[Xe(s&u-1)].get(t+r,e,n,o)},Ue.prototype.update=function(t,e,u,s,a,c,f){void 0===u&&(u=vt(s));var h=(0===e?u:u>>>e)&i,p=1<=Ze)return function(t,e,r,i,o){for(var u=0,s=new Array(n),a=0;0!==r;a++,r>>>=1)s[a]=1&r?e[u++]:void 0;return s[i]=o,new Te(t,u+1,s)}(t,y,_,h,g);if(l&&!g&&2===y.length&&Ye(y[1^v]))return y[1^v];if(l&&g&&1===y.length&&Ye(g))return g;var w=t&&t===this.ownerID,m=l?g?_:_^p:_|p,z=l?g?Fe(y,v,g,w):function(t,e,r){var n=t.length-1;if(r&&e===n)return t.pop(),t;for(var i=new Array(n),o=0,u=0;u>>t)&i,s=this.nodes[u];return s?s.get(t+r,e,n,o):o},Te.prototype.update=function(t,e,n,u,s,a,c){void 0===n&&(n=vt(u));var f=(0===e?n:n>>>e)&i,h=s===o,p=this.nodes,_=p[f];if(h&&!_)return this;var l=Ve(_,t,e+r,n,u,s,a,c);if(l===_)return this;var v=this.count;if(_){if(!l&&--v<$e)return function(t,e,r,n){for(var i=0,o=0,u=new Array(r),s=0,a=1,c=e.length;s>>n)&i,c=(0===n?o:o>>>n)&i,f=a===c?[Qe(t,e,n+r,o,u)]:(s=new Ke(e,o,u),a>1&1431655765))+(t>>2&858993459))+(t>>4)&252645135,t+=t>>8,127&(t+=t>>16)}function Fe(t,e,r,n){var i=n?t:Gt(t);return i[e]=r,i}var Ge=n/4,Ze=n/2,$e=n/4,tr="@@__IMMUTABLE_LIST__@@";function er(t){return Boolean(t&&t[tr])}var rr=function(t){function e(e){var i=ar();if(null==e)return i;if(er(e))return e;var o=t(e),u=o.size;return 0===u?i:($t(u),u>0&&u=0&&t=t.size||e<0)return t.withMutations((function(t){e<0?pr(t,e).set(0,r):pr(t,0,e+1).set(e,r)}));e+=t._origin;var n=t._tail,i=t._root,o={value:!1};e>=_r(t._capacity)?n=cr(n,t.__ownerID,0,e,r,o):i=cr(i,t.__ownerID,t._level,e,r,o);if(!o.value)return t;if(t.__ownerID)return t._root=i,t._tail=n,t.__hash=void 0,t.__altered=!0,t;return sr(t._origin,t._capacity,t._level,i,n)}(this,t,e)},e.prototype.remove=function(t){return this.has(t)?0===t?this.shift():t===this.size-1?this.pop():this.splice(t,1):this},e.prototype.insert=function(t,e){return this.splice(t,0,e)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=this._origin=this._capacity=0,this._level=r,this._root=this._tail=this.__hash=void 0,this.__altered=!0,this):ar()},e.prototype.push=function(){var t=arguments,e=this.size;return this.withMutations((function(r){pr(r,0,e+t.length);for(var n=0;n>>e&i;if(o>=this.array.length)return new ir([],t);var u,s=0===o;if(e>0){var a=this.array[o];if((u=a&&a.removeBefore(t,e-r,n))===a&&s)return this}if(s&&!u)return this;var c=fr(this,t);if(!s)for(var f=0;f>>e&i;if(s>=this.array.length)return this;if(e>0){var a=this.array[s];if((u=a&&a.removeAfter(t,e-r,o))===a&&s===this.array.length-1)return this}var c=fr(this,t);return c.array.splice(s+1),u&&(c.array[s]=u),c};var or={};function ur(t,e){var i=t._origin,o=t._capacity,u=_r(o),s=t._tail;return a(t._root,t._level,0);function a(t,c,f){return 0===c?function(t,r){var a=r===u?s&&s.array:t&&t.array,c=r>i?0:i-r,f=o-r;f>n&&(f=n);return function(){if(c===f)return or;var t=e?--f:c++;return a&&a[t]}}(t,f):function(t,u,s){var c,f=t&&t.array,h=s>i?0:i-s>>u,p=1+(o-s>>u);p>n&&(p=n);return function(){for(;;){if(c){var t=c();if(t!==or)return t;c=null}if(h===p)return or;var n=e?--p:h++;c=a(f&&f[n],u-r,s+(n<>>n&i,h=t&&f0){var p=t&&t.array[f],_=cr(p,e,n-r,o,s,a);return _===p?t:((c=fr(t,e)).array[f]=_,c)}return h&&t.array[f]===s?t:(a&&u(a),c=fr(t,e),void 0===s&&f===c.array.length-1?c.array.pop():c.array[f]=s,c)}function fr(t,e){return e&&t&&e===t.ownerID?t:new ir(t?t.array.slice():[],e)}function hr(t,e){if(e>=_r(t._capacity))return t._tail;if(e<1<0;)n=n.array[e>>>o&i],o-=r;return n}}function pr(t,e,n){void 0!==e&&(e|=0),void 0!==n&&(n|=0);var o=t.__ownerID||new s,u=t._origin,a=t._capacity,c=u+e,f=void 0===n?a:n<0?a+n:u+n;if(c===u&&f===a)return t;if(c>=f)return t.clear();for(var h=t._level,p=t._root,_=0;c+_<0;)p=new ir(p&&p.array.length?[void 0,p]:[],o),_+=1<<(h+=r);_&&(c+=_,u+=_,f+=_,a+=_);for(var l=_r(a),v=_r(f);v>=1<l?new ir([],o):y;if(y&&v>l&&cr;w-=r){var m=l>>>w&i;g=g.array[m]=fr(g.array[m],o)}g.array[l>>>r&i]=y}if(f=v)c-=v,f-=v,h=r,p=null,d=d&&d.removeBefore(o,0,c);else if(c>u||v>>h&i;if(z!==v>>>h&i)break;z&&(_+=(1<u&&(p=p.removeBefore(o,h,c-_)),p&&v>>r<=n&&a.size>=2*s.size?(i=(u=a.filter((function(t,e){return void 0!==t&&c!==e}))).toKeyedSeq().map((function(t){return t[0]})).flip().toMap(),t.__ownerID&&(i.__ownerID=u.__ownerID=t.__ownerID)):(i=s.remove(e),u=c===a.size-1?a.pop():a.set(c,void 0))}else if(f){if(r===a.get(c)[1])return t;i=s,u=a.set(c,[e,r])}else i=s.set(e,a.size),u=a.set(a.size,[e,r]);return t.__ownerID?(t.size=i.size,t._map=i,t._list=u,t.__hash=void 0,t.__altered=!0,t):yr(i,u)}vr.isOrderedMap=ct,vr.prototype[A]=!0,vr.prototype[e]=vr.prototype.remove;var wr="@@__IMMUTABLE_STACK__@@";function mr(t){return Boolean(t&&t[wr])}var zr=function(t){function e(t){return null==t?Or():mr(t)?t:Or().pushAll(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("Stack [","]")},e.prototype.get=function(t,e){var r=this._head;for(t=c(this,t);r&&t--;)r=r.next;return r?r.value:e},e.prototype.peek=function(){return this._head&&this._head.value},e.prototype.push=function(){var t=arguments;if(0===arguments.length)return this;for(var e=this.size+arguments.length,r=this._head,n=arguments.length-1;n>=0;n--)r={value:t[n],next:r};return this.__ownerID?(this.size=e,this._head=r,this.__hash=void 0,this.__altered=!0,this):Ir(e,r)},e.prototype.pushAll=function(e){if(0===(e=t(e)).size)return this;if(0===this.size&&mr(e))return e;$t(e.size);var r=this.size,n=this._head;return e.__iterate((function(t){r++,n={value:t,next:n}}),!0),this.__ownerID?(this.size=r,this._head=n,this.__hash=void 0,this.__altered=!0,this):Ir(r,n)},e.prototype.pop=function(){return this.slice(1)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):Or()},e.prototype.slice=function(e,r){if(h(e,r,this.size))return this;var n=p(e,this.size);if(_(r,this.size)!==this.size)return t.prototype.slice.call(this,e,r);for(var i=this.size-n,o=this._head;n--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):Ir(i,o)},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Ir(this.size,this._head,t,this.__hash):0===this.size?Or():(this.__ownerID=t,this.__altered=!1,this)},e.prototype.__iterate=function(t,e){var r=this;if(e)return new $(this.toArray()).__iterate((function(e,n){return t(e,n,r)}),e);for(var n=0,i=this._head;i&&!1!==t(i.value,n++,this);)i=i.next;return n},e.prototype.__iterator=function(t,e){if(e)return new $(this.toArray()).__iterator(t,e);var r=0,n=this._head;return new C((function(){if(n){var e=n.value;return n=n.next,P(t,r++,e)}return{value:void 0,done:!0}}))},e}(O);zr.isStack=mr;var Sr,br=zr.prototype;function Ir(t,e,r,n){var i=Object.create(br);return i.size=t,i._head=e,i.__ownerID=r,i.__hash=n,i.__altered=!1,i}function Or(){return Sr||(Sr=Ir(0))}br[wr]=!0,br.shift=br.pop,br.unshift=br.push,br.unshiftAll=br.pushAll,br.withMutations=je,br.wasAltered=xe,br.asImmutable=De,br["@@transducer/init"]=br.asMutable=Me,br["@@transducer/step"]=function(t,e){return t.unshift(e)},br["@@transducer/result"]=function(t){return t.asImmutable()};var Er="@@__IMMUTABLE_SET__@@";function qr(t){return Boolean(t&&t[Er])}function jr(t){return qr(t)&&k(t)}function Mr(t,e){if(t===e)return!0;if(!d(e)||void 0!==t.size&&void 0!==e.size&&t.size!==e.size||void 0!==t.__hash&&void 0!==e.__hash&&t.__hash!==e.__hash||w(t)!==w(e)||z(t)!==z(e)||k(t)!==k(e))return!1;if(0===t.size&&0===e.size)return!0;var r=!S(t);if(k(t)){var n=t.entries();return e.every((function(t,e){var i=n.next().value;return i&&ht(i[1],t)&&(r||ht(i[0],e))}))&&n.next().done}var i=!1;if(void 0===t.size)if(void 0===e.size)"function"==typeof t.cacheResult&&t.cacheResult();else{i=!0;var u=t;t=e,e=u}var s=!0,a=e.__iterate((function(e,n){if(r?!t.has(e):i?!ht(e,t.get(n,o)):!ht(t.get(n,o),e))return s=!1,!1}));return s&&t.size===a}function Dr(t,e){var r=function(r){t.prototype[r]=e[r]};return Object.keys(e).forEach(r),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(e).forEach(r),t}function xr(t){if(!t||"object"!=typeof t)return t;if(!d(t)){if(!ne(t))return t;t=X(t)}if(w(t)){var e={};return t.__iterate((function(t,r){e[r]=xr(t)})),e}var r=[];return t.__iterate((function(t){r.push(xr(t))})),r}var Ar=function(t){function e(e){return null==e?Br():qr(e)&&!k(e)?e:Br().withMutations((function(r){var n=t(e);$t(n.size),n.forEach((function(t){return r.add(t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(I(t).keySeq())},e.intersect=function(t){return(t=b(t).toArray()).length?Rr.intersect.apply(e(t.pop()),t):Br()},e.union=function(t){return(t=b(t).toArray()).length?Rr.union.apply(e(t.pop()),t):Br()},e.prototype.toString=function(){return this.__toString("Set {","}")},e.prototype.has=function(t){return this._map.has(t)},e.prototype.add=function(t){return Ur(this,this._map.set(t,t))},e.prototype.remove=function(t){return Ur(this,this._map.remove(t))},e.prototype.clear=function(){return Ur(this,this._map.clear())},e.prototype.map=function(t,e){var r=this,n=!1,i=Ur(this,this._map.mapEntries((function(i){var o=i[1],u=t.call(e,o,o,r);return u!==o&&(n=!0),[u,u]}),e));return n?i:this},e.prototype.union=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return 0===(e=e.filter((function(t){return 0!==t.size}))).length?this:0!==this.size||this.__ownerID||1!==e.length?this.withMutations((function(r){for(var n=0;n=0&&e=0&&r>>-15,461845907),e=pt(e<<13|e>>>-13,5),e=pt((e=(e+3864292196|0)^t)^e>>>16,2246822507),e=_t((e=pt(e^e>>>13,3266489909))^e>>>16)}(t.size,n)}(this))}});var Hr=b.prototype;Hr[y]=!0,Hr[L]=Hr.values,Hr.toJSON=Hr.toArray,Hr.__toStringMapper=ie,Hr.inspect=Hr.toSource=function(){return this.toString()},Hr.chain=Hr.flatMap,Hr.contains=Hr.includes,Dr(I,{flip:function(){return Jt(this,Rt(this))},mapEntries:function(t,e){var r=this,n=0;return Jt(this,this.toSeq().map((function(i,o){return t.call(e,[o,i],n++,r)})).fromEntrySeq())},mapKeys:function(t,e){var r=this;return Jt(this,this.toSeq().flip().map((function(n,i){return t.call(e,n,i,r)})).flip())}});var Jr=I.prototype;Jr[g]=!0,Jr[L]=Hr.entries,Jr.toJSON=Nr,Jr.__toStringMapper=function(t,e){return ie(e)+": "+ie(t)},Dr(O,{toKeyedSeq:function(){return new Dt(this,!1)},filter:function(t,e){return Jt(this,Bt(this,t,e,!1))},findIndex:function(t,e){var r=this.findEntry(t,e);return r?r[0]:-1},indexOf:function(t){var e=this.keyOf(t);return void 0===e?-1:e},lastIndexOf:function(t){var e=this.lastKeyOf(t);return void 0===e?-1:e},reverse:function(){return Jt(this,Tt(this,!1))},slice:function(t,e){return Jt(this,Kt(this,t,e,!1))},splice:function(t,e){var r=arguments.length;if(e=Math.max(e||0,0),0===r||2===r&&!e)return this;t=p(t,t<0?this.count():this.size);var n=this.slice(0,t);return Jt(this,1===r?n:n.concat(Gt(arguments,2),this.slice(t+e)))},findLastIndex:function(t,e){var r=this.findLastEntry(t,e);return r?r[0]:-1},first:function(t){return this.get(0,t)},flatten:function(t){return Jt(this,Ct(this,t,!1))},get:function(t,e){return(t=c(this,t))<0||this.size===1/0||void 0!==this.size&&t>this.size?e:this.find((function(e,r){return r===t}),void 0,e)},has:function(t){return(t=c(this,t))>=0&&(void 0!==this.size?this.size===1/0||te?-1:0}function en(t,e){return t^e+2654435769+(t<<6)+(t>>2)|0}Yr.has=Hr.includes,Yr.contains=Yr.includes,Yr.keys=Yr.values,Dr(F,Jr),Dr(G,Vr),Dr(Z,Yr);var rn=function(t){function e(t){return null==t?sn():jr(t)?t:sn().withMutations((function(e){var r=E(t);$t(r.size),r.forEach((function(t){return e.add(t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(I(t).keySeq())},e.prototype.toString=function(){return this.__toString("OrderedSet {","}")},e}(Ar);rn.isOrderedSet=jr;var nn,on=rn.prototype;function un(t,e){var r=Object.create(on);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function sn(){return nn||(nn=un(dr()))}on[A]=!0,on.zip=Vr.zip,on.zipWith=Vr.zipWith,on.zipAll=Vr.zipAll,on.__empty=sn,on.__make=un;var an=function(t,e){var r;!function(t){if(D(t))throw new Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(x(t))throw new Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(null===t||"object"!=typeof t)throw new Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}(t);var n=function(o){var u=this;if(o instanceof n)return o;if(!(this instanceof n))return new n(o);if(!r){r=!0;var s=Object.keys(t),a=i._indices={};i._name=e,i._keys=s,i._defaultValues=t;for(var c=0;c2?[]:void 0,{"":t})},t.get=ue,t.getIn=Cr,t.has=oe,t.hasIn=Wr,t.hash=vt,t.is=ht,t.isAssociative=S,t.isCollection=d,t.isImmutable=x,t.isIndexed=z,t.isKeyed=w,t.isList=er,t.isMap=at,t.isOrdered=k,t.isOrderedMap=ct,t.isOrderedSet=jr,t.isPlainObject=re,t.isRecord=D,t.isSeq=j,t.isSet=qr,t.isStack=mr,t.isValueObject=ft,t.merge=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return be(t,e)},t.mergeDeep=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Se(t,e)},t.mergeDeepWith=function(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];return Se(e,r,t)},t.mergeWith=function(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];return be(e,r,t)},t.remove=ae,t.removeIn=le,t.set=ce,t.setIn=pe,t.update=ye,t.updateIn=fe,t.version="5.0.2"})); From 27dfd5d0488f1de9d10410e53e45a0370f295ebe Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 19 Nov 2024 14:50:22 +0000 Subject: [PATCH 219/242] deploy: b3a1c9f13880048d744366ae561c39a34b26190a --- bower.json | 2 +- dist/immutable.es.js | 2 +- dist/immutable.js | 2 +- dist/immutable.min.js | 2 +- package.json | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/bower.json b/bower.json index 2976df5118..0eda1b7fa3 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "immutable", - "version": "5.0.2", + "version": "5.0.3", "description": "Immutable Data Collections", "license": "MIT", "homepage": "https://immutable-js.com", diff --git a/dist/immutable.es.js b/dist/immutable.es.js index 59afaac5f1..3a88af83db 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -5928,7 +5928,7 @@ function defaultConverter(k, v) { return isIndexed(v) ? v.toList() : isKeyed(v) ? v.toMap() : v.toSet(); } -var version = "5.0.2"; +var version = "5.0.3"; // Note: Iterable is deprecated var Iterable = Collection; diff --git a/dist/immutable.js b/dist/immutable.js index a64280baa8..9e47325888 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -5934,7 +5934,7 @@ return isIndexed(v) ? v.toList() : isKeyed(v) ? v.toMap() : v.toSet(); } - var version = "5.0.2"; + var version = "5.0.3"; // Note: Iterable is deprecated var Iterable = Collection; diff --git a/dist/immutable.min.js b/dist/immutable.min.js index 1e0ec159dd..291efde457 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -22,4 +22,4 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).Immutable={})}(this,(function(t){"use strict";var e="delete",r=5,n=1<>>0;if(""+r!==e||4294967295===r)return NaN;e=r}return e<0?a(t)+e:e}function f(){return!0}function h(t,e,r){return(0===t&&!v(t)||void 0!==r&&t<=-r)&&(void 0===e||void 0!==r&&e>=r)}function p(t,e){return l(t,e,0)}function _(t,e){return l(t,e,e)}function l(t,e,r){return void 0===t?r:v(t)?e===1/0?e:0|Math.max(0,e+t):void 0===e||e===t?t:0|Math.min(e,t)}function v(t){return t<0||0===t&&1/t==-1/0}var y="@@__IMMUTABLE_ITERABLE__@@";function d(t){return Boolean(t&&t[y])}var g="@@__IMMUTABLE_KEYED__@@";function w(t){return Boolean(t&&t[g])}var m="@@__IMMUTABLE_INDEXED__@@";function z(t){return Boolean(t&&t[m])}function S(t){return w(t)||z(t)}var b=function(t){return d(t)?t:X(t)},I=function(t){function e(t){return w(t)?t:F(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(b),O=function(t){function e(t){return z(t)?t:G(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(b),E=function(t){function e(t){return d(t)&&!S(t)?t:Z(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(b);b.Keyed=I,b.Indexed=O,b.Set=E;var q="@@__IMMUTABLE_SEQ__@@";function j(t){return Boolean(t&&t[q])}var M="@@__IMMUTABLE_RECORD__@@";function D(t){return Boolean(t&&t[M])}function x(t){return d(t)||D(t)}var A="@@__IMMUTABLE_ORDERED__@@";function k(t){return Boolean(t&&t[A])}var R=0,U=1,T=2,B="function"==typeof Symbol&&Symbol.iterator,K="@@iterator",L=B||K,C=function(t){this.next=t};function P(t,e,r,n){var i=0===t?e:1===t?r:[e,r];return n?n.value=i:n={value:i,done:!1},n}function W(){return{value:void 0,done:!0}}function N(t){return!!Array.isArray(t)||!!V(t)}function H(t){return t&&"function"==typeof t.next}function J(t){var e=V(t);return e&&e.call(t)}function V(t){var e=t&&(B&&t[B]||t[K]);if("function"==typeof e)return e}C.prototype.toString=function(){return"[Iterator]"},C.KEYS=R,C.VALUES=U,C.ENTRIES=T,C.prototype.inspect=C.prototype.toSource=function(){return this.toString()},C.prototype[L]=function(){return this};var Y=Object.prototype.hasOwnProperty;function Q(t){return!(!Array.isArray(t)&&"string"!=typeof t)||t&&"object"==typeof t&&Number.isInteger(t.length)&&t.length>=0&&(0===t.length?1===Object.keys(t).length:t.hasOwnProperty(t.length-1))}var X=function(t){function e(t){return null==t?nt():x(t)?t.toSeq():function(t){var e=ut(t);if(e)return(n=V(r=t))&&n===r.entries?e.fromEntrySeq():function(t){var e=V(t);return e&&e===t.keys}(t)?e.toSetSeq():e;var r,n;if("object"==typeof t)return new tt(t);throw new TypeError("Expected Array or collection object of values, or keyed object: "+t)}(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq {","}")},e.prototype.cacheResult=function(){return!this._cache&&this.__iterateUncached&&(this._cache=this.entrySeq().toArray(),this.size=this._cache.length),this},e.prototype.__iterate=function(t,e){var r=this._cache;if(r){for(var n=r.length,i=0;i!==n;){var o=r[e?n-++i:i++];if(!1===t(o[1],o[0],this))break}return i}return this.__iterateUncached(t,e)},e.prototype.__iterator=function(t,e){var r=this._cache;if(r){var n=r.length,i=0;return new C((function(){if(i===n)return{value:void 0,done:!0};var o=r[e?n-++i:i++];return P(t,o[0],o[1])}))}return this.__iteratorUncached(t,e)},e}(b),F=function(t){function e(t){return null==t?nt().toKeyedSeq():d(t)?w(t)?t.toSeq():t.fromEntrySeq():D(t)?t.toSeq():it(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toKeyedSeq=function(){return this},e}(X),G=function(t){function e(t){return null==t?nt():d(t)?w(t)?t.entrySeq():t.toIndexedSeq():D(t)?t.toSeq().entrySeq():ot(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return e(arguments)},e.prototype.toIndexedSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq [","]")},e}(X),Z=function(t){function e(t){return(d(t)&&!S(t)?t:G(t)).toSetSeq()}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return e(arguments)},e.prototype.toSetSeq=function(){return this},e}(X);X.isSeq=j,X.Keyed=F,X.Set=Z,X.Indexed=G,X.prototype[q]=!0;var $=function(t){function e(t){this._array=t,this.size=t.length}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t,e){return this.has(t)?this._array[c(this,t)]:e},e.prototype.__iterate=function(t,e){for(var r=this._array,n=r.length,i=0;i!==n;){var o=e?n-++i:i++;if(!1===t(r[o],o,this))break}return i},e.prototype.__iterator=function(t,e){var r=this._array,n=r.length,i=0;return new C((function(){if(i===n)return{value:void 0,done:!0};var o=e?n-++i:i++;return P(t,o,r[o])}))},e}(G),tt=function(t){function e(t){var e=Object.keys(t).concat(Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(t):[]);this._object=t,this._keys=e,this.size=e.length}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t,e){return void 0===e||this.has(t)?this._object[t]:e},e.prototype.has=function(t){return Y.call(this._object,t)},e.prototype.__iterate=function(t,e){for(var r=this._object,n=this._keys,i=n.length,o=0;o!==i;){var u=n[e?i-++o:o++];if(!1===t(r[u],u,this))break}return o},e.prototype.__iterator=function(t,e){var r=this._object,n=this._keys,i=n.length,o=0;return new C((function(){if(o===i)return{value:void 0,done:!0};var u=n[e?i-++o:o++];return P(t,u,r[u])}))},e}(F);tt.prototype[A]=!0;var et,rt=function(t){function e(t){this._collection=t,this.size=t.length||t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.__iterateUncached=function(t,e){if(e)return this.cacheResult().__iterate(t,e);var r=J(this._collection),n=0;if(H(r))for(var i;!(i=r.next()).done&&!1!==t(i.value,n++,this););return n},e.prototype.__iteratorUncached=function(t,e){if(e)return this.cacheResult().__iterator(t,e);var r=J(this._collection);if(!H(r))return new C(W);var n=0;return new C((function(){var e=r.next();return e.done?e:P(t,n++,e.value)}))},e}(G);function nt(){return et||(et=new $([]))}function it(t){var e=ut(t);if(e)return e.fromEntrySeq();if("object"==typeof t)return new tt(t);throw new TypeError("Expected Array or collection object of [k, v] entries, or keyed object: "+t)}function ot(t){var e=ut(t);if(e)return e;throw new TypeError("Expected Array or collection object of values: "+t)}function ut(t){return Q(t)?new $(t):N(t)?new rt(t):void 0}var st="@@__IMMUTABLE_MAP__@@";function at(t){return Boolean(t&&t[st])}function ct(t){return at(t)&&k(t)}function ft(t){return Boolean(t&&"function"==typeof t.equals&&"function"==typeof t.hashCode)}function ht(t,e){if(t===e||t!=t&&e!=e)return!0;if(!t||!e)return!1;if("function"==typeof t.valueOf&&"function"==typeof e.valueOf){if((t=t.valueOf())===(e=e.valueOf())||t!=t&&e!=e)return!0;if(!t||!e)return!1}return!!(ft(t)&&ft(e)&&t.equals(e))}var pt="function"==typeof Math.imul&&-2===Math.imul(4294967295,2)?Math.imul:function(t,e){var r=65535&(t|=0),n=65535&(e|=0);return r*n+((t>>>16)*n+r*(e>>>16)<<16>>>0)|0};function _t(t){return t>>>1&1073741824|3221225471&t}var lt=Object.prototype.valueOf;function vt(t){if(null==t)return yt(t);if("function"==typeof t.hashCode)return _t(t.hashCode(t));var e,r=(e=t).valueOf!==lt&&"function"==typeof e.valueOf?e.valueOf(e):e;if(null==r)return yt(r);switch(typeof r){case"boolean":return r?1108378657:1108378656;case"number":return function(t){if(t!=t||t===1/0)return 0;var e=0|t;e!==t&&(e^=4294967295*t);for(;t>4294967295;)e^=t/=4294967295;return _t(e)}(r);case"string":return r.length>Et?function(t){var e=Mt[t];void 0===e&&(e=dt(t),jt===qt&&(jt=0,Mt={}),jt++,Mt[t]=e);return e}(r):dt(r);case"object":case"function":return function(t){var e;if(St&&void 0!==(e=zt.get(t)))return e;if(e=t[Ot],void 0!==e)return e;if(!wt){if(void 0!==(e=t.propertyIsEnumerable&&t.propertyIsEnumerable[Ot]))return e;if(void 0!==(e=function(t){if(t&&t.nodeType>0)switch(t.nodeType){case 1:return t.uniqueID;case 9:return t.documentElement&&t.documentElement.uniqueID}}(t)))return e}if(e=mt(),St)zt.set(t,e);else{if(void 0!==gt&&!1===gt(t))throw new Error("Non-extensible objects are not allowed as keys.");if(wt)Object.defineProperty(t,Ot,{enumerable:!1,configurable:!1,writable:!1,value:e});else if(void 0!==t.propertyIsEnumerable&&t.propertyIsEnumerable===t.constructor.prototype.propertyIsEnumerable)t.propertyIsEnumerable=function(){return this.constructor.prototype.propertyIsEnumerable.apply(this,arguments)},t.propertyIsEnumerable[Ot]=e;else{if(void 0===t.nodeType)throw new Error("Unable to set a non-enumerable property on object.");t[Ot]=e}}return e}(r);case"symbol":return function(t){var e=bt[t];if(void 0!==e)return e;return e=mt(),bt[t]=e,e}(r);default:if("function"==typeof r.toString)return dt(r.toString());throw new Error("Value type "+typeof r+" cannot be hashed.")}}function yt(t){return null===t?1108378658:1108378659}function dt(t){for(var e=0,r=0;r=0&&(a.get=function(e,r){return(e=c(this,e))>=0&&eo)return{value:void 0,done:!0};var t=i.next();return n||e===U||t.done?t:P(e,a-1,e===R?void 0:t.value[1],t)}))},a}function Lt(t,e,r,n){var i=Qt(t);return i.__iterateUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterate(i,o);var s=!0,a=0;return t.__iterate((function(t,o,c){if(!s||!(s=e.call(r,t,o,c)))return a++,i(t,n?o:a-1,u)})),a},i.__iteratorUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterator(i,o);var s=t.__iterator(T,o),a=!0,c=0;return new C((function(){var t,o,f;do{if((t=s.next()).done)return n||i===U?t:P(i,c++,i===R?void 0:t.value[1],t);var h=t.value;o=h[0],f=h[1],a&&(a=e.call(r,f,o,u))}while(a);return i===T?t:P(i,o,f,t)}))},i}function Ct(t,e,r){var n=Qt(t);return n.__iterateUncached=function(i,o){if(o)return this.cacheResult().__iterate(i,o);var u=0,s=!1;return function t(a,c){a.__iterate((function(o,a){return(!e||c0}function Ht(t,e,r,n){var i=Qt(t),o=new $(r).map((function(t){return t.size}));return i.size=n?o.max():o.min(),i.__iterate=function(t,e){for(var r,n=this.__iterator(U,e),i=0;!(r=n.next()).done&&!1!==t(r.value,i++,this););return i},i.__iteratorUncached=function(t,i){var o=r.map((function(t){return t=b(t),J(i?t.reverse():t)})),u=0,s=!1;return new C((function(){var r;return s||(r=o.map((function(t){return t.next()})),s=n?r.every((function(t){return t.done})):r.some((function(t){return t.done}))),s?{value:void 0,done:!0}:P(t,u++,e.apply(null,r.map((function(t){return t.value}))))}))},i}function Jt(t,e){return t===e?t:j(t)?e:t.constructor(e)}function Vt(t){if(t!==Object(t))throw new TypeError("Expected [K, V] tuple: "+t)}function Yt(t){return w(t)?I:z(t)?O:E}function Qt(t){return Object.create((w(t)?F:z(t)?G:Z).prototype)}function Xt(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size,this):X.prototype.cacheResult.call(this)}function Ft(t,e){return void 0===t&&void 0===e?0:void 0===t?1:void 0===e?-1:t>e?1:t0;)e[r]=arguments[r+1];if("function"!=typeof t)throw new TypeError("Invalid merger function: "+t);return ze(this,e,t)}function ze(t,e,r){for(var n=[],i=0;i0;)e[r]=arguments[r+1];return Se(this,e,t)}function Ee(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return fe(this,t,He(),(function(t){return be(t,e)}))}function qe(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return fe(this,t,He(),(function(t){return Se(t,e)}))}function je(t){var e=this.asMutable();return t(e),e.wasAltered()?e.__ensureOwner(this.__ownerID):this}function Me(){return this.__ownerID?this:this.__ensureOwner(new s)}function De(){return this.__ensureOwner()}function xe(){return this.__altered}var Ae=function(t){function e(e){return null==e?He():at(e)&&!k(e)?e:He().withMutations((function(r){var n=t(e);$t(n.size),n.forEach((function(t,e){return r.set(e,t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toString=function(){return this.__toString("Map {","}")},e.prototype.get=function(t,e){return this._root?this._root.get(0,void 0,t,e):e},e.prototype.set=function(t,e){return Je(this,t,e)},e.prototype.remove=function(t){return Je(this,t,o)},e.prototype.deleteAll=function(t){var e=b(t);return 0===e.size?this:this.withMutations((function(t){e.forEach((function(e){return t.remove(e)}))}))},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):He()},e.prototype.sort=function(t){return vr(Pt(this,t))},e.prototype.sortBy=function(t,e){return vr(Pt(this,e,t))},e.prototype.map=function(t,e){var r=this;return this.withMutations((function(n){n.forEach((function(i,o){n.set(o,t.call(e,i,o,r))}))}))},e.prototype.__iterator=function(t,e){return new Ce(this,t,e)},e.prototype.__iterate=function(t,e){var r=this,n=0;return this._root&&this._root.iterate((function(e){return n++,t(e[1],e[0],r)}),e),n},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Ne(this.size,this._root,t,this.__hash):0===this.size?He():(this.__ownerID=t,this.__altered=!1,this)},e}(I);Ae.isMap=at;var ke=Ae.prototype;ke[st]=!0,ke[e]=ke.remove,ke.removeAll=ke.deleteAll,ke.setIn=_e,ke.removeIn=ke.deleteIn=ve,ke.update=de,ke.updateIn=ge,ke.merge=ke.concat=we,ke.mergeWith=me,ke.mergeDeep=Ie,ke.mergeDeepWith=Oe,ke.mergeIn=Ee,ke.mergeDeepIn=qe,ke.withMutations=je,ke.wasAltered=xe,ke.asImmutable=De,ke["@@transducer/init"]=ke.asMutable=Me,ke["@@transducer/step"]=function(t,e){return t.set(e[0],e[1])},ke["@@transducer/result"]=function(t){return t.asImmutable()};var Re=function(t,e){this.ownerID=t,this.entries=e};Re.prototype.get=function(t,e,r,n){for(var i=this.entries,o=0,u=i.length;o=Ge)return function(t,e,r,n){t||(t=new s);for(var i=new Ke(t,vt(r),[r,n]),o=0;o>>t)&i),s=this.bitmap;return 0==(s&u)?o:this.nodes[Xe(s&u-1)].get(t+r,e,n,o)},Ue.prototype.update=function(t,e,u,s,a,c,f){void 0===u&&(u=vt(s));var h=(0===e?u:u>>>e)&i,p=1<=Ze)return function(t,e,r,i,o){for(var u=0,s=new Array(n),a=0;0!==r;a++,r>>>=1)s[a]=1&r?e[u++]:void 0;return s[i]=o,new Te(t,u+1,s)}(t,y,_,h,g);if(l&&!g&&2===y.length&&Ye(y[1^v]))return y[1^v];if(l&&g&&1===y.length&&Ye(g))return g;var w=t&&t===this.ownerID,m=l?g?_:_^p:_|p,z=l?g?Fe(y,v,g,w):function(t,e,r){var n=t.length-1;if(r&&e===n)return t.pop(),t;for(var i=new Array(n),o=0,u=0;u>>t)&i,s=this.nodes[u];return s?s.get(t+r,e,n,o):o},Te.prototype.update=function(t,e,n,u,s,a,c){void 0===n&&(n=vt(u));var f=(0===e?n:n>>>e)&i,h=s===o,p=this.nodes,_=p[f];if(h&&!_)return this;var l=Ve(_,t,e+r,n,u,s,a,c);if(l===_)return this;var v=this.count;if(_){if(!l&&--v<$e)return function(t,e,r,n){for(var i=0,o=0,u=new Array(r),s=0,a=1,c=e.length;s>>n)&i,c=(0===n?o:o>>>n)&i,f=a===c?[Qe(t,e,n+r,o,u)]:(s=new Ke(e,o,u),a>1&1431655765))+(t>>2&858993459))+(t>>4)&252645135,t+=t>>8,127&(t+=t>>16)}function Fe(t,e,r,n){var i=n?t:Gt(t);return i[e]=r,i}var Ge=n/4,Ze=n/2,$e=n/4,tr="@@__IMMUTABLE_LIST__@@";function er(t){return Boolean(t&&t[tr])}var rr=function(t){function e(e){var i=ar();if(null==e)return i;if(er(e))return e;var o=t(e),u=o.size;return 0===u?i:($t(u),u>0&&u=0&&t=t.size||e<0)return t.withMutations((function(t){e<0?pr(t,e).set(0,r):pr(t,0,e+1).set(e,r)}));e+=t._origin;var n=t._tail,i=t._root,o={value:!1};e>=_r(t._capacity)?n=cr(n,t.__ownerID,0,e,r,o):i=cr(i,t.__ownerID,t._level,e,r,o);if(!o.value)return t;if(t.__ownerID)return t._root=i,t._tail=n,t.__hash=void 0,t.__altered=!0,t;return sr(t._origin,t._capacity,t._level,i,n)}(this,t,e)},e.prototype.remove=function(t){return this.has(t)?0===t?this.shift():t===this.size-1?this.pop():this.splice(t,1):this},e.prototype.insert=function(t,e){return this.splice(t,0,e)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=this._origin=this._capacity=0,this._level=r,this._root=this._tail=this.__hash=void 0,this.__altered=!0,this):ar()},e.prototype.push=function(){var t=arguments,e=this.size;return this.withMutations((function(r){pr(r,0,e+t.length);for(var n=0;n>>e&i;if(o>=this.array.length)return new ir([],t);var u,s=0===o;if(e>0){var a=this.array[o];if((u=a&&a.removeBefore(t,e-r,n))===a&&s)return this}if(s&&!u)return this;var c=fr(this,t);if(!s)for(var f=0;f>>e&i;if(s>=this.array.length)return this;if(e>0){var a=this.array[s];if((u=a&&a.removeAfter(t,e-r,o))===a&&s===this.array.length-1)return this}var c=fr(this,t);return c.array.splice(s+1),u&&(c.array[s]=u),c};var or={};function ur(t,e){var i=t._origin,o=t._capacity,u=_r(o),s=t._tail;return a(t._root,t._level,0);function a(t,c,f){return 0===c?function(t,r){var a=r===u?s&&s.array:t&&t.array,c=r>i?0:i-r,f=o-r;f>n&&(f=n);return function(){if(c===f)return or;var t=e?--f:c++;return a&&a[t]}}(t,f):function(t,u,s){var c,f=t&&t.array,h=s>i?0:i-s>>u,p=1+(o-s>>u);p>n&&(p=n);return function(){for(;;){if(c){var t=c();if(t!==or)return t;c=null}if(h===p)return or;var n=e?--p:h++;c=a(f&&f[n],u-r,s+(n<>>n&i,h=t&&f0){var p=t&&t.array[f],_=cr(p,e,n-r,o,s,a);return _===p?t:((c=fr(t,e)).array[f]=_,c)}return h&&t.array[f]===s?t:(a&&u(a),c=fr(t,e),void 0===s&&f===c.array.length-1?c.array.pop():c.array[f]=s,c)}function fr(t,e){return e&&t&&e===t.ownerID?t:new ir(t?t.array.slice():[],e)}function hr(t,e){if(e>=_r(t._capacity))return t._tail;if(e<1<0;)n=n.array[e>>>o&i],o-=r;return n}}function pr(t,e,n){void 0!==e&&(e|=0),void 0!==n&&(n|=0);var o=t.__ownerID||new s,u=t._origin,a=t._capacity,c=u+e,f=void 0===n?a:n<0?a+n:u+n;if(c===u&&f===a)return t;if(c>=f)return t.clear();for(var h=t._level,p=t._root,_=0;c+_<0;)p=new ir(p&&p.array.length?[void 0,p]:[],o),_+=1<<(h+=r);_&&(c+=_,u+=_,f+=_,a+=_);for(var l=_r(a),v=_r(f);v>=1<l?new ir([],o):y;if(y&&v>l&&cr;w-=r){var m=l>>>w&i;g=g.array[m]=fr(g.array[m],o)}g.array[l>>>r&i]=y}if(f=v)c-=v,f-=v,h=r,p=null,d=d&&d.removeBefore(o,0,c);else if(c>u||v>>h&i;if(z!==v>>>h&i)break;z&&(_+=(1<u&&(p=p.removeBefore(o,h,c-_)),p&&v>>r<=n&&a.size>=2*s.size?(i=(u=a.filter((function(t,e){return void 0!==t&&c!==e}))).toKeyedSeq().map((function(t){return t[0]})).flip().toMap(),t.__ownerID&&(i.__ownerID=u.__ownerID=t.__ownerID)):(i=s.remove(e),u=c===a.size-1?a.pop():a.set(c,void 0))}else if(f){if(r===a.get(c)[1])return t;i=s,u=a.set(c,[e,r])}else i=s.set(e,a.size),u=a.set(a.size,[e,r]);return t.__ownerID?(t.size=i.size,t._map=i,t._list=u,t.__hash=void 0,t.__altered=!0,t):yr(i,u)}vr.isOrderedMap=ct,vr.prototype[A]=!0,vr.prototype[e]=vr.prototype.remove;var wr="@@__IMMUTABLE_STACK__@@";function mr(t){return Boolean(t&&t[wr])}var zr=function(t){function e(t){return null==t?Or():mr(t)?t:Or().pushAll(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("Stack [","]")},e.prototype.get=function(t,e){var r=this._head;for(t=c(this,t);r&&t--;)r=r.next;return r?r.value:e},e.prototype.peek=function(){return this._head&&this._head.value},e.prototype.push=function(){var t=arguments;if(0===arguments.length)return this;for(var e=this.size+arguments.length,r=this._head,n=arguments.length-1;n>=0;n--)r={value:t[n],next:r};return this.__ownerID?(this.size=e,this._head=r,this.__hash=void 0,this.__altered=!0,this):Ir(e,r)},e.prototype.pushAll=function(e){if(0===(e=t(e)).size)return this;if(0===this.size&&mr(e))return e;$t(e.size);var r=this.size,n=this._head;return e.__iterate((function(t){r++,n={value:t,next:n}}),!0),this.__ownerID?(this.size=r,this._head=n,this.__hash=void 0,this.__altered=!0,this):Ir(r,n)},e.prototype.pop=function(){return this.slice(1)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):Or()},e.prototype.slice=function(e,r){if(h(e,r,this.size))return this;var n=p(e,this.size);if(_(r,this.size)!==this.size)return t.prototype.slice.call(this,e,r);for(var i=this.size-n,o=this._head;n--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):Ir(i,o)},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Ir(this.size,this._head,t,this.__hash):0===this.size?Or():(this.__ownerID=t,this.__altered=!1,this)},e.prototype.__iterate=function(t,e){var r=this;if(e)return new $(this.toArray()).__iterate((function(e,n){return t(e,n,r)}),e);for(var n=0,i=this._head;i&&!1!==t(i.value,n++,this);)i=i.next;return n},e.prototype.__iterator=function(t,e){if(e)return new $(this.toArray()).__iterator(t,e);var r=0,n=this._head;return new C((function(){if(n){var e=n.value;return n=n.next,P(t,r++,e)}return{value:void 0,done:!0}}))},e}(O);zr.isStack=mr;var Sr,br=zr.prototype;function Ir(t,e,r,n){var i=Object.create(br);return i.size=t,i._head=e,i.__ownerID=r,i.__hash=n,i.__altered=!1,i}function Or(){return Sr||(Sr=Ir(0))}br[wr]=!0,br.shift=br.pop,br.unshift=br.push,br.unshiftAll=br.pushAll,br.withMutations=je,br.wasAltered=xe,br.asImmutable=De,br["@@transducer/init"]=br.asMutable=Me,br["@@transducer/step"]=function(t,e){return t.unshift(e)},br["@@transducer/result"]=function(t){return t.asImmutable()};var Er="@@__IMMUTABLE_SET__@@";function qr(t){return Boolean(t&&t[Er])}function jr(t){return qr(t)&&k(t)}function Mr(t,e){if(t===e)return!0;if(!d(e)||void 0!==t.size&&void 0!==e.size&&t.size!==e.size||void 0!==t.__hash&&void 0!==e.__hash&&t.__hash!==e.__hash||w(t)!==w(e)||z(t)!==z(e)||k(t)!==k(e))return!1;if(0===t.size&&0===e.size)return!0;var r=!S(t);if(k(t)){var n=t.entries();return e.every((function(t,e){var i=n.next().value;return i&&ht(i[1],t)&&(r||ht(i[0],e))}))&&n.next().done}var i=!1;if(void 0===t.size)if(void 0===e.size)"function"==typeof t.cacheResult&&t.cacheResult();else{i=!0;var u=t;t=e,e=u}var s=!0,a=e.__iterate((function(e,n){if(r?!t.has(e):i?!ht(e,t.get(n,o)):!ht(t.get(n,o),e))return s=!1,!1}));return s&&t.size===a}function Dr(t,e){var r=function(r){t.prototype[r]=e[r]};return Object.keys(e).forEach(r),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(e).forEach(r),t}function xr(t){if(!t||"object"!=typeof t)return t;if(!d(t)){if(!ne(t))return t;t=X(t)}if(w(t)){var e={};return t.__iterate((function(t,r){e[r]=xr(t)})),e}var r=[];return t.__iterate((function(t){r.push(xr(t))})),r}var Ar=function(t){function e(e){return null==e?Br():qr(e)&&!k(e)?e:Br().withMutations((function(r){var n=t(e);$t(n.size),n.forEach((function(t){return r.add(t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(I(t).keySeq())},e.intersect=function(t){return(t=b(t).toArray()).length?Rr.intersect.apply(e(t.pop()),t):Br()},e.union=function(t){return(t=b(t).toArray()).length?Rr.union.apply(e(t.pop()),t):Br()},e.prototype.toString=function(){return this.__toString("Set {","}")},e.prototype.has=function(t){return this._map.has(t)},e.prototype.add=function(t){return Ur(this,this._map.set(t,t))},e.prototype.remove=function(t){return Ur(this,this._map.remove(t))},e.prototype.clear=function(){return Ur(this,this._map.clear())},e.prototype.map=function(t,e){var r=this,n=!1,i=Ur(this,this._map.mapEntries((function(i){var o=i[1],u=t.call(e,o,o,r);return u!==o&&(n=!0),[u,u]}),e));return n?i:this},e.prototype.union=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return 0===(e=e.filter((function(t){return 0!==t.size}))).length?this:0!==this.size||this.__ownerID||1!==e.length?this.withMutations((function(r){for(var n=0;n=0&&e=0&&r>>-15,461845907),e=pt(e<<13|e>>>-13,5),e=pt((e=(e+3864292196|0)^t)^e>>>16,2246822507),e=_t((e=pt(e^e>>>13,3266489909))^e>>>16)}(t.size,n)}(this))}});var Hr=b.prototype;Hr[y]=!0,Hr[L]=Hr.values,Hr.toJSON=Hr.toArray,Hr.__toStringMapper=ie,Hr.inspect=Hr.toSource=function(){return this.toString()},Hr.chain=Hr.flatMap,Hr.contains=Hr.includes,Dr(I,{flip:function(){return Jt(this,Rt(this))},mapEntries:function(t,e){var r=this,n=0;return Jt(this,this.toSeq().map((function(i,o){return t.call(e,[o,i],n++,r)})).fromEntrySeq())},mapKeys:function(t,e){var r=this;return Jt(this,this.toSeq().flip().map((function(n,i){return t.call(e,n,i,r)})).flip())}});var Jr=I.prototype;Jr[g]=!0,Jr[L]=Hr.entries,Jr.toJSON=Nr,Jr.__toStringMapper=function(t,e){return ie(e)+": "+ie(t)},Dr(O,{toKeyedSeq:function(){return new Dt(this,!1)},filter:function(t,e){return Jt(this,Bt(this,t,e,!1))},findIndex:function(t,e){var r=this.findEntry(t,e);return r?r[0]:-1},indexOf:function(t){var e=this.keyOf(t);return void 0===e?-1:e},lastIndexOf:function(t){var e=this.lastKeyOf(t);return void 0===e?-1:e},reverse:function(){return Jt(this,Tt(this,!1))},slice:function(t,e){return Jt(this,Kt(this,t,e,!1))},splice:function(t,e){var r=arguments.length;if(e=Math.max(e||0,0),0===r||2===r&&!e)return this;t=p(t,t<0?this.count():this.size);var n=this.slice(0,t);return Jt(this,1===r?n:n.concat(Gt(arguments,2),this.slice(t+e)))},findLastIndex:function(t,e){var r=this.findLastEntry(t,e);return r?r[0]:-1},first:function(t){return this.get(0,t)},flatten:function(t){return Jt(this,Ct(this,t,!1))},get:function(t,e){return(t=c(this,t))<0||this.size===1/0||void 0!==this.size&&t>this.size?e:this.find((function(e,r){return r===t}),void 0,e)},has:function(t){return(t=c(this,t))>=0&&(void 0!==this.size?this.size===1/0||te?-1:0}function en(t,e){return t^e+2654435769+(t<<6)+(t>>2)|0}Yr.has=Hr.includes,Yr.contains=Yr.includes,Yr.keys=Yr.values,Dr(F,Jr),Dr(G,Vr),Dr(Z,Yr);var rn=function(t){function e(t){return null==t?sn():jr(t)?t:sn().withMutations((function(e){var r=E(t);$t(r.size),r.forEach((function(t){return e.add(t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(I(t).keySeq())},e.prototype.toString=function(){return this.__toString("OrderedSet {","}")},e}(Ar);rn.isOrderedSet=jr;var nn,on=rn.prototype;function un(t,e){var r=Object.create(on);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function sn(){return nn||(nn=un(dr()))}on[A]=!0,on.zip=Vr.zip,on.zipWith=Vr.zipWith,on.zipAll=Vr.zipAll,on.__empty=sn,on.__make=un;var an=function(t,e){var r;!function(t){if(D(t))throw new Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(x(t))throw new Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(null===t||"object"!=typeof t)throw new Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}(t);var n=function(o){var u=this;if(o instanceof n)return o;if(!(this instanceof n))return new n(o);if(!r){r=!0;var s=Object.keys(t),a=i._indices={};i._name=e,i._keys=s,i._defaultValues=t;for(var c=0;c2?[]:void 0,{"":t})},t.get=ue,t.getIn=Cr,t.has=oe,t.hasIn=Wr,t.hash=vt,t.is=ht,t.isAssociative=S,t.isCollection=d,t.isImmutable=x,t.isIndexed=z,t.isKeyed=w,t.isList=er,t.isMap=at,t.isOrdered=k,t.isOrderedMap=ct,t.isOrderedSet=jr,t.isPlainObject=re,t.isRecord=D,t.isSeq=j,t.isSet=qr,t.isStack=mr,t.isValueObject=ft,t.merge=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return be(t,e)},t.mergeDeep=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Se(t,e)},t.mergeDeepWith=function(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];return Se(e,r,t)},t.mergeWith=function(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];return be(e,r,t)},t.remove=ae,t.removeIn=le,t.set=ce,t.setIn=pe,t.update=ye,t.updateIn=fe,t.version="5.0.2"})); +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).Immutable={})}(this,(function(t){"use strict";var e="delete",r=5,n=1<>>0;if(""+r!==e||4294967295===r)return NaN;e=r}return e<0?a(t)+e:e}function f(){return!0}function h(t,e,r){return(0===t&&!v(t)||void 0!==r&&t<=-r)&&(void 0===e||void 0!==r&&e>=r)}function p(t,e){return l(t,e,0)}function _(t,e){return l(t,e,e)}function l(t,e,r){return void 0===t?r:v(t)?e===1/0?e:0|Math.max(0,e+t):void 0===e||e===t?t:0|Math.min(e,t)}function v(t){return t<0||0===t&&1/t==-1/0}var y="@@__IMMUTABLE_ITERABLE__@@";function d(t){return Boolean(t&&t[y])}var g="@@__IMMUTABLE_KEYED__@@";function w(t){return Boolean(t&&t[g])}var m="@@__IMMUTABLE_INDEXED__@@";function z(t){return Boolean(t&&t[m])}function S(t){return w(t)||z(t)}var b=function(t){return d(t)?t:X(t)},I=function(t){function e(t){return w(t)?t:F(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(b),O=function(t){function e(t){return z(t)?t:G(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(b),E=function(t){function e(t){return d(t)&&!S(t)?t:Z(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(b);b.Keyed=I,b.Indexed=O,b.Set=E;var q="@@__IMMUTABLE_SEQ__@@";function j(t){return Boolean(t&&t[q])}var M="@@__IMMUTABLE_RECORD__@@";function D(t){return Boolean(t&&t[M])}function x(t){return d(t)||D(t)}var A="@@__IMMUTABLE_ORDERED__@@";function k(t){return Boolean(t&&t[A])}var R=0,U=1,T=2,B="function"==typeof Symbol&&Symbol.iterator,K="@@iterator",L=B||K,C=function(t){this.next=t};function P(t,e,r,n){var i=0===t?e:1===t?r:[e,r];return n?n.value=i:n={value:i,done:!1},n}function W(){return{value:void 0,done:!0}}function N(t){return!!Array.isArray(t)||!!V(t)}function H(t){return t&&"function"==typeof t.next}function J(t){var e=V(t);return e&&e.call(t)}function V(t){var e=t&&(B&&t[B]||t[K]);if("function"==typeof e)return e}C.prototype.toString=function(){return"[Iterator]"},C.KEYS=R,C.VALUES=U,C.ENTRIES=T,C.prototype.inspect=C.prototype.toSource=function(){return this.toString()},C.prototype[L]=function(){return this};var Y=Object.prototype.hasOwnProperty;function Q(t){return!(!Array.isArray(t)&&"string"!=typeof t)||t&&"object"==typeof t&&Number.isInteger(t.length)&&t.length>=0&&(0===t.length?1===Object.keys(t).length:t.hasOwnProperty(t.length-1))}var X=function(t){function e(t){return null==t?nt():x(t)?t.toSeq():function(t){var e=ut(t);if(e)return(n=V(r=t))&&n===r.entries?e.fromEntrySeq():function(t){var e=V(t);return e&&e===t.keys}(t)?e.toSetSeq():e;var r,n;if("object"==typeof t)return new tt(t);throw new TypeError("Expected Array or collection object of values, or keyed object: "+t)}(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq {","}")},e.prototype.cacheResult=function(){return!this._cache&&this.__iterateUncached&&(this._cache=this.entrySeq().toArray(),this.size=this._cache.length),this},e.prototype.__iterate=function(t,e){var r=this._cache;if(r){for(var n=r.length,i=0;i!==n;){var o=r[e?n-++i:i++];if(!1===t(o[1],o[0],this))break}return i}return this.__iterateUncached(t,e)},e.prototype.__iterator=function(t,e){var r=this._cache;if(r){var n=r.length,i=0;return new C((function(){if(i===n)return{value:void 0,done:!0};var o=r[e?n-++i:i++];return P(t,o[0],o[1])}))}return this.__iteratorUncached(t,e)},e}(b),F=function(t){function e(t){return null==t?nt().toKeyedSeq():d(t)?w(t)?t.toSeq():t.fromEntrySeq():D(t)?t.toSeq():it(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toKeyedSeq=function(){return this},e}(X),G=function(t){function e(t){return null==t?nt():d(t)?w(t)?t.entrySeq():t.toIndexedSeq():D(t)?t.toSeq().entrySeq():ot(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return e(arguments)},e.prototype.toIndexedSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq [","]")},e}(X),Z=function(t){function e(t){return(d(t)&&!S(t)?t:G(t)).toSetSeq()}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return e(arguments)},e.prototype.toSetSeq=function(){return this},e}(X);X.isSeq=j,X.Keyed=F,X.Set=Z,X.Indexed=G,X.prototype[q]=!0;var $=function(t){function e(t){this._array=t,this.size=t.length}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t,e){return this.has(t)?this._array[c(this,t)]:e},e.prototype.__iterate=function(t,e){for(var r=this._array,n=r.length,i=0;i!==n;){var o=e?n-++i:i++;if(!1===t(r[o],o,this))break}return i},e.prototype.__iterator=function(t,e){var r=this._array,n=r.length,i=0;return new C((function(){if(i===n)return{value:void 0,done:!0};var o=e?n-++i:i++;return P(t,o,r[o])}))},e}(G),tt=function(t){function e(t){var e=Object.keys(t).concat(Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(t):[]);this._object=t,this._keys=e,this.size=e.length}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t,e){return void 0===e||this.has(t)?this._object[t]:e},e.prototype.has=function(t){return Y.call(this._object,t)},e.prototype.__iterate=function(t,e){for(var r=this._object,n=this._keys,i=n.length,o=0;o!==i;){var u=n[e?i-++o:o++];if(!1===t(r[u],u,this))break}return o},e.prototype.__iterator=function(t,e){var r=this._object,n=this._keys,i=n.length,o=0;return new C((function(){if(o===i)return{value:void 0,done:!0};var u=n[e?i-++o:o++];return P(t,u,r[u])}))},e}(F);tt.prototype[A]=!0;var et,rt=function(t){function e(t){this._collection=t,this.size=t.length||t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.__iterateUncached=function(t,e){if(e)return this.cacheResult().__iterate(t,e);var r=J(this._collection),n=0;if(H(r))for(var i;!(i=r.next()).done&&!1!==t(i.value,n++,this););return n},e.prototype.__iteratorUncached=function(t,e){if(e)return this.cacheResult().__iterator(t,e);var r=J(this._collection);if(!H(r))return new C(W);var n=0;return new C((function(){var e=r.next();return e.done?e:P(t,n++,e.value)}))},e}(G);function nt(){return et||(et=new $([]))}function it(t){var e=ut(t);if(e)return e.fromEntrySeq();if("object"==typeof t)return new tt(t);throw new TypeError("Expected Array or collection object of [k, v] entries, or keyed object: "+t)}function ot(t){var e=ut(t);if(e)return e;throw new TypeError("Expected Array or collection object of values: "+t)}function ut(t){return Q(t)?new $(t):N(t)?new rt(t):void 0}var st="@@__IMMUTABLE_MAP__@@";function at(t){return Boolean(t&&t[st])}function ct(t){return at(t)&&k(t)}function ft(t){return Boolean(t&&"function"==typeof t.equals&&"function"==typeof t.hashCode)}function ht(t,e){if(t===e||t!=t&&e!=e)return!0;if(!t||!e)return!1;if("function"==typeof t.valueOf&&"function"==typeof e.valueOf){if((t=t.valueOf())===(e=e.valueOf())||t!=t&&e!=e)return!0;if(!t||!e)return!1}return!!(ft(t)&&ft(e)&&t.equals(e))}var pt="function"==typeof Math.imul&&-2===Math.imul(4294967295,2)?Math.imul:function(t,e){var r=65535&(t|=0),n=65535&(e|=0);return r*n+((t>>>16)*n+r*(e>>>16)<<16>>>0)|0};function _t(t){return t>>>1&1073741824|3221225471&t}var lt=Object.prototype.valueOf;function vt(t){if(null==t)return yt(t);if("function"==typeof t.hashCode)return _t(t.hashCode(t));var e,r=(e=t).valueOf!==lt&&"function"==typeof e.valueOf?e.valueOf(e):e;if(null==r)return yt(r);switch(typeof r){case"boolean":return r?1108378657:1108378656;case"number":return function(t){if(t!=t||t===1/0)return 0;var e=0|t;e!==t&&(e^=4294967295*t);for(;t>4294967295;)e^=t/=4294967295;return _t(e)}(r);case"string":return r.length>Et?function(t){var e=Mt[t];void 0===e&&(e=dt(t),jt===qt&&(jt=0,Mt={}),jt++,Mt[t]=e);return e}(r):dt(r);case"object":case"function":return function(t){var e;if(St&&void 0!==(e=zt.get(t)))return e;if(e=t[Ot],void 0!==e)return e;if(!wt){if(void 0!==(e=t.propertyIsEnumerable&&t.propertyIsEnumerable[Ot]))return e;if(void 0!==(e=function(t){if(t&&t.nodeType>0)switch(t.nodeType){case 1:return t.uniqueID;case 9:return t.documentElement&&t.documentElement.uniqueID}}(t)))return e}if(e=mt(),St)zt.set(t,e);else{if(void 0!==gt&&!1===gt(t))throw new Error("Non-extensible objects are not allowed as keys.");if(wt)Object.defineProperty(t,Ot,{enumerable:!1,configurable:!1,writable:!1,value:e});else if(void 0!==t.propertyIsEnumerable&&t.propertyIsEnumerable===t.constructor.prototype.propertyIsEnumerable)t.propertyIsEnumerable=function(){return this.constructor.prototype.propertyIsEnumerable.apply(this,arguments)},t.propertyIsEnumerable[Ot]=e;else{if(void 0===t.nodeType)throw new Error("Unable to set a non-enumerable property on object.");t[Ot]=e}}return e}(r);case"symbol":return function(t){var e=bt[t];if(void 0!==e)return e;return e=mt(),bt[t]=e,e}(r);default:if("function"==typeof r.toString)return dt(r.toString());throw new Error("Value type "+typeof r+" cannot be hashed.")}}function yt(t){return null===t?1108378658:1108378659}function dt(t){for(var e=0,r=0;r=0&&(a.get=function(e,r){return(e=c(this,e))>=0&&eo)return{value:void 0,done:!0};var t=i.next();return n||e===U||t.done?t:P(e,a-1,e===R?void 0:t.value[1],t)}))},a}function Lt(t,e,r,n){var i=Qt(t);return i.__iterateUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterate(i,o);var s=!0,a=0;return t.__iterate((function(t,o,c){if(!s||!(s=e.call(r,t,o,c)))return a++,i(t,n?o:a-1,u)})),a},i.__iteratorUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterator(i,o);var s=t.__iterator(T,o),a=!0,c=0;return new C((function(){var t,o,f;do{if((t=s.next()).done)return n||i===U?t:P(i,c++,i===R?void 0:t.value[1],t);var h=t.value;o=h[0],f=h[1],a&&(a=e.call(r,f,o,u))}while(a);return i===T?t:P(i,o,f,t)}))},i}function Ct(t,e,r){var n=Qt(t);return n.__iterateUncached=function(i,o){if(o)return this.cacheResult().__iterate(i,o);var u=0,s=!1;return function t(a,c){a.__iterate((function(o,a){return(!e||c0}function Ht(t,e,r,n){var i=Qt(t),o=new $(r).map((function(t){return t.size}));return i.size=n?o.max():o.min(),i.__iterate=function(t,e){for(var r,n=this.__iterator(U,e),i=0;!(r=n.next()).done&&!1!==t(r.value,i++,this););return i},i.__iteratorUncached=function(t,i){var o=r.map((function(t){return t=b(t),J(i?t.reverse():t)})),u=0,s=!1;return new C((function(){var r;return s||(r=o.map((function(t){return t.next()})),s=n?r.every((function(t){return t.done})):r.some((function(t){return t.done}))),s?{value:void 0,done:!0}:P(t,u++,e.apply(null,r.map((function(t){return t.value}))))}))},i}function Jt(t,e){return t===e?t:j(t)?e:t.constructor(e)}function Vt(t){if(t!==Object(t))throw new TypeError("Expected [K, V] tuple: "+t)}function Yt(t){return w(t)?I:z(t)?O:E}function Qt(t){return Object.create((w(t)?F:z(t)?G:Z).prototype)}function Xt(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size,this):X.prototype.cacheResult.call(this)}function Ft(t,e){return void 0===t&&void 0===e?0:void 0===t?1:void 0===e?-1:t>e?1:t0;)e[r]=arguments[r+1];if("function"!=typeof t)throw new TypeError("Invalid merger function: "+t);return ze(this,e,t)}function ze(t,e,r){for(var n=[],i=0;i0;)e[r]=arguments[r+1];return Se(this,e,t)}function Ee(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return fe(this,t,He(),(function(t){return be(t,e)}))}function qe(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return fe(this,t,He(),(function(t){return Se(t,e)}))}function je(t){var e=this.asMutable();return t(e),e.wasAltered()?e.__ensureOwner(this.__ownerID):this}function Me(){return this.__ownerID?this:this.__ensureOwner(new s)}function De(){return this.__ensureOwner()}function xe(){return this.__altered}var Ae=function(t){function e(e){return null==e?He():at(e)&&!k(e)?e:He().withMutations((function(r){var n=t(e);$t(n.size),n.forEach((function(t,e){return r.set(e,t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toString=function(){return this.__toString("Map {","}")},e.prototype.get=function(t,e){return this._root?this._root.get(0,void 0,t,e):e},e.prototype.set=function(t,e){return Je(this,t,e)},e.prototype.remove=function(t){return Je(this,t,o)},e.prototype.deleteAll=function(t){var e=b(t);return 0===e.size?this:this.withMutations((function(t){e.forEach((function(e){return t.remove(e)}))}))},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):He()},e.prototype.sort=function(t){return vr(Pt(this,t))},e.prototype.sortBy=function(t,e){return vr(Pt(this,e,t))},e.prototype.map=function(t,e){var r=this;return this.withMutations((function(n){n.forEach((function(i,o){n.set(o,t.call(e,i,o,r))}))}))},e.prototype.__iterator=function(t,e){return new Ce(this,t,e)},e.prototype.__iterate=function(t,e){var r=this,n=0;return this._root&&this._root.iterate((function(e){return n++,t(e[1],e[0],r)}),e),n},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Ne(this.size,this._root,t,this.__hash):0===this.size?He():(this.__ownerID=t,this.__altered=!1,this)},e}(I);Ae.isMap=at;var ke=Ae.prototype;ke[st]=!0,ke[e]=ke.remove,ke.removeAll=ke.deleteAll,ke.setIn=_e,ke.removeIn=ke.deleteIn=ve,ke.update=de,ke.updateIn=ge,ke.merge=ke.concat=we,ke.mergeWith=me,ke.mergeDeep=Ie,ke.mergeDeepWith=Oe,ke.mergeIn=Ee,ke.mergeDeepIn=qe,ke.withMutations=je,ke.wasAltered=xe,ke.asImmutable=De,ke["@@transducer/init"]=ke.asMutable=Me,ke["@@transducer/step"]=function(t,e){return t.set(e[0],e[1])},ke["@@transducer/result"]=function(t){return t.asImmutable()};var Re=function(t,e){this.ownerID=t,this.entries=e};Re.prototype.get=function(t,e,r,n){for(var i=this.entries,o=0,u=i.length;o=Ge)return function(t,e,r,n){t||(t=new s);for(var i=new Ke(t,vt(r),[r,n]),o=0;o>>t)&i),s=this.bitmap;return 0==(s&u)?o:this.nodes[Xe(s&u-1)].get(t+r,e,n,o)},Ue.prototype.update=function(t,e,u,s,a,c,f){void 0===u&&(u=vt(s));var h=(0===e?u:u>>>e)&i,p=1<=Ze)return function(t,e,r,i,o){for(var u=0,s=new Array(n),a=0;0!==r;a++,r>>>=1)s[a]=1&r?e[u++]:void 0;return s[i]=o,new Te(t,u+1,s)}(t,y,_,h,g);if(l&&!g&&2===y.length&&Ye(y[1^v]))return y[1^v];if(l&&g&&1===y.length&&Ye(g))return g;var w=t&&t===this.ownerID,m=l?g?_:_^p:_|p,z=l?g?Fe(y,v,g,w):function(t,e,r){var n=t.length-1;if(r&&e===n)return t.pop(),t;for(var i=new Array(n),o=0,u=0;u>>t)&i,s=this.nodes[u];return s?s.get(t+r,e,n,o):o},Te.prototype.update=function(t,e,n,u,s,a,c){void 0===n&&(n=vt(u));var f=(0===e?n:n>>>e)&i,h=s===o,p=this.nodes,_=p[f];if(h&&!_)return this;var l=Ve(_,t,e+r,n,u,s,a,c);if(l===_)return this;var v=this.count;if(_){if(!l&&--v<$e)return function(t,e,r,n){for(var i=0,o=0,u=new Array(r),s=0,a=1,c=e.length;s>>n)&i,c=(0===n?o:o>>>n)&i,f=a===c?[Qe(t,e,n+r,o,u)]:(s=new Ke(e,o,u),a>1&1431655765))+(t>>2&858993459))+(t>>4)&252645135,t+=t>>8,127&(t+=t>>16)}function Fe(t,e,r,n){var i=n?t:Gt(t);return i[e]=r,i}var Ge=n/4,Ze=n/2,$e=n/4,tr="@@__IMMUTABLE_LIST__@@";function er(t){return Boolean(t&&t[tr])}var rr=function(t){function e(e){var i=ar();if(null==e)return i;if(er(e))return e;var o=t(e),u=o.size;return 0===u?i:($t(u),u>0&&u=0&&t=t.size||e<0)return t.withMutations((function(t){e<0?pr(t,e).set(0,r):pr(t,0,e+1).set(e,r)}));e+=t._origin;var n=t._tail,i=t._root,o={value:!1};e>=_r(t._capacity)?n=cr(n,t.__ownerID,0,e,r,o):i=cr(i,t.__ownerID,t._level,e,r,o);if(!o.value)return t;if(t.__ownerID)return t._root=i,t._tail=n,t.__hash=void 0,t.__altered=!0,t;return sr(t._origin,t._capacity,t._level,i,n)}(this,t,e)},e.prototype.remove=function(t){return this.has(t)?0===t?this.shift():t===this.size-1?this.pop():this.splice(t,1):this},e.prototype.insert=function(t,e){return this.splice(t,0,e)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=this._origin=this._capacity=0,this._level=r,this._root=this._tail=this.__hash=void 0,this.__altered=!0,this):ar()},e.prototype.push=function(){var t=arguments,e=this.size;return this.withMutations((function(r){pr(r,0,e+t.length);for(var n=0;n>>e&i;if(o>=this.array.length)return new ir([],t);var u,s=0===o;if(e>0){var a=this.array[o];if((u=a&&a.removeBefore(t,e-r,n))===a&&s)return this}if(s&&!u)return this;var c=fr(this,t);if(!s)for(var f=0;f>>e&i;if(s>=this.array.length)return this;if(e>0){var a=this.array[s];if((u=a&&a.removeAfter(t,e-r,o))===a&&s===this.array.length-1)return this}var c=fr(this,t);return c.array.splice(s+1),u&&(c.array[s]=u),c};var or={};function ur(t,e){var i=t._origin,o=t._capacity,u=_r(o),s=t._tail;return a(t._root,t._level,0);function a(t,c,f){return 0===c?function(t,r){var a=r===u?s&&s.array:t&&t.array,c=r>i?0:i-r,f=o-r;f>n&&(f=n);return function(){if(c===f)return or;var t=e?--f:c++;return a&&a[t]}}(t,f):function(t,u,s){var c,f=t&&t.array,h=s>i?0:i-s>>u,p=1+(o-s>>u);p>n&&(p=n);return function(){for(;;){if(c){var t=c();if(t!==or)return t;c=null}if(h===p)return or;var n=e?--p:h++;c=a(f&&f[n],u-r,s+(n<>>n&i,h=t&&f0){var p=t&&t.array[f],_=cr(p,e,n-r,o,s,a);return _===p?t:((c=fr(t,e)).array[f]=_,c)}return h&&t.array[f]===s?t:(a&&u(a),c=fr(t,e),void 0===s&&f===c.array.length-1?c.array.pop():c.array[f]=s,c)}function fr(t,e){return e&&t&&e===t.ownerID?t:new ir(t?t.array.slice():[],e)}function hr(t,e){if(e>=_r(t._capacity))return t._tail;if(e<1<0;)n=n.array[e>>>o&i],o-=r;return n}}function pr(t,e,n){void 0!==e&&(e|=0),void 0!==n&&(n|=0);var o=t.__ownerID||new s,u=t._origin,a=t._capacity,c=u+e,f=void 0===n?a:n<0?a+n:u+n;if(c===u&&f===a)return t;if(c>=f)return t.clear();for(var h=t._level,p=t._root,_=0;c+_<0;)p=new ir(p&&p.array.length?[void 0,p]:[],o),_+=1<<(h+=r);_&&(c+=_,u+=_,f+=_,a+=_);for(var l=_r(a),v=_r(f);v>=1<l?new ir([],o):y;if(y&&v>l&&cr;w-=r){var m=l>>>w&i;g=g.array[m]=fr(g.array[m],o)}g.array[l>>>r&i]=y}if(f=v)c-=v,f-=v,h=r,p=null,d=d&&d.removeBefore(o,0,c);else if(c>u||v>>h&i;if(z!==v>>>h&i)break;z&&(_+=(1<u&&(p=p.removeBefore(o,h,c-_)),p&&v>>r<=n&&a.size>=2*s.size?(i=(u=a.filter((function(t,e){return void 0!==t&&c!==e}))).toKeyedSeq().map((function(t){return t[0]})).flip().toMap(),t.__ownerID&&(i.__ownerID=u.__ownerID=t.__ownerID)):(i=s.remove(e),u=c===a.size-1?a.pop():a.set(c,void 0))}else if(f){if(r===a.get(c)[1])return t;i=s,u=a.set(c,[e,r])}else i=s.set(e,a.size),u=a.set(a.size,[e,r]);return t.__ownerID?(t.size=i.size,t._map=i,t._list=u,t.__hash=void 0,t.__altered=!0,t):yr(i,u)}vr.isOrderedMap=ct,vr.prototype[A]=!0,vr.prototype[e]=vr.prototype.remove;var wr="@@__IMMUTABLE_STACK__@@";function mr(t){return Boolean(t&&t[wr])}var zr=function(t){function e(t){return null==t?Or():mr(t)?t:Or().pushAll(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("Stack [","]")},e.prototype.get=function(t,e){var r=this._head;for(t=c(this,t);r&&t--;)r=r.next;return r?r.value:e},e.prototype.peek=function(){return this._head&&this._head.value},e.prototype.push=function(){var t=arguments;if(0===arguments.length)return this;for(var e=this.size+arguments.length,r=this._head,n=arguments.length-1;n>=0;n--)r={value:t[n],next:r};return this.__ownerID?(this.size=e,this._head=r,this.__hash=void 0,this.__altered=!0,this):Ir(e,r)},e.prototype.pushAll=function(e){if(0===(e=t(e)).size)return this;if(0===this.size&&mr(e))return e;$t(e.size);var r=this.size,n=this._head;return e.__iterate((function(t){r++,n={value:t,next:n}}),!0),this.__ownerID?(this.size=r,this._head=n,this.__hash=void 0,this.__altered=!0,this):Ir(r,n)},e.prototype.pop=function(){return this.slice(1)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):Or()},e.prototype.slice=function(e,r){if(h(e,r,this.size))return this;var n=p(e,this.size);if(_(r,this.size)!==this.size)return t.prototype.slice.call(this,e,r);for(var i=this.size-n,o=this._head;n--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):Ir(i,o)},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Ir(this.size,this._head,t,this.__hash):0===this.size?Or():(this.__ownerID=t,this.__altered=!1,this)},e.prototype.__iterate=function(t,e){var r=this;if(e)return new $(this.toArray()).__iterate((function(e,n){return t(e,n,r)}),e);for(var n=0,i=this._head;i&&!1!==t(i.value,n++,this);)i=i.next;return n},e.prototype.__iterator=function(t,e){if(e)return new $(this.toArray()).__iterator(t,e);var r=0,n=this._head;return new C((function(){if(n){var e=n.value;return n=n.next,P(t,r++,e)}return{value:void 0,done:!0}}))},e}(O);zr.isStack=mr;var Sr,br=zr.prototype;function Ir(t,e,r,n){var i=Object.create(br);return i.size=t,i._head=e,i.__ownerID=r,i.__hash=n,i.__altered=!1,i}function Or(){return Sr||(Sr=Ir(0))}br[wr]=!0,br.shift=br.pop,br.unshift=br.push,br.unshiftAll=br.pushAll,br.withMutations=je,br.wasAltered=xe,br.asImmutable=De,br["@@transducer/init"]=br.asMutable=Me,br["@@transducer/step"]=function(t,e){return t.unshift(e)},br["@@transducer/result"]=function(t){return t.asImmutable()};var Er="@@__IMMUTABLE_SET__@@";function qr(t){return Boolean(t&&t[Er])}function jr(t){return qr(t)&&k(t)}function Mr(t,e){if(t===e)return!0;if(!d(e)||void 0!==t.size&&void 0!==e.size&&t.size!==e.size||void 0!==t.__hash&&void 0!==e.__hash&&t.__hash!==e.__hash||w(t)!==w(e)||z(t)!==z(e)||k(t)!==k(e))return!1;if(0===t.size&&0===e.size)return!0;var r=!S(t);if(k(t)){var n=t.entries();return e.every((function(t,e){var i=n.next().value;return i&&ht(i[1],t)&&(r||ht(i[0],e))}))&&n.next().done}var i=!1;if(void 0===t.size)if(void 0===e.size)"function"==typeof t.cacheResult&&t.cacheResult();else{i=!0;var u=t;t=e,e=u}var s=!0,a=e.__iterate((function(e,n){if(r?!t.has(e):i?!ht(e,t.get(n,o)):!ht(t.get(n,o),e))return s=!1,!1}));return s&&t.size===a}function Dr(t,e){var r=function(r){t.prototype[r]=e[r]};return Object.keys(e).forEach(r),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(e).forEach(r),t}function xr(t){if(!t||"object"!=typeof t)return t;if(!d(t)){if(!ne(t))return t;t=X(t)}if(w(t)){var e={};return t.__iterate((function(t,r){e[r]=xr(t)})),e}var r=[];return t.__iterate((function(t){r.push(xr(t))})),r}var Ar=function(t){function e(e){return null==e?Br():qr(e)&&!k(e)?e:Br().withMutations((function(r){var n=t(e);$t(n.size),n.forEach((function(t){return r.add(t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(I(t).keySeq())},e.intersect=function(t){return(t=b(t).toArray()).length?Rr.intersect.apply(e(t.pop()),t):Br()},e.union=function(t){return(t=b(t).toArray()).length?Rr.union.apply(e(t.pop()),t):Br()},e.prototype.toString=function(){return this.__toString("Set {","}")},e.prototype.has=function(t){return this._map.has(t)},e.prototype.add=function(t){return Ur(this,this._map.set(t,t))},e.prototype.remove=function(t){return Ur(this,this._map.remove(t))},e.prototype.clear=function(){return Ur(this,this._map.clear())},e.prototype.map=function(t,e){var r=this,n=!1,i=Ur(this,this._map.mapEntries((function(i){var o=i[1],u=t.call(e,o,o,r);return u!==o&&(n=!0),[u,u]}),e));return n?i:this},e.prototype.union=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return 0===(e=e.filter((function(t){return 0!==t.size}))).length?this:0!==this.size||this.__ownerID||1!==e.length?this.withMutations((function(r){for(var n=0;n=0&&e=0&&r>>-15,461845907),e=pt(e<<13|e>>>-13,5),e=pt((e=(e+3864292196|0)^t)^e>>>16,2246822507),e=_t((e=pt(e^e>>>13,3266489909))^e>>>16)}(t.size,n)}(this))}});var Hr=b.prototype;Hr[y]=!0,Hr[L]=Hr.values,Hr.toJSON=Hr.toArray,Hr.__toStringMapper=ie,Hr.inspect=Hr.toSource=function(){return this.toString()},Hr.chain=Hr.flatMap,Hr.contains=Hr.includes,Dr(I,{flip:function(){return Jt(this,Rt(this))},mapEntries:function(t,e){var r=this,n=0;return Jt(this,this.toSeq().map((function(i,o){return t.call(e,[o,i],n++,r)})).fromEntrySeq())},mapKeys:function(t,e){var r=this;return Jt(this,this.toSeq().flip().map((function(n,i){return t.call(e,n,i,r)})).flip())}});var Jr=I.prototype;Jr[g]=!0,Jr[L]=Hr.entries,Jr.toJSON=Nr,Jr.__toStringMapper=function(t,e){return ie(e)+": "+ie(t)},Dr(O,{toKeyedSeq:function(){return new Dt(this,!1)},filter:function(t,e){return Jt(this,Bt(this,t,e,!1))},findIndex:function(t,e){var r=this.findEntry(t,e);return r?r[0]:-1},indexOf:function(t){var e=this.keyOf(t);return void 0===e?-1:e},lastIndexOf:function(t){var e=this.lastKeyOf(t);return void 0===e?-1:e},reverse:function(){return Jt(this,Tt(this,!1))},slice:function(t,e){return Jt(this,Kt(this,t,e,!1))},splice:function(t,e){var r=arguments.length;if(e=Math.max(e||0,0),0===r||2===r&&!e)return this;t=p(t,t<0?this.count():this.size);var n=this.slice(0,t);return Jt(this,1===r?n:n.concat(Gt(arguments,2),this.slice(t+e)))},findLastIndex:function(t,e){var r=this.findLastEntry(t,e);return r?r[0]:-1},first:function(t){return this.get(0,t)},flatten:function(t){return Jt(this,Ct(this,t,!1))},get:function(t,e){return(t=c(this,t))<0||this.size===1/0||void 0!==this.size&&t>this.size?e:this.find((function(e,r){return r===t}),void 0,e)},has:function(t){return(t=c(this,t))>=0&&(void 0!==this.size?this.size===1/0||te?-1:0}function en(t,e){return t^e+2654435769+(t<<6)+(t>>2)|0}Yr.has=Hr.includes,Yr.contains=Yr.includes,Yr.keys=Yr.values,Dr(F,Jr),Dr(G,Vr),Dr(Z,Yr);var rn=function(t){function e(t){return null==t?sn():jr(t)?t:sn().withMutations((function(e){var r=E(t);$t(r.size),r.forEach((function(t){return e.add(t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(I(t).keySeq())},e.prototype.toString=function(){return this.__toString("OrderedSet {","}")},e}(Ar);rn.isOrderedSet=jr;var nn,on=rn.prototype;function un(t,e){var r=Object.create(on);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function sn(){return nn||(nn=un(dr()))}on[A]=!0,on.zip=Vr.zip,on.zipWith=Vr.zipWith,on.zipAll=Vr.zipAll,on.__empty=sn,on.__make=un;var an=function(t,e){var r;!function(t){if(D(t))throw new Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(x(t))throw new Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(null===t||"object"!=typeof t)throw new Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}(t);var n=function(o){var u=this;if(o instanceof n)return o;if(!(this instanceof n))return new n(o);if(!r){r=!0;var s=Object.keys(t),a=i._indices={};i._name=e,i._keys=s,i._defaultValues=t;for(var c=0;c2?[]:void 0,{"":t})},t.get=ue,t.getIn=Cr,t.has=oe,t.hasIn=Wr,t.hash=vt,t.is=ht,t.isAssociative=S,t.isCollection=d,t.isImmutable=x,t.isIndexed=z,t.isKeyed=w,t.isList=er,t.isMap=at,t.isOrdered=k,t.isOrderedMap=ct,t.isOrderedSet=jr,t.isPlainObject=re,t.isRecord=D,t.isSeq=j,t.isSet=qr,t.isStack=mr,t.isValueObject=ft,t.merge=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return be(t,e)},t.mergeDeep=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Se(t,e)},t.mergeDeepWith=function(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];return Se(e,r,t)},t.mergeWith=function(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];return be(e,r,t)},t.remove=ae,t.removeIn=le,t.set=ce,t.setIn=pe,t.update=ye,t.updateIn=fe,t.version="5.0.3"})); diff --git a/package.json b/package.json index 2976df5118..0eda1b7fa3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "immutable", - "version": "5.0.2", + "version": "5.0.3", "description": "Immutable Data Collections", "license": "MIT", "homepage": "https://immutable-js.com", From 66dda1d7292887c88bd4b56f1af60ba878939fca Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sat, 11 Jan 2025 21:33:14 +0000 Subject: [PATCH 220/242] deploy: 65b0f48e89fd57a1b246a065d77eb8303ec93d68 --- dist/immutable.es.js | 122 ++++++++++++++++++++++++++++++++++++------ dist/immutable.js | 122 ++++++++++++++++++++++++++++++++++++------ dist/immutable.min.js | 2 +- 3 files changed, 211 insertions(+), 35 deletions(-) diff --git a/dist/immutable.es.js b/dist/immutable.es.js index 3a88af83db..ad86c54397 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -236,7 +236,8 @@ Iterator.prototype[ITERATOR_SYMBOL] = function () { }; function iteratorValue(type, k, v, iteratorResult) { - var value = type === 0 ? k : type === 1 ? v : [k, v]; + var value = + type === ITERATE_KEYS ? k : type === ITERATE_VALUES ? v : [k, v]; iteratorResult ? (iteratorResult.value = value) : (iteratorResult = { @@ -1628,6 +1629,108 @@ function skipWhileFactory(collection, predicate, context, useKeys) { return skipSequence; } +var ConcatSeq = /*@__PURE__*/(function (Seq) { + function ConcatSeq(iterables) { + this._wrappedIterables = iterables.flatMap(function (iterable) { + if (iterable._wrappedIterables) { + return iterable._wrappedIterables; + } + return [iterable]; + }); + this.size = this._wrappedIterables.reduce(function (sum, iterable) { + if (sum !== undefined) { + var size = iterable.size; + if (size !== undefined) { + return sum + size; + } + } + }, 0); + this[IS_KEYED_SYMBOL] = this._wrappedIterables[0][IS_KEYED_SYMBOL]; + this[IS_INDEXED_SYMBOL] = this._wrappedIterables[0][IS_INDEXED_SYMBOL]; + this[IS_ORDERED_SYMBOL] = this._wrappedIterables[0][IS_ORDERED_SYMBOL]; + } + + if ( Seq ) ConcatSeq.__proto__ = Seq; + ConcatSeq.prototype = Object.create( Seq && Seq.prototype ); + ConcatSeq.prototype.constructor = ConcatSeq; + + ConcatSeq.prototype.__iterateUncached = function __iterateUncached (fn, reverse) { + if (this._wrappedIterables.length === 0) { + return; + } + + if (reverse) { + return this.cacheResult().__iterate(fn, reverse); + } + + var iterableIndex = 0; + var useKeys = isKeyed(this); + var iteratorType = useKeys ? ITERATE_ENTRIES : ITERATE_VALUES; + var currentIterator = this._wrappedIterables[iterableIndex].__iterator( + iteratorType, + reverse + ); + + var keepGoing = true; + var index = 0; + while (keepGoing) { + var next = currentIterator.next(); + while (next.done) { + iterableIndex++; + if (iterableIndex === this._wrappedIterables.length) { + return index; + } + currentIterator = this._wrappedIterables[iterableIndex].__iterator( + iteratorType, + reverse + ); + next = currentIterator.next(); + } + var fnResult = useKeys + ? fn(next.value[1], next.value[0], this) + : fn(next.value, index, this); + keepGoing = fnResult !== false; + index++; + } + return index; + }; + + ConcatSeq.prototype.__iteratorUncached = function __iteratorUncached (type, reverse) { + var this$1$1 = this; + + if (this._wrappedIterables.length === 0) { + return new Iterator(iteratorDone); + } + + if (reverse) { + return this.cacheResult().__iterator(type, reverse); + } + + var iterableIndex = 0; + var currentIterator = this._wrappedIterables[iterableIndex].__iterator( + type, + reverse + ); + return new Iterator(function () { + var next = currentIterator.next(); + while (next.done) { + iterableIndex++; + if (iterableIndex === this$1$1._wrappedIterables.length) { + return next; + } + currentIterator = this$1$1._wrappedIterables[iterableIndex].__iterator( + type, + reverse + ); + next = currentIterator.next(); + } + return next; + }); + }; + + return ConcatSeq; +}(Seq)); + function concatFactory(collection, values) { var isKeyedCollection = isKeyed(collection); var iters = [collection] @@ -1659,22 +1762,7 @@ function concatFactory(collection, values) { } } - var concatSeq = new ArraySeq(iters); - if (isKeyedCollection) { - concatSeq = concatSeq.toKeyedSeq(); - } else if (!isIndexed(collection)) { - concatSeq = concatSeq.toSetSeq(); - } - concatSeq = concatSeq.flatten(true); - concatSeq.size = iters.reduce(function (sum, seq) { - if (sum !== undefined) { - var size = seq.size; - if (size !== undefined) { - return sum + size; - } - } - }, 0); - return concatSeq; + return new ConcatSeq(iters); } function flattenFactory(collection, depth, useKeys) { diff --git a/dist/immutable.js b/dist/immutable.js index 9e47325888..4f7ee1142f 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -242,7 +242,8 @@ }; function iteratorValue(type, k, v, iteratorResult) { - var value = type === 0 ? k : type === 1 ? v : [k, v]; + var value = + type === ITERATE_KEYS ? k : type === ITERATE_VALUES ? v : [k, v]; iteratorResult ? (iteratorResult.value = value) : (iteratorResult = { @@ -1634,6 +1635,108 @@ return skipSequence; } + var ConcatSeq = /*@__PURE__*/(function (Seq) { + function ConcatSeq(iterables) { + this._wrappedIterables = iterables.flatMap(function (iterable) { + if (iterable._wrappedIterables) { + return iterable._wrappedIterables; + } + return [iterable]; + }); + this.size = this._wrappedIterables.reduce(function (sum, iterable) { + if (sum !== undefined) { + var size = iterable.size; + if (size !== undefined) { + return sum + size; + } + } + }, 0); + this[IS_KEYED_SYMBOL] = this._wrappedIterables[0][IS_KEYED_SYMBOL]; + this[IS_INDEXED_SYMBOL] = this._wrappedIterables[0][IS_INDEXED_SYMBOL]; + this[IS_ORDERED_SYMBOL] = this._wrappedIterables[0][IS_ORDERED_SYMBOL]; + } + + if ( Seq ) ConcatSeq.__proto__ = Seq; + ConcatSeq.prototype = Object.create( Seq && Seq.prototype ); + ConcatSeq.prototype.constructor = ConcatSeq; + + ConcatSeq.prototype.__iterateUncached = function __iterateUncached (fn, reverse) { + if (this._wrappedIterables.length === 0) { + return; + } + + if (reverse) { + return this.cacheResult().__iterate(fn, reverse); + } + + var iterableIndex = 0; + var useKeys = isKeyed(this); + var iteratorType = useKeys ? ITERATE_ENTRIES : ITERATE_VALUES; + var currentIterator = this._wrappedIterables[iterableIndex].__iterator( + iteratorType, + reverse + ); + + var keepGoing = true; + var index = 0; + while (keepGoing) { + var next = currentIterator.next(); + while (next.done) { + iterableIndex++; + if (iterableIndex === this._wrappedIterables.length) { + return index; + } + currentIterator = this._wrappedIterables[iterableIndex].__iterator( + iteratorType, + reverse + ); + next = currentIterator.next(); + } + var fnResult = useKeys + ? fn(next.value[1], next.value[0], this) + : fn(next.value, index, this); + keepGoing = fnResult !== false; + index++; + } + return index; + }; + + ConcatSeq.prototype.__iteratorUncached = function __iteratorUncached (type, reverse) { + var this$1$1 = this; + + if (this._wrappedIterables.length === 0) { + return new Iterator(iteratorDone); + } + + if (reverse) { + return this.cacheResult().__iterator(type, reverse); + } + + var iterableIndex = 0; + var currentIterator = this._wrappedIterables[iterableIndex].__iterator( + type, + reverse + ); + return new Iterator(function () { + var next = currentIterator.next(); + while (next.done) { + iterableIndex++; + if (iterableIndex === this$1$1._wrappedIterables.length) { + return next; + } + currentIterator = this$1$1._wrappedIterables[iterableIndex].__iterator( + type, + reverse + ); + next = currentIterator.next(); + } + return next; + }); + }; + + return ConcatSeq; + }(Seq)); + function concatFactory(collection, values) { var isKeyedCollection = isKeyed(collection); var iters = [collection] @@ -1665,22 +1768,7 @@ } } - var concatSeq = new ArraySeq(iters); - if (isKeyedCollection) { - concatSeq = concatSeq.toKeyedSeq(); - } else if (!isIndexed(collection)) { - concatSeq = concatSeq.toSetSeq(); - } - concatSeq = concatSeq.flatten(true); - concatSeq.size = iters.reduce(function (sum, seq) { - if (sum !== undefined) { - var size = seq.size; - if (size !== undefined) { - return sum + size; - } - } - }, 0); - return concatSeq; + return new ConcatSeq(iters); } function flattenFactory(collection, depth, useKeys) { diff --git a/dist/immutable.min.js b/dist/immutable.min.js index 291efde457..692260051e 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -22,4 +22,4 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).Immutable={})}(this,(function(t){"use strict";var e="delete",r=5,n=1<>>0;if(""+r!==e||4294967295===r)return NaN;e=r}return e<0?a(t)+e:e}function f(){return!0}function h(t,e,r){return(0===t&&!v(t)||void 0!==r&&t<=-r)&&(void 0===e||void 0!==r&&e>=r)}function p(t,e){return l(t,e,0)}function _(t,e){return l(t,e,e)}function l(t,e,r){return void 0===t?r:v(t)?e===1/0?e:0|Math.max(0,e+t):void 0===e||e===t?t:0|Math.min(e,t)}function v(t){return t<0||0===t&&1/t==-1/0}var y="@@__IMMUTABLE_ITERABLE__@@";function d(t){return Boolean(t&&t[y])}var g="@@__IMMUTABLE_KEYED__@@";function w(t){return Boolean(t&&t[g])}var m="@@__IMMUTABLE_INDEXED__@@";function z(t){return Boolean(t&&t[m])}function S(t){return w(t)||z(t)}var b=function(t){return d(t)?t:X(t)},I=function(t){function e(t){return w(t)?t:F(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(b),O=function(t){function e(t){return z(t)?t:G(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(b),E=function(t){function e(t){return d(t)&&!S(t)?t:Z(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(b);b.Keyed=I,b.Indexed=O,b.Set=E;var q="@@__IMMUTABLE_SEQ__@@";function j(t){return Boolean(t&&t[q])}var M="@@__IMMUTABLE_RECORD__@@";function D(t){return Boolean(t&&t[M])}function x(t){return d(t)||D(t)}var A="@@__IMMUTABLE_ORDERED__@@";function k(t){return Boolean(t&&t[A])}var R=0,U=1,T=2,B="function"==typeof Symbol&&Symbol.iterator,K="@@iterator",L=B||K,C=function(t){this.next=t};function P(t,e,r,n){var i=0===t?e:1===t?r:[e,r];return n?n.value=i:n={value:i,done:!1},n}function W(){return{value:void 0,done:!0}}function N(t){return!!Array.isArray(t)||!!V(t)}function H(t){return t&&"function"==typeof t.next}function J(t){var e=V(t);return e&&e.call(t)}function V(t){var e=t&&(B&&t[B]||t[K]);if("function"==typeof e)return e}C.prototype.toString=function(){return"[Iterator]"},C.KEYS=R,C.VALUES=U,C.ENTRIES=T,C.prototype.inspect=C.prototype.toSource=function(){return this.toString()},C.prototype[L]=function(){return this};var Y=Object.prototype.hasOwnProperty;function Q(t){return!(!Array.isArray(t)&&"string"!=typeof t)||t&&"object"==typeof t&&Number.isInteger(t.length)&&t.length>=0&&(0===t.length?1===Object.keys(t).length:t.hasOwnProperty(t.length-1))}var X=function(t){function e(t){return null==t?nt():x(t)?t.toSeq():function(t){var e=ut(t);if(e)return(n=V(r=t))&&n===r.entries?e.fromEntrySeq():function(t){var e=V(t);return e&&e===t.keys}(t)?e.toSetSeq():e;var r,n;if("object"==typeof t)return new tt(t);throw new TypeError("Expected Array or collection object of values, or keyed object: "+t)}(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq {","}")},e.prototype.cacheResult=function(){return!this._cache&&this.__iterateUncached&&(this._cache=this.entrySeq().toArray(),this.size=this._cache.length),this},e.prototype.__iterate=function(t,e){var r=this._cache;if(r){for(var n=r.length,i=0;i!==n;){var o=r[e?n-++i:i++];if(!1===t(o[1],o[0],this))break}return i}return this.__iterateUncached(t,e)},e.prototype.__iterator=function(t,e){var r=this._cache;if(r){var n=r.length,i=0;return new C((function(){if(i===n)return{value:void 0,done:!0};var o=r[e?n-++i:i++];return P(t,o[0],o[1])}))}return this.__iteratorUncached(t,e)},e}(b),F=function(t){function e(t){return null==t?nt().toKeyedSeq():d(t)?w(t)?t.toSeq():t.fromEntrySeq():D(t)?t.toSeq():it(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toKeyedSeq=function(){return this},e}(X),G=function(t){function e(t){return null==t?nt():d(t)?w(t)?t.entrySeq():t.toIndexedSeq():D(t)?t.toSeq().entrySeq():ot(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return e(arguments)},e.prototype.toIndexedSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq [","]")},e}(X),Z=function(t){function e(t){return(d(t)&&!S(t)?t:G(t)).toSetSeq()}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return e(arguments)},e.prototype.toSetSeq=function(){return this},e}(X);X.isSeq=j,X.Keyed=F,X.Set=Z,X.Indexed=G,X.prototype[q]=!0;var $=function(t){function e(t){this._array=t,this.size=t.length}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t,e){return this.has(t)?this._array[c(this,t)]:e},e.prototype.__iterate=function(t,e){for(var r=this._array,n=r.length,i=0;i!==n;){var o=e?n-++i:i++;if(!1===t(r[o],o,this))break}return i},e.prototype.__iterator=function(t,e){var r=this._array,n=r.length,i=0;return new C((function(){if(i===n)return{value:void 0,done:!0};var o=e?n-++i:i++;return P(t,o,r[o])}))},e}(G),tt=function(t){function e(t){var e=Object.keys(t).concat(Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(t):[]);this._object=t,this._keys=e,this.size=e.length}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t,e){return void 0===e||this.has(t)?this._object[t]:e},e.prototype.has=function(t){return Y.call(this._object,t)},e.prototype.__iterate=function(t,e){for(var r=this._object,n=this._keys,i=n.length,o=0;o!==i;){var u=n[e?i-++o:o++];if(!1===t(r[u],u,this))break}return o},e.prototype.__iterator=function(t,e){var r=this._object,n=this._keys,i=n.length,o=0;return new C((function(){if(o===i)return{value:void 0,done:!0};var u=n[e?i-++o:o++];return P(t,u,r[u])}))},e}(F);tt.prototype[A]=!0;var et,rt=function(t){function e(t){this._collection=t,this.size=t.length||t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.__iterateUncached=function(t,e){if(e)return this.cacheResult().__iterate(t,e);var r=J(this._collection),n=0;if(H(r))for(var i;!(i=r.next()).done&&!1!==t(i.value,n++,this););return n},e.prototype.__iteratorUncached=function(t,e){if(e)return this.cacheResult().__iterator(t,e);var r=J(this._collection);if(!H(r))return new C(W);var n=0;return new C((function(){var e=r.next();return e.done?e:P(t,n++,e.value)}))},e}(G);function nt(){return et||(et=new $([]))}function it(t){var e=ut(t);if(e)return e.fromEntrySeq();if("object"==typeof t)return new tt(t);throw new TypeError("Expected Array or collection object of [k, v] entries, or keyed object: "+t)}function ot(t){var e=ut(t);if(e)return e;throw new TypeError("Expected Array or collection object of values: "+t)}function ut(t){return Q(t)?new $(t):N(t)?new rt(t):void 0}var st="@@__IMMUTABLE_MAP__@@";function at(t){return Boolean(t&&t[st])}function ct(t){return at(t)&&k(t)}function ft(t){return Boolean(t&&"function"==typeof t.equals&&"function"==typeof t.hashCode)}function ht(t,e){if(t===e||t!=t&&e!=e)return!0;if(!t||!e)return!1;if("function"==typeof t.valueOf&&"function"==typeof e.valueOf){if((t=t.valueOf())===(e=e.valueOf())||t!=t&&e!=e)return!0;if(!t||!e)return!1}return!!(ft(t)&&ft(e)&&t.equals(e))}var pt="function"==typeof Math.imul&&-2===Math.imul(4294967295,2)?Math.imul:function(t,e){var r=65535&(t|=0),n=65535&(e|=0);return r*n+((t>>>16)*n+r*(e>>>16)<<16>>>0)|0};function _t(t){return t>>>1&1073741824|3221225471&t}var lt=Object.prototype.valueOf;function vt(t){if(null==t)return yt(t);if("function"==typeof t.hashCode)return _t(t.hashCode(t));var e,r=(e=t).valueOf!==lt&&"function"==typeof e.valueOf?e.valueOf(e):e;if(null==r)return yt(r);switch(typeof r){case"boolean":return r?1108378657:1108378656;case"number":return function(t){if(t!=t||t===1/0)return 0;var e=0|t;e!==t&&(e^=4294967295*t);for(;t>4294967295;)e^=t/=4294967295;return _t(e)}(r);case"string":return r.length>Et?function(t){var e=Mt[t];void 0===e&&(e=dt(t),jt===qt&&(jt=0,Mt={}),jt++,Mt[t]=e);return e}(r):dt(r);case"object":case"function":return function(t){var e;if(St&&void 0!==(e=zt.get(t)))return e;if(e=t[Ot],void 0!==e)return e;if(!wt){if(void 0!==(e=t.propertyIsEnumerable&&t.propertyIsEnumerable[Ot]))return e;if(void 0!==(e=function(t){if(t&&t.nodeType>0)switch(t.nodeType){case 1:return t.uniqueID;case 9:return t.documentElement&&t.documentElement.uniqueID}}(t)))return e}if(e=mt(),St)zt.set(t,e);else{if(void 0!==gt&&!1===gt(t))throw new Error("Non-extensible objects are not allowed as keys.");if(wt)Object.defineProperty(t,Ot,{enumerable:!1,configurable:!1,writable:!1,value:e});else if(void 0!==t.propertyIsEnumerable&&t.propertyIsEnumerable===t.constructor.prototype.propertyIsEnumerable)t.propertyIsEnumerable=function(){return this.constructor.prototype.propertyIsEnumerable.apply(this,arguments)},t.propertyIsEnumerable[Ot]=e;else{if(void 0===t.nodeType)throw new Error("Unable to set a non-enumerable property on object.");t[Ot]=e}}return e}(r);case"symbol":return function(t){var e=bt[t];if(void 0!==e)return e;return e=mt(),bt[t]=e,e}(r);default:if("function"==typeof r.toString)return dt(r.toString());throw new Error("Value type "+typeof r+" cannot be hashed.")}}function yt(t){return null===t?1108378658:1108378659}function dt(t){for(var e=0,r=0;r=0&&(a.get=function(e,r){return(e=c(this,e))>=0&&eo)return{value:void 0,done:!0};var t=i.next();return n||e===U||t.done?t:P(e,a-1,e===R?void 0:t.value[1],t)}))},a}function Lt(t,e,r,n){var i=Qt(t);return i.__iterateUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterate(i,o);var s=!0,a=0;return t.__iterate((function(t,o,c){if(!s||!(s=e.call(r,t,o,c)))return a++,i(t,n?o:a-1,u)})),a},i.__iteratorUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterator(i,o);var s=t.__iterator(T,o),a=!0,c=0;return new C((function(){var t,o,f;do{if((t=s.next()).done)return n||i===U?t:P(i,c++,i===R?void 0:t.value[1],t);var h=t.value;o=h[0],f=h[1],a&&(a=e.call(r,f,o,u))}while(a);return i===T?t:P(i,o,f,t)}))},i}function Ct(t,e,r){var n=Qt(t);return n.__iterateUncached=function(i,o){if(o)return this.cacheResult().__iterate(i,o);var u=0,s=!1;return function t(a,c){a.__iterate((function(o,a){return(!e||c0}function Ht(t,e,r,n){var i=Qt(t),o=new $(r).map((function(t){return t.size}));return i.size=n?o.max():o.min(),i.__iterate=function(t,e){for(var r,n=this.__iterator(U,e),i=0;!(r=n.next()).done&&!1!==t(r.value,i++,this););return i},i.__iteratorUncached=function(t,i){var o=r.map((function(t){return t=b(t),J(i?t.reverse():t)})),u=0,s=!1;return new C((function(){var r;return s||(r=o.map((function(t){return t.next()})),s=n?r.every((function(t){return t.done})):r.some((function(t){return t.done}))),s?{value:void 0,done:!0}:P(t,u++,e.apply(null,r.map((function(t){return t.value}))))}))},i}function Jt(t,e){return t===e?t:j(t)?e:t.constructor(e)}function Vt(t){if(t!==Object(t))throw new TypeError("Expected [K, V] tuple: "+t)}function Yt(t){return w(t)?I:z(t)?O:E}function Qt(t){return Object.create((w(t)?F:z(t)?G:Z).prototype)}function Xt(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size,this):X.prototype.cacheResult.call(this)}function Ft(t,e){return void 0===t&&void 0===e?0:void 0===t?1:void 0===e?-1:t>e?1:t0;)e[r]=arguments[r+1];if("function"!=typeof t)throw new TypeError("Invalid merger function: "+t);return ze(this,e,t)}function ze(t,e,r){for(var n=[],i=0;i0;)e[r]=arguments[r+1];return Se(this,e,t)}function Ee(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return fe(this,t,He(),(function(t){return be(t,e)}))}function qe(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return fe(this,t,He(),(function(t){return Se(t,e)}))}function je(t){var e=this.asMutable();return t(e),e.wasAltered()?e.__ensureOwner(this.__ownerID):this}function Me(){return this.__ownerID?this:this.__ensureOwner(new s)}function De(){return this.__ensureOwner()}function xe(){return this.__altered}var Ae=function(t){function e(e){return null==e?He():at(e)&&!k(e)?e:He().withMutations((function(r){var n=t(e);$t(n.size),n.forEach((function(t,e){return r.set(e,t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toString=function(){return this.__toString("Map {","}")},e.prototype.get=function(t,e){return this._root?this._root.get(0,void 0,t,e):e},e.prototype.set=function(t,e){return Je(this,t,e)},e.prototype.remove=function(t){return Je(this,t,o)},e.prototype.deleteAll=function(t){var e=b(t);return 0===e.size?this:this.withMutations((function(t){e.forEach((function(e){return t.remove(e)}))}))},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):He()},e.prototype.sort=function(t){return vr(Pt(this,t))},e.prototype.sortBy=function(t,e){return vr(Pt(this,e,t))},e.prototype.map=function(t,e){var r=this;return this.withMutations((function(n){n.forEach((function(i,o){n.set(o,t.call(e,i,o,r))}))}))},e.prototype.__iterator=function(t,e){return new Ce(this,t,e)},e.prototype.__iterate=function(t,e){var r=this,n=0;return this._root&&this._root.iterate((function(e){return n++,t(e[1],e[0],r)}),e),n},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Ne(this.size,this._root,t,this.__hash):0===this.size?He():(this.__ownerID=t,this.__altered=!1,this)},e}(I);Ae.isMap=at;var ke=Ae.prototype;ke[st]=!0,ke[e]=ke.remove,ke.removeAll=ke.deleteAll,ke.setIn=_e,ke.removeIn=ke.deleteIn=ve,ke.update=de,ke.updateIn=ge,ke.merge=ke.concat=we,ke.mergeWith=me,ke.mergeDeep=Ie,ke.mergeDeepWith=Oe,ke.mergeIn=Ee,ke.mergeDeepIn=qe,ke.withMutations=je,ke.wasAltered=xe,ke.asImmutable=De,ke["@@transducer/init"]=ke.asMutable=Me,ke["@@transducer/step"]=function(t,e){return t.set(e[0],e[1])},ke["@@transducer/result"]=function(t){return t.asImmutable()};var Re=function(t,e){this.ownerID=t,this.entries=e};Re.prototype.get=function(t,e,r,n){for(var i=this.entries,o=0,u=i.length;o=Ge)return function(t,e,r,n){t||(t=new s);for(var i=new Ke(t,vt(r),[r,n]),o=0;o>>t)&i),s=this.bitmap;return 0==(s&u)?o:this.nodes[Xe(s&u-1)].get(t+r,e,n,o)},Ue.prototype.update=function(t,e,u,s,a,c,f){void 0===u&&(u=vt(s));var h=(0===e?u:u>>>e)&i,p=1<=Ze)return function(t,e,r,i,o){for(var u=0,s=new Array(n),a=0;0!==r;a++,r>>>=1)s[a]=1&r?e[u++]:void 0;return s[i]=o,new Te(t,u+1,s)}(t,y,_,h,g);if(l&&!g&&2===y.length&&Ye(y[1^v]))return y[1^v];if(l&&g&&1===y.length&&Ye(g))return g;var w=t&&t===this.ownerID,m=l?g?_:_^p:_|p,z=l?g?Fe(y,v,g,w):function(t,e,r){var n=t.length-1;if(r&&e===n)return t.pop(),t;for(var i=new Array(n),o=0,u=0;u>>t)&i,s=this.nodes[u];return s?s.get(t+r,e,n,o):o},Te.prototype.update=function(t,e,n,u,s,a,c){void 0===n&&(n=vt(u));var f=(0===e?n:n>>>e)&i,h=s===o,p=this.nodes,_=p[f];if(h&&!_)return this;var l=Ve(_,t,e+r,n,u,s,a,c);if(l===_)return this;var v=this.count;if(_){if(!l&&--v<$e)return function(t,e,r,n){for(var i=0,o=0,u=new Array(r),s=0,a=1,c=e.length;s>>n)&i,c=(0===n?o:o>>>n)&i,f=a===c?[Qe(t,e,n+r,o,u)]:(s=new Ke(e,o,u),a>1&1431655765))+(t>>2&858993459))+(t>>4)&252645135,t+=t>>8,127&(t+=t>>16)}function Fe(t,e,r,n){var i=n?t:Gt(t);return i[e]=r,i}var Ge=n/4,Ze=n/2,$e=n/4,tr="@@__IMMUTABLE_LIST__@@";function er(t){return Boolean(t&&t[tr])}var rr=function(t){function e(e){var i=ar();if(null==e)return i;if(er(e))return e;var o=t(e),u=o.size;return 0===u?i:($t(u),u>0&&u=0&&t=t.size||e<0)return t.withMutations((function(t){e<0?pr(t,e).set(0,r):pr(t,0,e+1).set(e,r)}));e+=t._origin;var n=t._tail,i=t._root,o={value:!1};e>=_r(t._capacity)?n=cr(n,t.__ownerID,0,e,r,o):i=cr(i,t.__ownerID,t._level,e,r,o);if(!o.value)return t;if(t.__ownerID)return t._root=i,t._tail=n,t.__hash=void 0,t.__altered=!0,t;return sr(t._origin,t._capacity,t._level,i,n)}(this,t,e)},e.prototype.remove=function(t){return this.has(t)?0===t?this.shift():t===this.size-1?this.pop():this.splice(t,1):this},e.prototype.insert=function(t,e){return this.splice(t,0,e)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=this._origin=this._capacity=0,this._level=r,this._root=this._tail=this.__hash=void 0,this.__altered=!0,this):ar()},e.prototype.push=function(){var t=arguments,e=this.size;return this.withMutations((function(r){pr(r,0,e+t.length);for(var n=0;n>>e&i;if(o>=this.array.length)return new ir([],t);var u,s=0===o;if(e>0){var a=this.array[o];if((u=a&&a.removeBefore(t,e-r,n))===a&&s)return this}if(s&&!u)return this;var c=fr(this,t);if(!s)for(var f=0;f>>e&i;if(s>=this.array.length)return this;if(e>0){var a=this.array[s];if((u=a&&a.removeAfter(t,e-r,o))===a&&s===this.array.length-1)return this}var c=fr(this,t);return c.array.splice(s+1),u&&(c.array[s]=u),c};var or={};function ur(t,e){var i=t._origin,o=t._capacity,u=_r(o),s=t._tail;return a(t._root,t._level,0);function a(t,c,f){return 0===c?function(t,r){var a=r===u?s&&s.array:t&&t.array,c=r>i?0:i-r,f=o-r;f>n&&(f=n);return function(){if(c===f)return or;var t=e?--f:c++;return a&&a[t]}}(t,f):function(t,u,s){var c,f=t&&t.array,h=s>i?0:i-s>>u,p=1+(o-s>>u);p>n&&(p=n);return function(){for(;;){if(c){var t=c();if(t!==or)return t;c=null}if(h===p)return or;var n=e?--p:h++;c=a(f&&f[n],u-r,s+(n<>>n&i,h=t&&f0){var p=t&&t.array[f],_=cr(p,e,n-r,o,s,a);return _===p?t:((c=fr(t,e)).array[f]=_,c)}return h&&t.array[f]===s?t:(a&&u(a),c=fr(t,e),void 0===s&&f===c.array.length-1?c.array.pop():c.array[f]=s,c)}function fr(t,e){return e&&t&&e===t.ownerID?t:new ir(t?t.array.slice():[],e)}function hr(t,e){if(e>=_r(t._capacity))return t._tail;if(e<1<0;)n=n.array[e>>>o&i],o-=r;return n}}function pr(t,e,n){void 0!==e&&(e|=0),void 0!==n&&(n|=0);var o=t.__ownerID||new s,u=t._origin,a=t._capacity,c=u+e,f=void 0===n?a:n<0?a+n:u+n;if(c===u&&f===a)return t;if(c>=f)return t.clear();for(var h=t._level,p=t._root,_=0;c+_<0;)p=new ir(p&&p.array.length?[void 0,p]:[],o),_+=1<<(h+=r);_&&(c+=_,u+=_,f+=_,a+=_);for(var l=_r(a),v=_r(f);v>=1<l?new ir([],o):y;if(y&&v>l&&cr;w-=r){var m=l>>>w&i;g=g.array[m]=fr(g.array[m],o)}g.array[l>>>r&i]=y}if(f=v)c-=v,f-=v,h=r,p=null,d=d&&d.removeBefore(o,0,c);else if(c>u||v>>h&i;if(z!==v>>>h&i)break;z&&(_+=(1<u&&(p=p.removeBefore(o,h,c-_)),p&&v>>r<=n&&a.size>=2*s.size?(i=(u=a.filter((function(t,e){return void 0!==t&&c!==e}))).toKeyedSeq().map((function(t){return t[0]})).flip().toMap(),t.__ownerID&&(i.__ownerID=u.__ownerID=t.__ownerID)):(i=s.remove(e),u=c===a.size-1?a.pop():a.set(c,void 0))}else if(f){if(r===a.get(c)[1])return t;i=s,u=a.set(c,[e,r])}else i=s.set(e,a.size),u=a.set(a.size,[e,r]);return t.__ownerID?(t.size=i.size,t._map=i,t._list=u,t.__hash=void 0,t.__altered=!0,t):yr(i,u)}vr.isOrderedMap=ct,vr.prototype[A]=!0,vr.prototype[e]=vr.prototype.remove;var wr="@@__IMMUTABLE_STACK__@@";function mr(t){return Boolean(t&&t[wr])}var zr=function(t){function e(t){return null==t?Or():mr(t)?t:Or().pushAll(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("Stack [","]")},e.prototype.get=function(t,e){var r=this._head;for(t=c(this,t);r&&t--;)r=r.next;return r?r.value:e},e.prototype.peek=function(){return this._head&&this._head.value},e.prototype.push=function(){var t=arguments;if(0===arguments.length)return this;for(var e=this.size+arguments.length,r=this._head,n=arguments.length-1;n>=0;n--)r={value:t[n],next:r};return this.__ownerID?(this.size=e,this._head=r,this.__hash=void 0,this.__altered=!0,this):Ir(e,r)},e.prototype.pushAll=function(e){if(0===(e=t(e)).size)return this;if(0===this.size&&mr(e))return e;$t(e.size);var r=this.size,n=this._head;return e.__iterate((function(t){r++,n={value:t,next:n}}),!0),this.__ownerID?(this.size=r,this._head=n,this.__hash=void 0,this.__altered=!0,this):Ir(r,n)},e.prototype.pop=function(){return this.slice(1)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):Or()},e.prototype.slice=function(e,r){if(h(e,r,this.size))return this;var n=p(e,this.size);if(_(r,this.size)!==this.size)return t.prototype.slice.call(this,e,r);for(var i=this.size-n,o=this._head;n--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):Ir(i,o)},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Ir(this.size,this._head,t,this.__hash):0===this.size?Or():(this.__ownerID=t,this.__altered=!1,this)},e.prototype.__iterate=function(t,e){var r=this;if(e)return new $(this.toArray()).__iterate((function(e,n){return t(e,n,r)}),e);for(var n=0,i=this._head;i&&!1!==t(i.value,n++,this);)i=i.next;return n},e.prototype.__iterator=function(t,e){if(e)return new $(this.toArray()).__iterator(t,e);var r=0,n=this._head;return new C((function(){if(n){var e=n.value;return n=n.next,P(t,r++,e)}return{value:void 0,done:!0}}))},e}(O);zr.isStack=mr;var Sr,br=zr.prototype;function Ir(t,e,r,n){var i=Object.create(br);return i.size=t,i._head=e,i.__ownerID=r,i.__hash=n,i.__altered=!1,i}function Or(){return Sr||(Sr=Ir(0))}br[wr]=!0,br.shift=br.pop,br.unshift=br.push,br.unshiftAll=br.pushAll,br.withMutations=je,br.wasAltered=xe,br.asImmutable=De,br["@@transducer/init"]=br.asMutable=Me,br["@@transducer/step"]=function(t,e){return t.unshift(e)},br["@@transducer/result"]=function(t){return t.asImmutable()};var Er="@@__IMMUTABLE_SET__@@";function qr(t){return Boolean(t&&t[Er])}function jr(t){return qr(t)&&k(t)}function Mr(t,e){if(t===e)return!0;if(!d(e)||void 0!==t.size&&void 0!==e.size&&t.size!==e.size||void 0!==t.__hash&&void 0!==e.__hash&&t.__hash!==e.__hash||w(t)!==w(e)||z(t)!==z(e)||k(t)!==k(e))return!1;if(0===t.size&&0===e.size)return!0;var r=!S(t);if(k(t)){var n=t.entries();return e.every((function(t,e){var i=n.next().value;return i&&ht(i[1],t)&&(r||ht(i[0],e))}))&&n.next().done}var i=!1;if(void 0===t.size)if(void 0===e.size)"function"==typeof t.cacheResult&&t.cacheResult();else{i=!0;var u=t;t=e,e=u}var s=!0,a=e.__iterate((function(e,n){if(r?!t.has(e):i?!ht(e,t.get(n,o)):!ht(t.get(n,o),e))return s=!1,!1}));return s&&t.size===a}function Dr(t,e){var r=function(r){t.prototype[r]=e[r]};return Object.keys(e).forEach(r),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(e).forEach(r),t}function xr(t){if(!t||"object"!=typeof t)return t;if(!d(t)){if(!ne(t))return t;t=X(t)}if(w(t)){var e={};return t.__iterate((function(t,r){e[r]=xr(t)})),e}var r=[];return t.__iterate((function(t){r.push(xr(t))})),r}var Ar=function(t){function e(e){return null==e?Br():qr(e)&&!k(e)?e:Br().withMutations((function(r){var n=t(e);$t(n.size),n.forEach((function(t){return r.add(t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(I(t).keySeq())},e.intersect=function(t){return(t=b(t).toArray()).length?Rr.intersect.apply(e(t.pop()),t):Br()},e.union=function(t){return(t=b(t).toArray()).length?Rr.union.apply(e(t.pop()),t):Br()},e.prototype.toString=function(){return this.__toString("Set {","}")},e.prototype.has=function(t){return this._map.has(t)},e.prototype.add=function(t){return Ur(this,this._map.set(t,t))},e.prototype.remove=function(t){return Ur(this,this._map.remove(t))},e.prototype.clear=function(){return Ur(this,this._map.clear())},e.prototype.map=function(t,e){var r=this,n=!1,i=Ur(this,this._map.mapEntries((function(i){var o=i[1],u=t.call(e,o,o,r);return u!==o&&(n=!0),[u,u]}),e));return n?i:this},e.prototype.union=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return 0===(e=e.filter((function(t){return 0!==t.size}))).length?this:0!==this.size||this.__ownerID||1!==e.length?this.withMutations((function(r){for(var n=0;n=0&&e=0&&r>>-15,461845907),e=pt(e<<13|e>>>-13,5),e=pt((e=(e+3864292196|0)^t)^e>>>16,2246822507),e=_t((e=pt(e^e>>>13,3266489909))^e>>>16)}(t.size,n)}(this))}});var Hr=b.prototype;Hr[y]=!0,Hr[L]=Hr.values,Hr.toJSON=Hr.toArray,Hr.__toStringMapper=ie,Hr.inspect=Hr.toSource=function(){return this.toString()},Hr.chain=Hr.flatMap,Hr.contains=Hr.includes,Dr(I,{flip:function(){return Jt(this,Rt(this))},mapEntries:function(t,e){var r=this,n=0;return Jt(this,this.toSeq().map((function(i,o){return t.call(e,[o,i],n++,r)})).fromEntrySeq())},mapKeys:function(t,e){var r=this;return Jt(this,this.toSeq().flip().map((function(n,i){return t.call(e,n,i,r)})).flip())}});var Jr=I.prototype;Jr[g]=!0,Jr[L]=Hr.entries,Jr.toJSON=Nr,Jr.__toStringMapper=function(t,e){return ie(e)+": "+ie(t)},Dr(O,{toKeyedSeq:function(){return new Dt(this,!1)},filter:function(t,e){return Jt(this,Bt(this,t,e,!1))},findIndex:function(t,e){var r=this.findEntry(t,e);return r?r[0]:-1},indexOf:function(t){var e=this.keyOf(t);return void 0===e?-1:e},lastIndexOf:function(t){var e=this.lastKeyOf(t);return void 0===e?-1:e},reverse:function(){return Jt(this,Tt(this,!1))},slice:function(t,e){return Jt(this,Kt(this,t,e,!1))},splice:function(t,e){var r=arguments.length;if(e=Math.max(e||0,0),0===r||2===r&&!e)return this;t=p(t,t<0?this.count():this.size);var n=this.slice(0,t);return Jt(this,1===r?n:n.concat(Gt(arguments,2),this.slice(t+e)))},findLastIndex:function(t,e){var r=this.findLastEntry(t,e);return r?r[0]:-1},first:function(t){return this.get(0,t)},flatten:function(t){return Jt(this,Ct(this,t,!1))},get:function(t,e){return(t=c(this,t))<0||this.size===1/0||void 0!==this.size&&t>this.size?e:this.find((function(e,r){return r===t}),void 0,e)},has:function(t){return(t=c(this,t))>=0&&(void 0!==this.size?this.size===1/0||te?-1:0}function en(t,e){return t^e+2654435769+(t<<6)+(t>>2)|0}Yr.has=Hr.includes,Yr.contains=Yr.includes,Yr.keys=Yr.values,Dr(F,Jr),Dr(G,Vr),Dr(Z,Yr);var rn=function(t){function e(t){return null==t?sn():jr(t)?t:sn().withMutations((function(e){var r=E(t);$t(r.size),r.forEach((function(t){return e.add(t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(I(t).keySeq())},e.prototype.toString=function(){return this.__toString("OrderedSet {","}")},e}(Ar);rn.isOrderedSet=jr;var nn,on=rn.prototype;function un(t,e){var r=Object.create(on);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function sn(){return nn||(nn=un(dr()))}on[A]=!0,on.zip=Vr.zip,on.zipWith=Vr.zipWith,on.zipAll=Vr.zipAll,on.__empty=sn,on.__make=un;var an=function(t,e){var r;!function(t){if(D(t))throw new Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(x(t))throw new Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(null===t||"object"!=typeof t)throw new Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}(t);var n=function(o){var u=this;if(o instanceof n)return o;if(!(this instanceof n))return new n(o);if(!r){r=!0;var s=Object.keys(t),a=i._indices={};i._name=e,i._keys=s,i._defaultValues=t;for(var c=0;c2?[]:void 0,{"":t})},t.get=ue,t.getIn=Cr,t.has=oe,t.hasIn=Wr,t.hash=vt,t.is=ht,t.isAssociative=S,t.isCollection=d,t.isImmutable=x,t.isIndexed=z,t.isKeyed=w,t.isList=er,t.isMap=at,t.isOrdered=k,t.isOrderedMap=ct,t.isOrderedSet=jr,t.isPlainObject=re,t.isRecord=D,t.isSeq=j,t.isSet=qr,t.isStack=mr,t.isValueObject=ft,t.merge=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return be(t,e)},t.mergeDeep=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Se(t,e)},t.mergeDeepWith=function(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];return Se(e,r,t)},t.mergeWith=function(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];return be(e,r,t)},t.remove=ae,t.removeIn=le,t.set=ce,t.setIn=pe,t.update=ye,t.updateIn=fe,t.version="5.0.3"})); +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).Immutable={})}(this,(function(t){"use strict";var e="delete",r=5,n=1<>>0;if(""+r!==e||4294967295===r)return NaN;e=r}return e<0?a(t)+e:e}function f(){return!0}function h(t,e,r){return(0===t&&!v(t)||void 0!==r&&t<=-r)&&(void 0===e||void 0!==r&&e>=r)}function p(t,e){return l(t,e,0)}function _(t,e){return l(t,e,e)}function l(t,e,r){return void 0===t?r:v(t)?e===1/0?e:0|Math.max(0,e+t):void 0===e||e===t?t:0|Math.min(e,t)}function v(t){return t<0||0===t&&1/t==-1/0}var y="@@__IMMUTABLE_ITERABLE__@@";function d(t){return Boolean(t&&t[y])}var g="@@__IMMUTABLE_KEYED__@@";function w(t){return Boolean(t&&t[g])}var m="@@__IMMUTABLE_INDEXED__@@";function b(t){return Boolean(t&&t[m])}function z(t){return w(t)||b(t)}var S=function(t){return d(t)?t:X(t)},I=function(t){function e(t){return w(t)?t:F(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(S),O=function(t){function e(t){return b(t)?t:G(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(S),E=function(t){function e(t){return d(t)&&!z(t)?t:Z(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(S);S.Keyed=I,S.Indexed=O,S.Set=E;var j="@@__IMMUTABLE_SEQ__@@";function q(t){return Boolean(t&&t[j])}var M="@@__IMMUTABLE_RECORD__@@";function D(t){return Boolean(t&&t[M])}function x(t){return d(t)||D(t)}var A="@@__IMMUTABLE_ORDERED__@@";function k(t){return Boolean(t&&t[A])}var R=0,U=1,T=2,B="function"==typeof Symbol&&Symbol.iterator,K="@@iterator",L=B||K,C=function(t){this.next=t};function P(t,e,r,n){var i=t===R?e:t===U?r:[e,r];return n?n.value=i:n={value:i,done:!1},n}function W(){return{value:void 0,done:!0}}function N(t){return!!Array.isArray(t)||!!V(t)}function H(t){return t&&"function"==typeof t.next}function J(t){var e=V(t);return e&&e.call(t)}function V(t){var e=t&&(B&&t[B]||t[K]);if("function"==typeof e)return e}C.prototype.toString=function(){return"[Iterator]"},C.KEYS=R,C.VALUES=U,C.ENTRIES=T,C.prototype.inspect=C.prototype.toSource=function(){return this.toString()},C.prototype[L]=function(){return this};var Y=Object.prototype.hasOwnProperty;function Q(t){return!(!Array.isArray(t)&&"string"!=typeof t)||t&&"object"==typeof t&&Number.isInteger(t.length)&&t.length>=0&&(0===t.length?1===Object.keys(t).length:t.hasOwnProperty(t.length-1))}var X=function(t){function e(t){return null==t?nt():x(t)?t.toSeq():function(t){var e=ut(t);if(e)return(n=V(r=t))&&n===r.entries?e.fromEntrySeq():function(t){var e=V(t);return e&&e===t.keys}(t)?e.toSetSeq():e;var r,n;if("object"==typeof t)return new tt(t);throw new TypeError("Expected Array or collection object of values, or keyed object: "+t)}(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq {","}")},e.prototype.cacheResult=function(){return!this._cache&&this.__iterateUncached&&(this._cache=this.entrySeq().toArray(),this.size=this._cache.length),this},e.prototype.__iterate=function(t,e){var r=this._cache;if(r){for(var n=r.length,i=0;i!==n;){var o=r[e?n-++i:i++];if(!1===t(o[1],o[0],this))break}return i}return this.__iterateUncached(t,e)},e.prototype.__iterator=function(t,e){var r=this._cache;if(r){var n=r.length,i=0;return new C((function(){if(i===n)return{value:void 0,done:!0};var o=r[e?n-++i:i++];return P(t,o[0],o[1])}))}return this.__iteratorUncached(t,e)},e}(S),F=function(t){function e(t){return null==t?nt().toKeyedSeq():d(t)?w(t)?t.toSeq():t.fromEntrySeq():D(t)?t.toSeq():it(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toKeyedSeq=function(){return this},e}(X),G=function(t){function e(t){return null==t?nt():d(t)?w(t)?t.entrySeq():t.toIndexedSeq():D(t)?t.toSeq().entrySeq():ot(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return e(arguments)},e.prototype.toIndexedSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq [","]")},e}(X),Z=function(t){function e(t){return(d(t)&&!z(t)?t:G(t)).toSetSeq()}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return e(arguments)},e.prototype.toSetSeq=function(){return this},e}(X);X.isSeq=q,X.Keyed=F,X.Set=Z,X.Indexed=G,X.prototype[j]=!0;var $=function(t){function e(t){this._array=t,this.size=t.length}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t,e){return this.has(t)?this._array[c(this,t)]:e},e.prototype.__iterate=function(t,e){for(var r=this._array,n=r.length,i=0;i!==n;){var o=e?n-++i:i++;if(!1===t(r[o],o,this))break}return i},e.prototype.__iterator=function(t,e){var r=this._array,n=r.length,i=0;return new C((function(){if(i===n)return{value:void 0,done:!0};var o=e?n-++i:i++;return P(t,o,r[o])}))},e}(G),tt=function(t){function e(t){var e=Object.keys(t).concat(Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(t):[]);this._object=t,this._keys=e,this.size=e.length}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t,e){return void 0===e||this.has(t)?this._object[t]:e},e.prototype.has=function(t){return Y.call(this._object,t)},e.prototype.__iterate=function(t,e){for(var r=this._object,n=this._keys,i=n.length,o=0;o!==i;){var u=n[e?i-++o:o++];if(!1===t(r[u],u,this))break}return o},e.prototype.__iterator=function(t,e){var r=this._object,n=this._keys,i=n.length,o=0;return new C((function(){if(o===i)return{value:void 0,done:!0};var u=n[e?i-++o:o++];return P(t,u,r[u])}))},e}(F);tt.prototype[A]=!0;var et,rt=function(t){function e(t){this._collection=t,this.size=t.length||t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.__iterateUncached=function(t,e){if(e)return this.cacheResult().__iterate(t,e);var r=J(this._collection),n=0;if(H(r))for(var i;!(i=r.next()).done&&!1!==t(i.value,n++,this););return n},e.prototype.__iteratorUncached=function(t,e){if(e)return this.cacheResult().__iterator(t,e);var r=J(this._collection);if(!H(r))return new C(W);var n=0;return new C((function(){var e=r.next();return e.done?e:P(t,n++,e.value)}))},e}(G);function nt(){return et||(et=new $([]))}function it(t){var e=ut(t);if(e)return e.fromEntrySeq();if("object"==typeof t)return new tt(t);throw new TypeError("Expected Array or collection object of [k, v] entries, or keyed object: "+t)}function ot(t){var e=ut(t);if(e)return e;throw new TypeError("Expected Array or collection object of values: "+t)}function ut(t){return Q(t)?new $(t):N(t)?new rt(t):void 0}var st="@@__IMMUTABLE_MAP__@@";function at(t){return Boolean(t&&t[st])}function ct(t){return at(t)&&k(t)}function ft(t){return Boolean(t&&"function"==typeof t.equals&&"function"==typeof t.hashCode)}function ht(t,e){if(t===e||t!=t&&e!=e)return!0;if(!t||!e)return!1;if("function"==typeof t.valueOf&&"function"==typeof e.valueOf){if((t=t.valueOf())===(e=e.valueOf())||t!=t&&e!=e)return!0;if(!t||!e)return!1}return!!(ft(t)&&ft(e)&&t.equals(e))}var pt="function"==typeof Math.imul&&-2===Math.imul(4294967295,2)?Math.imul:function(t,e){var r=65535&(t|=0),n=65535&(e|=0);return r*n+((t>>>16)*n+r*(e>>>16)<<16>>>0)|0};function _t(t){return t>>>1&1073741824|3221225471&t}var lt=Object.prototype.valueOf;function vt(t){if(null==t)return yt(t);if("function"==typeof t.hashCode)return _t(t.hashCode(t));var e,r=(e=t).valueOf!==lt&&"function"==typeof e.valueOf?e.valueOf(e):e;if(null==r)return yt(r);switch(typeof r){case"boolean":return r?1108378657:1108378656;case"number":return function(t){if(t!=t||t===1/0)return 0;var e=0|t;e!==t&&(e^=4294967295*t);for(;t>4294967295;)e^=t/=4294967295;return _t(e)}(r);case"string":return r.length>Et?function(t){var e=Mt[t];void 0===e&&(e=dt(t),qt===jt&&(qt=0,Mt={}),qt++,Mt[t]=e);return e}(r):dt(r);case"object":case"function":return function(t){var e;if(zt&&void 0!==(e=bt.get(t)))return e;if(e=t[Ot],void 0!==e)return e;if(!wt){if(void 0!==(e=t.propertyIsEnumerable&&t.propertyIsEnumerable[Ot]))return e;if(void 0!==(e=function(t){if(t&&t.nodeType>0)switch(t.nodeType){case 1:return t.uniqueID;case 9:return t.documentElement&&t.documentElement.uniqueID}}(t)))return e}if(e=mt(),zt)bt.set(t,e);else{if(void 0!==gt&&!1===gt(t))throw new Error("Non-extensible objects are not allowed as keys.");if(wt)Object.defineProperty(t,Ot,{enumerable:!1,configurable:!1,writable:!1,value:e});else if(void 0!==t.propertyIsEnumerable&&t.propertyIsEnumerable===t.constructor.prototype.propertyIsEnumerable)t.propertyIsEnumerable=function(){return this.constructor.prototype.propertyIsEnumerable.apply(this,arguments)},t.propertyIsEnumerable[Ot]=e;else{if(void 0===t.nodeType)throw new Error("Unable to set a non-enumerable property on object.");t[Ot]=e}}return e}(r);case"symbol":return function(t){var e=St[t];if(void 0!==e)return e;return e=mt(),St[t]=e,e}(r);default:if("function"==typeof r.toString)return dt(r.toString());throw new Error("Value type "+typeof r+" cannot be hashed.")}}function yt(t){return null===t?1108378658:1108378659}function dt(t){for(var e=0,r=0;r=0&&(a.get=function(e,r){return(e=c(this,e))>=0&&eo)return{value:void 0,done:!0};var t=i.next();return n||e===U||t.done?t:P(e,a-1,e===R?void 0:t.value[1],t)}))},a}function Lt(t,e,r,n){var i=Xt(t);return i.__iterateUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterate(i,o);var s=!0,a=0;return t.__iterate((function(t,o,c){if(!s||!(s=e.call(r,t,o,c)))return a++,i(t,n?o:a-1,u)})),a},i.__iteratorUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterator(i,o);var s=t.__iterator(T,o),a=!0,c=0;return new C((function(){var t,o,f;do{if((t=s.next()).done)return n||i===U?t:P(i,c++,i===R?void 0:t.value[1],t);var h=t.value;o=h[0],f=h[1],a&&(a=e.call(r,f,o,u))}while(a);return i===T?t:P(i,o,f,t)}))},i}xt.prototype.cacheResult=Dt.prototype.cacheResult=At.prototype.cacheResult=kt.prototype.cacheResult=Ft;var Ct=function(t){function e(t){this._wrappedIterables=t.flatMap((function(t){return t._wrappedIterables?t._wrappedIterables:[t]})),this.size=this._wrappedIterables.reduce((function(t,e){if(void 0!==t){var r=e.size;if(void 0!==r)return t+r}}),0),this[g]=this._wrappedIterables[0][g],this[m]=this._wrappedIterables[0][m],this[A]=this._wrappedIterables[0][A]}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.__iterateUncached=function(t,e){if(0!==this._wrappedIterables.length){if(e)return this.cacheResult().__iterate(t,e);for(var r=0,n=w(this),i=n?T:U,o=this._wrappedIterables[r].__iterator(i,e),u=!0,s=0;u;){for(var a=o.next();a.done;){if(++r===this._wrappedIterables.length)return s;a=(o=this._wrappedIterables[r].__iterator(i,e)).next()}u=!1!==(n?t(a.value[1],a.value[0],this):t(a.value,s,this)),s++}return s}},e.prototype.__iteratorUncached=function(t,e){var r=this;if(0===this._wrappedIterables.length)return new C(W);if(e)return this.cacheResult().__iterator(t,e);var n=0,i=this._wrappedIterables[n].__iterator(t,e);return new C((function(){for(var o=i.next();o.done;){if(++n===r._wrappedIterables.length)return o;o=(i=r._wrappedIterables[n].__iterator(t,e)).next()}return o}))},e}(X);function Pt(t,e,r){var n=Xt(t);return n.__iterateUncached=function(i,o){if(o)return this.cacheResult().__iterate(i,o);var u=0,s=!1;return function t(a,c){a.__iterate((function(o,a){return(!e||c0}function Jt(t,e,r,n){var i=Xt(t),o=new $(r).map((function(t){return t.size}));return i.size=n?o.max():o.min(),i.__iterate=function(t,e){for(var r,n=this.__iterator(U,e),i=0;!(r=n.next()).done&&!1!==t(r.value,i++,this););return i},i.__iteratorUncached=function(t,i){var o=r.map((function(t){return t=S(t),J(i?t.reverse():t)})),u=0,s=!1;return new C((function(){var r;return s||(r=o.map((function(t){return t.next()})),s=n?r.every((function(t){return t.done})):r.some((function(t){return t.done}))),s?{value:void 0,done:!0}:P(t,u++,e.apply(null,r.map((function(t){return t.value}))))}))},i}function Vt(t,e){return t===e?t:q(t)?e:t.constructor(e)}function Yt(t){if(t!==Object(t))throw new TypeError("Expected [K, V] tuple: "+t)}function Qt(t){return w(t)?I:b(t)?O:E}function Xt(t){return Object.create((w(t)?F:b(t)?G:Z).prototype)}function Ft(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size,this):X.prototype.cacheResult.call(this)}function Gt(t,e){return void 0===t&&void 0===e?0:void 0===t?1:void 0===e?-1:t>e?1:t0;)e[r]=arguments[r+1];if("function"!=typeof t)throw new TypeError("Invalid merger function: "+t);return ze(this,e,t)}function ze(t,e,r){for(var n=[],i=0;i0;)e[r]=arguments[r+1];return Se(this,e,t)}function je(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return he(this,t,Je(),(function(t){return Ie(t,e)}))}function qe(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return he(this,t,Je(),(function(t){return Se(t,e)}))}function Me(t){var e=this.asMutable();return t(e),e.wasAltered()?e.__ensureOwner(this.__ownerID):this}function De(){return this.__ownerID?this:this.__ensureOwner(new s)}function xe(){return this.__ensureOwner()}function Ae(){return this.__altered}var ke=function(t){function e(e){return null==e?Je():at(e)&&!k(e)?e:Je().withMutations((function(r){var n=t(e);te(n.size),n.forEach((function(t,e){return r.set(e,t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toString=function(){return this.__toString("Map {","}")},e.prototype.get=function(t,e){return this._root?this._root.get(0,void 0,t,e):e},e.prototype.set=function(t,e){return Ve(this,t,e)},e.prototype.remove=function(t){return Ve(this,t,o)},e.prototype.deleteAll=function(t){var e=S(t);return 0===e.size?this:this.withMutations((function(t){e.forEach((function(e){return t.remove(e)}))}))},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):Je()},e.prototype.sort=function(t){return yr(Wt(this,t))},e.prototype.sortBy=function(t,e){return yr(Wt(this,e,t))},e.prototype.map=function(t,e){var r=this;return this.withMutations((function(n){n.forEach((function(i,o){n.set(o,t.call(e,i,o,r))}))}))},e.prototype.__iterator=function(t,e){return new Pe(this,t,e)},e.prototype.__iterate=function(t,e){var r=this,n=0;return this._root&&this._root.iterate((function(e){return n++,t(e[1],e[0],r)}),e),n},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?He(this.size,this._root,t,this.__hash):0===this.size?Je():(this.__ownerID=t,this.__altered=!1,this)},e}(I);ke.isMap=at;var Re=ke.prototype;Re[st]=!0,Re[e]=Re.remove,Re.removeAll=Re.deleteAll,Re.setIn=le,Re.removeIn=Re.deleteIn=ye,Re.update=ge,Re.updateIn=we,Re.merge=Re.concat=me,Re.mergeWith=be,Re.mergeDeep=Oe,Re.mergeDeepWith=Ee,Re.mergeIn=je,Re.mergeDeepIn=qe,Re.withMutations=Me,Re.wasAltered=Ae,Re.asImmutable=xe,Re["@@transducer/init"]=Re.asMutable=De,Re["@@transducer/step"]=function(t,e){return t.set(e[0],e[1])},Re["@@transducer/result"]=function(t){return t.asImmutable()};var Ue=function(t,e){this.ownerID=t,this.entries=e};Ue.prototype.get=function(t,e,r,n){for(var i=this.entries,o=0,u=i.length;o=Ze)return function(t,e,r,n){t||(t=new s);for(var i=new Le(t,vt(r),[r,n]),o=0;o>>t)&i),s=this.bitmap;return 0==(s&u)?o:this.nodes[Fe(s&u-1)].get(t+r,e,n,o)},Te.prototype.update=function(t,e,u,s,a,c,f){void 0===u&&(u=vt(s));var h=(0===e?u:u>>>e)&i,p=1<=$e)return function(t,e,r,i,o){for(var u=0,s=new Array(n),a=0;0!==r;a++,r>>>=1)s[a]=1&r?e[u++]:void 0;return s[i]=o,new Be(t,u+1,s)}(t,y,_,h,g);if(l&&!g&&2===y.length&&Qe(y[1^v]))return y[1^v];if(l&&g&&1===y.length&&Qe(g))return g;var w=t&&t===this.ownerID,m=l?g?_:_^p:_|p,b=l?g?Ge(y,v,g,w):function(t,e,r){var n=t.length-1;if(r&&e===n)return t.pop(),t;for(var i=new Array(n),o=0,u=0;u>>t)&i,s=this.nodes[u];return s?s.get(t+r,e,n,o):o},Be.prototype.update=function(t,e,n,u,s,a,c){void 0===n&&(n=vt(u));var f=(0===e?n:n>>>e)&i,h=s===o,p=this.nodes,_=p[f];if(h&&!_)return this;var l=Ye(_,t,e+r,n,u,s,a,c);if(l===_)return this;var v=this.count;if(_){if(!l&&--v>>n)&i,c=(0===n?o:o>>>n)&i,f=a===c?[Xe(t,e,n+r,o,u)]:(s=new Le(e,o,u),a>1&1431655765))+(t>>2&858993459))+(t>>4)&252645135,t+=t>>8,127&(t+=t>>16)}function Ge(t,e,r,n){var i=n?t:Zt(t);return i[e]=r,i}var Ze=n/4,$e=n/2,tr=n/4,er="@@__IMMUTABLE_LIST__@@";function rr(t){return Boolean(t&&t[er])}var nr=function(t){function e(e){var i=cr();if(null==e)return i;if(rr(e))return e;var o=t(e),u=o.size;return 0===u?i:(te(u),u>0&&u=0&&t=t.size||e<0)return t.withMutations((function(t){e<0?_r(t,e).set(0,r):_r(t,0,e+1).set(e,r)}));e+=t._origin;var n=t._tail,i=t._root,o={value:!1};e>=lr(t._capacity)?n=fr(n,t.__ownerID,0,e,r,o):i=fr(i,t.__ownerID,t._level,e,r,o);if(!o.value)return t;if(t.__ownerID)return t._root=i,t._tail=n,t.__hash=void 0,t.__altered=!0,t;return ar(t._origin,t._capacity,t._level,i,n)}(this,t,e)},e.prototype.remove=function(t){return this.has(t)?0===t?this.shift():t===this.size-1?this.pop():this.splice(t,1):this},e.prototype.insert=function(t,e){return this.splice(t,0,e)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=this._origin=this._capacity=0,this._level=r,this._root=this._tail=this.__hash=void 0,this.__altered=!0,this):cr()},e.prototype.push=function(){var t=arguments,e=this.size;return this.withMutations((function(r){_r(r,0,e+t.length);for(var n=0;n>>e&i;if(o>=this.array.length)return new or([],t);var u,s=0===o;if(e>0){var a=this.array[o];if((u=a&&a.removeBefore(t,e-r,n))===a&&s)return this}if(s&&!u)return this;var c=hr(this,t);if(!s)for(var f=0;f>>e&i;if(s>=this.array.length)return this;if(e>0){var a=this.array[s];if((u=a&&a.removeAfter(t,e-r,o))===a&&s===this.array.length-1)return this}var c=hr(this,t);return c.array.splice(s+1),u&&(c.array[s]=u),c};var ur={};function sr(t,e){var i=t._origin,o=t._capacity,u=lr(o),s=t._tail;return a(t._root,t._level,0);function a(t,c,f){return 0===c?function(t,r){var a=r===u?s&&s.array:t&&t.array,c=r>i?0:i-r,f=o-r;f>n&&(f=n);return function(){if(c===f)return ur;var t=e?--f:c++;return a&&a[t]}}(t,f):function(t,u,s){var c,f=t&&t.array,h=s>i?0:i-s>>u,p=1+(o-s>>u);p>n&&(p=n);return function(){for(;;){if(c){var t=c();if(t!==ur)return t;c=null}if(h===p)return ur;var n=e?--p:h++;c=a(f&&f[n],u-r,s+(n<>>n&i,h=t&&f0){var p=t&&t.array[f],_=fr(p,e,n-r,o,s,a);return _===p?t:((c=hr(t,e)).array[f]=_,c)}return h&&t.array[f]===s?t:(a&&u(a),c=hr(t,e),void 0===s&&f===c.array.length-1?c.array.pop():c.array[f]=s,c)}function hr(t,e){return e&&t&&e===t.ownerID?t:new or(t?t.array.slice():[],e)}function pr(t,e){if(e>=lr(t._capacity))return t._tail;if(e<1<0;)n=n.array[e>>>o&i],o-=r;return n}}function _r(t,e,n){void 0!==e&&(e|=0),void 0!==n&&(n|=0);var o=t.__ownerID||new s,u=t._origin,a=t._capacity,c=u+e,f=void 0===n?a:n<0?a+n:u+n;if(c===u&&f===a)return t;if(c>=f)return t.clear();for(var h=t._level,p=t._root,_=0;c+_<0;)p=new or(p&&p.array.length?[void 0,p]:[],o),_+=1<<(h+=r);_&&(c+=_,u+=_,f+=_,a+=_);for(var l=lr(a),v=lr(f);v>=1<l?new or([],o):y;if(y&&v>l&&cr;w-=r){var m=l>>>w&i;g=g.array[m]=hr(g.array[m],o)}g.array[l>>>r&i]=y}if(f=v)c-=v,f-=v,h=r,p=null,d=d&&d.removeBefore(o,0,c);else if(c>u||v>>h&i;if(b!==v>>>h&i)break;b&&(_+=(1<u&&(p=p.removeBefore(o,h,c-_)),p&&v>>r<=n&&a.size>=2*s.size?(i=(u=a.filter((function(t,e){return void 0!==t&&c!==e}))).toKeyedSeq().map((function(t){return t[0]})).flip().toMap(),t.__ownerID&&(i.__ownerID=u.__ownerID=t.__ownerID)):(i=s.remove(e),u=c===a.size-1?a.pop():a.set(c,void 0))}else if(f){if(r===a.get(c)[1])return t;i=s,u=a.set(c,[e,r])}else i=s.set(e,a.size),u=a.set(a.size,[e,r]);return t.__ownerID?(t.size=i.size,t._map=i,t._list=u,t.__hash=void 0,t.__altered=!0,t):dr(i,u)}yr.isOrderedMap=ct,yr.prototype[A]=!0,yr.prototype[e]=yr.prototype.remove;var mr="@@__IMMUTABLE_STACK__@@";function br(t){return Boolean(t&&t[mr])}var zr=function(t){function e(t){return null==t?Er():br(t)?t:Er().pushAll(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("Stack [","]")},e.prototype.get=function(t,e){var r=this._head;for(t=c(this,t);r&&t--;)r=r.next;return r?r.value:e},e.prototype.peek=function(){return this._head&&this._head.value},e.prototype.push=function(){var t=arguments;if(0===arguments.length)return this;for(var e=this.size+arguments.length,r=this._head,n=arguments.length-1;n>=0;n--)r={value:t[n],next:r};return this.__ownerID?(this.size=e,this._head=r,this.__hash=void 0,this.__altered=!0,this):Or(e,r)},e.prototype.pushAll=function(e){if(0===(e=t(e)).size)return this;if(0===this.size&&br(e))return e;te(e.size);var r=this.size,n=this._head;return e.__iterate((function(t){r++,n={value:t,next:n}}),!0),this.__ownerID?(this.size=r,this._head=n,this.__hash=void 0,this.__altered=!0,this):Or(r,n)},e.prototype.pop=function(){return this.slice(1)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):Er()},e.prototype.slice=function(e,r){if(h(e,r,this.size))return this;var n=p(e,this.size);if(_(r,this.size)!==this.size)return t.prototype.slice.call(this,e,r);for(var i=this.size-n,o=this._head;n--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):Or(i,o)},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Or(this.size,this._head,t,this.__hash):0===this.size?Er():(this.__ownerID=t,this.__altered=!1,this)},e.prototype.__iterate=function(t,e){var r=this;if(e)return new $(this.toArray()).__iterate((function(e,n){return t(e,n,r)}),e);for(var n=0,i=this._head;i&&!1!==t(i.value,n++,this);)i=i.next;return n},e.prototype.__iterator=function(t,e){if(e)return new $(this.toArray()).__iterator(t,e);var r=0,n=this._head;return new C((function(){if(n){var e=n.value;return n=n.next,P(t,r++,e)}return{value:void 0,done:!0}}))},e}(O);zr.isStack=br;var Sr,Ir=zr.prototype;function Or(t,e,r,n){var i=Object.create(Ir);return i.size=t,i._head=e,i.__ownerID=r,i.__hash=n,i.__altered=!1,i}function Er(){return Sr||(Sr=Or(0))}Ir[mr]=!0,Ir.shift=Ir.pop,Ir.unshift=Ir.push,Ir.unshiftAll=Ir.pushAll,Ir.withMutations=Me,Ir.wasAltered=Ae,Ir.asImmutable=xe,Ir["@@transducer/init"]=Ir.asMutable=De,Ir["@@transducer/step"]=function(t,e){return t.unshift(e)},Ir["@@transducer/result"]=function(t){return t.asImmutable()};var jr="@@__IMMUTABLE_SET__@@";function qr(t){return Boolean(t&&t[jr])}function Mr(t){return qr(t)&&k(t)}function Dr(t,e){if(t===e)return!0;if(!d(e)||void 0!==t.size&&void 0!==e.size&&t.size!==e.size||void 0!==t.__hash&&void 0!==e.__hash&&t.__hash!==e.__hash||w(t)!==w(e)||b(t)!==b(e)||k(t)!==k(e))return!1;if(0===t.size&&0===e.size)return!0;var r=!z(t);if(k(t)){var n=t.entries();return e.every((function(t,e){var i=n.next().value;return i&&ht(i[1],t)&&(r||ht(i[0],e))}))&&n.next().done}var i=!1;if(void 0===t.size)if(void 0===e.size)"function"==typeof t.cacheResult&&t.cacheResult();else{i=!0;var u=t;t=e,e=u}var s=!0,a=e.__iterate((function(e,n){if(r?!t.has(e):i?!ht(e,t.get(n,o)):!ht(t.get(n,o),e))return s=!1,!1}));return s&&t.size===a}function xr(t,e){var r=function(r){t.prototype[r]=e[r]};return Object.keys(e).forEach(r),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(e).forEach(r),t}function Ar(t){if(!t||"object"!=typeof t)return t;if(!d(t)){if(!ie(t))return t;t=X(t)}if(w(t)){var e={};return t.__iterate((function(t,r){e[r]=Ar(t)})),e}var r=[];return t.__iterate((function(t){r.push(Ar(t))})),r}var kr=function(t){function e(e){return null==e?Kr():qr(e)&&!k(e)?e:Kr().withMutations((function(r){var n=t(e);te(n.size),n.forEach((function(t){return r.add(t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(I(t).keySeq())},e.intersect=function(t){return(t=S(t).toArray()).length?Ur.intersect.apply(e(t.pop()),t):Kr()},e.union=function(t){return(t=S(t).toArray()).length?Ur.union.apply(e(t.pop()),t):Kr()},e.prototype.toString=function(){return this.__toString("Set {","}")},e.prototype.has=function(t){return this._map.has(t)},e.prototype.add=function(t){return Tr(this,this._map.set(t,t))},e.prototype.remove=function(t){return Tr(this,this._map.remove(t))},e.prototype.clear=function(){return Tr(this,this._map.clear())},e.prototype.map=function(t,e){var r=this,n=!1,i=Tr(this,this._map.mapEntries((function(i){var o=i[1],u=t.call(e,o,o,r);return u!==o&&(n=!0),[u,u]}),e));return n?i:this},e.prototype.union=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return 0===(e=e.filter((function(t){return 0!==t.size}))).length?this:0!==this.size||this.__ownerID||1!==e.length?this.withMutations((function(r){for(var n=0;n=0&&e=0&&r>>-15,461845907),e=pt(e<<13|e>>>-13,5),e=pt((e=(e+3864292196|0)^t)^e>>>16,2246822507),e=_t((e=pt(e^e>>>13,3266489909))^e>>>16)}(t.size,n)}(this))}});var Jr=S.prototype;Jr[y]=!0,Jr[L]=Jr.values,Jr.toJSON=Jr.toArray,Jr.__toStringMapper=oe,Jr.inspect=Jr.toSource=function(){return this.toString()},Jr.chain=Jr.flatMap,Jr.contains=Jr.includes,xr(I,{flip:function(){return Vt(this,Rt(this))},mapEntries:function(t,e){var r=this,n=0;return Vt(this,this.toSeq().map((function(i,o){return t.call(e,[o,i],n++,r)})).fromEntrySeq())},mapKeys:function(t,e){var r=this;return Vt(this,this.toSeq().flip().map((function(n,i){return t.call(e,n,i,r)})).flip())}});var Vr=I.prototype;Vr[g]=!0,Vr[L]=Jr.entries,Vr.toJSON=Hr,Vr.__toStringMapper=function(t,e){return oe(e)+": "+oe(t)},xr(O,{toKeyedSeq:function(){return new Dt(this,!1)},filter:function(t,e){return Vt(this,Bt(this,t,e,!1))},findIndex:function(t,e){var r=this.findEntry(t,e);return r?r[0]:-1},indexOf:function(t){var e=this.keyOf(t);return void 0===e?-1:e},lastIndexOf:function(t){var e=this.lastKeyOf(t);return void 0===e?-1:e},reverse:function(){return Vt(this,Tt(this,!1))},slice:function(t,e){return Vt(this,Kt(this,t,e,!1))},splice:function(t,e){var r=arguments.length;if(e=Math.max(e||0,0),0===r||2===r&&!e)return this;t=p(t,t<0?this.count():this.size);var n=this.slice(0,t);return Vt(this,1===r?n:n.concat(Zt(arguments,2),this.slice(t+e)))},findLastIndex:function(t,e){var r=this.findLastEntry(t,e);return r?r[0]:-1},first:function(t){return this.get(0,t)},flatten:function(t){return Vt(this,Pt(this,t,!1))},get:function(t,e){return(t=c(this,t))<0||this.size===1/0||void 0!==this.size&&t>this.size?e:this.find((function(e,r){return r===t}),void 0,e)},has:function(t){return(t=c(this,t))>=0&&(void 0!==this.size?this.size===1/0||te?-1:0}function rn(t,e){return t^e+2654435769+(t<<6)+(t>>2)|0}Qr.has=Jr.includes,Qr.contains=Qr.includes,Qr.keys=Qr.values,xr(F,Vr),xr(G,Yr),xr(Z,Qr);var nn=function(t){function e(t){return null==t?an():Mr(t)?t:an().withMutations((function(e){var r=E(t);te(r.size),r.forEach((function(t){return e.add(t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(I(t).keySeq())},e.prototype.toString=function(){return this.__toString("OrderedSet {","}")},e}(kr);nn.isOrderedSet=Mr;var on,un=nn.prototype;function sn(t,e){var r=Object.create(un);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function an(){return on||(on=sn(gr()))}un[A]=!0,un.zip=Yr.zip,un.zipWith=Yr.zipWith,un.zipAll=Yr.zipAll,un.__empty=an,un.__make=sn;var cn=function(t,e){var r;!function(t){if(D(t))throw new Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(x(t))throw new Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(null===t||"object"!=typeof t)throw new Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}(t);var n=function(o){var u=this;if(o instanceof n)return o;if(!(this instanceof n))return new n(o);if(!r){r=!0;var s=Object.keys(t),a=i._indices={};i._name=e,i._keys=s,i._defaultValues=t;for(var c=0;c2?[]:void 0,{"":t})},t.get=se,t.getIn=Pr,t.has=ue,t.hasIn=Nr,t.hash=vt,t.is=ht,t.isAssociative=z,t.isCollection=d,t.isImmutable=x,t.isIndexed=b,t.isKeyed=w,t.isList=rr,t.isMap=at,t.isOrdered=k,t.isOrderedMap=ct,t.isOrderedSet=Mr,t.isPlainObject=ne,t.isRecord=D,t.isSeq=q,t.isSet=qr,t.isStack=br,t.isValueObject=ft,t.merge=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Ie(t,e)},t.mergeDeep=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Se(t,e)},t.mergeDeepWith=function(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];return Se(e,r,t)},t.mergeWith=function(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];return Ie(e,r,t)},t.remove=ce,t.removeIn=ve,t.set=fe,t.setIn=_e,t.update=de,t.updateIn=he,t.version="5.0.3"})); From f11d46f7f7507ea1a5082d200d66ed2d69753bac Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sat, 11 Jan 2025 22:04:55 +0000 Subject: [PATCH 221/242] deploy: a2bc1b475969ad5f28d128821dddccc320d82204 --- dist/immutable.d.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index b27aac2a74..fbf7d4a107 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -3675,6 +3675,15 @@ declare namespace Immutable { predicate: (this: C, value: V, key: K, iter: this) => unknown, context?: C ): [this, this]; + + /** + * Returns a new Sequence of the same type with other values and + * collection-like concatenated to this one. + * + * All entries will be present in the resulting Seq, even if they + * have the same key. + */ + concat(...valuesOrCollections: Array): Seq; } /** From 192cb564da2c7589d9b4580a15913eb495323676 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sun, 2 Feb 2025 13:03:40 +0000 Subject: [PATCH 222/242] deploy: 7d6920695c906ee28a5dace5bbc9afb501fd7263 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index bcb5d0b818..b9216576fa 100644 --- a/README.md +++ b/README.md @@ -126,9 +126,9 @@ collections in your [Flowtype](https://flowtype.org/) or [TypeScript](https://ty advantage of type generics, error detection, and auto-complete in your IDE. Installing `immutable` via npm brings with it type definitions for Flow (v0.55.0 or higher) -and TypeScript (v2.1.0 or higher), so you shouldn't need to do anything at all! +and TypeScript (v4.5 or higher), so you shouldn't need to do anything at all! -#### Using TypeScript with Immutable.js v4 +#### Using TypeScript with Immutable.js v4+ Immutable.js type definitions embrace ES2015. While Immutable.js itself supports legacy browsers and environments, its type definitions require TypeScript's 2015 From 7db66d3c4bef0bad583332d31b018ba591a3c9fb Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 12 Feb 2025 15:56:31 +0000 Subject: [PATCH 223/242] deploy: de415ecbd455ada02d4f461a9ce00f6fa84c412a --- dist/immutable.d.ts | 36 +++++++++++++++++++----------------- dist/immutable.es.js | 20 ++++++++++++++++++++ dist/immutable.js | 20 ++++++++++++++++++++ 3 files changed, 59 insertions(+), 17 deletions(-) diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index fbf7d4a107..fd74772164 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -1,5 +1,4 @@ /** @ignore we should disable this rules, but let's activate it to enable eslint first */ -/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types */ /** * Immutable data encourages pure functions (data-in, data-out) and lends itself * to much simpler application development and enabling techniques from @@ -853,7 +852,7 @@ declare namespace Immutable { * that does not guarantee the key was not found. */ get(key: K, notSetValue?: unknown): R[K]; - get(key: any, notSetValue: NSV): NSV; + get(key: unknown, notSetValue: NSV): NSV; // TODO `` can be used after dropping support for TypeScript 4.x // reference: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-0.html#const-type-parameters @@ -894,7 +893,7 @@ declare namespace Immutable { type GetMapType = S extends MapOf ? T : S; /** @ignore */ - type Head> = T extends [ + type Head> = T extends [ infer H, ...Array ] @@ -902,7 +901,7 @@ declare namespace Immutable { : never; /** @ignore */ - type Tail> = T extends [unknown, ...infer I] + type Tail> = T extends [unknown, ...infer I] ? I : Array; @@ -910,7 +909,7 @@ declare namespace Immutable { type RetrievePathReducer< T, C, - L extends ReadonlyArray + L extends ReadonlyArray > = C extends keyof GetMapType ? L extends [] ? GetMapType[C] @@ -2765,7 +2764,7 @@ declare namespace Immutable { /** * True if `maybeRecord` is an instance of a Record. */ - function isRecord(maybeRecord: unknown): maybeRecord is Record<{}>; + function isRecord(maybeRecord: unknown): maybeRecord is Record; /** * Records allow passing a second parameter to supply a descriptive name @@ -2784,7 +2783,9 @@ declare namespace Immutable { * Record.getDescriptiveName(me) // "Person" * ``` */ - function getDescriptiveName(record: Record): string; + function getDescriptiveName( + record: RecordOf + ): string; /** * A Record.Factory is created by the `Record()` function. Record instances @@ -2837,11 +2838,12 @@ declare namespace Immutable { namespace Factory {} interface Factory { - (values?: Partial | Iterable<[string, unknown]>): Record & - Readonly; + ( + values?: Partial | Iterable<[string, unknown]> + ): RecordOf; new ( values?: Partial | Iterable<[string, unknown]> - ): Record & Readonly; + ): RecordOf; /** * The name provided to `Record(values, name)` can be accessed with @@ -2852,7 +2854,7 @@ declare namespace Immutable { function Factory( values?: Partial | Iterable<[string, unknown]> - ): Record & Readonly; + ): RecordOf; } /** @@ -5416,14 +5418,14 @@ declare namespace Immutable { type FromJS = JSValue extends FromJSNoTransform ? JSValue - : JSValue extends Array + : JSValue extends Array ? FromJSArray - : JSValue extends {} + : JSValue extends object ? FromJSObject - : any; + : unknown; type FromJSNoTransform = - | Collection + | Collection | number | string | null @@ -5433,7 +5435,7 @@ declare namespace Immutable { ? List> : never; - type FromJSObject = JSValue extends {} + type FromJSObject = JSValue extends object ? Map> : never; @@ -5657,7 +5659,7 @@ declare namespace Immutable { /** * True if `maybeRecord` is a Record. */ - function isRecord(maybeRecord: unknown): maybeRecord is Record<{}>; + function isRecord(maybeRecord: unknown): maybeRecord is Record; /** * Returns the value within the provided collection associated with the diff --git a/dist/immutable.es.js b/dist/immutable.es.js index ad86c54397..9db9060981 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -238,6 +238,7 @@ Iterator.prototype[ITERATOR_SYMBOL] = function () { function iteratorValue(type, k, v, iteratorResult) { var value = type === ITERATE_KEYS ? k : type === ITERATE_VALUES ? v : [k, v]; + // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here iteratorResult ? (iteratorResult.value = value) : (iteratorResult = { @@ -972,6 +973,7 @@ var canDefineProperty = (function () { try { Object.defineProperty({}, '@', {}); return true; + // eslint-disable-next-line @typescript-eslint/no-unused-vars } catch (e) { return false; } @@ -1100,6 +1102,7 @@ var ToIndexedSequence = /*@__PURE__*/(function (IndexedSeq) { var this$1$1 = this; var i = 0; + // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here reverse && ensureSize(this); return this._iter.__iterate( function (v) { return fn(v, reverse ? this$1$1.size - ++i : i++, this$1$1); }, @@ -1112,6 +1115,7 @@ var ToIndexedSequence = /*@__PURE__*/(function (IndexedSeq) { var iterator = this._iter.__iterator(ITERATE_VALUES, reverse); var i = 0; + // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here reverse && ensureSize(this); return new Iterator(function () { var step = iterator.next(); @@ -1327,6 +1331,7 @@ function reverseFactory(collection, useKeys) { var this$1$1 = this; var i = 0; + // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here reverse && ensureSize(collection); return collection.__iterate( function (v, k) { return fn(v, useKeys ? k : reverse ? this$1$1.size - ++i : i++, this$1$1); }, @@ -1335,6 +1340,7 @@ function reverseFactory(collection, useKeys) { }; reversedSequence.__iterator = function (type, reverse) { var i = 0; + // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here reverse && ensureSize(collection); var iterator = collection.__iterator(ITERATE_ENTRIES, !reverse); return new Iterator(function () { @@ -1621,6 +1627,7 @@ function skipWhileFactory(collection, predicate, context, useKeys) { var entry = step.value; k = entry[0]; v = entry[1]; + // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here skipping && (skipping = predicate.call(context, v, k, this$1$1)); } while (skipping); return type === ITERATE_ENTRIES ? step : iteratorValue(type, k, v, step); @@ -2106,6 +2113,7 @@ function isDataStructure(value) { function quoteString(value) { try { return typeof value === 'string' ? JSON.stringify(value) : String(value); + // eslint-disable-next-line @typescript-eslint/no-unused-vars } catch (_ignoreError) { return JSON.stringify(value); } @@ -2575,6 +2583,7 @@ var Map = /*@__PURE__*/(function (KeyedCollection) { var this$1$1 = this; var iterations = 0; + // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here this._root && this._root.iterate(function (entry) { iterations++; @@ -2663,6 +2672,7 @@ ArrayMapNode.prototype.update = function update (ownerID, shift, keyHash, key, v } SetRef(didAlter); + // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here (removed || !exists) && SetRef(didChangeSize); if (removed && entries.length === 1) { @@ -2678,6 +2688,7 @@ ArrayMapNode.prototype.update = function update (ownerID, shift, keyHash, key, v if (exists) { if (removed) { + // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here idx === len - 1 ? newEntries.pop() : (newEntries[idx] = newEntries.pop()); @@ -2896,6 +2907,7 @@ HashCollisionNode.prototype.update = function update (ownerID, shift, keyHash, k } SetRef(didAlter); + // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here (removed || !exists) && SetRef(didChangeSize); if (removed && len === 2) { @@ -2907,6 +2919,7 @@ HashCollisionNode.prototype.update = function update (ownerID, shift, keyHash, k if (exists) { if (removed) { + // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here idx === len - 1 ? newEntries.pop() : (newEntries[idx] = newEntries.pop()); @@ -3661,6 +3674,7 @@ function updateList(list, index, value) { if (index >= list.size || index < 0) { return list.withMutations(function (list) { + // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here index < 0 ? setListBounds(list, index).set(0, value) : setListBounds(list, 0, index + 1).set(index, value); @@ -4393,6 +4407,7 @@ function mixin(ctor, methods) { ctor.prototype[key] = methods[key]; }; Object.keys(methods).forEach(keyCopier); + // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here Object.getOwnPropertySymbols && Object.getOwnPropertySymbols(methods).forEach(keyCopier); return ctor; @@ -4989,6 +5004,7 @@ mixin(Collection, { var joined = ''; var isFirst = true; this.__iterate(function (v) { + // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here isFirst ? (isFirst = false) : (joined += separator); joined += v !== null && v !== undefined ? v.toString() : ''; }); @@ -5679,6 +5695,7 @@ var Record = function Record(defaultValues, name) { indices[propName] = i; if (RecordTypePrototype[propName]) { /* eslint-disable no-console */ + // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here typeof console === 'object' && console.warn && console.warn( @@ -5868,6 +5885,7 @@ function setProp(prototype, name) { this.set(name, value); }, }); + // eslint-disable-next-line @typescript-eslint/no-unused-vars -- TODO enable eslint here } catch (error) { // Object.defineProperty failed. Probably IE8. } @@ -5996,6 +6014,7 @@ function fromJSWith(stack, converter, value, key, keyPath, parentValue) { throw new TypeError('Cannot convert circular structure to Immutable'); } stack.push(value); + // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here keyPath && key !== '' && keyPath.push(key); var converted = converter.call( parentValue, @@ -6005,6 +6024,7 @@ function fromJSWith(stack, converter, value, key, keyPath, parentValue) { keyPath && keyPath.slice() ); stack.pop(); + // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here keyPath && keyPath.pop(); return converted; } diff --git a/dist/immutable.js b/dist/immutable.js index 4f7ee1142f..12ee38c2dd 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -244,6 +244,7 @@ function iteratorValue(type, k, v, iteratorResult) { var value = type === ITERATE_KEYS ? k : type === ITERATE_VALUES ? v : [k, v]; + // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here iteratorResult ? (iteratorResult.value = value) : (iteratorResult = { @@ -978,6 +979,7 @@ try { Object.defineProperty({}, '@', {}); return true; + // eslint-disable-next-line @typescript-eslint/no-unused-vars } catch (e) { return false; } @@ -1106,6 +1108,7 @@ var this$1$1 = this; var i = 0; + // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here reverse && ensureSize(this); return this._iter.__iterate( function (v) { return fn(v, reverse ? this$1$1.size - ++i : i++, this$1$1); }, @@ -1118,6 +1121,7 @@ var iterator = this._iter.__iterator(ITERATE_VALUES, reverse); var i = 0; + // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here reverse && ensureSize(this); return new Iterator(function () { var step = iterator.next(); @@ -1333,6 +1337,7 @@ var this$1$1 = this; var i = 0; + // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here reverse && ensureSize(collection); return collection.__iterate( function (v, k) { return fn(v, useKeys ? k : reverse ? this$1$1.size - ++i : i++, this$1$1); }, @@ -1341,6 +1346,7 @@ }; reversedSequence.__iterator = function (type, reverse) { var i = 0; + // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here reverse && ensureSize(collection); var iterator = collection.__iterator(ITERATE_ENTRIES, !reverse); return new Iterator(function () { @@ -1627,6 +1633,7 @@ var entry = step.value; k = entry[0]; v = entry[1]; + // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here skipping && (skipping = predicate.call(context, v, k, this$1$1)); } while (skipping); return type === ITERATE_ENTRIES ? step : iteratorValue(type, k, v, step); @@ -2112,6 +2119,7 @@ function quoteString(value) { try { return typeof value === 'string' ? JSON.stringify(value) : String(value); + // eslint-disable-next-line @typescript-eslint/no-unused-vars } catch (_ignoreError) { return JSON.stringify(value); } @@ -2581,6 +2589,7 @@ var this$1$1 = this; var iterations = 0; + // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here this._root && this._root.iterate(function (entry) { iterations++; @@ -2669,6 +2678,7 @@ } SetRef(didAlter); + // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here (removed || !exists) && SetRef(didChangeSize); if (removed && entries.length === 1) { @@ -2684,6 +2694,7 @@ if (exists) { if (removed) { + // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here idx === len - 1 ? newEntries.pop() : (newEntries[idx] = newEntries.pop()); @@ -2902,6 +2913,7 @@ } SetRef(didAlter); + // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here (removed || !exists) && SetRef(didChangeSize); if (removed && len === 2) { @@ -2913,6 +2925,7 @@ if (exists) { if (removed) { + // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here idx === len - 1 ? newEntries.pop() : (newEntries[idx] = newEntries.pop()); @@ -3667,6 +3680,7 @@ if (index >= list.size || index < 0) { return list.withMutations(function (list) { + // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here index < 0 ? setListBounds(list, index).set(0, value) : setListBounds(list, 0, index + 1).set(index, value); @@ -4399,6 +4413,7 @@ ctor.prototype[key] = methods[key]; }; Object.keys(methods).forEach(keyCopier); + // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here Object.getOwnPropertySymbols && Object.getOwnPropertySymbols(methods).forEach(keyCopier); return ctor; @@ -4995,6 +5010,7 @@ var joined = ''; var isFirst = true; this.__iterate(function (v) { + // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here isFirst ? (isFirst = false) : (joined += separator); joined += v !== null && v !== undefined ? v.toString() : ''; }); @@ -5685,6 +5701,7 @@ indices[propName] = i; if (RecordTypePrototype[propName]) { /* eslint-disable no-console */ + // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here typeof console === 'object' && console.warn && console.warn( @@ -5874,6 +5891,7 @@ this.set(name, value); }, }); + // eslint-disable-next-line @typescript-eslint/no-unused-vars -- TODO enable eslint here } catch (error) { // Object.defineProperty failed. Probably IE8. } @@ -6002,6 +6020,7 @@ throw new TypeError('Cannot convert circular structure to Immutable'); } stack.push(value); + // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here keyPath && key !== '' && keyPath.push(key); var converted = converter.call( parentValue, @@ -6011,6 +6030,7 @@ keyPath && keyPath.slice() ); stack.pop(); + // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here keyPath && keyPath.pop(); return converted; } From e2f2be4059c0fd35fcca7656f1ffd56b4bfce5af Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 12 Feb 2025 21:52:47 +0000 Subject: [PATCH 224/242] deploy: 73b986c4eeba4a4c776ed70ca662e168de97eb13 --- dist/immutable.d.ts | 111 +++++++++++++------------ dist/immutable.es.js | 184 +++++++++++++++++++++-------------------- dist/immutable.js | 184 +++++++++++++++++++++-------------------- dist/immutable.js.flow | 120 +++++++++++++-------------- 4 files changed, 305 insertions(+), 294 deletions(-) diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index fd74772164..4d16cd3f5e 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -96,11 +96,12 @@ declare namespace Immutable { type OnlyObject = Extract; /** @ignore */ - type ContainObject = OnlyObject extends object - ? OnlyObject extends never - ? false - : true - : false; + type ContainObject = + OnlyObject extends object + ? OnlyObject extends never + ? false + : true + : false; /** * @ignore @@ -108,39 +109,46 @@ declare namespace Immutable { * Used to convert deeply all immutable types to a plain TS type. * Using `unknown` on object instead of recursive call as we have a circular reference issue */ - export type DeepCopy = T extends Record - ? // convert Record to DeepCopy plain JS object - { - [key in keyof R]: ContainObject extends true ? unknown : R[key]; - } - : T extends MapOf - ? // convert MapOf to DeepCopy plain JS object - { - [key in keyof R]: ContainObject extends true ? unknown : R[key]; - } - : T extends Collection.Keyed - ? // convert KeyedCollection to DeepCopy plain JS object - { - [key in KeyedKey extends string | number | symbol - ? KeyedKey - : string]: V extends object ? unknown : V; - } - : // convert IndexedCollection or Immutable.Set to DeepCopy plain JS array - // eslint-disable-next-line @typescript-eslint/no-unused-vars - T extends Collection - ? Array> - : T extends string | number // Iterable scalar types : should be kept as is - ? T - : T extends Iterable // Iterable are converted to plain JS array - ? Array> - : T extends object // plain JS object are converted deeply - ? { - [ObjectKey in keyof T]: ContainObject extends true - ? unknown - : T[ObjectKey]; - } - : // other case : should be kept as is - T; + export type DeepCopy = + T extends Record + ? // convert Record to DeepCopy plain JS object + { + [key in keyof R]: ContainObject extends true + ? unknown + : R[key]; + } + : T extends MapOf + ? // convert MapOf to DeepCopy plain JS object + { + [key in keyof R]: ContainObject extends true + ? unknown + : R[key]; + } + : T extends Collection.Keyed + ? // convert KeyedCollection to DeepCopy plain JS object + { + [key in KeyedKey extends string | number | symbol + ? KeyedKey + : string]: V extends object ? unknown : V; + } + : // convert IndexedCollection or Immutable.Set to DeepCopy plain JS array + // eslint-disable-next-line @typescript-eslint/no-unused-vars + T extends Collection + ? Array> + : T extends string | number // Iterable scalar types : should be kept as is + ? T + : T extends Iterable // Iterable are converted to plain JS array + ? Array> + : T extends object // plain JS object are converted deeply + ? { + [ObjectKey in keyof T]: ContainObject< + T[ObjectKey] + > extends true + ? unknown + : T[ObjectKey]; + } + : // other case : should be kept as is + T; /** * Describes which item in a pair should be placed first when sorting @@ -895,7 +903,7 @@ declare namespace Immutable { /** @ignore */ type Head> = T extends [ infer H, - ...Array + ...Array, ] ? H : never; @@ -909,7 +917,7 @@ declare namespace Immutable { type RetrievePathReducer< T, C, - L extends ReadonlyArray + L extends ReadonlyArray, > = C extends keyof GetMapType ? L extends [] ? GetMapType[C] @@ -919,7 +927,7 @@ declare namespace Immutable { /** @ignore */ type RetrievePath< R, - P extends ReadonlyArray + P extends ReadonlyArray, > = P extends [] ? P : RetrievePathReducer, Tail

>; interface Map extends Collection.Keyed { @@ -5419,10 +5427,10 @@ declare namespace Immutable { type FromJS = JSValue extends FromJSNoTransform ? JSValue : JSValue extends Array - ? FromJSArray - : JSValue extends object - ? FromJSObject - : unknown; + ? FromJSArray + : JSValue extends object + ? FromJSObject + : unknown; type FromJSNoTransform = | Collection @@ -5431,9 +5439,8 @@ declare namespace Immutable { | null | undefined; - type FromJSArray = JSValue extends Array - ? List> - : never; + type FromJSArray = + JSValue extends Array ? List> : never; type FromJSObject = JSValue extends object ? Map> @@ -5748,7 +5755,7 @@ declare namespace Immutable { function remove< TProps extends object, C extends Record, - K extends keyof TProps + K extends keyof TProps, >(collection: C, key: K): C; function remove>(collection: C, key: number): C; function remove(collection: C, key: K): C; @@ -5784,7 +5791,7 @@ declare namespace Immutable { function set< TProps extends object, C extends Record, - K extends keyof TProps + K extends keyof TProps, >(record: C, key: K, value: TProps[K]): C; function set>(collection: C, key: number, value: V): C; function set(object: C, key: K, value: C[K]): C; @@ -5827,13 +5834,13 @@ declare namespace Immutable { function update< TProps extends object, C extends Record, - K extends keyof TProps + K extends keyof TProps, >(record: C, key: K, updater: (value: TProps[K]) => TProps[K]): C; function update< TProps extends object, C extends Record, K extends keyof TProps, - NSV + NSV, >( record: C, key: K, diff --git a/dist/immutable.es.js b/dist/immutable.es.js index 9db9060981..57f620632f 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -101,12 +101,12 @@ function resolveIndex(index, size, defaultIndex) { return index === undefined ? defaultIndex : isNeg(index) - ? size === Infinity - ? size - : Math.max(0, size + index) | 0 - : size === undefined || size === index - ? index - : Math.min(size, index) | 0; + ? size === Infinity + ? size + : Math.max(0, size + index) | 0 + : size === undefined || size === index + ? index + : Math.min(size, index) | 0; } function isNeg(value) { @@ -317,8 +317,8 @@ var Seq = /*@__PURE__*/(function (Collection) { return value === undefined || value === null ? emptySequence() : isImmutable(value) - ? value.toSeq() - : seqFromValue(value); + ? value.toSeq() + : seqFromValue(value); } if ( Collection ) Seq.__proto__ = Collection; @@ -386,12 +386,12 @@ var KeyedSeq = /*@__PURE__*/(function (Seq) { return value === undefined || value === null ? emptySequence().toKeyedSeq() : isCollection(value) - ? isKeyed(value) - ? value.toSeq() - : value.fromEntrySeq() - : isRecord(value) - ? value.toSeq() - : keyedSeqFromValue(value); + ? isKeyed(value) + ? value.toSeq() + : value.fromEntrySeq() + : isRecord(value) + ? value.toSeq() + : keyedSeqFromValue(value); } if ( Seq ) KeyedSeq.__proto__ = Seq; @@ -411,12 +411,12 @@ var IndexedSeq = /*@__PURE__*/(function (Seq) { return value === undefined || value === null ? emptySequence() : isCollection(value) - ? isKeyed(value) - ? value.entrySeq() - : value.toIndexedSeq() - : isRecord(value) - ? value.toSeq().entrySeq() - : indexedSeqFromValue(value); + ? isKeyed(value) + ? value.entrySeq() + : value.toIndexedSeq() + : isRecord(value) + ? value.toSeq().entrySeq() + : indexedSeqFromValue(value); } if ( Seq ) IndexedSeq.__proto__ = Seq; @@ -655,8 +655,8 @@ function seqFromValue(value) { return isEntriesIterable(value) ? seq.fromEntrySeq() : isKeysIterable(value) - ? seq.toSetSeq() - : seq; + ? seq.toSetSeq() + : seq; } if (typeof value === 'object') { return new ObjectSeq(value); @@ -670,8 +670,8 @@ function maybeIndexedSeqFromValue(value) { return isArrayLike(value) ? new ArraySeq(value) : hasIterator(value) - ? new CollectionSeq(value) - : undefined; + ? new CollectionSeq(value) + : undefined; } var IS_MAP_SYMBOL = '@@__IMMUTABLE_MAP__@@'; @@ -1893,8 +1893,8 @@ function sortFactory(collection, comparator, mapper) { return isKeyedCollection ? KeyedSeq(entries) : isIndexed(collection) - ? IndexedSeq(entries) - : SetSeq(entries); + ? IndexedSeq(entries) + : SetSeq(entries); } function maxFactory(collection, comparator, mapper) { @@ -1961,7 +1961,9 @@ function zipWithFactory(keyIter, zipper, iters, zipAll) { var steps; if (!isDone) { steps = iterators.map(function (i) { return i.next(); }); - isDone = zipAll ? steps.every(function (s) { return s.done; }) : steps.some(function (s) { return s.done; }); + isDone = zipAll + ? steps.every(function (s) { return s.done; }) + : steps.some(function (s) { return s.done; }); } if (isDone) { return iteratorDone(); @@ -1995,8 +1997,8 @@ function collectionClass(collection) { return isKeyed(collection) ? KeyedCollection : isIndexed(collection) - ? IndexedCollection - : SetCollection; + ? IndexedCollection + : SetCollection; } function makeSequence(collection) { @@ -2004,8 +2006,8 @@ function makeSequence(collection) { (isKeyed(collection) ? KeyedSeq : isIndexed(collection) - ? IndexedSeq - : SetSeq + ? IndexedSeq + : SetSeq ).prototype ); } @@ -2129,10 +2131,10 @@ function get(collection, key, notSetValue) { return isImmutable(collection) ? collection.get(key, notSetValue) : !has(collection, key) - ? notSetValue - : typeof collection.get === 'function' - ? collection.get(key) - : collection[key]; + ? notSetValue + : typeof collection.get === 'function' + ? collection.get(key) + : collection[key]; } function shallowCopy(from) { @@ -2247,12 +2249,12 @@ function updateInDeeply( return nextUpdated === nextExisting ? existing : nextUpdated === NOT_SET - ? remove(existing, key) - : set( - wasNotSet ? (inImmutable ? emptyMap() : {}) : existing, - key, - nextUpdated - ); + ? remove(existing, key) + : set( + wasNotSet ? (inImmutable ? emptyMap() : {}) : existing, + key, + nextUpdated + ); } function setIn$1(collection, keyPath, value) { @@ -2377,8 +2379,8 @@ function mergeWithSources(collection, sources, merger) { return typeof merger === 'function' && collection.mergeWith ? collection.mergeWith.apply(collection, [ merger ].concat( sources )) : collection.merge - ? collection.merge.apply(collection, sources) - : collection.concat.apply(collection, sources); + ? collection.merge.apply(collection, sources) + : collection.concat.apply(collection, sources); } var isArray = Array.isArray(collection); var merged = collection; @@ -2416,8 +2418,8 @@ function deepMergerWith(merger) { areMergeable(oldValue, newValue) ? mergeWithSources(oldValue, [newValue], deepMerger) : merger - ? merger(oldValue, newValue, key) - : newValue; + ? merger(oldValue, newValue, key) + : newValue; } return deepMerger; } @@ -2491,12 +2493,12 @@ var Map = /*@__PURE__*/(function (KeyedCollection) { return value === undefined || value === null ? emptyMap() : isMap(value) && !isOrdered(value) - ? value - : emptyMap().withMutations(function (map) { - var iter = KeyedCollection(value); - assertNotInfinite(iter.size); - iter.forEach(function (v, k) { return map.set(k, v); }); - }); + ? value + : emptyMap().withMutations(function (map) { + var iter = KeyedCollection(value); + assertNotInfinite(iter.size); + iter.forEach(function (v, k) { return map.set(k, v); }); + }); } if ( KeyedCollection ) Map.__proto__ = KeyedCollection; @@ -3330,10 +3332,10 @@ var List = /*@__PURE__*/(function (IndexedCollection) { return !this.has(index) ? this : index === 0 - ? this.shift() - : index === this.size - 1 - ? this.pop() - : this.splice(index, 1); + ? this.shift() + : index === this.size - 1 + ? this.pop() + : this.splice(index, 1); }; List.prototype.insert = function insert (index, value) { @@ -3796,8 +3798,8 @@ function setListBounds(list, begin, end) { end === undefined ? oldCapacity : end < 0 - ? oldCapacity + end - : oldOrigin + end; + ? oldCapacity + end + : oldOrigin + end; if (newOrigin === oldOrigin && newCapacity === oldCapacity) { return list; } @@ -3845,8 +3847,8 @@ function setListBounds(list, begin, end) { newTailOffset < oldTailOffset ? listNodeFor(list, newCapacity - 1) : newTailOffset > oldTailOffset - ? new VNode([], owner) - : oldTail; + ? new VNode([], owner) + : oldTail; // Merge Tail into tree. if ( @@ -3935,12 +3937,12 @@ var OrderedMap = /*@__PURE__*/(function (Map) { return value === undefined || value === null ? emptyOrderedMap() : isOrderedMap(value) - ? value - : emptyOrderedMap().withMutations(function (map) { - var iter = KeyedCollection(value); - assertNotInfinite(iter.size); - iter.forEach(function (v, k) { return map.set(k, v); }); - }); + ? value + : emptyOrderedMap().withMutations(function (map) { + var iter = KeyedCollection(value); + assertNotInfinite(iter.size); + iter.forEach(function (v, k) { return map.set(k, v); }); + }); } if ( Map ) OrderedMap.__proto__ = Map; @@ -4104,8 +4106,8 @@ var Stack = /*@__PURE__*/(function (IndexedCollection) { return value === undefined || value === null ? emptyStack() : isStack(value) - ? value - : emptyStack().pushAll(value); + ? value + : emptyStack().pushAll(value); } if ( IndexedCollection ) Stack.__proto__ = IndexedCollection; @@ -4388,8 +4390,8 @@ function deepEqual(a, b) { notAssociative ? !a.has(v) : flipped - ? !is(v, a.get(k, NOT_SET)) - : !is(a.get(k, NOT_SET), v) + ? !is(v, a.get(k, NOT_SET)) + : !is(a.get(k, NOT_SET), v) ) { allEqual = false; return false; @@ -4443,12 +4445,12 @@ var Set = /*@__PURE__*/(function (SetCollection) { return value === undefined || value === null ? emptySet() : isSet(value) && !isOrdered(value) - ? value - : emptySet().withMutations(function (set) { - var iter = SetCollection(value); - assertNotInfinite(iter.size); - iter.forEach(function (v) { return set.add(v); }); - }); + ? value + : emptySet().withMutations(function (set) { + var iter = SetCollection(value); + assertNotInfinite(iter.size); + iter.forEach(function (v) { return set.add(v); }); + }); } if ( SetCollection ) Set.__proto__ = SetCollection; @@ -4662,8 +4664,8 @@ function updateSet(set, newMap) { return newMap === set._map ? set : newMap.size === 0 - ? set.__empty() - : set.__make(newMap); + ? set.__empty() + : set.__make(newMap); } function makeSet(map, ownerID) { @@ -4918,8 +4920,8 @@ mixin(Collection, { return isIndexed(this) ? this.toIndexedSeq() : isKeyed(this) - ? this.toKeyedSeq() - : this.toSetSeq(); + ? this.toKeyedSeq() + : this.toSetSeq(); }, toStack: function toStack() { @@ -5556,12 +5558,12 @@ function hashCollection(collection) { h = (h + hashMerge(hash(v), hash(k))) | 0; } : ordered - ? function (v) { - h = (31 * h + hash(v)) | 0; - } - : function (v) { - h = (h + hash(v)) | 0; - } + ? function (v) { + h = (31 * h + hash(v)) | 0; + } + : function (v) { + h = (h + hash(v)) | 0; + } ); return murmurHashOfSize(collection.size, h); @@ -5588,12 +5590,12 @@ var OrderedSet = /*@__PURE__*/(function (Set) { return value === undefined || value === null ? emptyOrderedSet() : isOrderedSet(value) - ? value - : emptyOrderedSet().withMutations(function (set) { - var iter = SetCollection(value); - assertNotInfinite(iter.size); - iter.forEach(function (v) { return set.add(v); }); - }); + ? value + : emptyOrderedSet().withMutations(function (set) { + var iter = SetCollection(value); + assertNotInfinite(iter.size); + iter.forEach(function (v) { return set.add(v); }); + }); } if ( Set ) OrderedSet.__proto__ = Set; diff --git a/dist/immutable.js b/dist/immutable.js index 12ee38c2dd..850187ec2c 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -107,12 +107,12 @@ return index === undefined ? defaultIndex : isNeg(index) - ? size === Infinity - ? size - : Math.max(0, size + index) | 0 - : size === undefined || size === index - ? index - : Math.min(size, index) | 0; + ? size === Infinity + ? size + : Math.max(0, size + index) | 0 + : size === undefined || size === index + ? index + : Math.min(size, index) | 0; } function isNeg(value) { @@ -323,8 +323,8 @@ return value === undefined || value === null ? emptySequence() : isImmutable(value) - ? value.toSeq() - : seqFromValue(value); + ? value.toSeq() + : seqFromValue(value); } if ( Collection ) Seq.__proto__ = Collection; @@ -392,12 +392,12 @@ return value === undefined || value === null ? emptySequence().toKeyedSeq() : isCollection(value) - ? isKeyed(value) - ? value.toSeq() - : value.fromEntrySeq() - : isRecord(value) - ? value.toSeq() - : keyedSeqFromValue(value); + ? isKeyed(value) + ? value.toSeq() + : value.fromEntrySeq() + : isRecord(value) + ? value.toSeq() + : keyedSeqFromValue(value); } if ( Seq ) KeyedSeq.__proto__ = Seq; @@ -417,12 +417,12 @@ return value === undefined || value === null ? emptySequence() : isCollection(value) - ? isKeyed(value) - ? value.entrySeq() - : value.toIndexedSeq() - : isRecord(value) - ? value.toSeq().entrySeq() - : indexedSeqFromValue(value); + ? isKeyed(value) + ? value.entrySeq() + : value.toIndexedSeq() + : isRecord(value) + ? value.toSeq().entrySeq() + : indexedSeqFromValue(value); } if ( Seq ) IndexedSeq.__proto__ = Seq; @@ -661,8 +661,8 @@ return isEntriesIterable(value) ? seq.fromEntrySeq() : isKeysIterable(value) - ? seq.toSetSeq() - : seq; + ? seq.toSetSeq() + : seq; } if (typeof value === 'object') { return new ObjectSeq(value); @@ -676,8 +676,8 @@ return isArrayLike(value) ? new ArraySeq(value) : hasIterator(value) - ? new CollectionSeq(value) - : undefined; + ? new CollectionSeq(value) + : undefined; } var IS_MAP_SYMBOL = '@@__IMMUTABLE_MAP__@@'; @@ -1899,8 +1899,8 @@ return isKeyedCollection ? KeyedSeq(entries) : isIndexed(collection) - ? IndexedSeq(entries) - : SetSeq(entries); + ? IndexedSeq(entries) + : SetSeq(entries); } function maxFactory(collection, comparator, mapper) { @@ -1967,7 +1967,9 @@ var steps; if (!isDone) { steps = iterators.map(function (i) { return i.next(); }); - isDone = zipAll ? steps.every(function (s) { return s.done; }) : steps.some(function (s) { return s.done; }); + isDone = zipAll + ? steps.every(function (s) { return s.done; }) + : steps.some(function (s) { return s.done; }); } if (isDone) { return iteratorDone(); @@ -2001,8 +2003,8 @@ return isKeyed(collection) ? KeyedCollection : isIndexed(collection) - ? IndexedCollection - : SetCollection; + ? IndexedCollection + : SetCollection; } function makeSequence(collection) { @@ -2010,8 +2012,8 @@ (isKeyed(collection) ? KeyedSeq : isIndexed(collection) - ? IndexedSeq - : SetSeq + ? IndexedSeq + : SetSeq ).prototype ); } @@ -2135,10 +2137,10 @@ return isImmutable(collection) ? collection.get(key, notSetValue) : !has(collection, key) - ? notSetValue - : typeof collection.get === 'function' - ? collection.get(key) - : collection[key]; + ? notSetValue + : typeof collection.get === 'function' + ? collection.get(key) + : collection[key]; } function shallowCopy(from) { @@ -2253,12 +2255,12 @@ return nextUpdated === nextExisting ? existing : nextUpdated === NOT_SET - ? remove(existing, key) - : set( - wasNotSet ? (inImmutable ? emptyMap() : {}) : existing, - key, - nextUpdated - ); + ? remove(existing, key) + : set( + wasNotSet ? (inImmutable ? emptyMap() : {}) : existing, + key, + nextUpdated + ); } function setIn$1(collection, keyPath, value) { @@ -2383,8 +2385,8 @@ return typeof merger === 'function' && collection.mergeWith ? collection.mergeWith.apply(collection, [ merger ].concat( sources )) : collection.merge - ? collection.merge.apply(collection, sources) - : collection.concat.apply(collection, sources); + ? collection.merge.apply(collection, sources) + : collection.concat.apply(collection, sources); } var isArray = Array.isArray(collection); var merged = collection; @@ -2422,8 +2424,8 @@ areMergeable(oldValue, newValue) ? mergeWithSources(oldValue, [newValue], deepMerger) : merger - ? merger(oldValue, newValue, key) - : newValue; + ? merger(oldValue, newValue, key) + : newValue; } return deepMerger; } @@ -2497,12 +2499,12 @@ return value === undefined || value === null ? emptyMap() : isMap(value) && !isOrdered(value) - ? value - : emptyMap().withMutations(function (map) { - var iter = KeyedCollection(value); - assertNotInfinite(iter.size); - iter.forEach(function (v, k) { return map.set(k, v); }); - }); + ? value + : emptyMap().withMutations(function (map) { + var iter = KeyedCollection(value); + assertNotInfinite(iter.size); + iter.forEach(function (v, k) { return map.set(k, v); }); + }); } if ( KeyedCollection ) Map.__proto__ = KeyedCollection; @@ -3336,10 +3338,10 @@ return !this.has(index) ? this : index === 0 - ? this.shift() - : index === this.size - 1 - ? this.pop() - : this.splice(index, 1); + ? this.shift() + : index === this.size - 1 + ? this.pop() + : this.splice(index, 1); }; List.prototype.insert = function insert (index, value) { @@ -3802,8 +3804,8 @@ end === undefined ? oldCapacity : end < 0 - ? oldCapacity + end - : oldOrigin + end; + ? oldCapacity + end + : oldOrigin + end; if (newOrigin === oldOrigin && newCapacity === oldCapacity) { return list; } @@ -3851,8 +3853,8 @@ newTailOffset < oldTailOffset ? listNodeFor(list, newCapacity - 1) : newTailOffset > oldTailOffset - ? new VNode([], owner) - : oldTail; + ? new VNode([], owner) + : oldTail; // Merge Tail into tree. if ( @@ -3941,12 +3943,12 @@ return value === undefined || value === null ? emptyOrderedMap() : isOrderedMap(value) - ? value - : emptyOrderedMap().withMutations(function (map) { - var iter = KeyedCollection(value); - assertNotInfinite(iter.size); - iter.forEach(function (v, k) { return map.set(k, v); }); - }); + ? value + : emptyOrderedMap().withMutations(function (map) { + var iter = KeyedCollection(value); + assertNotInfinite(iter.size); + iter.forEach(function (v, k) { return map.set(k, v); }); + }); } if ( Map ) OrderedMap.__proto__ = Map; @@ -4110,8 +4112,8 @@ return value === undefined || value === null ? emptyStack() : isStack(value) - ? value - : emptyStack().pushAll(value); + ? value + : emptyStack().pushAll(value); } if ( IndexedCollection ) Stack.__proto__ = IndexedCollection; @@ -4394,8 +4396,8 @@ notAssociative ? !a.has(v) : flipped - ? !is(v, a.get(k, NOT_SET)) - : !is(a.get(k, NOT_SET), v) + ? !is(v, a.get(k, NOT_SET)) + : !is(a.get(k, NOT_SET), v) ) { allEqual = false; return false; @@ -4449,12 +4451,12 @@ return value === undefined || value === null ? emptySet() : isSet(value) && !isOrdered(value) - ? value - : emptySet().withMutations(function (set) { - var iter = SetCollection(value); - assertNotInfinite(iter.size); - iter.forEach(function (v) { return set.add(v); }); - }); + ? value + : emptySet().withMutations(function (set) { + var iter = SetCollection(value); + assertNotInfinite(iter.size); + iter.forEach(function (v) { return set.add(v); }); + }); } if ( SetCollection ) Set.__proto__ = SetCollection; @@ -4668,8 +4670,8 @@ return newMap === set._map ? set : newMap.size === 0 - ? set.__empty() - : set.__make(newMap); + ? set.__empty() + : set.__make(newMap); } function makeSet(map, ownerID) { @@ -4924,8 +4926,8 @@ return isIndexed(this) ? this.toIndexedSeq() : isKeyed(this) - ? this.toKeyedSeq() - : this.toSetSeq(); + ? this.toKeyedSeq() + : this.toSetSeq(); }, toStack: function toStack() { @@ -5562,12 +5564,12 @@ h = (h + hashMerge(hash(v), hash(k))) | 0; } : ordered - ? function (v) { - h = (31 * h + hash(v)) | 0; - } - : function (v) { - h = (h + hash(v)) | 0; - } + ? function (v) { + h = (31 * h + hash(v)) | 0; + } + : function (v) { + h = (h + hash(v)) | 0; + } ); return murmurHashOfSize(collection.size, h); @@ -5594,12 +5596,12 @@ return value === undefined || value === null ? emptyOrderedSet() : isOrderedSet(value) - ? value - : emptyOrderedSet().withMutations(function (set) { - var iter = SetCollection(value); - assertNotInfinite(iter.size); - iter.forEach(function (v) { return set.add(v); }); - }); + ? value + : emptyOrderedSet().withMutations(function (set) { + var iter = SetCollection(value); + assertNotInfinite(iter.size); + iter.forEach(function (v) { return set.add(v); }); + }); } if ( Set ) OrderedSet.__proto__ = Set; diff --git a/dist/immutable.js.flow b/dist/immutable.js.flow index afb87e0da9..9ab444d234 100644 --- a/dist/immutable.js.flow +++ b/dist/immutable.js.flow @@ -33,7 +33,7 @@ type $KeyOf = $Call< ((?$ReadOnlyArray) => number) & ((?RecordInstance | T) => $Keys) & ((T) => $Keys), - C + C, >; type $ValOf> = $Call< @@ -42,7 +42,7 @@ type $ValOf> = $Call< (>(?RecordInstance | T, K) => $ElementType) & ((T) => $Values), C, - K + K, >; type $IterableOf = $Call< @@ -53,11 +53,11 @@ type $IterableOf = $Call< V: | KeyedCollection | RecordInstance - | PlainObjInput + | PlainObjInput, >( V ) => Iterable<[$KeyOf, $ValOf]>), - C + C, >; const PairSorting: $ReadOnly<{ LeftThenRight: number, RightThenLeft: number }> = @@ -97,7 +97,7 @@ declare class _Collection implements ValueObject { NSV, K2: $KeyOf, K3: $KeyOf<$ValOf>, - K4: $KeyOf<$ValOf<$ValOf, K3>> + K4: $KeyOf<$ValOf<$ValOf, K3>>, >( keyPath: [K, K2, K3, K4], notSetValue: NSV @@ -107,7 +107,7 @@ declare class _Collection implements ValueObject { K2: $KeyOf, K3: $KeyOf<$ValOf>, K4: $KeyOf<$ValOf<$ValOf, K3>>, - K5: $KeyOf<$ValOf<$ValOf<$ValOf, K3>, K4>> + K5: $KeyOf<$ValOf<$ValOf<$ValOf, K3>, K4>>, >( keyPath: [K, K2, K3, K4, K5], notSetValue: NSV @@ -441,7 +441,7 @@ declare class IndexedCollection<+T> extends Collection { e: Iterable, ..._: [] ): IndexedCollection< - [T | void, A | void, B | void, C | void, D | void, E | void] + [T | void, A | void, B | void, C | void, D | void, E | void], >; zipWith( @@ -795,7 +795,7 @@ declare class UpdatableInCollection { K2: $KeyOf, K3: $KeyOf<$ValOf>, K4: $KeyOf<$ValOf<$ValOf, K3>>, - S: $ValOf<$ValOf<$ValOf, K3>, K4> + S: $ValOf<$ValOf<$ValOf, K3>, K4>, >( keyPath: [K, K2, K3, K4], value: S @@ -805,7 +805,7 @@ declare class UpdatableInCollection { K3: $KeyOf<$ValOf>, K4: $KeyOf<$ValOf<$ValOf, K3>>, K5: $KeyOf<$ValOf<$ValOf<$ValOf, K3>, K4>>, - S: $ValOf<$ValOf<$ValOf<$ValOf, K3>, K4>, K5> + S: $ValOf<$ValOf<$ValOf<$ValOf, K3>, K4>, K5>, >( keyPath: [K, K2, K3, K4, K5], value: S @@ -820,7 +820,7 @@ declare class UpdatableInCollection { deleteIn< K2: $KeyOf, K3: $KeyOf<$ValOf>, - K4: $KeyOf<$ValOf<$ValOf, K3>> + K4: $KeyOf<$ValOf<$ValOf, K3>>, >( keyPath: [K, K2, K3, K4] ): this; @@ -828,7 +828,7 @@ declare class UpdatableInCollection { K2: $KeyOf, K3: $KeyOf<$ValOf>, K4: $KeyOf<$ValOf<$ValOf, K3>>, - K5: $KeyOf<$ValOf<$ValOf<$ValOf, K3>, K4>> + K5: $KeyOf<$ValOf<$ValOf<$ValOf, K3>, K4>>, >( keyPath: [K, K2, K3, K4, K5] ): this; @@ -842,7 +842,7 @@ declare class UpdatableInCollection { removeIn< K2: $KeyOf, K3: $KeyOf<$ValOf>, - K4: $KeyOf<$ValOf<$ValOf, K3>> + K4: $KeyOf<$ValOf<$ValOf, K3>>, >( keyPath: [K, K2, K3, K4] ): this; @@ -850,7 +850,7 @@ declare class UpdatableInCollection { K2: $KeyOf, K3: $KeyOf<$ValOf>, K4: $KeyOf<$ValOf<$ValOf, K3>>, - K5: $KeyOf<$ValOf<$ValOf<$ValOf, K3>, K4>> + K5: $KeyOf<$ValOf<$ValOf<$ValOf, K3>, K4>>, >( keyPath: [K, K2, K3, K4, K5] ): this; @@ -872,7 +872,7 @@ declare class UpdatableInCollection { NSV, K2: $KeyOf, K3: $KeyOf<$ValOf>, - S: $ValOf<$ValOf, K3> + S: $ValOf<$ValOf, K3>, >( keyPath: [K, K2, K3], notSetValue: NSV, @@ -881,7 +881,7 @@ declare class UpdatableInCollection { updateIn< K2: $KeyOf, K3: $KeyOf<$ValOf>, - S: $ValOf<$ValOf, K3> + S: $ValOf<$ValOf, K3>, >( keyPath: [K, K2, K3], updater: (value: $ValOf<$ValOf, K3>) => S @@ -891,7 +891,7 @@ declare class UpdatableInCollection { K2: $KeyOf, K3: $KeyOf<$ValOf>, K4: $KeyOf<$ValOf<$ValOf, K3>>, - S: $ValOf<$ValOf<$ValOf, K3>, K4> + S: $ValOf<$ValOf<$ValOf, K3>, K4>, >( keyPath: [K, K2, K3, K4], notSetValue: NSV, @@ -901,7 +901,7 @@ declare class UpdatableInCollection { K2: $KeyOf, K3: $KeyOf<$ValOf>, K4: $KeyOf<$ValOf<$ValOf, K3>>, - S: $ValOf<$ValOf<$ValOf, K3>, K4> + S: $ValOf<$ValOf<$ValOf, K3>, K4>, >( keyPath: [K, K2, K3, K4], updater: (value: $ValOf<$ValOf<$ValOf, K3>, K4>) => S @@ -912,7 +912,7 @@ declare class UpdatableInCollection { K3: $KeyOf<$ValOf>, K4: $KeyOf<$ValOf<$ValOf, K3>>, K5: $KeyOf<$ValOf<$ValOf<$ValOf, K3>, K4>>, - S: $ValOf<$ValOf<$ValOf<$ValOf, K3>, K4>, K5> + S: $ValOf<$ValOf<$ValOf<$ValOf, K3>, K4>, K5>, >( keyPath: [K, K2, K3, K4, K5], notSetValue: NSV, @@ -925,7 +925,7 @@ declare class UpdatableInCollection { K3: $KeyOf<$ValOf>, K4: $KeyOf<$ValOf<$ValOf, K3>>, K5: $KeyOf<$ValOf<$ValOf<$ValOf, K3>, K4>>, - S: $ValOf<$ValOf<$ValOf<$ValOf, K3>, K4>, K5> + S: $ValOf<$ValOf<$ValOf<$ValOf, K3>, K4>, K5>, >( keyPath: [K, K2, K3, K4, K5], updater: (value: $ValOf<$ValOf<$ValOf<$ValOf, K3>, K4>, K5>) => S @@ -1690,7 +1690,7 @@ declare class RecordInstance { NSV, K: $Keys, K2: $KeyOf<$ValOf>, - K3: $KeyOf<$ValOf<$ValOf, K2>> + K3: $KeyOf<$ValOf<$ValOf, K2>>, >( keyPath: [K, K2, K3], notSetValue: NSV @@ -1700,7 +1700,7 @@ declare class RecordInstance { K: $Keys, K2: $KeyOf<$ValOf>, K3: $KeyOf<$ValOf<$ValOf, K2>>, - K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>> + K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>>, >( keyPath: [K, K2, K3, K4], notSetValue: NSV @@ -1711,7 +1711,7 @@ declare class RecordInstance { K2: $KeyOf<$ValOf>, K3: $KeyOf<$ValOf<$ValOf, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>>, - K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>> + K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>>, >( keyPath: [K, K2, K3, K4, K5], notSetValue: NSV @@ -1758,7 +1758,7 @@ declare class RecordInstance { K: $Keys, K2: $KeyOf<$ValOf>, K3: $KeyOf<$ValOf<$ValOf, K2>>, - S: $ValOf<$ValOf<$ValOf, K2>, K3> + S: $ValOf<$ValOf<$ValOf, K2>, K3>, >( keyPath: [K, K2, K3], value: S @@ -1768,7 +1768,7 @@ declare class RecordInstance { K2: $KeyOf<$ValOf>, K3: $KeyOf<$ValOf<$ValOf, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>>, - S: $ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4> + S: $ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>, >( keyPath: [K, K2, K3, K4], value: S @@ -1779,7 +1779,7 @@ declare class RecordInstance { K3: $KeyOf<$ValOf<$ValOf, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>>, K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>>, - S: $ValOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>, K5> + S: $ValOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>, K5>, >( keyPath: [K, K2, K3, K4, K5], value: S @@ -1793,7 +1793,7 @@ declare class RecordInstance { deleteIn< K: $Keys, K2: $KeyOf<$ValOf>, - K3: $KeyOf<$ValOf<$ValOf, K2>> + K3: $KeyOf<$ValOf<$ValOf, K2>>, >( keyPath: [K, K2, K3] ): this & $ReadOnly; @@ -1801,7 +1801,7 @@ declare class RecordInstance { K: $Keys, K2: $KeyOf<$ValOf>, K3: $KeyOf<$ValOf<$ValOf, K2>>, - K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>> + K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>>, >( keyPath: [K, K2, K3, K4] ): this & $ReadOnly; @@ -1810,7 +1810,7 @@ declare class RecordInstance { K2: $KeyOf<$ValOf>, K3: $KeyOf<$ValOf<$ValOf, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>>, - K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>> + K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>>, >( keyPath: [K, K2, K3, K4, K5] ): this & $ReadOnly; @@ -1823,7 +1823,7 @@ declare class RecordInstance { removeIn< K: $Keys, K2: $KeyOf<$ValOf>, - K3: $KeyOf<$ValOf<$ValOf, K2>> + K3: $KeyOf<$ValOf<$ValOf, K2>>, >( keyPath: [K, K2, K3] ): this & $ReadOnly; @@ -1831,7 +1831,7 @@ declare class RecordInstance { K: $Keys, K2: $KeyOf<$ValOf>, K3: $KeyOf<$ValOf<$ValOf, K2>>, - K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>> + K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>>, >( keyPath: [K, K2, K3, K4] ): this & $ReadOnly; @@ -1840,7 +1840,7 @@ declare class RecordInstance { K2: $KeyOf<$ValOf>, K3: $KeyOf<$ValOf<$ValOf, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>>, - K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>> + K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>>, >( keyPath: [K, K2, K3, K4, K5] ): this & $ReadOnly; @@ -1864,7 +1864,7 @@ declare class RecordInstance { NSV, K: $Keys, K2: $KeyOf<$ValOf>, - S: $ValOf<$ValOf, K2> + S: $ValOf<$ValOf, K2>, >( keyPath: [K, K2], notSetValue: NSV, @@ -1879,7 +1879,7 @@ declare class RecordInstance { K: $Keys, K2: $KeyOf<$ValOf>, K3: $KeyOf<$ValOf<$ValOf, K2>>, - S: $ValOf<$ValOf<$ValOf, K2>, K3> + S: $ValOf<$ValOf<$ValOf, K2>, K3>, >( keyPath: [K, K2, K3], notSetValue: NSV, @@ -1889,7 +1889,7 @@ declare class RecordInstance { K: $Keys, K2: $KeyOf<$ValOf>, K3: $KeyOf<$ValOf<$ValOf, K2>>, - S: $ValOf<$ValOf<$ValOf, K2>, K3> + S: $ValOf<$ValOf<$ValOf, K2>, K3>, >( keyPath: [K, K2, K3], updater: (value: $ValOf<$ValOf<$ValOf, K2>, K3>) => S @@ -1900,7 +1900,7 @@ declare class RecordInstance { K2: $KeyOf<$ValOf>, K3: $KeyOf<$ValOf<$ValOf, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>>, - S: $ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4> + S: $ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>, >( keyPath: [K, K2, K3, K4], notSetValue: NSV, @@ -1913,7 +1913,7 @@ declare class RecordInstance { K2: $KeyOf<$ValOf>, K3: $KeyOf<$ValOf<$ValOf, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>>, - S: $ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4> + S: $ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>, >( keyPath: [K, K2, K3, K4], updater: (value: $ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>) => S @@ -1925,7 +1925,7 @@ declare class RecordInstance { K3: $KeyOf<$ValOf<$ValOf, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>>, K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>>, - S: $ValOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>, K5> + S: $ValOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>, K5>, >( keyPath: [K, K2, K3, K4, K5], notSetValue: NSV, @@ -1939,7 +1939,7 @@ declare class RecordInstance { K3: $KeyOf<$ValOf<$ValOf, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>>, K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>>, - S: $ValOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>, K5> + S: $ValOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>, K5>, >( keyPath: [K, K2, K3, K4, K5], updater: ( @@ -2028,7 +2028,7 @@ declare function getIn< K: $KeyOf, K2: $KeyOf<$ValOf>, K3: $KeyOf<$ValOf<$ValOf, K2>>, - NSV + NSV, >( collection: C, keyPath: [K, K2, K3], @@ -2040,7 +2040,7 @@ declare function getIn< K2: $KeyOf<$ValOf>, K3: $KeyOf<$ValOf<$ValOf, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>>, - NSV + NSV, >( collection: C, keyPath: [K, K2, K3, K4], @@ -2053,7 +2053,7 @@ declare function getIn< K3: $KeyOf<$ValOf<$ValOf, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>>, K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>>, - NSV + NSV, >( collection: C, keyPath: [K, K2, K3, K4, K5], @@ -2072,7 +2072,7 @@ declare function removeIn< C, K: $KeyOf, K2: $KeyOf<$ValOf>, - K3: $KeyOf<$ValOf<$ValOf, K2>> + K3: $KeyOf<$ValOf<$ValOf, K2>>, >( collection: C, keyPath: [K, K2, K3] @@ -2082,7 +2082,7 @@ declare function removeIn< K: $KeyOf, K2: $KeyOf<$ValOf>, K3: $KeyOf<$ValOf<$ValOf, K2>>, - K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>> + K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>>, >( collection: C, keyPath: [K, K2, K3, K4] @@ -2093,7 +2093,7 @@ declare function removeIn< K2: $KeyOf<$ValOf>, K3: $KeyOf<$ValOf<$ValOf, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>>, - K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>> + K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>>, >( collection: C, keyPath: [K, K2, K3, K4, K5] @@ -2109,7 +2109,7 @@ declare function setIn< C, K: $KeyOf, K2: $KeyOf<$ValOf>, - S: $ValOf<$ValOf, K2> + S: $ValOf<$ValOf, K2>, >( collection: C, keyPath: [K, K2], @@ -2120,7 +2120,7 @@ declare function setIn< K: $KeyOf, K2: $KeyOf<$ValOf>, K3: $KeyOf<$ValOf<$ValOf, K2>>, - S: $ValOf<$ValOf<$ValOf, K2>, K3> + S: $ValOf<$ValOf<$ValOf, K2>, K3>, >( collection: C, keyPath: [K, K2, K3], @@ -2132,7 +2132,7 @@ declare function setIn< K2: $KeyOf<$ValOf>, K3: $KeyOf<$ValOf<$ValOf, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>>, - S: $ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4> + S: $ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>, >( collection: C, keyPath: [K, K2, K3, K4], @@ -2145,7 +2145,7 @@ declare function setIn< K3: $KeyOf<$ValOf<$ValOf, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>>, K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>>, - S: $ValOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>, K5> + S: $ValOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>, K5>, >( collection: C, keyPath: [K, K2, K3, K4, K5], @@ -2179,7 +2179,7 @@ declare function updateIn< K: $KeyOf, K2: $KeyOf<$ValOf>, S: $ValOf<$ValOf, K2>, - NSV + NSV, >( collection: C, keyPath: [K, K2], @@ -2190,7 +2190,7 @@ declare function updateIn< C, K: $KeyOf, K2: $KeyOf<$ValOf>, - S: $ValOf<$ValOf, K2> + S: $ValOf<$ValOf, K2>, >( collection: C, keyPath: [K, K2], @@ -2202,7 +2202,7 @@ declare function updateIn< K2: $KeyOf<$ValOf>, K3: $KeyOf<$ValOf<$ValOf, K2>>, S: $ValOf<$ValOf<$ValOf, K2>, K3>, - NSV + NSV, >( collection: C, keyPath: [K, K2, K3], @@ -2214,7 +2214,7 @@ declare function updateIn< K: $KeyOf, K2: $KeyOf<$ValOf>, K3: $KeyOf<$ValOf<$ValOf, K2>>, - S: $ValOf<$ValOf<$ValOf, K2>, K3> + S: $ValOf<$ValOf<$ValOf, K2>, K3>, >( collection: C, keyPath: [K, K2, K3], @@ -2227,7 +2227,7 @@ declare function updateIn< K3: $KeyOf<$ValOf<$ValOf, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>>, S: $ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>, - NSV + NSV, >( collection: C, keyPath: [K, K2, K3, K4], @@ -2240,7 +2240,7 @@ declare function updateIn< K2: $KeyOf<$ValOf>, K3: $KeyOf<$ValOf<$ValOf, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>>, - S: $ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4> + S: $ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>, >( collection: C, keyPath: [K, K2, K3, K4], @@ -2254,7 +2254,7 @@ declare function updateIn< K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>>, K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>>, S: $ValOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>, K5>, - NSV + NSV, >( collection: C, keyPath: [K, K2, K3, K4, K5], @@ -2270,7 +2270,7 @@ declare function updateIn< K3: $KeyOf<$ValOf<$ValOf, K2>>, K4: $KeyOf<$ValOf<$ValOf<$ValOf, K2>, K3>>, K5: $KeyOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>>, - S: $ValOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>, K5> + S: $ValOf<$ValOf<$ValOf<$ValOf<$ValOf, K2>, K3>, K4>, K5>, >( collection: C, keyPath: [K, K2, K3, K4, K5], @@ -2284,7 +2284,7 @@ declare function merge( ...collections: Array< | $IterableOf | $Shape> - | PlainObjInput<$KeyOf, $ValOf> + | PlainObjInput<$KeyOf, $ValOf>, > ): C; declare function mergeWith( @@ -2293,7 +2293,7 @@ declare function mergeWith( ...collections: Array< | $IterableOf | $Shape> - | PlainObjInput<$KeyOf, $ValOf> + | PlainObjInput<$KeyOf, $ValOf>, > ): C; declare function mergeDeep( @@ -2301,7 +2301,7 @@ declare function mergeDeep( ...collections: Array< | $IterableOf | $Shape> - | PlainObjInput<$KeyOf, $ValOf> + | PlainObjInput<$KeyOf, $ValOf>, > ): C; declare function mergeDeepWith( @@ -2310,7 +2310,7 @@ declare function mergeDeepWith( ...collections: Array< | $IterableOf | $Shape> - | PlainObjInput<$KeyOf, $ValOf> + | PlainObjInput<$KeyOf, $ValOf>, > ): C; From fdf60fae69da9678e19a2ac7b51db82c7212a21f Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 13 Feb 2025 11:08:40 +0000 Subject: [PATCH 225/242] deploy: e5942bba7c3594973b5dc606842a0bf96af3e1f9 --- dist/immutable.es.js | 2 ++ dist/immutable.js | 2 ++ 2 files changed, 4 insertions(+) diff --git a/dist/immutable.es.js b/dist/immutable.es.js index 57f620632f..935b7b8513 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -796,6 +796,7 @@ function smi(i32) { var defaultValueOf = Object.prototype.valueOf; function hash(o) { + // eslint-disable-next-line eqeqeq if (o == null) { return hashNullish(o); } @@ -807,6 +808,7 @@ function hash(o) { var v = valueOf(o); + // eslint-disable-next-line eqeqeq if (v == null) { return hashNullish(v); } diff --git a/dist/immutable.js b/dist/immutable.js index 850187ec2c..c203bda6f2 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -802,6 +802,7 @@ var defaultValueOf = Object.prototype.valueOf; function hash(o) { + // eslint-disable-next-line eqeqeq if (o == null) { return hashNullish(o); } @@ -813,6 +814,7 @@ var v = valueOf(o); + // eslint-disable-next-line eqeqeq if (v == null) { return hashNullish(v); } From ee000bcde9e549de22854a43ad79f180b11c914d Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 19 Feb 2025 08:34:47 +0000 Subject: [PATCH 226/242] deploy: 9c784ee6e391dfab8a9905ee1e75da31e352eaa3 --- dist/immutable.es.js | 2 +- dist/immutable.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/immutable.es.js b/dist/immutable.es.js index 935b7b8513..73ab3b1a92 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -5647,7 +5647,7 @@ function emptyOrderedSet() { var PairSorting = { LeftThenRight: -1, - RightThenLeft: +1, + RightThenLeft: 1, }; function throwOnInvalidDefaultValues(defaultValues) { diff --git a/dist/immutable.js b/dist/immutable.js index c203bda6f2..64eb72f616 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -5653,7 +5653,7 @@ var PairSorting = { LeftThenRight: -1, - RightThenLeft: +1, + RightThenLeft: 1, }; function throwOnInvalidDefaultValues(defaultValues) { From 03e07da14677b74f1b0a5a977126f690517873c2 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sun, 23 Feb 2025 20:36:41 +0000 Subject: [PATCH 227/242] deploy: 51ce099ecb91ff17bdf2476b0fd67b33ed310df3 --- dist/immutable.es.js | 223 +++++++++++++++++++++++++++++++++---------- dist/immutable.js | 223 +++++++++++++++++++++++++++++++++---------- 2 files changed, 348 insertions(+), 98 deletions(-) diff --git a/dist/immutable.es.js b/dist/immutable.es.js index 73ab3b1a92..d2c799229b 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -116,25 +116,82 @@ function isNeg(value) { // Note: value is unchanged to not break immutable-devtools. var IS_COLLECTION_SYMBOL = '@@__IMMUTABLE_ITERABLE__@@'; - +/** + * True if `maybeCollection` is a Collection, or any of its subclasses. + * + * ```js + * import { isCollection, Map, List, Stack } from 'immutable'; + * + * isCollection([]); // false + * isCollection({}); // false + * isCollection(Map()); // true + * isCollection(List()); // true + * isCollection(Stack()); // true + * ``` + */ function isCollection(maybeCollection) { - return Boolean(maybeCollection && maybeCollection[IS_COLLECTION_SYMBOL]); + return Boolean(maybeCollection && + // @ts-expect-error: maybeCollection is typed as `{}`, need to change in 6.0 to `maybeCollection && typeof maybeCollection === 'object' && IS_COLLECTION_SYMBOL in maybeCollection` + maybeCollection[IS_COLLECTION_SYMBOL]); } var IS_KEYED_SYMBOL = '@@__IMMUTABLE_KEYED__@@'; - +/** + * True if `maybeKeyed` is a Collection.Keyed, or any of its subclasses. + * + * ```js + * import { isKeyed, Map, List, Stack } from 'immutable'; + * + * isKeyed([]); // false + * isKeyed({}); // false + * isKeyed(Map()); // true + * isKeyed(List()); // false + * isKeyed(Stack()); // false + * ``` + */ function isKeyed(maybeKeyed) { - return Boolean(maybeKeyed && maybeKeyed[IS_KEYED_SYMBOL]); + return Boolean(maybeKeyed && + // @ts-expect-error: maybeKeyed is typed as `{}`, need to change in 6.0 to `maybeKeyed && typeof maybeKeyed === 'object' && IS_KEYED_SYMBOL in maybeKeyed` + maybeKeyed[IS_KEYED_SYMBOL]); } var IS_INDEXED_SYMBOL = '@@__IMMUTABLE_INDEXED__@@'; - +/** + * True if `maybeIndexed` is a Collection.Indexed, or any of its subclasses. + * + * ```js + * import { isIndexed, Map, List, Stack, Set } from 'immutable'; + * + * isIndexed([]); // false + * isIndexed({}); // false + * isIndexed(Map()); // false + * isIndexed(List()); // true + * isIndexed(Stack()); // true + * isIndexed(Set()); // false + * ``` + */ function isIndexed(maybeIndexed) { - return Boolean(maybeIndexed && maybeIndexed[IS_INDEXED_SYMBOL]); + return Boolean(maybeIndexed && + // @ts-expect-error: maybeIndexed is typed as `{}`, need to change in 6.0 to `maybeIndexed && typeof maybeIndexed === 'object' && IS_INDEXED_SYMBOL in maybeIndexed` + maybeIndexed[IS_INDEXED_SYMBOL]); } +/** + * True if `maybeAssociative` is either a Keyed or Indexed Collection. + * + * ```js + * import { isAssociative, Map, List, Stack, Set } from 'immutable'; + * + * isAssociative([]); // false + * isAssociative({}); // false + * isAssociative(Map()); // true + * isAssociative(List()); // true + * isAssociative(Stack()); // true + * isAssociative(Set()); // false + * ``` + */ function isAssociative(maybeAssociative) { - return isKeyed(maybeAssociative) || isIndexed(maybeAssociative); + return isKeyed(maybeAssociative) || isIndexed(maybeAssociative); } var Collection = function Collection(value) { @@ -186,25 +243,64 @@ Collection.Indexed = IndexedCollection; Collection.Set = SetCollection; var IS_SEQ_SYMBOL = '@@__IMMUTABLE_SEQ__@@'; - +/** + * True if `maybeSeq` is a Seq. + */ function isSeq(maybeSeq) { - return Boolean(maybeSeq && maybeSeq[IS_SEQ_SYMBOL]); + return Boolean(maybeSeq && + // @ts-expect-error: maybeSeq is typed as `{}`, need to change in 6.0 to `maybeSeq && typeof maybeSeq === 'object' && MAYBE_SEQ_SYMBOL in maybeSeq` + maybeSeq[IS_SEQ_SYMBOL]); } var IS_RECORD_SYMBOL = '@@__IMMUTABLE_RECORD__@@'; - +/** + * True if `maybeRecord` is a Record. + */ function isRecord(maybeRecord) { - return Boolean(maybeRecord && maybeRecord[IS_RECORD_SYMBOL]); + return Boolean(maybeRecord && + // @ts-expect-error: maybeRecord is typed as `{}`, need to change in 6.0 to `maybeRecord && typeof maybeRecord === 'object' && IS_RECORD_SYMBOL in maybeRecord` + maybeRecord[IS_RECORD_SYMBOL]); } +/** + * True if `maybeImmutable` is an Immutable Collection or Record. + * + * Note: Still returns true even if the collections is within a `withMutations()`. + * + * ```js + * import { isImmutable, Map, List, Stack } from 'immutable'; + * isImmutable([]); // false + * isImmutable({}); // false + * isImmutable(Map()); // true + * isImmutable(List()); // true + * isImmutable(Stack()); // true + * isImmutable(Map().asMutable()); // true + * ``` + */ function isImmutable(maybeImmutable) { - return isCollection(maybeImmutable) || isRecord(maybeImmutable); + return isCollection(maybeImmutable) || isRecord(maybeImmutable); } var IS_ORDERED_SYMBOL = '@@__IMMUTABLE_ORDERED__@@'; - +/** + * True if `maybeOrdered` is a Collection where iteration order is well + * defined. True for Collection.Indexed as well as OrderedMap and OrderedSet. + * + * ```js + * import { isOrdered, Map, OrderedMap, List, Set } from 'immutable'; + * + * isOrdered([]); // false + * isOrdered({}); // false + * isOrdered(Map()); // false + * isOrdered(OrderedMap()); // true + * isOrdered(List()); // true + * isOrdered(Set()); // false + * ``` + */ function isOrdered(maybeOrdered) { - return Boolean(maybeOrdered && maybeOrdered[IS_ORDERED_SYMBOL]); + return Boolean(maybeOrdered && + // @ts-expect-error: maybeOrdered is typed as `{}`, need to change in 6.0 to `maybeOrdered && typeof maybeOrdered === 'object' && IS_ORDERED_SYMBOL in maybeOrdered` + maybeOrdered[IS_ORDERED_SYMBOL]); } var ITERATE_KEYS = 0; @@ -675,21 +771,37 @@ function maybeIndexedSeqFromValue(value) { } var IS_MAP_SYMBOL = '@@__IMMUTABLE_MAP__@@'; - +/** + * True if `maybeMap` is a Map. + * + * Also true for OrderedMaps. + */ function isMap(maybeMap) { - return Boolean(maybeMap && maybeMap[IS_MAP_SYMBOL]); + return Boolean(maybeMap && + // @ts-expect-error: maybeMap is typed as `{}`, need to change in 6.0 to `maybeMap && typeof maybeMap === 'object' && IS_MAP_SYMBOL in maybeMap` + maybeMap[IS_MAP_SYMBOL]); } +/** + * True if `maybeOrderedMap` is an OrderedMap. + */ function isOrderedMap(maybeOrderedMap) { - return isMap(maybeOrderedMap) && isOrdered(maybeOrderedMap); + return isMap(maybeOrderedMap) && isOrdered(maybeOrderedMap); } +/** + * True if `maybeValue` is a JavaScript Object which has *both* `equals()` + * and `hashCode()` methods. + * + * Any two instances of *value objects* can be compared for value equality with + * `Immutable.is()` and can be used as keys in a `Map` or members in a `Set`. + */ function isValueObject(maybeValue) { - return Boolean( - maybeValue && - typeof maybeValue.equals === 'function' && - typeof maybeValue.hashCode === 'function' - ); + return Boolean(maybeValue && + // @ts-expect-error: maybeValue is typed as `{}` + typeof maybeValue.equals === 'function' && + // @ts-expect-error: maybeValue is typed as `{}` + typeof maybeValue.hashCode === 'function'); } /** @@ -747,30 +859,26 @@ function isValueObject(maybeValue) { * and `hashCode()`. */ function is(valueA, valueB) { - if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) { - return true; - } - if (!valueA || !valueB) { - return false; - } - if ( - typeof valueA.valueOf === 'function' && - typeof valueB.valueOf === 'function' - ) { - valueA = valueA.valueOf(); - valueB = valueB.valueOf(); if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) { - return true; + return true; } if (!valueA || !valueB) { - return false; + return false; } - } - return !!( - isValueObject(valueA) && - isValueObject(valueB) && - valueA.equals(valueB) - ); + if (typeof valueA.valueOf === 'function' && + typeof valueB.valueOf === 'function') { + valueA = valueA.valueOf(); + valueB = valueB.valueOf(); + if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) { + return true; + } + if (!valueA || !valueB) { + return false; + } + } + return !!(isValueObject(valueA) && + isValueObject(valueB) && + valueA.equals(valueB)); } var imul = @@ -3266,9 +3374,13 @@ var MAX_BITMAP_INDEXED_SIZE = SIZE / 2; var MIN_HASH_ARRAY_MAP_SIZE = SIZE / 4; var IS_LIST_SYMBOL = '@@__IMMUTABLE_LIST__@@'; - +/** + * True if `maybeList` is a List. + */ function isList(maybeList) { - return Boolean(maybeList && maybeList[IS_LIST_SYMBOL]); + return Boolean(maybeList && + // @ts-expect-error: maybeList is typed as `{}`, need to change in 6.0 to `maybeList && typeof maybeList === 'object' && IS_LIST_SYMBOL in maybeList` + maybeList[IS_LIST_SYMBOL]); } var List = /*@__PURE__*/(function (IndexedCollection) { @@ -4097,9 +4209,13 @@ function updateOrderedMap(omap, k, v) { } var IS_STACK_SYMBOL = '@@__IMMUTABLE_STACK__@@'; - +/** + * True if `maybeStack` is a Stack. + */ function isStack(maybeStack) { - return Boolean(maybeStack && maybeStack[IS_STACK_SYMBOL]); + return Boolean(maybeStack && + // @ts-expect-error: maybeStack is typed as `{}`, need to change in 6.0 to `maybeStack && typeof maybeStack === 'object' && MAYBE_STACK_SYMBOL in maybeStack` + maybeStack[IS_STACK_SYMBOL]); } var Stack = /*@__PURE__*/(function (IndexedCollection) { @@ -4328,13 +4444,22 @@ function emptyStack() { } var IS_SET_SYMBOL = '@@__IMMUTABLE_SET__@@'; - +/** + * True if `maybeSet` is a Set. + * + * Also true for OrderedSets. + */ function isSet(maybeSet) { - return Boolean(maybeSet && maybeSet[IS_SET_SYMBOL]); + return Boolean(maybeSet && + // @ts-expect-error: maybeSet is typed as `{}`, need to change in 6.0 to `maybeSeq && typeof maybeSet === 'object' && MAYBE_SET_SYMBOL in maybeSet` + maybeSet[IS_SET_SYMBOL]); } +/** + * True if `maybeOrderedSet` is an OrderedSet. + */ function isOrderedSet(maybeOrderedSet) { - return isSet(maybeOrderedSet) && isOrdered(maybeOrderedSet); + return isSet(maybeOrderedSet) && isOrdered(maybeOrderedSet); } function deepEqual(a, b) { diff --git a/dist/immutable.js b/dist/immutable.js index 64eb72f616..f59ac9def2 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -122,25 +122,82 @@ // Note: value is unchanged to not break immutable-devtools. var IS_COLLECTION_SYMBOL = '@@__IMMUTABLE_ITERABLE__@@'; - + /** + * True if `maybeCollection` is a Collection, or any of its subclasses. + * + * ```js + * import { isCollection, Map, List, Stack } from 'immutable'; + * + * isCollection([]); // false + * isCollection({}); // false + * isCollection(Map()); // true + * isCollection(List()); // true + * isCollection(Stack()); // true + * ``` + */ function isCollection(maybeCollection) { - return Boolean(maybeCollection && maybeCollection[IS_COLLECTION_SYMBOL]); + return Boolean(maybeCollection && + // @ts-expect-error: maybeCollection is typed as `{}`, need to change in 6.0 to `maybeCollection && typeof maybeCollection === 'object' && IS_COLLECTION_SYMBOL in maybeCollection` + maybeCollection[IS_COLLECTION_SYMBOL]); } var IS_KEYED_SYMBOL = '@@__IMMUTABLE_KEYED__@@'; - + /** + * True if `maybeKeyed` is a Collection.Keyed, or any of its subclasses. + * + * ```js + * import { isKeyed, Map, List, Stack } from 'immutable'; + * + * isKeyed([]); // false + * isKeyed({}); // false + * isKeyed(Map()); // true + * isKeyed(List()); // false + * isKeyed(Stack()); // false + * ``` + */ function isKeyed(maybeKeyed) { - return Boolean(maybeKeyed && maybeKeyed[IS_KEYED_SYMBOL]); + return Boolean(maybeKeyed && + // @ts-expect-error: maybeKeyed is typed as `{}`, need to change in 6.0 to `maybeKeyed && typeof maybeKeyed === 'object' && IS_KEYED_SYMBOL in maybeKeyed` + maybeKeyed[IS_KEYED_SYMBOL]); } var IS_INDEXED_SYMBOL = '@@__IMMUTABLE_INDEXED__@@'; - + /** + * True if `maybeIndexed` is a Collection.Indexed, or any of its subclasses. + * + * ```js + * import { isIndexed, Map, List, Stack, Set } from 'immutable'; + * + * isIndexed([]); // false + * isIndexed({}); // false + * isIndexed(Map()); // false + * isIndexed(List()); // true + * isIndexed(Stack()); // true + * isIndexed(Set()); // false + * ``` + */ function isIndexed(maybeIndexed) { - return Boolean(maybeIndexed && maybeIndexed[IS_INDEXED_SYMBOL]); + return Boolean(maybeIndexed && + // @ts-expect-error: maybeIndexed is typed as `{}`, need to change in 6.0 to `maybeIndexed && typeof maybeIndexed === 'object' && IS_INDEXED_SYMBOL in maybeIndexed` + maybeIndexed[IS_INDEXED_SYMBOL]); } + /** + * True if `maybeAssociative` is either a Keyed or Indexed Collection. + * + * ```js + * import { isAssociative, Map, List, Stack, Set } from 'immutable'; + * + * isAssociative([]); // false + * isAssociative({}); // false + * isAssociative(Map()); // true + * isAssociative(List()); // true + * isAssociative(Stack()); // true + * isAssociative(Set()); // false + * ``` + */ function isAssociative(maybeAssociative) { - return isKeyed(maybeAssociative) || isIndexed(maybeAssociative); + return isKeyed(maybeAssociative) || isIndexed(maybeAssociative); } var Collection = function Collection(value) { @@ -192,25 +249,64 @@ Collection.Set = SetCollection; var IS_SEQ_SYMBOL = '@@__IMMUTABLE_SEQ__@@'; - + /** + * True if `maybeSeq` is a Seq. + */ function isSeq(maybeSeq) { - return Boolean(maybeSeq && maybeSeq[IS_SEQ_SYMBOL]); + return Boolean(maybeSeq && + // @ts-expect-error: maybeSeq is typed as `{}`, need to change in 6.0 to `maybeSeq && typeof maybeSeq === 'object' && MAYBE_SEQ_SYMBOL in maybeSeq` + maybeSeq[IS_SEQ_SYMBOL]); } var IS_RECORD_SYMBOL = '@@__IMMUTABLE_RECORD__@@'; - + /** + * True if `maybeRecord` is a Record. + */ function isRecord(maybeRecord) { - return Boolean(maybeRecord && maybeRecord[IS_RECORD_SYMBOL]); + return Boolean(maybeRecord && + // @ts-expect-error: maybeRecord is typed as `{}`, need to change in 6.0 to `maybeRecord && typeof maybeRecord === 'object' && IS_RECORD_SYMBOL in maybeRecord` + maybeRecord[IS_RECORD_SYMBOL]); } + /** + * True if `maybeImmutable` is an Immutable Collection or Record. + * + * Note: Still returns true even if the collections is within a `withMutations()`. + * + * ```js + * import { isImmutable, Map, List, Stack } from 'immutable'; + * isImmutable([]); // false + * isImmutable({}); // false + * isImmutable(Map()); // true + * isImmutable(List()); // true + * isImmutable(Stack()); // true + * isImmutable(Map().asMutable()); // true + * ``` + */ function isImmutable(maybeImmutable) { - return isCollection(maybeImmutable) || isRecord(maybeImmutable); + return isCollection(maybeImmutable) || isRecord(maybeImmutable); } var IS_ORDERED_SYMBOL = '@@__IMMUTABLE_ORDERED__@@'; - + /** + * True if `maybeOrdered` is a Collection where iteration order is well + * defined. True for Collection.Indexed as well as OrderedMap and OrderedSet. + * + * ```js + * import { isOrdered, Map, OrderedMap, List, Set } from 'immutable'; + * + * isOrdered([]); // false + * isOrdered({}); // false + * isOrdered(Map()); // false + * isOrdered(OrderedMap()); // true + * isOrdered(List()); // true + * isOrdered(Set()); // false + * ``` + */ function isOrdered(maybeOrdered) { - return Boolean(maybeOrdered && maybeOrdered[IS_ORDERED_SYMBOL]); + return Boolean(maybeOrdered && + // @ts-expect-error: maybeOrdered is typed as `{}`, need to change in 6.0 to `maybeOrdered && typeof maybeOrdered === 'object' && IS_ORDERED_SYMBOL in maybeOrdered` + maybeOrdered[IS_ORDERED_SYMBOL]); } var ITERATE_KEYS = 0; @@ -681,21 +777,37 @@ } var IS_MAP_SYMBOL = '@@__IMMUTABLE_MAP__@@'; - + /** + * True if `maybeMap` is a Map. + * + * Also true for OrderedMaps. + */ function isMap(maybeMap) { - return Boolean(maybeMap && maybeMap[IS_MAP_SYMBOL]); + return Boolean(maybeMap && + // @ts-expect-error: maybeMap is typed as `{}`, need to change in 6.0 to `maybeMap && typeof maybeMap === 'object' && IS_MAP_SYMBOL in maybeMap` + maybeMap[IS_MAP_SYMBOL]); } + /** + * True if `maybeOrderedMap` is an OrderedMap. + */ function isOrderedMap(maybeOrderedMap) { - return isMap(maybeOrderedMap) && isOrdered(maybeOrderedMap); + return isMap(maybeOrderedMap) && isOrdered(maybeOrderedMap); } + /** + * True if `maybeValue` is a JavaScript Object which has *both* `equals()` + * and `hashCode()` methods. + * + * Any two instances of *value objects* can be compared for value equality with + * `Immutable.is()` and can be used as keys in a `Map` or members in a `Set`. + */ function isValueObject(maybeValue) { - return Boolean( - maybeValue && - typeof maybeValue.equals === 'function' && - typeof maybeValue.hashCode === 'function' - ); + return Boolean(maybeValue && + // @ts-expect-error: maybeValue is typed as `{}` + typeof maybeValue.equals === 'function' && + // @ts-expect-error: maybeValue is typed as `{}` + typeof maybeValue.hashCode === 'function'); } /** @@ -753,30 +865,26 @@ * and `hashCode()`. */ function is(valueA, valueB) { - if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) { - return true; - } - if (!valueA || !valueB) { - return false; - } - if ( - typeof valueA.valueOf === 'function' && - typeof valueB.valueOf === 'function' - ) { - valueA = valueA.valueOf(); - valueB = valueB.valueOf(); if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) { - return true; + return true; } if (!valueA || !valueB) { - return false; + return false; } - } - return !!( - isValueObject(valueA) && - isValueObject(valueB) && - valueA.equals(valueB) - ); + if (typeof valueA.valueOf === 'function' && + typeof valueB.valueOf === 'function') { + valueA = valueA.valueOf(); + valueB = valueB.valueOf(); + if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) { + return true; + } + if (!valueA || !valueB) { + return false; + } + } + return !!(isValueObject(valueA) && + isValueObject(valueB) && + valueA.equals(valueB)); } var imul = @@ -3272,9 +3380,13 @@ var MIN_HASH_ARRAY_MAP_SIZE = SIZE / 4; var IS_LIST_SYMBOL = '@@__IMMUTABLE_LIST__@@'; - + /** + * True if `maybeList` is a List. + */ function isList(maybeList) { - return Boolean(maybeList && maybeList[IS_LIST_SYMBOL]); + return Boolean(maybeList && + // @ts-expect-error: maybeList is typed as `{}`, need to change in 6.0 to `maybeList && typeof maybeList === 'object' && IS_LIST_SYMBOL in maybeList` + maybeList[IS_LIST_SYMBOL]); } var List = /*@__PURE__*/(function (IndexedCollection) { @@ -4103,9 +4215,13 @@ } var IS_STACK_SYMBOL = '@@__IMMUTABLE_STACK__@@'; - + /** + * True if `maybeStack` is a Stack. + */ function isStack(maybeStack) { - return Boolean(maybeStack && maybeStack[IS_STACK_SYMBOL]); + return Boolean(maybeStack && + // @ts-expect-error: maybeStack is typed as `{}`, need to change in 6.0 to `maybeStack && typeof maybeStack === 'object' && MAYBE_STACK_SYMBOL in maybeStack` + maybeStack[IS_STACK_SYMBOL]); } var Stack = /*@__PURE__*/(function (IndexedCollection) { @@ -4334,13 +4450,22 @@ } var IS_SET_SYMBOL = '@@__IMMUTABLE_SET__@@'; - + /** + * True if `maybeSet` is a Set. + * + * Also true for OrderedSets. + */ function isSet(maybeSet) { - return Boolean(maybeSet && maybeSet[IS_SET_SYMBOL]); + return Boolean(maybeSet && + // @ts-expect-error: maybeSet is typed as `{}`, need to change in 6.0 to `maybeSeq && typeof maybeSet === 'object' && MAYBE_SET_SYMBOL in maybeSet` + maybeSet[IS_SET_SYMBOL]); } + /** + * True if `maybeOrderedSet` is an OrderedSet. + */ function isOrderedSet(maybeOrderedSet) { - return isSet(maybeOrderedSet) && isOrdered(maybeOrderedSet); + return isSet(maybeOrderedSet) && isOrdered(maybeOrderedSet); } function deepEqual(a, b) { From 7cf3adcd3350e8aa4b13b97e0c08eac7906840f8 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 24 Feb 2025 10:01:12 +0000 Subject: [PATCH 228/242] deploy: ec7cb812a9a4783ef950eb615c7eb563d3c09133 --- dist/immutable.d.ts | 27 +- dist/immutable.es.js | 414 +- dist/immutable.js | 10978 ++++++++++++++++++++--------------------- 3 files changed, 5691 insertions(+), 5728 deletions(-) diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index 4d16cd3f5e..0f9efbec40 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -1697,7 +1697,7 @@ declare namespace Immutable { function OrderedMap(collection?: Iterable<[K, V]>): OrderedMap; function OrderedMap(obj: { [key: string]: V }): OrderedMap; - interface OrderedMap extends Map { + interface OrderedMap extends Map, OrderedCollection<[K, V]> { /** * The number of entries in this OrderedMap. */ @@ -2182,7 +2182,7 @@ declare namespace Immutable { collection?: Iterable | ArrayLike ): OrderedSet; - interface OrderedSet extends Set { + interface OrderedSet extends Set, OrderedCollection { /** * The number of items in this OrderedSet. */ @@ -3916,7 +3916,7 @@ declare namespace Immutable { collection?: Iterable | ArrayLike ): Collection.Indexed; - interface Indexed extends Collection { + interface Indexed extends Collection, OrderedCollection { /** * Deeply converts this Indexed collection to equivalent native JavaScript Array. */ @@ -5341,6 +5341,20 @@ declare namespace Immutable { hashCode(): number; } + /** + * Interface representing all oredered collections. + * This includes `List`, `Stack`, `Map`, `OrderedMap`, `Set`, and `OrderedSet`. + * return of `isOrdered()` return true in that case. + */ + interface OrderedCollection { + /** + * Shallowly converts this collection to an Array. + */ + toArray(): Array; + + [Symbol.iterator](): IterableIterator; + } + /** * Deeply converts plain JS objects and arrays to Immutable Maps and Lists. * @@ -5604,7 +5618,12 @@ declare namespace Immutable { * isOrdered(Set()); // false * ``` */ - function isOrdered(maybeOrdered: unknown): boolean; + function isOrdered( + maybeOrdered: Iterable + ): maybeOrdered is OrderedCollection; + function isOrdered( + maybeOrdered: unknown + ): maybeOrdered is OrderedCollection; /** * True if `maybeValue` is a JavaScript Object which has *both* `equals()` diff --git a/dist/immutable.es.js b/dist/immutable.es.js index d2c799229b..302803c449 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -24,94 +24,82 @@ */ // Used for setting prototype methods that IE8 chokes on. var DELETE = 'delete'; - // Constants describing the size of trie nodes. var SHIFT = 5; // Resulted in best performance after ______? var SIZE = 1 << SHIFT; var MASK = SIZE - 1; - // A consistent shared value representing "not set" which equals nothing other // than itself, and nothing that could be provided externally. var NOT_SET = {}; - // Boolean references, Rough equivalent of `bool &`. function MakeRef() { - return { value: false }; + return { value: false }; } - function SetRef(ref) { - if (ref) { - ref.value = true; - } + if (ref) { + ref.value = true; + } } - // A function which returns a value representing an "owner" for transient writes // to tries. The return value will only ever equal itself, and will not equal // the return of any subsequent call of this function. -function OwnerID() {} - +function OwnerID() { } function ensureSize(iter) { - if (iter.size === undefined) { - iter.size = iter.__iterate(returnTrue); - } - return iter.size; + // @ts-expect-error size should exists on Collection + if (iter.size === undefined) { + // @ts-expect-error size should exists on Collection, __iterate does exist on Collection + iter.size = iter.__iterate(returnTrue); + } + // @ts-expect-error size should exists on Collection + return iter.size; } - function wrapIndex(iter, index) { - // This implements "is array index" which the ECMAString spec defines as: - // - // A String property name P is an array index if and only if - // ToString(ToUint32(P)) is equal to P and ToUint32(P) is not equal - // to 2^32−1. - // - // http://www.ecma-international.org/ecma-262/6.0/#sec-array-exotic-objects - if (typeof index !== 'number') { - var uint32Index = index >>> 0; // N >>> 0 is shorthand for ToUint32 - if ('' + uint32Index !== index || uint32Index === 4294967295) { - return NaN; + // This implements "is array index" which the ECMAString spec defines as: + // + // A String property name P is an array index if and only if + // ToString(ToUint32(P)) is equal to P and ToUint32(P) is not equal + // to 2^32−1. + // + // http://www.ecma-international.org/ecma-262/6.0/#sec-array-exotic-objects + if (typeof index !== 'number') { + var uint32Index = index >>> 0; // N >>> 0 is shorthand for ToUint32 + if ('' + uint32Index !== index || uint32Index === 4294967295) { + return NaN; + } + index = uint32Index; } - index = uint32Index; - } - return index < 0 ? ensureSize(iter) + index : index; + return index < 0 ? ensureSize(iter) + index : index; } - function returnTrue() { - return true; + return true; } - function wholeSlice(begin, end, size) { - return ( - ((begin === 0 && !isNeg(begin)) || - (size !== undefined && begin <= -size)) && - (end === undefined || (size !== undefined && end >= size)) - ); + return (((begin === 0 && !isNeg(begin)) || + (size !== undefined && begin <= -size)) && + (end === undefined || (size !== undefined && end >= size))); } - function resolveBegin(begin, size) { - return resolveIndex(begin, size, 0); + return resolveIndex(begin, size, 0); } - function resolveEnd(end, size) { - return resolveIndex(end, size, size); + return resolveIndex(end, size, size); } - function resolveIndex(index, size, defaultIndex) { - // Sanitize indices using this shorthand for ToInt32(argument) - // http://www.ecma-international.org/ecma-262/6.0/#sec-toint32 - return index === undefined - ? defaultIndex - : isNeg(index) - ? size === Infinity - ? size - : Math.max(0, size + index) | 0 - : size === undefined || size === index - ? index - : Math.min(size, index) | 0; + // Sanitize indices using this shorthand for ToInt32(argument) + // http://www.ecma-international.org/ecma-262/6.0/#sec-toint32 + return index === undefined + ? defaultIndex + : isNeg(index) + ? size === Infinity + ? size + : Math.max(0, size + index) | 0 + : size === undefined || size === index + ? index + : Math.min(size, index) | 0; } - function isNeg(value) { - // Account for -0 which is negative, but not less than 0. - return value < 0 || (value === 0 && 1 / value === -Infinity); + // Account for -0 which is negative, but not less than 0. + return value < 0 || (value === 0 && 1 / value === -Infinity); } // Note: value is unchanged to not break immutable-devtools. @@ -282,21 +270,6 @@ function isImmutable(maybeImmutable) { } var IS_ORDERED_SYMBOL = '@@__IMMUTABLE_ORDERED__@@'; -/** - * True if `maybeOrdered` is a Collection where iteration order is well - * defined. True for Collection.Indexed as well as OrderedMap and OrderedSet. - * - * ```js - * import { isOrdered, Map, OrderedMap, List, Set } from 'immutable'; - * - * isOrdered([]); // false - * isOrdered({}); // false - * isOrdered(Map()); // false - * isOrdered(OrderedMap()); // true - * isOrdered(List()); // true - * isOrdered(Set()); // false - * ``` - */ function isOrdered(maybeOrdered) { return Boolean(maybeOrdered && // @ts-expect-error: maybeOrdered is typed as `{}`, need to change in 6.0 to `maybeOrdered && typeof maybeOrdered === 'object' && IS_ORDERED_SYMBOL in maybeOrdered` @@ -389,22 +362,24 @@ function isKeysIterable(maybeIterable) { var hasOwnProperty = Object.prototype.hasOwnProperty; function isArrayLike(value) { - if (Array.isArray(value) || typeof value === 'string') { - return true; - } - - return ( - value && - typeof value === 'object' && - Number.isInteger(value.length) && - value.length >= 0 && - (value.length === 0 - ? // Only {length: 0} is considered Array-like. - Object.keys(value).length === 1 - : // An object is only Array-like if it has a property where the last value - // in the array-like may be found (which could be undefined). - value.hasOwnProperty(value.length - 1)) - ); + if (Array.isArray(value) || typeof value === 'string') { + return true; + } + // @ts-expect-error "Type 'unknown' is not assignable to type 'boolean'" : convert to Boolean + return (value && + typeof value === 'object' && + // @ts-expect-error check that `'length' in value &&` + Number.isInteger(value.length) && + // @ts-expect-error check that `'length' in value &&` + value.length >= 0 && + // @ts-expect-error check that `'length' in value &&` + (value.length === 0 + ? // Only {length: 0} is considered Array-like. + Object.keys(value).length === 1 + : // An object is only Array-like if it has a property where the last value + // in the array-like may be found (which could be undefined). + // @ts-expect-error check that `'length' in value &&` + value.hasOwnProperty(value.length - 1))); } var Seq = /*@__PURE__*/(function (Collection) { @@ -2149,63 +2124,55 @@ function defaultComparator(a, b) { // http://jsperf.com/copy-array-inline function arrCopy(arr, offset) { - offset = offset || 0; - var len = Math.max(0, arr.length - offset); - var newArr = new Array(len); - for (var ii = 0; ii < len; ii++) { - newArr[ii] = arr[ii + offset]; - } - return newArr; + offset = offset || 0; + var len = Math.max(0, arr.length - offset); + var newArr = new Array(len); + for (var ii = 0; ii < len; ii++) { + // @ts-expect-error We may want to guard for undefined values with `if (arr[ii + offset] !== undefined`, but ths should not happen by design + newArr[ii] = arr[ii + offset]; + } + return newArr; } function invariant(condition, error) { - if (!condition) { throw new Error(error); } + if (!condition) + { throw new Error(error); } } function assertNotInfinite(size) { - invariant( - size !== Infinity, - 'Cannot perform this action with an infinite size.' - ); + invariant(size !== Infinity, 'Cannot perform this action with an infinite size.'); } function coerceKeyPath(keyPath) { - if (isArrayLike(keyPath) && typeof keyPath !== 'string') { - return keyPath; - } - if (isOrdered(keyPath)) { - return keyPath.toArray(); - } - throw new TypeError( - 'Invalid keyPath: expected Ordered Collection or Array: ' + keyPath - ); + if (isArrayLike(keyPath) && typeof keyPath !== 'string') { + return keyPath; + } + if (isOrdered(keyPath)) { + return keyPath.toArray(); + } + throw new TypeError('Invalid keyPath: expected Ordered Collection or Array: ' + keyPath); } var toString = Object.prototype.toString; - function isPlainObject(value) { - // The base prototype's toString deals with Argument objects and native namespaces like Math - if ( - !value || - typeof value !== 'object' || - toString.call(value) !== '[object Object]' - ) { - return false; - } - - var proto = Object.getPrototypeOf(value); - if (proto === null) { - return true; - } - - // Iteratively going up the prototype chain is needed for cross-realm environments (differing contexts, iframes, etc) - var parentProto = proto; - var nextProto = Object.getPrototypeOf(proto); - while (nextProto !== null) { - parentProto = nextProto; - nextProto = Object.getPrototypeOf(parentProto); - } - return parentProto === proto; + // The base prototype's toString deals with Argument objects and native namespaces like Math + if (!value || + typeof value !== 'object' || + toString.call(value) !== '[object Object]') { + return false; + } + var proto = Object.getPrototypeOf(value); + if (proto === null) { + return true; + } + // Iteratively going up the prototype chain is needed for cross-realm environments (differing contexts, iframes, etc) + var parentProto = proto; + var nextProto = Object.getPrototypeOf(proto); + while (nextProto !== null) { + parentProto = nextProto; + nextProto = Object.getPrototypeOf(parentProto); + } + return parentProto === proto; } /** @@ -2213,22 +2180,21 @@ function isPlainObject(value) { * provided by Immutable.js or a plain Array or Object. */ function isDataStructure(value) { - return ( - typeof value === 'object' && - (isImmutable(value) || Array.isArray(value) || isPlainObject(value)) - ); + return (typeof value === 'object' && + (isImmutable(value) || Array.isArray(value) || isPlainObject(value))); } /** * Converts a value to a string, adding quotes if a string was provided. */ function quoteString(value) { - try { - return typeof value === 'string' ? JSON.stringify(value) : String(value); - // eslint-disable-next-line @typescript-eslint/no-unused-vars - } catch (_ignoreError) { - return JSON.stringify(value); - } + try { + return typeof value === 'string' ? JSON.stringify(value) : String(value); + // eslint-disable-next-line @typescript-eslint/no-unused-vars + } + catch (_ignoreError) { + return JSON.stringify(value); + } } function has(collection, key) { @@ -2248,16 +2214,16 @@ function get(collection, key, notSetValue) { } function shallowCopy(from) { - if (Array.isArray(from)) { - return arrCopy(from); - } - var to = {}; - for (var key in from) { - if (hasOwnProperty.call(from, key)) { - to[key] = from[key]; + if (Array.isArray(from)) { + return arrCopy(from); } - } - return to; + var to = {}; + for (var key in from) { + if (hasOwnProperty.call(from, key)) { + to[key] = from[key]; + } + } + return to; } function remove(collection, key) { @@ -4463,83 +4429,89 @@ function isOrderedSet(maybeOrderedSet) { } function deepEqual(a, b) { - if (a === b) { - return true; - } - - if ( - !isCollection(b) || - (a.size !== undefined && b.size !== undefined && a.size !== b.size) || - (a.__hash !== undefined && - b.__hash !== undefined && - a.__hash !== b.__hash) || - isKeyed(a) !== isKeyed(b) || - isIndexed(a) !== isIndexed(b) || - isOrdered(a) !== isOrdered(b) - ) { - return false; - } - - if (a.size === 0 && b.size === 0) { - return true; - } - - var notAssociative = !isAssociative(a); - - if (isOrdered(a)) { - var entries = a.entries(); - return ( - b.every(function (v, k) { - var entry = entries.next().value; - return entry && is(entry[1], v) && (notAssociative || is(entry[0], k)); - }) && entries.next().done - ); - } - - var flipped = false; - - if (a.size === undefined) { - if (b.size === undefined) { - if (typeof a.cacheResult === 'function') { - a.cacheResult(); - } - } else { - flipped = true; - var _ = a; - a = b; - b = _; + if (a === b) { + return true; } - } - - var allEqual = true; - var bSize = b.__iterate(function (v, k) { - if ( - notAssociative - ? !a.has(v) - : flipped - ? !is(v, a.get(k, NOT_SET)) - : !is(a.get(k, NOT_SET), v) - ) { - allEqual = false; - return false; + if (!isCollection(b) || + // @ts-expect-error size should exists on Collection + (a.size !== undefined && b.size !== undefined && a.size !== b.size) || + // @ts-expect-error __hash exists on Collection + (a.__hash !== undefined && + // @ts-expect-error __hash exists on Collection + b.__hash !== undefined && + // @ts-expect-error __hash exists on Collection + a.__hash !== b.__hash) || + isKeyed(a) !== isKeyed(b) || + isIndexed(a) !== isIndexed(b) || + // @ts-expect-error Range extends Collection, which implements [Symbol.iterator], so it is valid + isOrdered(a) !== isOrdered(b)) { + return false; } - }); - - return allEqual && a.size === bSize; + // @ts-expect-error size should exists on Collection + if (a.size === 0 && b.size === 0) { + return true; + } + var notAssociative = !isAssociative(a); + // @ts-expect-error Range extends Collection, which implements [Symbol.iterator], so it is valid + if (isOrdered(a)) { + var entries = a.entries(); + // @ts-expect-error need to cast as boolean + return (b.every(function (v, k) { + var entry = entries.next().value; + return entry && is(entry[1], v) && (notAssociative || is(entry[0], k)); + }) && entries.next().done); + } + var flipped = false; + if (a.size === undefined) { + // @ts-expect-error size should exists on Collection + if (b.size === undefined) { + if (typeof a.cacheResult === 'function') { + a.cacheResult(); + } + } + else { + flipped = true; + var _ = a; + a = b; + b = _; + } + } + var allEqual = true; + var bSize = + // @ts-expect-error b is Range | Repeat | Collection as it may have been flipped, and __iterate is valid + b.__iterate(function (v, k) { + if (notAssociative + ? // @ts-expect-error has exists on Collection + !a.has(v) + : flipped + ? // @ts-expect-error type of `get` does not "catch" the version with `notSetValue` + !is(v, a.get(k, NOT_SET)) + : // @ts-expect-error type of `get` does not "catch" the version with `notSetValue` + !is(a.get(k, NOT_SET), v)) { + allEqual = false; + return false; + } + }); + return (allEqual && + // @ts-expect-error size should exists on Collection + a.size === bSize); } /** * Contributes additional methods to a constructor */ -function mixin(ctor, methods) { - var keyCopier = function (key) { - ctor.prototype[key] = methods[key]; - }; - Object.keys(methods).forEach(keyCopier); - // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here - Object.getOwnPropertySymbols && - Object.getOwnPropertySymbols(methods).forEach(keyCopier); - return ctor; +function mixin(ctor, +// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type +methods) { + var keyCopier = function (key) { + // @ts-expect-error how to handle symbol ? + ctor.prototype[key] = methods[key]; + }; + Object.keys(methods).forEach(keyCopier); + // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here + Object.getOwnPropertySymbols && + Object.getOwnPropertySymbols(methods).forEach(keyCopier); + return ctor; } function toJS(value) { diff --git a/dist/immutable.js b/dist/immutable.js index f59ac9def2..86a078f6bf 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -23,6205 +23,6177 @@ * SOFTWARE. */ (function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : - typeof define === 'function' && define.amd ? define(['exports'], factory) : - (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Immutable = {})); + typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : + typeof define === 'function' && define.amd ? define(['exports'], factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Immutable = {})); })(this, (function (exports) { 'use strict'; - // Used for setting prototype methods that IE8 chokes on. - var DELETE = 'delete'; - - // Constants describing the size of trie nodes. - var SHIFT = 5; // Resulted in best performance after ______? - var SIZE = 1 << SHIFT; - var MASK = SIZE - 1; - - // A consistent shared value representing "not set" which equals nothing other - // than itself, and nothing that could be provided externally. - var NOT_SET = {}; - - // Boolean references, Rough equivalent of `bool &`. - function MakeRef() { - return { value: false }; - } - - function SetRef(ref) { - if (ref) { - ref.value = true; - } - } - - // A function which returns a value representing an "owner" for transient writes - // to tries. The return value will only ever equal itself, and will not equal - // the return of any subsequent call of this function. - function OwnerID() {} - - function ensureSize(iter) { - if (iter.size === undefined) { - iter.size = iter.__iterate(returnTrue); - } - return iter.size; - } - - function wrapIndex(iter, index) { - // This implements "is array index" which the ECMAString spec defines as: - // - // A String property name P is an array index if and only if - // ToString(ToUint32(P)) is equal to P and ToUint32(P) is not equal - // to 2^32−1. - // - // http://www.ecma-international.org/ecma-262/6.0/#sec-array-exotic-objects - if (typeof index !== 'number') { - var uint32Index = index >>> 0; // N >>> 0 is shorthand for ToUint32 - if ('' + uint32Index !== index || uint32Index === 4294967295) { - return NaN; - } - index = uint32Index; - } - return index < 0 ? ensureSize(iter) + index : index; - } - - function returnTrue() { - return true; - } - - function wholeSlice(begin, end, size) { - return ( - ((begin === 0 && !isNeg(begin)) || - (size !== undefined && begin <= -size)) && - (end === undefined || (size !== undefined && end >= size)) - ); - } - - function resolveBegin(begin, size) { - return resolveIndex(begin, size, 0); - } - - function resolveEnd(end, size) { - return resolveIndex(end, size, size); - } - - function resolveIndex(index, size, defaultIndex) { - // Sanitize indices using this shorthand for ToInt32(argument) - // http://www.ecma-international.org/ecma-262/6.0/#sec-toint32 - return index === undefined - ? defaultIndex - : isNeg(index) - ? size === Infinity - ? size - : Math.max(0, size + index) | 0 - : size === undefined || size === index - ? index - : Math.min(size, index) | 0; - } - - function isNeg(value) { - // Account for -0 which is negative, but not less than 0. - return value < 0 || (value === 0 && 1 / value === -Infinity); - } - - // Note: value is unchanged to not break immutable-devtools. - var IS_COLLECTION_SYMBOL = '@@__IMMUTABLE_ITERABLE__@@'; - /** - * True if `maybeCollection` is a Collection, or any of its subclasses. - * - * ```js - * import { isCollection, Map, List, Stack } from 'immutable'; - * - * isCollection([]); // false - * isCollection({}); // false - * isCollection(Map()); // true - * isCollection(List()); // true - * isCollection(Stack()); // true - * ``` - */ - function isCollection(maybeCollection) { - return Boolean(maybeCollection && - // @ts-expect-error: maybeCollection is typed as `{}`, need to change in 6.0 to `maybeCollection && typeof maybeCollection === 'object' && IS_COLLECTION_SYMBOL in maybeCollection` - maybeCollection[IS_COLLECTION_SYMBOL]); - } - - var IS_KEYED_SYMBOL = '@@__IMMUTABLE_KEYED__@@'; - /** - * True if `maybeKeyed` is a Collection.Keyed, or any of its subclasses. - * - * ```js - * import { isKeyed, Map, List, Stack } from 'immutable'; - * - * isKeyed([]); // false - * isKeyed({}); // false - * isKeyed(Map()); // true - * isKeyed(List()); // false - * isKeyed(Stack()); // false - * ``` - */ - function isKeyed(maybeKeyed) { - return Boolean(maybeKeyed && - // @ts-expect-error: maybeKeyed is typed as `{}`, need to change in 6.0 to `maybeKeyed && typeof maybeKeyed === 'object' && IS_KEYED_SYMBOL in maybeKeyed` - maybeKeyed[IS_KEYED_SYMBOL]); - } - - var IS_INDEXED_SYMBOL = '@@__IMMUTABLE_INDEXED__@@'; - /** - * True if `maybeIndexed` is a Collection.Indexed, or any of its subclasses. - * - * ```js - * import { isIndexed, Map, List, Stack, Set } from 'immutable'; - * - * isIndexed([]); // false - * isIndexed({}); // false - * isIndexed(Map()); // false - * isIndexed(List()); // true - * isIndexed(Stack()); // true - * isIndexed(Set()); // false - * ``` - */ - function isIndexed(maybeIndexed) { - return Boolean(maybeIndexed && - // @ts-expect-error: maybeIndexed is typed as `{}`, need to change in 6.0 to `maybeIndexed && typeof maybeIndexed === 'object' && IS_INDEXED_SYMBOL in maybeIndexed` - maybeIndexed[IS_INDEXED_SYMBOL]); - } - - /** - * True if `maybeAssociative` is either a Keyed or Indexed Collection. - * - * ```js - * import { isAssociative, Map, List, Stack, Set } from 'immutable'; - * - * isAssociative([]); // false - * isAssociative({}); // false - * isAssociative(Map()); // true - * isAssociative(List()); // true - * isAssociative(Stack()); // true - * isAssociative(Set()); // false - * ``` - */ - function isAssociative(maybeAssociative) { - return isKeyed(maybeAssociative) || isIndexed(maybeAssociative); - } - - var Collection = function Collection(value) { - // eslint-disable-next-line no-constructor-return - return isCollection(value) ? value : Seq(value); - }; - - var KeyedCollection = /*@__PURE__*/(function (Collection) { - function KeyedCollection(value) { - // eslint-disable-next-line no-constructor-return - return isKeyed(value) ? value : KeyedSeq(value); + // Used for setting prototype methods that IE8 chokes on. + var DELETE = 'delete'; + // Constants describing the size of trie nodes. + var SHIFT = 5; // Resulted in best performance after ______? + var SIZE = 1 << SHIFT; + var MASK = SIZE - 1; + // A consistent shared value representing "not set" which equals nothing other + // than itself, and nothing that could be provided externally. + var NOT_SET = {}; + // Boolean references, Rough equivalent of `bool &`. + function MakeRef() { + return { value: false }; + } + function SetRef(ref) { + if (ref) { + ref.value = true; + } } - - if ( Collection ) KeyedCollection.__proto__ = Collection; - KeyedCollection.prototype = Object.create( Collection && Collection.prototype ); - KeyedCollection.prototype.constructor = KeyedCollection; - - return KeyedCollection; - }(Collection)); - - var IndexedCollection = /*@__PURE__*/(function (Collection) { - function IndexedCollection(value) { + // A function which returns a value representing an "owner" for transient writes + // to tries. The return value will only ever equal itself, and will not equal + // the return of any subsequent call of this function. + function OwnerID() { } + function ensureSize(iter) { + // @ts-expect-error size should exists on Collection + if (iter.size === undefined) { + // @ts-expect-error size should exists on Collection, __iterate does exist on Collection + iter.size = iter.__iterate(returnTrue); + } + // @ts-expect-error size should exists on Collection + return iter.size; + } + function wrapIndex(iter, index) { + // This implements "is array index" which the ECMAString spec defines as: + // + // A String property name P is an array index if and only if + // ToString(ToUint32(P)) is equal to P and ToUint32(P) is not equal + // to 2^32−1. + // + // http://www.ecma-international.org/ecma-262/6.0/#sec-array-exotic-objects + if (typeof index !== 'number') { + var uint32Index = index >>> 0; // N >>> 0 is shorthand for ToUint32 + if ('' + uint32Index !== index || uint32Index === 4294967295) { + return NaN; + } + index = uint32Index; + } + return index < 0 ? ensureSize(iter) + index : index; + } + function returnTrue() { + return true; + } + function wholeSlice(begin, end, size) { + return (((begin === 0 && !isNeg(begin)) || + (size !== undefined && begin <= -size)) && + (end === undefined || (size !== undefined && end >= size))); + } + function resolveBegin(begin, size) { + return resolveIndex(begin, size, 0); + } + function resolveEnd(end, size) { + return resolveIndex(end, size, size); + } + function resolveIndex(index, size, defaultIndex) { + // Sanitize indices using this shorthand for ToInt32(argument) + // http://www.ecma-international.org/ecma-262/6.0/#sec-toint32 + return index === undefined + ? defaultIndex + : isNeg(index) + ? size === Infinity + ? size + : Math.max(0, size + index) | 0 + : size === undefined || size === index + ? index + : Math.min(size, index) | 0; + } + function isNeg(value) { + // Account for -0 which is negative, but not less than 0. + return value < 0 || (value === 0 && 1 / value === -Infinity); + } + + // Note: value is unchanged to not break immutable-devtools. + var IS_COLLECTION_SYMBOL = '@@__IMMUTABLE_ITERABLE__@@'; + /** + * True if `maybeCollection` is a Collection, or any of its subclasses. + * + * ```js + * import { isCollection, Map, List, Stack } from 'immutable'; + * + * isCollection([]); // false + * isCollection({}); // false + * isCollection(Map()); // true + * isCollection(List()); // true + * isCollection(Stack()); // true + * ``` + */ + function isCollection(maybeCollection) { + return Boolean(maybeCollection && + // @ts-expect-error: maybeCollection is typed as `{}`, need to change in 6.0 to `maybeCollection && typeof maybeCollection === 'object' && IS_COLLECTION_SYMBOL in maybeCollection` + maybeCollection[IS_COLLECTION_SYMBOL]); + } + + var IS_KEYED_SYMBOL = '@@__IMMUTABLE_KEYED__@@'; + /** + * True if `maybeKeyed` is a Collection.Keyed, or any of its subclasses. + * + * ```js + * import { isKeyed, Map, List, Stack } from 'immutable'; + * + * isKeyed([]); // false + * isKeyed({}); // false + * isKeyed(Map()); // true + * isKeyed(List()); // false + * isKeyed(Stack()); // false + * ``` + */ + function isKeyed(maybeKeyed) { + return Boolean(maybeKeyed && + // @ts-expect-error: maybeKeyed is typed as `{}`, need to change in 6.0 to `maybeKeyed && typeof maybeKeyed === 'object' && IS_KEYED_SYMBOL in maybeKeyed` + maybeKeyed[IS_KEYED_SYMBOL]); + } + + var IS_INDEXED_SYMBOL = '@@__IMMUTABLE_INDEXED__@@'; + /** + * True if `maybeIndexed` is a Collection.Indexed, or any of its subclasses. + * + * ```js + * import { isIndexed, Map, List, Stack, Set } from 'immutable'; + * + * isIndexed([]); // false + * isIndexed({}); // false + * isIndexed(Map()); // false + * isIndexed(List()); // true + * isIndexed(Stack()); // true + * isIndexed(Set()); // false + * ``` + */ + function isIndexed(maybeIndexed) { + return Boolean(maybeIndexed && + // @ts-expect-error: maybeIndexed is typed as `{}`, need to change in 6.0 to `maybeIndexed && typeof maybeIndexed === 'object' && IS_INDEXED_SYMBOL in maybeIndexed` + maybeIndexed[IS_INDEXED_SYMBOL]); + } + + /** + * True if `maybeAssociative` is either a Keyed or Indexed Collection. + * + * ```js + * import { isAssociative, Map, List, Stack, Set } from 'immutable'; + * + * isAssociative([]); // false + * isAssociative({}); // false + * isAssociative(Map()); // true + * isAssociative(List()); // true + * isAssociative(Stack()); // true + * isAssociative(Set()); // false + * ``` + */ + function isAssociative(maybeAssociative) { + return isKeyed(maybeAssociative) || isIndexed(maybeAssociative); + } + + var Collection = function Collection(value) { // eslint-disable-next-line no-constructor-return - return isIndexed(value) ? value : IndexedSeq(value); - } + return isCollection(value) ? value : Seq(value); + }; - if ( Collection ) IndexedCollection.__proto__ = Collection; - IndexedCollection.prototype = Object.create( Collection && Collection.prototype ); - IndexedCollection.prototype.constructor = IndexedCollection; + var KeyedCollection = /*@__PURE__*/(function (Collection) { + function KeyedCollection(value) { + // eslint-disable-next-line no-constructor-return + return isKeyed(value) ? value : KeyedSeq(value); + } - return IndexedCollection; - }(Collection)); + if ( Collection ) KeyedCollection.__proto__ = Collection; + KeyedCollection.prototype = Object.create( Collection && Collection.prototype ); + KeyedCollection.prototype.constructor = KeyedCollection; - var SetCollection = /*@__PURE__*/(function (Collection) { - function SetCollection(value) { - // eslint-disable-next-line no-constructor-return - return isCollection(value) && !isAssociative(value) ? value : SetSeq(value); - } - - if ( Collection ) SetCollection.__proto__ = Collection; - SetCollection.prototype = Object.create( Collection && Collection.prototype ); - SetCollection.prototype.constructor = SetCollection; - - return SetCollection; - }(Collection)); - - Collection.Keyed = KeyedCollection; - Collection.Indexed = IndexedCollection; - Collection.Set = SetCollection; - - var IS_SEQ_SYMBOL = '@@__IMMUTABLE_SEQ__@@'; - /** - * True if `maybeSeq` is a Seq. - */ - function isSeq(maybeSeq) { - return Boolean(maybeSeq && - // @ts-expect-error: maybeSeq is typed as `{}`, need to change in 6.0 to `maybeSeq && typeof maybeSeq === 'object' && MAYBE_SEQ_SYMBOL in maybeSeq` - maybeSeq[IS_SEQ_SYMBOL]); - } - - var IS_RECORD_SYMBOL = '@@__IMMUTABLE_RECORD__@@'; - /** - * True if `maybeRecord` is a Record. - */ - function isRecord(maybeRecord) { - return Boolean(maybeRecord && - // @ts-expect-error: maybeRecord is typed as `{}`, need to change in 6.0 to `maybeRecord && typeof maybeRecord === 'object' && IS_RECORD_SYMBOL in maybeRecord` - maybeRecord[IS_RECORD_SYMBOL]); - } - - /** - * True if `maybeImmutable` is an Immutable Collection or Record. - * - * Note: Still returns true even if the collections is within a `withMutations()`. - * - * ```js - * import { isImmutable, Map, List, Stack } from 'immutable'; - * isImmutable([]); // false - * isImmutable({}); // false - * isImmutable(Map()); // true - * isImmutable(List()); // true - * isImmutable(Stack()); // true - * isImmutable(Map().asMutable()); // true - * ``` - */ - function isImmutable(maybeImmutable) { - return isCollection(maybeImmutable) || isRecord(maybeImmutable); - } - - var IS_ORDERED_SYMBOL = '@@__IMMUTABLE_ORDERED__@@'; - /** - * True if `maybeOrdered` is a Collection where iteration order is well - * defined. True for Collection.Indexed as well as OrderedMap and OrderedSet. - * - * ```js - * import { isOrdered, Map, OrderedMap, List, Set } from 'immutable'; - * - * isOrdered([]); // false - * isOrdered({}); // false - * isOrdered(Map()); // false - * isOrdered(OrderedMap()); // true - * isOrdered(List()); // true - * isOrdered(Set()); // false - * ``` - */ - function isOrdered(maybeOrdered) { - return Boolean(maybeOrdered && - // @ts-expect-error: maybeOrdered is typed as `{}`, need to change in 6.0 to `maybeOrdered && typeof maybeOrdered === 'object' && IS_ORDERED_SYMBOL in maybeOrdered` - maybeOrdered[IS_ORDERED_SYMBOL]); - } - - var ITERATE_KEYS = 0; - var ITERATE_VALUES = 1; - var ITERATE_ENTRIES = 2; - - var REAL_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator; - var FAUX_ITERATOR_SYMBOL = '@@iterator'; - - var ITERATOR_SYMBOL = REAL_ITERATOR_SYMBOL || FAUX_ITERATOR_SYMBOL; - - var Iterator = function Iterator(next) { - this.next = next; - }; - - Iterator.prototype.toString = function toString () { - return '[Iterator]'; - }; - - Iterator.KEYS = ITERATE_KEYS; - Iterator.VALUES = ITERATE_VALUES; - Iterator.ENTRIES = ITERATE_ENTRIES; - - Iterator.prototype.inspect = Iterator.prototype.toSource = function () { - return this.toString(); - }; - Iterator.prototype[ITERATOR_SYMBOL] = function () { - return this; - }; - - function iteratorValue(type, k, v, iteratorResult) { - var value = - type === ITERATE_KEYS ? k : type === ITERATE_VALUES ? v : [k, v]; - // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here - iteratorResult - ? (iteratorResult.value = value) - : (iteratorResult = { - value: value, - done: false, - }); - return iteratorResult; - } - - function iteratorDone() { - return { value: undefined, done: true }; - } - - function hasIterator(maybeIterable) { - if (Array.isArray(maybeIterable)) { - // IE11 trick as it does not support `Symbol.iterator` - return true; - } - - return !!getIteratorFn(maybeIterable); - } - - function isIterator(maybeIterator) { - return maybeIterator && typeof maybeIterator.next === 'function'; - } - - function getIterator(iterable) { - var iteratorFn = getIteratorFn(iterable); - return iteratorFn && iteratorFn.call(iterable); - } - - function getIteratorFn(iterable) { - var iteratorFn = - iterable && - ((REAL_ITERATOR_SYMBOL && iterable[REAL_ITERATOR_SYMBOL]) || - iterable[FAUX_ITERATOR_SYMBOL]); - if (typeof iteratorFn === 'function') { - return iteratorFn; - } - } - - function isEntriesIterable(maybeIterable) { - var iteratorFn = getIteratorFn(maybeIterable); - return iteratorFn && iteratorFn === maybeIterable.entries; - } - - function isKeysIterable(maybeIterable) { - var iteratorFn = getIteratorFn(maybeIterable); - return iteratorFn && iteratorFn === maybeIterable.keys; - } - - var hasOwnProperty = Object.prototype.hasOwnProperty; - - function isArrayLike(value) { - if (Array.isArray(value) || typeof value === 'string') { - return true; - } - - return ( - value && - typeof value === 'object' && - Number.isInteger(value.length) && - value.length >= 0 && - (value.length === 0 - ? // Only {length: 0} is considered Array-like. - Object.keys(value).length === 1 - : // An object is only Array-like if it has a property where the last value - // in the array-like may be found (which could be undefined). - value.hasOwnProperty(value.length - 1)) - ); - } - - var Seq = /*@__PURE__*/(function (Collection) { - function Seq(value) { - // eslint-disable-next-line no-constructor-return - return value === undefined || value === null - ? emptySequence() - : isImmutable(value) - ? value.toSeq() - : seqFromValue(value); - } + return KeyedCollection; + }(Collection)); - if ( Collection ) Seq.__proto__ = Collection; - Seq.prototype = Object.create( Collection && Collection.prototype ); - Seq.prototype.constructor = Seq; + var IndexedCollection = /*@__PURE__*/(function (Collection) { + function IndexedCollection(value) { + // eslint-disable-next-line no-constructor-return + return isIndexed(value) ? value : IndexedSeq(value); + } - Seq.prototype.toSeq = function toSeq () { - return this; - }; + if ( Collection ) IndexedCollection.__proto__ = Collection; + IndexedCollection.prototype = Object.create( Collection && Collection.prototype ); + IndexedCollection.prototype.constructor = IndexedCollection; - Seq.prototype.toString = function toString () { - return this.__toString('Seq {', '}'); - }; + return IndexedCollection; + }(Collection)); - Seq.prototype.cacheResult = function cacheResult () { - if (!this._cache && this.__iterateUncached) { - this._cache = this.entrySeq().toArray(); - this.size = this._cache.length; + var SetCollection = /*@__PURE__*/(function (Collection) { + function SetCollection(value) { + // eslint-disable-next-line no-constructor-return + return isCollection(value) && !isAssociative(value) ? value : SetSeq(value); } - return this; - }; - // abstract __iterateUncached(fn, reverse) + if ( Collection ) SetCollection.__proto__ = Collection; + SetCollection.prototype = Object.create( Collection && Collection.prototype ); + SetCollection.prototype.constructor = SetCollection; - Seq.prototype.__iterate = function __iterate (fn, reverse) { - var cache = this._cache; - if (cache) { - var size = cache.length; - var i = 0; - while (i !== size) { - var entry = cache[reverse ? size - ++i : i++]; - if (fn(entry[1], entry[0], this) === false) { - break; - } - } - return i; - } - return this.__iterateUncached(fn, reverse); - }; + return SetCollection; + }(Collection)); - // abstract __iteratorUncached(type, reverse) + Collection.Keyed = KeyedCollection; + Collection.Indexed = IndexedCollection; + Collection.Set = SetCollection; - Seq.prototype.__iterator = function __iterator (type, reverse) { - var cache = this._cache; - if (cache) { - var size = cache.length; - var i = 0; - return new Iterator(function () { - if (i === size) { - return iteratorDone(); - } - var entry = cache[reverse ? size - ++i : i++]; - return iteratorValue(type, entry[0], entry[1]); - }); - } - return this.__iteratorUncached(type, reverse); - }; + var IS_SEQ_SYMBOL = '@@__IMMUTABLE_SEQ__@@'; + /** + * True if `maybeSeq` is a Seq. + */ + function isSeq(maybeSeq) { + return Boolean(maybeSeq && + // @ts-expect-error: maybeSeq is typed as `{}`, need to change in 6.0 to `maybeSeq && typeof maybeSeq === 'object' && MAYBE_SEQ_SYMBOL in maybeSeq` + maybeSeq[IS_SEQ_SYMBOL]); + } - return Seq; - }(Collection)); + var IS_RECORD_SYMBOL = '@@__IMMUTABLE_RECORD__@@'; + /** + * True if `maybeRecord` is a Record. + */ + function isRecord(maybeRecord) { + return Boolean(maybeRecord && + // @ts-expect-error: maybeRecord is typed as `{}`, need to change in 6.0 to `maybeRecord && typeof maybeRecord === 'object' && IS_RECORD_SYMBOL in maybeRecord` + maybeRecord[IS_RECORD_SYMBOL]); + } - var KeyedSeq = /*@__PURE__*/(function (Seq) { - function KeyedSeq(value) { - // eslint-disable-next-line no-constructor-return - return value === undefined || value === null - ? emptySequence().toKeyedSeq() - : isCollection(value) - ? isKeyed(value) - ? value.toSeq() - : value.fromEntrySeq() - : isRecord(value) - ? value.toSeq() - : keyedSeqFromValue(value); + /** + * True if `maybeImmutable` is an Immutable Collection or Record. + * + * Note: Still returns true even if the collections is within a `withMutations()`. + * + * ```js + * import { isImmutable, Map, List, Stack } from 'immutable'; + * isImmutable([]); // false + * isImmutable({}); // false + * isImmutable(Map()); // true + * isImmutable(List()); // true + * isImmutable(Stack()); // true + * isImmutable(Map().asMutable()); // true + * ``` + */ + function isImmutable(maybeImmutable) { + return isCollection(maybeImmutable) || isRecord(maybeImmutable); } - if ( Seq ) KeyedSeq.__proto__ = Seq; - KeyedSeq.prototype = Object.create( Seq && Seq.prototype ); - KeyedSeq.prototype.constructor = KeyedSeq; + var IS_ORDERED_SYMBOL = '@@__IMMUTABLE_ORDERED__@@'; + function isOrdered(maybeOrdered) { + return Boolean(maybeOrdered && + // @ts-expect-error: maybeOrdered is typed as `{}`, need to change in 6.0 to `maybeOrdered && typeof maybeOrdered === 'object' && IS_ORDERED_SYMBOL in maybeOrdered` + maybeOrdered[IS_ORDERED_SYMBOL]); + } - KeyedSeq.prototype.toKeyedSeq = function toKeyedSeq () { - return this; - }; + var ITERATE_KEYS = 0; + var ITERATE_VALUES = 1; + var ITERATE_ENTRIES = 2; - return KeyedSeq; - }(Seq)); + var REAL_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator; + var FAUX_ITERATOR_SYMBOL = '@@iterator'; - var IndexedSeq = /*@__PURE__*/(function (Seq) { - function IndexedSeq(value) { - // eslint-disable-next-line no-constructor-return - return value === undefined || value === null - ? emptySequence() - : isCollection(value) - ? isKeyed(value) - ? value.entrySeq() - : value.toIndexedSeq() - : isRecord(value) - ? value.toSeq().entrySeq() - : indexedSeqFromValue(value); - } - - if ( Seq ) IndexedSeq.__proto__ = Seq; - IndexedSeq.prototype = Object.create( Seq && Seq.prototype ); - IndexedSeq.prototype.constructor = IndexedSeq; - - IndexedSeq.of = function of (/*...values*/) { - return IndexedSeq(arguments); - }; + var ITERATOR_SYMBOL = REAL_ITERATOR_SYMBOL || FAUX_ITERATOR_SYMBOL; - IndexedSeq.prototype.toIndexedSeq = function toIndexedSeq () { - return this; + var Iterator = function Iterator(next) { + this.next = next; }; - IndexedSeq.prototype.toString = function toString () { - return this.__toString('Seq [', ']'); + Iterator.prototype.toString = function toString () { + return '[Iterator]'; }; - return IndexedSeq; - }(Seq)); - - var SetSeq = /*@__PURE__*/(function (Seq) { - function SetSeq(value) { - // eslint-disable-next-line no-constructor-return - return ( - isCollection(value) && !isAssociative(value) ? value : IndexedSeq(value) - ).toSetSeq(); - } - - if ( Seq ) SetSeq.__proto__ = Seq; - SetSeq.prototype = Object.create( Seq && Seq.prototype ); - SetSeq.prototype.constructor = SetSeq; + Iterator.KEYS = ITERATE_KEYS; + Iterator.VALUES = ITERATE_VALUES; + Iterator.ENTRIES = ITERATE_ENTRIES; - SetSeq.of = function of (/*...values*/) { - return SetSeq(arguments); + Iterator.prototype.inspect = Iterator.prototype.toSource = function () { + return this.toString(); }; - - SetSeq.prototype.toSetSeq = function toSetSeq () { + Iterator.prototype[ITERATOR_SYMBOL] = function () { return this; }; - return SetSeq; - }(Seq)); - - Seq.isSeq = isSeq; - Seq.Keyed = KeyedSeq; - Seq.Set = SetSeq; - Seq.Indexed = IndexedSeq; + function iteratorValue(type, k, v, iteratorResult) { + var value = + type === ITERATE_KEYS ? k : type === ITERATE_VALUES ? v : [k, v]; + // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here + iteratorResult + ? (iteratorResult.value = value) + : (iteratorResult = { + value: value, + done: false, + }); + return iteratorResult; + } - Seq.prototype[IS_SEQ_SYMBOL] = true; + function iteratorDone() { + return { value: undefined, done: true }; + } - // #pragma Root Sequences + function hasIterator(maybeIterable) { + if (Array.isArray(maybeIterable)) { + // IE11 trick as it does not support `Symbol.iterator` + return true; + } - var ArraySeq = /*@__PURE__*/(function (IndexedSeq) { - function ArraySeq(array) { - this._array = array; - this.size = array.length; + return !!getIteratorFn(maybeIterable); } - if ( IndexedSeq ) ArraySeq.__proto__ = IndexedSeq; - ArraySeq.prototype = Object.create( IndexedSeq && IndexedSeq.prototype ); - ArraySeq.prototype.constructor = ArraySeq; + function isIterator(maybeIterator) { + return maybeIterator && typeof maybeIterator.next === 'function'; + } - ArraySeq.prototype.get = function get (index, notSetValue) { - return this.has(index) ? this._array[wrapIndex(this, index)] : notSetValue; - }; + function getIterator(iterable) { + var iteratorFn = getIteratorFn(iterable); + return iteratorFn && iteratorFn.call(iterable); + } - ArraySeq.prototype.__iterate = function __iterate (fn, reverse) { - var array = this._array; - var size = array.length; - var i = 0; - while (i !== size) { - var ii = reverse ? size - ++i : i++; - if (fn(array[ii], ii, this) === false) { - break; - } + function getIteratorFn(iterable) { + var iteratorFn = + iterable && + ((REAL_ITERATOR_SYMBOL && iterable[REAL_ITERATOR_SYMBOL]) || + iterable[FAUX_ITERATOR_SYMBOL]); + if (typeof iteratorFn === 'function') { + return iteratorFn; } - return i; - }; - - ArraySeq.prototype.__iterator = function __iterator (type, reverse) { - var array = this._array; - var size = array.length; - var i = 0; - return new Iterator(function () { - if (i === size) { - return iteratorDone(); - } - var ii = reverse ? size - ++i : i++; - return iteratorValue(type, ii, array[ii]); - }); - }; - - return ArraySeq; - }(IndexedSeq)); - - var ObjectSeq = /*@__PURE__*/(function (KeyedSeq) { - function ObjectSeq(object) { - var keys = Object.keys(object).concat( - Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(object) : [] - ); - this._object = object; - this._keys = keys; - this.size = keys.length; } - if ( KeyedSeq ) ObjectSeq.__proto__ = KeyedSeq; - ObjectSeq.prototype = Object.create( KeyedSeq && KeyedSeq.prototype ); - ObjectSeq.prototype.constructor = ObjectSeq; + function isEntriesIterable(maybeIterable) { + var iteratorFn = getIteratorFn(maybeIterable); + return iteratorFn && iteratorFn === maybeIterable.entries; + } - ObjectSeq.prototype.get = function get (key, notSetValue) { - if (notSetValue !== undefined && !this.has(key)) { - return notSetValue; - } - return this._object[key]; - }; + function isKeysIterable(maybeIterable) { + var iteratorFn = getIteratorFn(maybeIterable); + return iteratorFn && iteratorFn === maybeIterable.keys; + } - ObjectSeq.prototype.has = function has (key) { - return hasOwnProperty.call(this._object, key); - }; + var hasOwnProperty = Object.prototype.hasOwnProperty; - ObjectSeq.prototype.__iterate = function __iterate (fn, reverse) { - var object = this._object; - var keys = this._keys; - var size = keys.length; - var i = 0; - while (i !== size) { - var key = keys[reverse ? size - ++i : i++]; - if (fn(object[key], key, this) === false) { - break; + function isArrayLike(value) { + if (Array.isArray(value) || typeof value === 'string') { + return true; } + // @ts-expect-error "Type 'unknown' is not assignable to type 'boolean'" : convert to Boolean + return (value && + typeof value === 'object' && + // @ts-expect-error check that `'length' in value &&` + Number.isInteger(value.length) && + // @ts-expect-error check that `'length' in value &&` + value.length >= 0 && + // @ts-expect-error check that `'length' in value &&` + (value.length === 0 + ? // Only {length: 0} is considered Array-like. + Object.keys(value).length === 1 + : // An object is only Array-like if it has a property where the last value + // in the array-like may be found (which could be undefined). + // @ts-expect-error check that `'length' in value &&` + value.hasOwnProperty(value.length - 1))); + } + + var Seq = /*@__PURE__*/(function (Collection) { + function Seq(value) { + // eslint-disable-next-line no-constructor-return + return value === undefined || value === null + ? emptySequence() + : isImmutable(value) + ? value.toSeq() + : seqFromValue(value); } - return i; - }; - ObjectSeq.prototype.__iterator = function __iterator (type, reverse) { - var object = this._object; - var keys = this._keys; - var size = keys.length; - var i = 0; - return new Iterator(function () { - if (i === size) { - return iteratorDone(); - } - var key = keys[reverse ? size - ++i : i++]; - return iteratorValue(type, key, object[key]); - }); - }; + if ( Collection ) Seq.__proto__ = Collection; + Seq.prototype = Object.create( Collection && Collection.prototype ); + Seq.prototype.constructor = Seq; - return ObjectSeq; - }(KeyedSeq)); - ObjectSeq.prototype[IS_ORDERED_SYMBOL] = true; + Seq.prototype.toSeq = function toSeq () { + return this; + }; - var CollectionSeq = /*@__PURE__*/(function (IndexedSeq) { - function CollectionSeq(collection) { - this._collection = collection; - this.size = collection.length || collection.size; - } + Seq.prototype.toString = function toString () { + return this.__toString('Seq {', '}'); + }; - if ( IndexedSeq ) CollectionSeq.__proto__ = IndexedSeq; - CollectionSeq.prototype = Object.create( IndexedSeq && IndexedSeq.prototype ); - CollectionSeq.prototype.constructor = CollectionSeq; + Seq.prototype.cacheResult = function cacheResult () { + if (!this._cache && this.__iterateUncached) { + this._cache = this.entrySeq().toArray(); + this.size = this._cache.length; + } + return this; + }; - CollectionSeq.prototype.__iterateUncached = function __iterateUncached (fn, reverse) { - if (reverse) { - return this.cacheResult().__iterate(fn, reverse); - } - var collection = this._collection; - var iterator = getIterator(collection); - var iterations = 0; - if (isIterator(iterator)) { - var step; - while (!(step = iterator.next()).done) { - if (fn(step.value, iterations++, this) === false) { - break; + // abstract __iterateUncached(fn, reverse) + + Seq.prototype.__iterate = function __iterate (fn, reverse) { + var cache = this._cache; + if (cache) { + var size = cache.length; + var i = 0; + while (i !== size) { + var entry = cache[reverse ? size - ++i : i++]; + if (fn(entry[1], entry[0], this) === false) { + break; + } } + return i; } - } - return iterations; - }; + return this.__iterateUncached(fn, reverse); + }; - CollectionSeq.prototype.__iteratorUncached = function __iteratorUncached (type, reverse) { - if (reverse) { - return this.cacheResult().__iterator(type, reverse); - } - var collection = this._collection; - var iterator = getIterator(collection); - if (!isIterator(iterator)) { - return new Iterator(iteratorDone); - } - var iterations = 0; - return new Iterator(function () { - var step = iterator.next(); - return step.done ? step : iteratorValue(type, iterations++, step.value); - }); - }; + // abstract __iteratorUncached(type, reverse) - return CollectionSeq; - }(IndexedSeq)); - - // # pragma Helper functions - - var EMPTY_SEQ; - - function emptySequence() { - return EMPTY_SEQ || (EMPTY_SEQ = new ArraySeq([])); - } - - function keyedSeqFromValue(value) { - var seq = maybeIndexedSeqFromValue(value); - if (seq) { - return seq.fromEntrySeq(); - } - if (typeof value === 'object') { - return new ObjectSeq(value); - } - throw new TypeError( - 'Expected Array or collection object of [k, v] entries, or keyed object: ' + - value - ); - } - - function indexedSeqFromValue(value) { - var seq = maybeIndexedSeqFromValue(value); - if (seq) { - return seq; - } - throw new TypeError( - 'Expected Array or collection object of values: ' + value - ); - } - - function seqFromValue(value) { - var seq = maybeIndexedSeqFromValue(value); - if (seq) { - return isEntriesIterable(value) - ? seq.fromEntrySeq() - : isKeysIterable(value) - ? seq.toSetSeq() - : seq; - } - if (typeof value === 'object') { - return new ObjectSeq(value); - } - throw new TypeError( - 'Expected Array or collection object of values, or keyed object: ' + value - ); - } - - function maybeIndexedSeqFromValue(value) { - return isArrayLike(value) - ? new ArraySeq(value) - : hasIterator(value) - ? new CollectionSeq(value) - : undefined; - } - - var IS_MAP_SYMBOL = '@@__IMMUTABLE_MAP__@@'; - /** - * True if `maybeMap` is a Map. - * - * Also true for OrderedMaps. - */ - function isMap(maybeMap) { - return Boolean(maybeMap && - // @ts-expect-error: maybeMap is typed as `{}`, need to change in 6.0 to `maybeMap && typeof maybeMap === 'object' && IS_MAP_SYMBOL in maybeMap` - maybeMap[IS_MAP_SYMBOL]); - } - - /** - * True if `maybeOrderedMap` is an OrderedMap. - */ - function isOrderedMap(maybeOrderedMap) { - return isMap(maybeOrderedMap) && isOrdered(maybeOrderedMap); - } - - /** - * True if `maybeValue` is a JavaScript Object which has *both* `equals()` - * and `hashCode()` methods. - * - * Any two instances of *value objects* can be compared for value equality with - * `Immutable.is()` and can be used as keys in a `Map` or members in a `Set`. - */ - function isValueObject(maybeValue) { - return Boolean(maybeValue && - // @ts-expect-error: maybeValue is typed as `{}` - typeof maybeValue.equals === 'function' && - // @ts-expect-error: maybeValue is typed as `{}` - typeof maybeValue.hashCode === 'function'); - } - - /** - * An extension of the "same-value" algorithm as [described for use by ES6 Map - * and Set](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map#Key_equality) - * - * NaN is considered the same as NaN, however -0 and 0 are considered the same - * value, which is different from the algorithm described by - * [`Object.is`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is). - * - * This is extended further to allow Objects to describe the values they - * represent, by way of `valueOf` or `equals` (and `hashCode`). - * - * Note: because of this extension, the key equality of Immutable.Map and the - * value equality of Immutable.Set will differ from ES6 Map and Set. - * - * ### Defining custom values - * - * The easiest way to describe the value an object represents is by implementing - * `valueOf`. For example, `Date` represents a value by returning a unix - * timestamp for `valueOf`: - * - * var date1 = new Date(1234567890000); // Fri Feb 13 2009 ... - * var date2 = new Date(1234567890000); - * date1.valueOf(); // 1234567890000 - * assert( date1 !== date2 ); - * assert( Immutable.is( date1, date2 ) ); - * - * Note: overriding `valueOf` may have other implications if you use this object - * where JavaScript expects a primitive, such as implicit string coercion. - * - * For more complex types, especially collections, implementing `valueOf` may - * not be performant. An alternative is to implement `equals` and `hashCode`. - * - * `equals` takes another object, presumably of similar type, and returns true - * if it is equal. Equality is symmetrical, so the same result should be - * returned if this and the argument are flipped. - * - * assert( a.equals(b) === b.equals(a) ); - * - * `hashCode` returns a 32bit integer number representing the object which will - * be used to determine how to store the value object in a Map or Set. You must - * provide both or neither methods, one must not exist without the other. - * - * Also, an important relationship between these methods must be upheld: if two - * values are equal, they *must* return the same hashCode. If the values are not - * equal, they might have the same hashCode; this is called a hash collision, - * and while undesirable for performance reasons, it is acceptable. - * - * if (a.equals(b)) { - * assert( a.hashCode() === b.hashCode() ); - * } - * - * All Immutable collections are Value Objects: they implement `equals()` - * and `hashCode()`. - */ - function is(valueA, valueB) { - if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) { - return true; - } - if (!valueA || !valueB) { - return false; - } - if (typeof valueA.valueOf === 'function' && - typeof valueB.valueOf === 'function') { - valueA = valueA.valueOf(); - valueB = valueB.valueOf(); - if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) { - return true; - } - if (!valueA || !valueB) { - return false; - } - } - return !!(isValueObject(valueA) && - isValueObject(valueB) && - valueA.equals(valueB)); - } - - var imul = - typeof Math.imul === 'function' && Math.imul(0xffffffff, 2) === -2 - ? Math.imul - : function imul(a, b) { - a |= 0; // int - b |= 0; // int - var c = a & 0xffff; - var d = b & 0xffff; - // Shift by 0 fixes the sign on the high part. - return (c * d + ((((a >>> 16) * d + c * (b >>> 16)) << 16) >>> 0)) | 0; // int - }; + Seq.prototype.__iterator = function __iterator (type, reverse) { + var cache = this._cache; + if (cache) { + var size = cache.length; + var i = 0; + return new Iterator(function () { + if (i === size) { + return iteratorDone(); + } + var entry = cache[reverse ? size - ++i : i++]; + return iteratorValue(type, entry[0], entry[1]); + }); + } + return this.__iteratorUncached(type, reverse); + }; - // v8 has an optimization for storing 31-bit signed numbers. - // Values which have either 00 or 11 as the high order bits qualify. - // This function drops the highest order bit in a signed number, maintaining - // the sign bit. - function smi(i32) { - return ((i32 >>> 1) & 0x40000000) | (i32 & 0xbfffffff); - } - - var defaultValueOf = Object.prototype.valueOf; - - function hash(o) { - // eslint-disable-next-line eqeqeq - if (o == null) { - return hashNullish(o); - } - - if (typeof o.hashCode === 'function') { - // Drop any high bits from accidentally long hash codes. - return smi(o.hashCode(o)); - } - - var v = valueOf(o); - - // eslint-disable-next-line eqeqeq - if (v == null) { - return hashNullish(v); - } - - switch (typeof v) { - case 'boolean': - // The hash values for built-in constants are a 1 value for each 5-byte - // shift region expect for the first, which encodes the value. This - // reduces the odds of a hash collision for these common values. - return v ? 0x42108421 : 0x42108420; - case 'number': - return hashNumber(v); - case 'string': - return v.length > STRING_HASH_CACHE_MIN_STRLEN - ? cachedHashString(v) - : hashString(v); - case 'object': - case 'function': - return hashJSObj(v); - case 'symbol': - return hashSymbol(v); - default: - if (typeof v.toString === 'function') { - return hashString(v.toString()); - } - throw new Error('Value type ' + typeof v + ' cannot be hashed.'); - } - } - - function hashNullish(nullish) { - return nullish === null ? 0x42108422 : /* undefined */ 0x42108423; - } - - // Compress arbitrarily large numbers into smi hashes. - function hashNumber(n) { - if (n !== n || n === Infinity) { - return 0; - } - var hash = n | 0; - if (hash !== n) { - hash ^= n * 0xffffffff; - } - while (n > 0xffffffff) { - n /= 0xffffffff; - hash ^= n; - } - return smi(hash); - } - - function cachedHashString(string) { - var hashed = stringHashCache[string]; - if (hashed === undefined) { - hashed = hashString(string); - if (STRING_HASH_CACHE_SIZE === STRING_HASH_CACHE_MAX_SIZE) { - STRING_HASH_CACHE_SIZE = 0; - stringHashCache = {}; - } - STRING_HASH_CACHE_SIZE++; - stringHashCache[string] = hashed; - } - return hashed; - } - - // http://jsperf.com/hashing-strings - function hashString(string) { - // This is the hash from JVM - // The hash code for a string is computed as - // s[0] * 31 ^ (n - 1) + s[1] * 31 ^ (n - 2) + ... + s[n - 1], - // where s[i] is the ith character of the string and n is the length of - // the string. We "mod" the result to make it between 0 (inclusive) and 2^31 - // (exclusive) by dropping high bits. - var hashed = 0; - for (var ii = 0; ii < string.length; ii++) { - hashed = (31 * hashed + string.charCodeAt(ii)) | 0; - } - return smi(hashed); - } - - function hashSymbol(sym) { - var hashed = symbolMap[sym]; - if (hashed !== undefined) { - return hashed; - } + return Seq; + }(Collection)); - hashed = nextHash(); + var KeyedSeq = /*@__PURE__*/(function (Seq) { + function KeyedSeq(value) { + // eslint-disable-next-line no-constructor-return + return value === undefined || value === null + ? emptySequence().toKeyedSeq() + : isCollection(value) + ? isKeyed(value) + ? value.toSeq() + : value.fromEntrySeq() + : isRecord(value) + ? value.toSeq() + : keyedSeqFromValue(value); + } + + if ( Seq ) KeyedSeq.__proto__ = Seq; + KeyedSeq.prototype = Object.create( Seq && Seq.prototype ); + KeyedSeq.prototype.constructor = KeyedSeq; + + KeyedSeq.prototype.toKeyedSeq = function toKeyedSeq () { + return this; + }; - symbolMap[sym] = hashed; + return KeyedSeq; + }(Seq)); - return hashed; - } + var IndexedSeq = /*@__PURE__*/(function (Seq) { + function IndexedSeq(value) { + // eslint-disable-next-line no-constructor-return + return value === undefined || value === null + ? emptySequence() + : isCollection(value) + ? isKeyed(value) + ? value.entrySeq() + : value.toIndexedSeq() + : isRecord(value) + ? value.toSeq().entrySeq() + : indexedSeqFromValue(value); + } + + if ( Seq ) IndexedSeq.__proto__ = Seq; + IndexedSeq.prototype = Object.create( Seq && Seq.prototype ); + IndexedSeq.prototype.constructor = IndexedSeq; + + IndexedSeq.of = function of (/*...values*/) { + return IndexedSeq(arguments); + }; - function hashJSObj(obj) { - var hashed; - if (usingWeakMap) { - hashed = weakMap.get(obj); - if (hashed !== undefined) { - return hashed; - } - } + IndexedSeq.prototype.toIndexedSeq = function toIndexedSeq () { + return this; + }; - hashed = obj[UID_HASH_KEY]; - if (hashed !== undefined) { - return hashed; - } + IndexedSeq.prototype.toString = function toString () { + return this.__toString('Seq [', ']'); + }; - if (!canDefineProperty) { - hashed = obj.propertyIsEnumerable && obj.propertyIsEnumerable[UID_HASH_KEY]; - if (hashed !== undefined) { - return hashed; - } + return IndexedSeq; + }(Seq)); - hashed = getIENodeHash(obj); - if (hashed !== undefined) { - return hashed; + var SetSeq = /*@__PURE__*/(function (Seq) { + function SetSeq(value) { + // eslint-disable-next-line no-constructor-return + return ( + isCollection(value) && !isAssociative(value) ? value : IndexedSeq(value) + ).toSetSeq(); } - } - hashed = nextHash(); + if ( Seq ) SetSeq.__proto__ = Seq; + SetSeq.prototype = Object.create( Seq && Seq.prototype ); + SetSeq.prototype.constructor = SetSeq; - if (usingWeakMap) { - weakMap.set(obj, hashed); - } else if (isExtensible !== undefined && isExtensible(obj) === false) { - throw new Error('Non-extensible objects are not allowed as keys.'); - } else if (canDefineProperty) { - Object.defineProperty(obj, UID_HASH_KEY, { - enumerable: false, - configurable: false, - writable: false, - value: hashed, - }); - } else if ( - obj.propertyIsEnumerable !== undefined && - obj.propertyIsEnumerable === obj.constructor.prototype.propertyIsEnumerable - ) { - // Since we can't define a non-enumerable property on the object - // we'll hijack one of the less-used non-enumerable properties to - // save our hash on it. Since this is a function it will not show up in - // `JSON.stringify` which is what we want. - obj.propertyIsEnumerable = function () { - return this.constructor.prototype.propertyIsEnumerable.apply( - this, - arguments - ); + SetSeq.of = function of (/*...values*/) { + return SetSeq(arguments); }; - obj.propertyIsEnumerable[UID_HASH_KEY] = hashed; - } else if (obj.nodeType !== undefined) { - // At this point we couldn't get the IE `uniqueID` to use as a hash - // and we couldn't use a non-enumerable property to exploit the - // dontEnum bug so we simply add the `UID_HASH_KEY` on the node - // itself. - obj[UID_HASH_KEY] = hashed; - } else { - throw new Error('Unable to set a non-enumerable property on object.'); - } - - return hashed; - } - - // Get references to ES5 object methods. - var isExtensible = Object.isExtensible; - - // True if Object.defineProperty works as expected. IE8 fails this test. - var canDefineProperty = (function () { - try { - Object.defineProperty({}, '@', {}); - return true; - // eslint-disable-next-line @typescript-eslint/no-unused-vars - } catch (e) { - return false; - } - })(); - - // IE has a `uniqueID` property on DOM nodes. We can construct the hash from it - // and avoid memory leaks from the IE cloneNode bug. - function getIENodeHash(node) { - if (node && node.nodeType > 0) { - switch (node.nodeType) { - case 1: // Element - return node.uniqueID; - case 9: // Document - return node.documentElement && node.documentElement.uniqueID; - } - } - } - - function valueOf(obj) { - return obj.valueOf !== defaultValueOf && typeof obj.valueOf === 'function' - ? obj.valueOf(obj) - : obj; - } - - function nextHash() { - var nextHash = ++_objHashUID; - if (_objHashUID & 0x40000000) { - _objHashUID = 0; - } - return nextHash; - } - - // If possible, use a WeakMap. - var usingWeakMap = typeof WeakMap === 'function'; - var weakMap; - if (usingWeakMap) { - weakMap = new WeakMap(); - } - - var symbolMap = Object.create(null); - - var _objHashUID = 0; - - var UID_HASH_KEY = '__immutablehash__'; - if (typeof Symbol === 'function') { - UID_HASH_KEY = Symbol(UID_HASH_KEY); - } - - var STRING_HASH_CACHE_MIN_STRLEN = 16; - var STRING_HASH_CACHE_MAX_SIZE = 255; - var STRING_HASH_CACHE_SIZE = 0; - var stringHashCache = {}; - - var ToKeyedSequence = /*@__PURE__*/(function (KeyedSeq) { - function ToKeyedSequence(indexed, useKeys) { - this._iter = indexed; - this._useKeys = useKeys; - this.size = indexed.size; - } - - if ( KeyedSeq ) ToKeyedSequence.__proto__ = KeyedSeq; - ToKeyedSequence.prototype = Object.create( KeyedSeq && KeyedSeq.prototype ); - ToKeyedSequence.prototype.constructor = ToKeyedSequence; - - ToKeyedSequence.prototype.get = function get (key, notSetValue) { - return this._iter.get(key, notSetValue); - }; - ToKeyedSequence.prototype.has = function has (key) { - return this._iter.has(key); - }; + SetSeq.prototype.toSetSeq = function toSetSeq () { + return this; + }; - ToKeyedSequence.prototype.valueSeq = function valueSeq () { - return this._iter.valueSeq(); - }; + return SetSeq; + }(Seq)); - ToKeyedSequence.prototype.reverse = function reverse () { - var this$1$1 = this; + Seq.isSeq = isSeq; + Seq.Keyed = KeyedSeq; + Seq.Set = SetSeq; + Seq.Indexed = IndexedSeq; - var reversedSequence = reverseFactory(this, true); - if (!this._useKeys) { - reversedSequence.valueSeq = function () { return this$1$1._iter.toSeq().reverse(); }; - } - return reversedSequence; - }; + Seq.prototype[IS_SEQ_SYMBOL] = true; - ToKeyedSequence.prototype.map = function map (mapper, context) { - var this$1$1 = this; + // #pragma Root Sequences - var mappedSequence = mapFactory(this, mapper, context); - if (!this._useKeys) { - mappedSequence.valueSeq = function () { return this$1$1._iter.toSeq().map(mapper, context); }; + var ArraySeq = /*@__PURE__*/(function (IndexedSeq) { + function ArraySeq(array) { + this._array = array; + this.size = array.length; } - return mappedSequence; - }; - ToKeyedSequence.prototype.__iterate = function __iterate (fn, reverse) { - var this$1$1 = this; + if ( IndexedSeq ) ArraySeq.__proto__ = IndexedSeq; + ArraySeq.prototype = Object.create( IndexedSeq && IndexedSeq.prototype ); + ArraySeq.prototype.constructor = ArraySeq; - return this._iter.__iterate(function (v, k) { return fn(v, k, this$1$1); }, reverse); - }; + ArraySeq.prototype.get = function get (index, notSetValue) { + return this.has(index) ? this._array[wrapIndex(this, index)] : notSetValue; + }; - ToKeyedSequence.prototype.__iterator = function __iterator (type, reverse) { - return this._iter.__iterator(type, reverse); - }; + ArraySeq.prototype.__iterate = function __iterate (fn, reverse) { + var array = this._array; + var size = array.length; + var i = 0; + while (i !== size) { + var ii = reverse ? size - ++i : i++; + if (fn(array[ii], ii, this) === false) { + break; + } + } + return i; + }; - return ToKeyedSequence; - }(KeyedSeq)); - ToKeyedSequence.prototype[IS_ORDERED_SYMBOL] = true; + ArraySeq.prototype.__iterator = function __iterator (type, reverse) { + var array = this._array; + var size = array.length; + var i = 0; + return new Iterator(function () { + if (i === size) { + return iteratorDone(); + } + var ii = reverse ? size - ++i : i++; + return iteratorValue(type, ii, array[ii]); + }); + }; - var ToIndexedSequence = /*@__PURE__*/(function (IndexedSeq) { - function ToIndexedSequence(iter) { - this._iter = iter; - this.size = iter.size; - } + return ArraySeq; + }(IndexedSeq)); - if ( IndexedSeq ) ToIndexedSequence.__proto__ = IndexedSeq; - ToIndexedSequence.prototype = Object.create( IndexedSeq && IndexedSeq.prototype ); - ToIndexedSequence.prototype.constructor = ToIndexedSequence; + var ObjectSeq = /*@__PURE__*/(function (KeyedSeq) { + function ObjectSeq(object) { + var keys = Object.keys(object).concat( + Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(object) : [] + ); + this._object = object; + this._keys = keys; + this.size = keys.length; + } - ToIndexedSequence.prototype.includes = function includes (value) { - return this._iter.includes(value); - }; + if ( KeyedSeq ) ObjectSeq.__proto__ = KeyedSeq; + ObjectSeq.prototype = Object.create( KeyedSeq && KeyedSeq.prototype ); + ObjectSeq.prototype.constructor = ObjectSeq; - ToIndexedSequence.prototype.__iterate = function __iterate (fn, reverse) { - var this$1$1 = this; + ObjectSeq.prototype.get = function get (key, notSetValue) { + if (notSetValue !== undefined && !this.has(key)) { + return notSetValue; + } + return this._object[key]; + }; - var i = 0; - // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here - reverse && ensureSize(this); - return this._iter.__iterate( - function (v) { return fn(v, reverse ? this$1$1.size - ++i : i++, this$1$1); }, - reverse - ); - }; + ObjectSeq.prototype.has = function has (key) { + return hasOwnProperty.call(this._object, key); + }; - ToIndexedSequence.prototype.__iterator = function __iterator (type, reverse) { - var this$1$1 = this; + ObjectSeq.prototype.__iterate = function __iterate (fn, reverse) { + var object = this._object; + var keys = this._keys; + var size = keys.length; + var i = 0; + while (i !== size) { + var key = keys[reverse ? size - ++i : i++]; + if (fn(object[key], key, this) === false) { + break; + } + } + return i; + }; - var iterator = this._iter.__iterator(ITERATE_VALUES, reverse); - var i = 0; - // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here - reverse && ensureSize(this); - return new Iterator(function () { - var step = iterator.next(); - return step.done - ? step - : iteratorValue( - type, - reverse ? this$1$1.size - ++i : i++, - step.value, - step - ); - }); - }; + ObjectSeq.prototype.__iterator = function __iterator (type, reverse) { + var object = this._object; + var keys = this._keys; + var size = keys.length; + var i = 0; + return new Iterator(function () { + if (i === size) { + return iteratorDone(); + } + var key = keys[reverse ? size - ++i : i++]; + return iteratorValue(type, key, object[key]); + }); + }; - return ToIndexedSequence; - }(IndexedSeq)); + return ObjectSeq; + }(KeyedSeq)); + ObjectSeq.prototype[IS_ORDERED_SYMBOL] = true; - var ToSetSequence = /*@__PURE__*/(function (SetSeq) { - function ToSetSequence(iter) { - this._iter = iter; - this.size = iter.size; - } + var CollectionSeq = /*@__PURE__*/(function (IndexedSeq) { + function CollectionSeq(collection) { + this._collection = collection; + this.size = collection.length || collection.size; + } - if ( SetSeq ) ToSetSequence.__proto__ = SetSeq; - ToSetSequence.prototype = Object.create( SetSeq && SetSeq.prototype ); - ToSetSequence.prototype.constructor = ToSetSequence; + if ( IndexedSeq ) CollectionSeq.__proto__ = IndexedSeq; + CollectionSeq.prototype = Object.create( IndexedSeq && IndexedSeq.prototype ); + CollectionSeq.prototype.constructor = CollectionSeq; - ToSetSequence.prototype.has = function has (key) { - return this._iter.includes(key); - }; + CollectionSeq.prototype.__iterateUncached = function __iterateUncached (fn, reverse) { + if (reverse) { + return this.cacheResult().__iterate(fn, reverse); + } + var collection = this._collection; + var iterator = getIterator(collection); + var iterations = 0; + if (isIterator(iterator)) { + var step; + while (!(step = iterator.next()).done) { + if (fn(step.value, iterations++, this) === false) { + break; + } + } + } + return iterations; + }; - ToSetSequence.prototype.__iterate = function __iterate (fn, reverse) { - var this$1$1 = this; + CollectionSeq.prototype.__iteratorUncached = function __iteratorUncached (type, reverse) { + if (reverse) { + return this.cacheResult().__iterator(type, reverse); + } + var collection = this._collection; + var iterator = getIterator(collection); + if (!isIterator(iterator)) { + return new Iterator(iteratorDone); + } + var iterations = 0; + return new Iterator(function () { + var step = iterator.next(); + return step.done ? step : iteratorValue(type, iterations++, step.value); + }); + }; - return this._iter.__iterate(function (v) { return fn(v, v, this$1$1); }, reverse); - }; + return CollectionSeq; + }(IndexedSeq)); - ToSetSequence.prototype.__iterator = function __iterator (type, reverse) { - var iterator = this._iter.__iterator(ITERATE_VALUES, reverse); - return new Iterator(function () { - var step = iterator.next(); - return step.done - ? step - : iteratorValue(type, step.value, step.value, step); - }); - }; + // # pragma Helper functions - return ToSetSequence; - }(SetSeq)); + var EMPTY_SEQ; - var FromEntriesSequence = /*@__PURE__*/(function (KeyedSeq) { - function FromEntriesSequence(entries) { - this._iter = entries; - this.size = entries.size; + function emptySequence() { + return EMPTY_SEQ || (EMPTY_SEQ = new ArraySeq([])); } - if ( KeyedSeq ) FromEntriesSequence.__proto__ = KeyedSeq; - FromEntriesSequence.prototype = Object.create( KeyedSeq && KeyedSeq.prototype ); - FromEntriesSequence.prototype.constructor = FromEntriesSequence; + function keyedSeqFromValue(value) { + var seq = maybeIndexedSeqFromValue(value); + if (seq) { + return seq.fromEntrySeq(); + } + if (typeof value === 'object') { + return new ObjectSeq(value); + } + throw new TypeError( + 'Expected Array or collection object of [k, v] entries, or keyed object: ' + + value + ); + } - FromEntriesSequence.prototype.entrySeq = function entrySeq () { - return this._iter.toSeq(); - }; + function indexedSeqFromValue(value) { + var seq = maybeIndexedSeqFromValue(value); + if (seq) { + return seq; + } + throw new TypeError( + 'Expected Array or collection object of values: ' + value + ); + } - FromEntriesSequence.prototype.__iterate = function __iterate (fn, reverse) { - var this$1$1 = this; + function seqFromValue(value) { + var seq = maybeIndexedSeqFromValue(value); + if (seq) { + return isEntriesIterable(value) + ? seq.fromEntrySeq() + : isKeysIterable(value) + ? seq.toSetSeq() + : seq; + } + if (typeof value === 'object') { + return new ObjectSeq(value); + } + throw new TypeError( + 'Expected Array or collection object of values, or keyed object: ' + value + ); + } - return this._iter.__iterate(function (entry) { - // Check if entry exists first so array access doesn't throw for holes - // in the parent iteration. - if (entry) { - validateEntry(entry); - var indexedCollection = isCollection(entry); - return fn( - indexedCollection ? entry.get(1) : entry[1], - indexedCollection ? entry.get(0) : entry[0], - this$1$1 - ); + function maybeIndexedSeqFromValue(value) { + return isArrayLike(value) + ? new ArraySeq(value) + : hasIterator(value) + ? new CollectionSeq(value) + : undefined; + } + + var IS_MAP_SYMBOL = '@@__IMMUTABLE_MAP__@@'; + /** + * True if `maybeMap` is a Map. + * + * Also true for OrderedMaps. + */ + function isMap(maybeMap) { + return Boolean(maybeMap && + // @ts-expect-error: maybeMap is typed as `{}`, need to change in 6.0 to `maybeMap && typeof maybeMap === 'object' && IS_MAP_SYMBOL in maybeMap` + maybeMap[IS_MAP_SYMBOL]); + } + + /** + * True if `maybeOrderedMap` is an OrderedMap. + */ + function isOrderedMap(maybeOrderedMap) { + return isMap(maybeOrderedMap) && isOrdered(maybeOrderedMap); + } + + /** + * True if `maybeValue` is a JavaScript Object which has *both* `equals()` + * and `hashCode()` methods. + * + * Any two instances of *value objects* can be compared for value equality with + * `Immutable.is()` and can be used as keys in a `Map` or members in a `Set`. + */ + function isValueObject(maybeValue) { + return Boolean(maybeValue && + // @ts-expect-error: maybeValue is typed as `{}` + typeof maybeValue.equals === 'function' && + // @ts-expect-error: maybeValue is typed as `{}` + typeof maybeValue.hashCode === 'function'); + } + + /** + * An extension of the "same-value" algorithm as [described for use by ES6 Map + * and Set](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map#Key_equality) + * + * NaN is considered the same as NaN, however -0 and 0 are considered the same + * value, which is different from the algorithm described by + * [`Object.is`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is). + * + * This is extended further to allow Objects to describe the values they + * represent, by way of `valueOf` or `equals` (and `hashCode`). + * + * Note: because of this extension, the key equality of Immutable.Map and the + * value equality of Immutable.Set will differ from ES6 Map and Set. + * + * ### Defining custom values + * + * The easiest way to describe the value an object represents is by implementing + * `valueOf`. For example, `Date` represents a value by returning a unix + * timestamp for `valueOf`: + * + * var date1 = new Date(1234567890000); // Fri Feb 13 2009 ... + * var date2 = new Date(1234567890000); + * date1.valueOf(); // 1234567890000 + * assert( date1 !== date2 ); + * assert( Immutable.is( date1, date2 ) ); + * + * Note: overriding `valueOf` may have other implications if you use this object + * where JavaScript expects a primitive, such as implicit string coercion. + * + * For more complex types, especially collections, implementing `valueOf` may + * not be performant. An alternative is to implement `equals` and `hashCode`. + * + * `equals` takes another object, presumably of similar type, and returns true + * if it is equal. Equality is symmetrical, so the same result should be + * returned if this and the argument are flipped. + * + * assert( a.equals(b) === b.equals(a) ); + * + * `hashCode` returns a 32bit integer number representing the object which will + * be used to determine how to store the value object in a Map or Set. You must + * provide both or neither methods, one must not exist without the other. + * + * Also, an important relationship between these methods must be upheld: if two + * values are equal, they *must* return the same hashCode. If the values are not + * equal, they might have the same hashCode; this is called a hash collision, + * and while undesirable for performance reasons, it is acceptable. + * + * if (a.equals(b)) { + * assert( a.hashCode() === b.hashCode() ); + * } + * + * All Immutable collections are Value Objects: they implement `equals()` + * and `hashCode()`. + */ + function is(valueA, valueB) { + if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) { + return true; } - }, reverse); - }; - - FromEntriesSequence.prototype.__iterator = function __iterator (type, reverse) { - var iterator = this._iter.__iterator(ITERATE_VALUES, reverse); - return new Iterator(function () { - while (true) { - var step = iterator.next(); - if (step.done) { - return step; + if (!valueA || !valueB) { + return false; + } + if (typeof valueA.valueOf === 'function' && + typeof valueB.valueOf === 'function') { + valueA = valueA.valueOf(); + valueB = valueB.valueOf(); + if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) { + return true; + } + if (!valueA || !valueB) { + return false; + } + } + return !!(isValueObject(valueA) && + isValueObject(valueB) && + valueA.equals(valueB)); + } + + var imul = + typeof Math.imul === 'function' && Math.imul(0xffffffff, 2) === -2 + ? Math.imul + : function imul(a, b) { + a |= 0; // int + b |= 0; // int + var c = a & 0xffff; + var d = b & 0xffff; + // Shift by 0 fixes the sign on the high part. + return (c * d + ((((a >>> 16) * d + c * (b >>> 16)) << 16) >>> 0)) | 0; // int + }; + + // v8 has an optimization for storing 31-bit signed numbers. + // Values which have either 00 or 11 as the high order bits qualify. + // This function drops the highest order bit in a signed number, maintaining + // the sign bit. + function smi(i32) { + return ((i32 >>> 1) & 0x40000000) | (i32 & 0xbfffffff); + } + + var defaultValueOf = Object.prototype.valueOf; + + function hash(o) { + // eslint-disable-next-line eqeqeq + if (o == null) { + return hashNullish(o); + } + + if (typeof o.hashCode === 'function') { + // Drop any high bits from accidentally long hash codes. + return smi(o.hashCode(o)); + } + + var v = valueOf(o); + + // eslint-disable-next-line eqeqeq + if (v == null) { + return hashNullish(v); + } + + switch (typeof v) { + case 'boolean': + // The hash values for built-in constants are a 1 value for each 5-byte + // shift region expect for the first, which encodes the value. This + // reduces the odds of a hash collision for these common values. + return v ? 0x42108421 : 0x42108420; + case 'number': + return hashNumber(v); + case 'string': + return v.length > STRING_HASH_CACHE_MIN_STRLEN + ? cachedHashString(v) + : hashString(v); + case 'object': + case 'function': + return hashJSObj(v); + case 'symbol': + return hashSymbol(v); + default: + if (typeof v.toString === 'function') { + return hashString(v.toString()); } - var entry = step.value; + throw new Error('Value type ' + typeof v + ' cannot be hashed.'); + } + } + + function hashNullish(nullish) { + return nullish === null ? 0x42108422 : /* undefined */ 0x42108423; + } + + // Compress arbitrarily large numbers into smi hashes. + function hashNumber(n) { + if (n !== n || n === Infinity) { + return 0; + } + var hash = n | 0; + if (hash !== n) { + hash ^= n * 0xffffffff; + } + while (n > 0xffffffff) { + n /= 0xffffffff; + hash ^= n; + } + return smi(hash); + } + + function cachedHashString(string) { + var hashed = stringHashCache[string]; + if (hashed === undefined) { + hashed = hashString(string); + if (STRING_HASH_CACHE_SIZE === STRING_HASH_CACHE_MAX_SIZE) { + STRING_HASH_CACHE_SIZE = 0; + stringHashCache = {}; + } + STRING_HASH_CACHE_SIZE++; + stringHashCache[string] = hashed; + } + return hashed; + } + + // http://jsperf.com/hashing-strings + function hashString(string) { + // This is the hash from JVM + // The hash code for a string is computed as + // s[0] * 31 ^ (n - 1) + s[1] * 31 ^ (n - 2) + ... + s[n - 1], + // where s[i] is the ith character of the string and n is the length of + // the string. We "mod" the result to make it between 0 (inclusive) and 2^31 + // (exclusive) by dropping high bits. + var hashed = 0; + for (var ii = 0; ii < string.length; ii++) { + hashed = (31 * hashed + string.charCodeAt(ii)) | 0; + } + return smi(hashed); + } + + function hashSymbol(sym) { + var hashed = symbolMap[sym]; + if (hashed !== undefined) { + return hashed; + } + + hashed = nextHash(); + + symbolMap[sym] = hashed; + + return hashed; + } + + function hashJSObj(obj) { + var hashed; + if (usingWeakMap) { + hashed = weakMap.get(obj); + if (hashed !== undefined) { + return hashed; + } + } + + hashed = obj[UID_HASH_KEY]; + if (hashed !== undefined) { + return hashed; + } + + if (!canDefineProperty) { + hashed = obj.propertyIsEnumerable && obj.propertyIsEnumerable[UID_HASH_KEY]; + if (hashed !== undefined) { + return hashed; + } + + hashed = getIENodeHash(obj); + if (hashed !== undefined) { + return hashed; + } + } + + hashed = nextHash(); + + if (usingWeakMap) { + weakMap.set(obj, hashed); + } else if (isExtensible !== undefined && isExtensible(obj) === false) { + throw new Error('Non-extensible objects are not allowed as keys.'); + } else if (canDefineProperty) { + Object.defineProperty(obj, UID_HASH_KEY, { + enumerable: false, + configurable: false, + writable: false, + value: hashed, + }); + } else if ( + obj.propertyIsEnumerable !== undefined && + obj.propertyIsEnumerable === obj.constructor.prototype.propertyIsEnumerable + ) { + // Since we can't define a non-enumerable property on the object + // we'll hijack one of the less-used non-enumerable properties to + // save our hash on it. Since this is a function it will not show up in + // `JSON.stringify` which is what we want. + obj.propertyIsEnumerable = function () { + return this.constructor.prototype.propertyIsEnumerable.apply( + this, + arguments + ); + }; + obj.propertyIsEnumerable[UID_HASH_KEY] = hashed; + } else if (obj.nodeType !== undefined) { + // At this point we couldn't get the IE `uniqueID` to use as a hash + // and we couldn't use a non-enumerable property to exploit the + // dontEnum bug so we simply add the `UID_HASH_KEY` on the node + // itself. + obj[UID_HASH_KEY] = hashed; + } else { + throw new Error('Unable to set a non-enumerable property on object.'); + } + + return hashed; + } + + // Get references to ES5 object methods. + var isExtensible = Object.isExtensible; + + // True if Object.defineProperty works as expected. IE8 fails this test. + var canDefineProperty = (function () { + try { + Object.defineProperty({}, '@', {}); + return true; + // eslint-disable-next-line @typescript-eslint/no-unused-vars + } catch (e) { + return false; + } + })(); + + // IE has a `uniqueID` property on DOM nodes. We can construct the hash from it + // and avoid memory leaks from the IE cloneNode bug. + function getIENodeHash(node) { + if (node && node.nodeType > 0) { + switch (node.nodeType) { + case 1: // Element + return node.uniqueID; + case 9: // Document + return node.documentElement && node.documentElement.uniqueID; + } + } + } + + function valueOf(obj) { + return obj.valueOf !== defaultValueOf && typeof obj.valueOf === 'function' + ? obj.valueOf(obj) + : obj; + } + + function nextHash() { + var nextHash = ++_objHashUID; + if (_objHashUID & 0x40000000) { + _objHashUID = 0; + } + return nextHash; + } + + // If possible, use a WeakMap. + var usingWeakMap = typeof WeakMap === 'function'; + var weakMap; + if (usingWeakMap) { + weakMap = new WeakMap(); + } + + var symbolMap = Object.create(null); + + var _objHashUID = 0; + + var UID_HASH_KEY = '__immutablehash__'; + if (typeof Symbol === 'function') { + UID_HASH_KEY = Symbol(UID_HASH_KEY); + } + + var STRING_HASH_CACHE_MIN_STRLEN = 16; + var STRING_HASH_CACHE_MAX_SIZE = 255; + var STRING_HASH_CACHE_SIZE = 0; + var stringHashCache = {}; + + var ToKeyedSequence = /*@__PURE__*/(function (KeyedSeq) { + function ToKeyedSequence(indexed, useKeys) { + this._iter = indexed; + this._useKeys = useKeys; + this.size = indexed.size; + } + + if ( KeyedSeq ) ToKeyedSequence.__proto__ = KeyedSeq; + ToKeyedSequence.prototype = Object.create( KeyedSeq && KeyedSeq.prototype ); + ToKeyedSequence.prototype.constructor = ToKeyedSequence; + + ToKeyedSequence.prototype.get = function get (key, notSetValue) { + return this._iter.get(key, notSetValue); + }; + + ToKeyedSequence.prototype.has = function has (key) { + return this._iter.has(key); + }; + + ToKeyedSequence.prototype.valueSeq = function valueSeq () { + return this._iter.valueSeq(); + }; + + ToKeyedSequence.prototype.reverse = function reverse () { + var this$1$1 = this; + + var reversedSequence = reverseFactory(this, true); + if (!this._useKeys) { + reversedSequence.valueSeq = function () { return this$1$1._iter.toSeq().reverse(); }; + } + return reversedSequence; + }; + + ToKeyedSequence.prototype.map = function map (mapper, context) { + var this$1$1 = this; + + var mappedSequence = mapFactory(this, mapper, context); + if (!this._useKeys) { + mappedSequence.valueSeq = function () { return this$1$1._iter.toSeq().map(mapper, context); }; + } + return mappedSequence; + }; + + ToKeyedSequence.prototype.__iterate = function __iterate (fn, reverse) { + var this$1$1 = this; + + return this._iter.__iterate(function (v, k) { return fn(v, k, this$1$1); }, reverse); + }; + + ToKeyedSequence.prototype.__iterator = function __iterator (type, reverse) { + return this._iter.__iterator(type, reverse); + }; + + return ToKeyedSequence; + }(KeyedSeq)); + ToKeyedSequence.prototype[IS_ORDERED_SYMBOL] = true; + + var ToIndexedSequence = /*@__PURE__*/(function (IndexedSeq) { + function ToIndexedSequence(iter) { + this._iter = iter; + this.size = iter.size; + } + + if ( IndexedSeq ) ToIndexedSequence.__proto__ = IndexedSeq; + ToIndexedSequence.prototype = Object.create( IndexedSeq && IndexedSeq.prototype ); + ToIndexedSequence.prototype.constructor = ToIndexedSequence; + + ToIndexedSequence.prototype.includes = function includes (value) { + return this._iter.includes(value); + }; + + ToIndexedSequence.prototype.__iterate = function __iterate (fn, reverse) { + var this$1$1 = this; + + var i = 0; + // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here + reverse && ensureSize(this); + return this._iter.__iterate( + function (v) { return fn(v, reverse ? this$1$1.size - ++i : i++, this$1$1); }, + reverse + ); + }; + + ToIndexedSequence.prototype.__iterator = function __iterator (type, reverse) { + var this$1$1 = this; + + var iterator = this._iter.__iterator(ITERATE_VALUES, reverse); + var i = 0; + // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here + reverse && ensureSize(this); + return new Iterator(function () { + var step = iterator.next(); + return step.done + ? step + : iteratorValue( + type, + reverse ? this$1$1.size - ++i : i++, + step.value, + step + ); + }); + }; + + return ToIndexedSequence; + }(IndexedSeq)); + + var ToSetSequence = /*@__PURE__*/(function (SetSeq) { + function ToSetSequence(iter) { + this._iter = iter; + this.size = iter.size; + } + + if ( SetSeq ) ToSetSequence.__proto__ = SetSeq; + ToSetSequence.prototype = Object.create( SetSeq && SetSeq.prototype ); + ToSetSequence.prototype.constructor = ToSetSequence; + + ToSetSequence.prototype.has = function has (key) { + return this._iter.includes(key); + }; + + ToSetSequence.prototype.__iterate = function __iterate (fn, reverse) { + var this$1$1 = this; + + return this._iter.__iterate(function (v) { return fn(v, v, this$1$1); }, reverse); + }; + + ToSetSequence.prototype.__iterator = function __iterator (type, reverse) { + var iterator = this._iter.__iterator(ITERATE_VALUES, reverse); + return new Iterator(function () { + var step = iterator.next(); + return step.done + ? step + : iteratorValue(type, step.value, step.value, step); + }); + }; + + return ToSetSequence; + }(SetSeq)); + + var FromEntriesSequence = /*@__PURE__*/(function (KeyedSeq) { + function FromEntriesSequence(entries) { + this._iter = entries; + this.size = entries.size; + } + + if ( KeyedSeq ) FromEntriesSequence.__proto__ = KeyedSeq; + FromEntriesSequence.prototype = Object.create( KeyedSeq && KeyedSeq.prototype ); + FromEntriesSequence.prototype.constructor = FromEntriesSequence; + + FromEntriesSequence.prototype.entrySeq = function entrySeq () { + return this._iter.toSeq(); + }; + + FromEntriesSequence.prototype.__iterate = function __iterate (fn, reverse) { + var this$1$1 = this; + + return this._iter.__iterate(function (entry) { // Check if entry exists first so array access doesn't throw for holes // in the parent iteration. if (entry) { validateEntry(entry); var indexedCollection = isCollection(entry); - return iteratorValue( - type, - indexedCollection ? entry.get(0) : entry[0], + return fn( indexedCollection ? entry.get(1) : entry[1], - step + indexedCollection ? entry.get(0) : entry[0], + this$1$1 ); } + }, reverse); + }; + + FromEntriesSequence.prototype.__iterator = function __iterator (type, reverse) { + var iterator = this._iter.__iterator(ITERATE_VALUES, reverse); + return new Iterator(function () { + while (true) { + var step = iterator.next(); + if (step.done) { + return step; + } + var entry = step.value; + // Check if entry exists first so array access doesn't throw for holes + // in the parent iteration. + if (entry) { + validateEntry(entry); + var indexedCollection = isCollection(entry); + return iteratorValue( + type, + indexedCollection ? entry.get(0) : entry[0], + indexedCollection ? entry.get(1) : entry[1], + step + ); + } + } + }); + }; + + return FromEntriesSequence; + }(KeyedSeq)); + + ToIndexedSequence.prototype.cacheResult = + ToKeyedSequence.prototype.cacheResult = + ToSetSequence.prototype.cacheResult = + FromEntriesSequence.prototype.cacheResult = + cacheResultThrough; + + function flipFactory(collection) { + var flipSequence = makeSequence(collection); + flipSequence._iter = collection; + flipSequence.size = collection.size; + flipSequence.flip = function () { return collection; }; + flipSequence.reverse = function () { + var reversedSequence = collection.reverse.apply(this); // super.reverse() + reversedSequence.flip = function () { return collection.reverse(); }; + return reversedSequence; + }; + flipSequence.has = function (key) { return collection.includes(key); }; + flipSequence.includes = function (key) { return collection.has(key); }; + flipSequence.cacheResult = cacheResultThrough; + flipSequence.__iterateUncached = function (fn, reverse) { + var this$1$1 = this; + + return collection.__iterate(function (v, k) { return fn(k, v, this$1$1) !== false; }, reverse); + }; + flipSequence.__iteratorUncached = function (type, reverse) { + if (type === ITERATE_ENTRIES) { + var iterator = collection.__iterator(type, reverse); + return new Iterator(function () { + var step = iterator.next(); + if (!step.done) { + var k = step.value[0]; + step.value[0] = step.value[1]; + step.value[1] = k; + } + return step; + }); } - }); - }; + return collection.__iterator( + type === ITERATE_VALUES ? ITERATE_KEYS : ITERATE_VALUES, + reverse + ); + }; + return flipSequence; + } - return FromEntriesSequence; - }(KeyedSeq)); - - ToIndexedSequence.prototype.cacheResult = - ToKeyedSequence.prototype.cacheResult = - ToSetSequence.prototype.cacheResult = - FromEntriesSequence.prototype.cacheResult = - cacheResultThrough; - - function flipFactory(collection) { - var flipSequence = makeSequence(collection); - flipSequence._iter = collection; - flipSequence.size = collection.size; - flipSequence.flip = function () { return collection; }; - flipSequence.reverse = function () { - var reversedSequence = collection.reverse.apply(this); // super.reverse() - reversedSequence.flip = function () { return collection.reverse(); }; - return reversedSequence; - }; - flipSequence.has = function (key) { return collection.includes(key); }; - flipSequence.includes = function (key) { return collection.has(key); }; - flipSequence.cacheResult = cacheResultThrough; - flipSequence.__iterateUncached = function (fn, reverse) { + function mapFactory(collection, mapper, context) { + var mappedSequence = makeSequence(collection); + mappedSequence.size = collection.size; + mappedSequence.has = function (key) { return collection.has(key); }; + mappedSequence.get = function (key, notSetValue) { + var v = collection.get(key, NOT_SET); + return v === NOT_SET + ? notSetValue + : mapper.call(context, v, key, collection); + }; + mappedSequence.__iterateUncached = function (fn, reverse) { + var this$1$1 = this; + + return collection.__iterate( + function (v, k, c) { return fn(mapper.call(context, v, k, c), k, this$1$1) !== false; }, + reverse + ); + }; + mappedSequence.__iteratorUncached = function (type, reverse) { + var iterator = collection.__iterator(ITERATE_ENTRIES, reverse); + return new Iterator(function () { + var step = iterator.next(); + if (step.done) { + return step; + } + var entry = step.value; + var key = entry[0]; + return iteratorValue( + type, + key, + mapper.call(context, entry[1], key, collection), + step + ); + }); + }; + return mappedSequence; + } + + function reverseFactory(collection, useKeys) { var this$1$1 = this; - return collection.__iterate(function (v, k) { return fn(k, v, this$1$1) !== false; }, reverse); - }; - flipSequence.__iteratorUncached = function (type, reverse) { - if (type === ITERATE_ENTRIES) { - var iterator = collection.__iterator(type, reverse); + var reversedSequence = makeSequence(collection); + reversedSequence._iter = collection; + reversedSequence.size = collection.size; + reversedSequence.reverse = function () { return collection; }; + if (collection.flip) { + reversedSequence.flip = function () { + var flipSequence = flipFactory(collection); + flipSequence.reverse = function () { return collection.flip(); }; + return flipSequence; + }; + } + reversedSequence.get = function (key, notSetValue) { return collection.get(useKeys ? key : -1 - key, notSetValue); }; + reversedSequence.has = function (key) { return collection.has(useKeys ? key : -1 - key); }; + reversedSequence.includes = function (value) { return collection.includes(value); }; + reversedSequence.cacheResult = cacheResultThrough; + reversedSequence.__iterate = function (fn, reverse) { + var this$1$1 = this; + + var i = 0; + // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here + reverse && ensureSize(collection); + return collection.__iterate( + function (v, k) { return fn(v, useKeys ? k : reverse ? this$1$1.size - ++i : i++, this$1$1); }, + !reverse + ); + }; + reversedSequence.__iterator = function (type, reverse) { + var i = 0; + // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here + reverse && ensureSize(collection); + var iterator = collection.__iterator(ITERATE_ENTRIES, !reverse); return new Iterator(function () { var step = iterator.next(); - if (!step.done) { - var k = step.value[0]; - step.value[0] = step.value[1]; - step.value[1] = k; + if (step.done) { + return step; } - return step; + var entry = step.value; + return iteratorValue( + type, + useKeys ? entry[0] : reverse ? this$1$1.size - ++i : i++, + entry[1], + step + ); }); + }; + return reversedSequence; + } + + function filterFactory(collection, predicate, context, useKeys) { + var filterSequence = makeSequence(collection); + if (useKeys) { + filterSequence.has = function (key) { + var v = collection.get(key, NOT_SET); + return v !== NOT_SET && !!predicate.call(context, v, key, collection); + }; + filterSequence.get = function (key, notSetValue) { + var v = collection.get(key, NOT_SET); + return v !== NOT_SET && predicate.call(context, v, key, collection) + ? v + : notSetValue; + }; } - return collection.__iterator( - type === ITERATE_VALUES ? ITERATE_KEYS : ITERATE_VALUES, - reverse - ); - }; - return flipSequence; - } - - function mapFactory(collection, mapper, context) { - var mappedSequence = makeSequence(collection); - mappedSequence.size = collection.size; - mappedSequence.has = function (key) { return collection.has(key); }; - mappedSequence.get = function (key, notSetValue) { - var v = collection.get(key, NOT_SET); - return v === NOT_SET - ? notSetValue - : mapper.call(context, v, key, collection); - }; - mappedSequence.__iterateUncached = function (fn, reverse) { - var this$1$1 = this; + filterSequence.__iterateUncached = function (fn, reverse) { + var this$1$1 = this; - return collection.__iterate( - function (v, k, c) { return fn(mapper.call(context, v, k, c), k, this$1$1) !== false; }, - reverse - ); - }; - mappedSequence.__iteratorUncached = function (type, reverse) { - var iterator = collection.__iterator(ITERATE_ENTRIES, reverse); - return new Iterator(function () { - var step = iterator.next(); - if (step.done) { - return step; - } - var entry = step.value; - var key = entry[0]; - return iteratorValue( - type, - key, - mapper.call(context, entry[1], key, collection), - step + var iterations = 0; + collection.__iterate(function (v, k, c) { + if (predicate.call(context, v, k, c)) { + iterations++; + return fn(v, useKeys ? k : iterations - 1, this$1$1); + } + }, reverse); + return iterations; + }; + filterSequence.__iteratorUncached = function (type, reverse) { + var iterator = collection.__iterator(ITERATE_ENTRIES, reverse); + var iterations = 0; + return new Iterator(function () { + while (true) { + var step = iterator.next(); + if (step.done) { + return step; + } + var entry = step.value; + var key = entry[0]; + var value = entry[1]; + if (predicate.call(context, value, key, collection)) { + return iteratorValue(type, useKeys ? key : iterations++, value, step); + } + } + }); + }; + return filterSequence; + } + + function countByFactory(collection, grouper, context) { + var groups = Map().asMutable(); + collection.__iterate(function (v, k) { + groups.update(grouper.call(context, v, k, collection), 0, function (a) { return a + 1; }); + }); + return groups.asImmutable(); + } + + function groupByFactory(collection, grouper, context) { + var isKeyedIter = isKeyed(collection); + var groups = (isOrdered(collection) ? OrderedMap() : Map()).asMutable(); + collection.__iterate(function (v, k) { + groups.update( + grouper.call(context, v, k, collection), + function (a) { return ((a = a || []), a.push(isKeyedIter ? [k, v] : v), a); } ); }); - }; - return mappedSequence; - } - - function reverseFactory(collection, useKeys) { - var this$1$1 = this; - - var reversedSequence = makeSequence(collection); - reversedSequence._iter = collection; - reversedSequence.size = collection.size; - reversedSequence.reverse = function () { return collection; }; - if (collection.flip) { - reversedSequence.flip = function () { - var flipSequence = flipFactory(collection); - flipSequence.reverse = function () { return collection.flip(); }; - return flipSequence; - }; - } - reversedSequence.get = function (key, notSetValue) { return collection.get(useKeys ? key : -1 - key, notSetValue); }; - reversedSequence.has = function (key) { return collection.has(useKeys ? key : -1 - key); }; - reversedSequence.includes = function (value) { return collection.includes(value); }; - reversedSequence.cacheResult = cacheResultThrough; - reversedSequence.__iterate = function (fn, reverse) { - var this$1$1 = this; + var coerce = collectionClass(collection); + return groups.map(function (arr) { return reify(collection, coerce(arr)); }).asImmutable(); + } - var i = 0; - // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here - reverse && ensureSize(collection); - return collection.__iterate( - function (v, k) { return fn(v, useKeys ? k : reverse ? this$1$1.size - ++i : i++, this$1$1); }, - !reverse - ); - }; - reversedSequence.__iterator = function (type, reverse) { - var i = 0; - // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here - reverse && ensureSize(collection); - var iterator = collection.__iterator(ITERATE_ENTRIES, !reverse); - return new Iterator(function () { - var step = iterator.next(); - if (step.done) { - return step; - } - var entry = step.value; - return iteratorValue( - type, - useKeys ? entry[0] : reverse ? this$1$1.size - ++i : i++, - entry[1], - step + function partitionFactory(collection, predicate, context) { + var isKeyedIter = isKeyed(collection); + var groups = [[], []]; + collection.__iterate(function (v, k) { + groups[predicate.call(context, v, k, collection) ? 1 : 0].push( + isKeyedIter ? [k, v] : v ); }); - }; - return reversedSequence; - } + var coerce = collectionClass(collection); + return groups.map(function (arr) { return reify(collection, coerce(arr)); }); + } - function filterFactory(collection, predicate, context, useKeys) { - var filterSequence = makeSequence(collection); - if (useKeys) { - filterSequence.has = function (key) { - var v = collection.get(key, NOT_SET); - return v !== NOT_SET && !!predicate.call(context, v, key, collection); + function sliceFactory(collection, begin, end, useKeys) { + var originalSize = collection.size; + + if (wholeSlice(begin, end, originalSize)) { + return collection; + } + + // begin or end can not be resolved if they were provided as negative numbers and + // this collection's size is unknown. In that case, cache first so there is + // a known size and these do not resolve to NaN. + if (typeof originalSize === 'undefined' && (begin < 0 || end < 0)) { + return sliceFactory(collection.toSeq().cacheResult(), begin, end, useKeys); + } + + var resolvedBegin = resolveBegin(begin, originalSize); + var resolvedEnd = resolveEnd(end, originalSize); + + // Note: resolvedEnd is undefined when the original sequence's length is + // unknown and this slice did not supply an end and should contain all + // elements after resolvedBegin. + // In that case, resolvedSize will be NaN and sliceSize will remain undefined. + var resolvedSize = resolvedEnd - resolvedBegin; + var sliceSize; + if (resolvedSize === resolvedSize) { + sliceSize = resolvedSize < 0 ? 0 : resolvedSize; + } + + var sliceSeq = makeSequence(collection); + + // If collection.size is undefined, the size of the realized sliceSeq is + // unknown at this point unless the number of items to slice is 0 + sliceSeq.size = + sliceSize === 0 ? sliceSize : (collection.size && sliceSize) || undefined; + + if (!useKeys && isSeq(collection) && sliceSize >= 0) { + sliceSeq.get = function (index, notSetValue) { + index = wrapIndex(this, index); + return index >= 0 && index < sliceSize + ? collection.get(index + resolvedBegin, notSetValue) + : notSetValue; + }; + } + + sliceSeq.__iterateUncached = function (fn, reverse) { + var this$1$1 = this; + + if (sliceSize === 0) { + return 0; + } + if (reverse) { + return this.cacheResult().__iterate(fn, reverse); + } + var skipped = 0; + var isSkipping = true; + var iterations = 0; + collection.__iterate(function (v, k) { + if (!(isSkipping && (isSkipping = skipped++ < resolvedBegin))) { + iterations++; + return ( + fn(v, useKeys ? k : iterations - 1, this$1$1) !== false && + iterations !== sliceSize + ); + } + }); + return iterations; }; - filterSequence.get = function (key, notSetValue) { - var v = collection.get(key, NOT_SET); - return v !== NOT_SET && predicate.call(context, v, key, collection) - ? v - : notSetValue; + + sliceSeq.__iteratorUncached = function (type, reverse) { + if (sliceSize !== 0 && reverse) { + return this.cacheResult().__iterator(type, reverse); + } + // Don't bother instantiating parent iterator if taking 0. + if (sliceSize === 0) { + return new Iterator(iteratorDone); + } + var iterator = collection.__iterator(type, reverse); + var skipped = 0; + var iterations = 0; + return new Iterator(function () { + while (skipped++ < resolvedBegin) { + iterator.next(); + } + if (++iterations > sliceSize) { + return iteratorDone(); + } + var step = iterator.next(); + if (useKeys || type === ITERATE_VALUES || step.done) { + return step; + } + if (type === ITERATE_KEYS) { + return iteratorValue(type, iterations - 1, undefined, step); + } + return iteratorValue(type, iterations - 1, step.value[1], step); + }); }; + + return sliceSeq; } - filterSequence.__iterateUncached = function (fn, reverse) { - var this$1$1 = this; - var iterations = 0; - collection.__iterate(function (v, k, c) { - if (predicate.call(context, v, k, c)) { - iterations++; - return fn(v, useKeys ? k : iterations - 1, this$1$1); + function takeWhileFactory(collection, predicate, context) { + var takeSequence = makeSequence(collection); + takeSequence.__iterateUncached = function (fn, reverse) { + var this$1$1 = this; + + if (reverse) { + return this.cacheResult().__iterate(fn, reverse); } - }, reverse); - return iterations; - }; - filterSequence.__iteratorUncached = function (type, reverse) { - var iterator = collection.__iterator(ITERATE_ENTRIES, reverse); - var iterations = 0; - return new Iterator(function () { - while (true) { + var iterations = 0; + collection.__iterate( + function (v, k, c) { return predicate.call(context, v, k, c) && ++iterations && fn(v, k, this$1$1); } + ); + return iterations; + }; + takeSequence.__iteratorUncached = function (type, reverse) { + var this$1$1 = this; + + if (reverse) { + return this.cacheResult().__iterator(type, reverse); + } + var iterator = collection.__iterator(ITERATE_ENTRIES, reverse); + var iterating = true; + return new Iterator(function () { + if (!iterating) { + return iteratorDone(); + } var step = iterator.next(); if (step.done) { return step; } var entry = step.value; - var key = entry[0]; - var value = entry[1]; - if (predicate.call(context, value, key, collection)) { - return iteratorValue(type, useKeys ? key : iterations++, value, step); + var k = entry[0]; + var v = entry[1]; + if (!predicate.call(context, v, k, this$1$1)) { + iterating = false; + return iteratorDone(); } + return type === ITERATE_ENTRIES ? step : iteratorValue(type, k, v, step); + }); + }; + return takeSequence; + } + + function skipWhileFactory(collection, predicate, context, useKeys) { + var skipSequence = makeSequence(collection); + skipSequence.__iterateUncached = function (fn, reverse) { + var this$1$1 = this; + + if (reverse) { + return this.cacheResult().__iterate(fn, reverse); } - }); - }; - return filterSequence; - } + var isSkipping = true; + var iterations = 0; + collection.__iterate(function (v, k, c) { + if (!(isSkipping && (isSkipping = predicate.call(context, v, k, c)))) { + iterations++; + return fn(v, useKeys ? k : iterations - 1, this$1$1); + } + }); + return iterations; + }; + skipSequence.__iteratorUncached = function (type, reverse) { + var this$1$1 = this; + + if (reverse) { + return this.cacheResult().__iterator(type, reverse); + } + var iterator = collection.__iterator(ITERATE_ENTRIES, reverse); + var skipping = true; + var iterations = 0; + return new Iterator(function () { + var step; + var k; + var v; + do { + step = iterator.next(); + if (step.done) { + if (useKeys || type === ITERATE_VALUES) { + return step; + } + if (type === ITERATE_KEYS) { + return iteratorValue(type, iterations++, undefined, step); + } + return iteratorValue(type, iterations++, step.value[1], step); + } + var entry = step.value; + k = entry[0]; + v = entry[1]; + // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here + skipping && (skipping = predicate.call(context, v, k, this$1$1)); + } while (skipping); + return type === ITERATE_ENTRIES ? step : iteratorValue(type, k, v, step); + }); + }; + return skipSequence; + } + + var ConcatSeq = /*@__PURE__*/(function (Seq) { + function ConcatSeq(iterables) { + this._wrappedIterables = iterables.flatMap(function (iterable) { + if (iterable._wrappedIterables) { + return iterable._wrappedIterables; + } + return [iterable]; + }); + this.size = this._wrappedIterables.reduce(function (sum, iterable) { + if (sum !== undefined) { + var size = iterable.size; + if (size !== undefined) { + return sum + size; + } + } + }, 0); + this[IS_KEYED_SYMBOL] = this._wrappedIterables[0][IS_KEYED_SYMBOL]; + this[IS_INDEXED_SYMBOL] = this._wrappedIterables[0][IS_INDEXED_SYMBOL]; + this[IS_ORDERED_SYMBOL] = this._wrappedIterables[0][IS_ORDERED_SYMBOL]; + } + + if ( Seq ) ConcatSeq.__proto__ = Seq; + ConcatSeq.prototype = Object.create( Seq && Seq.prototype ); + ConcatSeq.prototype.constructor = ConcatSeq; + + ConcatSeq.prototype.__iterateUncached = function __iterateUncached (fn, reverse) { + if (this._wrappedIterables.length === 0) { + return; + } + + if (reverse) { + return this.cacheResult().__iterate(fn, reverse); + } + + var iterableIndex = 0; + var useKeys = isKeyed(this); + var iteratorType = useKeys ? ITERATE_ENTRIES : ITERATE_VALUES; + var currentIterator = this._wrappedIterables[iterableIndex].__iterator( + iteratorType, + reverse + ); + + var keepGoing = true; + var index = 0; + while (keepGoing) { + var next = currentIterator.next(); + while (next.done) { + iterableIndex++; + if (iterableIndex === this._wrappedIterables.length) { + return index; + } + currentIterator = this._wrappedIterables[iterableIndex].__iterator( + iteratorType, + reverse + ); + next = currentIterator.next(); + } + var fnResult = useKeys + ? fn(next.value[1], next.value[0], this) + : fn(next.value, index, this); + keepGoing = fnResult !== false; + index++; + } + return index; + }; + + ConcatSeq.prototype.__iteratorUncached = function __iteratorUncached (type, reverse) { + var this$1$1 = this; + + if (this._wrappedIterables.length === 0) { + return new Iterator(iteratorDone); + } + + if (reverse) { + return this.cacheResult().__iterator(type, reverse); + } + + var iterableIndex = 0; + var currentIterator = this._wrappedIterables[iterableIndex].__iterator( + type, + reverse + ); + return new Iterator(function () { + var next = currentIterator.next(); + while (next.done) { + iterableIndex++; + if (iterableIndex === this$1$1._wrappedIterables.length) { + return next; + } + currentIterator = this$1$1._wrappedIterables[iterableIndex].__iterator( + type, + reverse + ); + next = currentIterator.next(); + } + return next; + }); + }; + + return ConcatSeq; + }(Seq)); + + function concatFactory(collection, values) { + var isKeyedCollection = isKeyed(collection); + var iters = [collection] + .concat(values) + .map(function (v) { + if (!isCollection(v)) { + v = isKeyedCollection + ? keyedSeqFromValue(v) + : indexedSeqFromValue(Array.isArray(v) ? v : [v]); + } else if (isKeyedCollection) { + v = KeyedCollection(v); + } + return v; + }) + .filter(function (v) { return v.size !== 0; }); + + if (iters.length === 0) { + return collection; + } + + if (iters.length === 1) { + var singleton = iters[0]; + if ( + singleton === collection || + (isKeyedCollection && isKeyed(singleton)) || + (isIndexed(collection) && isIndexed(singleton)) + ) { + return singleton; + } + } + + return new ConcatSeq(iters); + } + + function flattenFactory(collection, depth, useKeys) { + var flatSequence = makeSequence(collection); + flatSequence.__iterateUncached = function (fn, reverse) { + if (reverse) { + return this.cacheResult().__iterate(fn, reverse); + } + var iterations = 0; + var stopped = false; + function flatDeep(iter, currentDepth) { + iter.__iterate(function (v, k) { + if ((!depth || currentDepth < depth) && isCollection(v)) { + flatDeep(v, currentDepth + 1); + } else { + iterations++; + if (fn(v, useKeys ? k : iterations - 1, flatSequence) === false) { + stopped = true; + } + } + return !stopped; + }, reverse); + } + flatDeep(collection, 0); + return iterations; + }; + flatSequence.__iteratorUncached = function (type, reverse) { + if (reverse) { + return this.cacheResult().__iterator(type, reverse); + } + var iterator = collection.__iterator(type, reverse); + var stack = []; + var iterations = 0; + return new Iterator(function () { + while (iterator) { + var step = iterator.next(); + if (step.done !== false) { + iterator = stack.pop(); + continue; + } + var v = step.value; + if (type === ITERATE_ENTRIES) { + v = v[1]; + } + if ((!depth || stack.length < depth) && isCollection(v)) { + stack.push(iterator); + iterator = v.__iterator(type, reverse); + } else { + return useKeys ? step : iteratorValue(type, iterations++, v, step); + } + } + return iteratorDone(); + }); + }; + return flatSequence; + } + + function flatMapFactory(collection, mapper, context) { + var coerce = collectionClass(collection); + return collection + .toSeq() + .map(function (v, k) { return coerce(mapper.call(context, v, k, collection)); }) + .flatten(true); + } + + function interposeFactory(collection, separator) { + var interposedSequence = makeSequence(collection); + interposedSequence.size = collection.size && collection.size * 2 - 1; + interposedSequence.__iterateUncached = function (fn, reverse) { + var this$1$1 = this; + + var iterations = 0; + collection.__iterate( + function (v) { return (!iterations || fn(separator, iterations++, this$1$1) !== false) && + fn(v, iterations++, this$1$1) !== false; }, + reverse + ); + return iterations; + }; + interposedSequence.__iteratorUncached = function (type, reverse) { + var iterator = collection.__iterator(ITERATE_VALUES, reverse); + var iterations = 0; + var step; + return new Iterator(function () { + if (!step || iterations % 2) { + step = iterator.next(); + if (step.done) { + return step; + } + } + return iterations % 2 + ? iteratorValue(type, iterations++, separator) + : iteratorValue(type, iterations++, step.value, step); + }); + }; + return interposedSequence; + } + + function sortFactory(collection, comparator, mapper) { + if (!comparator) { + comparator = defaultComparator; + } + var isKeyedCollection = isKeyed(collection); + var index = 0; + var entries = collection + .toSeq() + .map(function (v, k) { return [k, v, index++, mapper ? mapper(v, k, collection) : v]; }) + .valueSeq() + .toArray(); + entries + .sort(function (a, b) { return comparator(a[3], b[3]) || a[2] - b[2]; }) + .forEach( + isKeyedCollection + ? function (v, i) { + entries[i].length = 2; + } + : function (v, i) { + entries[i] = v[1]; + } + ); + return isKeyedCollection + ? KeyedSeq(entries) + : isIndexed(collection) + ? IndexedSeq(entries) + : SetSeq(entries); + } + + function maxFactory(collection, comparator, mapper) { + if (!comparator) { + comparator = defaultComparator; + } + if (mapper) { + var entry = collection + .toSeq() + .map(function (v, k) { return [v, mapper(v, k, collection)]; }) + .reduce(function (a, b) { return (maxCompare(comparator, a[1], b[1]) ? b : a); }); + return entry && entry[0]; + } + return collection.reduce(function (a, b) { return (maxCompare(comparator, a, b) ? b : a); }); + } + + function maxCompare(comparator, a, b) { + var comp = comparator(b, a); + // b is considered the new max if the comparator declares them equal, but + // they are not equal and b is in fact a nullish value. + return ( + (comp === 0 && b !== a && (b === undefined || b === null || b !== b)) || + comp > 0 + ); + } + + function zipWithFactory(keyIter, zipper, iters, zipAll) { + var zipSequence = makeSequence(keyIter); + var sizes = new ArraySeq(iters).map(function (i) { return i.size; }); + zipSequence.size = zipAll ? sizes.max() : sizes.min(); + // Note: this a generic base implementation of __iterate in terms of + // __iterator which may be more generically useful in the future. + zipSequence.__iterate = function (fn, reverse) { + /* generic: + var iterator = this.__iterator(ITERATE_ENTRIES, reverse); + var step; + var iterations = 0; + while (!(step = iterator.next()).done) { + iterations++; + if (fn(step.value[1], step.value[0], this) === false) { + break; + } + } + return iterations; + */ + // indexed: + var iterator = this.__iterator(ITERATE_VALUES, reverse); + var step; + var iterations = 0; + while (!(step = iterator.next()).done) { + if (fn(step.value, iterations++, this) === false) { + break; + } + } + return iterations; + }; + zipSequence.__iteratorUncached = function (type, reverse) { + var iterators = iters.map( + function (i) { return ((i = Collection(i)), getIterator(reverse ? i.reverse() : i)); } + ); + var iterations = 0; + var isDone = false; + return new Iterator(function () { + var steps; + if (!isDone) { + steps = iterators.map(function (i) { return i.next(); }); + isDone = zipAll + ? steps.every(function (s) { return s.done; }) + : steps.some(function (s) { return s.done; }); + } + if (isDone) { + return iteratorDone(); + } + return iteratorValue( + type, + iterations++, + zipper.apply( + null, + steps.map(function (s) { return s.value; }) + ) + ); + }); + }; + return zipSequence; + } + + // #pragma Helper Functions + + function reify(iter, seq) { + return iter === seq ? iter : isSeq(iter) ? seq : iter.constructor(seq); + } + + function validateEntry(entry) { + if (entry !== Object(entry)) { + throw new TypeError('Expected [K, V] tuple: ' + entry); + } + } + + function collectionClass(collection) { + return isKeyed(collection) + ? KeyedCollection + : isIndexed(collection) + ? IndexedCollection + : SetCollection; + } + + function makeSequence(collection) { + return Object.create( + (isKeyed(collection) + ? KeyedSeq + : isIndexed(collection) + ? IndexedSeq + : SetSeq + ).prototype + ); + } + + function cacheResultThrough() { + if (this._iter.cacheResult) { + this._iter.cacheResult(); + this.size = this._iter.size; + return this; + } + return Seq.prototype.cacheResult.call(this); + } + + function defaultComparator(a, b) { + if (a === undefined && b === undefined) { + return 0; + } + + if (a === undefined) { + return 1; + } + + if (b === undefined) { + return -1; + } - function countByFactory(collection, grouper, context) { - var groups = Map().asMutable(); - collection.__iterate(function (v, k) { - groups.update(grouper.call(context, v, k, collection), 0, function (a) { return a + 1; }); - }); - return groups.asImmutable(); - } - - function groupByFactory(collection, grouper, context) { - var isKeyedIter = isKeyed(collection); - var groups = (isOrdered(collection) ? OrderedMap() : Map()).asMutable(); - collection.__iterate(function (v, k) { - groups.update( - grouper.call(context, v, k, collection), - function (a) { return ((a = a || []), a.push(isKeyedIter ? [k, v] : v), a); } - ); - }); - var coerce = collectionClass(collection); - return groups.map(function (arr) { return reify(collection, coerce(arr)); }).asImmutable(); - } - - function partitionFactory(collection, predicate, context) { - var isKeyedIter = isKeyed(collection); - var groups = [[], []]; - collection.__iterate(function (v, k) { - groups[predicate.call(context, v, k, collection) ? 1 : 0].push( - isKeyedIter ? [k, v] : v - ); - }); - var coerce = collectionClass(collection); - return groups.map(function (arr) { return reify(collection, coerce(arr)); }); - } + return a > b ? 1 : a < b ? -1 : 0; + } + + // http://jsperf.com/copy-array-inline + function arrCopy(arr, offset) { + offset = offset || 0; + var len = Math.max(0, arr.length - offset); + var newArr = new Array(len); + for (var ii = 0; ii < len; ii++) { + // @ts-expect-error We may want to guard for undefined values with `if (arr[ii + offset] !== undefined`, but ths should not happen by design + newArr[ii] = arr[ii + offset]; + } + return newArr; + } - function sliceFactory(collection, begin, end, useKeys) { - var originalSize = collection.size; + function invariant(condition, error) { + if (!condition) + { throw new Error(error); } + } - if (wholeSlice(begin, end, originalSize)) { - return collection; + function assertNotInfinite(size) { + invariant(size !== Infinity, 'Cannot perform this action with an infinite size.'); } - // begin or end can not be resolved if they were provided as negative numbers and - // this collection's size is unknown. In that case, cache first so there is - // a known size and these do not resolve to NaN. - if (typeof originalSize === 'undefined' && (begin < 0 || end < 0)) { - return sliceFactory(collection.toSeq().cacheResult(), begin, end, useKeys); + function coerceKeyPath(keyPath) { + if (isArrayLike(keyPath) && typeof keyPath !== 'string') { + return keyPath; + } + if (isOrdered(keyPath)) { + return keyPath.toArray(); + } + throw new TypeError('Invalid keyPath: expected Ordered Collection or Array: ' + keyPath); } - var resolvedBegin = resolveBegin(begin, originalSize); - var resolvedEnd = resolveEnd(end, originalSize); + var toString = Object.prototype.toString; + function isPlainObject(value) { + // The base prototype's toString deals with Argument objects and native namespaces like Math + if (!value || + typeof value !== 'object' || + toString.call(value) !== '[object Object]') { + return false; + } + var proto = Object.getPrototypeOf(value); + if (proto === null) { + return true; + } + // Iteratively going up the prototype chain is needed for cross-realm environments (differing contexts, iframes, etc) + var parentProto = proto; + var nextProto = Object.getPrototypeOf(proto); + while (nextProto !== null) { + parentProto = nextProto; + nextProto = Object.getPrototypeOf(parentProto); + } + return parentProto === proto; + } - // Note: resolvedEnd is undefined when the original sequence's length is - // unknown and this slice did not supply an end and should contain all - // elements after resolvedBegin. - // In that case, resolvedSize will be NaN and sliceSize will remain undefined. - var resolvedSize = resolvedEnd - resolvedBegin; - var sliceSize; - if (resolvedSize === resolvedSize) { - sliceSize = resolvedSize < 0 ? 0 : resolvedSize; + /** + * Returns true if the value is a potentially-persistent data structure, either + * provided by Immutable.js or a plain Array or Object. + */ + function isDataStructure(value) { + return (typeof value === 'object' && + (isImmutable(value) || Array.isArray(value) || isPlainObject(value))); } - var sliceSeq = makeSequence(collection); + /** + * Converts a value to a string, adding quotes if a string was provided. + */ + function quoteString(value) { + try { + return typeof value === 'string' ? JSON.stringify(value) : String(value); + // eslint-disable-next-line @typescript-eslint/no-unused-vars + } + catch (_ignoreError) { + return JSON.stringify(value); + } + } - // If collection.size is undefined, the size of the realized sliceSeq is - // unknown at this point unless the number of items to slice is 0 - sliceSeq.size = - sliceSize === 0 ? sliceSize : (collection.size && sliceSize) || undefined; + function has(collection, key) { + return isImmutable(collection) + ? collection.has(key) + : isDataStructure(collection) && hasOwnProperty.call(collection, key); + } - if (!useKeys && isSeq(collection) && sliceSize >= 0) { - sliceSeq.get = function (index, notSetValue) { - index = wrapIndex(this, index); - return index >= 0 && index < sliceSize - ? collection.get(index + resolvedBegin, notSetValue) - : notSetValue; - }; + function get(collection, key, notSetValue) { + return isImmutable(collection) + ? collection.get(key, notSetValue) + : !has(collection, key) + ? notSetValue + : typeof collection.get === 'function' + ? collection.get(key) + : collection[key]; } - sliceSeq.__iterateUncached = function (fn, reverse) { - var this$1$1 = this; + function shallowCopy(from) { + if (Array.isArray(from)) { + return arrCopy(from); + } + var to = {}; + for (var key in from) { + if (hasOwnProperty.call(from, key)) { + to[key] = from[key]; + } + } + return to; + } - if (sliceSize === 0) { - return 0; - } - if (reverse) { - return this.cacheResult().__iterate(fn, reverse); + function remove(collection, key) { + if (!isDataStructure(collection)) { + throw new TypeError( + 'Cannot update non-data-structure value: ' + collection + ); } - var skipped = 0; - var isSkipping = true; - var iterations = 0; - collection.__iterate(function (v, k) { - if (!(isSkipping && (isSkipping = skipped++ < resolvedBegin))) { - iterations++; - return ( - fn(v, useKeys ? k : iterations - 1, this$1$1) !== false && - iterations !== sliceSize + if (isImmutable(collection)) { + if (!collection.remove) { + throw new TypeError( + 'Cannot update immutable value without .remove() method: ' + collection ); } - }); - return iterations; - }; - - sliceSeq.__iteratorUncached = function (type, reverse) { - if (sliceSize !== 0 && reverse) { - return this.cacheResult().__iterator(type, reverse); + return collection.remove(key); } - // Don't bother instantiating parent iterator if taking 0. - if (sliceSize === 0) { - return new Iterator(iteratorDone); + if (!hasOwnProperty.call(collection, key)) { + return collection; } - var iterator = collection.__iterator(type, reverse); - var skipped = 0; - var iterations = 0; - return new Iterator(function () { - while (skipped++ < resolvedBegin) { - iterator.next(); - } - if (++iterations > sliceSize) { - return iteratorDone(); - } - var step = iterator.next(); - if (useKeys || type === ITERATE_VALUES || step.done) { - return step; - } - if (type === ITERATE_KEYS) { - return iteratorValue(type, iterations - 1, undefined, step); - } - return iteratorValue(type, iterations - 1, step.value[1], step); - }); - }; - - return sliceSeq; - } + var collectionCopy = shallowCopy(collection); + if (Array.isArray(collectionCopy)) { + collectionCopy.splice(key, 1); + } else { + delete collectionCopy[key]; + } + return collectionCopy; + } - function takeWhileFactory(collection, predicate, context) { - var takeSequence = makeSequence(collection); - takeSequence.__iterateUncached = function (fn, reverse) { - var this$1$1 = this; + function set(collection, key, value) { + if (!isDataStructure(collection)) { + throw new TypeError( + 'Cannot update non-data-structure value: ' + collection + ); + } + if (isImmutable(collection)) { + if (!collection.set) { + throw new TypeError( + 'Cannot update immutable value without .set() method: ' + collection + ); + } + return collection.set(key, value); + } + if (hasOwnProperty.call(collection, key) && value === collection[key]) { + return collection; + } + var collectionCopy = shallowCopy(collection); + collectionCopy[key] = value; + return collectionCopy; + } - if (reverse) { - return this.cacheResult().__iterate(fn, reverse); + function updateIn$1(collection, keyPath, notSetValue, updater) { + if (!updater) { + updater = notSetValue; + notSetValue = undefined; } - var iterations = 0; - collection.__iterate( - function (v, k, c) { return predicate.call(context, v, k, c) && ++iterations && fn(v, k, this$1$1); } + var updatedValue = updateInDeeply( + isImmutable(collection), + collection, + coerceKeyPath(keyPath), + 0, + notSetValue, + updater ); - return iterations; - }; - takeSequence.__iteratorUncached = function (type, reverse) { - var this$1$1 = this; + return updatedValue === NOT_SET ? notSetValue : updatedValue; + } - if (reverse) { - return this.cacheResult().__iterator(type, reverse); + function updateInDeeply( + inImmutable, + existing, + keyPath, + i, + notSetValue, + updater + ) { + var wasNotSet = existing === NOT_SET; + if (i === keyPath.length) { + var existingValue = wasNotSet ? notSetValue : existing; + var newValue = updater(existingValue); + return newValue === existingValue ? existing : newValue; } - var iterator = collection.__iterator(ITERATE_ENTRIES, reverse); - var iterating = true; - return new Iterator(function () { - if (!iterating) { - return iteratorDone(); - } - var step = iterator.next(); - if (step.done) { - return step; - } - var entry = step.value; - var k = entry[0]; - var v = entry[1]; - if (!predicate.call(context, v, k, this$1$1)) { - iterating = false; - return iteratorDone(); - } - return type === ITERATE_ENTRIES ? step : iteratorValue(type, k, v, step); - }); - }; - return takeSequence; - } + if (!wasNotSet && !isDataStructure(existing)) { + throw new TypeError( + 'Cannot update within non-data-structure value in path [' + + keyPath.slice(0, i).map(quoteString) + + ']: ' + + existing + ); + } + var key = keyPath[i]; + var nextExisting = wasNotSet ? NOT_SET : get(existing, key, NOT_SET); + var nextUpdated = updateInDeeply( + nextExisting === NOT_SET ? inImmutable : isImmutable(nextExisting), + nextExisting, + keyPath, + i + 1, + notSetValue, + updater + ); + return nextUpdated === nextExisting + ? existing + : nextUpdated === NOT_SET + ? remove(existing, key) + : set( + wasNotSet ? (inImmutable ? emptyMap() : {}) : existing, + key, + nextUpdated + ); + } - function skipWhileFactory(collection, predicate, context, useKeys) { - var skipSequence = makeSequence(collection); - skipSequence.__iterateUncached = function (fn, reverse) { - var this$1$1 = this; + function setIn$1(collection, keyPath, value) { + return updateIn$1(collection, keyPath, NOT_SET, function () { return value; }); + } - if (reverse) { - return this.cacheResult().__iterate(fn, reverse); - } - var isSkipping = true; - var iterations = 0; - collection.__iterate(function (v, k, c) { - if (!(isSkipping && (isSkipping = predicate.call(context, v, k, c)))) { - iterations++; - return fn(v, useKeys ? k : iterations - 1, this$1$1); - } - }); - return iterations; - }; - skipSequence.__iteratorUncached = function (type, reverse) { - var this$1$1 = this; + function setIn(keyPath, v) { + return setIn$1(this, keyPath, v); + } - if (reverse) { - return this.cacheResult().__iterator(type, reverse); - } - var iterator = collection.__iterator(ITERATE_ENTRIES, reverse); - var skipping = true; - var iterations = 0; - return new Iterator(function () { - var step; - var k; - var v; - do { - step = iterator.next(); - if (step.done) { - if (useKeys || type === ITERATE_VALUES) { - return step; - } - if (type === ITERATE_KEYS) { - return iteratorValue(type, iterations++, undefined, step); - } - return iteratorValue(type, iterations++, step.value[1], step); - } - var entry = step.value; - k = entry[0]; - v = entry[1]; - // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here - skipping && (skipping = predicate.call(context, v, k, this$1$1)); - } while (skipping); - return type === ITERATE_ENTRIES ? step : iteratorValue(type, k, v, step); - }); - }; - return skipSequence; - } + function removeIn(collection, keyPath) { + return updateIn$1(collection, keyPath, function () { return NOT_SET; }); + } - var ConcatSeq = /*@__PURE__*/(function (Seq) { - function ConcatSeq(iterables) { - this._wrappedIterables = iterables.flatMap(function (iterable) { - if (iterable._wrappedIterables) { - return iterable._wrappedIterables; - } - return [iterable]; - }); - this.size = this._wrappedIterables.reduce(function (sum, iterable) { - if (sum !== undefined) { - var size = iterable.size; - if (size !== undefined) { - return sum + size; - } - } - }, 0); - this[IS_KEYED_SYMBOL] = this._wrappedIterables[0][IS_KEYED_SYMBOL]; - this[IS_INDEXED_SYMBOL] = this._wrappedIterables[0][IS_INDEXED_SYMBOL]; - this[IS_ORDERED_SYMBOL] = this._wrappedIterables[0][IS_ORDERED_SYMBOL]; + function deleteIn(keyPath) { + return removeIn(this, keyPath); } - if ( Seq ) ConcatSeq.__proto__ = Seq; - ConcatSeq.prototype = Object.create( Seq && Seq.prototype ); - ConcatSeq.prototype.constructor = ConcatSeq; + function update$1(collection, key, notSetValue, updater) { + return updateIn$1(collection, [key], notSetValue, updater); + } - ConcatSeq.prototype.__iterateUncached = function __iterateUncached (fn, reverse) { - if (this._wrappedIterables.length === 0) { - return; - } + function update(key, notSetValue, updater) { + return arguments.length === 1 + ? key(this) + : update$1(this, key, notSetValue, updater); + } - if (reverse) { - return this.cacheResult().__iterate(fn, reverse); - } + function updateIn(keyPath, notSetValue, updater) { + return updateIn$1(this, keyPath, notSetValue, updater); + } - var iterableIndex = 0; - var useKeys = isKeyed(this); - var iteratorType = useKeys ? ITERATE_ENTRIES : ITERATE_VALUES; - var currentIterator = this._wrappedIterables[iterableIndex].__iterator( - iteratorType, - reverse - ); + function merge$1() { + var iters = [], len = arguments.length; + while ( len-- ) iters[ len ] = arguments[ len ]; - var keepGoing = true; - var index = 0; - while (keepGoing) { - var next = currentIterator.next(); - while (next.done) { - iterableIndex++; - if (iterableIndex === this._wrappedIterables.length) { - return index; - } - currentIterator = this._wrappedIterables[iterableIndex].__iterator( - iteratorType, - reverse - ); - next = currentIterator.next(); - } - var fnResult = useKeys - ? fn(next.value[1], next.value[0], this) - : fn(next.value, index, this); - keepGoing = fnResult !== false; - index++; - } - return index; - }; + return mergeIntoKeyedWith(this, iters); + } - ConcatSeq.prototype.__iteratorUncached = function __iteratorUncached (type, reverse) { - var this$1$1 = this; + function mergeWith$1(merger) { + var iters = [], len = arguments.length - 1; + while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; - if (this._wrappedIterables.length === 0) { - return new Iterator(iteratorDone); + if (typeof merger !== 'function') { + throw new TypeError('Invalid merger function: ' + merger); } + return mergeIntoKeyedWith(this, iters, merger); + } - if (reverse) { - return this.cacheResult().__iterator(type, reverse); + function mergeIntoKeyedWith(collection, collections, merger) { + var iters = []; + for (var ii = 0; ii < collections.length; ii++) { + var collection$1 = KeyedCollection(collections[ii]); + if (collection$1.size !== 0) { + iters.push(collection$1); + } } - - var iterableIndex = 0; - var currentIterator = this._wrappedIterables[iterableIndex].__iterator( - type, - reverse - ); - return new Iterator(function () { - var next = currentIterator.next(); - while (next.done) { - iterableIndex++; - if (iterableIndex === this$1$1._wrappedIterables.length) { - return next; - } - currentIterator = this$1$1._wrappedIterables[iterableIndex].__iterator( - type, - reverse - ); - next = currentIterator.next(); + if (iters.length === 0) { + return collection; + } + if ( + collection.toSeq().size === 0 && + !collection.__ownerID && + iters.length === 1 + ) { + return collection.constructor(iters[0]); + } + return collection.withMutations(function (collection) { + var mergeIntoCollection = merger + ? function (value, key) { + update$1(collection, key, NOT_SET, function (oldVal) { return oldVal === NOT_SET ? value : merger(oldVal, value, key); } + ); + } + : function (value, key) { + collection.set(key, value); + }; + for (var ii = 0; ii < iters.length; ii++) { + iters[ii].forEach(mergeIntoCollection); } - return next; }); - }; + } - return ConcatSeq; - }(Seq)); - - function concatFactory(collection, values) { - var isKeyedCollection = isKeyed(collection); - var iters = [collection] - .concat(values) - .map(function (v) { - if (!isCollection(v)) { - v = isKeyedCollection - ? keyedSeqFromValue(v) - : indexedSeqFromValue(Array.isArray(v) ? v : [v]); - } else if (isKeyedCollection) { - v = KeyedCollection(v); - } - return v; - }) - .filter(function (v) { return v.size !== 0; }); - - if (iters.length === 0) { - return collection; + function merge(collection) { + var sources = [], len = arguments.length - 1; + while ( len-- > 0 ) sources[ len ] = arguments[ len + 1 ]; + + return mergeWithSources(collection, sources); } - if (iters.length === 1) { - var singleton = iters[0]; - if ( - singleton === collection || - (isKeyedCollection && isKeyed(singleton)) || - (isIndexed(collection) && isIndexed(singleton)) - ) { - return singleton; - } + function mergeWith(merger, collection) { + var sources = [], len = arguments.length - 2; + while ( len-- > 0 ) sources[ len ] = arguments[ len + 2 ]; + + return mergeWithSources(collection, sources, merger); + } + + function mergeDeep$1(collection) { + var sources = [], len = arguments.length - 1; + while ( len-- > 0 ) sources[ len ] = arguments[ len + 1 ]; + + return mergeDeepWithSources(collection, sources); + } + + function mergeDeepWith$1(merger, collection) { + var sources = [], len = arguments.length - 2; + while ( len-- > 0 ) sources[ len ] = arguments[ len + 2 ]; + + return mergeDeepWithSources(collection, sources, merger); } - return new ConcatSeq(iters); - } + function mergeDeepWithSources(collection, sources, merger) { + return mergeWithSources(collection, sources, deepMergerWith(merger)); + } - function flattenFactory(collection, depth, useKeys) { - var flatSequence = makeSequence(collection); - flatSequence.__iterateUncached = function (fn, reverse) { - if (reverse) { - return this.cacheResult().__iterate(fn, reverse); + function mergeWithSources(collection, sources, merger) { + if (!isDataStructure(collection)) { + throw new TypeError( + 'Cannot merge into non-data-structure value: ' + collection + ); } - var iterations = 0; - var stopped = false; - function flatDeep(iter, currentDepth) { - iter.__iterate(function (v, k) { - if ((!depth || currentDepth < depth) && isCollection(v)) { - flatDeep(v, currentDepth + 1); - } else { - iterations++; - if (fn(v, useKeys ? k : iterations - 1, flatSequence) === false) { - stopped = true; + if (isImmutable(collection)) { + return typeof merger === 'function' && collection.mergeWith + ? collection.mergeWith.apply(collection, [ merger ].concat( sources )) + : collection.merge + ? collection.merge.apply(collection, sources) + : collection.concat.apply(collection, sources); + } + var isArray = Array.isArray(collection); + var merged = collection; + var Collection = isArray ? IndexedCollection : KeyedCollection; + var mergeItem = isArray + ? function (value) { + // Copy on write + if (merged === collection) { + merged = shallowCopy(merged); } + merged.push(value); } - return !stopped; - }, reverse); - } - flatDeep(collection, 0); - return iterations; - }; - flatSequence.__iteratorUncached = function (type, reverse) { - if (reverse) { - return this.cacheResult().__iterator(type, reverse); - } - var iterator = collection.__iterator(type, reverse); - var stack = []; - var iterations = 0; - return new Iterator(function () { - while (iterator) { - var step = iterator.next(); - if (step.done !== false) { - iterator = stack.pop(); - continue; - } - var v = step.value; - if (type === ITERATE_ENTRIES) { - v = v[1]; - } - if ((!depth || stack.length < depth) && isCollection(v)) { - stack.push(iterator); - iterator = v.__iterator(type, reverse); - } else { - return useKeys ? step : iteratorValue(type, iterations++, v, step); - } - } - return iteratorDone(); - }); - }; - return flatSequence; - } - - function flatMapFactory(collection, mapper, context) { - var coerce = collectionClass(collection); - return collection - .toSeq() - .map(function (v, k) { return coerce(mapper.call(context, v, k, collection)); }) - .flatten(true); - } - - function interposeFactory(collection, separator) { - var interposedSequence = makeSequence(collection); - interposedSequence.size = collection.size && collection.size * 2 - 1; - interposedSequence.__iterateUncached = function (fn, reverse) { - var this$1$1 = this; - - var iterations = 0; - collection.__iterate( - function (v) { return (!iterations || fn(separator, iterations++, this$1$1) !== false) && - fn(v, iterations++, this$1$1) !== false; }, - reverse - ); - return iterations; - }; - interposedSequence.__iteratorUncached = function (type, reverse) { - var iterator = collection.__iterator(ITERATE_VALUES, reverse); - var iterations = 0; - var step; - return new Iterator(function () { - if (!step || iterations % 2) { - step = iterator.next(); - if (step.done) { - return step; - } - } - return iterations % 2 - ? iteratorValue(type, iterations++, separator) - : iteratorValue(type, iterations++, step.value, step); - }); - }; - return interposedSequence; - } - - function sortFactory(collection, comparator, mapper) { - if (!comparator) { - comparator = defaultComparator; - } - var isKeyedCollection = isKeyed(collection); - var index = 0; - var entries = collection - .toSeq() - .map(function (v, k) { return [k, v, index++, mapper ? mapper(v, k, collection) : v]; }) - .valueSeq() - .toArray(); - entries - .sort(function (a, b) { return comparator(a[3], b[3]) || a[2] - b[2]; }) - .forEach( - isKeyedCollection - ? function (v, i) { - entries[i].length = 2; - } - : function (v, i) { - entries[i] = v[1]; + : function (value, key) { + var hasVal = hasOwnProperty.call(merged, key); + var nextVal = + hasVal && merger ? merger(merged[key], value, key) : value; + if (!hasVal || nextVal !== merged[key]) { + // Copy on write + if (merged === collection) { + merged = shallowCopy(merged); + } + merged[key] = nextVal; } + }; + for (var i = 0; i < sources.length; i++) { + Collection(sources[i]).forEach(mergeItem); + } + return merged; + } + + function deepMergerWith(merger) { + function deepMerger(oldValue, newValue, key) { + return isDataStructure(oldValue) && + isDataStructure(newValue) && + areMergeable(oldValue, newValue) + ? mergeWithSources(oldValue, [newValue], deepMerger) + : merger + ? merger(oldValue, newValue, key) + : newValue; + } + return deepMerger; + } + + /** + * It's unclear what the desired behavior is for merging two collections that + * fall into separate categories between keyed, indexed, or set-like, so we only + * consider them mergeable if they fall into the same category. + */ + function areMergeable(oldDataStructure, newDataStructure) { + var oldSeq = Seq(oldDataStructure); + var newSeq = Seq(newDataStructure); + // This logic assumes that a sequence can only fall into one of the three + // categories mentioned above (since there's no `isSetLike()` method). + return ( + isIndexed(oldSeq) === isIndexed(newSeq) && + isKeyed(oldSeq) === isKeyed(newSeq) ); - return isKeyedCollection - ? KeyedSeq(entries) - : isIndexed(collection) - ? IndexedSeq(entries) - : SetSeq(entries); - } - - function maxFactory(collection, comparator, mapper) { - if (!comparator) { - comparator = defaultComparator; - } - if (mapper) { - var entry = collection - .toSeq() - .map(function (v, k) { return [v, mapper(v, k, collection)]; }) - .reduce(function (a, b) { return (maxCompare(comparator, a[1], b[1]) ? b : a); }); - return entry && entry[0]; - } - return collection.reduce(function (a, b) { return (maxCompare(comparator, a, b) ? b : a); }); - } - - function maxCompare(comparator, a, b) { - var comp = comparator(b, a); - // b is considered the new max if the comparator declares them equal, but - // they are not equal and b is in fact a nullish value. - return ( - (comp === 0 && b !== a && (b === undefined || b === null || b !== b)) || - comp > 0 - ); - } - - function zipWithFactory(keyIter, zipper, iters, zipAll) { - var zipSequence = makeSequence(keyIter); - var sizes = new ArraySeq(iters).map(function (i) { return i.size; }); - zipSequence.size = zipAll ? sizes.max() : sizes.min(); - // Note: this a generic base implementation of __iterate in terms of - // __iterator which may be more generically useful in the future. - zipSequence.__iterate = function (fn, reverse) { - /* generic: - var iterator = this.__iterator(ITERATE_ENTRIES, reverse); - var step; - var iterations = 0; - while (!(step = iterator.next()).done) { - iterations++; - if (fn(step.value[1], step.value[0], this) === false) { - break; - } - } - return iterations; - */ - // indexed: - var iterator = this.__iterator(ITERATE_VALUES, reverse); - var step; - var iterations = 0; - while (!(step = iterator.next()).done) { - if (fn(step.value, iterations++, this) === false) { - break; - } - } - return iterations; - }; - zipSequence.__iteratorUncached = function (type, reverse) { - var iterators = iters.map( - function (i) { return ((i = Collection(i)), getIterator(reverse ? i.reverse() : i)); } - ); - var iterations = 0; - var isDone = false; - return new Iterator(function () { - var steps; - if (!isDone) { - steps = iterators.map(function (i) { return i.next(); }); - isDone = zipAll - ? steps.every(function (s) { return s.done; }) - : steps.some(function (s) { return s.done; }); - } - if (isDone) { - return iteratorDone(); - } - return iteratorValue( - type, - iterations++, - zipper.apply( - null, - steps.map(function (s) { return s.value; }) - ) - ); - }); - }; - return zipSequence; - } + } + + function mergeDeep() { + var iters = [], len = arguments.length; + while ( len-- ) iters[ len ] = arguments[ len ]; - // #pragma Helper Functions + return mergeDeepWithSources(this, iters); + } - function reify(iter, seq) { - return iter === seq ? iter : isSeq(iter) ? seq : iter.constructor(seq); - } + function mergeDeepWith(merger) { + var iters = [], len = arguments.length - 1; + while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; - function validateEntry(entry) { - if (entry !== Object(entry)) { - throw new TypeError('Expected [K, V] tuple: ' + entry); + return mergeDeepWithSources(this, iters, merger); } - } - function collectionClass(collection) { - return isKeyed(collection) - ? KeyedCollection - : isIndexed(collection) - ? IndexedCollection - : SetCollection; - } + function mergeIn(keyPath) { + var iters = [], len = arguments.length - 1; + while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; - function makeSequence(collection) { - return Object.create( - (isKeyed(collection) - ? KeyedSeq - : isIndexed(collection) - ? IndexedSeq - : SetSeq - ).prototype - ); - } - - function cacheResultThrough() { - if (this._iter.cacheResult) { - this._iter.cacheResult(); - this.size = this._iter.size; - return this; + return updateIn$1(this, keyPath, emptyMap(), function (m) { return mergeWithSources(m, iters); }); + } + + function mergeDeepIn(keyPath) { + var iters = [], len = arguments.length - 1; + while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; + + return updateIn$1(this, keyPath, emptyMap(), function (m) { return mergeDeepWithSources(m, iters); } + ); } - return Seq.prototype.cacheResult.call(this); - } - function defaultComparator(a, b) { - if (a === undefined && b === undefined) { - return 0; + function withMutations(fn) { + var mutable = this.asMutable(); + fn(mutable); + return mutable.wasAltered() ? mutable.__ensureOwner(this.__ownerID) : this; } - if (a === undefined) { - return 1; + function asMutable() { + return this.__ownerID ? this : this.__ensureOwner(new OwnerID()); } - if (b === undefined) { - return -1; + function asImmutable() { + return this.__ensureOwner(); } - return a > b ? 1 : a < b ? -1 : 0; - } + function wasAltered() { + return this.__altered; + } + + var Map = /*@__PURE__*/(function (KeyedCollection) { + function Map(value) { + // eslint-disable-next-line no-constructor-return + return value === undefined || value === null + ? emptyMap() + : isMap(value) && !isOrdered(value) + ? value + : emptyMap().withMutations(function (map) { + var iter = KeyedCollection(value); + assertNotInfinite(iter.size); + iter.forEach(function (v, k) { return map.set(k, v); }); + }); + } + + if ( KeyedCollection ) Map.__proto__ = KeyedCollection; + Map.prototype = Object.create( KeyedCollection && KeyedCollection.prototype ); + Map.prototype.constructor = Map; + + Map.prototype.toString = function toString () { + return this.__toString('Map {', '}'); + }; + + // @pragma Access + + Map.prototype.get = function get (k, notSetValue) { + return this._root + ? this._root.get(0, undefined, k, notSetValue) + : notSetValue; + }; + + // @pragma Modification + + Map.prototype.set = function set (k, v) { + return updateMap(this, k, v); + }; + + Map.prototype.remove = function remove (k) { + return updateMap(this, k, NOT_SET); + }; + + Map.prototype.deleteAll = function deleteAll (keys) { + var collection = Collection(keys); + + if (collection.size === 0) { + return this; + } + + return this.withMutations(function (map) { + collection.forEach(function (key) { return map.remove(key); }); + }); + }; + + Map.prototype.clear = function clear () { + if (this.size === 0) { + return this; + } + if (this.__ownerID) { + this.size = 0; + this._root = null; + this.__hash = undefined; + this.__altered = true; + return this; + } + return emptyMap(); + }; + + // @pragma Composition + + Map.prototype.sort = function sort (comparator) { + // Late binding + return OrderedMap(sortFactory(this, comparator)); + }; + + Map.prototype.sortBy = function sortBy (mapper, comparator) { + // Late binding + return OrderedMap(sortFactory(this, comparator, mapper)); + }; + + Map.prototype.map = function map (mapper, context) { + var this$1$1 = this; + + return this.withMutations(function (map) { + map.forEach(function (value, key) { + map.set(key, mapper.call(context, value, key, this$1$1)); + }); + }); + }; + + // @pragma Mutability + + Map.prototype.__iterator = function __iterator (type, reverse) { + return new MapIterator(this, type, reverse); + }; + + Map.prototype.__iterate = function __iterate (fn, reverse) { + var this$1$1 = this; + + var iterations = 0; + // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here + this._root && + this._root.iterate(function (entry) { + iterations++; + return fn(entry[1], entry[0], this$1$1); + }, reverse); + return iterations; + }; - // http://jsperf.com/copy-array-inline - function arrCopy(arr, offset) { - offset = offset || 0; - var len = Math.max(0, arr.length - offset); - var newArr = new Array(len); - for (var ii = 0; ii < len; ii++) { - newArr[ii] = arr[ii + offset]; - } - return newArr; - } + Map.prototype.__ensureOwner = function __ensureOwner (ownerID) { + if (ownerID === this.__ownerID) { + return this; + } + if (!ownerID) { + if (this.size === 0) { + return emptyMap(); + } + this.__ownerID = ownerID; + this.__altered = false; + return this; + } + return makeMap(this.size, this._root, ownerID, this.__hash); + }; - function invariant(condition, error) { - if (!condition) { throw new Error(error); } - } + return Map; + }(KeyedCollection)); - function assertNotInfinite(size) { - invariant( - size !== Infinity, - 'Cannot perform this action with an infinite size.' - ); - } + Map.isMap = isMap; - function coerceKeyPath(keyPath) { - if (isArrayLike(keyPath) && typeof keyPath !== 'string') { - return keyPath; - } - if (isOrdered(keyPath)) { - return keyPath.toArray(); - } - throw new TypeError( - 'Invalid keyPath: expected Ordered Collection or Array: ' + keyPath - ); - } + var MapPrototype = Map.prototype; + MapPrototype[IS_MAP_SYMBOL] = true; + MapPrototype[DELETE] = MapPrototype.remove; + MapPrototype.removeAll = MapPrototype.deleteAll; + MapPrototype.setIn = setIn; + MapPrototype.removeIn = MapPrototype.deleteIn = deleteIn; + MapPrototype.update = update; + MapPrototype.updateIn = updateIn; + MapPrototype.merge = MapPrototype.concat = merge$1; + MapPrototype.mergeWith = mergeWith$1; + MapPrototype.mergeDeep = mergeDeep; + MapPrototype.mergeDeepWith = mergeDeepWith; + MapPrototype.mergeIn = mergeIn; + MapPrototype.mergeDeepIn = mergeDeepIn; + MapPrototype.withMutations = withMutations; + MapPrototype.wasAltered = wasAltered; + MapPrototype.asImmutable = asImmutable; + MapPrototype['@@transducer/init'] = MapPrototype.asMutable = asMutable; + MapPrototype['@@transducer/step'] = function (result, arr) { + return result.set(arr[0], arr[1]); + }; + MapPrototype['@@transducer/result'] = function (obj) { + return obj.asImmutable(); + }; - var toString = Object.prototype.toString; + // #pragma Trie Nodes - function isPlainObject(value) { - // The base prototype's toString deals with Argument objects and native namespaces like Math - if ( - !value || - typeof value !== 'object' || - toString.call(value) !== '[object Object]' - ) { - return false; - } - - var proto = Object.getPrototypeOf(value); - if (proto === null) { - return true; - } - - // Iteratively going up the prototype chain is needed for cross-realm environments (differing contexts, iframes, etc) - var parentProto = proto; - var nextProto = Object.getPrototypeOf(proto); - while (nextProto !== null) { - parentProto = nextProto; - nextProto = Object.getPrototypeOf(parentProto); - } - return parentProto === proto; - } - - /** - * Returns true if the value is a potentially-persistent data structure, either - * provided by Immutable.js or a plain Array or Object. - */ - function isDataStructure(value) { - return ( - typeof value === 'object' && - (isImmutable(value) || Array.isArray(value) || isPlainObject(value)) - ); - } - - /** - * Converts a value to a string, adding quotes if a string was provided. - */ - function quoteString(value) { - try { - return typeof value === 'string' ? JSON.stringify(value) : String(value); - // eslint-disable-next-line @typescript-eslint/no-unused-vars - } catch (_ignoreError) { - return JSON.stringify(value); - } - } - - function has(collection, key) { - return isImmutable(collection) - ? collection.has(key) - : isDataStructure(collection) && hasOwnProperty.call(collection, key); - } - - function get(collection, key, notSetValue) { - return isImmutable(collection) - ? collection.get(key, notSetValue) - : !has(collection, key) - ? notSetValue - : typeof collection.get === 'function' - ? collection.get(key) - : collection[key]; - } + var ArrayMapNode = function ArrayMapNode(ownerID, entries) { + this.ownerID = ownerID; + this.entries = entries; + }; - function shallowCopy(from) { - if (Array.isArray(from)) { - return arrCopy(from); - } - var to = {}; - for (var key in from) { - if (hasOwnProperty.call(from, key)) { - to[key] = from[key]; + ArrayMapNode.prototype.get = function get (shift, keyHash, key, notSetValue) { + var entries = this.entries; + for (var ii = 0, len = entries.length; ii < len; ii++) { + if (is(key, entries[ii][0])) { + return entries[ii][1]; + } } - } - return to; - } + return notSetValue; + }; - function remove(collection, key) { - if (!isDataStructure(collection)) { - throw new TypeError( - 'Cannot update non-data-structure value: ' + collection - ); - } - if (isImmutable(collection)) { - if (!collection.remove) { - throw new TypeError( - 'Cannot update immutable value without .remove() method: ' + collection - ); - } - return collection.remove(key); - } - if (!hasOwnProperty.call(collection, key)) { - return collection; - } - var collectionCopy = shallowCopy(collection); - if (Array.isArray(collectionCopy)) { - collectionCopy.splice(key, 1); - } else { - delete collectionCopy[key]; - } - return collectionCopy; - } + ArrayMapNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { + var removed = value === NOT_SET; - function set(collection, key, value) { - if (!isDataStructure(collection)) { - throw new TypeError( - 'Cannot update non-data-structure value: ' + collection - ); - } - if (isImmutable(collection)) { - if (!collection.set) { - throw new TypeError( - 'Cannot update immutable value without .set() method: ' + collection - ); + var entries = this.entries; + var idx = 0; + var len = entries.length; + for (; idx < len; idx++) { + if (is(key, entries[idx][0])) { + break; + } } - return collection.set(key, value); - } - if (hasOwnProperty.call(collection, key) && value === collection[key]) { - return collection; - } - var collectionCopy = shallowCopy(collection); - collectionCopy[key] = value; - return collectionCopy; - } - - function updateIn$1(collection, keyPath, notSetValue, updater) { - if (!updater) { - updater = notSetValue; - notSetValue = undefined; - } - var updatedValue = updateInDeeply( - isImmutable(collection), - collection, - coerceKeyPath(keyPath), - 0, - notSetValue, - updater - ); - return updatedValue === NOT_SET ? notSetValue : updatedValue; - } - - function updateInDeeply( - inImmutable, - existing, - keyPath, - i, - notSetValue, - updater - ) { - var wasNotSet = existing === NOT_SET; - if (i === keyPath.length) { - var existingValue = wasNotSet ? notSetValue : existing; - var newValue = updater(existingValue); - return newValue === existingValue ? existing : newValue; - } - if (!wasNotSet && !isDataStructure(existing)) { - throw new TypeError( - 'Cannot update within non-data-structure value in path [' + - keyPath.slice(0, i).map(quoteString) + - ']: ' + - existing - ); - } - var key = keyPath[i]; - var nextExisting = wasNotSet ? NOT_SET : get(existing, key, NOT_SET); - var nextUpdated = updateInDeeply( - nextExisting === NOT_SET ? inImmutable : isImmutable(nextExisting), - nextExisting, - keyPath, - i + 1, - notSetValue, - updater - ); - return nextUpdated === nextExisting - ? existing - : nextUpdated === NOT_SET - ? remove(existing, key) - : set( - wasNotSet ? (inImmutable ? emptyMap() : {}) : existing, - key, - nextUpdated - ); - } - - function setIn$1(collection, keyPath, value) { - return updateIn$1(collection, keyPath, NOT_SET, function () { return value; }); - } - - function setIn(keyPath, v) { - return setIn$1(this, keyPath, v); - } + var exists = idx < len; - function removeIn(collection, keyPath) { - return updateIn$1(collection, keyPath, function () { return NOT_SET; }); - } + if (exists ? entries[idx][1] === value : removed) { + return this; + } - function deleteIn(keyPath) { - return removeIn(this, keyPath); - } + SetRef(didAlter); + // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here + (removed || !exists) && SetRef(didChangeSize); - function update$1(collection, key, notSetValue, updater) { - return updateIn$1(collection, [key], notSetValue, updater); - } + if (removed && entries.length === 1) { + return; // undefined + } - function update(key, notSetValue, updater) { - return arguments.length === 1 - ? key(this) - : update$1(this, key, notSetValue, updater); - } + if (!exists && !removed && entries.length >= MAX_ARRAY_MAP_SIZE) { + return createNodes(ownerID, entries, key, value); + } - function updateIn(keyPath, notSetValue, updater) { - return updateIn$1(this, keyPath, notSetValue, updater); - } + var isEditable = ownerID && ownerID === this.ownerID; + var newEntries = isEditable ? entries : arrCopy(entries); - function merge$1() { - var iters = [], len = arguments.length; - while ( len-- ) iters[ len ] = arguments[ len ]; + if (exists) { + if (removed) { + // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here + idx === len - 1 + ? newEntries.pop() + : (newEntries[idx] = newEntries.pop()); + } else { + newEntries[idx] = [key, value]; + } + } else { + newEntries.push([key, value]); + } - return mergeIntoKeyedWith(this, iters); - } + if (isEditable) { + this.entries = newEntries; + return this; + } - function mergeWith$1(merger) { - var iters = [], len = arguments.length - 1; - while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; + return new ArrayMapNode(ownerID, newEntries); + }; - if (typeof merger !== 'function') { - throw new TypeError('Invalid merger function: ' + merger); - } - return mergeIntoKeyedWith(this, iters, merger); - } + var BitmapIndexedNode = function BitmapIndexedNode(ownerID, bitmap, nodes) { + this.ownerID = ownerID; + this.bitmap = bitmap; + this.nodes = nodes; + }; - function mergeIntoKeyedWith(collection, collections, merger) { - var iters = []; - for (var ii = 0; ii < collections.length; ii++) { - var collection$1 = KeyedCollection(collections[ii]); - if (collection$1.size !== 0) { - iters.push(collection$1); - } - } - if (iters.length === 0) { - return collection; - } - if ( - collection.toSeq().size === 0 && - !collection.__ownerID && - iters.length === 1 - ) { - return collection.constructor(iters[0]); - } - return collection.withMutations(function (collection) { - var mergeIntoCollection = merger - ? function (value, key) { - update$1(collection, key, NOT_SET, function (oldVal) { return oldVal === NOT_SET ? value : merger(oldVal, value, key); } - ); - } - : function (value, key) { - collection.set(key, value); - }; - for (var ii = 0; ii < iters.length; ii++) { - iters[ii].forEach(mergeIntoCollection); + BitmapIndexedNode.prototype.get = function get (shift, keyHash, key, notSetValue) { + if (keyHash === undefined) { + keyHash = hash(key); } - }); - } - - function merge(collection) { - var sources = [], len = arguments.length - 1; - while ( len-- > 0 ) sources[ len ] = arguments[ len + 1 ]; - - return mergeWithSources(collection, sources); - } + var bit = 1 << ((shift === 0 ? keyHash : keyHash >>> shift) & MASK); + var bitmap = this.bitmap; + return (bitmap & bit) === 0 + ? notSetValue + : this.nodes[popCount(bitmap & (bit - 1))].get( + shift + SHIFT, + keyHash, + key, + notSetValue + ); + }; - function mergeWith(merger, collection) { - var sources = [], len = arguments.length - 2; - while ( len-- > 0 ) sources[ len ] = arguments[ len + 2 ]; + BitmapIndexedNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { + if (keyHash === undefined) { + keyHash = hash(key); + } + var keyHashFrag = (shift === 0 ? keyHash : keyHash >>> shift) & MASK; + var bit = 1 << keyHashFrag; + var bitmap = this.bitmap; + var exists = (bitmap & bit) !== 0; - return mergeWithSources(collection, sources, merger); - } + if (!exists && value === NOT_SET) { + return this; + } - function mergeDeep$1(collection) { - var sources = [], len = arguments.length - 1; - while ( len-- > 0 ) sources[ len ] = arguments[ len + 1 ]; + var idx = popCount(bitmap & (bit - 1)); + var nodes = this.nodes; + var node = exists ? nodes[idx] : undefined; + var newNode = updateNode( + node, + ownerID, + shift + SHIFT, + keyHash, + key, + value, + didChangeSize, + didAlter + ); - return mergeDeepWithSources(collection, sources); - } + if (newNode === node) { + return this; + } - function mergeDeepWith$1(merger, collection) { - var sources = [], len = arguments.length - 2; - while ( len-- > 0 ) sources[ len ] = arguments[ len + 2 ]; + if (!exists && newNode && nodes.length >= MAX_BITMAP_INDEXED_SIZE) { + return expandNodes(ownerID, nodes, bitmap, keyHashFrag, newNode); + } - return mergeDeepWithSources(collection, sources, merger); - } + if ( + exists && + !newNode && + nodes.length === 2 && + isLeafNode(nodes[idx ^ 1]) + ) { + return nodes[idx ^ 1]; + } - function mergeDeepWithSources(collection, sources, merger) { - return mergeWithSources(collection, sources, deepMergerWith(merger)); - } + if (exists && newNode && nodes.length === 1 && isLeafNode(newNode)) { + return newNode; + } - function mergeWithSources(collection, sources, merger) { - if (!isDataStructure(collection)) { - throw new TypeError( - 'Cannot merge into non-data-structure value: ' + collection - ); - } - if (isImmutable(collection)) { - return typeof merger === 'function' && collection.mergeWith - ? collection.mergeWith.apply(collection, [ merger ].concat( sources )) - : collection.merge - ? collection.merge.apply(collection, sources) - : collection.concat.apply(collection, sources); - } - var isArray = Array.isArray(collection); - var merged = collection; - var Collection = isArray ? IndexedCollection : KeyedCollection; - var mergeItem = isArray - ? function (value) { - // Copy on write - if (merged === collection) { - merged = shallowCopy(merged); - } - merged.push(value); - } - : function (value, key) { - var hasVal = hasOwnProperty.call(merged, key); - var nextVal = - hasVal && merger ? merger(merged[key], value, key) : value; - if (!hasVal || nextVal !== merged[key]) { - // Copy on write - if (merged === collection) { - merged = shallowCopy(merged); - } - merged[key] = nextVal; - } - }; - for (var i = 0; i < sources.length; i++) { - Collection(sources[i]).forEach(mergeItem); - } - return merged; - } - - function deepMergerWith(merger) { - function deepMerger(oldValue, newValue, key) { - return isDataStructure(oldValue) && - isDataStructure(newValue) && - areMergeable(oldValue, newValue) - ? mergeWithSources(oldValue, [newValue], deepMerger) - : merger - ? merger(oldValue, newValue, key) - : newValue; - } - return deepMerger; - } - - /** - * It's unclear what the desired behavior is for merging two collections that - * fall into separate categories between keyed, indexed, or set-like, so we only - * consider them mergeable if they fall into the same category. - */ - function areMergeable(oldDataStructure, newDataStructure) { - var oldSeq = Seq(oldDataStructure); - var newSeq = Seq(newDataStructure); - // This logic assumes that a sequence can only fall into one of the three - // categories mentioned above (since there's no `isSetLike()` method). - return ( - isIndexed(oldSeq) === isIndexed(newSeq) && - isKeyed(oldSeq) === isKeyed(newSeq) - ); - } - - function mergeDeep() { - var iters = [], len = arguments.length; - while ( len-- ) iters[ len ] = arguments[ len ]; - - return mergeDeepWithSources(this, iters); - } - - function mergeDeepWith(merger) { - var iters = [], len = arguments.length - 1; - while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; - - return mergeDeepWithSources(this, iters, merger); - } - - function mergeIn(keyPath) { - var iters = [], len = arguments.length - 1; - while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; - - return updateIn$1(this, keyPath, emptyMap(), function (m) { return mergeWithSources(m, iters); }); - } - - function mergeDeepIn(keyPath) { - var iters = [], len = arguments.length - 1; - while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ]; - - return updateIn$1(this, keyPath, emptyMap(), function (m) { return mergeDeepWithSources(m, iters); } - ); - } - - function withMutations(fn) { - var mutable = this.asMutable(); - fn(mutable); - return mutable.wasAltered() ? mutable.__ensureOwner(this.__ownerID) : this; - } - - function asMutable() { - return this.__ownerID ? this : this.__ensureOwner(new OwnerID()); - } - - function asImmutable() { - return this.__ensureOwner(); - } - - function wasAltered() { - return this.__altered; - } - - var Map = /*@__PURE__*/(function (KeyedCollection) { - function Map(value) { - // eslint-disable-next-line no-constructor-return - return value === undefined || value === null - ? emptyMap() - : isMap(value) && !isOrdered(value) - ? value - : emptyMap().withMutations(function (map) { - var iter = KeyedCollection(value); - assertNotInfinite(iter.size); - iter.forEach(function (v, k) { return map.set(k, v); }); - }); - } - - if ( KeyedCollection ) Map.__proto__ = KeyedCollection; - Map.prototype = Object.create( KeyedCollection && KeyedCollection.prototype ); - Map.prototype.constructor = Map; - - Map.prototype.toString = function toString () { - return this.__toString('Map {', '}'); - }; + var isEditable = ownerID && ownerID === this.ownerID; + var newBitmap = exists ? (newNode ? bitmap : bitmap ^ bit) : bitmap | bit; + var newNodes = exists + ? newNode + ? setAt(nodes, idx, newNode, isEditable) + : spliceOut(nodes, idx, isEditable) + : spliceIn(nodes, idx, newNode, isEditable); - // @pragma Access + if (isEditable) { + this.bitmap = newBitmap; + this.nodes = newNodes; + return this; + } - Map.prototype.get = function get (k, notSetValue) { - return this._root - ? this._root.get(0, undefined, k, notSetValue) - : notSetValue; + return new BitmapIndexedNode(ownerID, newBitmap, newNodes); }; - // @pragma Modification - - Map.prototype.set = function set (k, v) { - return updateMap(this, k, v); + var HashArrayMapNode = function HashArrayMapNode(ownerID, count, nodes) { + this.ownerID = ownerID; + this.count = count; + this.nodes = nodes; }; - Map.prototype.remove = function remove (k) { - return updateMap(this, k, NOT_SET); + HashArrayMapNode.prototype.get = function get (shift, keyHash, key, notSetValue) { + if (keyHash === undefined) { + keyHash = hash(key); + } + var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK; + var node = this.nodes[idx]; + return node + ? node.get(shift + SHIFT, keyHash, key, notSetValue) + : notSetValue; }; - Map.prototype.deleteAll = function deleteAll (keys) { - var collection = Collection(keys); + HashArrayMapNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { + if (keyHash === undefined) { + keyHash = hash(key); + } + var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK; + var removed = value === NOT_SET; + var nodes = this.nodes; + var node = nodes[idx]; - if (collection.size === 0) { + if (removed && !node) { return this; } - return this.withMutations(function (map) { - collection.forEach(function (key) { return map.remove(key); }); - }); - }; - - Map.prototype.clear = function clear () { - if (this.size === 0) { + var newNode = updateNode( + node, + ownerID, + shift + SHIFT, + keyHash, + key, + value, + didChangeSize, + didAlter + ); + if (newNode === node) { return this; } - if (this.__ownerID) { - this.size = 0; - this._root = null; - this.__hash = undefined; - this.__altered = true; + + var newCount = this.count; + if (!node) { + newCount++; + } else if (!newNode) { + newCount--; + if (newCount < MIN_HASH_ARRAY_MAP_SIZE) { + return packNodes(ownerID, nodes, newCount, idx); + } + } + + var isEditable = ownerID && ownerID === this.ownerID; + var newNodes = setAt(nodes, idx, newNode, isEditable); + + if (isEditable) { + this.count = newCount; + this.nodes = newNodes; return this; } - return emptyMap(); - }; - // @pragma Composition + return new HashArrayMapNode(ownerID, newCount, newNodes); + }; - Map.prototype.sort = function sort (comparator) { - // Late binding - return OrderedMap(sortFactory(this, comparator)); + var HashCollisionNode = function HashCollisionNode(ownerID, keyHash, entries) { + this.ownerID = ownerID; + this.keyHash = keyHash; + this.entries = entries; }; - Map.prototype.sortBy = function sortBy (mapper, comparator) { - // Late binding - return OrderedMap(sortFactory(this, comparator, mapper)); + HashCollisionNode.prototype.get = function get (shift, keyHash, key, notSetValue) { + var entries = this.entries; + for (var ii = 0, len = entries.length; ii < len; ii++) { + if (is(key, entries[ii][0])) { + return entries[ii][1]; + } + } + return notSetValue; }; - Map.prototype.map = function map (mapper, context) { - var this$1$1 = this; + HashCollisionNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { + if (keyHash === undefined) { + keyHash = hash(key); + } - return this.withMutations(function (map) { - map.forEach(function (value, key) { - map.set(key, mapper.call(context, value, key, this$1$1)); - }); - }); - }; + var removed = value === NOT_SET; - // @pragma Mutability + if (keyHash !== this.keyHash) { + if (removed) { + return this; + } + SetRef(didAlter); + SetRef(didChangeSize); + return mergeIntoNode(this, ownerID, shift, keyHash, [key, value]); + } - Map.prototype.__iterator = function __iterator (type, reverse) { - return new MapIterator(this, type, reverse); - }; + var entries = this.entries; + var idx = 0; + var len = entries.length; + for (; idx < len; idx++) { + if (is(key, entries[idx][0])) { + break; + } + } + var exists = idx < len; - Map.prototype.__iterate = function __iterate (fn, reverse) { - var this$1$1 = this; + if (exists ? entries[idx][1] === value : removed) { + return this; + } - var iterations = 0; + SetRef(didAlter); // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here - this._root && - this._root.iterate(function (entry) { - iterations++; - return fn(entry[1], entry[0], this$1$1); - }, reverse); - return iterations; - }; + (removed || !exists) && SetRef(didChangeSize); - Map.prototype.__ensureOwner = function __ensureOwner (ownerID) { - if (ownerID === this.__ownerID) { - return this; + if (removed && len === 2) { + return new ValueNode(ownerID, this.keyHash, entries[idx ^ 1]); } - if (!ownerID) { - if (this.size === 0) { - return emptyMap(); + + var isEditable = ownerID && ownerID === this.ownerID; + var newEntries = isEditable ? entries : arrCopy(entries); + + if (exists) { + if (removed) { + // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here + idx === len - 1 + ? newEntries.pop() + : (newEntries[idx] = newEntries.pop()); + } else { + newEntries[idx] = [key, value]; } - this.__ownerID = ownerID; - this.__altered = false; + } else { + newEntries.push([key, value]); + } + + if (isEditable) { + this.entries = newEntries; return this; } - return makeMap(this.size, this._root, ownerID, this.__hash); - }; - return Map; - }(KeyedCollection)); - - Map.isMap = isMap; - - var MapPrototype = Map.prototype; - MapPrototype[IS_MAP_SYMBOL] = true; - MapPrototype[DELETE] = MapPrototype.remove; - MapPrototype.removeAll = MapPrototype.deleteAll; - MapPrototype.setIn = setIn; - MapPrototype.removeIn = MapPrototype.deleteIn = deleteIn; - MapPrototype.update = update; - MapPrototype.updateIn = updateIn; - MapPrototype.merge = MapPrototype.concat = merge$1; - MapPrototype.mergeWith = mergeWith$1; - MapPrototype.mergeDeep = mergeDeep; - MapPrototype.mergeDeepWith = mergeDeepWith; - MapPrototype.mergeIn = mergeIn; - MapPrototype.mergeDeepIn = mergeDeepIn; - MapPrototype.withMutations = withMutations; - MapPrototype.wasAltered = wasAltered; - MapPrototype.asImmutable = asImmutable; - MapPrototype['@@transducer/init'] = MapPrototype.asMutable = asMutable; - MapPrototype['@@transducer/step'] = function (result, arr) { - return result.set(arr[0], arr[1]); - }; - MapPrototype['@@transducer/result'] = function (obj) { - return obj.asImmutable(); - }; - - // #pragma Trie Nodes - - var ArrayMapNode = function ArrayMapNode(ownerID, entries) { - this.ownerID = ownerID; - this.entries = entries; - }; - - ArrayMapNode.prototype.get = function get (shift, keyHash, key, notSetValue) { - var entries = this.entries; - for (var ii = 0, len = entries.length; ii < len; ii++) { - if (is(key, entries[ii][0])) { - return entries[ii][1]; - } - } - return notSetValue; - }; - - ArrayMapNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { - var removed = value === NOT_SET; - - var entries = this.entries; - var idx = 0; - var len = entries.length; - for (; idx < len; idx++) { - if (is(key, entries[idx][0])) { - break; - } - } - var exists = idx < len; - - if (exists ? entries[idx][1] === value : removed) { - return this; - } + return new HashCollisionNode(ownerID, this.keyHash, newEntries); + }; - SetRef(didAlter); - // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here - (removed || !exists) && SetRef(didChangeSize); + var ValueNode = function ValueNode(ownerID, keyHash, entry) { + this.ownerID = ownerID; + this.keyHash = keyHash; + this.entry = entry; + }; - if (removed && entries.length === 1) { - return; // undefined - } + ValueNode.prototype.get = function get (shift, keyHash, key, notSetValue) { + return is(key, this.entry[0]) ? this.entry[1] : notSetValue; + }; - if (!exists && !removed && entries.length >= MAX_ARRAY_MAP_SIZE) { - return createNodes(ownerID, entries, key, value); - } + ValueNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { + var removed = value === NOT_SET; + var keyMatch = is(key, this.entry[0]); + if (keyMatch ? value === this.entry[1] : removed) { + return this; + } - var isEditable = ownerID && ownerID === this.ownerID; - var newEntries = isEditable ? entries : arrCopy(entries); + SetRef(didAlter); - if (exists) { if (removed) { - // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here - idx === len - 1 - ? newEntries.pop() - : (newEntries[idx] = newEntries.pop()); - } else { - newEntries[idx] = [key, value]; + SetRef(didChangeSize); + return; // undefined } - } else { - newEntries.push([key, value]); - } - if (isEditable) { - this.entries = newEntries; - return this; - } + if (keyMatch) { + if (ownerID && ownerID === this.ownerID) { + this.entry[1] = value; + return this; + } + return new ValueNode(ownerID, this.keyHash, [key, value]); + } - return new ArrayMapNode(ownerID, newEntries); - }; + SetRef(didChangeSize); + return mergeIntoNode(this, ownerID, shift, hash(key), [key, value]); + }; - var BitmapIndexedNode = function BitmapIndexedNode(ownerID, bitmap, nodes) { - this.ownerID = ownerID; - this.bitmap = bitmap; - this.nodes = nodes; - }; + // #pragma Iterators - BitmapIndexedNode.prototype.get = function get (shift, keyHash, key, notSetValue) { - if (keyHash === undefined) { - keyHash = hash(key); - } - var bit = 1 << ((shift === 0 ? keyHash : keyHash >>> shift) & MASK); - var bitmap = this.bitmap; - return (bitmap & bit) === 0 - ? notSetValue - : this.nodes[popCount(bitmap & (bit - 1))].get( - shift + SHIFT, - keyHash, - key, - notSetValue - ); - }; + ArrayMapNode.prototype.iterate = HashCollisionNode.prototype.iterate = + function (fn, reverse) { + var entries = this.entries; + for (var ii = 0, maxIndex = entries.length - 1; ii <= maxIndex; ii++) { + if (fn(entries[reverse ? maxIndex - ii : ii]) === false) { + return false; + } + } + }; - BitmapIndexedNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { - if (keyHash === undefined) { - keyHash = hash(key); - } - var keyHashFrag = (shift === 0 ? keyHash : keyHash >>> shift) & MASK; - var bit = 1 << keyHashFrag; - var bitmap = this.bitmap; - var exists = (bitmap & bit) !== 0; + BitmapIndexedNode.prototype.iterate = HashArrayMapNode.prototype.iterate = + function (fn, reverse) { + var nodes = this.nodes; + for (var ii = 0, maxIndex = nodes.length - 1; ii <= maxIndex; ii++) { + var node = nodes[reverse ? maxIndex - ii : ii]; + if (node && node.iterate(fn, reverse) === false) { + return false; + } + } + }; - if (!exists && value === NOT_SET) { - return this; - } + // eslint-disable-next-line @typescript-eslint/no-unused-vars + ValueNode.prototype.iterate = function (fn, reverse) { + return fn(this.entry); + }; - var idx = popCount(bitmap & (bit - 1)); - var nodes = this.nodes; - var node = exists ? nodes[idx] : undefined; - var newNode = updateNode( - node, - ownerID, - shift + SHIFT, - keyHash, - key, - value, - didChangeSize, - didAlter - ); + var MapIterator = /*@__PURE__*/(function (Iterator) { + function MapIterator(map, type, reverse) { + this._type = type; + this._reverse = reverse; + this._stack = map._root && mapIteratorFrame(map._root); + } - if (newNode === node) { - return this; - } + if ( Iterator ) MapIterator.__proto__ = Iterator; + MapIterator.prototype = Object.create( Iterator && Iterator.prototype ); + MapIterator.prototype.constructor = MapIterator; - if (!exists && newNode && nodes.length >= MAX_BITMAP_INDEXED_SIZE) { - return expandNodes(ownerID, nodes, bitmap, keyHashFrag, newNode); - } + MapIterator.prototype.next = function next () { + var type = this._type; + var stack = this._stack; + while (stack) { + var node = stack.node; + var index = stack.index++; + var maxIndex = (void 0); + if (node.entry) { + if (index === 0) { + return mapIteratorValue(type, node.entry); + } + } else if (node.entries) { + maxIndex = node.entries.length - 1; + if (index <= maxIndex) { + return mapIteratorValue( + type, + node.entries[this._reverse ? maxIndex - index : index] + ); + } + } else { + maxIndex = node.nodes.length - 1; + if (index <= maxIndex) { + var subNode = node.nodes[this._reverse ? maxIndex - index : index]; + if (subNode) { + if (subNode.entry) { + return mapIteratorValue(type, subNode.entry); + } + stack = this._stack = mapIteratorFrame(subNode, stack); + } + continue; + } + } + stack = this._stack = this._stack.__prev; + } + return iteratorDone(); + }; - if ( - exists && - !newNode && - nodes.length === 2 && - isLeafNode(nodes[idx ^ 1]) - ) { - return nodes[idx ^ 1]; - } + return MapIterator; + }(Iterator)); - if (exists && newNode && nodes.length === 1 && isLeafNode(newNode)) { - return newNode; + function mapIteratorValue(type, entry) { + return iteratorValue(type, entry[0], entry[1]); } - var isEditable = ownerID && ownerID === this.ownerID; - var newBitmap = exists ? (newNode ? bitmap : bitmap ^ bit) : bitmap | bit; - var newNodes = exists - ? newNode - ? setAt(nodes, idx, newNode, isEditable) - : spliceOut(nodes, idx, isEditable) - : spliceIn(nodes, idx, newNode, isEditable); - - if (isEditable) { - this.bitmap = newBitmap; - this.nodes = newNodes; - return this; + function mapIteratorFrame(node, prev) { + return { + node: node, + index: 0, + __prev: prev, + }; } - return new BitmapIndexedNode(ownerID, newBitmap, newNodes); - }; - - var HashArrayMapNode = function HashArrayMapNode(ownerID, count, nodes) { - this.ownerID = ownerID; - this.count = count; - this.nodes = nodes; - }; - - HashArrayMapNode.prototype.get = function get (shift, keyHash, key, notSetValue) { - if (keyHash === undefined) { - keyHash = hash(key); + function makeMap(size, root, ownerID, hash) { + var map = Object.create(MapPrototype); + map.size = size; + map._root = root; + map.__ownerID = ownerID; + map.__hash = hash; + map.__altered = false; + return map; } - var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK; - var node = this.nodes[idx]; - return node - ? node.get(shift + SHIFT, keyHash, key, notSetValue) - : notSetValue; - }; - HashArrayMapNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { - if (keyHash === undefined) { - keyHash = hash(key); + var EMPTY_MAP; + function emptyMap() { + return EMPTY_MAP || (EMPTY_MAP = makeMap(0)); } - var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK; - var removed = value === NOT_SET; - var nodes = this.nodes; - var node = nodes[idx]; - if (removed && !node) { - return this; + function updateMap(map, k, v) { + var newRoot; + var newSize; + if (!map._root) { + if (v === NOT_SET) { + return map; + } + newSize = 1; + newRoot = new ArrayMapNode(map.__ownerID, [[k, v]]); + } else { + var didChangeSize = MakeRef(); + var didAlter = MakeRef(); + newRoot = updateNode( + map._root, + map.__ownerID, + 0, + undefined, + k, + v, + didChangeSize, + didAlter + ); + if (!didAlter.value) { + return map; + } + newSize = map.size + (didChangeSize.value ? (v === NOT_SET ? -1 : 1) : 0); + } + if (map.__ownerID) { + map.size = newSize; + map._root = newRoot; + map.__hash = undefined; + map.__altered = true; + return map; + } + return newRoot ? makeMap(newSize, newRoot) : emptyMap(); } - var newNode = updateNode( + function updateNode( node, ownerID, - shift + SHIFT, + shift, keyHash, key, value, didChangeSize, didAlter - ); - if (newNode === node) { - return this; + ) { + if (!node) { + if (value === NOT_SET) { + return node; + } + SetRef(didAlter); + SetRef(didChangeSize); + return new ValueNode(ownerID, keyHash, [key, value]); + } + return node.update( + ownerID, + shift, + keyHash, + key, + value, + didChangeSize, + didAlter + ); } - var newCount = this.count; - if (!node) { - newCount++; - } else if (!newNode) { - newCount--; - if (newCount < MIN_HASH_ARRAY_MAP_SIZE) { - return packNodes(ownerID, nodes, newCount, idx); - } + function isLeafNode(node) { + return ( + node.constructor === ValueNode || node.constructor === HashCollisionNode + ); } - var isEditable = ownerID && ownerID === this.ownerID; - var newNodes = setAt(nodes, idx, newNode, isEditable); - - if (isEditable) { - this.count = newCount; - this.nodes = newNodes; - return this; - } + function mergeIntoNode(node, ownerID, shift, keyHash, entry) { + if (node.keyHash === keyHash) { + return new HashCollisionNode(ownerID, keyHash, [node.entry, entry]); + } - return new HashArrayMapNode(ownerID, newCount, newNodes); - }; + var idx1 = (shift === 0 ? node.keyHash : node.keyHash >>> shift) & MASK; + var idx2 = (shift === 0 ? keyHash : keyHash >>> shift) & MASK; - var HashCollisionNode = function HashCollisionNode(ownerID, keyHash, entries) { - this.ownerID = ownerID; - this.keyHash = keyHash; - this.entries = entries; - }; + var newNode; + var nodes = + idx1 === idx2 + ? [mergeIntoNode(node, ownerID, shift + SHIFT, keyHash, entry)] + : ((newNode = new ValueNode(ownerID, keyHash, entry)), + idx1 < idx2 ? [node, newNode] : [newNode, node]); - HashCollisionNode.prototype.get = function get (shift, keyHash, key, notSetValue) { - var entries = this.entries; - for (var ii = 0, len = entries.length; ii < len; ii++) { - if (is(key, entries[ii][0])) { - return entries[ii][1]; - } + return new BitmapIndexedNode(ownerID, (1 << idx1) | (1 << idx2), nodes); } - return notSetValue; - }; - HashCollisionNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { - if (keyHash === undefined) { - keyHash = hash(key); + function createNodes(ownerID, entries, key, value) { + if (!ownerID) { + ownerID = new OwnerID(); + } + var node = new ValueNode(ownerID, hash(key), [key, value]); + for (var ii = 0; ii < entries.length; ii++) { + var entry = entries[ii]; + node = node.update(ownerID, 0, undefined, entry[0], entry[1]); + } + return node; } - var removed = value === NOT_SET; - - if (keyHash !== this.keyHash) { - if (removed) { - return this; + function packNodes(ownerID, nodes, count, excluding) { + var bitmap = 0; + var packedII = 0; + var packedNodes = new Array(count); + for (var ii = 0, bit = 1, len = nodes.length; ii < len; ii++, bit <<= 1) { + var node = nodes[ii]; + if (node !== undefined && ii !== excluding) { + bitmap |= bit; + packedNodes[packedII++] = node; + } } - SetRef(didAlter); - SetRef(didChangeSize); - return mergeIntoNode(this, ownerID, shift, keyHash, [key, value]); + return new BitmapIndexedNode(ownerID, bitmap, packedNodes); } - var entries = this.entries; - var idx = 0; - var len = entries.length; - for (; idx < len; idx++) { - if (is(key, entries[idx][0])) { - break; + function expandNodes(ownerID, nodes, bitmap, including, node) { + var count = 0; + var expandedNodes = new Array(SIZE); + for (var ii = 0; bitmap !== 0; ii++, bitmap >>>= 1) { + expandedNodes[ii] = bitmap & 1 ? nodes[count++] : undefined; } + expandedNodes[including] = node; + return new HashArrayMapNode(ownerID, count + 1, expandedNodes); } - var exists = idx < len; - if (exists ? entries[idx][1] === value : removed) { - return this; + function popCount(x) { + x -= (x >> 1) & 0x55555555; + x = (x & 0x33333333) + ((x >> 2) & 0x33333333); + x = (x + (x >> 4)) & 0x0f0f0f0f; + x += x >> 8; + x += x >> 16; + return x & 0x7f; } - SetRef(didAlter); - // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here - (removed || !exists) && SetRef(didChangeSize); - - if (removed && len === 2) { - return new ValueNode(ownerID, this.keyHash, entries[idx ^ 1]); + function setAt(array, idx, val, canEdit) { + var newArray = canEdit ? array : arrCopy(array); + newArray[idx] = val; + return newArray; } - var isEditable = ownerID && ownerID === this.ownerID; - var newEntries = isEditable ? entries : arrCopy(entries); - - if (exists) { - if (removed) { - // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here - idx === len - 1 - ? newEntries.pop() - : (newEntries[idx] = newEntries.pop()); - } else { - newEntries[idx] = [key, value]; + function spliceIn(array, idx, val, canEdit) { + var newLen = array.length + 1; + if (canEdit && idx + 1 === newLen) { + array[idx] = val; + return array; + } + var newArray = new Array(newLen); + var after = 0; + for (var ii = 0; ii < newLen; ii++) { + if (ii === idx) { + newArray[ii] = val; + after = -1; + } else { + newArray[ii] = array[ii + after]; + } } - } else { - newEntries.push([key, value]); + return newArray; } - if (isEditable) { - this.entries = newEntries; - return this; + function spliceOut(array, idx, canEdit) { + var newLen = array.length - 1; + if (canEdit && idx === newLen) { + array.pop(); + return array; + } + var newArray = new Array(newLen); + var after = 0; + for (var ii = 0; ii < newLen; ii++) { + if (ii === idx) { + after = 1; + } + newArray[ii] = array[ii + after]; + } + return newArray; } - return new HashCollisionNode(ownerID, this.keyHash, newEntries); - }; - - var ValueNode = function ValueNode(ownerID, keyHash, entry) { - this.ownerID = ownerID; - this.keyHash = keyHash; - this.entry = entry; - }; - - ValueNode.prototype.get = function get (shift, keyHash, key, notSetValue) { - return is(key, this.entry[0]) ? this.entry[1] : notSetValue; - }; + var MAX_ARRAY_MAP_SIZE = SIZE / 4; + var MAX_BITMAP_INDEXED_SIZE = SIZE / 2; + var MIN_HASH_ARRAY_MAP_SIZE = SIZE / 4; - ValueNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) { - var removed = value === NOT_SET; - var keyMatch = is(key, this.entry[0]); - if (keyMatch ? value === this.entry[1] : removed) { - return this; + var IS_LIST_SYMBOL = '@@__IMMUTABLE_LIST__@@'; + /** + * True if `maybeList` is a List. + */ + function isList(maybeList) { + return Boolean(maybeList && + // @ts-expect-error: maybeList is typed as `{}`, need to change in 6.0 to `maybeList && typeof maybeList === 'object' && IS_LIST_SYMBOL in maybeList` + maybeList[IS_LIST_SYMBOL]); } - SetRef(didAlter); + var List = /*@__PURE__*/(function (IndexedCollection) { + function List(value) { + var empty = emptyList(); + if (value === undefined || value === null) { + // eslint-disable-next-line no-constructor-return + return empty; + } + if (isList(value)) { + // eslint-disable-next-line no-constructor-return + return value; + } + var iter = IndexedCollection(value); + var size = iter.size; + if (size === 0) { + // eslint-disable-next-line no-constructor-return + return empty; + } + assertNotInfinite(size); + if (size > 0 && size < SIZE) { + // eslint-disable-next-line no-constructor-return + return makeList(0, size, SHIFT, null, new VNode(iter.toArray())); + } + // eslint-disable-next-line no-constructor-return + return empty.withMutations(function (list) { + list.setSize(size); + iter.forEach(function (v, i) { return list.set(i, v); }); + }); + } - if (removed) { - SetRef(didChangeSize); - return; // undefined - } + if ( IndexedCollection ) List.__proto__ = IndexedCollection; + List.prototype = Object.create( IndexedCollection && IndexedCollection.prototype ); + List.prototype.constructor = List; - if (keyMatch) { - if (ownerID && ownerID === this.ownerID) { - this.entry[1] = value; - return this; - } - return new ValueNode(ownerID, this.keyHash, [key, value]); - } + List.of = function of (/*...values*/) { + return this(arguments); + }; - SetRef(didChangeSize); - return mergeIntoNode(this, ownerID, shift, hash(key), [key, value]); - }; + List.prototype.toString = function toString () { + return this.__toString('List [', ']'); + }; - // #pragma Iterators + // @pragma Access - ArrayMapNode.prototype.iterate = HashCollisionNode.prototype.iterate = - function (fn, reverse) { - var entries = this.entries; - for (var ii = 0, maxIndex = entries.length - 1; ii <= maxIndex; ii++) { - if (fn(entries[reverse ? maxIndex - ii : ii]) === false) { - return false; + List.prototype.get = function get (index, notSetValue) { + index = wrapIndex(this, index); + if (index >= 0 && index < this.size) { + index += this._origin; + var node = listNodeFor(this, index); + return node && node.array[index & MASK]; } - } - }; + return notSetValue; + }; - BitmapIndexedNode.prototype.iterate = HashArrayMapNode.prototype.iterate = - function (fn, reverse) { - var nodes = this.nodes; - for (var ii = 0, maxIndex = nodes.length - 1; ii <= maxIndex; ii++) { - var node = nodes[reverse ? maxIndex - ii : ii]; - if (node && node.iterate(fn, reverse) === false) { - return false; - } - } - }; + // @pragma Modification - // eslint-disable-next-line @typescript-eslint/no-unused-vars - ValueNode.prototype.iterate = function (fn, reverse) { - return fn(this.entry); - }; - - var MapIterator = /*@__PURE__*/(function (Iterator) { - function MapIterator(map, type, reverse) { - this._type = type; - this._reverse = reverse; - this._stack = map._root && mapIteratorFrame(map._root); - } - - if ( Iterator ) MapIterator.__proto__ = Iterator; - MapIterator.prototype = Object.create( Iterator && Iterator.prototype ); - MapIterator.prototype.constructor = MapIterator; - - MapIterator.prototype.next = function next () { - var type = this._type; - var stack = this._stack; - while (stack) { - var node = stack.node; - var index = stack.index++; - var maxIndex = (void 0); - if (node.entry) { - if (index === 0) { - return mapIteratorValue(type, node.entry); - } - } else if (node.entries) { - maxIndex = node.entries.length - 1; - if (index <= maxIndex) { - return mapIteratorValue( - type, - node.entries[this._reverse ? maxIndex - index : index] - ); - } - } else { - maxIndex = node.nodes.length - 1; - if (index <= maxIndex) { - var subNode = node.nodes[this._reverse ? maxIndex - index : index]; - if (subNode) { - if (subNode.entry) { - return mapIteratorValue(type, subNode.entry); - } - stack = this._stack = mapIteratorFrame(subNode, stack); - } - continue; - } - } - stack = this._stack = this._stack.__prev; - } - return iteratorDone(); - }; + List.prototype.set = function set (index, value) { + return updateList(this, index, value); + }; - return MapIterator; - }(Iterator)); + List.prototype.remove = function remove (index) { + return !this.has(index) + ? this + : index === 0 + ? this.shift() + : index === this.size - 1 + ? this.pop() + : this.splice(index, 1); + }; - function mapIteratorValue(type, entry) { - return iteratorValue(type, entry[0], entry[1]); - } + List.prototype.insert = function insert (index, value) { + return this.splice(index, 0, value); + }; - function mapIteratorFrame(node, prev) { - return { - node: node, - index: 0, - __prev: prev, - }; - } - - function makeMap(size, root, ownerID, hash) { - var map = Object.create(MapPrototype); - map.size = size; - map._root = root; - map.__ownerID = ownerID; - map.__hash = hash; - map.__altered = false; - return map; - } - - var EMPTY_MAP; - function emptyMap() { - return EMPTY_MAP || (EMPTY_MAP = makeMap(0)); - } - - function updateMap(map, k, v) { - var newRoot; - var newSize; - if (!map._root) { - if (v === NOT_SET) { - return map; - } - newSize = 1; - newRoot = new ArrayMapNode(map.__ownerID, [[k, v]]); - } else { - var didChangeSize = MakeRef(); - var didAlter = MakeRef(); - newRoot = updateNode( - map._root, - map.__ownerID, - 0, - undefined, - k, - v, - didChangeSize, - didAlter - ); - if (!didAlter.value) { - return map; - } - newSize = map.size + (didChangeSize.value ? (v === NOT_SET ? -1 : 1) : 0); - } - if (map.__ownerID) { - map.size = newSize; - map._root = newRoot; - map.__hash = undefined; - map.__altered = true; - return map; - } - return newRoot ? makeMap(newSize, newRoot) : emptyMap(); - } - - function updateNode( - node, - ownerID, - shift, - keyHash, - key, - value, - didChangeSize, - didAlter - ) { - if (!node) { - if (value === NOT_SET) { - return node; - } - SetRef(didAlter); - SetRef(didChangeSize); - return new ValueNode(ownerID, keyHash, [key, value]); - } - return node.update( - ownerID, - shift, - keyHash, - key, - value, - didChangeSize, - didAlter - ); - } - - function isLeafNode(node) { - return ( - node.constructor === ValueNode || node.constructor === HashCollisionNode - ); - } - - function mergeIntoNode(node, ownerID, shift, keyHash, entry) { - if (node.keyHash === keyHash) { - return new HashCollisionNode(ownerID, keyHash, [node.entry, entry]); - } - - var idx1 = (shift === 0 ? node.keyHash : node.keyHash >>> shift) & MASK; - var idx2 = (shift === 0 ? keyHash : keyHash >>> shift) & MASK; - - var newNode; - var nodes = - idx1 === idx2 - ? [mergeIntoNode(node, ownerID, shift + SHIFT, keyHash, entry)] - : ((newNode = new ValueNode(ownerID, keyHash, entry)), - idx1 < idx2 ? [node, newNode] : [newNode, node]); - - return new BitmapIndexedNode(ownerID, (1 << idx1) | (1 << idx2), nodes); - } - - function createNodes(ownerID, entries, key, value) { - if (!ownerID) { - ownerID = new OwnerID(); - } - var node = new ValueNode(ownerID, hash(key), [key, value]); - for (var ii = 0; ii < entries.length; ii++) { - var entry = entries[ii]; - node = node.update(ownerID, 0, undefined, entry[0], entry[1]); - } - return node; - } - - function packNodes(ownerID, nodes, count, excluding) { - var bitmap = 0; - var packedII = 0; - var packedNodes = new Array(count); - for (var ii = 0, bit = 1, len = nodes.length; ii < len; ii++, bit <<= 1) { - var node = nodes[ii]; - if (node !== undefined && ii !== excluding) { - bitmap |= bit; - packedNodes[packedII++] = node; - } - } - return new BitmapIndexedNode(ownerID, bitmap, packedNodes); - } - - function expandNodes(ownerID, nodes, bitmap, including, node) { - var count = 0; - var expandedNodes = new Array(SIZE); - for (var ii = 0; bitmap !== 0; ii++, bitmap >>>= 1) { - expandedNodes[ii] = bitmap & 1 ? nodes[count++] : undefined; - } - expandedNodes[including] = node; - return new HashArrayMapNode(ownerID, count + 1, expandedNodes); - } - - function popCount(x) { - x -= (x >> 1) & 0x55555555; - x = (x & 0x33333333) + ((x >> 2) & 0x33333333); - x = (x + (x >> 4)) & 0x0f0f0f0f; - x += x >> 8; - x += x >> 16; - return x & 0x7f; - } - - function setAt(array, idx, val, canEdit) { - var newArray = canEdit ? array : arrCopy(array); - newArray[idx] = val; - return newArray; - } - - function spliceIn(array, idx, val, canEdit) { - var newLen = array.length + 1; - if (canEdit && idx + 1 === newLen) { - array[idx] = val; - return array; - } - var newArray = new Array(newLen); - var after = 0; - for (var ii = 0; ii < newLen; ii++) { - if (ii === idx) { - newArray[ii] = val; - after = -1; - } else { - newArray[ii] = array[ii + after]; - } - } - return newArray; - } - - function spliceOut(array, idx, canEdit) { - var newLen = array.length - 1; - if (canEdit && idx === newLen) { - array.pop(); - return array; - } - var newArray = new Array(newLen); - var after = 0; - for (var ii = 0; ii < newLen; ii++) { - if (ii === idx) { - after = 1; - } - newArray[ii] = array[ii + after]; - } - return newArray; - } - - var MAX_ARRAY_MAP_SIZE = SIZE / 4; - var MAX_BITMAP_INDEXED_SIZE = SIZE / 2; - var MIN_HASH_ARRAY_MAP_SIZE = SIZE / 4; - - var IS_LIST_SYMBOL = '@@__IMMUTABLE_LIST__@@'; - /** - * True if `maybeList` is a List. - */ - function isList(maybeList) { - return Boolean(maybeList && - // @ts-expect-error: maybeList is typed as `{}`, need to change in 6.0 to `maybeList && typeof maybeList === 'object' && IS_LIST_SYMBOL in maybeList` - maybeList[IS_LIST_SYMBOL]); - } - - var List = /*@__PURE__*/(function (IndexedCollection) { - function List(value) { - var empty = emptyList(); - if (value === undefined || value === null) { - // eslint-disable-next-line no-constructor-return - return empty; - } - if (isList(value)) { - // eslint-disable-next-line no-constructor-return - return value; - } - var iter = IndexedCollection(value); - var size = iter.size; - if (size === 0) { - // eslint-disable-next-line no-constructor-return - return empty; - } - assertNotInfinite(size); - if (size > 0 && size < SIZE) { - // eslint-disable-next-line no-constructor-return - return makeList(0, size, SHIFT, null, new VNode(iter.toArray())); - } - // eslint-disable-next-line no-constructor-return - return empty.withMutations(function (list) { - list.setSize(size); - iter.forEach(function (v, i) { return list.set(i, v); }); - }); - } + List.prototype.clear = function clear () { + if (this.size === 0) { + return this; + } + if (this.__ownerID) { + this.size = this._origin = this._capacity = 0; + this._level = SHIFT; + this._root = this._tail = this.__hash = undefined; + this.__altered = true; + return this; + } + return emptyList(); + }; + + List.prototype.push = function push (/*...values*/) { + var values = arguments; + var oldSize = this.size; + return this.withMutations(function (list) { + setListBounds(list, 0, oldSize + values.length); + for (var ii = 0; ii < values.length; ii++) { + list.set(oldSize + ii, values[ii]); + } + }); + }; - if ( IndexedCollection ) List.__proto__ = IndexedCollection; - List.prototype = Object.create( IndexedCollection && IndexedCollection.prototype ); - List.prototype.constructor = List; + List.prototype.pop = function pop () { + return setListBounds(this, 0, -1); + }; - List.of = function of (/*...values*/) { - return this(arguments); - }; + List.prototype.unshift = function unshift (/*...values*/) { + var values = arguments; + return this.withMutations(function (list) { + setListBounds(list, -values.length); + for (var ii = 0; ii < values.length; ii++) { + list.set(ii, values[ii]); + } + }); + }; - List.prototype.toString = function toString () { - return this.__toString('List [', ']'); - }; + List.prototype.shift = function shift () { + return setListBounds(this, 1); + }; - // @pragma Access + // @pragma Composition - List.prototype.get = function get (index, notSetValue) { - index = wrapIndex(this, index); - if (index >= 0 && index < this.size) { - index += this._origin; - var node = listNodeFor(this, index); - return node && node.array[index & MASK]; - } - return notSetValue; - }; + List.prototype.concat = function concat (/*...collections*/) { + var arguments$1 = arguments; - // @pragma Modification + var seqs = []; + for (var i = 0; i < arguments.length; i++) { + var argument = arguments$1[i]; + var seq = IndexedCollection( + typeof argument !== 'string' && hasIterator(argument) + ? argument + : [argument] + ); + if (seq.size !== 0) { + seqs.push(seq); + } + } + if (seqs.length === 0) { + return this; + } + if (this.size === 0 && !this.__ownerID && seqs.length === 1) { + return this.constructor(seqs[0]); + } + return this.withMutations(function (list) { + seqs.forEach(function (seq) { return seq.forEach(function (value) { return list.push(value); }); }); + }); + }; - List.prototype.set = function set (index, value) { - return updateList(this, index, value); - }; + List.prototype.setSize = function setSize (size) { + return setListBounds(this, 0, size); + }; - List.prototype.remove = function remove (index) { - return !this.has(index) - ? this - : index === 0 - ? this.shift() - : index === this.size - 1 - ? this.pop() - : this.splice(index, 1); - }; + List.prototype.map = function map (mapper, context) { + var this$1$1 = this; - List.prototype.insert = function insert (index, value) { - return this.splice(index, 0, value); - }; + return this.withMutations(function (list) { + for (var i = 0; i < this$1$1.size; i++) { + list.set(i, mapper.call(context, list.get(i), i, this$1$1)); + } + }); + }; - List.prototype.clear = function clear () { - if (this.size === 0) { - return this; - } - if (this.__ownerID) { - this.size = this._origin = this._capacity = 0; - this._level = SHIFT; - this._root = this._tail = this.__hash = undefined; - this.__altered = true; - return this; - } - return emptyList(); - }; + // @pragma Iteration - List.prototype.push = function push (/*...values*/) { - var values = arguments; - var oldSize = this.size; - return this.withMutations(function (list) { - setListBounds(list, 0, oldSize + values.length); - for (var ii = 0; ii < values.length; ii++) { - list.set(oldSize + ii, values[ii]); + List.prototype.slice = function slice (begin, end) { + var size = this.size; + if (wholeSlice(begin, end, size)) { + return this; } - }); - }; + return setListBounds( + this, + resolveBegin(begin, size), + resolveEnd(end, size) + ); + }; - List.prototype.pop = function pop () { - return setListBounds(this, 0, -1); - }; + List.prototype.__iterator = function __iterator (type, reverse) { + var index = reverse ? this.size : 0; + var values = iterateList(this, reverse); + return new Iterator(function () { + var value = values(); + return value === DONE + ? iteratorDone() + : iteratorValue(type, reverse ? --index : index++, value); + }); + }; - List.prototype.unshift = function unshift (/*...values*/) { - var values = arguments; - return this.withMutations(function (list) { - setListBounds(list, -values.length); - for (var ii = 0; ii < values.length; ii++) { - list.set(ii, values[ii]); + List.prototype.__iterate = function __iterate (fn, reverse) { + var index = reverse ? this.size : 0; + var values = iterateList(this, reverse); + var value; + while ((value = values()) !== DONE) { + if (fn(value, reverse ? --index : index++, this) === false) { + break; + } } - }); - }; + return index; + }; - List.prototype.shift = function shift () { - return setListBounds(this, 1); - }; + List.prototype.__ensureOwner = function __ensureOwner (ownerID) { + if (ownerID === this.__ownerID) { + return this; + } + if (!ownerID) { + if (this.size === 0) { + return emptyList(); + } + this.__ownerID = ownerID; + this.__altered = false; + return this; + } + return makeList( + this._origin, + this._capacity, + this._level, + this._root, + this._tail, + ownerID, + this.__hash + ); + }; - // @pragma Composition + return List; + }(IndexedCollection)); - List.prototype.concat = function concat (/*...collections*/) { - var arguments$1 = arguments; + List.isList = isList; - var seqs = []; - for (var i = 0; i < arguments.length; i++) { - var argument = arguments$1[i]; - var seq = IndexedCollection( - typeof argument !== 'string' && hasIterator(argument) - ? argument - : [argument] - ); - if (seq.size !== 0) { - seqs.push(seq); - } - } - if (seqs.length === 0) { - return this; - } - if (this.size === 0 && !this.__ownerID && seqs.length === 1) { - return this.constructor(seqs[0]); - } - return this.withMutations(function (list) { - seqs.forEach(function (seq) { return seq.forEach(function (value) { return list.push(value); }); }); - }); + var ListPrototype = List.prototype; + ListPrototype[IS_LIST_SYMBOL] = true; + ListPrototype[DELETE] = ListPrototype.remove; + ListPrototype.merge = ListPrototype.concat; + ListPrototype.setIn = setIn; + ListPrototype.deleteIn = ListPrototype.removeIn = deleteIn; + ListPrototype.update = update; + ListPrototype.updateIn = updateIn; + ListPrototype.mergeIn = mergeIn; + ListPrototype.mergeDeepIn = mergeDeepIn; + ListPrototype.withMutations = withMutations; + ListPrototype.wasAltered = wasAltered; + ListPrototype.asImmutable = asImmutable; + ListPrototype['@@transducer/init'] = ListPrototype.asMutable = asMutable; + ListPrototype['@@transducer/step'] = function (result, arr) { + return result.push(arr); }; - - List.prototype.setSize = function setSize (size) { - return setListBounds(this, 0, size); + ListPrototype['@@transducer/result'] = function (obj) { + return obj.asImmutable(); }; - List.prototype.map = function map (mapper, context) { - var this$1$1 = this; - - return this.withMutations(function (list) { - for (var i = 0; i < this$1$1.size; i++) { - list.set(i, mapper.call(context, list.get(i), i, this$1$1)); - } - }); + var VNode = function VNode(array, ownerID) { + this.array = array; + this.ownerID = ownerID; }; - // @pragma Iteration + // TODO: seems like these methods are very similar - List.prototype.slice = function slice (begin, end) { - var size = this.size; - if (wholeSlice(begin, end, size)) { + VNode.prototype.removeBefore = function removeBefore (ownerID, level, index) { + if ( + (index & ((1 << (level + SHIFT)) - 1)) === 0 || + this.array.length === 0 + ) { return this; } - return setListBounds( - this, - resolveBegin(begin, size), - resolveEnd(end, size) - ); - }; - - List.prototype.__iterator = function __iterator (type, reverse) { - var index = reverse ? this.size : 0; - var values = iterateList(this, reverse); - return new Iterator(function () { - var value = values(); - return value === DONE - ? iteratorDone() - : iteratorValue(type, reverse ? --index : index++, value); - }); - }; - - List.prototype.__iterate = function __iterate (fn, reverse) { - var index = reverse ? this.size : 0; - var values = iterateList(this, reverse); - var value; - while ((value = values()) !== DONE) { - if (fn(value, reverse ? --index : index++, this) === false) { - break; + var originIndex = (index >>> level) & MASK; + if (originIndex >= this.array.length) { + return new VNode([], ownerID); + } + var removingFirst = originIndex === 0; + var newChild; + if (level > 0) { + var oldChild = this.array[originIndex]; + newChild = + oldChild && oldChild.removeBefore(ownerID, level - SHIFT, index); + if (newChild === oldChild && removingFirst) { + return this; } } - return index; - }; - - List.prototype.__ensureOwner = function __ensureOwner (ownerID) { - if (ownerID === this.__ownerID) { + if (removingFirst && !newChild) { return this; } - if (!ownerID) { - if (this.size === 0) { - return emptyList(); + var editable = editableVNode(this, ownerID); + if (!removingFirst) { + for (var ii = 0; ii < originIndex; ii++) { + editable.array[ii] = undefined; } - this.__ownerID = ownerID; - this.__altered = false; - return this; } - return makeList( - this._origin, - this._capacity, - this._level, - this._root, - this._tail, - ownerID, - this.__hash - ); + if (newChild) { + editable.array[originIndex] = newChild; + } + return editable; }; - return List; - }(IndexedCollection)); - - List.isList = isList; - - var ListPrototype = List.prototype; - ListPrototype[IS_LIST_SYMBOL] = true; - ListPrototype[DELETE] = ListPrototype.remove; - ListPrototype.merge = ListPrototype.concat; - ListPrototype.setIn = setIn; - ListPrototype.deleteIn = ListPrototype.removeIn = deleteIn; - ListPrototype.update = update; - ListPrototype.updateIn = updateIn; - ListPrototype.mergeIn = mergeIn; - ListPrototype.mergeDeepIn = mergeDeepIn; - ListPrototype.withMutations = withMutations; - ListPrototype.wasAltered = wasAltered; - ListPrototype.asImmutable = asImmutable; - ListPrototype['@@transducer/init'] = ListPrototype.asMutable = asMutable; - ListPrototype['@@transducer/step'] = function (result, arr) { - return result.push(arr); - }; - ListPrototype['@@transducer/result'] = function (obj) { - return obj.asImmutable(); - }; - - var VNode = function VNode(array, ownerID) { - this.array = array; - this.ownerID = ownerID; - }; - - // TODO: seems like these methods are very similar - - VNode.prototype.removeBefore = function removeBefore (ownerID, level, index) { - if ( - (index & ((1 << (level + SHIFT)) - 1)) === 0 || - this.array.length === 0 - ) { - return this; - } - var originIndex = (index >>> level) & MASK; - if (originIndex >= this.array.length) { - return new VNode([], ownerID); - } - var removingFirst = originIndex === 0; - var newChild; - if (level > 0) { - var oldChild = this.array[originIndex]; - newChild = - oldChild && oldChild.removeBefore(ownerID, level - SHIFT, index); - if (newChild === oldChild && removingFirst) { + VNode.prototype.removeAfter = function removeAfter (ownerID, level, index) { + if ( + index === (level ? 1 << (level + SHIFT) : SIZE) || + this.array.length === 0 + ) { return this; } - } - if (removingFirst && !newChild) { - return this; - } - var editable = editableVNode(this, ownerID); - if (!removingFirst) { - for (var ii = 0; ii < originIndex; ii++) { - editable.array[ii] = undefined; - } - } - if (newChild) { - editable.array[originIndex] = newChild; - } - return editable; - }; - - VNode.prototype.removeAfter = function removeAfter (ownerID, level, index) { - if ( - index === (level ? 1 << (level + SHIFT) : SIZE) || - this.array.length === 0 - ) { - return this; - } - var sizeIndex = ((index - 1) >>> level) & MASK; - if (sizeIndex >= this.array.length) { - return this; - } - - var newChild; - if (level > 0) { - var oldChild = this.array[sizeIndex]; - newChild = - oldChild && oldChild.removeAfter(ownerID, level - SHIFT, index); - if (newChild === oldChild && sizeIndex === this.array.length - 1) { + var sizeIndex = ((index - 1) >>> level) & MASK; + if (sizeIndex >= this.array.length) { return this; } - } - var editable = editableVNode(this, ownerID); - editable.array.splice(sizeIndex + 1); - if (newChild) { - editable.array[sizeIndex] = newChild; - } - return editable; - }; + var newChild; + if (level > 0) { + var oldChild = this.array[sizeIndex]; + newChild = + oldChild && oldChild.removeAfter(ownerID, level - SHIFT, index); + if (newChild === oldChild && sizeIndex === this.array.length - 1) { + return this; + } + } - var DONE = {}; + var editable = editableVNode(this, ownerID); + editable.array.splice(sizeIndex + 1); + if (newChild) { + editable.array[sizeIndex] = newChild; + } + return editable; + }; - function iterateList(list, reverse) { - var left = list._origin; - var right = list._capacity; - var tailPos = getTailOffset(right); - var tail = list._tail; + var DONE = {}; - return iterateNodeOrLeaf(list._root, list._level, 0); + function iterateList(list, reverse) { + var left = list._origin; + var right = list._capacity; + var tailPos = getTailOffset(right); + var tail = list._tail; - function iterateNodeOrLeaf(node, level, offset) { - return level === 0 - ? iterateLeaf(node, offset) - : iterateNode(node, level, offset); - } + return iterateNodeOrLeaf(list._root, list._level, 0); - function iterateLeaf(node, offset) { - var array = offset === tailPos ? tail && tail.array : node && node.array; - var from = offset > left ? 0 : left - offset; - var to = right - offset; - if (to > SIZE) { - to = SIZE; + function iterateNodeOrLeaf(node, level, offset) { + return level === 0 + ? iterateLeaf(node, offset) + : iterateNode(node, level, offset); } - return function () { - if (from === to) { - return DONE; - } - var idx = reverse ? --to : from++; - return array && array[idx]; - }; - } - function iterateNode(node, level, offset) { - var values; - var array = node && node.array; - var from = offset > left ? 0 : (left - offset) >> level; - var to = ((right - offset) >> level) + 1; - if (to > SIZE) { - to = SIZE; - } - return function () { - while (true) { - if (values) { - var value = values(); - if (value !== DONE) { - return value; - } - values = null; - } + function iterateLeaf(node, offset) { + var array = offset === tailPos ? tail && tail.array : node && node.array; + var from = offset > left ? 0 : left - offset; + var to = right - offset; + if (to > SIZE) { + to = SIZE; + } + return function () { if (from === to) { return DONE; } var idx = reverse ? --to : from++; - values = iterateNodeOrLeaf( - array && array[idx], - level - SHIFT, - offset + (idx << level) - ); + return array && array[idx]; + }; + } + + function iterateNode(node, level, offset) { + var values; + var array = node && node.array; + var from = offset > left ? 0 : (left - offset) >> level; + var to = ((right - offset) >> level) + 1; + if (to > SIZE) { + to = SIZE; } - }; + return function () { + while (true) { + if (values) { + var value = values(); + if (value !== DONE) { + return value; + } + values = null; + } + if (from === to) { + return DONE; + } + var idx = reverse ? --to : from++; + values = iterateNodeOrLeaf( + array && array[idx], + level - SHIFT, + offset + (idx << level) + ); + } + }; + } } - } - - function makeList(origin, capacity, level, root, tail, ownerID, hash) { - var list = Object.create(ListPrototype); - list.size = capacity - origin; - list._origin = origin; - list._capacity = capacity; - list._level = level; - list._root = root; - list._tail = tail; - list.__ownerID = ownerID; - list.__hash = hash; - list.__altered = false; - return list; - } - function emptyList() { - return makeList(0, 0, SHIFT); - } - - function updateList(list, index, value) { - index = wrapIndex(list, index); - - if (index !== index) { + function makeList(origin, capacity, level, root, tail, ownerID, hash) { + var list = Object.create(ListPrototype); + list.size = capacity - origin; + list._origin = origin; + list._capacity = capacity; + list._level = level; + list._root = root; + list._tail = tail; + list.__ownerID = ownerID; + list.__hash = hash; + list.__altered = false; return list; } - if (index >= list.size || index < 0) { - return list.withMutations(function (list) { - // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here - index < 0 - ? setListBounds(list, index).set(0, value) - : setListBounds(list, 0, index + 1).set(index, value); - }); + function emptyList() { + return makeList(0, 0, SHIFT); } - index += list._origin; + function updateList(list, index, value) { + index = wrapIndex(list, index); - var newTail = list._tail; - var newRoot = list._root; - var didAlter = MakeRef(); - if (index >= getTailOffset(list._capacity)) { - newTail = updateVNode(newTail, list.__ownerID, 0, index, value, didAlter); - } else { - newRoot = updateVNode( - newRoot, - list.__ownerID, - list._level, - index, - value, - didAlter - ); - } + if (index !== index) { + return list; + } - if (!didAlter.value) { - return list; - } + if (index >= list.size || index < 0) { + return list.withMutations(function (list) { + // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here + index < 0 + ? setListBounds(list, index).set(0, value) + : setListBounds(list, 0, index + 1).set(index, value); + }); + } - if (list.__ownerID) { - list._root = newRoot; - list._tail = newTail; - list.__hash = undefined; - list.__altered = true; - return list; - } - return makeList(list._origin, list._capacity, list._level, newRoot, newTail); - } + index += list._origin; - function updateVNode(node, ownerID, level, index, value, didAlter) { - var idx = (index >>> level) & MASK; - var nodeHas = node && idx < node.array.length; - if (!nodeHas && value === undefined) { - return node; + var newTail = list._tail; + var newRoot = list._root; + var didAlter = MakeRef(); + if (index >= getTailOffset(list._capacity)) { + newTail = updateVNode(newTail, list.__ownerID, 0, index, value, didAlter); + } else { + newRoot = updateVNode( + newRoot, + list.__ownerID, + list._level, + index, + value, + didAlter + ); + } + + if (!didAlter.value) { + return list; + } + + if (list.__ownerID) { + list._root = newRoot; + list._tail = newTail; + list.__hash = undefined; + list.__altered = true; + return list; + } + return makeList(list._origin, list._capacity, list._level, newRoot, newTail); } - var newNode; + function updateVNode(node, ownerID, level, index, value, didAlter) { + var idx = (index >>> level) & MASK; + var nodeHas = node && idx < node.array.length; + if (!nodeHas && value === undefined) { + return node; + } + + var newNode; - if (level > 0) { - var lowerNode = node && node.array[idx]; - var newLowerNode = updateVNode( - lowerNode, - ownerID, - level - SHIFT, - index, - value, - didAlter - ); - if (newLowerNode === lowerNode) { + if (level > 0) { + var lowerNode = node && node.array[idx]; + var newLowerNode = updateVNode( + lowerNode, + ownerID, + level - SHIFT, + index, + value, + didAlter + ); + if (newLowerNode === lowerNode) { + return node; + } + newNode = editableVNode(node, ownerID); + newNode.array[idx] = newLowerNode; + return newNode; + } + + if (nodeHas && node.array[idx] === value) { return node; } + + if (didAlter) { + SetRef(didAlter); + } + newNode = editableVNode(node, ownerID); - newNode.array[idx] = newLowerNode; + if (value === undefined && idx === newNode.array.length - 1) { + newNode.array.pop(); + } else { + newNode.array[idx] = value; + } return newNode; } - if (nodeHas && node.array[idx] === value) { - return node; + function editableVNode(node, ownerID) { + if (ownerID && node && ownerID === node.ownerID) { + return node; + } + return new VNode(node ? node.array.slice() : [], ownerID); } - if (didAlter) { - SetRef(didAlter); + function listNodeFor(list, rawIndex) { + if (rawIndex >= getTailOffset(list._capacity)) { + return list._tail; + } + if (rawIndex < 1 << (list._level + SHIFT)) { + var node = list._root; + var level = list._level; + while (node && level > 0) { + node = node.array[(rawIndex >>> level) & MASK]; + level -= SHIFT; + } + return node; + } } - newNode = editableVNode(node, ownerID); - if (value === undefined && idx === newNode.array.length - 1) { - newNode.array.pop(); - } else { - newNode.array[idx] = value; - } - return newNode; - } + function setListBounds(list, begin, end) { + // Sanitize begin & end using this shorthand for ToInt32(argument) + // http://www.ecma-international.org/ecma-262/6.0/#sec-toint32 + if (begin !== undefined) { + begin |= 0; + } + if (end !== undefined) { + end |= 0; + } + var owner = list.__ownerID || new OwnerID(); + var oldOrigin = list._origin; + var oldCapacity = list._capacity; + var newOrigin = oldOrigin + begin; + var newCapacity = + end === undefined + ? oldCapacity + : end < 0 + ? oldCapacity + end + : oldOrigin + end; + if (newOrigin === oldOrigin && newCapacity === oldCapacity) { + return list; + } - function editableVNode(node, ownerID) { - if (ownerID && node && ownerID === node.ownerID) { - return node; - } - return new VNode(node ? node.array.slice() : [], ownerID); - } + // If it's going to end after it starts, it's empty. + if (newOrigin >= newCapacity) { + return list.clear(); + } - function listNodeFor(list, rawIndex) { - if (rawIndex >= getTailOffset(list._capacity)) { - return list._tail; - } - if (rawIndex < 1 << (list._level + SHIFT)) { - var node = list._root; - var level = list._level; - while (node && level > 0) { - node = node.array[(rawIndex >>> level) & MASK]; - level -= SHIFT; + var newLevel = list._level; + var newRoot = list._root; + + // New origin might need creating a higher root. + var offsetShift = 0; + while (newOrigin + offsetShift < 0) { + newRoot = new VNode( + newRoot && newRoot.array.length ? [undefined, newRoot] : [], + owner + ); + newLevel += SHIFT; + offsetShift += 1 << newLevel; + } + if (offsetShift) { + newOrigin += offsetShift; + oldOrigin += offsetShift; + newCapacity += offsetShift; + oldCapacity += offsetShift; } - return node; - } - } - - function setListBounds(list, begin, end) { - // Sanitize begin & end using this shorthand for ToInt32(argument) - // http://www.ecma-international.org/ecma-262/6.0/#sec-toint32 - if (begin !== undefined) { - begin |= 0; - } - if (end !== undefined) { - end |= 0; - } - var owner = list.__ownerID || new OwnerID(); - var oldOrigin = list._origin; - var oldCapacity = list._capacity; - var newOrigin = oldOrigin + begin; - var newCapacity = - end === undefined - ? oldCapacity - : end < 0 - ? oldCapacity + end - : oldOrigin + end; - if (newOrigin === oldOrigin && newCapacity === oldCapacity) { - return list; - } - // If it's going to end after it starts, it's empty. - if (newOrigin >= newCapacity) { - return list.clear(); - } + var oldTailOffset = getTailOffset(oldCapacity); + var newTailOffset = getTailOffset(newCapacity); - var newLevel = list._level; - var newRoot = list._root; + // New size might need creating a higher root. + while (newTailOffset >= 1 << (newLevel + SHIFT)) { + newRoot = new VNode( + newRoot && newRoot.array.length ? [newRoot] : [], + owner + ); + newLevel += SHIFT; + } - // New origin might need creating a higher root. - var offsetShift = 0; - while (newOrigin + offsetShift < 0) { - newRoot = new VNode( - newRoot && newRoot.array.length ? [undefined, newRoot] : [], - owner - ); - newLevel += SHIFT; - offsetShift += 1 << newLevel; - } - if (offsetShift) { - newOrigin += offsetShift; - oldOrigin += offsetShift; - newCapacity += offsetShift; - oldCapacity += offsetShift; - } + // Locate or create the new tail. + var oldTail = list._tail; + var newTail = + newTailOffset < oldTailOffset + ? listNodeFor(list, newCapacity - 1) + : newTailOffset > oldTailOffset + ? new VNode([], owner) + : oldTail; - var oldTailOffset = getTailOffset(oldCapacity); - var newTailOffset = getTailOffset(newCapacity); + // Merge Tail into tree. + if ( + oldTail && + newTailOffset > oldTailOffset && + newOrigin < oldCapacity && + oldTail.array.length + ) { + newRoot = editableVNode(newRoot, owner); + var node = newRoot; + for (var level = newLevel; level > SHIFT; level -= SHIFT) { + var idx = (oldTailOffset >>> level) & MASK; + node = node.array[idx] = editableVNode(node.array[idx], owner); + } + node.array[(oldTailOffset >>> SHIFT) & MASK] = oldTail; + } - // New size might need creating a higher root. - while (newTailOffset >= 1 << (newLevel + SHIFT)) { - newRoot = new VNode( - newRoot && newRoot.array.length ? [newRoot] : [], - owner - ); - newLevel += SHIFT; - } - - // Locate or create the new tail. - var oldTail = list._tail; - var newTail = - newTailOffset < oldTailOffset - ? listNodeFor(list, newCapacity - 1) - : newTailOffset > oldTailOffset - ? new VNode([], owner) - : oldTail; - - // Merge Tail into tree. - if ( - oldTail && - newTailOffset > oldTailOffset && - newOrigin < oldCapacity && - oldTail.array.length - ) { - newRoot = editableVNode(newRoot, owner); - var node = newRoot; - for (var level = newLevel; level > SHIFT; level -= SHIFT) { - var idx = (oldTailOffset >>> level) & MASK; - node = node.array[idx] = editableVNode(node.array[idx], owner); + // If the size has been reduced, there's a chance the tail needs to be trimmed. + if (newCapacity < oldCapacity) { + newTail = newTail && newTail.removeAfter(owner, 0, newCapacity); } - node.array[(oldTailOffset >>> SHIFT) & MASK] = oldTail; - } - // If the size has been reduced, there's a chance the tail needs to be trimmed. - if (newCapacity < oldCapacity) { - newTail = newTail && newTail.removeAfter(owner, 0, newCapacity); - } + // If the new origin is within the tail, then we do not need a root. + if (newOrigin >= newTailOffset) { + newOrigin -= newTailOffset; + newCapacity -= newTailOffset; + newLevel = SHIFT; + newRoot = null; + newTail = newTail && newTail.removeBefore(owner, 0, newOrigin); - // If the new origin is within the tail, then we do not need a root. - if (newOrigin >= newTailOffset) { - newOrigin -= newTailOffset; - newCapacity -= newTailOffset; - newLevel = SHIFT; - newRoot = null; - newTail = newTail && newTail.removeBefore(owner, 0, newOrigin); + // Otherwise, if the root has been trimmed, garbage collect. + } else if (newOrigin > oldOrigin || newTailOffset < oldTailOffset) { + offsetShift = 0; - // Otherwise, if the root has been trimmed, garbage collect. - } else if (newOrigin > oldOrigin || newTailOffset < oldTailOffset) { - offsetShift = 0; + // Identify the new top root node of the subtree of the old root. + while (newRoot) { + var beginIndex = (newOrigin >>> newLevel) & MASK; + if ((beginIndex !== newTailOffset >>> newLevel) & MASK) { + break; + } + if (beginIndex) { + offsetShift += (1 << newLevel) * beginIndex; + } + newLevel -= SHIFT; + newRoot = newRoot.array[beginIndex]; + } - // Identify the new top root node of the subtree of the old root. - while (newRoot) { - var beginIndex = (newOrigin >>> newLevel) & MASK; - if ((beginIndex !== newTailOffset >>> newLevel) & MASK) { - break; + // Trim the new sides of the new root. + if (newRoot && newOrigin > oldOrigin) { + newRoot = newRoot.removeBefore(owner, newLevel, newOrigin - offsetShift); + } + if (newRoot && newTailOffset < oldTailOffset) { + newRoot = newRoot.removeAfter( + owner, + newLevel, + newTailOffset - offsetShift + ); } - if (beginIndex) { - offsetShift += (1 << newLevel) * beginIndex; + if (offsetShift) { + newOrigin -= offsetShift; + newCapacity -= offsetShift; } - newLevel -= SHIFT; - newRoot = newRoot.array[beginIndex]; } - // Trim the new sides of the new root. - if (newRoot && newOrigin > oldOrigin) { - newRoot = newRoot.removeBefore(owner, newLevel, newOrigin - offsetShift); - } - if (newRoot && newTailOffset < oldTailOffset) { - newRoot = newRoot.removeAfter( - owner, - newLevel, - newTailOffset - offsetShift - ); - } - if (offsetShift) { - newOrigin -= offsetShift; - newCapacity -= offsetShift; + if (list.__ownerID) { + list.size = newCapacity - newOrigin; + list._origin = newOrigin; + list._capacity = newCapacity; + list._level = newLevel; + list._root = newRoot; + list._tail = newTail; + list.__hash = undefined; + list.__altered = true; + return list; } + return makeList(newOrigin, newCapacity, newLevel, newRoot, newTail); } - if (list.__ownerID) { - list.size = newCapacity - newOrigin; - list._origin = newOrigin; - list._capacity = newCapacity; - list._level = newLevel; - list._root = newRoot; - list._tail = newTail; - list.__hash = undefined; - list.__altered = true; - return list; + function getTailOffset(size) { + return size < SIZE ? 0 : ((size - 1) >>> SHIFT) << SHIFT; } - return makeList(newOrigin, newCapacity, newLevel, newRoot, newTail); - } - function getTailOffset(size) { - return size < SIZE ? 0 : ((size - 1) >>> SHIFT) << SHIFT; - } - - var OrderedMap = /*@__PURE__*/(function (Map) { - function OrderedMap(value) { - // eslint-disable-next-line no-constructor-return - return value === undefined || value === null - ? emptyOrderedMap() - : isOrderedMap(value) - ? value - : emptyOrderedMap().withMutations(function (map) { - var iter = KeyedCollection(value); - assertNotInfinite(iter.size); - iter.forEach(function (v, k) { return map.set(k, v); }); - }); - } - - if ( Map ) OrderedMap.__proto__ = Map; - OrderedMap.prototype = Object.create( Map && Map.prototype ); - OrderedMap.prototype.constructor = OrderedMap; - - OrderedMap.of = function of (/*...values*/) { - return this(arguments); - }; + var OrderedMap = /*@__PURE__*/(function (Map) { + function OrderedMap(value) { + // eslint-disable-next-line no-constructor-return + return value === undefined || value === null + ? emptyOrderedMap() + : isOrderedMap(value) + ? value + : emptyOrderedMap().withMutations(function (map) { + var iter = KeyedCollection(value); + assertNotInfinite(iter.size); + iter.forEach(function (v, k) { return map.set(k, v); }); + }); + } + + if ( Map ) OrderedMap.__proto__ = Map; + OrderedMap.prototype = Object.create( Map && Map.prototype ); + OrderedMap.prototype.constructor = OrderedMap; + + OrderedMap.of = function of (/*...values*/) { + return this(arguments); + }; - OrderedMap.prototype.toString = function toString () { - return this.__toString('OrderedMap {', '}'); - }; + OrderedMap.prototype.toString = function toString () { + return this.__toString('OrderedMap {', '}'); + }; - // @pragma Access + // @pragma Access - OrderedMap.prototype.get = function get (k, notSetValue) { - var index = this._map.get(k); - return index !== undefined ? this._list.get(index)[1] : notSetValue; - }; + OrderedMap.prototype.get = function get (k, notSetValue) { + var index = this._map.get(k); + return index !== undefined ? this._list.get(index)[1] : notSetValue; + }; - // @pragma Modification + // @pragma Modification - OrderedMap.prototype.clear = function clear () { - if (this.size === 0) { - return this; - } - if (this.__ownerID) { - this.size = 0; - this._map.clear(); - this._list.clear(); - this.__altered = true; - return this; - } - return emptyOrderedMap(); - }; + OrderedMap.prototype.clear = function clear () { + if (this.size === 0) { + return this; + } + if (this.__ownerID) { + this.size = 0; + this._map.clear(); + this._list.clear(); + this.__altered = true; + return this; + } + return emptyOrderedMap(); + }; - OrderedMap.prototype.set = function set (k, v) { - return updateOrderedMap(this, k, v); - }; + OrderedMap.prototype.set = function set (k, v) { + return updateOrderedMap(this, k, v); + }; - OrderedMap.prototype.remove = function remove (k) { - return updateOrderedMap(this, k, NOT_SET); - }; + OrderedMap.prototype.remove = function remove (k) { + return updateOrderedMap(this, k, NOT_SET); + }; - OrderedMap.prototype.__iterate = function __iterate (fn, reverse) { - var this$1$1 = this; + OrderedMap.prototype.__iterate = function __iterate (fn, reverse) { + var this$1$1 = this; - return this._list.__iterate( - function (entry) { return entry && fn(entry[1], entry[0], this$1$1); }, - reverse - ); - }; + return this._list.__iterate( + function (entry) { return entry && fn(entry[1], entry[0], this$1$1); }, + reverse + ); + }; - OrderedMap.prototype.__iterator = function __iterator (type, reverse) { - return this._list.fromEntrySeq().__iterator(type, reverse); - }; + OrderedMap.prototype.__iterator = function __iterator (type, reverse) { + return this._list.fromEntrySeq().__iterator(type, reverse); + }; - OrderedMap.prototype.__ensureOwner = function __ensureOwner (ownerID) { - if (ownerID === this.__ownerID) { - return this; - } - var newMap = this._map.__ensureOwner(ownerID); - var newList = this._list.__ensureOwner(ownerID); - if (!ownerID) { - if (this.size === 0) { - return emptyOrderedMap(); + OrderedMap.prototype.__ensureOwner = function __ensureOwner (ownerID) { + if (ownerID === this.__ownerID) { + return this; } - this.__ownerID = ownerID; - this.__altered = false; - this._map = newMap; - this._list = newList; - return this; - } - return makeOrderedMap(newMap, newList, ownerID, this.__hash); - }; + var newMap = this._map.__ensureOwner(ownerID); + var newList = this._list.__ensureOwner(ownerID); + if (!ownerID) { + if (this.size === 0) { + return emptyOrderedMap(); + } + this.__ownerID = ownerID; + this.__altered = false; + this._map = newMap; + this._list = newList; + return this; + } + return makeOrderedMap(newMap, newList, ownerID, this.__hash); + }; - return OrderedMap; - }(Map)); - - OrderedMap.isOrderedMap = isOrderedMap; - - OrderedMap.prototype[IS_ORDERED_SYMBOL] = true; - OrderedMap.prototype[DELETE] = OrderedMap.prototype.remove; - - function makeOrderedMap(map, list, ownerID, hash) { - var omap = Object.create(OrderedMap.prototype); - omap.size = map ? map.size : 0; - omap._map = map; - omap._list = list; - omap.__ownerID = ownerID; - omap.__hash = hash; - omap.__altered = false; - return omap; - } - - var EMPTY_ORDERED_MAP; - function emptyOrderedMap() { - return ( - EMPTY_ORDERED_MAP || - (EMPTY_ORDERED_MAP = makeOrderedMap(emptyMap(), emptyList())) - ); - } - - function updateOrderedMap(omap, k, v) { - var map = omap._map; - var list = omap._list; - var i = map.get(k); - var has = i !== undefined; - var newMap; - var newList; - if (v === NOT_SET) { - // removed - if (!has) { - return omap; - } - if (list.size >= SIZE && list.size >= map.size * 2) { - newList = list.filter(function (entry, idx) { return entry !== undefined && i !== idx; }); - newMap = newList - .toKeyedSeq() - .map(function (entry) { return entry[0]; }) - .flip() - .toMap(); - if (omap.__ownerID) { - newMap.__ownerID = newList.__ownerID = omap.__ownerID; + return OrderedMap; + }(Map)); + + OrderedMap.isOrderedMap = isOrderedMap; + + OrderedMap.prototype[IS_ORDERED_SYMBOL] = true; + OrderedMap.prototype[DELETE] = OrderedMap.prototype.remove; + + function makeOrderedMap(map, list, ownerID, hash) { + var omap = Object.create(OrderedMap.prototype); + omap.size = map ? map.size : 0; + omap._map = map; + omap._list = list; + omap.__ownerID = ownerID; + omap.__hash = hash; + omap.__altered = false; + return omap; + } + + var EMPTY_ORDERED_MAP; + function emptyOrderedMap() { + return ( + EMPTY_ORDERED_MAP || + (EMPTY_ORDERED_MAP = makeOrderedMap(emptyMap(), emptyList())) + ); + } + + function updateOrderedMap(omap, k, v) { + var map = omap._map; + var list = omap._list; + var i = map.get(k); + var has = i !== undefined; + var newMap; + var newList; + if (v === NOT_SET) { + // removed + if (!has) { + return omap; + } + if (list.size >= SIZE && list.size >= map.size * 2) { + newList = list.filter(function (entry, idx) { return entry !== undefined && i !== idx; }); + newMap = newList + .toKeyedSeq() + .map(function (entry) { return entry[0]; }) + .flip() + .toMap(); + if (omap.__ownerID) { + newMap.__ownerID = newList.__ownerID = omap.__ownerID; + } + } else { + newMap = map.remove(k); + newList = i === list.size - 1 ? list.pop() : list.set(i, undefined); } + } else if (has) { + if (v === list.get(i)[1]) { + return omap; + } + newMap = map; + newList = list.set(i, [k, v]); } else { - newMap = map.remove(k); - newList = i === list.size - 1 ? list.pop() : list.set(i, undefined); - } - } else if (has) { - if (v === list.get(i)[1]) { + newMap = map.set(k, list.size); + newList = list.set(list.size, [k, v]); + } + if (omap.__ownerID) { + omap.size = newMap.size; + omap._map = newMap; + omap._list = newList; + omap.__hash = undefined; + omap.__altered = true; return omap; } - newMap = map; - newList = list.set(i, [k, v]); - } else { - newMap = map.set(k, list.size); - newList = list.set(list.size, [k, v]); - } - if (omap.__ownerID) { - omap.size = newMap.size; - omap._map = newMap; - omap._list = newList; - omap.__hash = undefined; - omap.__altered = true; - return omap; - } - return makeOrderedMap(newMap, newList); - } - - var IS_STACK_SYMBOL = '@@__IMMUTABLE_STACK__@@'; - /** - * True if `maybeStack` is a Stack. - */ - function isStack(maybeStack) { - return Boolean(maybeStack && - // @ts-expect-error: maybeStack is typed as `{}`, need to change in 6.0 to `maybeStack && typeof maybeStack === 'object' && MAYBE_STACK_SYMBOL in maybeStack` - maybeStack[IS_STACK_SYMBOL]); - } - - var Stack = /*@__PURE__*/(function (IndexedCollection) { - function Stack(value) { - // eslint-disable-next-line no-constructor-return - return value === undefined || value === null - ? emptyStack() - : isStack(value) - ? value - : emptyStack().pushAll(value); + return makeOrderedMap(newMap, newList); } - if ( IndexedCollection ) Stack.__proto__ = IndexedCollection; - Stack.prototype = Object.create( IndexedCollection && IndexedCollection.prototype ); - Stack.prototype.constructor = Stack; - - Stack.of = function of (/*...values*/) { - return this(arguments); - }; + var IS_STACK_SYMBOL = '@@__IMMUTABLE_STACK__@@'; + /** + * True if `maybeStack` is a Stack. + */ + function isStack(maybeStack) { + return Boolean(maybeStack && + // @ts-expect-error: maybeStack is typed as `{}`, need to change in 6.0 to `maybeStack && typeof maybeStack === 'object' && MAYBE_STACK_SYMBOL in maybeStack` + maybeStack[IS_STACK_SYMBOL]); + } - Stack.prototype.toString = function toString () { - return this.__toString('Stack [', ']'); - }; + var Stack = /*@__PURE__*/(function (IndexedCollection) { + function Stack(value) { + // eslint-disable-next-line no-constructor-return + return value === undefined || value === null + ? emptyStack() + : isStack(value) + ? value + : emptyStack().pushAll(value); + } - // @pragma Access + if ( IndexedCollection ) Stack.__proto__ = IndexedCollection; + Stack.prototype = Object.create( IndexedCollection && IndexedCollection.prototype ); + Stack.prototype.constructor = Stack; - Stack.prototype.get = function get (index, notSetValue) { - var head = this._head; - index = wrapIndex(this, index); - while (head && index--) { - head = head.next; - } - return head ? head.value : notSetValue; - }; + Stack.of = function of (/*...values*/) { + return this(arguments); + }; - Stack.prototype.peek = function peek () { - return this._head && this._head.value; - }; + Stack.prototype.toString = function toString () { + return this.__toString('Stack [', ']'); + }; - // @pragma Modification + // @pragma Access - Stack.prototype.push = function push (/*...values*/) { - var arguments$1 = arguments; + Stack.prototype.get = function get (index, notSetValue) { + var head = this._head; + index = wrapIndex(this, index); + while (head && index--) { + head = head.next; + } + return head ? head.value : notSetValue; + }; - if (arguments.length === 0) { - return this; - } - var newSize = this.size + arguments.length; - var head = this._head; - for (var ii = arguments.length - 1; ii >= 0; ii--) { - head = { - value: arguments$1[ii], - next: head, - }; - } - if (this.__ownerID) { - this.size = newSize; - this._head = head; - this.__hash = undefined; - this.__altered = true; - return this; - } - return makeStack(newSize, head); - }; + Stack.prototype.peek = function peek () { + return this._head && this._head.value; + }; - Stack.prototype.pushAll = function pushAll (iter) { - iter = IndexedCollection(iter); - if (iter.size === 0) { - return this; - } - if (this.size === 0 && isStack(iter)) { - return iter; - } - assertNotInfinite(iter.size); - var newSize = this.size; - var head = this._head; - iter.__iterate(function (value) { - newSize++; - head = { - value: value, - next: head, - }; - }, /* reverse */ true); - if (this.__ownerID) { - this.size = newSize; - this._head = head; - this.__hash = undefined; - this.__altered = true; - return this; - } - return makeStack(newSize, head); - }; + // @pragma Modification - Stack.prototype.pop = function pop () { - return this.slice(1); - }; + Stack.prototype.push = function push (/*...values*/) { + var arguments$1 = arguments; - Stack.prototype.clear = function clear () { - if (this.size === 0) { - return this; - } - if (this.__ownerID) { - this.size = 0; - this._head = undefined; - this.__hash = undefined; - this.__altered = true; - return this; - } - return emptyStack(); - }; + if (arguments.length === 0) { + return this; + } + var newSize = this.size + arguments.length; + var head = this._head; + for (var ii = arguments.length - 1; ii >= 0; ii--) { + head = { + value: arguments$1[ii], + next: head, + }; + } + if (this.__ownerID) { + this.size = newSize; + this._head = head; + this.__hash = undefined; + this.__altered = true; + return this; + } + return makeStack(newSize, head); + }; - Stack.prototype.slice = function slice (begin, end) { - if (wholeSlice(begin, end, this.size)) { - return this; - } - var resolvedBegin = resolveBegin(begin, this.size); - var resolvedEnd = resolveEnd(end, this.size); - if (resolvedEnd !== this.size) { - // super.slice(begin, end); - return IndexedCollection.prototype.slice.call(this, begin, end); - } - var newSize = this.size - resolvedBegin; - var head = this._head; - while (resolvedBegin--) { - head = head.next; - } - if (this.__ownerID) { - this.size = newSize; - this._head = head; - this.__hash = undefined; - this.__altered = true; - return this; - } - return makeStack(newSize, head); - }; + Stack.prototype.pushAll = function pushAll (iter) { + iter = IndexedCollection(iter); + if (iter.size === 0) { + return this; + } + if (this.size === 0 && isStack(iter)) { + return iter; + } + assertNotInfinite(iter.size); + var newSize = this.size; + var head = this._head; + iter.__iterate(function (value) { + newSize++; + head = { + value: value, + next: head, + }; + }, /* reverse */ true); + if (this.__ownerID) { + this.size = newSize; + this._head = head; + this.__hash = undefined; + this.__altered = true; + return this; + } + return makeStack(newSize, head); + }; - // @pragma Mutability + Stack.prototype.pop = function pop () { + return this.slice(1); + }; - Stack.prototype.__ensureOwner = function __ensureOwner (ownerID) { - if (ownerID === this.__ownerID) { - return this; - } - if (!ownerID) { + Stack.prototype.clear = function clear () { if (this.size === 0) { - return emptyStack(); + return this; } - this.__ownerID = ownerID; - this.__altered = false; - return this; - } - return makeStack(this.size, this._head, ownerID, this.__hash); - }; + if (this.__ownerID) { + this.size = 0; + this._head = undefined; + this.__hash = undefined; + this.__altered = true; + return this; + } + return emptyStack(); + }; - // @pragma Iteration + Stack.prototype.slice = function slice (begin, end) { + if (wholeSlice(begin, end, this.size)) { + return this; + } + var resolvedBegin = resolveBegin(begin, this.size); + var resolvedEnd = resolveEnd(end, this.size); + if (resolvedEnd !== this.size) { + // super.slice(begin, end); + return IndexedCollection.prototype.slice.call(this, begin, end); + } + var newSize = this.size - resolvedBegin; + var head = this._head; + while (resolvedBegin--) { + head = head.next; + } + if (this.__ownerID) { + this.size = newSize; + this._head = head; + this.__hash = undefined; + this.__altered = true; + return this; + } + return makeStack(newSize, head); + }; - Stack.prototype.__iterate = function __iterate (fn, reverse) { - var this$1$1 = this; + // @pragma Mutability - if (reverse) { - return new ArraySeq(this.toArray()).__iterate( - function (v, k) { return fn(v, k, this$1$1); }, - reverse - ); - } - var iterations = 0; - var node = this._head; - while (node) { - if (fn(node.value, iterations++, this) === false) { - break; + Stack.prototype.__ensureOwner = function __ensureOwner (ownerID) { + if (ownerID === this.__ownerID) { + return this; } - node = node.next; - } - return iterations; - }; + if (!ownerID) { + if (this.size === 0) { + return emptyStack(); + } + this.__ownerID = ownerID; + this.__altered = false; + return this; + } + return makeStack(this.size, this._head, ownerID, this.__hash); + }; - Stack.prototype.__iterator = function __iterator (type, reverse) { - if (reverse) { - return new ArraySeq(this.toArray()).__iterator(type, reverse); - } - var iterations = 0; - var node = this._head; - return new Iterator(function () { - if (node) { - var value = node.value; + // @pragma Iteration + + Stack.prototype.__iterate = function __iterate (fn, reverse) { + var this$1$1 = this; + + if (reverse) { + return new ArraySeq(this.toArray()).__iterate( + function (v, k) { return fn(v, k, this$1$1); }, + reverse + ); + } + var iterations = 0; + var node = this._head; + while (node) { + if (fn(node.value, iterations++, this) === false) { + break; + } node = node.next; - return iteratorValue(type, iterations++, value); } - return iteratorDone(); - }); - }; + return iterations; + }; + + Stack.prototype.__iterator = function __iterator (type, reverse) { + if (reverse) { + return new ArraySeq(this.toArray()).__iterator(type, reverse); + } + var iterations = 0; + var node = this._head; + return new Iterator(function () { + if (node) { + var value = node.value; + node = node.next; + return iteratorValue(type, iterations++, value); + } + return iteratorDone(); + }); + }; - return Stack; - }(IndexedCollection)); - - Stack.isStack = isStack; - - var StackPrototype = Stack.prototype; - StackPrototype[IS_STACK_SYMBOL] = true; - StackPrototype.shift = StackPrototype.pop; - StackPrototype.unshift = StackPrototype.push; - StackPrototype.unshiftAll = StackPrototype.pushAll; - StackPrototype.withMutations = withMutations; - StackPrototype.wasAltered = wasAltered; - StackPrototype.asImmutable = asImmutable; - StackPrototype['@@transducer/init'] = StackPrototype.asMutable = asMutable; - StackPrototype['@@transducer/step'] = function (result, arr) { - return result.unshift(arr); - }; - StackPrototype['@@transducer/result'] = function (obj) { - return obj.asImmutable(); - }; - - function makeStack(size, head, ownerID, hash) { - var map = Object.create(StackPrototype); - map.size = size; - map._head = head; - map.__ownerID = ownerID; - map.__hash = hash; - map.__altered = false; - return map; - } - - var EMPTY_STACK; - function emptyStack() { - return EMPTY_STACK || (EMPTY_STACK = makeStack(0)); - } - - var IS_SET_SYMBOL = '@@__IMMUTABLE_SET__@@'; - /** - * True if `maybeSet` is a Set. - * - * Also true for OrderedSets. - */ - function isSet(maybeSet) { - return Boolean(maybeSet && - // @ts-expect-error: maybeSet is typed as `{}`, need to change in 6.0 to `maybeSeq && typeof maybeSet === 'object' && MAYBE_SET_SYMBOL in maybeSet` - maybeSet[IS_SET_SYMBOL]); - } - - /** - * True if `maybeOrderedSet` is an OrderedSet. - */ - function isOrderedSet(maybeOrderedSet) { - return isSet(maybeOrderedSet) && isOrdered(maybeOrderedSet); - } - - function deepEqual(a, b) { - if (a === b) { - return true; - } - - if ( - !isCollection(b) || - (a.size !== undefined && b.size !== undefined && a.size !== b.size) || - (a.__hash !== undefined && - b.__hash !== undefined && - a.__hash !== b.__hash) || - isKeyed(a) !== isKeyed(b) || - isIndexed(a) !== isIndexed(b) || - isOrdered(a) !== isOrdered(b) - ) { - return false; + return Stack; + }(IndexedCollection)); + + Stack.isStack = isStack; + + var StackPrototype = Stack.prototype; + StackPrototype[IS_STACK_SYMBOL] = true; + StackPrototype.shift = StackPrototype.pop; + StackPrototype.unshift = StackPrototype.push; + StackPrototype.unshiftAll = StackPrototype.pushAll; + StackPrototype.withMutations = withMutations; + StackPrototype.wasAltered = wasAltered; + StackPrototype.asImmutable = asImmutable; + StackPrototype['@@transducer/init'] = StackPrototype.asMutable = asMutable; + StackPrototype['@@transducer/step'] = function (result, arr) { + return result.unshift(arr); + }; + StackPrototype['@@transducer/result'] = function (obj) { + return obj.asImmutable(); + }; + + function makeStack(size, head, ownerID, hash) { + var map = Object.create(StackPrototype); + map.size = size; + map._head = head; + map.__ownerID = ownerID; + map.__hash = hash; + map.__altered = false; + return map; } - if (a.size === 0 && b.size === 0) { - return true; + var EMPTY_STACK; + function emptyStack() { + return EMPTY_STACK || (EMPTY_STACK = makeStack(0)); } - var notAssociative = !isAssociative(a); - - if (isOrdered(a)) { - var entries = a.entries(); - return ( - b.every(function (v, k) { - var entry = entries.next().value; - return entry && is(entry[1], v) && (notAssociative || is(entry[0], k)); - }) && entries.next().done - ); + var IS_SET_SYMBOL = '@@__IMMUTABLE_SET__@@'; + /** + * True if `maybeSet` is a Set. + * + * Also true for OrderedSets. + */ + function isSet(maybeSet) { + return Boolean(maybeSet && + // @ts-expect-error: maybeSet is typed as `{}`, need to change in 6.0 to `maybeSeq && typeof maybeSet === 'object' && MAYBE_SET_SYMBOL in maybeSet` + maybeSet[IS_SET_SYMBOL]); } - var flipped = false; + /** + * True if `maybeOrderedSet` is an OrderedSet. + */ + function isOrderedSet(maybeOrderedSet) { + return isSet(maybeOrderedSet) && isOrdered(maybeOrderedSet); + } - if (a.size === undefined) { - if (b.size === undefined) { - if (typeof a.cacheResult === 'function') { - a.cacheResult(); + function deepEqual(a, b) { + if (a === b) { + return true; } - } else { - flipped = true; - var _ = a; - a = b; - b = _; - } + if (!isCollection(b) || + // @ts-expect-error size should exists on Collection + (a.size !== undefined && b.size !== undefined && a.size !== b.size) || + // @ts-expect-error __hash exists on Collection + (a.__hash !== undefined && + // @ts-expect-error __hash exists on Collection + b.__hash !== undefined && + // @ts-expect-error __hash exists on Collection + a.__hash !== b.__hash) || + isKeyed(a) !== isKeyed(b) || + isIndexed(a) !== isIndexed(b) || + // @ts-expect-error Range extends Collection, which implements [Symbol.iterator], so it is valid + isOrdered(a) !== isOrdered(b)) { + return false; + } + // @ts-expect-error size should exists on Collection + if (a.size === 0 && b.size === 0) { + return true; + } + var notAssociative = !isAssociative(a); + // @ts-expect-error Range extends Collection, which implements [Symbol.iterator], so it is valid + if (isOrdered(a)) { + var entries = a.entries(); + // @ts-expect-error need to cast as boolean + return (b.every(function (v, k) { + var entry = entries.next().value; + return entry && is(entry[1], v) && (notAssociative || is(entry[0], k)); + }) && entries.next().done); + } + var flipped = false; + if (a.size === undefined) { + // @ts-expect-error size should exists on Collection + if (b.size === undefined) { + if (typeof a.cacheResult === 'function') { + a.cacheResult(); + } + } + else { + flipped = true; + var _ = a; + a = b; + b = _; + } + } + var allEqual = true; + var bSize = + // @ts-expect-error b is Range | Repeat | Collection as it may have been flipped, and __iterate is valid + b.__iterate(function (v, k) { + if (notAssociative + ? // @ts-expect-error has exists on Collection + !a.has(v) + : flipped + ? // @ts-expect-error type of `get` does not "catch" the version with `notSetValue` + !is(v, a.get(k, NOT_SET)) + : // @ts-expect-error type of `get` does not "catch" the version with `notSetValue` + !is(a.get(k, NOT_SET), v)) { + allEqual = false; + return false; + } + }); + return (allEqual && + // @ts-expect-error size should exists on Collection + a.size === bSize); + } + + /** + * Contributes additional methods to a constructor + */ + function mixin(ctor, + // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type + methods) { + var keyCopier = function (key) { + // @ts-expect-error how to handle symbol ? + ctor.prototype[key] = methods[key]; + }; + Object.keys(methods).forEach(keyCopier); + // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here + Object.getOwnPropertySymbols && + Object.getOwnPropertySymbols(methods).forEach(keyCopier); + return ctor; } - var allEqual = true; - var bSize = b.__iterate(function (v, k) { - if ( - notAssociative - ? !a.has(v) - : flipped - ? !is(v, a.get(k, NOT_SET)) - : !is(a.get(k, NOT_SET), v) - ) { - allEqual = false; - return false; - } - }); - - return allEqual && a.size === bSize; - } - - /** - * Contributes additional methods to a constructor - */ - function mixin(ctor, methods) { - var keyCopier = function (key) { - ctor.prototype[key] = methods[key]; - }; - Object.keys(methods).forEach(keyCopier); - // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here - Object.getOwnPropertySymbols && - Object.getOwnPropertySymbols(methods).forEach(keyCopier); - return ctor; - } - - function toJS(value) { - if (!value || typeof value !== 'object') { - return value; - } - if (!isCollection(value)) { - if (!isDataStructure(value)) { + function toJS(value) { + if (!value || typeof value !== 'object') { return value; } - value = Seq(value); - } - if (isKeyed(value)) { - var result$1 = {}; - value.__iterate(function (v, k) { - result$1[k] = toJS(v); + if (!isCollection(value)) { + if (!isDataStructure(value)) { + return value; + } + value = Seq(value); + } + if (isKeyed(value)) { + var result$1 = {}; + value.__iterate(function (v, k) { + result$1[k] = toJS(v); + }); + return result$1; + } + var result = []; + value.__iterate(function (v) { + result.push(toJS(v)); }); - return result$1; + return result; } - var result = []; - value.__iterate(function (v) { - result.push(toJS(v)); - }); - return result; - } - var Set = /*@__PURE__*/(function (SetCollection) { - function Set(value) { - // eslint-disable-next-line no-constructor-return - return value === undefined || value === null - ? emptySet() - : isSet(value) && !isOrdered(value) - ? value - : emptySet().withMutations(function (set) { - var iter = SetCollection(value); - assertNotInfinite(iter.size); - iter.forEach(function (v) { return set.add(v); }); - }); - } - - if ( SetCollection ) Set.__proto__ = SetCollection; - Set.prototype = Object.create( SetCollection && SetCollection.prototype ); - Set.prototype.constructor = Set; - - Set.of = function of (/*...values*/) { - return this(arguments); - }; + var Set = /*@__PURE__*/(function (SetCollection) { + function Set(value) { + // eslint-disable-next-line no-constructor-return + return value === undefined || value === null + ? emptySet() + : isSet(value) && !isOrdered(value) + ? value + : emptySet().withMutations(function (set) { + var iter = SetCollection(value); + assertNotInfinite(iter.size); + iter.forEach(function (v) { return set.add(v); }); + }); + } + + if ( SetCollection ) Set.__proto__ = SetCollection; + Set.prototype = Object.create( SetCollection && SetCollection.prototype ); + Set.prototype.constructor = Set; + + Set.of = function of (/*...values*/) { + return this(arguments); + }; - Set.fromKeys = function fromKeys (value) { - return this(KeyedCollection(value).keySeq()); - }; + Set.fromKeys = function fromKeys (value) { + return this(KeyedCollection(value).keySeq()); + }; - Set.intersect = function intersect (sets) { - sets = Collection(sets).toArray(); - return sets.length - ? SetPrototype.intersect.apply(Set(sets.pop()), sets) - : emptySet(); - }; + Set.intersect = function intersect (sets) { + sets = Collection(sets).toArray(); + return sets.length + ? SetPrototype.intersect.apply(Set(sets.pop()), sets) + : emptySet(); + }; - Set.union = function union (sets) { - sets = Collection(sets).toArray(); - return sets.length - ? SetPrototype.union.apply(Set(sets.pop()), sets) - : emptySet(); - }; + Set.union = function union (sets) { + sets = Collection(sets).toArray(); + return sets.length + ? SetPrototype.union.apply(Set(sets.pop()), sets) + : emptySet(); + }; - Set.prototype.toString = function toString () { - return this.__toString('Set {', '}'); - }; + Set.prototype.toString = function toString () { + return this.__toString('Set {', '}'); + }; - // @pragma Access + // @pragma Access - Set.prototype.has = function has (value) { - return this._map.has(value); - }; + Set.prototype.has = function has (value) { + return this._map.has(value); + }; - // @pragma Modification + // @pragma Modification - Set.prototype.add = function add (value) { - return updateSet(this, this._map.set(value, value)); - }; + Set.prototype.add = function add (value) { + return updateSet(this, this._map.set(value, value)); + }; - Set.prototype.remove = function remove (value) { - return updateSet(this, this._map.remove(value)); - }; + Set.prototype.remove = function remove (value) { + return updateSet(this, this._map.remove(value)); + }; - Set.prototype.clear = function clear () { - return updateSet(this, this._map.clear()); - }; + Set.prototype.clear = function clear () { + return updateSet(this, this._map.clear()); + }; - // @pragma Composition + // @pragma Composition - Set.prototype.map = function map (mapper, context) { - var this$1$1 = this; + Set.prototype.map = function map (mapper, context) { + var this$1$1 = this; - // keep track if the set is altered by the map function - var didChanges = false; + // keep track if the set is altered by the map function + var didChanges = false; - var newMap = updateSet( - this, - this._map.mapEntries(function (ref) { - var v = ref[1]; + var newMap = updateSet( + this, + this._map.mapEntries(function (ref) { + var v = ref[1]; - var mapped = mapper.call(context, v, v, this$1$1); + var mapped = mapper.call(context, v, v, this$1$1); - if (mapped !== v) { - didChanges = true; - } + if (mapped !== v) { + didChanges = true; + } - return [mapped, mapped]; - }, context) - ); + return [mapped, mapped]; + }, context) + ); - return didChanges ? newMap : this; - }; + return didChanges ? newMap : this; + }; - Set.prototype.union = function union () { - var iters = [], len = arguments.length; - while ( len-- ) iters[ len ] = arguments[ len ]; + Set.prototype.union = function union () { + var iters = [], len = arguments.length; + while ( len-- ) iters[ len ] = arguments[ len ]; - iters = iters.filter(function (x) { return x.size !== 0; }); - if (iters.length === 0) { - return this; - } - if (this.size === 0 && !this.__ownerID && iters.length === 1) { - return this.constructor(iters[0]); - } - return this.withMutations(function (set) { - for (var ii = 0; ii < iters.length; ii++) { - if (typeof iters[ii] === 'string') { - set.add(iters[ii]); - } else { - SetCollection(iters[ii]).forEach(function (value) { return set.add(value); }); - } + iters = iters.filter(function (x) { return x.size !== 0; }); + if (iters.length === 0) { + return this; } - }); - }; + if (this.size === 0 && !this.__ownerID && iters.length === 1) { + return this.constructor(iters[0]); + } + return this.withMutations(function (set) { + for (var ii = 0; ii < iters.length; ii++) { + if (typeof iters[ii] === 'string') { + set.add(iters[ii]); + } else { + SetCollection(iters[ii]).forEach(function (value) { return set.add(value); }); + } + } + }); + }; - Set.prototype.intersect = function intersect () { - var iters = [], len = arguments.length; - while ( len-- ) iters[ len ] = arguments[ len ]; + Set.prototype.intersect = function intersect () { + var iters = [], len = arguments.length; + while ( len-- ) iters[ len ] = arguments[ len ]; - if (iters.length === 0) { - return this; - } - iters = iters.map(function (iter) { return SetCollection(iter); }); - var toRemove = []; - this.forEach(function (value) { - if (!iters.every(function (iter) { return iter.includes(value); })) { - toRemove.push(value); + if (iters.length === 0) { + return this; } - }); - return this.withMutations(function (set) { - toRemove.forEach(function (value) { - set.remove(value); + iters = iters.map(function (iter) { return SetCollection(iter); }); + var toRemove = []; + this.forEach(function (value) { + if (!iters.every(function (iter) { return iter.includes(value); })) { + toRemove.push(value); + } }); - }); - }; + return this.withMutations(function (set) { + toRemove.forEach(function (value) { + set.remove(value); + }); + }); + }; - Set.prototype.subtract = function subtract () { - var iters = [], len = arguments.length; - while ( len-- ) iters[ len ] = arguments[ len ]; + Set.prototype.subtract = function subtract () { + var iters = [], len = arguments.length; + while ( len-- ) iters[ len ] = arguments[ len ]; - if (iters.length === 0) { - return this; - } - iters = iters.map(function (iter) { return SetCollection(iter); }); - var toRemove = []; - this.forEach(function (value) { - if (iters.some(function (iter) { return iter.includes(value); })) { - toRemove.push(value); + if (iters.length === 0) { + return this; } - }); - return this.withMutations(function (set) { - toRemove.forEach(function (value) { - set.remove(value); + iters = iters.map(function (iter) { return SetCollection(iter); }); + var toRemove = []; + this.forEach(function (value) { + if (iters.some(function (iter) { return iter.includes(value); })) { + toRemove.push(value); + } }); - }); - }; + return this.withMutations(function (set) { + toRemove.forEach(function (value) { + set.remove(value); + }); + }); + }; - Set.prototype.sort = function sort (comparator) { - // Late binding - return OrderedSet(sortFactory(this, comparator)); - }; + Set.prototype.sort = function sort (comparator) { + // Late binding + return OrderedSet(sortFactory(this, comparator)); + }; - Set.prototype.sortBy = function sortBy (mapper, comparator) { - // Late binding - return OrderedSet(sortFactory(this, comparator, mapper)); - }; + Set.prototype.sortBy = function sortBy (mapper, comparator) { + // Late binding + return OrderedSet(sortFactory(this, comparator, mapper)); + }; - Set.prototype.wasAltered = function wasAltered () { - return this._map.wasAltered(); - }; + Set.prototype.wasAltered = function wasAltered () { + return this._map.wasAltered(); + }; - Set.prototype.__iterate = function __iterate (fn, reverse) { - var this$1$1 = this; + Set.prototype.__iterate = function __iterate (fn, reverse) { + var this$1$1 = this; - return this._map.__iterate(function (k) { return fn(k, k, this$1$1); }, reverse); - }; + return this._map.__iterate(function (k) { return fn(k, k, this$1$1); }, reverse); + }; - Set.prototype.__iterator = function __iterator (type, reverse) { - return this._map.__iterator(type, reverse); - }; + Set.prototype.__iterator = function __iterator (type, reverse) { + return this._map.__iterator(type, reverse); + }; - Set.prototype.__ensureOwner = function __ensureOwner (ownerID) { - if (ownerID === this.__ownerID) { - return this; - } - var newMap = this._map.__ensureOwner(ownerID); - if (!ownerID) { - if (this.size === 0) { - return this.__empty(); + Set.prototype.__ensureOwner = function __ensureOwner (ownerID) { + if (ownerID === this.__ownerID) { + return this; } - this.__ownerID = ownerID; - this._map = newMap; - return this; - } - return this.__make(newMap, ownerID); + var newMap = this._map.__ensureOwner(ownerID); + if (!ownerID) { + if (this.size === 0) { + return this.__empty(); + } + this.__ownerID = ownerID; + this._map = newMap; + return this; + } + return this.__make(newMap, ownerID); + }; + + return Set; + }(SetCollection)); + + Set.isSet = isSet; + + var SetPrototype = Set.prototype; + SetPrototype[IS_SET_SYMBOL] = true; + SetPrototype[DELETE] = SetPrototype.remove; + SetPrototype.merge = SetPrototype.concat = SetPrototype.union; + SetPrototype.withMutations = withMutations; + SetPrototype.asImmutable = asImmutable; + SetPrototype['@@transducer/init'] = SetPrototype.asMutable = asMutable; + SetPrototype['@@transducer/step'] = function (result, arr) { + return result.add(arr); }; + SetPrototype['@@transducer/result'] = function (obj) { + return obj.asImmutable(); + }; + + SetPrototype.__empty = emptySet; + SetPrototype.__make = makeSet; + + function updateSet(set, newMap) { + if (set.__ownerID) { + set.size = newMap.size; + set._map = newMap; + return set; + } + return newMap === set._map + ? set + : newMap.size === 0 + ? set.__empty() + : set.__make(newMap); + } - return Set; - }(SetCollection)); - - Set.isSet = isSet; - - var SetPrototype = Set.prototype; - SetPrototype[IS_SET_SYMBOL] = true; - SetPrototype[DELETE] = SetPrototype.remove; - SetPrototype.merge = SetPrototype.concat = SetPrototype.union; - SetPrototype.withMutations = withMutations; - SetPrototype.asImmutable = asImmutable; - SetPrototype['@@transducer/init'] = SetPrototype.asMutable = asMutable; - SetPrototype['@@transducer/step'] = function (result, arr) { - return result.add(arr); - }; - SetPrototype['@@transducer/result'] = function (obj) { - return obj.asImmutable(); - }; - - SetPrototype.__empty = emptySet; - SetPrototype.__make = makeSet; - - function updateSet(set, newMap) { - if (set.__ownerID) { - set.size = newMap.size; - set._map = newMap; + function makeSet(map, ownerID) { + var set = Object.create(SetPrototype); + set.size = map ? map.size : 0; + set._map = map; + set.__ownerID = ownerID; return set; } - return newMap === set._map - ? set - : newMap.size === 0 - ? set.__empty() - : set.__make(newMap); - } - - function makeSet(map, ownerID) { - var set = Object.create(SetPrototype); - set.size = map ? map.size : 0; - set._map = map; - set.__ownerID = ownerID; - return set; - } - - var EMPTY_SET; - function emptySet() { - return EMPTY_SET || (EMPTY_SET = makeSet(emptyMap())); - } - - /** - * Returns a lazy seq of nums from start (inclusive) to end - * (exclusive), by step, where start defaults to 0, step to 1, and end to - * infinity. When start is equal to end, returns empty list. - */ - var Range = /*@__PURE__*/(function (IndexedSeq) { - function Range(start, end, step) { - if ( step === void 0 ) step = 1; - - if (!(this instanceof Range)) { - // eslint-disable-next-line no-constructor-return - return new Range(start, end, step); - } - invariant(step !== 0, 'Cannot step a Range by 0'); - invariant( - start !== undefined, - 'You must define a start value when using Range' - ); - invariant( - end !== undefined, - 'You must define an end value when using Range' - ); - step = Math.abs(step); - if (end < start) { - step = -step; - } - this._start = start; - this._end = end; - this._step = step; - this.size = Math.max(0, Math.ceil((end - start) / step - 1) + 1); - if (this.size === 0) { - if (EMPTY_RANGE) { + var EMPTY_SET; + function emptySet() { + return EMPTY_SET || (EMPTY_SET = makeSet(emptyMap())); + } + + /** + * Returns a lazy seq of nums from start (inclusive) to end + * (exclusive), by step, where start defaults to 0, step to 1, and end to + * infinity. When start is equal to end, returns empty list. + */ + var Range = /*@__PURE__*/(function (IndexedSeq) { + function Range(start, end, step) { + if ( step === void 0 ) step = 1; + + if (!(this instanceof Range)) { // eslint-disable-next-line no-constructor-return - return EMPTY_RANGE; + return new Range(start, end, step); + } + invariant(step !== 0, 'Cannot step a Range by 0'); + invariant( + start !== undefined, + 'You must define a start value when using Range' + ); + invariant( + end !== undefined, + 'You must define an end value when using Range' + ); + + step = Math.abs(step); + if (end < start) { + step = -step; + } + this._start = start; + this._end = end; + this._step = step; + this.size = Math.max(0, Math.ceil((end - start) / step - 1) + 1); + if (this.size === 0) { + if (EMPTY_RANGE) { + // eslint-disable-next-line no-constructor-return + return EMPTY_RANGE; + } + // eslint-disable-next-line @typescript-eslint/no-this-alias + EMPTY_RANGE = this; } - // eslint-disable-next-line @typescript-eslint/no-this-alias - EMPTY_RANGE = this; } - } - if ( IndexedSeq ) Range.__proto__ = IndexedSeq; - Range.prototype = Object.create( IndexedSeq && IndexedSeq.prototype ); - Range.prototype.constructor = Range; + if ( IndexedSeq ) Range.__proto__ = IndexedSeq; + Range.prototype = Object.create( IndexedSeq && IndexedSeq.prototype ); + Range.prototype.constructor = Range; - Range.prototype.toString = function toString () { - if (this.size === 0) { - return 'Range []'; - } - return ( - 'Range [ ' + - this._start + - '...' + - this._end + - (this._step !== 1 ? ' by ' + this._step : '') + - ' ]' - ); - }; + Range.prototype.toString = function toString () { + if (this.size === 0) { + return 'Range []'; + } + return ( + 'Range [ ' + + this._start + + '...' + + this._end + + (this._step !== 1 ? ' by ' + this._step : '') + + ' ]' + ); + }; - Range.prototype.get = function get (index, notSetValue) { - return this.has(index) - ? this._start + wrapIndex(this, index) * this._step - : notSetValue; - }; + Range.prototype.get = function get (index, notSetValue) { + return this.has(index) + ? this._start + wrapIndex(this, index) * this._step + : notSetValue; + }; - Range.prototype.includes = function includes (searchValue) { - var possibleIndex = (searchValue - this._start) / this._step; - return ( - possibleIndex >= 0 && - possibleIndex < this.size && - possibleIndex === Math.floor(possibleIndex) - ); - }; + Range.prototype.includes = function includes (searchValue) { + var possibleIndex = (searchValue - this._start) / this._step; + return ( + possibleIndex >= 0 && + possibleIndex < this.size && + possibleIndex === Math.floor(possibleIndex) + ); + }; - Range.prototype.slice = function slice (begin, end) { - if (wholeSlice(begin, end, this.size)) { - return this; - } - begin = resolveBegin(begin, this.size); - end = resolveEnd(end, this.size); - if (end <= begin) { - return new Range(0, 0); - } - return new Range( - this.get(begin, this._end), - this.get(end, this._end), - this._step - ); - }; + Range.prototype.slice = function slice (begin, end) { + if (wholeSlice(begin, end, this.size)) { + return this; + } + begin = resolveBegin(begin, this.size); + end = resolveEnd(end, this.size); + if (end <= begin) { + return new Range(0, 0); + } + return new Range( + this.get(begin, this._end), + this.get(end, this._end), + this._step + ); + }; - Range.prototype.indexOf = function indexOf (searchValue) { - var offsetValue = searchValue - this._start; - if (offsetValue % this._step === 0) { - var index = offsetValue / this._step; - if (index >= 0 && index < this.size) { - return index; + Range.prototype.indexOf = function indexOf (searchValue) { + var offsetValue = searchValue - this._start; + if (offsetValue % this._step === 0) { + var index = offsetValue / this._step; + if (index >= 0 && index < this.size) { + return index; + } } - } - return -1; - }; + return -1; + }; - Range.prototype.lastIndexOf = function lastIndexOf (searchValue) { - return this.indexOf(searchValue); - }; + Range.prototype.lastIndexOf = function lastIndexOf (searchValue) { + return this.indexOf(searchValue); + }; - Range.prototype.__iterate = function __iterate (fn, reverse) { - var size = this.size; - var step = this._step; - var value = reverse ? this._start + (size - 1) * step : this._start; - var i = 0; - while (i !== size) { - if (fn(value, reverse ? size - ++i : i++, this) === false) { - break; + Range.prototype.__iterate = function __iterate (fn, reverse) { + var size = this.size; + var step = this._step; + var value = reverse ? this._start + (size - 1) * step : this._start; + var i = 0; + while (i !== size) { + if (fn(value, reverse ? size - ++i : i++, this) === false) { + break; + } + value += reverse ? -step : step; } - value += reverse ? -step : step; - } - return i; - }; + return i; + }; + + Range.prototype.__iterator = function __iterator (type, reverse) { + var size = this.size; + var step = this._step; + var value = reverse ? this._start + (size - 1) * step : this._start; + var i = 0; + return new Iterator(function () { + if (i === size) { + return iteratorDone(); + } + var v = value; + value += reverse ? -step : step; + return iteratorValue(type, reverse ? size - ++i : i++, v); + }); + }; + + Range.prototype.equals = function equals (other) { + return other instanceof Range + ? this._start === other._start && + this._end === other._end && + this._step === other._step + : deepEqual(this, other); + }; - Range.prototype.__iterator = function __iterator (type, reverse) { - var size = this.size; - var step = this._step; - var value = reverse ? this._start + (size - 1) * step : this._start; + return Range; + }(IndexedSeq)); + + var EMPTY_RANGE; + + function getIn$1(collection, searchKeyPath, notSetValue) { + var keyPath = coerceKeyPath(searchKeyPath); var i = 0; - return new Iterator(function () { - if (i === size) { - return iteratorDone(); + while (i !== keyPath.length) { + collection = get(collection, keyPath[i++], NOT_SET); + if (collection === NOT_SET) { + return notSetValue; } - var v = value; - value += reverse ? -step : step; - return iteratorValue(type, reverse ? size - ++i : i++, v); + } + return collection; + } + + function getIn(searchKeyPath, notSetValue) { + return getIn$1(this, searchKeyPath, notSetValue); + } + + function hasIn$1(collection, keyPath) { + return getIn$1(collection, keyPath, NOT_SET) !== NOT_SET; + } + + function hasIn(searchKeyPath) { + return hasIn$1(this, searchKeyPath); + } + + function toObject() { + assertNotInfinite(this.size); + var object = {}; + this.__iterate(function (v, k) { + object[k] = v; }); - }; + return object; + } + + Collection.Iterator = Iterator; + + mixin(Collection, { + // ### Conversion to other types + + toArray: function toArray() { + assertNotInfinite(this.size); + var array = new Array(this.size || 0); + var useTuples = isKeyed(this); + var i = 0; + this.__iterate(function (v, k) { + // Keyed collections produce an array of tuples. + array[i++] = useTuples ? [k, v] : v; + }); + return array; + }, + + toIndexedSeq: function toIndexedSeq() { + return new ToIndexedSequence(this); + }, + + toJS: function toJS$1() { + return toJS(this); + }, + + toKeyedSeq: function toKeyedSeq() { + return new ToKeyedSequence(this, true); + }, + + toMap: function toMap() { + // Use Late Binding here to solve the circular dependency. + return Map(this.toKeyedSeq()); + }, + + toObject: toObject, + + toOrderedMap: function toOrderedMap() { + // Use Late Binding here to solve the circular dependency. + return OrderedMap(this.toKeyedSeq()); + }, + + toOrderedSet: function toOrderedSet() { + // Use Late Binding here to solve the circular dependency. + return OrderedSet(isKeyed(this) ? this.valueSeq() : this); + }, + + toSet: function toSet() { + // Use Late Binding here to solve the circular dependency. + return Set(isKeyed(this) ? this.valueSeq() : this); + }, + + toSetSeq: function toSetSeq() { + return new ToSetSequence(this); + }, + + toSeq: function toSeq() { + return isIndexed(this) + ? this.toIndexedSeq() + : isKeyed(this) + ? this.toKeyedSeq() + : this.toSetSeq(); + }, + + toStack: function toStack() { + // Use Late Binding here to solve the circular dependency. + return Stack(isKeyed(this) ? this.valueSeq() : this); + }, + + toList: function toList() { + // Use Late Binding here to solve the circular dependency. + return List(isKeyed(this) ? this.valueSeq() : this); + }, + + // ### Common JavaScript methods and properties + + toString: function toString() { + return '[Collection]'; + }, + + __toString: function __toString(head, tail) { + if (this.size === 0) { + return head + tail; + } + return ( + head + + ' ' + + this.toSeq().map(this.__toStringMapper).join(', ') + + ' ' + + tail + ); + }, + + // ### ES6 Collection methods (ES6 Array and Map) + + concat: function concat() { + var values = [], len = arguments.length; + while ( len-- ) values[ len ] = arguments[ len ]; + + return reify(this, concatFactory(this, values)); + }, + + includes: function includes(searchValue) { + return this.some(function (value) { return is(value, searchValue); }); + }, + + entries: function entries() { + return this.__iterator(ITERATE_ENTRIES); + }, + + every: function every(predicate, context) { + assertNotInfinite(this.size); + var returnValue = true; + this.__iterate(function (v, k, c) { + if (!predicate.call(context, v, k, c)) { + returnValue = false; + return false; + } + }); + return returnValue; + }, + + filter: function filter(predicate, context) { + return reify(this, filterFactory(this, predicate, context, true)); + }, + + partition: function partition(predicate, context) { + return partitionFactory(this, predicate, context); + }, + + find: function find(predicate, context, notSetValue) { + var entry = this.findEntry(predicate, context); + return entry ? entry[1] : notSetValue; + }, + + forEach: function forEach(sideEffect, context) { + assertNotInfinite(this.size); + return this.__iterate(context ? sideEffect.bind(context) : sideEffect); + }, + + join: function join(separator) { + assertNotInfinite(this.size); + separator = separator !== undefined ? '' + separator : ','; + var joined = ''; + var isFirst = true; + this.__iterate(function (v) { + // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here + isFirst ? (isFirst = false) : (joined += separator); + joined += v !== null && v !== undefined ? v.toString() : ''; + }); + return joined; + }, + + keys: function keys() { + return this.__iterator(ITERATE_KEYS); + }, + + map: function map(mapper, context) { + return reify(this, mapFactory(this, mapper, context)); + }, + + reduce: function reduce$1(reducer, initialReduction, context) { + return reduce( + this, + reducer, + initialReduction, + context, + arguments.length < 2, + false + ); + }, + + reduceRight: function reduceRight(reducer, initialReduction, context) { + return reduce( + this, + reducer, + initialReduction, + context, + arguments.length < 2, + true + ); + }, + + reverse: function reverse() { + return reify(this, reverseFactory(this, true)); + }, + + slice: function slice(begin, end) { + return reify(this, sliceFactory(this, begin, end, true)); + }, + + some: function some(predicate, context) { + assertNotInfinite(this.size); + var returnValue = false; + this.__iterate(function (v, k, c) { + if (predicate.call(context, v, k, c)) { + returnValue = true; + return false; + } + }); + return returnValue; + }, + + sort: function sort(comparator) { + return reify(this, sortFactory(this, comparator)); + }, + + values: function values() { + return this.__iterator(ITERATE_VALUES); + }, + + // ### More sequential methods + + butLast: function butLast() { + return this.slice(0, -1); + }, + + isEmpty: function isEmpty() { + return this.size !== undefined ? this.size === 0 : !this.some(function () { return true; }); + }, + + count: function count(predicate, context) { + return ensureSize( + predicate ? this.toSeq().filter(predicate, context) : this + ); + }, - Range.prototype.equals = function equals (other) { - return other instanceof Range - ? this._start === other._start && - this._end === other._end && - this._step === other._step - : deepEqual(this, other); - }; + countBy: function countBy(grouper, context) { + return countByFactory(this, grouper, context); + }, - return Range; - }(IndexedSeq)); + equals: function equals(other) { + return deepEqual(this, other); + }, - var EMPTY_RANGE; + entrySeq: function entrySeq() { + // eslint-disable-next-line @typescript-eslint/no-this-alias + var collection = this; + if (collection._cache) { + // We cache as an entries array, so we can just return the cache! + return new ArraySeq(collection._cache); + } + var entriesSequence = collection.toSeq().map(entryMapper).toIndexedSeq(); + entriesSequence.fromEntrySeq = function () { return collection.toSeq(); }; + return entriesSequence; + }, + + filterNot: function filterNot(predicate, context) { + return this.filter(not(predicate), context); + }, + + findEntry: function findEntry(predicate, context, notSetValue) { + var found = notSetValue; + this.__iterate(function (v, k, c) { + if (predicate.call(context, v, k, c)) { + found = [k, v]; + return false; + } + }); + return found; + }, - function getIn$1(collection, searchKeyPath, notSetValue) { - var keyPath = coerceKeyPath(searchKeyPath); - var i = 0; - while (i !== keyPath.length) { - collection = get(collection, keyPath[i++], NOT_SET); - if (collection === NOT_SET) { - return notSetValue; - } - } - return collection; - } + findKey: function findKey(predicate, context) { + var entry = this.findEntry(predicate, context); + return entry && entry[0]; + }, - function getIn(searchKeyPath, notSetValue) { - return getIn$1(this, searchKeyPath, notSetValue); - } + findLast: function findLast(predicate, context, notSetValue) { + return this.toKeyedSeq().reverse().find(predicate, context, notSetValue); + }, - function hasIn$1(collection, keyPath) { - return getIn$1(collection, keyPath, NOT_SET) !== NOT_SET; - } + findLastEntry: function findLastEntry(predicate, context, notSetValue) { + return this.toKeyedSeq() + .reverse() + .findEntry(predicate, context, notSetValue); + }, - function hasIn(searchKeyPath) { - return hasIn$1(this, searchKeyPath); - } + findLastKey: function findLastKey(predicate, context) { + return this.toKeyedSeq().reverse().findKey(predicate, context); + }, - function toObject() { - assertNotInfinite(this.size); - var object = {}; - this.__iterate(function (v, k) { - object[k] = v; - }); - return object; - } + first: function first(notSetValue) { + return this.find(returnTrue, null, notSetValue); + }, - Collection.Iterator = Iterator; + flatMap: function flatMap(mapper, context) { + return reify(this, flatMapFactory(this, mapper, context)); + }, - mixin(Collection, { - // ### Conversion to other types + flatten: function flatten(depth) { + return reify(this, flattenFactory(this, depth, true)); + }, - toArray: function toArray() { - assertNotInfinite(this.size); - var array = new Array(this.size || 0); - var useTuples = isKeyed(this); - var i = 0; - this.__iterate(function (v, k) { - // Keyed collections produce an array of tuples. - array[i++] = useTuples ? [k, v] : v; - }); - return array; - }, + fromEntrySeq: function fromEntrySeq() { + return new FromEntriesSequence(this); + }, - toIndexedSeq: function toIndexedSeq() { - return new ToIndexedSequence(this); - }, + get: function get(searchKey, notSetValue) { + return this.find(function (_, key) { return is(key, searchKey); }, undefined, notSetValue); + }, - toJS: function toJS$1() { - return toJS(this); - }, - - toKeyedSeq: function toKeyedSeq() { - return new ToKeyedSequence(this, true); - }, - - toMap: function toMap() { - // Use Late Binding here to solve the circular dependency. - return Map(this.toKeyedSeq()); - }, - - toObject: toObject, - - toOrderedMap: function toOrderedMap() { - // Use Late Binding here to solve the circular dependency. - return OrderedMap(this.toKeyedSeq()); - }, - - toOrderedSet: function toOrderedSet() { - // Use Late Binding here to solve the circular dependency. - return OrderedSet(isKeyed(this) ? this.valueSeq() : this); - }, - - toSet: function toSet() { - // Use Late Binding here to solve the circular dependency. - return Set(isKeyed(this) ? this.valueSeq() : this); - }, - - toSetSeq: function toSetSeq() { - return new ToSetSequence(this); - }, - - toSeq: function toSeq() { - return isIndexed(this) - ? this.toIndexedSeq() - : isKeyed(this) - ? this.toKeyedSeq() - : this.toSetSeq(); - }, - - toStack: function toStack() { - // Use Late Binding here to solve the circular dependency. - return Stack(isKeyed(this) ? this.valueSeq() : this); - }, - - toList: function toList() { - // Use Late Binding here to solve the circular dependency. - return List(isKeyed(this) ? this.valueSeq() : this); - }, - - // ### Common JavaScript methods and properties - - toString: function toString() { - return '[Collection]'; - }, - - __toString: function __toString(head, tail) { - if (this.size === 0) { - return head + tail; - } - return ( - head + - ' ' + - this.toSeq().map(this.__toStringMapper).join(', ') + - ' ' + - tail - ); - }, + getIn: getIn, - // ### ES6 Collection methods (ES6 Array and Map) + groupBy: function groupBy(grouper, context) { + return groupByFactory(this, grouper, context); + }, - concat: function concat() { - var values = [], len = arguments.length; - while ( len-- ) values[ len ] = arguments[ len ]; + has: function has(searchKey) { + return this.get(searchKey, NOT_SET) !== NOT_SET; + }, - return reify(this, concatFactory(this, values)); - }, + hasIn: hasIn, - includes: function includes(searchValue) { - return this.some(function (value) { return is(value, searchValue); }); - }, + isSubset: function isSubset(iter) { + iter = typeof iter.includes === 'function' ? iter : Collection(iter); + return this.every(function (value) { return iter.includes(value); }); + }, - entries: function entries() { - return this.__iterator(ITERATE_ENTRIES); - }, + isSuperset: function isSuperset(iter) { + iter = typeof iter.isSubset === 'function' ? iter : Collection(iter); + return iter.isSubset(this); + }, - every: function every(predicate, context) { - assertNotInfinite(this.size); - var returnValue = true; - this.__iterate(function (v, k, c) { - if (!predicate.call(context, v, k, c)) { - returnValue = false; - return false; - } - }); - return returnValue; - }, + keyOf: function keyOf(searchValue) { + return this.findKey(function (value) { return is(value, searchValue); }); + }, - filter: function filter(predicate, context) { - return reify(this, filterFactory(this, predicate, context, true)); - }, + keySeq: function keySeq() { + return this.toSeq().map(keyMapper).toIndexedSeq(); + }, - partition: function partition(predicate, context) { - return partitionFactory(this, predicate, context); - }, + last: function last(notSetValue) { + return this.toSeq().reverse().first(notSetValue); + }, - find: function find(predicate, context, notSetValue) { - var entry = this.findEntry(predicate, context); - return entry ? entry[1] : notSetValue; - }, + lastKeyOf: function lastKeyOf(searchValue) { + return this.toKeyedSeq().reverse().keyOf(searchValue); + }, - forEach: function forEach(sideEffect, context) { - assertNotInfinite(this.size); - return this.__iterate(context ? sideEffect.bind(context) : sideEffect); - }, + max: function max(comparator) { + return maxFactory(this, comparator); + }, - join: function join(separator) { - assertNotInfinite(this.size); - separator = separator !== undefined ? '' + separator : ','; - var joined = ''; - var isFirst = true; - this.__iterate(function (v) { - // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here - isFirst ? (isFirst = false) : (joined += separator); - joined += v !== null && v !== undefined ? v.toString() : ''; - }); - return joined; - }, - - keys: function keys() { - return this.__iterator(ITERATE_KEYS); - }, - - map: function map(mapper, context) { - return reify(this, mapFactory(this, mapper, context)); - }, - - reduce: function reduce$1(reducer, initialReduction, context) { - return reduce( - this, - reducer, - initialReduction, - context, - arguments.length < 2, - false - ); - }, - - reduceRight: function reduceRight(reducer, initialReduction, context) { - return reduce( - this, - reducer, - initialReduction, - context, - arguments.length < 2, - true - ); - }, + maxBy: function maxBy(mapper, comparator) { + return maxFactory(this, comparator, mapper); + }, - reverse: function reverse() { - return reify(this, reverseFactory(this, true)); - }, + min: function min(comparator) { + return maxFactory( + this, + comparator ? neg(comparator) : defaultNegComparator + ); + }, - slice: function slice(begin, end) { - return reify(this, sliceFactory(this, begin, end, true)); - }, + minBy: function minBy(mapper, comparator) { + return maxFactory( + this, + comparator ? neg(comparator) : defaultNegComparator, + mapper + ); + }, - some: function some(predicate, context) { - assertNotInfinite(this.size); - var returnValue = false; - this.__iterate(function (v, k, c) { - if (predicate.call(context, v, k, c)) { - returnValue = true; - return false; - } - }); - return returnValue; - }, + rest: function rest() { + return this.slice(1); + }, - sort: function sort(comparator) { - return reify(this, sortFactory(this, comparator)); - }, + skip: function skip(amount) { + return amount === 0 ? this : this.slice(Math.max(0, amount)); + }, - values: function values() { - return this.__iterator(ITERATE_VALUES); - }, + skipLast: function skipLast(amount) { + return amount === 0 ? this : this.slice(0, -Math.max(0, amount)); + }, - // ### More sequential methods + skipWhile: function skipWhile(predicate, context) { + return reify(this, skipWhileFactory(this, predicate, context, true)); + }, - butLast: function butLast() { - return this.slice(0, -1); - }, + skipUntil: function skipUntil(predicate, context) { + return this.skipWhile(not(predicate), context); + }, - isEmpty: function isEmpty() { - return this.size !== undefined ? this.size === 0 : !this.some(function () { return true; }); - }, + sortBy: function sortBy(mapper, comparator) { + return reify(this, sortFactory(this, comparator, mapper)); + }, - count: function count(predicate, context) { - return ensureSize( - predicate ? this.toSeq().filter(predicate, context) : this - ); - }, - - countBy: function countBy(grouper, context) { - return countByFactory(this, grouper, context); - }, - - equals: function equals(other) { - return deepEqual(this, other); - }, - - entrySeq: function entrySeq() { - // eslint-disable-next-line @typescript-eslint/no-this-alias - var collection = this; - if (collection._cache) { - // We cache as an entries array, so we can just return the cache! - return new ArraySeq(collection._cache); - } - var entriesSequence = collection.toSeq().map(entryMapper).toIndexedSeq(); - entriesSequence.fromEntrySeq = function () { return collection.toSeq(); }; - return entriesSequence; - }, - - filterNot: function filterNot(predicate, context) { - return this.filter(not(predicate), context); - }, - - findEntry: function findEntry(predicate, context, notSetValue) { - var found = notSetValue; - this.__iterate(function (v, k, c) { - if (predicate.call(context, v, k, c)) { - found = [k, v]; - return false; - } - }); - return found; - }, - - findKey: function findKey(predicate, context) { - var entry = this.findEntry(predicate, context); - return entry && entry[0]; - }, - - findLast: function findLast(predicate, context, notSetValue) { - return this.toKeyedSeq().reverse().find(predicate, context, notSetValue); - }, - - findLastEntry: function findLastEntry(predicate, context, notSetValue) { - return this.toKeyedSeq() - .reverse() - .findEntry(predicate, context, notSetValue); - }, - - findLastKey: function findLastKey(predicate, context) { - return this.toKeyedSeq().reverse().findKey(predicate, context); - }, - - first: function first(notSetValue) { - return this.find(returnTrue, null, notSetValue); - }, - - flatMap: function flatMap(mapper, context) { - return reify(this, flatMapFactory(this, mapper, context)); - }, - - flatten: function flatten(depth) { - return reify(this, flattenFactory(this, depth, true)); - }, - - fromEntrySeq: function fromEntrySeq() { - return new FromEntriesSequence(this); - }, - - get: function get(searchKey, notSetValue) { - return this.find(function (_, key) { return is(key, searchKey); }, undefined, notSetValue); - }, - - getIn: getIn, - - groupBy: function groupBy(grouper, context) { - return groupByFactory(this, grouper, context); - }, - - has: function has(searchKey) { - return this.get(searchKey, NOT_SET) !== NOT_SET; - }, - - hasIn: hasIn, - - isSubset: function isSubset(iter) { - iter = typeof iter.includes === 'function' ? iter : Collection(iter); - return this.every(function (value) { return iter.includes(value); }); - }, - - isSuperset: function isSuperset(iter) { - iter = typeof iter.isSubset === 'function' ? iter : Collection(iter); - return iter.isSubset(this); - }, - - keyOf: function keyOf(searchValue) { - return this.findKey(function (value) { return is(value, searchValue); }); - }, - - keySeq: function keySeq() { - return this.toSeq().map(keyMapper).toIndexedSeq(); - }, - - last: function last(notSetValue) { - return this.toSeq().reverse().first(notSetValue); - }, - - lastKeyOf: function lastKeyOf(searchValue) { - return this.toKeyedSeq().reverse().keyOf(searchValue); - }, - - max: function max(comparator) { - return maxFactory(this, comparator); - }, - - maxBy: function maxBy(mapper, comparator) { - return maxFactory(this, comparator, mapper); - }, - - min: function min(comparator) { - return maxFactory( - this, - comparator ? neg(comparator) : defaultNegComparator - ); - }, + take: function take(amount) { + return this.slice(0, Math.max(0, amount)); + }, - minBy: function minBy(mapper, comparator) { - return maxFactory( - this, - comparator ? neg(comparator) : defaultNegComparator, - mapper - ); - }, + takeLast: function takeLast(amount) { + return this.slice(-Math.max(0, amount)); + }, - rest: function rest() { - return this.slice(1); - }, + takeWhile: function takeWhile(predicate, context) { + return reify(this, takeWhileFactory(this, predicate, context)); + }, - skip: function skip(amount) { - return amount === 0 ? this : this.slice(Math.max(0, amount)); - }, + takeUntil: function takeUntil(predicate, context) { + return this.takeWhile(not(predicate), context); + }, - skipLast: function skipLast(amount) { - return amount === 0 ? this : this.slice(0, -Math.max(0, amount)); - }, + update: function update(fn) { + return fn(this); + }, - skipWhile: function skipWhile(predicate, context) { - return reify(this, skipWhileFactory(this, predicate, context, true)); - }, + valueSeq: function valueSeq() { + return this.toIndexedSeq(); + }, - skipUntil: function skipUntil(predicate, context) { - return this.skipWhile(not(predicate), context); - }, + // ### Hashable Object - sortBy: function sortBy(mapper, comparator) { - return reify(this, sortFactory(this, comparator, mapper)); - }, + hashCode: function hashCode() { + return this.__hash || (this.__hash = hashCollection(this)); + }, - take: function take(amount) { - return this.slice(0, Math.max(0, amount)); - }, + // ### Internal - takeLast: function takeLast(amount) { - return this.slice(-Math.max(0, amount)); - }, + // abstract __iterate(fn, reverse) - takeWhile: function takeWhile(predicate, context) { - return reify(this, takeWhileFactory(this, predicate, context)); - }, + // abstract __iterator(type, reverse) + }); - takeUntil: function takeUntil(predicate, context) { - return this.takeWhile(not(predicate), context); - }, + var CollectionPrototype = Collection.prototype; + CollectionPrototype[IS_COLLECTION_SYMBOL] = true; + CollectionPrototype[ITERATOR_SYMBOL] = CollectionPrototype.values; + CollectionPrototype.toJSON = CollectionPrototype.toArray; + CollectionPrototype.__toStringMapper = quoteString; + CollectionPrototype.inspect = CollectionPrototype.toSource = function () { + return this.toString(); + }; + CollectionPrototype.chain = CollectionPrototype.flatMap; + CollectionPrototype.contains = CollectionPrototype.includes; - update: function update(fn) { - return fn(this); - }, + mixin(KeyedCollection, { + // ### More sequential methods - valueSeq: function valueSeq() { - return this.toIndexedSeq(); - }, + flip: function flip() { + return reify(this, flipFactory(this)); + }, - // ### Hashable Object + mapEntries: function mapEntries(mapper, context) { + var this$1$1 = this; - hashCode: function hashCode() { - return this.__hash || (this.__hash = hashCollection(this)); - }, + var iterations = 0; + return reify( + this, + this.toSeq() + .map(function (v, k) { return mapper.call(context, [k, v], iterations++, this$1$1); }) + .fromEntrySeq() + ); + }, - // ### Internal + mapKeys: function mapKeys(mapper, context) { + var this$1$1 = this; - // abstract __iterate(fn, reverse) + return reify( + this, + this.toSeq() + .flip() + .map(function (k, v) { return mapper.call(context, k, v, this$1$1); }) + .flip() + ); + }, + }); - // abstract __iterator(type, reverse) - }); + var KeyedCollectionPrototype = KeyedCollection.prototype; + KeyedCollectionPrototype[IS_KEYED_SYMBOL] = true; + KeyedCollectionPrototype[ITERATOR_SYMBOL] = CollectionPrototype.entries; + KeyedCollectionPrototype.toJSON = toObject; + KeyedCollectionPrototype.__toStringMapper = function (v, k) { return quoteString(k) + ': ' + quoteString(v); }; + + mixin(IndexedCollection, { + // ### Conversion to other types + + toKeyedSeq: function toKeyedSeq() { + return new ToKeyedSequence(this, false); + }, + + // ### ES6 Collection methods (ES6 Array and Map) + + filter: function filter(predicate, context) { + return reify(this, filterFactory(this, predicate, context, false)); + }, + + findIndex: function findIndex(predicate, context) { + var entry = this.findEntry(predicate, context); + return entry ? entry[0] : -1; + }, + + indexOf: function indexOf(searchValue) { + var key = this.keyOf(searchValue); + return key === undefined ? -1 : key; + }, + + lastIndexOf: function lastIndexOf(searchValue) { + var key = this.lastKeyOf(searchValue); + return key === undefined ? -1 : key; + }, + + reverse: function reverse() { + return reify(this, reverseFactory(this, false)); + }, + + slice: function slice(begin, end) { + return reify(this, sliceFactory(this, begin, end, false)); + }, + + splice: function splice(index, removeNum /*, ...values*/) { + var numArgs = arguments.length; + removeNum = Math.max(removeNum || 0, 0); + if (numArgs === 0 || (numArgs === 2 && !removeNum)) { + return this; + } + // If index is negative, it should resolve relative to the size of the + // collection. However size may be expensive to compute if not cached, so + // only call count() if the number is in fact negative. + index = resolveBegin(index, index < 0 ? this.count() : this.size); + var spliced = this.slice(0, index); + return reify( + this, + numArgs === 1 + ? spliced + : spliced.concat(arrCopy(arguments, 2), this.slice(index + removeNum)) + ); + }, - var CollectionPrototype = Collection.prototype; - CollectionPrototype[IS_COLLECTION_SYMBOL] = true; - CollectionPrototype[ITERATOR_SYMBOL] = CollectionPrototype.values; - CollectionPrototype.toJSON = CollectionPrototype.toArray; - CollectionPrototype.__toStringMapper = quoteString; - CollectionPrototype.inspect = CollectionPrototype.toSource = function () { - return this.toString(); - }; - CollectionPrototype.chain = CollectionPrototype.flatMap; - CollectionPrototype.contains = CollectionPrototype.includes; + // ### More collection methods - mixin(KeyedCollection, { - // ### More sequential methods + findLastIndex: function findLastIndex(predicate, context) { + var entry = this.findLastEntry(predicate, context); + return entry ? entry[0] : -1; + }, - flip: function flip() { - return reify(this, flipFactory(this)); - }, + first: function first(notSetValue) { + return this.get(0, notSetValue); + }, - mapEntries: function mapEntries(mapper, context) { - var this$1$1 = this; + flatten: function flatten(depth) { + return reify(this, flattenFactory(this, depth, false)); + }, - var iterations = 0; - return reify( - this, - this.toSeq() - .map(function (v, k) { return mapper.call(context, [k, v], iterations++, this$1$1); }) - .fromEntrySeq() - ); - }, + get: function get(index, notSetValue) { + index = wrapIndex(this, index); + return index < 0 || + this.size === Infinity || + (this.size !== undefined && index > this.size) + ? notSetValue + : this.find(function (_, key) { return key === index; }, undefined, notSetValue); + }, + + has: function has(index) { + index = wrapIndex(this, index); + return ( + index >= 0 && + (this.size !== undefined + ? this.size === Infinity || index < this.size + : this.indexOf(index) !== -1) + ); + }, + + interpose: function interpose(separator) { + return reify(this, interposeFactory(this, separator)); + }, + + interleave: function interleave(/*...collections*/) { + var collections = [this].concat(arrCopy(arguments)); + var zipped = zipWithFactory(this.toSeq(), IndexedSeq.of, collections); + var interleaved = zipped.flatten(true); + if (zipped.size) { + interleaved.size = zipped.size * collections.length; + } + return reify(this, interleaved); + }, + + keySeq: function keySeq() { + return Range(0, this.size); + }, + + last: function last(notSetValue) { + return this.get(-1, notSetValue); + }, + + skipWhile: function skipWhile(predicate, context) { + return reify(this, skipWhileFactory(this, predicate, context, false)); + }, + + zip: function zip(/*, ...collections */) { + var collections = [this].concat(arrCopy(arguments)); + return reify(this, zipWithFactory(this, defaultZipper, collections)); + }, + + zipAll: function zipAll(/*, ...collections */) { + var collections = [this].concat(arrCopy(arguments)); + return reify(this, zipWithFactory(this, defaultZipper, collections, true)); + }, + + zipWith: function zipWith(zipper /*, ...collections */) { + var collections = arrCopy(arguments); + collections[0] = this; + return reify(this, zipWithFactory(this, zipper, collections)); + }, + }); - mapKeys: function mapKeys(mapper, context) { - var this$1$1 = this; + var IndexedCollectionPrototype = IndexedCollection.prototype; + IndexedCollectionPrototype[IS_INDEXED_SYMBOL] = true; + IndexedCollectionPrototype[IS_ORDERED_SYMBOL] = true; - return reify( - this, - this.toSeq() - .flip() - .map(function (k, v) { return mapper.call(context, k, v, this$1$1); }) - .flip() - ); - }, - }); - - var KeyedCollectionPrototype = KeyedCollection.prototype; - KeyedCollectionPrototype[IS_KEYED_SYMBOL] = true; - KeyedCollectionPrototype[ITERATOR_SYMBOL] = CollectionPrototype.entries; - KeyedCollectionPrototype.toJSON = toObject; - KeyedCollectionPrototype.__toStringMapper = function (v, k) { return quoteString(k) + ': ' + quoteString(v); }; - - mixin(IndexedCollection, { - // ### Conversion to other types - - toKeyedSeq: function toKeyedSeq() { - return new ToKeyedSequence(this, false); - }, - - // ### ES6 Collection methods (ES6 Array and Map) - - filter: function filter(predicate, context) { - return reify(this, filterFactory(this, predicate, context, false)); - }, - - findIndex: function findIndex(predicate, context) { - var entry = this.findEntry(predicate, context); - return entry ? entry[0] : -1; - }, - - indexOf: function indexOf(searchValue) { - var key = this.keyOf(searchValue); - return key === undefined ? -1 : key; - }, - - lastIndexOf: function lastIndexOf(searchValue) { - var key = this.lastKeyOf(searchValue); - return key === undefined ? -1 : key; - }, - - reverse: function reverse() { - return reify(this, reverseFactory(this, false)); - }, - - slice: function slice(begin, end) { - return reify(this, sliceFactory(this, begin, end, false)); - }, - - splice: function splice(index, removeNum /*, ...values*/) { - var numArgs = arguments.length; - removeNum = Math.max(removeNum || 0, 0); - if (numArgs === 0 || (numArgs === 2 && !removeNum)) { - return this; - } - // If index is negative, it should resolve relative to the size of the - // collection. However size may be expensive to compute if not cached, so - // only call count() if the number is in fact negative. - index = resolveBegin(index, index < 0 ? this.count() : this.size); - var spliced = this.slice(0, index); - return reify( - this, - numArgs === 1 - ? spliced - : spliced.concat(arrCopy(arguments, 2), this.slice(index + removeNum)) - ); - }, + mixin(SetCollection, { + // ### ES6 Collection methods (ES6 Array and Map) - // ### More collection methods + get: function get(value, notSetValue) { + return this.has(value) ? value : notSetValue; + }, - findLastIndex: function findLastIndex(predicate, context) { - var entry = this.findLastEntry(predicate, context); - return entry ? entry[0] : -1; - }, + includes: function includes(value) { + return this.has(value); + }, - first: function first(notSetValue) { - return this.get(0, notSetValue); - }, + // ### More sequential methods - flatten: function flatten(depth) { - return reify(this, flattenFactory(this, depth, false)); - }, + keySeq: function keySeq() { + return this.valueSeq(); + }, + }); - get: function get(index, notSetValue) { - index = wrapIndex(this, index); - return index < 0 || - this.size === Infinity || - (this.size !== undefined && index > this.size) - ? notSetValue - : this.find(function (_, key) { return key === index; }, undefined, notSetValue); - }, + var SetCollectionPrototype = SetCollection.prototype; + SetCollectionPrototype.has = CollectionPrototype.includes; + SetCollectionPrototype.contains = SetCollectionPrototype.includes; + SetCollectionPrototype.keys = SetCollectionPrototype.values; - has: function has(index) { - index = wrapIndex(this, index); - return ( - index >= 0 && - (this.size !== undefined - ? this.size === Infinity || index < this.size - : this.indexOf(index) !== -1) - ); - }, - - interpose: function interpose(separator) { - return reify(this, interposeFactory(this, separator)); - }, - - interleave: function interleave(/*...collections*/) { - var collections = [this].concat(arrCopy(arguments)); - var zipped = zipWithFactory(this.toSeq(), IndexedSeq.of, collections); - var interleaved = zipped.flatten(true); - if (zipped.size) { - interleaved.size = zipped.size * collections.length; - } - return reify(this, interleaved); - }, - - keySeq: function keySeq() { - return Range(0, this.size); - }, - - last: function last(notSetValue) { - return this.get(-1, notSetValue); - }, - - skipWhile: function skipWhile(predicate, context) { - return reify(this, skipWhileFactory(this, predicate, context, false)); - }, - - zip: function zip(/*, ...collections */) { - var collections = [this].concat(arrCopy(arguments)); - return reify(this, zipWithFactory(this, defaultZipper, collections)); - }, - - zipAll: function zipAll(/*, ...collections */) { - var collections = [this].concat(arrCopy(arguments)); - return reify(this, zipWithFactory(this, defaultZipper, collections, true)); - }, - - zipWith: function zipWith(zipper /*, ...collections */) { - var collections = arrCopy(arguments); - collections[0] = this; - return reify(this, zipWithFactory(this, zipper, collections)); - }, - }); - - var IndexedCollectionPrototype = IndexedCollection.prototype; - IndexedCollectionPrototype[IS_INDEXED_SYMBOL] = true; - IndexedCollectionPrototype[IS_ORDERED_SYMBOL] = true; - - mixin(SetCollection, { - // ### ES6 Collection methods (ES6 Array and Map) - - get: function get(value, notSetValue) { - return this.has(value) ? value : notSetValue; - }, - - includes: function includes(value) { - return this.has(value); - }, - - // ### More sequential methods - - keySeq: function keySeq() { - return this.valueSeq(); - }, - }); - - var SetCollectionPrototype = SetCollection.prototype; - SetCollectionPrototype.has = CollectionPrototype.includes; - SetCollectionPrototype.contains = SetCollectionPrototype.includes; - SetCollectionPrototype.keys = SetCollectionPrototype.values; - - // Mixin subclasses - - mixin(KeyedSeq, KeyedCollectionPrototype); - mixin(IndexedSeq, IndexedCollectionPrototype); - mixin(SetSeq, SetCollectionPrototype); - - // #pragma Helper functions - - function reduce(collection, reducer, reduction, context, useFirst, reverse) { - assertNotInfinite(collection.size); - collection.__iterate(function (v, k, c) { - if (useFirst) { - useFirst = false; - reduction = v; - } else { - reduction = reducer.call(context, reduction, v, k, c); - } - }, reverse); - return reduction; - } + // Mixin subclasses - function keyMapper(v, k) { - return k; - } + mixin(KeyedSeq, KeyedCollectionPrototype); + mixin(IndexedSeq, IndexedCollectionPrototype); + mixin(SetSeq, SetCollectionPrototype); - function entryMapper(v, k) { - return [k, v]; - } + // #pragma Helper functions - function not(predicate) { - return function () { - return !predicate.apply(this, arguments); - }; - } + function reduce(collection, reducer, reduction, context, useFirst, reverse) { + assertNotInfinite(collection.size); + collection.__iterate(function (v, k, c) { + if (useFirst) { + useFirst = false; + reduction = v; + } else { + reduction = reducer.call(context, reduction, v, k, c); + } + }, reverse); + return reduction; + } - function neg(predicate) { - return function () { - return -predicate.apply(this, arguments); - }; - } + function keyMapper(v, k) { + return k; + } - function defaultZipper() { - return arrCopy(arguments); - } + function entryMapper(v, k) { + return [k, v]; + } - function defaultNegComparator(a, b) { - return a < b ? 1 : a > b ? -1 : 0; - } + function not(predicate) { + return function () { + return !predicate.apply(this, arguments); + }; + } - function hashCollection(collection) { - if (collection.size === Infinity) { - return 0; + function neg(predicate) { + return function () { + return -predicate.apply(this, arguments); + }; } - var ordered = isOrdered(collection); - var keyed = isKeyed(collection); - var h = ordered ? 1 : 0; - collection.__iterate( - keyed - ? ordered - ? function (v, k) { - h = (31 * h + hashMerge(hash(v), hash(k))) | 0; - } - : function (v, k) { - h = (h + hashMerge(hash(v), hash(k))) | 0; - } - : ordered - ? function (v) { - h = (31 * h + hash(v)) | 0; - } - : function (v) { - h = (h + hash(v)) | 0; - } - ); - - return murmurHashOfSize(collection.size, h); - } - - function murmurHashOfSize(size, h) { - h = imul(h, 0xcc9e2d51); - h = imul((h << 15) | (h >>> -15), 0x1b873593); - h = imul((h << 13) | (h >>> -13), 5); - h = ((h + 0xe6546b64) | 0) ^ size; - h = imul(h ^ (h >>> 16), 0x85ebca6b); - h = imul(h ^ (h >>> 13), 0xc2b2ae35); - h = smi(h ^ (h >>> 16)); - return h; - } - - function hashMerge(a, b) { - return (a ^ (b + 0x9e3779b9 + (a << 6) + (a >> 2))) | 0; // int - } - - var OrderedSet = /*@__PURE__*/(function (Set) { - function OrderedSet(value) { - // eslint-disable-next-line no-constructor-return - return value === undefined || value === null - ? emptyOrderedSet() - : isOrderedSet(value) - ? value - : emptyOrderedSet().withMutations(function (set) { - var iter = SetCollection(value); - assertNotInfinite(iter.size); - iter.forEach(function (v) { return set.add(v); }); - }); - } - - if ( Set ) OrderedSet.__proto__ = Set; - OrderedSet.prototype = Object.create( Set && Set.prototype ); - OrderedSet.prototype.constructor = OrderedSet; - - OrderedSet.of = function of (/*...values*/) { - return this(arguments); - }; + function defaultZipper() { + return arrCopy(arguments); + } - OrderedSet.fromKeys = function fromKeys (value) { - return this(KeyedCollection(value).keySeq()); - }; + function defaultNegComparator(a, b) { + return a < b ? 1 : a > b ? -1 : 0; + } - OrderedSet.prototype.toString = function toString () { - return this.__toString('OrderedSet {', '}'); - }; + function hashCollection(collection) { + if (collection.size === Infinity) { + return 0; + } + var ordered = isOrdered(collection); + var keyed = isKeyed(collection); + var h = ordered ? 1 : 0; - return OrderedSet; - }(Set)); - - OrderedSet.isOrderedSet = isOrderedSet; - - var OrderedSetPrototype = OrderedSet.prototype; - OrderedSetPrototype[IS_ORDERED_SYMBOL] = true; - OrderedSetPrototype.zip = IndexedCollectionPrototype.zip; - OrderedSetPrototype.zipWith = IndexedCollectionPrototype.zipWith; - OrderedSetPrototype.zipAll = IndexedCollectionPrototype.zipAll; - - OrderedSetPrototype.__empty = emptyOrderedSet; - OrderedSetPrototype.__make = makeOrderedSet; - - function makeOrderedSet(map, ownerID) { - var set = Object.create(OrderedSetPrototype); - set.size = map ? map.size : 0; - set._map = map; - set.__ownerID = ownerID; - return set; - } - - var EMPTY_ORDERED_SET; - function emptyOrderedSet() { - return ( - EMPTY_ORDERED_SET || (EMPTY_ORDERED_SET = makeOrderedSet(emptyOrderedMap())) - ); - } - - var PairSorting = { - LeftThenRight: -1, - RightThenLeft: 1, - }; - - function throwOnInvalidDefaultValues(defaultValues) { - if (isRecord(defaultValues)) { - throw new Error( - 'Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.' + collection.__iterate( + keyed + ? ordered + ? function (v, k) { + h = (31 * h + hashMerge(hash(v), hash(k))) | 0; + } + : function (v, k) { + h = (h + hashMerge(hash(v), hash(k))) | 0; + } + : ordered + ? function (v) { + h = (31 * h + hash(v)) | 0; + } + : function (v) { + h = (h + hash(v)) | 0; + } ); + + return murmurHashOfSize(collection.size, h); } - if (isImmutable(defaultValues)) { - throw new Error( - 'Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.' - ); + function murmurHashOfSize(size, h) { + h = imul(h, 0xcc9e2d51); + h = imul((h << 15) | (h >>> -15), 0x1b873593); + h = imul((h << 13) | (h >>> -13), 5); + h = ((h + 0xe6546b64) | 0) ^ size; + h = imul(h ^ (h >>> 16), 0x85ebca6b); + h = imul(h ^ (h >>> 13), 0xc2b2ae35); + h = smi(h ^ (h >>> 16)); + return h; } - if (defaultValues === null || typeof defaultValues !== 'object') { - throw new Error( - 'Can not call `Record` with a non-object as default values. Use a plain javascript object instead.' - ); + function hashMerge(a, b) { + return (a ^ (b + 0x9e3779b9 + (a << 6) + (a >> 2))) | 0; // int } - } - var Record = function Record(defaultValues, name) { - var hasInitialized; + var OrderedSet = /*@__PURE__*/(function (Set) { + function OrderedSet(value) { + // eslint-disable-next-line no-constructor-return + return value === undefined || value === null + ? emptyOrderedSet() + : isOrderedSet(value) + ? value + : emptyOrderedSet().withMutations(function (set) { + var iter = SetCollection(value); + assertNotInfinite(iter.size); + iter.forEach(function (v) { return set.add(v); }); + }); + } + + if ( Set ) OrderedSet.__proto__ = Set; + OrderedSet.prototype = Object.create( Set && Set.prototype ); + OrderedSet.prototype.constructor = OrderedSet; + + OrderedSet.of = function of (/*...values*/) { + return this(arguments); + }; - throwOnInvalidDefaultValues(defaultValues); + OrderedSet.fromKeys = function fromKeys (value) { + return this(KeyedCollection(value).keySeq()); + }; - var RecordType = function Record(values) { - var this$1$1 = this; + OrderedSet.prototype.toString = function toString () { + return this.__toString('OrderedSet {', '}'); + }; - if (values instanceof RecordType) { - return values; - } - if (!(this instanceof RecordType)) { - return new RecordType(values); - } - if (!hasInitialized) { - hasInitialized = true; - var keys = Object.keys(defaultValues); - var indices = (RecordTypePrototype._indices = {}); - // Deprecated: left to attempt not to break any external code which - // relies on a ._name property existing on record instances. - // Use Record.getDescriptiveName() instead - RecordTypePrototype._name = name; - RecordTypePrototype._keys = keys; - RecordTypePrototype._defaultValues = defaultValues; - for (var i = 0; i < keys.length; i++) { - var propName = keys[i]; - indices[propName] = i; - if (RecordTypePrototype[propName]) { - /* eslint-disable no-console */ - // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here - typeof console === 'object' && - console.warn && - console.warn( - 'Cannot define ' + - recordName(this) + - ' with property "' + - propName + - '" since that property name is part of the Record API.' - ); - /* eslint-enable no-console */ - } else { - setProp(RecordTypePrototype, propName); - } - } - } - this.__ownerID = undefined; - this._values = List().withMutations(function (l) { - l.setSize(this$1$1._keys.length); - KeyedCollection(values).forEach(function (v, k) { - l.set(this$1$1._indices[k], v === this$1$1._defaultValues[k] ? undefined : v); - }); - }); - return this; - }; + return OrderedSet; + }(Set)); - var RecordTypePrototype = (RecordType.prototype = - Object.create(RecordPrototype)); - RecordTypePrototype.constructor = RecordType; + OrderedSet.isOrderedSet = isOrderedSet; - if (name) { - RecordType.displayName = name; - } + var OrderedSetPrototype = OrderedSet.prototype; + OrderedSetPrototype[IS_ORDERED_SYMBOL] = true; + OrderedSetPrototype.zip = IndexedCollectionPrototype.zip; + OrderedSetPrototype.zipWith = IndexedCollectionPrototype.zipWith; + OrderedSetPrototype.zipAll = IndexedCollectionPrototype.zipAll; - // eslint-disable-next-line no-constructor-return - return RecordType; - }; + OrderedSetPrototype.__empty = emptyOrderedSet; + OrderedSetPrototype.__make = makeOrderedSet; - Record.prototype.toString = function toString () { - var str = recordName(this) + ' { '; - var keys = this._keys; - var k; - for (var i = 0, l = keys.length; i !== l; i++) { - k = keys[i]; - str += (i ? ', ' : '') + k + ': ' + quoteString(this.get(k)); + function makeOrderedSet(map, ownerID) { + var set = Object.create(OrderedSetPrototype); + set.size = map ? map.size : 0; + set._map = map; + set.__ownerID = ownerID; + return set; } - return str + ' }'; - }; - Record.prototype.equals = function equals (other) { - return ( - this === other || - (isRecord(other) && recordSeq(this).equals(recordSeq(other))) - ); - }; + var EMPTY_ORDERED_SET; + function emptyOrderedSet() { + return ( + EMPTY_ORDERED_SET || (EMPTY_ORDERED_SET = makeOrderedSet(emptyOrderedMap())) + ); + } - Record.prototype.hashCode = function hashCode () { - return recordSeq(this).hashCode(); - }; + var PairSorting = { + LeftThenRight: -1, + RightThenLeft: 1, + }; - // @pragma Access + function throwOnInvalidDefaultValues(defaultValues) { + if (isRecord(defaultValues)) { + throw new Error( + 'Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.' + ); + } - Record.prototype.has = function has (k) { - return this._indices.hasOwnProperty(k); - }; + if (isImmutable(defaultValues)) { + throw new Error( + 'Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.' + ); + } - Record.prototype.get = function get (k, notSetValue) { - if (!this.has(k)) { - return notSetValue; + if (defaultValues === null || typeof defaultValues !== 'object') { + throw new Error( + 'Can not call `Record` with a non-object as default values. Use a plain javascript object instead.' + ); + } } - var index = this._indices[k]; - var value = this._values.get(index); - return value === undefined ? this._defaultValues[k] : value; - }; - // @pragma Modification + var Record = function Record(defaultValues, name) { + var hasInitialized; - Record.prototype.set = function set (k, v) { - if (this.has(k)) { - var newValues = this._values.set( - this._indices[k], - v === this._defaultValues[k] ? undefined : v - ); - if (newValues !== this._values && !this.__ownerID) { - return makeRecord(this, newValues); - } - } - return this; - }; + throwOnInvalidDefaultValues(defaultValues); - Record.prototype.remove = function remove (k) { - return this.set(k); - }; + var RecordType = function Record(values) { + var this$1$1 = this; + + if (values instanceof RecordType) { + return values; + } + if (!(this instanceof RecordType)) { + return new RecordType(values); + } + if (!hasInitialized) { + hasInitialized = true; + var keys = Object.keys(defaultValues); + var indices = (RecordTypePrototype._indices = {}); + // Deprecated: left to attempt not to break any external code which + // relies on a ._name property existing on record instances. + // Use Record.getDescriptiveName() instead + RecordTypePrototype._name = name; + RecordTypePrototype._keys = keys; + RecordTypePrototype._defaultValues = defaultValues; + for (var i = 0; i < keys.length; i++) { + var propName = keys[i]; + indices[propName] = i; + if (RecordTypePrototype[propName]) { + /* eslint-disable no-console */ + // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here + typeof console === 'object' && + console.warn && + console.warn( + 'Cannot define ' + + recordName(this) + + ' with property "' + + propName + + '" since that property name is part of the Record API.' + ); + /* eslint-enable no-console */ + } else { + setProp(RecordTypePrototype, propName); + } + } + } + this.__ownerID = undefined; + this._values = List().withMutations(function (l) { + l.setSize(this$1$1._keys.length); + KeyedCollection(values).forEach(function (v, k) { + l.set(this$1$1._indices[k], v === this$1$1._defaultValues[k] ? undefined : v); + }); + }); + return this; + }; - Record.prototype.clear = function clear () { - var newValues = this._values.clear().setSize(this._keys.length); + var RecordTypePrototype = (RecordType.prototype = + Object.create(RecordPrototype)); + RecordTypePrototype.constructor = RecordType; - return this.__ownerID ? this : makeRecord(this, newValues); - }; + if (name) { + RecordType.displayName = name; + } - Record.prototype.wasAltered = function wasAltered () { - return this._values.wasAltered(); - }; + // eslint-disable-next-line no-constructor-return + return RecordType; + }; - Record.prototype.toSeq = function toSeq () { - return recordSeq(this); - }; + Record.prototype.toString = function toString () { + var str = recordName(this) + ' { '; + var keys = this._keys; + var k; + for (var i = 0, l = keys.length; i !== l; i++) { + k = keys[i]; + str += (i ? ', ' : '') + k + ': ' + quoteString(this.get(k)); + } + return str + ' }'; + }; - Record.prototype.toJS = function toJS$1 () { - return toJS(this); - }; + Record.prototype.equals = function equals (other) { + return ( + this === other || + (isRecord(other) && recordSeq(this).equals(recordSeq(other))) + ); + }; - Record.prototype.entries = function entries () { - return this.__iterator(ITERATE_ENTRIES); - }; + Record.prototype.hashCode = function hashCode () { + return recordSeq(this).hashCode(); + }; - Record.prototype.__iterator = function __iterator (type, reverse) { - return recordSeq(this).__iterator(type, reverse); - }; + // @pragma Access - Record.prototype.__iterate = function __iterate (fn, reverse) { - return recordSeq(this).__iterate(fn, reverse); - }; + Record.prototype.has = function has (k) { + return this._indices.hasOwnProperty(k); + }; - Record.prototype.__ensureOwner = function __ensureOwner (ownerID) { - if (ownerID === this.__ownerID) { - return this; - } - var newValues = this._values.__ensureOwner(ownerID); - if (!ownerID) { - this.__ownerID = ownerID; - this._values = newValues; - return this; - } - return makeRecord(this, newValues, ownerID); - }; - - Record.isRecord = isRecord; - Record.getDescriptiveName = recordName; - var RecordPrototype = Record.prototype; - RecordPrototype[IS_RECORD_SYMBOL] = true; - RecordPrototype[DELETE] = RecordPrototype.remove; - RecordPrototype.deleteIn = RecordPrototype.removeIn = deleteIn; - RecordPrototype.getIn = getIn; - RecordPrototype.hasIn = CollectionPrototype.hasIn; - RecordPrototype.merge = merge$1; - RecordPrototype.mergeWith = mergeWith$1; - RecordPrototype.mergeIn = mergeIn; - RecordPrototype.mergeDeep = mergeDeep; - RecordPrototype.mergeDeepWith = mergeDeepWith; - RecordPrototype.mergeDeepIn = mergeDeepIn; - RecordPrototype.setIn = setIn; - RecordPrototype.update = update; - RecordPrototype.updateIn = updateIn; - RecordPrototype.withMutations = withMutations; - RecordPrototype.asMutable = asMutable; - RecordPrototype.asImmutable = asImmutable; - RecordPrototype[ITERATOR_SYMBOL] = RecordPrototype.entries; - RecordPrototype.toJSON = RecordPrototype.toObject = - CollectionPrototype.toObject; - RecordPrototype.inspect = RecordPrototype.toSource = function () { - return this.toString(); - }; - - function makeRecord(likeRecord, values, ownerID) { - var record = Object.create(Object.getPrototypeOf(likeRecord)); - record._values = values; - record.__ownerID = ownerID; - return record; - } - - function recordName(record) { - return record.constructor.displayName || record.constructor.name || 'Record'; - } - - function recordSeq(record) { - return keyedSeqFromValue(record._keys.map(function (k) { return [k, record.get(k)]; })); - } - - function setProp(prototype, name) { - try { - Object.defineProperty(prototype, name, { - get: function () { - return this.get(name); - }, - set: function (value) { - invariant(this.__ownerID, 'Cannot set on an immutable record.'); - this.set(name, value); - }, - }); - // eslint-disable-next-line @typescript-eslint/no-unused-vars -- TODO enable eslint here - } catch (error) { - // Object.defineProperty failed. Probably IE8. - } - } - - /** - * Returns a lazy Seq of `value` repeated `times` times. When `times` is - * undefined, returns an infinite sequence of `value`. - */ - var Repeat = /*@__PURE__*/(function (IndexedSeq) { - function Repeat(value, times) { - if (!(this instanceof Repeat)) { - // eslint-disable-next-line no-constructor-return - return new Repeat(value, times); + Record.prototype.get = function get (k, notSetValue) { + if (!this.has(k)) { + return notSetValue; } - this._value = value; - this.size = times === undefined ? Infinity : Math.max(0, times); - if (this.size === 0) { - if (EMPTY_REPEAT) { - // eslint-disable-next-line no-constructor-return - return EMPTY_REPEAT; + var index = this._indices[k]; + var value = this._values.get(index); + return value === undefined ? this._defaultValues[k] : value; + }; + + // @pragma Modification + + Record.prototype.set = function set (k, v) { + if (this.has(k)) { + var newValues = this._values.set( + this._indices[k], + v === this._defaultValues[k] ? undefined : v + ); + if (newValues !== this._values && !this.__ownerID) { + return makeRecord(this, newValues); } - // eslint-disable-next-line @typescript-eslint/no-this-alias - EMPTY_REPEAT = this; } - } + return this; + }; - if ( IndexedSeq ) Repeat.__proto__ = IndexedSeq; - Repeat.prototype = Object.create( IndexedSeq && IndexedSeq.prototype ); - Repeat.prototype.constructor = Repeat; + Record.prototype.remove = function remove (k) { + return this.set(k); + }; - Repeat.prototype.toString = function toString () { - if (this.size === 0) { - return 'Repeat []'; - } - return 'Repeat [ ' + this._value + ' ' + this.size + ' times ]'; + Record.prototype.clear = function clear () { + var newValues = this._values.clear().setSize(this._keys.length); + + return this.__ownerID ? this : makeRecord(this, newValues); }; - Repeat.prototype.get = function get (index, notSetValue) { - return this.has(index) ? this._value : notSetValue; + Record.prototype.wasAltered = function wasAltered () { + return this._values.wasAltered(); }; - Repeat.prototype.includes = function includes (searchValue) { - return is(this._value, searchValue); + Record.prototype.toSeq = function toSeq () { + return recordSeq(this); }; - Repeat.prototype.slice = function slice (begin, end) { - var size = this.size; - return wholeSlice(begin, end, size) - ? this - : new Repeat( - this._value, - resolveEnd(end, size) - resolveBegin(begin, size) - ); + Record.prototype.toJS = function toJS$1 () { + return toJS(this); }; - Repeat.prototype.reverse = function reverse () { - return this; + Record.prototype.entries = function entries () { + return this.__iterator(ITERATE_ENTRIES); }; - Repeat.prototype.indexOf = function indexOf (searchValue) { - if (is(this._value, searchValue)) { - return 0; - } - return -1; + Record.prototype.__iterator = function __iterator (type, reverse) { + return recordSeq(this).__iterator(type, reverse); }; - Repeat.prototype.lastIndexOf = function lastIndexOf (searchValue) { - if (is(this._value, searchValue)) { - return this.size; - } - return -1; + Record.prototype.__iterate = function __iterate (fn, reverse) { + return recordSeq(this).__iterate(fn, reverse); }; - Repeat.prototype.__iterate = function __iterate (fn, reverse) { - var size = this.size; - var i = 0; - while (i !== size) { - if (fn(this._value, reverse ? size - ++i : i++, this) === false) { - break; + Record.prototype.__ensureOwner = function __ensureOwner (ownerID) { + if (ownerID === this.__ownerID) { + return this; + } + var newValues = this._values.__ensureOwner(ownerID); + if (!ownerID) { + this.__ownerID = ownerID; + this._values = newValues; + return this; + } + return makeRecord(this, newValues, ownerID); + }; + + Record.isRecord = isRecord; + Record.getDescriptiveName = recordName; + var RecordPrototype = Record.prototype; + RecordPrototype[IS_RECORD_SYMBOL] = true; + RecordPrototype[DELETE] = RecordPrototype.remove; + RecordPrototype.deleteIn = RecordPrototype.removeIn = deleteIn; + RecordPrototype.getIn = getIn; + RecordPrototype.hasIn = CollectionPrototype.hasIn; + RecordPrototype.merge = merge$1; + RecordPrototype.mergeWith = mergeWith$1; + RecordPrototype.mergeIn = mergeIn; + RecordPrototype.mergeDeep = mergeDeep; + RecordPrototype.mergeDeepWith = mergeDeepWith; + RecordPrototype.mergeDeepIn = mergeDeepIn; + RecordPrototype.setIn = setIn; + RecordPrototype.update = update; + RecordPrototype.updateIn = updateIn; + RecordPrototype.withMutations = withMutations; + RecordPrototype.asMutable = asMutable; + RecordPrototype.asImmutable = asImmutable; + RecordPrototype[ITERATOR_SYMBOL] = RecordPrototype.entries; + RecordPrototype.toJSON = RecordPrototype.toObject = + CollectionPrototype.toObject; + RecordPrototype.inspect = RecordPrototype.toSource = function () { + return this.toString(); + }; + + function makeRecord(likeRecord, values, ownerID) { + var record = Object.create(Object.getPrototypeOf(likeRecord)); + record._values = values; + record.__ownerID = ownerID; + return record; + } + + function recordName(record) { + return record.constructor.displayName || record.constructor.name || 'Record'; + } + + function recordSeq(record) { + return keyedSeqFromValue(record._keys.map(function (k) { return [k, record.get(k)]; })); + } + + function setProp(prototype, name) { + try { + Object.defineProperty(prototype, name, { + get: function () { + return this.get(name); + }, + set: function (value) { + invariant(this.__ownerID, 'Cannot set on an immutable record.'); + this.set(name, value); + }, + }); + // eslint-disable-next-line @typescript-eslint/no-unused-vars -- TODO enable eslint here + } catch (error) { + // Object.defineProperty failed. Probably IE8. + } + } + + /** + * Returns a lazy Seq of `value` repeated `times` times. When `times` is + * undefined, returns an infinite sequence of `value`. + */ + var Repeat = /*@__PURE__*/(function (IndexedSeq) { + function Repeat(value, times) { + if (!(this instanceof Repeat)) { + // eslint-disable-next-line no-constructor-return + return new Repeat(value, times); + } + this._value = value; + this.size = times === undefined ? Infinity : Math.max(0, times); + if (this.size === 0) { + if (EMPTY_REPEAT) { + // eslint-disable-next-line no-constructor-return + return EMPTY_REPEAT; + } + // eslint-disable-next-line @typescript-eslint/no-this-alias + EMPTY_REPEAT = this; } } - return i; - }; - Repeat.prototype.__iterator = function __iterator (type, reverse) { - var this$1$1 = this; + if ( IndexedSeq ) Repeat.__proto__ = IndexedSeq; + Repeat.prototype = Object.create( IndexedSeq && IndexedSeq.prototype ); + Repeat.prototype.constructor = Repeat; - var size = this.size; - var i = 0; - return new Iterator(function () { return i === size - ? iteratorDone() - : iteratorValue(type, reverse ? size - ++i : i++, this$1$1._value); } - ); - }; + Repeat.prototype.toString = function toString () { + if (this.size === 0) { + return 'Repeat []'; + } + return 'Repeat [ ' + this._value + ' ' + this.size + ' times ]'; + }; - Repeat.prototype.equals = function equals (other) { - return other instanceof Repeat - ? is(this._value, other._value) - : deepEqual(this, other); - }; + Repeat.prototype.get = function get (index, notSetValue) { + return this.has(index) ? this._value : notSetValue; + }; + + Repeat.prototype.includes = function includes (searchValue) { + return is(this._value, searchValue); + }; - return Repeat; - }(IndexedSeq)); + Repeat.prototype.slice = function slice (begin, end) { + var size = this.size; + return wholeSlice(begin, end, size) + ? this + : new Repeat( + this._value, + resolveEnd(end, size) - resolveBegin(begin, size) + ); + }; - var EMPTY_REPEAT; + Repeat.prototype.reverse = function reverse () { + return this; + }; - function fromJS(value, converter) { - return fromJSWith( - [], - converter || defaultConverter, - value, - '', - converter && converter.length > 2 ? [] : undefined, - { '': value } - ); - } - - function fromJSWith(stack, converter, value, key, keyPath, parentValue) { - if ( - typeof value !== 'string' && - !isImmutable(value) && - (isArrayLike(value) || hasIterator(value) || isPlainObject(value)) - ) { - if (~stack.indexOf(value)) { - throw new TypeError('Cannot convert circular structure to Immutable'); - } - stack.push(value); - // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here - keyPath && key !== '' && keyPath.push(key); - var converted = converter.call( - parentValue, - key, - Seq(value).map(function (v, k) { return fromJSWith(stack, converter, v, k, keyPath, value); } - ), - keyPath && keyPath.slice() + Repeat.prototype.indexOf = function indexOf (searchValue) { + if (is(this._value, searchValue)) { + return 0; + } + return -1; + }; + + Repeat.prototype.lastIndexOf = function lastIndexOf (searchValue) { + if (is(this._value, searchValue)) { + return this.size; + } + return -1; + }; + + Repeat.prototype.__iterate = function __iterate (fn, reverse) { + var size = this.size; + var i = 0; + while (i !== size) { + if (fn(this._value, reverse ? size - ++i : i++, this) === false) { + break; + } + } + return i; + }; + + Repeat.prototype.__iterator = function __iterator (type, reverse) { + var this$1$1 = this; + + var size = this.size; + var i = 0; + return new Iterator(function () { return i === size + ? iteratorDone() + : iteratorValue(type, reverse ? size - ++i : i++, this$1$1._value); } + ); + }; + + Repeat.prototype.equals = function equals (other) { + return other instanceof Repeat + ? is(this._value, other._value) + : deepEqual(this, other); + }; + + return Repeat; + }(IndexedSeq)); + + var EMPTY_REPEAT; + + function fromJS(value, converter) { + return fromJSWith( + [], + converter || defaultConverter, + value, + '', + converter && converter.length > 2 ? [] : undefined, + { '': value } ); - stack.pop(); - // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here - keyPath && keyPath.pop(); - return converted; - } - return value; - } - - function defaultConverter(k, v) { - // Effectively the opposite of "Collection.toSeq()" - return isIndexed(v) ? v.toList() : isKeyed(v) ? v.toMap() : v.toSet(); - } - - var version = "5.0.3"; - - // Note: Iterable is deprecated - var Iterable = Collection; - - exports.Collection = Collection; - exports.Iterable = Iterable; - exports.List = List; - exports.Map = Map; - exports.OrderedMap = OrderedMap; - exports.OrderedSet = OrderedSet; - exports.PairSorting = PairSorting; - exports.Range = Range; - exports.Record = Record; - exports.Repeat = Repeat; - exports.Seq = Seq; - exports.Set = Set; - exports.Stack = Stack; - exports.fromJS = fromJS; - exports.get = get; - exports.getIn = getIn$1; - exports.has = has; - exports.hasIn = hasIn$1; - exports.hash = hash; - exports.is = is; - exports.isAssociative = isAssociative; - exports.isCollection = isCollection; - exports.isImmutable = isImmutable; - exports.isIndexed = isIndexed; - exports.isKeyed = isKeyed; - exports.isList = isList; - exports.isMap = isMap; - exports.isOrdered = isOrdered; - exports.isOrderedMap = isOrderedMap; - exports.isOrderedSet = isOrderedSet; - exports.isPlainObject = isPlainObject; - exports.isRecord = isRecord; - exports.isSeq = isSeq; - exports.isSet = isSet; - exports.isStack = isStack; - exports.isValueObject = isValueObject; - exports.merge = merge; - exports.mergeDeep = mergeDeep$1; - exports.mergeDeepWith = mergeDeepWith$1; - exports.mergeWith = mergeWith; - exports.remove = remove; - exports.removeIn = removeIn; - exports.set = set; - exports.setIn = setIn$1; - exports.update = update$1; - exports.updateIn = updateIn$1; - exports.version = version; + } + + function fromJSWith(stack, converter, value, key, keyPath, parentValue) { + if ( + typeof value !== 'string' && + !isImmutable(value) && + (isArrayLike(value) || hasIterator(value) || isPlainObject(value)) + ) { + if (~stack.indexOf(value)) { + throw new TypeError('Cannot convert circular structure to Immutable'); + } + stack.push(value); + // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here + keyPath && key !== '' && keyPath.push(key); + var converted = converter.call( + parentValue, + key, + Seq(value).map(function (v, k) { return fromJSWith(stack, converter, v, k, keyPath, value); } + ), + keyPath && keyPath.slice() + ); + stack.pop(); + // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here + keyPath && keyPath.pop(); + return converted; + } + return value; + } + + function defaultConverter(k, v) { + // Effectively the opposite of "Collection.toSeq()" + return isIndexed(v) ? v.toList() : isKeyed(v) ? v.toMap() : v.toSet(); + } + + var version = "5.0.3"; + + // Note: Iterable is deprecated + var Iterable = Collection; + + exports.Collection = Collection; + exports.Iterable = Iterable; + exports.List = List; + exports.Map = Map; + exports.OrderedMap = OrderedMap; + exports.OrderedSet = OrderedSet; + exports.PairSorting = PairSorting; + exports.Range = Range; + exports.Record = Record; + exports.Repeat = Repeat; + exports.Seq = Seq; + exports.Set = Set; + exports.Stack = Stack; + exports.fromJS = fromJS; + exports.get = get; + exports.getIn = getIn$1; + exports.has = has; + exports.hasIn = hasIn$1; + exports.hash = hash; + exports.is = is; + exports.isAssociative = isAssociative; + exports.isCollection = isCollection; + exports.isImmutable = isImmutable; + exports.isIndexed = isIndexed; + exports.isKeyed = isKeyed; + exports.isList = isList; + exports.isMap = isMap; + exports.isOrdered = isOrdered; + exports.isOrderedMap = isOrderedMap; + exports.isOrderedSet = isOrderedSet; + exports.isPlainObject = isPlainObject; + exports.isRecord = isRecord; + exports.isSeq = isSeq; + exports.isSet = isSet; + exports.isStack = isStack; + exports.isValueObject = isValueObject; + exports.merge = merge; + exports.mergeDeep = mergeDeep$1; + exports.mergeDeepWith = mergeDeepWith$1; + exports.mergeWith = mergeWith; + exports.remove = remove; + exports.removeIn = removeIn; + exports.set = set; + exports.setIn = setIn$1; + exports.update = update$1; + exports.updateIn = updateIn$1; + exports.version = version; })); From 834ec98970c62487fbbf037ec5c076eb047235d0 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 25 Feb 2025 06:46:56 +0000 Subject: [PATCH 229/242] deploy: a6b6178f215ecc9b439efedb1ef0ade95f4365f0 --- dist/immutable.es.js | 43 ++++++++++++++++++++++++------------------- dist/immutable.js | 43 ++++++++++++++++++++++++------------------- 2 files changed, 48 insertions(+), 38 deletions(-) diff --git a/dist/immutable.es.js b/dist/immutable.es.js index 302803c449..dc15773157 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -2198,19 +2198,23 @@ function quoteString(value) { } function has(collection, key) { - return isImmutable(collection) - ? collection.has(key) - : isDataStructure(collection) && hasOwnProperty.call(collection, key); + return isImmutable(collection) + ? // @ts-expect-error key might be a number or symbol, which is not handled be Record key type + collection.has(key) + : isDataStructure(collection) && hasOwnProperty.call(collection, key); } function get(collection, key, notSetValue) { - return isImmutable(collection) - ? collection.get(key, notSetValue) - : !has(collection, key) - ? notSetValue - : typeof collection.get === 'function' - ? collection.get(key) - : collection[key]; + return isImmutable(collection) + ? collection.get(key, notSetValue) + : !has(collection, key) + ? notSetValue + : // @ts-expect-error weird "get" here, + typeof collection.get === 'function' + ? // @ts-expect-error weird "get" here, + collection.get(key) + : // @ts-expect-error key is unknown here, + collection[key]; } function shallowCopy(from) { @@ -4928,15 +4932,16 @@ var Range = /*@__PURE__*/(function (IndexedSeq) { var EMPTY_RANGE; function getIn$1(collection, searchKeyPath, notSetValue) { - var keyPath = coerceKeyPath(searchKeyPath); - var i = 0; - while (i !== keyPath.length) { - collection = get(collection, keyPath[i++], NOT_SET); - if (collection === NOT_SET) { - return notSetValue; + var keyPath = coerceKeyPath(searchKeyPath); + var i = 0; + while (i !== keyPath.length) { + // @ts-expect-error keyPath[i++] can not be undefined by design + collection = get(collection, keyPath[i++], NOT_SET); + if (collection === NOT_SET) { + return notSetValue; + } } - } - return collection; + return collection; } function getIn(searchKeyPath, notSetValue) { @@ -4944,7 +4949,7 @@ function getIn(searchKeyPath, notSetValue) { } function hasIn$1(collection, keyPath) { - return getIn$1(collection, keyPath, NOT_SET) !== NOT_SET; + return getIn$1(collection, keyPath, NOT_SET) !== NOT_SET; } function hasIn(searchKeyPath) { diff --git a/dist/immutable.js b/dist/immutable.js index 86a078f6bf..3081fe600b 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -2204,19 +2204,23 @@ } function has(collection, key) { - return isImmutable(collection) - ? collection.has(key) - : isDataStructure(collection) && hasOwnProperty.call(collection, key); + return isImmutable(collection) + ? // @ts-expect-error key might be a number or symbol, which is not handled be Record key type + collection.has(key) + : isDataStructure(collection) && hasOwnProperty.call(collection, key); } function get(collection, key, notSetValue) { - return isImmutable(collection) - ? collection.get(key, notSetValue) - : !has(collection, key) - ? notSetValue - : typeof collection.get === 'function' - ? collection.get(key) - : collection[key]; + return isImmutable(collection) + ? collection.get(key, notSetValue) + : !has(collection, key) + ? notSetValue + : // @ts-expect-error weird "get" here, + typeof collection.get === 'function' + ? // @ts-expect-error weird "get" here, + collection.get(key) + : // @ts-expect-error key is unknown here, + collection[key]; } function shallowCopy(from) { @@ -4934,15 +4938,16 @@ var EMPTY_RANGE; function getIn$1(collection, searchKeyPath, notSetValue) { - var keyPath = coerceKeyPath(searchKeyPath); - var i = 0; - while (i !== keyPath.length) { - collection = get(collection, keyPath[i++], NOT_SET); - if (collection === NOT_SET) { - return notSetValue; + var keyPath = coerceKeyPath(searchKeyPath); + var i = 0; + while (i !== keyPath.length) { + // @ts-expect-error keyPath[i++] can not be undefined by design + collection = get(collection, keyPath[i++], NOT_SET); + if (collection === NOT_SET) { + return notSetValue; + } } - } - return collection; + return collection; } function getIn(searchKeyPath, notSetValue) { @@ -4950,7 +4955,7 @@ } function hasIn$1(collection, keyPath) { - return getIn$1(collection, keyPath, NOT_SET) !== NOT_SET; + return getIn$1(collection, keyPath, NOT_SET) !== NOT_SET; } function hasIn(searchKeyPath) { From 64d1f0630bd924b99e8b23fefa7f25f7988ee4b6 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 11 Mar 2025 02:53:53 +0000 Subject: [PATCH 230/242] deploy: 2a62b652745471a9449d5cc52ca1c13a788fec00 --- dist/immutable.es.js | 2 +- dist/immutable.js | 2 +- dist/immutable.min.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/dist/immutable.es.js b/dist/immutable.es.js index dc15773157..55cdd91123 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -2311,7 +2311,7 @@ function updateInDeeply( if (!wasNotSet && !isDataStructure(existing)) { throw new TypeError( 'Cannot update within non-data-structure value in path [' + - keyPath.slice(0, i).map(quoteString) + + Array.from(keyPath).slice(0, i).map(quoteString) + ']: ' + existing ); diff --git a/dist/immutable.js b/dist/immutable.js index 3081fe600b..a27bd4d833 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -2317,7 +2317,7 @@ if (!wasNotSet && !isDataStructure(existing)) { throw new TypeError( 'Cannot update within non-data-structure value in path [' + - keyPath.slice(0, i).map(quoteString) + + Array.from(keyPath).slice(0, i).map(quoteString) + ']: ' + existing ); diff --git a/dist/immutable.min.js b/dist/immutable.min.js index 692260051e..f04d2ab99d 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -22,4 +22,4 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).Immutable={})}(this,(function(t){"use strict";var e="delete",r=5,n=1<>>0;if(""+r!==e||4294967295===r)return NaN;e=r}return e<0?a(t)+e:e}function f(){return!0}function h(t,e,r){return(0===t&&!v(t)||void 0!==r&&t<=-r)&&(void 0===e||void 0!==r&&e>=r)}function p(t,e){return l(t,e,0)}function _(t,e){return l(t,e,e)}function l(t,e,r){return void 0===t?r:v(t)?e===1/0?e:0|Math.max(0,e+t):void 0===e||e===t?t:0|Math.min(e,t)}function v(t){return t<0||0===t&&1/t==-1/0}var y="@@__IMMUTABLE_ITERABLE__@@";function d(t){return Boolean(t&&t[y])}var g="@@__IMMUTABLE_KEYED__@@";function w(t){return Boolean(t&&t[g])}var m="@@__IMMUTABLE_INDEXED__@@";function b(t){return Boolean(t&&t[m])}function z(t){return w(t)||b(t)}var S=function(t){return d(t)?t:X(t)},I=function(t){function e(t){return w(t)?t:F(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(S),O=function(t){function e(t){return b(t)?t:G(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(S),E=function(t){function e(t){return d(t)&&!z(t)?t:Z(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(S);S.Keyed=I,S.Indexed=O,S.Set=E;var j="@@__IMMUTABLE_SEQ__@@";function q(t){return Boolean(t&&t[j])}var M="@@__IMMUTABLE_RECORD__@@";function D(t){return Boolean(t&&t[M])}function x(t){return d(t)||D(t)}var A="@@__IMMUTABLE_ORDERED__@@";function k(t){return Boolean(t&&t[A])}var R=0,U=1,T=2,B="function"==typeof Symbol&&Symbol.iterator,K="@@iterator",L=B||K,C=function(t){this.next=t};function P(t,e,r,n){var i=t===R?e:t===U?r:[e,r];return n?n.value=i:n={value:i,done:!1},n}function W(){return{value:void 0,done:!0}}function N(t){return!!Array.isArray(t)||!!V(t)}function H(t){return t&&"function"==typeof t.next}function J(t){var e=V(t);return e&&e.call(t)}function V(t){var e=t&&(B&&t[B]||t[K]);if("function"==typeof e)return e}C.prototype.toString=function(){return"[Iterator]"},C.KEYS=R,C.VALUES=U,C.ENTRIES=T,C.prototype.inspect=C.prototype.toSource=function(){return this.toString()},C.prototype[L]=function(){return this};var Y=Object.prototype.hasOwnProperty;function Q(t){return!(!Array.isArray(t)&&"string"!=typeof t)||t&&"object"==typeof t&&Number.isInteger(t.length)&&t.length>=0&&(0===t.length?1===Object.keys(t).length:t.hasOwnProperty(t.length-1))}var X=function(t){function e(t){return null==t?nt():x(t)?t.toSeq():function(t){var e=ut(t);if(e)return(n=V(r=t))&&n===r.entries?e.fromEntrySeq():function(t){var e=V(t);return e&&e===t.keys}(t)?e.toSetSeq():e;var r,n;if("object"==typeof t)return new tt(t);throw new TypeError("Expected Array or collection object of values, or keyed object: "+t)}(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq {","}")},e.prototype.cacheResult=function(){return!this._cache&&this.__iterateUncached&&(this._cache=this.entrySeq().toArray(),this.size=this._cache.length),this},e.prototype.__iterate=function(t,e){var r=this._cache;if(r){for(var n=r.length,i=0;i!==n;){var o=r[e?n-++i:i++];if(!1===t(o[1],o[0],this))break}return i}return this.__iterateUncached(t,e)},e.prototype.__iterator=function(t,e){var r=this._cache;if(r){var n=r.length,i=0;return new C((function(){if(i===n)return{value:void 0,done:!0};var o=r[e?n-++i:i++];return P(t,o[0],o[1])}))}return this.__iteratorUncached(t,e)},e}(S),F=function(t){function e(t){return null==t?nt().toKeyedSeq():d(t)?w(t)?t.toSeq():t.fromEntrySeq():D(t)?t.toSeq():it(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toKeyedSeq=function(){return this},e}(X),G=function(t){function e(t){return null==t?nt():d(t)?w(t)?t.entrySeq():t.toIndexedSeq():D(t)?t.toSeq().entrySeq():ot(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return e(arguments)},e.prototype.toIndexedSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq [","]")},e}(X),Z=function(t){function e(t){return(d(t)&&!z(t)?t:G(t)).toSetSeq()}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return e(arguments)},e.prototype.toSetSeq=function(){return this},e}(X);X.isSeq=q,X.Keyed=F,X.Set=Z,X.Indexed=G,X.prototype[j]=!0;var $=function(t){function e(t){this._array=t,this.size=t.length}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t,e){return this.has(t)?this._array[c(this,t)]:e},e.prototype.__iterate=function(t,e){for(var r=this._array,n=r.length,i=0;i!==n;){var o=e?n-++i:i++;if(!1===t(r[o],o,this))break}return i},e.prototype.__iterator=function(t,e){var r=this._array,n=r.length,i=0;return new C((function(){if(i===n)return{value:void 0,done:!0};var o=e?n-++i:i++;return P(t,o,r[o])}))},e}(G),tt=function(t){function e(t){var e=Object.keys(t).concat(Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(t):[]);this._object=t,this._keys=e,this.size=e.length}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t,e){return void 0===e||this.has(t)?this._object[t]:e},e.prototype.has=function(t){return Y.call(this._object,t)},e.prototype.__iterate=function(t,e){for(var r=this._object,n=this._keys,i=n.length,o=0;o!==i;){var u=n[e?i-++o:o++];if(!1===t(r[u],u,this))break}return o},e.prototype.__iterator=function(t,e){var r=this._object,n=this._keys,i=n.length,o=0;return new C((function(){if(o===i)return{value:void 0,done:!0};var u=n[e?i-++o:o++];return P(t,u,r[u])}))},e}(F);tt.prototype[A]=!0;var et,rt=function(t){function e(t){this._collection=t,this.size=t.length||t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.__iterateUncached=function(t,e){if(e)return this.cacheResult().__iterate(t,e);var r=J(this._collection),n=0;if(H(r))for(var i;!(i=r.next()).done&&!1!==t(i.value,n++,this););return n},e.prototype.__iteratorUncached=function(t,e){if(e)return this.cacheResult().__iterator(t,e);var r=J(this._collection);if(!H(r))return new C(W);var n=0;return new C((function(){var e=r.next();return e.done?e:P(t,n++,e.value)}))},e}(G);function nt(){return et||(et=new $([]))}function it(t){var e=ut(t);if(e)return e.fromEntrySeq();if("object"==typeof t)return new tt(t);throw new TypeError("Expected Array or collection object of [k, v] entries, or keyed object: "+t)}function ot(t){var e=ut(t);if(e)return e;throw new TypeError("Expected Array or collection object of values: "+t)}function ut(t){return Q(t)?new $(t):N(t)?new rt(t):void 0}var st="@@__IMMUTABLE_MAP__@@";function at(t){return Boolean(t&&t[st])}function ct(t){return at(t)&&k(t)}function ft(t){return Boolean(t&&"function"==typeof t.equals&&"function"==typeof t.hashCode)}function ht(t,e){if(t===e||t!=t&&e!=e)return!0;if(!t||!e)return!1;if("function"==typeof t.valueOf&&"function"==typeof e.valueOf){if((t=t.valueOf())===(e=e.valueOf())||t!=t&&e!=e)return!0;if(!t||!e)return!1}return!!(ft(t)&&ft(e)&&t.equals(e))}var pt="function"==typeof Math.imul&&-2===Math.imul(4294967295,2)?Math.imul:function(t,e){var r=65535&(t|=0),n=65535&(e|=0);return r*n+((t>>>16)*n+r*(e>>>16)<<16>>>0)|0};function _t(t){return t>>>1&1073741824|3221225471&t}var lt=Object.prototype.valueOf;function vt(t){if(null==t)return yt(t);if("function"==typeof t.hashCode)return _t(t.hashCode(t));var e,r=(e=t).valueOf!==lt&&"function"==typeof e.valueOf?e.valueOf(e):e;if(null==r)return yt(r);switch(typeof r){case"boolean":return r?1108378657:1108378656;case"number":return function(t){if(t!=t||t===1/0)return 0;var e=0|t;e!==t&&(e^=4294967295*t);for(;t>4294967295;)e^=t/=4294967295;return _t(e)}(r);case"string":return r.length>Et?function(t){var e=Mt[t];void 0===e&&(e=dt(t),qt===jt&&(qt=0,Mt={}),qt++,Mt[t]=e);return e}(r):dt(r);case"object":case"function":return function(t){var e;if(zt&&void 0!==(e=bt.get(t)))return e;if(e=t[Ot],void 0!==e)return e;if(!wt){if(void 0!==(e=t.propertyIsEnumerable&&t.propertyIsEnumerable[Ot]))return e;if(void 0!==(e=function(t){if(t&&t.nodeType>0)switch(t.nodeType){case 1:return t.uniqueID;case 9:return t.documentElement&&t.documentElement.uniqueID}}(t)))return e}if(e=mt(),zt)bt.set(t,e);else{if(void 0!==gt&&!1===gt(t))throw new Error("Non-extensible objects are not allowed as keys.");if(wt)Object.defineProperty(t,Ot,{enumerable:!1,configurable:!1,writable:!1,value:e});else if(void 0!==t.propertyIsEnumerable&&t.propertyIsEnumerable===t.constructor.prototype.propertyIsEnumerable)t.propertyIsEnumerable=function(){return this.constructor.prototype.propertyIsEnumerable.apply(this,arguments)},t.propertyIsEnumerable[Ot]=e;else{if(void 0===t.nodeType)throw new Error("Unable to set a non-enumerable property on object.");t[Ot]=e}}return e}(r);case"symbol":return function(t){var e=St[t];if(void 0!==e)return e;return e=mt(),St[t]=e,e}(r);default:if("function"==typeof r.toString)return dt(r.toString());throw new Error("Value type "+typeof r+" cannot be hashed.")}}function yt(t){return null===t?1108378658:1108378659}function dt(t){for(var e=0,r=0;r=0&&(a.get=function(e,r){return(e=c(this,e))>=0&&eo)return{value:void 0,done:!0};var t=i.next();return n||e===U||t.done?t:P(e,a-1,e===R?void 0:t.value[1],t)}))},a}function Lt(t,e,r,n){var i=Xt(t);return i.__iterateUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterate(i,o);var s=!0,a=0;return t.__iterate((function(t,o,c){if(!s||!(s=e.call(r,t,o,c)))return a++,i(t,n?o:a-1,u)})),a},i.__iteratorUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterator(i,o);var s=t.__iterator(T,o),a=!0,c=0;return new C((function(){var t,o,f;do{if((t=s.next()).done)return n||i===U?t:P(i,c++,i===R?void 0:t.value[1],t);var h=t.value;o=h[0],f=h[1],a&&(a=e.call(r,f,o,u))}while(a);return i===T?t:P(i,o,f,t)}))},i}xt.prototype.cacheResult=Dt.prototype.cacheResult=At.prototype.cacheResult=kt.prototype.cacheResult=Ft;var Ct=function(t){function e(t){this._wrappedIterables=t.flatMap((function(t){return t._wrappedIterables?t._wrappedIterables:[t]})),this.size=this._wrappedIterables.reduce((function(t,e){if(void 0!==t){var r=e.size;if(void 0!==r)return t+r}}),0),this[g]=this._wrappedIterables[0][g],this[m]=this._wrappedIterables[0][m],this[A]=this._wrappedIterables[0][A]}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.__iterateUncached=function(t,e){if(0!==this._wrappedIterables.length){if(e)return this.cacheResult().__iterate(t,e);for(var r=0,n=w(this),i=n?T:U,o=this._wrappedIterables[r].__iterator(i,e),u=!0,s=0;u;){for(var a=o.next();a.done;){if(++r===this._wrappedIterables.length)return s;a=(o=this._wrappedIterables[r].__iterator(i,e)).next()}u=!1!==(n?t(a.value[1],a.value[0],this):t(a.value,s,this)),s++}return s}},e.prototype.__iteratorUncached=function(t,e){var r=this;if(0===this._wrappedIterables.length)return new C(W);if(e)return this.cacheResult().__iterator(t,e);var n=0,i=this._wrappedIterables[n].__iterator(t,e);return new C((function(){for(var o=i.next();o.done;){if(++n===r._wrappedIterables.length)return o;o=(i=r._wrappedIterables[n].__iterator(t,e)).next()}return o}))},e}(X);function Pt(t,e,r){var n=Xt(t);return n.__iterateUncached=function(i,o){if(o)return this.cacheResult().__iterate(i,o);var u=0,s=!1;return function t(a,c){a.__iterate((function(o,a){return(!e||c0}function Jt(t,e,r,n){var i=Xt(t),o=new $(r).map((function(t){return t.size}));return i.size=n?o.max():o.min(),i.__iterate=function(t,e){for(var r,n=this.__iterator(U,e),i=0;!(r=n.next()).done&&!1!==t(r.value,i++,this););return i},i.__iteratorUncached=function(t,i){var o=r.map((function(t){return t=S(t),J(i?t.reverse():t)})),u=0,s=!1;return new C((function(){var r;return s||(r=o.map((function(t){return t.next()})),s=n?r.every((function(t){return t.done})):r.some((function(t){return t.done}))),s?{value:void 0,done:!0}:P(t,u++,e.apply(null,r.map((function(t){return t.value}))))}))},i}function Vt(t,e){return t===e?t:q(t)?e:t.constructor(e)}function Yt(t){if(t!==Object(t))throw new TypeError("Expected [K, V] tuple: "+t)}function Qt(t){return w(t)?I:b(t)?O:E}function Xt(t){return Object.create((w(t)?F:b(t)?G:Z).prototype)}function Ft(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size,this):X.prototype.cacheResult.call(this)}function Gt(t,e){return void 0===t&&void 0===e?0:void 0===t?1:void 0===e?-1:t>e?1:t0;)e[r]=arguments[r+1];if("function"!=typeof t)throw new TypeError("Invalid merger function: "+t);return ze(this,e,t)}function ze(t,e,r){for(var n=[],i=0;i0;)e[r]=arguments[r+1];return Se(this,e,t)}function je(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return he(this,t,Je(),(function(t){return Ie(t,e)}))}function qe(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return he(this,t,Je(),(function(t){return Se(t,e)}))}function Me(t){var e=this.asMutable();return t(e),e.wasAltered()?e.__ensureOwner(this.__ownerID):this}function De(){return this.__ownerID?this:this.__ensureOwner(new s)}function xe(){return this.__ensureOwner()}function Ae(){return this.__altered}var ke=function(t){function e(e){return null==e?Je():at(e)&&!k(e)?e:Je().withMutations((function(r){var n=t(e);te(n.size),n.forEach((function(t,e){return r.set(e,t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toString=function(){return this.__toString("Map {","}")},e.prototype.get=function(t,e){return this._root?this._root.get(0,void 0,t,e):e},e.prototype.set=function(t,e){return Ve(this,t,e)},e.prototype.remove=function(t){return Ve(this,t,o)},e.prototype.deleteAll=function(t){var e=S(t);return 0===e.size?this:this.withMutations((function(t){e.forEach((function(e){return t.remove(e)}))}))},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):Je()},e.prototype.sort=function(t){return yr(Wt(this,t))},e.prototype.sortBy=function(t,e){return yr(Wt(this,e,t))},e.prototype.map=function(t,e){var r=this;return this.withMutations((function(n){n.forEach((function(i,o){n.set(o,t.call(e,i,o,r))}))}))},e.prototype.__iterator=function(t,e){return new Pe(this,t,e)},e.prototype.__iterate=function(t,e){var r=this,n=0;return this._root&&this._root.iterate((function(e){return n++,t(e[1],e[0],r)}),e),n},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?He(this.size,this._root,t,this.__hash):0===this.size?Je():(this.__ownerID=t,this.__altered=!1,this)},e}(I);ke.isMap=at;var Re=ke.prototype;Re[st]=!0,Re[e]=Re.remove,Re.removeAll=Re.deleteAll,Re.setIn=le,Re.removeIn=Re.deleteIn=ye,Re.update=ge,Re.updateIn=we,Re.merge=Re.concat=me,Re.mergeWith=be,Re.mergeDeep=Oe,Re.mergeDeepWith=Ee,Re.mergeIn=je,Re.mergeDeepIn=qe,Re.withMutations=Me,Re.wasAltered=Ae,Re.asImmutable=xe,Re["@@transducer/init"]=Re.asMutable=De,Re["@@transducer/step"]=function(t,e){return t.set(e[0],e[1])},Re["@@transducer/result"]=function(t){return t.asImmutable()};var Ue=function(t,e){this.ownerID=t,this.entries=e};Ue.prototype.get=function(t,e,r,n){for(var i=this.entries,o=0,u=i.length;o=Ze)return function(t,e,r,n){t||(t=new s);for(var i=new Le(t,vt(r),[r,n]),o=0;o>>t)&i),s=this.bitmap;return 0==(s&u)?o:this.nodes[Fe(s&u-1)].get(t+r,e,n,o)},Te.prototype.update=function(t,e,u,s,a,c,f){void 0===u&&(u=vt(s));var h=(0===e?u:u>>>e)&i,p=1<=$e)return function(t,e,r,i,o){for(var u=0,s=new Array(n),a=0;0!==r;a++,r>>>=1)s[a]=1&r?e[u++]:void 0;return s[i]=o,new Be(t,u+1,s)}(t,y,_,h,g);if(l&&!g&&2===y.length&&Qe(y[1^v]))return y[1^v];if(l&&g&&1===y.length&&Qe(g))return g;var w=t&&t===this.ownerID,m=l?g?_:_^p:_|p,b=l?g?Ge(y,v,g,w):function(t,e,r){var n=t.length-1;if(r&&e===n)return t.pop(),t;for(var i=new Array(n),o=0,u=0;u>>t)&i,s=this.nodes[u];return s?s.get(t+r,e,n,o):o},Be.prototype.update=function(t,e,n,u,s,a,c){void 0===n&&(n=vt(u));var f=(0===e?n:n>>>e)&i,h=s===o,p=this.nodes,_=p[f];if(h&&!_)return this;var l=Ye(_,t,e+r,n,u,s,a,c);if(l===_)return this;var v=this.count;if(_){if(!l&&--v>>n)&i,c=(0===n?o:o>>>n)&i,f=a===c?[Xe(t,e,n+r,o,u)]:(s=new Le(e,o,u),a>1&1431655765))+(t>>2&858993459))+(t>>4)&252645135,t+=t>>8,127&(t+=t>>16)}function Ge(t,e,r,n){var i=n?t:Zt(t);return i[e]=r,i}var Ze=n/4,$e=n/2,tr=n/4,er="@@__IMMUTABLE_LIST__@@";function rr(t){return Boolean(t&&t[er])}var nr=function(t){function e(e){var i=cr();if(null==e)return i;if(rr(e))return e;var o=t(e),u=o.size;return 0===u?i:(te(u),u>0&&u=0&&t=t.size||e<0)return t.withMutations((function(t){e<0?_r(t,e).set(0,r):_r(t,0,e+1).set(e,r)}));e+=t._origin;var n=t._tail,i=t._root,o={value:!1};e>=lr(t._capacity)?n=fr(n,t.__ownerID,0,e,r,o):i=fr(i,t.__ownerID,t._level,e,r,o);if(!o.value)return t;if(t.__ownerID)return t._root=i,t._tail=n,t.__hash=void 0,t.__altered=!0,t;return ar(t._origin,t._capacity,t._level,i,n)}(this,t,e)},e.prototype.remove=function(t){return this.has(t)?0===t?this.shift():t===this.size-1?this.pop():this.splice(t,1):this},e.prototype.insert=function(t,e){return this.splice(t,0,e)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=this._origin=this._capacity=0,this._level=r,this._root=this._tail=this.__hash=void 0,this.__altered=!0,this):cr()},e.prototype.push=function(){var t=arguments,e=this.size;return this.withMutations((function(r){_r(r,0,e+t.length);for(var n=0;n>>e&i;if(o>=this.array.length)return new or([],t);var u,s=0===o;if(e>0){var a=this.array[o];if((u=a&&a.removeBefore(t,e-r,n))===a&&s)return this}if(s&&!u)return this;var c=hr(this,t);if(!s)for(var f=0;f>>e&i;if(s>=this.array.length)return this;if(e>0){var a=this.array[s];if((u=a&&a.removeAfter(t,e-r,o))===a&&s===this.array.length-1)return this}var c=hr(this,t);return c.array.splice(s+1),u&&(c.array[s]=u),c};var ur={};function sr(t,e){var i=t._origin,o=t._capacity,u=lr(o),s=t._tail;return a(t._root,t._level,0);function a(t,c,f){return 0===c?function(t,r){var a=r===u?s&&s.array:t&&t.array,c=r>i?0:i-r,f=o-r;f>n&&(f=n);return function(){if(c===f)return ur;var t=e?--f:c++;return a&&a[t]}}(t,f):function(t,u,s){var c,f=t&&t.array,h=s>i?0:i-s>>u,p=1+(o-s>>u);p>n&&(p=n);return function(){for(;;){if(c){var t=c();if(t!==ur)return t;c=null}if(h===p)return ur;var n=e?--p:h++;c=a(f&&f[n],u-r,s+(n<>>n&i,h=t&&f0){var p=t&&t.array[f],_=fr(p,e,n-r,o,s,a);return _===p?t:((c=hr(t,e)).array[f]=_,c)}return h&&t.array[f]===s?t:(a&&u(a),c=hr(t,e),void 0===s&&f===c.array.length-1?c.array.pop():c.array[f]=s,c)}function hr(t,e){return e&&t&&e===t.ownerID?t:new or(t?t.array.slice():[],e)}function pr(t,e){if(e>=lr(t._capacity))return t._tail;if(e<1<0;)n=n.array[e>>>o&i],o-=r;return n}}function _r(t,e,n){void 0!==e&&(e|=0),void 0!==n&&(n|=0);var o=t.__ownerID||new s,u=t._origin,a=t._capacity,c=u+e,f=void 0===n?a:n<0?a+n:u+n;if(c===u&&f===a)return t;if(c>=f)return t.clear();for(var h=t._level,p=t._root,_=0;c+_<0;)p=new or(p&&p.array.length?[void 0,p]:[],o),_+=1<<(h+=r);_&&(c+=_,u+=_,f+=_,a+=_);for(var l=lr(a),v=lr(f);v>=1<l?new or([],o):y;if(y&&v>l&&cr;w-=r){var m=l>>>w&i;g=g.array[m]=hr(g.array[m],o)}g.array[l>>>r&i]=y}if(f=v)c-=v,f-=v,h=r,p=null,d=d&&d.removeBefore(o,0,c);else if(c>u||v>>h&i;if(b!==v>>>h&i)break;b&&(_+=(1<u&&(p=p.removeBefore(o,h,c-_)),p&&v>>r<=n&&a.size>=2*s.size?(i=(u=a.filter((function(t,e){return void 0!==t&&c!==e}))).toKeyedSeq().map((function(t){return t[0]})).flip().toMap(),t.__ownerID&&(i.__ownerID=u.__ownerID=t.__ownerID)):(i=s.remove(e),u=c===a.size-1?a.pop():a.set(c,void 0))}else if(f){if(r===a.get(c)[1])return t;i=s,u=a.set(c,[e,r])}else i=s.set(e,a.size),u=a.set(a.size,[e,r]);return t.__ownerID?(t.size=i.size,t._map=i,t._list=u,t.__hash=void 0,t.__altered=!0,t):dr(i,u)}yr.isOrderedMap=ct,yr.prototype[A]=!0,yr.prototype[e]=yr.prototype.remove;var mr="@@__IMMUTABLE_STACK__@@";function br(t){return Boolean(t&&t[mr])}var zr=function(t){function e(t){return null==t?Er():br(t)?t:Er().pushAll(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("Stack [","]")},e.prototype.get=function(t,e){var r=this._head;for(t=c(this,t);r&&t--;)r=r.next;return r?r.value:e},e.prototype.peek=function(){return this._head&&this._head.value},e.prototype.push=function(){var t=arguments;if(0===arguments.length)return this;for(var e=this.size+arguments.length,r=this._head,n=arguments.length-1;n>=0;n--)r={value:t[n],next:r};return this.__ownerID?(this.size=e,this._head=r,this.__hash=void 0,this.__altered=!0,this):Or(e,r)},e.prototype.pushAll=function(e){if(0===(e=t(e)).size)return this;if(0===this.size&&br(e))return e;te(e.size);var r=this.size,n=this._head;return e.__iterate((function(t){r++,n={value:t,next:n}}),!0),this.__ownerID?(this.size=r,this._head=n,this.__hash=void 0,this.__altered=!0,this):Or(r,n)},e.prototype.pop=function(){return this.slice(1)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):Er()},e.prototype.slice=function(e,r){if(h(e,r,this.size))return this;var n=p(e,this.size);if(_(r,this.size)!==this.size)return t.prototype.slice.call(this,e,r);for(var i=this.size-n,o=this._head;n--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):Or(i,o)},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Or(this.size,this._head,t,this.__hash):0===this.size?Er():(this.__ownerID=t,this.__altered=!1,this)},e.prototype.__iterate=function(t,e){var r=this;if(e)return new $(this.toArray()).__iterate((function(e,n){return t(e,n,r)}),e);for(var n=0,i=this._head;i&&!1!==t(i.value,n++,this);)i=i.next;return n},e.prototype.__iterator=function(t,e){if(e)return new $(this.toArray()).__iterator(t,e);var r=0,n=this._head;return new C((function(){if(n){var e=n.value;return n=n.next,P(t,r++,e)}return{value:void 0,done:!0}}))},e}(O);zr.isStack=br;var Sr,Ir=zr.prototype;function Or(t,e,r,n){var i=Object.create(Ir);return i.size=t,i._head=e,i.__ownerID=r,i.__hash=n,i.__altered=!1,i}function Er(){return Sr||(Sr=Or(0))}Ir[mr]=!0,Ir.shift=Ir.pop,Ir.unshift=Ir.push,Ir.unshiftAll=Ir.pushAll,Ir.withMutations=Me,Ir.wasAltered=Ae,Ir.asImmutable=xe,Ir["@@transducer/init"]=Ir.asMutable=De,Ir["@@transducer/step"]=function(t,e){return t.unshift(e)},Ir["@@transducer/result"]=function(t){return t.asImmutable()};var jr="@@__IMMUTABLE_SET__@@";function qr(t){return Boolean(t&&t[jr])}function Mr(t){return qr(t)&&k(t)}function Dr(t,e){if(t===e)return!0;if(!d(e)||void 0!==t.size&&void 0!==e.size&&t.size!==e.size||void 0!==t.__hash&&void 0!==e.__hash&&t.__hash!==e.__hash||w(t)!==w(e)||b(t)!==b(e)||k(t)!==k(e))return!1;if(0===t.size&&0===e.size)return!0;var r=!z(t);if(k(t)){var n=t.entries();return e.every((function(t,e){var i=n.next().value;return i&&ht(i[1],t)&&(r||ht(i[0],e))}))&&n.next().done}var i=!1;if(void 0===t.size)if(void 0===e.size)"function"==typeof t.cacheResult&&t.cacheResult();else{i=!0;var u=t;t=e,e=u}var s=!0,a=e.__iterate((function(e,n){if(r?!t.has(e):i?!ht(e,t.get(n,o)):!ht(t.get(n,o),e))return s=!1,!1}));return s&&t.size===a}function xr(t,e){var r=function(r){t.prototype[r]=e[r]};return Object.keys(e).forEach(r),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(e).forEach(r),t}function Ar(t){if(!t||"object"!=typeof t)return t;if(!d(t)){if(!ie(t))return t;t=X(t)}if(w(t)){var e={};return t.__iterate((function(t,r){e[r]=Ar(t)})),e}var r=[];return t.__iterate((function(t){r.push(Ar(t))})),r}var kr=function(t){function e(e){return null==e?Kr():qr(e)&&!k(e)?e:Kr().withMutations((function(r){var n=t(e);te(n.size),n.forEach((function(t){return r.add(t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(I(t).keySeq())},e.intersect=function(t){return(t=S(t).toArray()).length?Ur.intersect.apply(e(t.pop()),t):Kr()},e.union=function(t){return(t=S(t).toArray()).length?Ur.union.apply(e(t.pop()),t):Kr()},e.prototype.toString=function(){return this.__toString("Set {","}")},e.prototype.has=function(t){return this._map.has(t)},e.prototype.add=function(t){return Tr(this,this._map.set(t,t))},e.prototype.remove=function(t){return Tr(this,this._map.remove(t))},e.prototype.clear=function(){return Tr(this,this._map.clear())},e.prototype.map=function(t,e){var r=this,n=!1,i=Tr(this,this._map.mapEntries((function(i){var o=i[1],u=t.call(e,o,o,r);return u!==o&&(n=!0),[u,u]}),e));return n?i:this},e.prototype.union=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return 0===(e=e.filter((function(t){return 0!==t.size}))).length?this:0!==this.size||this.__ownerID||1!==e.length?this.withMutations((function(r){for(var n=0;n=0&&e=0&&r>>-15,461845907),e=pt(e<<13|e>>>-13,5),e=pt((e=(e+3864292196|0)^t)^e>>>16,2246822507),e=_t((e=pt(e^e>>>13,3266489909))^e>>>16)}(t.size,n)}(this))}});var Jr=S.prototype;Jr[y]=!0,Jr[L]=Jr.values,Jr.toJSON=Jr.toArray,Jr.__toStringMapper=oe,Jr.inspect=Jr.toSource=function(){return this.toString()},Jr.chain=Jr.flatMap,Jr.contains=Jr.includes,xr(I,{flip:function(){return Vt(this,Rt(this))},mapEntries:function(t,e){var r=this,n=0;return Vt(this,this.toSeq().map((function(i,o){return t.call(e,[o,i],n++,r)})).fromEntrySeq())},mapKeys:function(t,e){var r=this;return Vt(this,this.toSeq().flip().map((function(n,i){return t.call(e,n,i,r)})).flip())}});var Vr=I.prototype;Vr[g]=!0,Vr[L]=Jr.entries,Vr.toJSON=Hr,Vr.__toStringMapper=function(t,e){return oe(e)+": "+oe(t)},xr(O,{toKeyedSeq:function(){return new Dt(this,!1)},filter:function(t,e){return Vt(this,Bt(this,t,e,!1))},findIndex:function(t,e){var r=this.findEntry(t,e);return r?r[0]:-1},indexOf:function(t){var e=this.keyOf(t);return void 0===e?-1:e},lastIndexOf:function(t){var e=this.lastKeyOf(t);return void 0===e?-1:e},reverse:function(){return Vt(this,Tt(this,!1))},slice:function(t,e){return Vt(this,Kt(this,t,e,!1))},splice:function(t,e){var r=arguments.length;if(e=Math.max(e||0,0),0===r||2===r&&!e)return this;t=p(t,t<0?this.count():this.size);var n=this.slice(0,t);return Vt(this,1===r?n:n.concat(Zt(arguments,2),this.slice(t+e)))},findLastIndex:function(t,e){var r=this.findLastEntry(t,e);return r?r[0]:-1},first:function(t){return this.get(0,t)},flatten:function(t){return Vt(this,Pt(this,t,!1))},get:function(t,e){return(t=c(this,t))<0||this.size===1/0||void 0!==this.size&&t>this.size?e:this.find((function(e,r){return r===t}),void 0,e)},has:function(t){return(t=c(this,t))>=0&&(void 0!==this.size?this.size===1/0||te?-1:0}function rn(t,e){return t^e+2654435769+(t<<6)+(t>>2)|0}Qr.has=Jr.includes,Qr.contains=Qr.includes,Qr.keys=Qr.values,xr(F,Vr),xr(G,Yr),xr(Z,Qr);var nn=function(t){function e(t){return null==t?an():Mr(t)?t:an().withMutations((function(e){var r=E(t);te(r.size),r.forEach((function(t){return e.add(t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(I(t).keySeq())},e.prototype.toString=function(){return this.__toString("OrderedSet {","}")},e}(kr);nn.isOrderedSet=Mr;var on,un=nn.prototype;function sn(t,e){var r=Object.create(un);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function an(){return on||(on=sn(gr()))}un[A]=!0,un.zip=Yr.zip,un.zipWith=Yr.zipWith,un.zipAll=Yr.zipAll,un.__empty=an,un.__make=sn;var cn=function(t,e){var r;!function(t){if(D(t))throw new Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(x(t))throw new Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(null===t||"object"!=typeof t)throw new Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}(t);var n=function(o){var u=this;if(o instanceof n)return o;if(!(this instanceof n))return new n(o);if(!r){r=!0;var s=Object.keys(t),a=i._indices={};i._name=e,i._keys=s,i._defaultValues=t;for(var c=0;c2?[]:void 0,{"":t})},t.get=se,t.getIn=Pr,t.has=ue,t.hasIn=Nr,t.hash=vt,t.is=ht,t.isAssociative=z,t.isCollection=d,t.isImmutable=x,t.isIndexed=b,t.isKeyed=w,t.isList=rr,t.isMap=at,t.isOrdered=k,t.isOrderedMap=ct,t.isOrderedSet=Mr,t.isPlainObject=ne,t.isRecord=D,t.isSeq=q,t.isSet=qr,t.isStack=br,t.isValueObject=ft,t.merge=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Ie(t,e)},t.mergeDeep=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Se(t,e)},t.mergeDeepWith=function(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];return Se(e,r,t)},t.mergeWith=function(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];return Ie(e,r,t)},t.remove=ce,t.removeIn=ve,t.set=fe,t.setIn=_e,t.update=de,t.updateIn=he,t.version="5.0.3"})); +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).Immutable={})}(this,(function(t){"use strict";var e="delete",r=5,n=1<>>0;if(""+r!==e||4294967295===r)return NaN;e=r}return e<0?a(t)+e:e}function f(){return!0}function h(t,e,r){return(0===t&&!v(t)||void 0!==r&&t<=-r)&&(void 0===e||void 0!==r&&e>=r)}function p(t,e){return l(t,e,0)}function _(t,e){return l(t,e,e)}function l(t,e,r){return void 0===t?r:v(t)?e===1/0?e:0|Math.max(0,e+t):void 0===e||e===t?t:0|Math.min(e,t)}function v(t){return t<0||0===t&&1/t==-1/0}var y="@@__IMMUTABLE_ITERABLE__@@";function d(t){return Boolean(t&&t[y])}var g="@@__IMMUTABLE_KEYED__@@";function w(t){return Boolean(t&&t[g])}var m="@@__IMMUTABLE_INDEXED__@@";function b(t){return Boolean(t&&t[m])}function z(t){return w(t)||b(t)}var S=function(t){return d(t)?t:X(t)},I=function(t){function e(t){return w(t)?t:F(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(S),O=function(t){function e(t){return b(t)?t:G(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(S),E=function(t){function e(t){return d(t)&&!z(t)?t:Z(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(S);S.Keyed=I,S.Indexed=O,S.Set=E;var j="@@__IMMUTABLE_SEQ__@@";function q(t){return Boolean(t&&t[j])}var M="@@__IMMUTABLE_RECORD__@@";function D(t){return Boolean(t&&t[M])}function x(t){return d(t)||D(t)}var A="@@__IMMUTABLE_ORDERED__@@";function k(t){return Boolean(t&&t[A])}var R=0,U=1,T=2,B="function"==typeof Symbol&&Symbol.iterator,K="@@iterator",L=B||K,C=function(t){this.next=t};function P(t,e,r,n){var i=t===R?e:t===U?r:[e,r];return n?n.value=i:n={value:i,done:!1},n}function W(){return{value:void 0,done:!0}}function N(t){return!!Array.isArray(t)||!!V(t)}function H(t){return t&&"function"==typeof t.next}function J(t){var e=V(t);return e&&e.call(t)}function V(t){var e=t&&(B&&t[B]||t[K]);if("function"==typeof e)return e}C.prototype.toString=function(){return"[Iterator]"},C.KEYS=R,C.VALUES=U,C.ENTRIES=T,C.prototype.inspect=C.prototype.toSource=function(){return this.toString()},C.prototype[L]=function(){return this};var Y=Object.prototype.hasOwnProperty;function Q(t){return!(!Array.isArray(t)&&"string"!=typeof t)||t&&"object"==typeof t&&Number.isInteger(t.length)&&t.length>=0&&(0===t.length?1===Object.keys(t).length:t.hasOwnProperty(t.length-1))}var X=function(t){function e(t){return null==t?nt():x(t)?t.toSeq():function(t){var e=ut(t);if(e)return(n=V(r=t))&&n===r.entries?e.fromEntrySeq():function(t){var e=V(t);return e&&e===t.keys}(t)?e.toSetSeq():e;var r,n;if("object"==typeof t)return new tt(t);throw new TypeError("Expected Array or collection object of values, or keyed object: "+t)}(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq {","}")},e.prototype.cacheResult=function(){return!this._cache&&this.__iterateUncached&&(this._cache=this.entrySeq().toArray(),this.size=this._cache.length),this},e.prototype.__iterate=function(t,e){var r=this._cache;if(r){for(var n=r.length,i=0;i!==n;){var o=r[e?n-++i:i++];if(!1===t(o[1],o[0],this))break}return i}return this.__iterateUncached(t,e)},e.prototype.__iterator=function(t,e){var r=this._cache;if(r){var n=r.length,i=0;return new C((function(){if(i===n)return{value:void 0,done:!0};var o=r[e?n-++i:i++];return P(t,o[0],o[1])}))}return this.__iteratorUncached(t,e)},e}(S),F=function(t){function e(t){return null==t?nt().toKeyedSeq():d(t)?w(t)?t.toSeq():t.fromEntrySeq():D(t)?t.toSeq():it(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toKeyedSeq=function(){return this},e}(X),G=function(t){function e(t){return null==t?nt():d(t)?w(t)?t.entrySeq():t.toIndexedSeq():D(t)?t.toSeq().entrySeq():ot(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return e(arguments)},e.prototype.toIndexedSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq [","]")},e}(X),Z=function(t){function e(t){return(d(t)&&!z(t)?t:G(t)).toSetSeq()}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return e(arguments)},e.prototype.toSetSeq=function(){return this},e}(X);X.isSeq=q,X.Keyed=F,X.Set=Z,X.Indexed=G,X.prototype[j]=!0;var $=function(t){function e(t){this._array=t,this.size=t.length}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t,e){return this.has(t)?this._array[c(this,t)]:e},e.prototype.__iterate=function(t,e){for(var r=this._array,n=r.length,i=0;i!==n;){var o=e?n-++i:i++;if(!1===t(r[o],o,this))break}return i},e.prototype.__iterator=function(t,e){var r=this._array,n=r.length,i=0;return new C((function(){if(i===n)return{value:void 0,done:!0};var o=e?n-++i:i++;return P(t,o,r[o])}))},e}(G),tt=function(t){function e(t){var e=Object.keys(t).concat(Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(t):[]);this._object=t,this._keys=e,this.size=e.length}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t,e){return void 0===e||this.has(t)?this._object[t]:e},e.prototype.has=function(t){return Y.call(this._object,t)},e.prototype.__iterate=function(t,e){for(var r=this._object,n=this._keys,i=n.length,o=0;o!==i;){var u=n[e?i-++o:o++];if(!1===t(r[u],u,this))break}return o},e.prototype.__iterator=function(t,e){var r=this._object,n=this._keys,i=n.length,o=0;return new C((function(){if(o===i)return{value:void 0,done:!0};var u=n[e?i-++o:o++];return P(t,u,r[u])}))},e}(F);tt.prototype[A]=!0;var et,rt=function(t){function e(t){this._collection=t,this.size=t.length||t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.__iterateUncached=function(t,e){if(e)return this.cacheResult().__iterate(t,e);var r=J(this._collection),n=0;if(H(r))for(var i;!(i=r.next()).done&&!1!==t(i.value,n++,this););return n},e.prototype.__iteratorUncached=function(t,e){if(e)return this.cacheResult().__iterator(t,e);var r=J(this._collection);if(!H(r))return new C(W);var n=0;return new C((function(){var e=r.next();return e.done?e:P(t,n++,e.value)}))},e}(G);function nt(){return et||(et=new $([]))}function it(t){var e=ut(t);if(e)return e.fromEntrySeq();if("object"==typeof t)return new tt(t);throw new TypeError("Expected Array or collection object of [k, v] entries, or keyed object: "+t)}function ot(t){var e=ut(t);if(e)return e;throw new TypeError("Expected Array or collection object of values: "+t)}function ut(t){return Q(t)?new $(t):N(t)?new rt(t):void 0}var st="@@__IMMUTABLE_MAP__@@";function at(t){return Boolean(t&&t[st])}function ct(t){return at(t)&&k(t)}function ft(t){return Boolean(t&&"function"==typeof t.equals&&"function"==typeof t.hashCode)}function ht(t,e){if(t===e||t!=t&&e!=e)return!0;if(!t||!e)return!1;if("function"==typeof t.valueOf&&"function"==typeof e.valueOf){if((t=t.valueOf())===(e=e.valueOf())||t!=t&&e!=e)return!0;if(!t||!e)return!1}return!!(ft(t)&&ft(e)&&t.equals(e))}var pt="function"==typeof Math.imul&&-2===Math.imul(4294967295,2)?Math.imul:function(t,e){var r=65535&(t|=0),n=65535&(e|=0);return r*n+((t>>>16)*n+r*(e>>>16)<<16>>>0)|0};function _t(t){return t>>>1&1073741824|3221225471&t}var lt=Object.prototype.valueOf;function vt(t){if(null==t)return yt(t);if("function"==typeof t.hashCode)return _t(t.hashCode(t));var e,r=(e=t).valueOf!==lt&&"function"==typeof e.valueOf?e.valueOf(e):e;if(null==r)return yt(r);switch(typeof r){case"boolean":return r?1108378657:1108378656;case"number":return function(t){if(t!=t||t===1/0)return 0;var e=0|t;e!==t&&(e^=4294967295*t);for(;t>4294967295;)e^=t/=4294967295;return _t(e)}(r);case"string":return r.length>Et?function(t){var e=Mt[t];void 0===e&&(e=dt(t),qt===jt&&(qt=0,Mt={}),qt++,Mt[t]=e);return e}(r):dt(r);case"object":case"function":return function(t){var e;if(zt&&void 0!==(e=bt.get(t)))return e;if(e=t[Ot],void 0!==e)return e;if(!wt){if(void 0!==(e=t.propertyIsEnumerable&&t.propertyIsEnumerable[Ot]))return e;if(void 0!==(e=function(t){if(t&&t.nodeType>0)switch(t.nodeType){case 1:return t.uniqueID;case 9:return t.documentElement&&t.documentElement.uniqueID}}(t)))return e}if(e=mt(),zt)bt.set(t,e);else{if(void 0!==gt&&!1===gt(t))throw new Error("Non-extensible objects are not allowed as keys.");if(wt)Object.defineProperty(t,Ot,{enumerable:!1,configurable:!1,writable:!1,value:e});else if(void 0!==t.propertyIsEnumerable&&t.propertyIsEnumerable===t.constructor.prototype.propertyIsEnumerable)t.propertyIsEnumerable=function(){return this.constructor.prototype.propertyIsEnumerable.apply(this,arguments)},t.propertyIsEnumerable[Ot]=e;else{if(void 0===t.nodeType)throw new Error("Unable to set a non-enumerable property on object.");t[Ot]=e}}return e}(r);case"symbol":return function(t){var e=St[t];if(void 0!==e)return e;return e=mt(),St[t]=e,e}(r);default:if("function"==typeof r.toString)return dt(r.toString());throw new Error("Value type "+typeof r+" cannot be hashed.")}}function yt(t){return null===t?1108378658:1108378659}function dt(t){for(var e=0,r=0;r=0&&(a.get=function(e,r){return(e=c(this,e))>=0&&eo)return{value:void 0,done:!0};var t=i.next();return n||e===U||t.done?t:P(e,a-1,e===R?void 0:t.value[1],t)}))},a}function Lt(t,e,r,n){var i=Xt(t);return i.__iterateUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterate(i,o);var s=!0,a=0;return t.__iterate((function(t,o,c){if(!s||!(s=e.call(r,t,o,c)))return a++,i(t,n?o:a-1,u)})),a},i.__iteratorUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterator(i,o);var s=t.__iterator(T,o),a=!0,c=0;return new C((function(){var t,o,f;do{if((t=s.next()).done)return n||i===U?t:P(i,c++,i===R?void 0:t.value[1],t);var h=t.value;o=h[0],f=h[1],a&&(a=e.call(r,f,o,u))}while(a);return i===T?t:P(i,o,f,t)}))},i}xt.prototype.cacheResult=Dt.prototype.cacheResult=At.prototype.cacheResult=kt.prototype.cacheResult=Ft;var Ct=function(t){function e(t){this._wrappedIterables=t.flatMap((function(t){return t._wrappedIterables?t._wrappedIterables:[t]})),this.size=this._wrappedIterables.reduce((function(t,e){if(void 0!==t){var r=e.size;if(void 0!==r)return t+r}}),0),this[g]=this._wrappedIterables[0][g],this[m]=this._wrappedIterables[0][m],this[A]=this._wrappedIterables[0][A]}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.__iterateUncached=function(t,e){if(0!==this._wrappedIterables.length){if(e)return this.cacheResult().__iterate(t,e);for(var r=0,n=w(this),i=n?T:U,o=this._wrappedIterables[r].__iterator(i,e),u=!0,s=0;u;){for(var a=o.next();a.done;){if(++r===this._wrappedIterables.length)return s;a=(o=this._wrappedIterables[r].__iterator(i,e)).next()}u=!1!==(n?t(a.value[1],a.value[0],this):t(a.value,s,this)),s++}return s}},e.prototype.__iteratorUncached=function(t,e){var r=this;if(0===this._wrappedIterables.length)return new C(W);if(e)return this.cacheResult().__iterator(t,e);var n=0,i=this._wrappedIterables[n].__iterator(t,e);return new C((function(){for(var o=i.next();o.done;){if(++n===r._wrappedIterables.length)return o;o=(i=r._wrappedIterables[n].__iterator(t,e)).next()}return o}))},e}(X);function Pt(t,e,r){var n=Xt(t);return n.__iterateUncached=function(i,o){if(o)return this.cacheResult().__iterate(i,o);var u=0,s=!1;return function t(a,c){a.__iterate((function(o,a){return(!e||c0}function Jt(t,e,r,n){var i=Xt(t),o=new $(r).map((function(t){return t.size}));return i.size=n?o.max():o.min(),i.__iterate=function(t,e){for(var r,n=this.__iterator(U,e),i=0;!(r=n.next()).done&&!1!==t(r.value,i++,this););return i},i.__iteratorUncached=function(t,i){var o=r.map((function(t){return t=S(t),J(i?t.reverse():t)})),u=0,s=!1;return new C((function(){var r;return s||(r=o.map((function(t){return t.next()})),s=n?r.every((function(t){return t.done})):r.some((function(t){return t.done}))),s?{value:void 0,done:!0}:P(t,u++,e.apply(null,r.map((function(t){return t.value}))))}))},i}function Vt(t,e){return t===e?t:q(t)?e:t.constructor(e)}function Yt(t){if(t!==Object(t))throw new TypeError("Expected [K, V] tuple: "+t)}function Qt(t){return w(t)?I:b(t)?O:E}function Xt(t){return Object.create((w(t)?F:b(t)?G:Z).prototype)}function Ft(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size,this):X.prototype.cacheResult.call(this)}function Gt(t,e){return void 0===t&&void 0===e?0:void 0===t?1:void 0===e?-1:t>e?1:t0;)e[r]=arguments[r+1];if("function"!=typeof t)throw new TypeError("Invalid merger function: "+t);return ze(this,e,t)}function ze(t,e,r){for(var n=[],i=0;i0;)e[r]=arguments[r+1];return Se(this,e,t)}function je(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return he(this,t,Je(),(function(t){return Ie(t,e)}))}function qe(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return he(this,t,Je(),(function(t){return Se(t,e)}))}function Me(t){var e=this.asMutable();return t(e),e.wasAltered()?e.__ensureOwner(this.__ownerID):this}function De(){return this.__ownerID?this:this.__ensureOwner(new s)}function xe(){return this.__ensureOwner()}function Ae(){return this.__altered}var ke=function(t){function e(e){return null==e?Je():at(e)&&!k(e)?e:Je().withMutations((function(r){var n=t(e);te(n.size),n.forEach((function(t,e){return r.set(e,t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toString=function(){return this.__toString("Map {","}")},e.prototype.get=function(t,e){return this._root?this._root.get(0,void 0,t,e):e},e.prototype.set=function(t,e){return Ve(this,t,e)},e.prototype.remove=function(t){return Ve(this,t,o)},e.prototype.deleteAll=function(t){var e=S(t);return 0===e.size?this:this.withMutations((function(t){e.forEach((function(e){return t.remove(e)}))}))},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):Je()},e.prototype.sort=function(t){return yr(Wt(this,t))},e.prototype.sortBy=function(t,e){return yr(Wt(this,e,t))},e.prototype.map=function(t,e){var r=this;return this.withMutations((function(n){n.forEach((function(i,o){n.set(o,t.call(e,i,o,r))}))}))},e.prototype.__iterator=function(t,e){return new Pe(this,t,e)},e.prototype.__iterate=function(t,e){var r=this,n=0;return this._root&&this._root.iterate((function(e){return n++,t(e[1],e[0],r)}),e),n},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?He(this.size,this._root,t,this.__hash):0===this.size?Je():(this.__ownerID=t,this.__altered=!1,this)},e}(I);ke.isMap=at;var Re=ke.prototype;Re[st]=!0,Re[e]=Re.remove,Re.removeAll=Re.deleteAll,Re.setIn=le,Re.removeIn=Re.deleteIn=ye,Re.update=ge,Re.updateIn=we,Re.merge=Re.concat=me,Re.mergeWith=be,Re.mergeDeep=Oe,Re.mergeDeepWith=Ee,Re.mergeIn=je,Re.mergeDeepIn=qe,Re.withMutations=Me,Re.wasAltered=Ae,Re.asImmutable=xe,Re["@@transducer/init"]=Re.asMutable=De,Re["@@transducer/step"]=function(t,e){return t.set(e[0],e[1])},Re["@@transducer/result"]=function(t){return t.asImmutable()};var Ue=function(t,e){this.ownerID=t,this.entries=e};Ue.prototype.get=function(t,e,r,n){for(var i=this.entries,o=0,u=i.length;o=Ze)return function(t,e,r,n){t||(t=new s);for(var i=new Le(t,vt(r),[r,n]),o=0;o>>t)&i),s=this.bitmap;return 0==(s&u)?o:this.nodes[Fe(s&u-1)].get(t+r,e,n,o)},Te.prototype.update=function(t,e,u,s,a,c,f){void 0===u&&(u=vt(s));var h=(0===e?u:u>>>e)&i,p=1<=$e)return function(t,e,r,i,o){for(var u=0,s=new Array(n),a=0;0!==r;a++,r>>>=1)s[a]=1&r?e[u++]:void 0;return s[i]=o,new Be(t,u+1,s)}(t,y,_,h,g);if(l&&!g&&2===y.length&&Qe(y[1^v]))return y[1^v];if(l&&g&&1===y.length&&Qe(g))return g;var w=t&&t===this.ownerID,m=l?g?_:_^p:_|p,b=l?g?Ge(y,v,g,w):function(t,e,r){var n=t.length-1;if(r&&e===n)return t.pop(),t;for(var i=new Array(n),o=0,u=0;u>>t)&i,s=this.nodes[u];return s?s.get(t+r,e,n,o):o},Be.prototype.update=function(t,e,n,u,s,a,c){void 0===n&&(n=vt(u));var f=(0===e?n:n>>>e)&i,h=s===o,p=this.nodes,_=p[f];if(h&&!_)return this;var l=Ye(_,t,e+r,n,u,s,a,c);if(l===_)return this;var v=this.count;if(_){if(!l&&--v>>n)&i,c=(0===n?o:o>>>n)&i,f=a===c?[Xe(t,e,n+r,o,u)]:(s=new Le(e,o,u),a>1&1431655765))+(t>>2&858993459))+(t>>4)&252645135,t+=t>>8,127&(t+=t>>16)}function Ge(t,e,r,n){var i=n?t:Zt(t);return i[e]=r,i}var Ze=n/4,$e=n/2,tr=n/4,er="@@__IMMUTABLE_LIST__@@";function rr(t){return Boolean(t&&t[er])}var nr=function(t){function e(e){var i=cr();if(null==e)return i;if(rr(e))return e;var o=t(e),u=o.size;return 0===u?i:(te(u),u>0&&u=0&&t=t.size||e<0)return t.withMutations((function(t){e<0?_r(t,e).set(0,r):_r(t,0,e+1).set(e,r)}));e+=t._origin;var n=t._tail,i=t._root,o={value:!1};e>=lr(t._capacity)?n=fr(n,t.__ownerID,0,e,r,o):i=fr(i,t.__ownerID,t._level,e,r,o);if(!o.value)return t;if(t.__ownerID)return t._root=i,t._tail=n,t.__hash=void 0,t.__altered=!0,t;return ar(t._origin,t._capacity,t._level,i,n)}(this,t,e)},e.prototype.remove=function(t){return this.has(t)?0===t?this.shift():t===this.size-1?this.pop():this.splice(t,1):this},e.prototype.insert=function(t,e){return this.splice(t,0,e)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=this._origin=this._capacity=0,this._level=r,this._root=this._tail=this.__hash=void 0,this.__altered=!0,this):cr()},e.prototype.push=function(){var t=arguments,e=this.size;return this.withMutations((function(r){_r(r,0,e+t.length);for(var n=0;n>>e&i;if(o>=this.array.length)return new or([],t);var u,s=0===o;if(e>0){var a=this.array[o];if((u=a&&a.removeBefore(t,e-r,n))===a&&s)return this}if(s&&!u)return this;var c=hr(this,t);if(!s)for(var f=0;f>>e&i;if(s>=this.array.length)return this;if(e>0){var a=this.array[s];if((u=a&&a.removeAfter(t,e-r,o))===a&&s===this.array.length-1)return this}var c=hr(this,t);return c.array.splice(s+1),u&&(c.array[s]=u),c};var ur={};function sr(t,e){var i=t._origin,o=t._capacity,u=lr(o),s=t._tail;return a(t._root,t._level,0);function a(t,c,f){return 0===c?function(t,r){var a=r===u?s&&s.array:t&&t.array,c=r>i?0:i-r,f=o-r;f>n&&(f=n);return function(){if(c===f)return ur;var t=e?--f:c++;return a&&a[t]}}(t,f):function(t,u,s){var c,f=t&&t.array,h=s>i?0:i-s>>u,p=1+(o-s>>u);p>n&&(p=n);return function(){for(;;){if(c){var t=c();if(t!==ur)return t;c=null}if(h===p)return ur;var n=e?--p:h++;c=a(f&&f[n],u-r,s+(n<>>n&i,h=t&&f0){var p=t&&t.array[f],_=fr(p,e,n-r,o,s,a);return _===p?t:((c=hr(t,e)).array[f]=_,c)}return h&&t.array[f]===s?t:(a&&u(a),c=hr(t,e),void 0===s&&f===c.array.length-1?c.array.pop():c.array[f]=s,c)}function hr(t,e){return e&&t&&e===t.ownerID?t:new or(t?t.array.slice():[],e)}function pr(t,e){if(e>=lr(t._capacity))return t._tail;if(e<1<0;)n=n.array[e>>>o&i],o-=r;return n}}function _r(t,e,n){void 0!==e&&(e|=0),void 0!==n&&(n|=0);var o=t.__ownerID||new s,u=t._origin,a=t._capacity,c=u+e,f=void 0===n?a:n<0?a+n:u+n;if(c===u&&f===a)return t;if(c>=f)return t.clear();for(var h=t._level,p=t._root,_=0;c+_<0;)p=new or(p&&p.array.length?[void 0,p]:[],o),_+=1<<(h+=r);_&&(c+=_,u+=_,f+=_,a+=_);for(var l=lr(a),v=lr(f);v>=1<l?new or([],o):y;if(y&&v>l&&cr;w-=r){var m=l>>>w&i;g=g.array[m]=hr(g.array[m],o)}g.array[l>>>r&i]=y}if(f=v)c-=v,f-=v,h=r,p=null,d=d&&d.removeBefore(o,0,c);else if(c>u||v>>h&i;if(b!==v>>>h&i)break;b&&(_+=(1<u&&(p=p.removeBefore(o,h,c-_)),p&&v>>r<=n&&a.size>=2*s.size?(i=(u=a.filter((function(t,e){return void 0!==t&&c!==e}))).toKeyedSeq().map((function(t){return t[0]})).flip().toMap(),t.__ownerID&&(i.__ownerID=u.__ownerID=t.__ownerID)):(i=s.remove(e),u=c===a.size-1?a.pop():a.set(c,void 0))}else if(f){if(r===a.get(c)[1])return t;i=s,u=a.set(c,[e,r])}else i=s.set(e,a.size),u=a.set(a.size,[e,r]);return t.__ownerID?(t.size=i.size,t._map=i,t._list=u,t.__hash=void 0,t.__altered=!0,t):dr(i,u)}yr.isOrderedMap=ct,yr.prototype[A]=!0,yr.prototype[e]=yr.prototype.remove;var mr="@@__IMMUTABLE_STACK__@@";function br(t){return Boolean(t&&t[mr])}var zr=function(t){function e(t){return null==t?Er():br(t)?t:Er().pushAll(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("Stack [","]")},e.prototype.get=function(t,e){var r=this._head;for(t=c(this,t);r&&t--;)r=r.next;return r?r.value:e},e.prototype.peek=function(){return this._head&&this._head.value},e.prototype.push=function(){var t=arguments;if(0===arguments.length)return this;for(var e=this.size+arguments.length,r=this._head,n=arguments.length-1;n>=0;n--)r={value:t[n],next:r};return this.__ownerID?(this.size=e,this._head=r,this.__hash=void 0,this.__altered=!0,this):Or(e,r)},e.prototype.pushAll=function(e){if(0===(e=t(e)).size)return this;if(0===this.size&&br(e))return e;te(e.size);var r=this.size,n=this._head;return e.__iterate((function(t){r++,n={value:t,next:n}}),!0),this.__ownerID?(this.size=r,this._head=n,this.__hash=void 0,this.__altered=!0,this):Or(r,n)},e.prototype.pop=function(){return this.slice(1)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):Er()},e.prototype.slice=function(e,r){if(h(e,r,this.size))return this;var n=p(e,this.size);if(_(r,this.size)!==this.size)return t.prototype.slice.call(this,e,r);for(var i=this.size-n,o=this._head;n--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):Or(i,o)},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Or(this.size,this._head,t,this.__hash):0===this.size?Er():(this.__ownerID=t,this.__altered=!1,this)},e.prototype.__iterate=function(t,e){var r=this;if(e)return new $(this.toArray()).__iterate((function(e,n){return t(e,n,r)}),e);for(var n=0,i=this._head;i&&!1!==t(i.value,n++,this);)i=i.next;return n},e.prototype.__iterator=function(t,e){if(e)return new $(this.toArray()).__iterator(t,e);var r=0,n=this._head;return new C((function(){if(n){var e=n.value;return n=n.next,P(t,r++,e)}return{value:void 0,done:!0}}))},e}(O);zr.isStack=br;var Sr,Ir=zr.prototype;function Or(t,e,r,n){var i=Object.create(Ir);return i.size=t,i._head=e,i.__ownerID=r,i.__hash=n,i.__altered=!1,i}function Er(){return Sr||(Sr=Or(0))}Ir[mr]=!0,Ir.shift=Ir.pop,Ir.unshift=Ir.push,Ir.unshiftAll=Ir.pushAll,Ir.withMutations=Me,Ir.wasAltered=Ae,Ir.asImmutable=xe,Ir["@@transducer/init"]=Ir.asMutable=De,Ir["@@transducer/step"]=function(t,e){return t.unshift(e)},Ir["@@transducer/result"]=function(t){return t.asImmutable()};var jr="@@__IMMUTABLE_SET__@@";function qr(t){return Boolean(t&&t[jr])}function Mr(t){return qr(t)&&k(t)}function Dr(t,e){if(t===e)return!0;if(!d(e)||void 0!==t.size&&void 0!==e.size&&t.size!==e.size||void 0!==t.__hash&&void 0!==e.__hash&&t.__hash!==e.__hash||w(t)!==w(e)||b(t)!==b(e)||k(t)!==k(e))return!1;if(0===t.size&&0===e.size)return!0;var r=!z(t);if(k(t)){var n=t.entries();return e.every((function(t,e){var i=n.next().value;return i&&ht(i[1],t)&&(r||ht(i[0],e))}))&&n.next().done}var i=!1;if(void 0===t.size)if(void 0===e.size)"function"==typeof t.cacheResult&&t.cacheResult();else{i=!0;var u=t;t=e,e=u}var s=!0,a=e.__iterate((function(e,n){if(r?!t.has(e):i?!ht(e,t.get(n,o)):!ht(t.get(n,o),e))return s=!1,!1}));return s&&t.size===a}function xr(t,e){var r=function(r){t.prototype[r]=e[r]};return Object.keys(e).forEach(r),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(e).forEach(r),t}function Ar(t){if(!t||"object"!=typeof t)return t;if(!d(t)){if(!ie(t))return t;t=X(t)}if(w(t)){var e={};return t.__iterate((function(t,r){e[r]=Ar(t)})),e}var r=[];return t.__iterate((function(t){r.push(Ar(t))})),r}var kr=function(t){function e(e){return null==e?Kr():qr(e)&&!k(e)?e:Kr().withMutations((function(r){var n=t(e);te(n.size),n.forEach((function(t){return r.add(t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(I(t).keySeq())},e.intersect=function(t){return(t=S(t).toArray()).length?Ur.intersect.apply(e(t.pop()),t):Kr()},e.union=function(t){return(t=S(t).toArray()).length?Ur.union.apply(e(t.pop()),t):Kr()},e.prototype.toString=function(){return this.__toString("Set {","}")},e.prototype.has=function(t){return this._map.has(t)},e.prototype.add=function(t){return Tr(this,this._map.set(t,t))},e.prototype.remove=function(t){return Tr(this,this._map.remove(t))},e.prototype.clear=function(){return Tr(this,this._map.clear())},e.prototype.map=function(t,e){var r=this,n=!1,i=Tr(this,this._map.mapEntries((function(i){var o=i[1],u=t.call(e,o,o,r);return u!==o&&(n=!0),[u,u]}),e));return n?i:this},e.prototype.union=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return 0===(e=e.filter((function(t){return 0!==t.size}))).length?this:0!==this.size||this.__ownerID||1!==e.length?this.withMutations((function(r){for(var n=0;n=0&&e=0&&r>>-15,461845907),e=pt(e<<13|e>>>-13,5),e=pt((e=(e+3864292196|0)^t)^e>>>16,2246822507),e=_t((e=pt(e^e>>>13,3266489909))^e>>>16)}(t.size,n)}(this))}});var Jr=S.prototype;Jr[y]=!0,Jr[L]=Jr.values,Jr.toJSON=Jr.toArray,Jr.__toStringMapper=oe,Jr.inspect=Jr.toSource=function(){return this.toString()},Jr.chain=Jr.flatMap,Jr.contains=Jr.includes,xr(I,{flip:function(){return Vt(this,Rt(this))},mapEntries:function(t,e){var r=this,n=0;return Vt(this,this.toSeq().map((function(i,o){return t.call(e,[o,i],n++,r)})).fromEntrySeq())},mapKeys:function(t,e){var r=this;return Vt(this,this.toSeq().flip().map((function(n,i){return t.call(e,n,i,r)})).flip())}});var Vr=I.prototype;Vr[g]=!0,Vr[L]=Jr.entries,Vr.toJSON=Hr,Vr.__toStringMapper=function(t,e){return oe(e)+": "+oe(t)},xr(O,{toKeyedSeq:function(){return new Dt(this,!1)},filter:function(t,e){return Vt(this,Bt(this,t,e,!1))},findIndex:function(t,e){var r=this.findEntry(t,e);return r?r[0]:-1},indexOf:function(t){var e=this.keyOf(t);return void 0===e?-1:e},lastIndexOf:function(t){var e=this.lastKeyOf(t);return void 0===e?-1:e},reverse:function(){return Vt(this,Tt(this,!1))},slice:function(t,e){return Vt(this,Kt(this,t,e,!1))},splice:function(t,e){var r=arguments.length;if(e=Math.max(e||0,0),0===r||2===r&&!e)return this;t=p(t,t<0?this.count():this.size);var n=this.slice(0,t);return Vt(this,1===r?n:n.concat(Zt(arguments,2),this.slice(t+e)))},findLastIndex:function(t,e){var r=this.findLastEntry(t,e);return r?r[0]:-1},first:function(t){return this.get(0,t)},flatten:function(t){return Vt(this,Pt(this,t,!1))},get:function(t,e){return(t=c(this,t))<0||this.size===1/0||void 0!==this.size&&t>this.size?e:this.find((function(e,r){return r===t}),void 0,e)},has:function(t){return(t=c(this,t))>=0&&(void 0!==this.size?this.size===1/0||te?-1:0}function rn(t,e){return t^e+2654435769+(t<<6)+(t>>2)|0}Qr.has=Jr.includes,Qr.contains=Qr.includes,Qr.keys=Qr.values,xr(F,Vr),xr(G,Yr),xr(Z,Qr);var nn=function(t){function e(t){return null==t?an():Mr(t)?t:an().withMutations((function(e){var r=E(t);te(r.size),r.forEach((function(t){return e.add(t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(I(t).keySeq())},e.prototype.toString=function(){return this.__toString("OrderedSet {","}")},e}(kr);nn.isOrderedSet=Mr;var on,un=nn.prototype;function sn(t,e){var r=Object.create(un);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function an(){return on||(on=sn(gr()))}un[A]=!0,un.zip=Yr.zip,un.zipWith=Yr.zipWith,un.zipAll=Yr.zipAll,un.__empty=an,un.__make=sn;var cn=function(t,e){var r;!function(t){if(D(t))throw new Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(x(t))throw new Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(null===t||"object"!=typeof t)throw new Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}(t);var n=function(o){var u=this;if(o instanceof n)return o;if(!(this instanceof n))return new n(o);if(!r){r=!0;var s=Object.keys(t),a=i._indices={};i._name=e,i._keys=s,i._defaultValues=t;for(var c=0;c2?[]:void 0,{"":t})},t.get=se,t.getIn=Pr,t.has=ue,t.hasIn=Nr,t.hash=vt,t.is=ht,t.isAssociative=z,t.isCollection=d,t.isImmutable=x,t.isIndexed=b,t.isKeyed=w,t.isList=rr,t.isMap=at,t.isOrdered=k,t.isOrderedMap=ct,t.isOrderedSet=Mr,t.isPlainObject=ne,t.isRecord=D,t.isSeq=q,t.isSet=qr,t.isStack=br,t.isValueObject=ft,t.merge=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Ie(t,e)},t.mergeDeep=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Se(t,e)},t.mergeDeepWith=function(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];return Se(e,r,t)},t.mergeWith=function(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];return Ie(e,r,t)},t.remove=ce,t.removeIn=ve,t.set=fe,t.setIn=_e,t.update=de,t.updateIn=he,t.version="5.0.3"})); From 77b1b5486cd0dbba38dac81c16d4fe251c583a75 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sat, 15 Mar 2025 18:55:05 +0000 Subject: [PATCH 231/242] deploy: c5898580660195740d551d439c47a4b139632602 --- dist/immutable.d.ts | 8 ++++++++ dist/immutable.es.js | 19 +++++++++++++++++++ dist/immutable.js | 19 +++++++++++++++++++ dist/immutable.min.js | 2 +- 4 files changed, 47 insertions(+), 1 deletion(-) diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index 0f9efbec40..75bf383d3b 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -758,6 +758,14 @@ declare namespace Immutable { zipper: (...values: Array) => Z, ...collections: Array> ): List; + + /** + * Returns a new List with its values shuffled thanks to the + * [Fisher–Yates](https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle) + * algorithm. + * It uses Math.random, but you can provide your own random number generator. + */ + shuffle(random?: () => number): this; } /** diff --git a/dist/immutable.es.js b/dist/immutable.es.js index 55cdd91123..54809a9e84 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -3469,6 +3469,25 @@ var List = /*@__PURE__*/(function (IndexedCollection) { return setListBounds(this, 1); }; + List.prototype.shuffle = function shuffle (random) { + if ( random === void 0 ) random = Math.random; + + return this.withMutations(function (mutable) { + // implementation of the Fisher-Yates shuffle: https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle + var current = mutable.size; + var destination; + var tmp; + + while (current) { + destination = Math.floor(random() * current--); + + tmp = mutable.get(destination); + mutable.set(destination, mutable.get(current)); + mutable.set(current, tmp); + } + }); + }; + // @pragma Composition List.prototype.concat = function concat (/*...collections*/) { diff --git a/dist/immutable.js b/dist/immutable.js index a27bd4d833..27da41634e 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -3475,6 +3475,25 @@ return setListBounds(this, 1); }; + List.prototype.shuffle = function shuffle (random) { + if ( random === void 0 ) random = Math.random; + + return this.withMutations(function (mutable) { + // implementation of the Fisher-Yates shuffle: https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle + var current = mutable.size; + var destination; + var tmp; + + while (current) { + destination = Math.floor(random() * current--); + + tmp = mutable.get(destination); + mutable.set(destination, mutable.get(current)); + mutable.set(current, tmp); + } + }); + }; + // @pragma Composition List.prototype.concat = function concat (/*...collections*/) { diff --git a/dist/immutable.min.js b/dist/immutable.min.js index f04d2ab99d..4c6e288f7e 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -22,4 +22,4 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).Immutable={})}(this,(function(t){"use strict";var e="delete",r=5,n=1<>>0;if(""+r!==e||4294967295===r)return NaN;e=r}return e<0?a(t)+e:e}function f(){return!0}function h(t,e,r){return(0===t&&!v(t)||void 0!==r&&t<=-r)&&(void 0===e||void 0!==r&&e>=r)}function p(t,e){return l(t,e,0)}function _(t,e){return l(t,e,e)}function l(t,e,r){return void 0===t?r:v(t)?e===1/0?e:0|Math.max(0,e+t):void 0===e||e===t?t:0|Math.min(e,t)}function v(t){return t<0||0===t&&1/t==-1/0}var y="@@__IMMUTABLE_ITERABLE__@@";function d(t){return Boolean(t&&t[y])}var g="@@__IMMUTABLE_KEYED__@@";function w(t){return Boolean(t&&t[g])}var m="@@__IMMUTABLE_INDEXED__@@";function b(t){return Boolean(t&&t[m])}function z(t){return w(t)||b(t)}var S=function(t){return d(t)?t:X(t)},I=function(t){function e(t){return w(t)?t:F(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(S),O=function(t){function e(t){return b(t)?t:G(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(S),E=function(t){function e(t){return d(t)&&!z(t)?t:Z(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(S);S.Keyed=I,S.Indexed=O,S.Set=E;var j="@@__IMMUTABLE_SEQ__@@";function q(t){return Boolean(t&&t[j])}var M="@@__IMMUTABLE_RECORD__@@";function D(t){return Boolean(t&&t[M])}function x(t){return d(t)||D(t)}var A="@@__IMMUTABLE_ORDERED__@@";function k(t){return Boolean(t&&t[A])}var R=0,U=1,T=2,B="function"==typeof Symbol&&Symbol.iterator,K="@@iterator",L=B||K,C=function(t){this.next=t};function P(t,e,r,n){var i=t===R?e:t===U?r:[e,r];return n?n.value=i:n={value:i,done:!1},n}function W(){return{value:void 0,done:!0}}function N(t){return!!Array.isArray(t)||!!V(t)}function H(t){return t&&"function"==typeof t.next}function J(t){var e=V(t);return e&&e.call(t)}function V(t){var e=t&&(B&&t[B]||t[K]);if("function"==typeof e)return e}C.prototype.toString=function(){return"[Iterator]"},C.KEYS=R,C.VALUES=U,C.ENTRIES=T,C.prototype.inspect=C.prototype.toSource=function(){return this.toString()},C.prototype[L]=function(){return this};var Y=Object.prototype.hasOwnProperty;function Q(t){return!(!Array.isArray(t)&&"string"!=typeof t)||t&&"object"==typeof t&&Number.isInteger(t.length)&&t.length>=0&&(0===t.length?1===Object.keys(t).length:t.hasOwnProperty(t.length-1))}var X=function(t){function e(t){return null==t?nt():x(t)?t.toSeq():function(t){var e=ut(t);if(e)return(n=V(r=t))&&n===r.entries?e.fromEntrySeq():function(t){var e=V(t);return e&&e===t.keys}(t)?e.toSetSeq():e;var r,n;if("object"==typeof t)return new tt(t);throw new TypeError("Expected Array or collection object of values, or keyed object: "+t)}(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq {","}")},e.prototype.cacheResult=function(){return!this._cache&&this.__iterateUncached&&(this._cache=this.entrySeq().toArray(),this.size=this._cache.length),this},e.prototype.__iterate=function(t,e){var r=this._cache;if(r){for(var n=r.length,i=0;i!==n;){var o=r[e?n-++i:i++];if(!1===t(o[1],o[0],this))break}return i}return this.__iterateUncached(t,e)},e.prototype.__iterator=function(t,e){var r=this._cache;if(r){var n=r.length,i=0;return new C((function(){if(i===n)return{value:void 0,done:!0};var o=r[e?n-++i:i++];return P(t,o[0],o[1])}))}return this.__iteratorUncached(t,e)},e}(S),F=function(t){function e(t){return null==t?nt().toKeyedSeq():d(t)?w(t)?t.toSeq():t.fromEntrySeq():D(t)?t.toSeq():it(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toKeyedSeq=function(){return this},e}(X),G=function(t){function e(t){return null==t?nt():d(t)?w(t)?t.entrySeq():t.toIndexedSeq():D(t)?t.toSeq().entrySeq():ot(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return e(arguments)},e.prototype.toIndexedSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq [","]")},e}(X),Z=function(t){function e(t){return(d(t)&&!z(t)?t:G(t)).toSetSeq()}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return e(arguments)},e.prototype.toSetSeq=function(){return this},e}(X);X.isSeq=q,X.Keyed=F,X.Set=Z,X.Indexed=G,X.prototype[j]=!0;var $=function(t){function e(t){this._array=t,this.size=t.length}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t,e){return this.has(t)?this._array[c(this,t)]:e},e.prototype.__iterate=function(t,e){for(var r=this._array,n=r.length,i=0;i!==n;){var o=e?n-++i:i++;if(!1===t(r[o],o,this))break}return i},e.prototype.__iterator=function(t,e){var r=this._array,n=r.length,i=0;return new C((function(){if(i===n)return{value:void 0,done:!0};var o=e?n-++i:i++;return P(t,o,r[o])}))},e}(G),tt=function(t){function e(t){var e=Object.keys(t).concat(Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(t):[]);this._object=t,this._keys=e,this.size=e.length}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t,e){return void 0===e||this.has(t)?this._object[t]:e},e.prototype.has=function(t){return Y.call(this._object,t)},e.prototype.__iterate=function(t,e){for(var r=this._object,n=this._keys,i=n.length,o=0;o!==i;){var u=n[e?i-++o:o++];if(!1===t(r[u],u,this))break}return o},e.prototype.__iterator=function(t,e){var r=this._object,n=this._keys,i=n.length,o=0;return new C((function(){if(o===i)return{value:void 0,done:!0};var u=n[e?i-++o:o++];return P(t,u,r[u])}))},e}(F);tt.prototype[A]=!0;var et,rt=function(t){function e(t){this._collection=t,this.size=t.length||t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.__iterateUncached=function(t,e){if(e)return this.cacheResult().__iterate(t,e);var r=J(this._collection),n=0;if(H(r))for(var i;!(i=r.next()).done&&!1!==t(i.value,n++,this););return n},e.prototype.__iteratorUncached=function(t,e){if(e)return this.cacheResult().__iterator(t,e);var r=J(this._collection);if(!H(r))return new C(W);var n=0;return new C((function(){var e=r.next();return e.done?e:P(t,n++,e.value)}))},e}(G);function nt(){return et||(et=new $([]))}function it(t){var e=ut(t);if(e)return e.fromEntrySeq();if("object"==typeof t)return new tt(t);throw new TypeError("Expected Array or collection object of [k, v] entries, or keyed object: "+t)}function ot(t){var e=ut(t);if(e)return e;throw new TypeError("Expected Array or collection object of values: "+t)}function ut(t){return Q(t)?new $(t):N(t)?new rt(t):void 0}var st="@@__IMMUTABLE_MAP__@@";function at(t){return Boolean(t&&t[st])}function ct(t){return at(t)&&k(t)}function ft(t){return Boolean(t&&"function"==typeof t.equals&&"function"==typeof t.hashCode)}function ht(t,e){if(t===e||t!=t&&e!=e)return!0;if(!t||!e)return!1;if("function"==typeof t.valueOf&&"function"==typeof e.valueOf){if((t=t.valueOf())===(e=e.valueOf())||t!=t&&e!=e)return!0;if(!t||!e)return!1}return!!(ft(t)&&ft(e)&&t.equals(e))}var pt="function"==typeof Math.imul&&-2===Math.imul(4294967295,2)?Math.imul:function(t,e){var r=65535&(t|=0),n=65535&(e|=0);return r*n+((t>>>16)*n+r*(e>>>16)<<16>>>0)|0};function _t(t){return t>>>1&1073741824|3221225471&t}var lt=Object.prototype.valueOf;function vt(t){if(null==t)return yt(t);if("function"==typeof t.hashCode)return _t(t.hashCode(t));var e,r=(e=t).valueOf!==lt&&"function"==typeof e.valueOf?e.valueOf(e):e;if(null==r)return yt(r);switch(typeof r){case"boolean":return r?1108378657:1108378656;case"number":return function(t){if(t!=t||t===1/0)return 0;var e=0|t;e!==t&&(e^=4294967295*t);for(;t>4294967295;)e^=t/=4294967295;return _t(e)}(r);case"string":return r.length>Et?function(t){var e=Mt[t];void 0===e&&(e=dt(t),qt===jt&&(qt=0,Mt={}),qt++,Mt[t]=e);return e}(r):dt(r);case"object":case"function":return function(t){var e;if(zt&&void 0!==(e=bt.get(t)))return e;if(e=t[Ot],void 0!==e)return e;if(!wt){if(void 0!==(e=t.propertyIsEnumerable&&t.propertyIsEnumerable[Ot]))return e;if(void 0!==(e=function(t){if(t&&t.nodeType>0)switch(t.nodeType){case 1:return t.uniqueID;case 9:return t.documentElement&&t.documentElement.uniqueID}}(t)))return e}if(e=mt(),zt)bt.set(t,e);else{if(void 0!==gt&&!1===gt(t))throw new Error("Non-extensible objects are not allowed as keys.");if(wt)Object.defineProperty(t,Ot,{enumerable:!1,configurable:!1,writable:!1,value:e});else if(void 0!==t.propertyIsEnumerable&&t.propertyIsEnumerable===t.constructor.prototype.propertyIsEnumerable)t.propertyIsEnumerable=function(){return this.constructor.prototype.propertyIsEnumerable.apply(this,arguments)},t.propertyIsEnumerable[Ot]=e;else{if(void 0===t.nodeType)throw new Error("Unable to set a non-enumerable property on object.");t[Ot]=e}}return e}(r);case"symbol":return function(t){var e=St[t];if(void 0!==e)return e;return e=mt(),St[t]=e,e}(r);default:if("function"==typeof r.toString)return dt(r.toString());throw new Error("Value type "+typeof r+" cannot be hashed.")}}function yt(t){return null===t?1108378658:1108378659}function dt(t){for(var e=0,r=0;r=0&&(a.get=function(e,r){return(e=c(this,e))>=0&&eo)return{value:void 0,done:!0};var t=i.next();return n||e===U||t.done?t:P(e,a-1,e===R?void 0:t.value[1],t)}))},a}function Lt(t,e,r,n){var i=Xt(t);return i.__iterateUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterate(i,o);var s=!0,a=0;return t.__iterate((function(t,o,c){if(!s||!(s=e.call(r,t,o,c)))return a++,i(t,n?o:a-1,u)})),a},i.__iteratorUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterator(i,o);var s=t.__iterator(T,o),a=!0,c=0;return new C((function(){var t,o,f;do{if((t=s.next()).done)return n||i===U?t:P(i,c++,i===R?void 0:t.value[1],t);var h=t.value;o=h[0],f=h[1],a&&(a=e.call(r,f,o,u))}while(a);return i===T?t:P(i,o,f,t)}))},i}xt.prototype.cacheResult=Dt.prototype.cacheResult=At.prototype.cacheResult=kt.prototype.cacheResult=Ft;var Ct=function(t){function e(t){this._wrappedIterables=t.flatMap((function(t){return t._wrappedIterables?t._wrappedIterables:[t]})),this.size=this._wrappedIterables.reduce((function(t,e){if(void 0!==t){var r=e.size;if(void 0!==r)return t+r}}),0),this[g]=this._wrappedIterables[0][g],this[m]=this._wrappedIterables[0][m],this[A]=this._wrappedIterables[0][A]}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.__iterateUncached=function(t,e){if(0!==this._wrappedIterables.length){if(e)return this.cacheResult().__iterate(t,e);for(var r=0,n=w(this),i=n?T:U,o=this._wrappedIterables[r].__iterator(i,e),u=!0,s=0;u;){for(var a=o.next();a.done;){if(++r===this._wrappedIterables.length)return s;a=(o=this._wrappedIterables[r].__iterator(i,e)).next()}u=!1!==(n?t(a.value[1],a.value[0],this):t(a.value,s,this)),s++}return s}},e.prototype.__iteratorUncached=function(t,e){var r=this;if(0===this._wrappedIterables.length)return new C(W);if(e)return this.cacheResult().__iterator(t,e);var n=0,i=this._wrappedIterables[n].__iterator(t,e);return new C((function(){for(var o=i.next();o.done;){if(++n===r._wrappedIterables.length)return o;o=(i=r._wrappedIterables[n].__iterator(t,e)).next()}return o}))},e}(X);function Pt(t,e,r){var n=Xt(t);return n.__iterateUncached=function(i,o){if(o)return this.cacheResult().__iterate(i,o);var u=0,s=!1;return function t(a,c){a.__iterate((function(o,a){return(!e||c0}function Jt(t,e,r,n){var i=Xt(t),o=new $(r).map((function(t){return t.size}));return i.size=n?o.max():o.min(),i.__iterate=function(t,e){for(var r,n=this.__iterator(U,e),i=0;!(r=n.next()).done&&!1!==t(r.value,i++,this););return i},i.__iteratorUncached=function(t,i){var o=r.map((function(t){return t=S(t),J(i?t.reverse():t)})),u=0,s=!1;return new C((function(){var r;return s||(r=o.map((function(t){return t.next()})),s=n?r.every((function(t){return t.done})):r.some((function(t){return t.done}))),s?{value:void 0,done:!0}:P(t,u++,e.apply(null,r.map((function(t){return t.value}))))}))},i}function Vt(t,e){return t===e?t:q(t)?e:t.constructor(e)}function Yt(t){if(t!==Object(t))throw new TypeError("Expected [K, V] tuple: "+t)}function Qt(t){return w(t)?I:b(t)?O:E}function Xt(t){return Object.create((w(t)?F:b(t)?G:Z).prototype)}function Ft(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size,this):X.prototype.cacheResult.call(this)}function Gt(t,e){return void 0===t&&void 0===e?0:void 0===t?1:void 0===e?-1:t>e?1:t0;)e[r]=arguments[r+1];if("function"!=typeof t)throw new TypeError("Invalid merger function: "+t);return ze(this,e,t)}function ze(t,e,r){for(var n=[],i=0;i0;)e[r]=arguments[r+1];return Se(this,e,t)}function je(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return he(this,t,Je(),(function(t){return Ie(t,e)}))}function qe(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return he(this,t,Je(),(function(t){return Se(t,e)}))}function Me(t){var e=this.asMutable();return t(e),e.wasAltered()?e.__ensureOwner(this.__ownerID):this}function De(){return this.__ownerID?this:this.__ensureOwner(new s)}function xe(){return this.__ensureOwner()}function Ae(){return this.__altered}var ke=function(t){function e(e){return null==e?Je():at(e)&&!k(e)?e:Je().withMutations((function(r){var n=t(e);te(n.size),n.forEach((function(t,e){return r.set(e,t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toString=function(){return this.__toString("Map {","}")},e.prototype.get=function(t,e){return this._root?this._root.get(0,void 0,t,e):e},e.prototype.set=function(t,e){return Ve(this,t,e)},e.prototype.remove=function(t){return Ve(this,t,o)},e.prototype.deleteAll=function(t){var e=S(t);return 0===e.size?this:this.withMutations((function(t){e.forEach((function(e){return t.remove(e)}))}))},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):Je()},e.prototype.sort=function(t){return yr(Wt(this,t))},e.prototype.sortBy=function(t,e){return yr(Wt(this,e,t))},e.prototype.map=function(t,e){var r=this;return this.withMutations((function(n){n.forEach((function(i,o){n.set(o,t.call(e,i,o,r))}))}))},e.prototype.__iterator=function(t,e){return new Pe(this,t,e)},e.prototype.__iterate=function(t,e){var r=this,n=0;return this._root&&this._root.iterate((function(e){return n++,t(e[1],e[0],r)}),e),n},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?He(this.size,this._root,t,this.__hash):0===this.size?Je():(this.__ownerID=t,this.__altered=!1,this)},e}(I);ke.isMap=at;var Re=ke.prototype;Re[st]=!0,Re[e]=Re.remove,Re.removeAll=Re.deleteAll,Re.setIn=le,Re.removeIn=Re.deleteIn=ye,Re.update=ge,Re.updateIn=we,Re.merge=Re.concat=me,Re.mergeWith=be,Re.mergeDeep=Oe,Re.mergeDeepWith=Ee,Re.mergeIn=je,Re.mergeDeepIn=qe,Re.withMutations=Me,Re.wasAltered=Ae,Re.asImmutable=xe,Re["@@transducer/init"]=Re.asMutable=De,Re["@@transducer/step"]=function(t,e){return t.set(e[0],e[1])},Re["@@transducer/result"]=function(t){return t.asImmutable()};var Ue=function(t,e){this.ownerID=t,this.entries=e};Ue.prototype.get=function(t,e,r,n){for(var i=this.entries,o=0,u=i.length;o=Ze)return function(t,e,r,n){t||(t=new s);for(var i=new Le(t,vt(r),[r,n]),o=0;o>>t)&i),s=this.bitmap;return 0==(s&u)?o:this.nodes[Fe(s&u-1)].get(t+r,e,n,o)},Te.prototype.update=function(t,e,u,s,a,c,f){void 0===u&&(u=vt(s));var h=(0===e?u:u>>>e)&i,p=1<=$e)return function(t,e,r,i,o){for(var u=0,s=new Array(n),a=0;0!==r;a++,r>>>=1)s[a]=1&r?e[u++]:void 0;return s[i]=o,new Be(t,u+1,s)}(t,y,_,h,g);if(l&&!g&&2===y.length&&Qe(y[1^v]))return y[1^v];if(l&&g&&1===y.length&&Qe(g))return g;var w=t&&t===this.ownerID,m=l?g?_:_^p:_|p,b=l?g?Ge(y,v,g,w):function(t,e,r){var n=t.length-1;if(r&&e===n)return t.pop(),t;for(var i=new Array(n),o=0,u=0;u>>t)&i,s=this.nodes[u];return s?s.get(t+r,e,n,o):o},Be.prototype.update=function(t,e,n,u,s,a,c){void 0===n&&(n=vt(u));var f=(0===e?n:n>>>e)&i,h=s===o,p=this.nodes,_=p[f];if(h&&!_)return this;var l=Ye(_,t,e+r,n,u,s,a,c);if(l===_)return this;var v=this.count;if(_){if(!l&&--v>>n)&i,c=(0===n?o:o>>>n)&i,f=a===c?[Xe(t,e,n+r,o,u)]:(s=new Le(e,o,u),a>1&1431655765))+(t>>2&858993459))+(t>>4)&252645135,t+=t>>8,127&(t+=t>>16)}function Ge(t,e,r,n){var i=n?t:Zt(t);return i[e]=r,i}var Ze=n/4,$e=n/2,tr=n/4,er="@@__IMMUTABLE_LIST__@@";function rr(t){return Boolean(t&&t[er])}var nr=function(t){function e(e){var i=cr();if(null==e)return i;if(rr(e))return e;var o=t(e),u=o.size;return 0===u?i:(te(u),u>0&&u=0&&t=t.size||e<0)return t.withMutations((function(t){e<0?_r(t,e).set(0,r):_r(t,0,e+1).set(e,r)}));e+=t._origin;var n=t._tail,i=t._root,o={value:!1};e>=lr(t._capacity)?n=fr(n,t.__ownerID,0,e,r,o):i=fr(i,t.__ownerID,t._level,e,r,o);if(!o.value)return t;if(t.__ownerID)return t._root=i,t._tail=n,t.__hash=void 0,t.__altered=!0,t;return ar(t._origin,t._capacity,t._level,i,n)}(this,t,e)},e.prototype.remove=function(t){return this.has(t)?0===t?this.shift():t===this.size-1?this.pop():this.splice(t,1):this},e.prototype.insert=function(t,e){return this.splice(t,0,e)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=this._origin=this._capacity=0,this._level=r,this._root=this._tail=this.__hash=void 0,this.__altered=!0,this):cr()},e.prototype.push=function(){var t=arguments,e=this.size;return this.withMutations((function(r){_r(r,0,e+t.length);for(var n=0;n>>e&i;if(o>=this.array.length)return new or([],t);var u,s=0===o;if(e>0){var a=this.array[o];if((u=a&&a.removeBefore(t,e-r,n))===a&&s)return this}if(s&&!u)return this;var c=hr(this,t);if(!s)for(var f=0;f>>e&i;if(s>=this.array.length)return this;if(e>0){var a=this.array[s];if((u=a&&a.removeAfter(t,e-r,o))===a&&s===this.array.length-1)return this}var c=hr(this,t);return c.array.splice(s+1),u&&(c.array[s]=u),c};var ur={};function sr(t,e){var i=t._origin,o=t._capacity,u=lr(o),s=t._tail;return a(t._root,t._level,0);function a(t,c,f){return 0===c?function(t,r){var a=r===u?s&&s.array:t&&t.array,c=r>i?0:i-r,f=o-r;f>n&&(f=n);return function(){if(c===f)return ur;var t=e?--f:c++;return a&&a[t]}}(t,f):function(t,u,s){var c,f=t&&t.array,h=s>i?0:i-s>>u,p=1+(o-s>>u);p>n&&(p=n);return function(){for(;;){if(c){var t=c();if(t!==ur)return t;c=null}if(h===p)return ur;var n=e?--p:h++;c=a(f&&f[n],u-r,s+(n<>>n&i,h=t&&f0){var p=t&&t.array[f],_=fr(p,e,n-r,o,s,a);return _===p?t:((c=hr(t,e)).array[f]=_,c)}return h&&t.array[f]===s?t:(a&&u(a),c=hr(t,e),void 0===s&&f===c.array.length-1?c.array.pop():c.array[f]=s,c)}function hr(t,e){return e&&t&&e===t.ownerID?t:new or(t?t.array.slice():[],e)}function pr(t,e){if(e>=lr(t._capacity))return t._tail;if(e<1<0;)n=n.array[e>>>o&i],o-=r;return n}}function _r(t,e,n){void 0!==e&&(e|=0),void 0!==n&&(n|=0);var o=t.__ownerID||new s,u=t._origin,a=t._capacity,c=u+e,f=void 0===n?a:n<0?a+n:u+n;if(c===u&&f===a)return t;if(c>=f)return t.clear();for(var h=t._level,p=t._root,_=0;c+_<0;)p=new or(p&&p.array.length?[void 0,p]:[],o),_+=1<<(h+=r);_&&(c+=_,u+=_,f+=_,a+=_);for(var l=lr(a),v=lr(f);v>=1<l?new or([],o):y;if(y&&v>l&&cr;w-=r){var m=l>>>w&i;g=g.array[m]=hr(g.array[m],o)}g.array[l>>>r&i]=y}if(f=v)c-=v,f-=v,h=r,p=null,d=d&&d.removeBefore(o,0,c);else if(c>u||v>>h&i;if(b!==v>>>h&i)break;b&&(_+=(1<u&&(p=p.removeBefore(o,h,c-_)),p&&v>>r<=n&&a.size>=2*s.size?(i=(u=a.filter((function(t,e){return void 0!==t&&c!==e}))).toKeyedSeq().map((function(t){return t[0]})).flip().toMap(),t.__ownerID&&(i.__ownerID=u.__ownerID=t.__ownerID)):(i=s.remove(e),u=c===a.size-1?a.pop():a.set(c,void 0))}else if(f){if(r===a.get(c)[1])return t;i=s,u=a.set(c,[e,r])}else i=s.set(e,a.size),u=a.set(a.size,[e,r]);return t.__ownerID?(t.size=i.size,t._map=i,t._list=u,t.__hash=void 0,t.__altered=!0,t):dr(i,u)}yr.isOrderedMap=ct,yr.prototype[A]=!0,yr.prototype[e]=yr.prototype.remove;var mr="@@__IMMUTABLE_STACK__@@";function br(t){return Boolean(t&&t[mr])}var zr=function(t){function e(t){return null==t?Er():br(t)?t:Er().pushAll(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("Stack [","]")},e.prototype.get=function(t,e){var r=this._head;for(t=c(this,t);r&&t--;)r=r.next;return r?r.value:e},e.prototype.peek=function(){return this._head&&this._head.value},e.prototype.push=function(){var t=arguments;if(0===arguments.length)return this;for(var e=this.size+arguments.length,r=this._head,n=arguments.length-1;n>=0;n--)r={value:t[n],next:r};return this.__ownerID?(this.size=e,this._head=r,this.__hash=void 0,this.__altered=!0,this):Or(e,r)},e.prototype.pushAll=function(e){if(0===(e=t(e)).size)return this;if(0===this.size&&br(e))return e;te(e.size);var r=this.size,n=this._head;return e.__iterate((function(t){r++,n={value:t,next:n}}),!0),this.__ownerID?(this.size=r,this._head=n,this.__hash=void 0,this.__altered=!0,this):Or(r,n)},e.prototype.pop=function(){return this.slice(1)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):Er()},e.prototype.slice=function(e,r){if(h(e,r,this.size))return this;var n=p(e,this.size);if(_(r,this.size)!==this.size)return t.prototype.slice.call(this,e,r);for(var i=this.size-n,o=this._head;n--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):Or(i,o)},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Or(this.size,this._head,t,this.__hash):0===this.size?Er():(this.__ownerID=t,this.__altered=!1,this)},e.prototype.__iterate=function(t,e){var r=this;if(e)return new $(this.toArray()).__iterate((function(e,n){return t(e,n,r)}),e);for(var n=0,i=this._head;i&&!1!==t(i.value,n++,this);)i=i.next;return n},e.prototype.__iterator=function(t,e){if(e)return new $(this.toArray()).__iterator(t,e);var r=0,n=this._head;return new C((function(){if(n){var e=n.value;return n=n.next,P(t,r++,e)}return{value:void 0,done:!0}}))},e}(O);zr.isStack=br;var Sr,Ir=zr.prototype;function Or(t,e,r,n){var i=Object.create(Ir);return i.size=t,i._head=e,i.__ownerID=r,i.__hash=n,i.__altered=!1,i}function Er(){return Sr||(Sr=Or(0))}Ir[mr]=!0,Ir.shift=Ir.pop,Ir.unshift=Ir.push,Ir.unshiftAll=Ir.pushAll,Ir.withMutations=Me,Ir.wasAltered=Ae,Ir.asImmutable=xe,Ir["@@transducer/init"]=Ir.asMutable=De,Ir["@@transducer/step"]=function(t,e){return t.unshift(e)},Ir["@@transducer/result"]=function(t){return t.asImmutable()};var jr="@@__IMMUTABLE_SET__@@";function qr(t){return Boolean(t&&t[jr])}function Mr(t){return qr(t)&&k(t)}function Dr(t,e){if(t===e)return!0;if(!d(e)||void 0!==t.size&&void 0!==e.size&&t.size!==e.size||void 0!==t.__hash&&void 0!==e.__hash&&t.__hash!==e.__hash||w(t)!==w(e)||b(t)!==b(e)||k(t)!==k(e))return!1;if(0===t.size&&0===e.size)return!0;var r=!z(t);if(k(t)){var n=t.entries();return e.every((function(t,e){var i=n.next().value;return i&&ht(i[1],t)&&(r||ht(i[0],e))}))&&n.next().done}var i=!1;if(void 0===t.size)if(void 0===e.size)"function"==typeof t.cacheResult&&t.cacheResult();else{i=!0;var u=t;t=e,e=u}var s=!0,a=e.__iterate((function(e,n){if(r?!t.has(e):i?!ht(e,t.get(n,o)):!ht(t.get(n,o),e))return s=!1,!1}));return s&&t.size===a}function xr(t,e){var r=function(r){t.prototype[r]=e[r]};return Object.keys(e).forEach(r),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(e).forEach(r),t}function Ar(t){if(!t||"object"!=typeof t)return t;if(!d(t)){if(!ie(t))return t;t=X(t)}if(w(t)){var e={};return t.__iterate((function(t,r){e[r]=Ar(t)})),e}var r=[];return t.__iterate((function(t){r.push(Ar(t))})),r}var kr=function(t){function e(e){return null==e?Kr():qr(e)&&!k(e)?e:Kr().withMutations((function(r){var n=t(e);te(n.size),n.forEach((function(t){return r.add(t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(I(t).keySeq())},e.intersect=function(t){return(t=S(t).toArray()).length?Ur.intersect.apply(e(t.pop()),t):Kr()},e.union=function(t){return(t=S(t).toArray()).length?Ur.union.apply(e(t.pop()),t):Kr()},e.prototype.toString=function(){return this.__toString("Set {","}")},e.prototype.has=function(t){return this._map.has(t)},e.prototype.add=function(t){return Tr(this,this._map.set(t,t))},e.prototype.remove=function(t){return Tr(this,this._map.remove(t))},e.prototype.clear=function(){return Tr(this,this._map.clear())},e.prototype.map=function(t,e){var r=this,n=!1,i=Tr(this,this._map.mapEntries((function(i){var o=i[1],u=t.call(e,o,o,r);return u!==o&&(n=!0),[u,u]}),e));return n?i:this},e.prototype.union=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return 0===(e=e.filter((function(t){return 0!==t.size}))).length?this:0!==this.size||this.__ownerID||1!==e.length?this.withMutations((function(r){for(var n=0;n=0&&e=0&&r>>-15,461845907),e=pt(e<<13|e>>>-13,5),e=pt((e=(e+3864292196|0)^t)^e>>>16,2246822507),e=_t((e=pt(e^e>>>13,3266489909))^e>>>16)}(t.size,n)}(this))}});var Jr=S.prototype;Jr[y]=!0,Jr[L]=Jr.values,Jr.toJSON=Jr.toArray,Jr.__toStringMapper=oe,Jr.inspect=Jr.toSource=function(){return this.toString()},Jr.chain=Jr.flatMap,Jr.contains=Jr.includes,xr(I,{flip:function(){return Vt(this,Rt(this))},mapEntries:function(t,e){var r=this,n=0;return Vt(this,this.toSeq().map((function(i,o){return t.call(e,[o,i],n++,r)})).fromEntrySeq())},mapKeys:function(t,e){var r=this;return Vt(this,this.toSeq().flip().map((function(n,i){return t.call(e,n,i,r)})).flip())}});var Vr=I.prototype;Vr[g]=!0,Vr[L]=Jr.entries,Vr.toJSON=Hr,Vr.__toStringMapper=function(t,e){return oe(e)+": "+oe(t)},xr(O,{toKeyedSeq:function(){return new Dt(this,!1)},filter:function(t,e){return Vt(this,Bt(this,t,e,!1))},findIndex:function(t,e){var r=this.findEntry(t,e);return r?r[0]:-1},indexOf:function(t){var e=this.keyOf(t);return void 0===e?-1:e},lastIndexOf:function(t){var e=this.lastKeyOf(t);return void 0===e?-1:e},reverse:function(){return Vt(this,Tt(this,!1))},slice:function(t,e){return Vt(this,Kt(this,t,e,!1))},splice:function(t,e){var r=arguments.length;if(e=Math.max(e||0,0),0===r||2===r&&!e)return this;t=p(t,t<0?this.count():this.size);var n=this.slice(0,t);return Vt(this,1===r?n:n.concat(Zt(arguments,2),this.slice(t+e)))},findLastIndex:function(t,e){var r=this.findLastEntry(t,e);return r?r[0]:-1},first:function(t){return this.get(0,t)},flatten:function(t){return Vt(this,Pt(this,t,!1))},get:function(t,e){return(t=c(this,t))<0||this.size===1/0||void 0!==this.size&&t>this.size?e:this.find((function(e,r){return r===t}),void 0,e)},has:function(t){return(t=c(this,t))>=0&&(void 0!==this.size?this.size===1/0||te?-1:0}function rn(t,e){return t^e+2654435769+(t<<6)+(t>>2)|0}Qr.has=Jr.includes,Qr.contains=Qr.includes,Qr.keys=Qr.values,xr(F,Vr),xr(G,Yr),xr(Z,Qr);var nn=function(t){function e(t){return null==t?an():Mr(t)?t:an().withMutations((function(e){var r=E(t);te(r.size),r.forEach((function(t){return e.add(t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(I(t).keySeq())},e.prototype.toString=function(){return this.__toString("OrderedSet {","}")},e}(kr);nn.isOrderedSet=Mr;var on,un=nn.prototype;function sn(t,e){var r=Object.create(un);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function an(){return on||(on=sn(gr()))}un[A]=!0,un.zip=Yr.zip,un.zipWith=Yr.zipWith,un.zipAll=Yr.zipAll,un.__empty=an,un.__make=sn;var cn=function(t,e){var r;!function(t){if(D(t))throw new Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(x(t))throw new Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(null===t||"object"!=typeof t)throw new Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}(t);var n=function(o){var u=this;if(o instanceof n)return o;if(!(this instanceof n))return new n(o);if(!r){r=!0;var s=Object.keys(t),a=i._indices={};i._name=e,i._keys=s,i._defaultValues=t;for(var c=0;c2?[]:void 0,{"":t})},t.get=se,t.getIn=Pr,t.has=ue,t.hasIn=Nr,t.hash=vt,t.is=ht,t.isAssociative=z,t.isCollection=d,t.isImmutable=x,t.isIndexed=b,t.isKeyed=w,t.isList=rr,t.isMap=at,t.isOrdered=k,t.isOrderedMap=ct,t.isOrderedSet=Mr,t.isPlainObject=ne,t.isRecord=D,t.isSeq=q,t.isSet=qr,t.isStack=br,t.isValueObject=ft,t.merge=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Ie(t,e)},t.mergeDeep=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Se(t,e)},t.mergeDeepWith=function(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];return Se(e,r,t)},t.mergeWith=function(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];return Ie(e,r,t)},t.remove=ce,t.removeIn=ve,t.set=fe,t.setIn=_e,t.update=de,t.updateIn=he,t.version="5.0.3"})); +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).Immutable={})}(this,(function(t){"use strict";var e="delete",r=5,n=1<>>0;if(""+r!==e||4294967295===r)return NaN;e=r}return e<0?a(t)+e:e}function f(){return!0}function h(t,e,r){return(0===t&&!v(t)||void 0!==r&&t<=-r)&&(void 0===e||void 0!==r&&e>=r)}function p(t,e){return l(t,e,0)}function _(t,e){return l(t,e,e)}function l(t,e,r){return void 0===t?r:v(t)?e===1/0?e:0|Math.max(0,e+t):void 0===e||e===t?t:0|Math.min(e,t)}function v(t){return t<0||0===t&&1/t==-1/0}var y="@@__IMMUTABLE_ITERABLE__@@";function d(t){return Boolean(t&&t[y])}var g="@@__IMMUTABLE_KEYED__@@";function w(t){return Boolean(t&&t[g])}var m="@@__IMMUTABLE_INDEXED__@@";function b(t){return Boolean(t&&t[m])}function z(t){return w(t)||b(t)}var S=function(t){return d(t)?t:X(t)},I=function(t){function e(t){return w(t)?t:F(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(S),O=function(t){function e(t){return b(t)?t:G(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(S),E=function(t){function e(t){return d(t)&&!z(t)?t:Z(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(S);S.Keyed=I,S.Indexed=O,S.Set=E;var j="@@__IMMUTABLE_SEQ__@@";function q(t){return Boolean(t&&t[j])}var M="@@__IMMUTABLE_RECORD__@@";function D(t){return Boolean(t&&t[M])}function x(t){return d(t)||D(t)}var A="@@__IMMUTABLE_ORDERED__@@";function k(t){return Boolean(t&&t[A])}var R=0,U=1,T=2,B="function"==typeof Symbol&&Symbol.iterator,K="@@iterator",L=B||K,C=function(t){this.next=t};function P(t,e,r,n){var i=t===R?e:t===U?r:[e,r];return n?n.value=i:n={value:i,done:!1},n}function W(){return{value:void 0,done:!0}}function N(t){return!!Array.isArray(t)||!!V(t)}function H(t){return t&&"function"==typeof t.next}function J(t){var e=V(t);return e&&e.call(t)}function V(t){var e=t&&(B&&t[B]||t[K]);if("function"==typeof e)return e}C.prototype.toString=function(){return"[Iterator]"},C.KEYS=R,C.VALUES=U,C.ENTRIES=T,C.prototype.inspect=C.prototype.toSource=function(){return this.toString()},C.prototype[L]=function(){return this};var Y=Object.prototype.hasOwnProperty;function Q(t){return!(!Array.isArray(t)&&"string"!=typeof t)||t&&"object"==typeof t&&Number.isInteger(t.length)&&t.length>=0&&(0===t.length?1===Object.keys(t).length:t.hasOwnProperty(t.length-1))}var X=function(t){function e(t){return null==t?nt():x(t)?t.toSeq():function(t){var e=ut(t);if(e)return(n=V(r=t))&&n===r.entries?e.fromEntrySeq():function(t){var e=V(t);return e&&e===t.keys}(t)?e.toSetSeq():e;var r,n;if("object"==typeof t)return new tt(t);throw new TypeError("Expected Array or collection object of values, or keyed object: "+t)}(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq {","}")},e.prototype.cacheResult=function(){return!this._cache&&this.__iterateUncached&&(this._cache=this.entrySeq().toArray(),this.size=this._cache.length),this},e.prototype.__iterate=function(t,e){var r=this._cache;if(r){for(var n=r.length,i=0;i!==n;){var o=r[e?n-++i:i++];if(!1===t(o[1],o[0],this))break}return i}return this.__iterateUncached(t,e)},e.prototype.__iterator=function(t,e){var r=this._cache;if(r){var n=r.length,i=0;return new C((function(){if(i===n)return{value:void 0,done:!0};var o=r[e?n-++i:i++];return P(t,o[0],o[1])}))}return this.__iteratorUncached(t,e)},e}(S),F=function(t){function e(t){return null==t?nt().toKeyedSeq():d(t)?w(t)?t.toSeq():t.fromEntrySeq():D(t)?t.toSeq():it(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toKeyedSeq=function(){return this},e}(X),G=function(t){function e(t){return null==t?nt():d(t)?w(t)?t.entrySeq():t.toIndexedSeq():D(t)?t.toSeq().entrySeq():ot(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return e(arguments)},e.prototype.toIndexedSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq [","]")},e}(X),Z=function(t){function e(t){return(d(t)&&!z(t)?t:G(t)).toSetSeq()}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return e(arguments)},e.prototype.toSetSeq=function(){return this},e}(X);X.isSeq=q,X.Keyed=F,X.Set=Z,X.Indexed=G,X.prototype[j]=!0;var $=function(t){function e(t){this._array=t,this.size=t.length}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t,e){return this.has(t)?this._array[c(this,t)]:e},e.prototype.__iterate=function(t,e){for(var r=this._array,n=r.length,i=0;i!==n;){var o=e?n-++i:i++;if(!1===t(r[o],o,this))break}return i},e.prototype.__iterator=function(t,e){var r=this._array,n=r.length,i=0;return new C((function(){if(i===n)return{value:void 0,done:!0};var o=e?n-++i:i++;return P(t,o,r[o])}))},e}(G),tt=function(t){function e(t){var e=Object.keys(t).concat(Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(t):[]);this._object=t,this._keys=e,this.size=e.length}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t,e){return void 0===e||this.has(t)?this._object[t]:e},e.prototype.has=function(t){return Y.call(this._object,t)},e.prototype.__iterate=function(t,e){for(var r=this._object,n=this._keys,i=n.length,o=0;o!==i;){var u=n[e?i-++o:o++];if(!1===t(r[u],u,this))break}return o},e.prototype.__iterator=function(t,e){var r=this._object,n=this._keys,i=n.length,o=0;return new C((function(){if(o===i)return{value:void 0,done:!0};var u=n[e?i-++o:o++];return P(t,u,r[u])}))},e}(F);tt.prototype[A]=!0;var et,rt=function(t){function e(t){this._collection=t,this.size=t.length||t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.__iterateUncached=function(t,e){if(e)return this.cacheResult().__iterate(t,e);var r=J(this._collection),n=0;if(H(r))for(var i;!(i=r.next()).done&&!1!==t(i.value,n++,this););return n},e.prototype.__iteratorUncached=function(t,e){if(e)return this.cacheResult().__iterator(t,e);var r=J(this._collection);if(!H(r))return new C(W);var n=0;return new C((function(){var e=r.next();return e.done?e:P(t,n++,e.value)}))},e}(G);function nt(){return et||(et=new $([]))}function it(t){var e=ut(t);if(e)return e.fromEntrySeq();if("object"==typeof t)return new tt(t);throw new TypeError("Expected Array or collection object of [k, v] entries, or keyed object: "+t)}function ot(t){var e=ut(t);if(e)return e;throw new TypeError("Expected Array or collection object of values: "+t)}function ut(t){return Q(t)?new $(t):N(t)?new rt(t):void 0}var st="@@__IMMUTABLE_MAP__@@";function at(t){return Boolean(t&&t[st])}function ct(t){return at(t)&&k(t)}function ft(t){return Boolean(t&&"function"==typeof t.equals&&"function"==typeof t.hashCode)}function ht(t,e){if(t===e||t!=t&&e!=e)return!0;if(!t||!e)return!1;if("function"==typeof t.valueOf&&"function"==typeof e.valueOf){if((t=t.valueOf())===(e=e.valueOf())||t!=t&&e!=e)return!0;if(!t||!e)return!1}return!!(ft(t)&&ft(e)&&t.equals(e))}var pt="function"==typeof Math.imul&&-2===Math.imul(4294967295,2)?Math.imul:function(t,e){var r=65535&(t|=0),n=65535&(e|=0);return r*n+((t>>>16)*n+r*(e>>>16)<<16>>>0)|0};function _t(t){return t>>>1&1073741824|3221225471&t}var lt=Object.prototype.valueOf;function vt(t){if(null==t)return yt(t);if("function"==typeof t.hashCode)return _t(t.hashCode(t));var e,r=(e=t).valueOf!==lt&&"function"==typeof e.valueOf?e.valueOf(e):e;if(null==r)return yt(r);switch(typeof r){case"boolean":return r?1108378657:1108378656;case"number":return function(t){if(t!=t||t===1/0)return 0;var e=0|t;e!==t&&(e^=4294967295*t);for(;t>4294967295;)e^=t/=4294967295;return _t(e)}(r);case"string":return r.length>Et?function(t){var e=Mt[t];void 0===e&&(e=dt(t),qt===jt&&(qt=0,Mt={}),qt++,Mt[t]=e);return e}(r):dt(r);case"object":case"function":return function(t){var e;if(zt&&void 0!==(e=bt.get(t)))return e;if(e=t[Ot],void 0!==e)return e;if(!wt){if(void 0!==(e=t.propertyIsEnumerable&&t.propertyIsEnumerable[Ot]))return e;if(void 0!==(e=function(t){if(t&&t.nodeType>0)switch(t.nodeType){case 1:return t.uniqueID;case 9:return t.documentElement&&t.documentElement.uniqueID}}(t)))return e}if(e=mt(),zt)bt.set(t,e);else{if(void 0!==gt&&!1===gt(t))throw new Error("Non-extensible objects are not allowed as keys.");if(wt)Object.defineProperty(t,Ot,{enumerable:!1,configurable:!1,writable:!1,value:e});else if(void 0!==t.propertyIsEnumerable&&t.propertyIsEnumerable===t.constructor.prototype.propertyIsEnumerable)t.propertyIsEnumerable=function(){return this.constructor.prototype.propertyIsEnumerable.apply(this,arguments)},t.propertyIsEnumerable[Ot]=e;else{if(void 0===t.nodeType)throw new Error("Unable to set a non-enumerable property on object.");t[Ot]=e}}return e}(r);case"symbol":return function(t){var e=St[t];if(void 0!==e)return e;return e=mt(),St[t]=e,e}(r);default:if("function"==typeof r.toString)return dt(r.toString());throw new Error("Value type "+typeof r+" cannot be hashed.")}}function yt(t){return null===t?1108378658:1108378659}function dt(t){for(var e=0,r=0;r=0&&(a.get=function(e,r){return(e=c(this,e))>=0&&eo)return{value:void 0,done:!0};var t=i.next();return n||e===U||t.done?t:P(e,a-1,e===R?void 0:t.value[1],t)}))},a}function Lt(t,e,r,n){var i=Xt(t);return i.__iterateUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterate(i,o);var s=!0,a=0;return t.__iterate((function(t,o,c){if(!s||!(s=e.call(r,t,o,c)))return a++,i(t,n?o:a-1,u)})),a},i.__iteratorUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterator(i,o);var s=t.__iterator(T,o),a=!0,c=0;return new C((function(){var t,o,f;do{if((t=s.next()).done)return n||i===U?t:P(i,c++,i===R?void 0:t.value[1],t);var h=t.value;o=h[0],f=h[1],a&&(a=e.call(r,f,o,u))}while(a);return i===T?t:P(i,o,f,t)}))},i}xt.prototype.cacheResult=Dt.prototype.cacheResult=At.prototype.cacheResult=kt.prototype.cacheResult=Ft;var Ct=function(t){function e(t){this._wrappedIterables=t.flatMap((function(t){return t._wrappedIterables?t._wrappedIterables:[t]})),this.size=this._wrappedIterables.reduce((function(t,e){if(void 0!==t){var r=e.size;if(void 0!==r)return t+r}}),0),this[g]=this._wrappedIterables[0][g],this[m]=this._wrappedIterables[0][m],this[A]=this._wrappedIterables[0][A]}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.__iterateUncached=function(t,e){if(0!==this._wrappedIterables.length){if(e)return this.cacheResult().__iterate(t,e);for(var r=0,n=w(this),i=n?T:U,o=this._wrappedIterables[r].__iterator(i,e),u=!0,s=0;u;){for(var a=o.next();a.done;){if(++r===this._wrappedIterables.length)return s;a=(o=this._wrappedIterables[r].__iterator(i,e)).next()}u=!1!==(n?t(a.value[1],a.value[0],this):t(a.value,s,this)),s++}return s}},e.prototype.__iteratorUncached=function(t,e){var r=this;if(0===this._wrappedIterables.length)return new C(W);if(e)return this.cacheResult().__iterator(t,e);var n=0,i=this._wrappedIterables[n].__iterator(t,e);return new C((function(){for(var o=i.next();o.done;){if(++n===r._wrappedIterables.length)return o;o=(i=r._wrappedIterables[n].__iterator(t,e)).next()}return o}))},e}(X);function Pt(t,e,r){var n=Xt(t);return n.__iterateUncached=function(i,o){if(o)return this.cacheResult().__iterate(i,o);var u=0,s=!1;return function t(a,c){a.__iterate((function(o,a){return(!e||c0}function Jt(t,e,r,n){var i=Xt(t),o=new $(r).map((function(t){return t.size}));return i.size=n?o.max():o.min(),i.__iterate=function(t,e){for(var r,n=this.__iterator(U,e),i=0;!(r=n.next()).done&&!1!==t(r.value,i++,this););return i},i.__iteratorUncached=function(t,i){var o=r.map((function(t){return t=S(t),J(i?t.reverse():t)})),u=0,s=!1;return new C((function(){var r;return s||(r=o.map((function(t){return t.next()})),s=n?r.every((function(t){return t.done})):r.some((function(t){return t.done}))),s?{value:void 0,done:!0}:P(t,u++,e.apply(null,r.map((function(t){return t.value}))))}))},i}function Vt(t,e){return t===e?t:q(t)?e:t.constructor(e)}function Yt(t){if(t!==Object(t))throw new TypeError("Expected [K, V] tuple: "+t)}function Qt(t){return w(t)?I:b(t)?O:E}function Xt(t){return Object.create((w(t)?F:b(t)?G:Z).prototype)}function Ft(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size,this):X.prototype.cacheResult.call(this)}function Gt(t,e){return void 0===t&&void 0===e?0:void 0===t?1:void 0===e?-1:t>e?1:t0;)e[r]=arguments[r+1];if("function"!=typeof t)throw new TypeError("Invalid merger function: "+t);return ze(this,e,t)}function ze(t,e,r){for(var n=[],i=0;i0;)e[r]=arguments[r+1];return Se(this,e,t)}function je(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return he(this,t,Je(),(function(t){return Ie(t,e)}))}function qe(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return he(this,t,Je(),(function(t){return Se(t,e)}))}function Me(t){var e=this.asMutable();return t(e),e.wasAltered()?e.__ensureOwner(this.__ownerID):this}function De(){return this.__ownerID?this:this.__ensureOwner(new s)}function xe(){return this.__ensureOwner()}function Ae(){return this.__altered}var ke=function(t){function e(e){return null==e?Je():at(e)&&!k(e)?e:Je().withMutations((function(r){var n=t(e);te(n.size),n.forEach((function(t,e){return r.set(e,t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toString=function(){return this.__toString("Map {","}")},e.prototype.get=function(t,e){return this._root?this._root.get(0,void 0,t,e):e},e.prototype.set=function(t,e){return Ve(this,t,e)},e.prototype.remove=function(t){return Ve(this,t,o)},e.prototype.deleteAll=function(t){var e=S(t);return 0===e.size?this:this.withMutations((function(t){e.forEach((function(e){return t.remove(e)}))}))},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):Je()},e.prototype.sort=function(t){return yr(Wt(this,t))},e.prototype.sortBy=function(t,e){return yr(Wt(this,e,t))},e.prototype.map=function(t,e){var r=this;return this.withMutations((function(n){n.forEach((function(i,o){n.set(o,t.call(e,i,o,r))}))}))},e.prototype.__iterator=function(t,e){return new Pe(this,t,e)},e.prototype.__iterate=function(t,e){var r=this,n=0;return this._root&&this._root.iterate((function(e){return n++,t(e[1],e[0],r)}),e),n},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?He(this.size,this._root,t,this.__hash):0===this.size?Je():(this.__ownerID=t,this.__altered=!1,this)},e}(I);ke.isMap=at;var Re=ke.prototype;Re[st]=!0,Re[e]=Re.remove,Re.removeAll=Re.deleteAll,Re.setIn=le,Re.removeIn=Re.deleteIn=ye,Re.update=ge,Re.updateIn=we,Re.merge=Re.concat=me,Re.mergeWith=be,Re.mergeDeep=Oe,Re.mergeDeepWith=Ee,Re.mergeIn=je,Re.mergeDeepIn=qe,Re.withMutations=Me,Re.wasAltered=Ae,Re.asImmutable=xe,Re["@@transducer/init"]=Re.asMutable=De,Re["@@transducer/step"]=function(t,e){return t.set(e[0],e[1])},Re["@@transducer/result"]=function(t){return t.asImmutable()};var Ue=function(t,e){this.ownerID=t,this.entries=e};Ue.prototype.get=function(t,e,r,n){for(var i=this.entries,o=0,u=i.length;o=Ze)return function(t,e,r,n){t||(t=new s);for(var i=new Le(t,vt(r),[r,n]),o=0;o>>t)&i),s=this.bitmap;return 0==(s&u)?o:this.nodes[Fe(s&u-1)].get(t+r,e,n,o)},Te.prototype.update=function(t,e,u,s,a,c,f){void 0===u&&(u=vt(s));var h=(0===e?u:u>>>e)&i,p=1<=$e)return function(t,e,r,i,o){for(var u=0,s=new Array(n),a=0;0!==r;a++,r>>>=1)s[a]=1&r?e[u++]:void 0;return s[i]=o,new Be(t,u+1,s)}(t,y,_,h,g);if(l&&!g&&2===y.length&&Qe(y[1^v]))return y[1^v];if(l&&g&&1===y.length&&Qe(g))return g;var w=t&&t===this.ownerID,m=l?g?_:_^p:_|p,b=l?g?Ge(y,v,g,w):function(t,e,r){var n=t.length-1;if(r&&e===n)return t.pop(),t;for(var i=new Array(n),o=0,u=0;u>>t)&i,s=this.nodes[u];return s?s.get(t+r,e,n,o):o},Be.prototype.update=function(t,e,n,u,s,a,c){void 0===n&&(n=vt(u));var f=(0===e?n:n>>>e)&i,h=s===o,p=this.nodes,_=p[f];if(h&&!_)return this;var l=Ye(_,t,e+r,n,u,s,a,c);if(l===_)return this;var v=this.count;if(_){if(!l&&--v>>n)&i,c=(0===n?o:o>>>n)&i,f=a===c?[Xe(t,e,n+r,o,u)]:(s=new Le(e,o,u),a>1&1431655765))+(t>>2&858993459))+(t>>4)&252645135,t+=t>>8,127&(t+=t>>16)}function Ge(t,e,r,n){var i=n?t:Zt(t);return i[e]=r,i}var Ze=n/4,$e=n/2,tr=n/4,er="@@__IMMUTABLE_LIST__@@";function rr(t){return Boolean(t&&t[er])}var nr=function(t){function e(e){var i=cr();if(null==e)return i;if(rr(e))return e;var o=t(e),u=o.size;return 0===u?i:(te(u),u>0&&u=0&&t=t.size||e<0)return t.withMutations((function(t){e<0?_r(t,e).set(0,r):_r(t,0,e+1).set(e,r)}));e+=t._origin;var n=t._tail,i=t._root,o={value:!1};e>=lr(t._capacity)?n=fr(n,t.__ownerID,0,e,r,o):i=fr(i,t.__ownerID,t._level,e,r,o);if(!o.value)return t;if(t.__ownerID)return t._root=i,t._tail=n,t.__hash=void 0,t.__altered=!0,t;return ar(t._origin,t._capacity,t._level,i,n)}(this,t,e)},e.prototype.remove=function(t){return this.has(t)?0===t?this.shift():t===this.size-1?this.pop():this.splice(t,1):this},e.prototype.insert=function(t,e){return this.splice(t,0,e)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=this._origin=this._capacity=0,this._level=r,this._root=this._tail=this.__hash=void 0,this.__altered=!0,this):cr()},e.prototype.push=function(){var t=arguments,e=this.size;return this.withMutations((function(r){_r(r,0,e+t.length);for(var n=0;n>>e&i;if(o>=this.array.length)return new or([],t);var u,s=0===o;if(e>0){var a=this.array[o];if((u=a&&a.removeBefore(t,e-r,n))===a&&s)return this}if(s&&!u)return this;var c=hr(this,t);if(!s)for(var f=0;f>>e&i;if(s>=this.array.length)return this;if(e>0){var a=this.array[s];if((u=a&&a.removeAfter(t,e-r,o))===a&&s===this.array.length-1)return this}var c=hr(this,t);return c.array.splice(s+1),u&&(c.array[s]=u),c};var ur={};function sr(t,e){var i=t._origin,o=t._capacity,u=lr(o),s=t._tail;return a(t._root,t._level,0);function a(t,c,f){return 0===c?function(t,r){var a=r===u?s&&s.array:t&&t.array,c=r>i?0:i-r,f=o-r;f>n&&(f=n);return function(){if(c===f)return ur;var t=e?--f:c++;return a&&a[t]}}(t,f):function(t,u,s){var c,f=t&&t.array,h=s>i?0:i-s>>u,p=1+(o-s>>u);p>n&&(p=n);return function(){for(;;){if(c){var t=c();if(t!==ur)return t;c=null}if(h===p)return ur;var n=e?--p:h++;c=a(f&&f[n],u-r,s+(n<>>n&i,h=t&&f0){var p=t&&t.array[f],_=fr(p,e,n-r,o,s,a);return _===p?t:((c=hr(t,e)).array[f]=_,c)}return h&&t.array[f]===s?t:(a&&u(a),c=hr(t,e),void 0===s&&f===c.array.length-1?c.array.pop():c.array[f]=s,c)}function hr(t,e){return e&&t&&e===t.ownerID?t:new or(t?t.array.slice():[],e)}function pr(t,e){if(e>=lr(t._capacity))return t._tail;if(e<1<0;)n=n.array[e>>>o&i],o-=r;return n}}function _r(t,e,n){void 0!==e&&(e|=0),void 0!==n&&(n|=0);var o=t.__ownerID||new s,u=t._origin,a=t._capacity,c=u+e,f=void 0===n?a:n<0?a+n:u+n;if(c===u&&f===a)return t;if(c>=f)return t.clear();for(var h=t._level,p=t._root,_=0;c+_<0;)p=new or(p&&p.array.length?[void 0,p]:[],o),_+=1<<(h+=r);_&&(c+=_,u+=_,f+=_,a+=_);for(var l=lr(a),v=lr(f);v>=1<l?new or([],o):y;if(y&&v>l&&cr;w-=r){var m=l>>>w&i;g=g.array[m]=hr(g.array[m],o)}g.array[l>>>r&i]=y}if(f=v)c-=v,f-=v,h=r,p=null,d=d&&d.removeBefore(o,0,c);else if(c>u||v>>h&i;if(b!==v>>>h&i)break;b&&(_+=(1<u&&(p=p.removeBefore(o,h,c-_)),p&&v>>r<=n&&a.size>=2*s.size?(i=(u=a.filter((function(t,e){return void 0!==t&&c!==e}))).toKeyedSeq().map((function(t){return t[0]})).flip().toMap(),t.__ownerID&&(i.__ownerID=u.__ownerID=t.__ownerID)):(i=s.remove(e),u=c===a.size-1?a.pop():a.set(c,void 0))}else if(f){if(r===a.get(c)[1])return t;i=s,u=a.set(c,[e,r])}else i=s.set(e,a.size),u=a.set(a.size,[e,r]);return t.__ownerID?(t.size=i.size,t._map=i,t._list=u,t.__hash=void 0,t.__altered=!0,t):dr(i,u)}yr.isOrderedMap=ct,yr.prototype[A]=!0,yr.prototype[e]=yr.prototype.remove;var mr="@@__IMMUTABLE_STACK__@@";function br(t){return Boolean(t&&t[mr])}var zr=function(t){function e(t){return null==t?Er():br(t)?t:Er().pushAll(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("Stack [","]")},e.prototype.get=function(t,e){var r=this._head;for(t=c(this,t);r&&t--;)r=r.next;return r?r.value:e},e.prototype.peek=function(){return this._head&&this._head.value},e.prototype.push=function(){var t=arguments;if(0===arguments.length)return this;for(var e=this.size+arguments.length,r=this._head,n=arguments.length-1;n>=0;n--)r={value:t[n],next:r};return this.__ownerID?(this.size=e,this._head=r,this.__hash=void 0,this.__altered=!0,this):Or(e,r)},e.prototype.pushAll=function(e){if(0===(e=t(e)).size)return this;if(0===this.size&&br(e))return e;te(e.size);var r=this.size,n=this._head;return e.__iterate((function(t){r++,n={value:t,next:n}}),!0),this.__ownerID?(this.size=r,this._head=n,this.__hash=void 0,this.__altered=!0,this):Or(r,n)},e.prototype.pop=function(){return this.slice(1)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):Er()},e.prototype.slice=function(e,r){if(h(e,r,this.size))return this;var n=p(e,this.size);if(_(r,this.size)!==this.size)return t.prototype.slice.call(this,e,r);for(var i=this.size-n,o=this._head;n--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):Or(i,o)},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Or(this.size,this._head,t,this.__hash):0===this.size?Er():(this.__ownerID=t,this.__altered=!1,this)},e.prototype.__iterate=function(t,e){var r=this;if(e)return new $(this.toArray()).__iterate((function(e,n){return t(e,n,r)}),e);for(var n=0,i=this._head;i&&!1!==t(i.value,n++,this);)i=i.next;return n},e.prototype.__iterator=function(t,e){if(e)return new $(this.toArray()).__iterator(t,e);var r=0,n=this._head;return new C((function(){if(n){var e=n.value;return n=n.next,P(t,r++,e)}return{value:void 0,done:!0}}))},e}(O);zr.isStack=br;var Sr,Ir=zr.prototype;function Or(t,e,r,n){var i=Object.create(Ir);return i.size=t,i._head=e,i.__ownerID=r,i.__hash=n,i.__altered=!1,i}function Er(){return Sr||(Sr=Or(0))}Ir[mr]=!0,Ir.shift=Ir.pop,Ir.unshift=Ir.push,Ir.unshiftAll=Ir.pushAll,Ir.withMutations=Me,Ir.wasAltered=Ae,Ir.asImmutable=xe,Ir["@@transducer/init"]=Ir.asMutable=De,Ir["@@transducer/step"]=function(t,e){return t.unshift(e)},Ir["@@transducer/result"]=function(t){return t.asImmutable()};var jr="@@__IMMUTABLE_SET__@@";function qr(t){return Boolean(t&&t[jr])}function Mr(t){return qr(t)&&k(t)}function Dr(t,e){if(t===e)return!0;if(!d(e)||void 0!==t.size&&void 0!==e.size&&t.size!==e.size||void 0!==t.__hash&&void 0!==e.__hash&&t.__hash!==e.__hash||w(t)!==w(e)||b(t)!==b(e)||k(t)!==k(e))return!1;if(0===t.size&&0===e.size)return!0;var r=!z(t);if(k(t)){var n=t.entries();return e.every((function(t,e){var i=n.next().value;return i&&ht(i[1],t)&&(r||ht(i[0],e))}))&&n.next().done}var i=!1;if(void 0===t.size)if(void 0===e.size)"function"==typeof t.cacheResult&&t.cacheResult();else{i=!0;var u=t;t=e,e=u}var s=!0,a=e.__iterate((function(e,n){if(r?!t.has(e):i?!ht(e,t.get(n,o)):!ht(t.get(n,o),e))return s=!1,!1}));return s&&t.size===a}function xr(t,e){var r=function(r){t.prototype[r]=e[r]};return Object.keys(e).forEach(r),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(e).forEach(r),t}function Ar(t){if(!t||"object"!=typeof t)return t;if(!d(t)){if(!ie(t))return t;t=X(t)}if(w(t)){var e={};return t.__iterate((function(t,r){e[r]=Ar(t)})),e}var r=[];return t.__iterate((function(t){r.push(Ar(t))})),r}var kr=function(t){function e(e){return null==e?Kr():qr(e)&&!k(e)?e:Kr().withMutations((function(r){var n=t(e);te(n.size),n.forEach((function(t){return r.add(t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(I(t).keySeq())},e.intersect=function(t){return(t=S(t).toArray()).length?Ur.intersect.apply(e(t.pop()),t):Kr()},e.union=function(t){return(t=S(t).toArray()).length?Ur.union.apply(e(t.pop()),t):Kr()},e.prototype.toString=function(){return this.__toString("Set {","}")},e.prototype.has=function(t){return this._map.has(t)},e.prototype.add=function(t){return Tr(this,this._map.set(t,t))},e.prototype.remove=function(t){return Tr(this,this._map.remove(t))},e.prototype.clear=function(){return Tr(this,this._map.clear())},e.prototype.map=function(t,e){var r=this,n=!1,i=Tr(this,this._map.mapEntries((function(i){var o=i[1],u=t.call(e,o,o,r);return u!==o&&(n=!0),[u,u]}),e));return n?i:this},e.prototype.union=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return 0===(e=e.filter((function(t){return 0!==t.size}))).length?this:0!==this.size||this.__ownerID||1!==e.length?this.withMutations((function(r){for(var n=0;n=0&&e=0&&r>>-15,461845907),e=pt(e<<13|e>>>-13,5),e=pt((e=(e+3864292196|0)^t)^e>>>16,2246822507),e=_t((e=pt(e^e>>>13,3266489909))^e>>>16)}(t.size,n)}(this))}});var Jr=S.prototype;Jr[y]=!0,Jr[L]=Jr.values,Jr.toJSON=Jr.toArray,Jr.__toStringMapper=oe,Jr.inspect=Jr.toSource=function(){return this.toString()},Jr.chain=Jr.flatMap,Jr.contains=Jr.includes,xr(I,{flip:function(){return Vt(this,Rt(this))},mapEntries:function(t,e){var r=this,n=0;return Vt(this,this.toSeq().map((function(i,o){return t.call(e,[o,i],n++,r)})).fromEntrySeq())},mapKeys:function(t,e){var r=this;return Vt(this,this.toSeq().flip().map((function(n,i){return t.call(e,n,i,r)})).flip())}});var Vr=I.prototype;Vr[g]=!0,Vr[L]=Jr.entries,Vr.toJSON=Hr,Vr.__toStringMapper=function(t,e){return oe(e)+": "+oe(t)},xr(O,{toKeyedSeq:function(){return new Dt(this,!1)},filter:function(t,e){return Vt(this,Bt(this,t,e,!1))},findIndex:function(t,e){var r=this.findEntry(t,e);return r?r[0]:-1},indexOf:function(t){var e=this.keyOf(t);return void 0===e?-1:e},lastIndexOf:function(t){var e=this.lastKeyOf(t);return void 0===e?-1:e},reverse:function(){return Vt(this,Tt(this,!1))},slice:function(t,e){return Vt(this,Kt(this,t,e,!1))},splice:function(t,e){var r=arguments.length;if(e=Math.max(e||0,0),0===r||2===r&&!e)return this;t=p(t,t<0?this.count():this.size);var n=this.slice(0,t);return Vt(this,1===r?n:n.concat(Zt(arguments,2),this.slice(t+e)))},findLastIndex:function(t,e){var r=this.findLastEntry(t,e);return r?r[0]:-1},first:function(t){return this.get(0,t)},flatten:function(t){return Vt(this,Pt(this,t,!1))},get:function(t,e){return(t=c(this,t))<0||this.size===1/0||void 0!==this.size&&t>this.size?e:this.find((function(e,r){return r===t}),void 0,e)},has:function(t){return(t=c(this,t))>=0&&(void 0!==this.size?this.size===1/0||te?-1:0}function rn(t,e){return t^e+2654435769+(t<<6)+(t>>2)|0}Qr.has=Jr.includes,Qr.contains=Qr.includes,Qr.keys=Qr.values,xr(F,Vr),xr(G,Yr),xr(Z,Qr);var nn=function(t){function e(t){return null==t?an():Mr(t)?t:an().withMutations((function(e){var r=E(t);te(r.size),r.forEach((function(t){return e.add(t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(I(t).keySeq())},e.prototype.toString=function(){return this.__toString("OrderedSet {","}")},e}(kr);nn.isOrderedSet=Mr;var on,un=nn.prototype;function sn(t,e){var r=Object.create(un);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function an(){return on||(on=sn(gr()))}un[A]=!0,un.zip=Yr.zip,un.zipWith=Yr.zipWith,un.zipAll=Yr.zipAll,un.__empty=an,un.__make=sn;var cn=function(t,e){var r;!function(t){if(D(t))throw new Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(x(t))throw new Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(null===t||"object"!=typeof t)throw new Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}(t);var n=function(o){var u=this;if(o instanceof n)return o;if(!(this instanceof n))return new n(o);if(!r){r=!0;var s=Object.keys(t),a=i._indices={};i._name=e,i._keys=s,i._defaultValues=t;for(var c=0;c2?[]:void 0,{"":t})},t.get=se,t.getIn=Pr,t.has=ue,t.hasIn=Nr,t.hash=vt,t.is=ht,t.isAssociative=z,t.isCollection=d,t.isImmutable=x,t.isIndexed=b,t.isKeyed=w,t.isList=rr,t.isMap=at,t.isOrdered=k,t.isOrderedMap=ct,t.isOrderedSet=Mr,t.isPlainObject=ne,t.isRecord=D,t.isSeq=q,t.isSet=qr,t.isStack=br,t.isValueObject=ft,t.merge=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Ie(t,e)},t.mergeDeep=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Se(t,e)},t.mergeDeepWith=function(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];return Se(e,r,t)},t.mergeWith=function(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];return Ie(e,r,t)},t.remove=ce,t.removeIn=ve,t.set=fe,t.setIn=_e,t.update=de,t.updateIn=he,t.version="5.0.3"})); From 12a133a51f1dac75770b251965754564c74ff61c Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 17 Mar 2025 07:41:14 +0000 Subject: [PATCH 232/242] deploy: f23809ae24b420cf395123246f0745917b9c3630 --- dist/{ => type-definitions}/immutable.d.ts | 0 dist/{ => type-definitions}/immutable.js.flow | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename dist/{ => type-definitions}/immutable.d.ts (100%) rename dist/{ => type-definitions}/immutable.js.flow (100%) diff --git a/dist/immutable.d.ts b/dist/type-definitions/immutable.d.ts similarity index 100% rename from dist/immutable.d.ts rename to dist/type-definitions/immutable.d.ts diff --git a/dist/immutable.js.flow b/dist/type-definitions/immutable.js.flow similarity index 100% rename from dist/immutable.js.flow rename to dist/type-definitions/immutable.js.flow From a928cc364956cb1341d2879b8b8501d1bd38554b Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 19 Mar 2025 20:09:47 +0000 Subject: [PATCH 233/242] deploy: 84e360f7aea2cbd1b932189b3773e607bbe12ad0 --- dist/type-definitions/immutable.d.ts | 66 ++++++++++++++++++++-------- 1 file changed, 48 insertions(+), 18 deletions(-) diff --git a/dist/type-definitions/immutable.d.ts b/dist/type-definitions/immutable.d.ts index 75bf383d3b..18c9a02fe7 100644 --- a/dist/type-definitions/immutable.d.ts +++ b/dist/type-definitions/immutable.d.ts @@ -171,6 +171,13 @@ declare namespace Immutable { */ export type Comparator = (left: T, right: T) => PairSorting | number; + /** + * @ignore + * + * KeyPath allowed for `xxxIn` methods + */ + export type KeyPath = OrderedCollection | ArrayLike; + /** * Lists are ordered indexed dense collections, much like a JavaScript * Array. @@ -873,7 +880,7 @@ declare namespace Immutable { // TODO `` can be used after dropping support for TypeScript 4.x // reference: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-0.html#const-type-parameters // after this change, `as const` assertions can be remove from the type tests - getIn

>( + getIn

>( searchKeyPath: [...P], notSetValue?: unknown ): RetrievePath; @@ -905,8 +912,14 @@ declare namespace Immutable { // Loosely based off of this work. // https://github.com/immutable-js/immutable-js/issues/1462#issuecomment-584123268 - /** @ignore */ - type GetMapType = S extends MapOf ? T : S; + /** + * @ignore + * Convert an immutable type to the equivalent plain TS type + * - MapOf -> object + * - List -> Array + */ + type GetNativeType = + S extends MapOf ? T : S extends List ? Array : S; /** @ignore */ type Head> = T extends [ @@ -915,28 +928,32 @@ declare namespace Immutable { ] ? H : never; - /** @ignore */ type Tail> = T extends [unknown, ...infer I] ? I : Array; - /** @ignore */ type RetrievePathReducer< T, C, L extends ReadonlyArray, - > = C extends keyof GetMapType - ? L extends [] - ? GetMapType[C] - : RetrievePathReducer[C], Head, Tail> - : never; + NT = GetNativeType, + > = + // we can not retrieve a path from a primitive type + T extends string | number | boolean | null | undefined + ? never + : C extends keyof NT + ? L extends [] // L extends [] means we are at the end of the path, lets return the current type + ? NT[C] + : // we are not at the end of the path, lets continue with the next key + RetrievePathReducer, Tail> + : // C is not a "key" of NT, so the path is invalid + never; /** @ignore */ - type RetrievePath< - R, - P extends ReadonlyArray, - > = P extends [] ? P : RetrievePathReducer, Tail

>; + type RetrievePath> = P extends [] + ? P + : RetrievePathReducer, Tail

>; interface Map extends Collection.Keyed { /** @@ -5908,6 +5925,9 @@ declare namespace Immutable { updater: (value: V | NSV) => V ): { [key: string]: V }; + // TODO `` can be used after dropping support for TypeScript 4.x + // reference: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-0.html#const-type-parameters + // after this change, `as const` assertions can be remove from the type tests /** * Returns the value at the provided key path starting at the provided * collection, or notSetValue if the key path is not defined. @@ -5922,10 +5942,20 @@ declare namespace Immutable { * getIn({ x: { y: { z: 123 }}}, ['x', 'q', 'p'], 'ifNotSet') // 'ifNotSet' * ``` */ - function getIn( - collection: unknown, - keyPath: Iterable, - notSetValue?: unknown + function getIn>( + object: C, + keyPath: [...P] + ): RetrievePath; + function getIn>(object: C, keyPath: P): unknown; + function getIn, NSV>( + collection: C, + keyPath: [...P], + notSetValue: NSV + ): RetrievePath extends never ? NSV : RetrievePath; + function getIn, NSV>( + object: C, + keyPath: P, + notSetValue: NSV ): unknown; /** From fb4de47d3699bd08a77993eef46691af810003fe Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 20 Mar 2025 22:06:45 +0000 Subject: [PATCH 234/242] deploy: 81673baae51e9db19e85c09d78fcbbc14ff6aab9 --- dist/type-definitions/immutable.d.ts | 115 +++++++++++++++++++++------ 1 file changed, 92 insertions(+), 23 deletions(-) diff --git a/dist/type-definitions/immutable.d.ts b/dist/type-definitions/immutable.d.ts index 18c9a02fe7..622fb01cfa 100644 --- a/dist/type-definitions/immutable.d.ts +++ b/dist/type-definitions/immutable.d.ts @@ -127,7 +127,7 @@ declare namespace Immutable { : T extends Collection.Keyed ? // convert KeyedCollection to DeepCopy plain JS object { - [key in KeyedKey extends string | number | symbol + [key in KeyedKey extends PropertyKey ? KeyedKey : string]: V extends object ? unknown : V; } @@ -853,9 +853,7 @@ declare namespace Immutable { * not altered. */ function Map(collection?: Iterable<[K, V]>): Map; - function Map( - obj: R - ): MapOf; + function Map(obj: R): MapOf; function Map(obj: { [key: string]: V }): Map; function Map(obj: { [P in K]?: V }): Map; @@ -864,7 +862,7 @@ declare namespace Immutable { * * @ignore */ - interface MapOf + interface MapOf extends Map { /** * Returns the value associated with the provided key, or notSetValue if @@ -3155,14 +3153,14 @@ declare namespace Immutable { * * Converts keys to Strings. */ - toJS(): { [key in string | number | symbol]: DeepCopy }; + toJS(): { [key in PropertyKey]: DeepCopy }; /** * Shallowly converts this Keyed Seq to equivalent native JavaScript Object. * * Converts keys to Strings. */ - toJSON(): { [key in string | number | symbol]: V }; + toJSON(): { [key in PropertyKey]: V }; /** * Shallowly converts this collection to an Array. @@ -3763,14 +3761,14 @@ declare namespace Immutable { * * Converts keys to Strings. */ - toJS(): { [key in string | number | symbol]: DeepCopy }; + toJS(): { [key in PropertyKey]: DeepCopy }; /** * Shallowly converts this Keyed collection to equivalent native JavaScript Object. * * Converts keys to Strings. */ - toJSON(): { [key in string | number | symbol]: V }; + toJSON(): { [key in PropertyKey]: V }; /** * Shallowly converts this collection to an Array. @@ -4520,9 +4518,7 @@ declare namespace Immutable { * `Collection.Indexed`, and `Collection.Set` become `Array`, while * `Collection.Keyed` become `Object`, converting keys to Strings. */ - toJS(): - | Array> - | { [key in string | number | symbol]: DeepCopy }; + toJS(): Array> | { [key in PropertyKey]: DeepCopy }; /** * Shallowly converts this Collection to equivalent native JavaScript Array or Object. @@ -4530,7 +4526,7 @@ declare namespace Immutable { * `Collection.Indexed`, and `Collection.Set` become `Array`, while * `Collection.Keyed` become `Object`, converting keys to Strings. */ - toJSON(): Array | { [key in string | number | symbol]: V }; + toJSON(): Array | { [key in PropertyKey]: V }; /** * Shallowly converts this collection to an Array. @@ -5749,9 +5745,12 @@ declare namespace Immutable { key: K, notSetValue: unknown ): C[K]; - function get(collection: { [key: string]: V }, key: string): V | undefined; + function get( + collection: { [key: PropertyKey]: V }, + key: string + ): V | undefined; function get( - collection: { [key: string]: V }, + collection: { [key: PropertyKey]: V }, key: string, notSetValue: NSV ): V | NSV; @@ -5971,7 +5970,11 @@ declare namespace Immutable { * hasIn({ x: { y: { z: 123 }}}, ['x', 'q', 'p']) // false * ``` */ - function hasIn(collection: unknown, keyPath: Iterable): boolean; + function hasIn( + collection: string | boolean | number, + keyPath: KeyPath + ): never; + function hasIn(collection: unknown, keyPath: KeyPath): boolean; /** * Returns a copy of the collection with the value at the key path removed. @@ -6025,17 +6028,83 @@ declare namespace Immutable { * console.log(original) // { x: { y: { z: 123 }}} * ``` */ - function updateIn( + function updateIn>( collection: C, - keyPath: Iterable, - updater: (value: unknown) => unknown + keyPath: KeyPath, + updater: ( + value: RetrievePath> | undefined + ) => unknown | undefined ): C; - function updateIn( + function updateIn, NSV>( collection: C, - keyPath: Iterable, - notSetValue: unknown, - updater: (value: unknown) => unknown + keyPath: KeyPath, + notSetValue: NSV, + updater: (value: RetrievePath> | NSV) => unknown + ): C; + function updateIn< + TProps extends object, + C extends Record, + K extends keyof TProps, + >( + record: C, + keyPath: KeyPath, + updater: (value: RetrievePath>) => unknown + ): C; + function updateIn< + TProps extends object, + C extends Record, + K extends keyof TProps, + NSV, + >( + record: C, + keyPath: KeyPath, + notSetValue: NSV, + updater: (value: RetrievePath> | NSV) => unknown ): C; + function updateIn>( + collection: Array, + keyPath: KeyPath, + updater: ( + value: RetrievePath> | undefined + ) => unknown | undefined + ): Array; + function updateIn, NSV>( + collection: Array, + keyPath: KeyPath, + notSetValue: NSV, + updater: (value: RetrievePath> | NSV) => unknown + ): Array; + function updateIn( + object: C, + keyPath: KeyPath, + updater: (value: RetrievePath>) => unknown + ): C; + function updateIn( + object: C, + keyPath: KeyPath, + notSetValue: NSV, + updater: (value: RetrievePath> | NSV) => unknown + ): C; + function updateIn< + K extends PropertyKey, + V, + C extends { [key: PropertyKey]: V }, + >( + collection: C, + keyPath: KeyPath, + updater: (value: RetrievePath>) => unknown + ): { [key: PropertyKey]: V }; + function updateIn< + K extends PropertyKey, + V, + C extends { [key: PropertyKey]: V }, + NSV, + >( + collection: C, + keyPath: KeyPath, + notSetValue: NSV, + updater: (value: RetrievePath> | NSV) => unknown + ): { [key: PropertyKey]: V }; /** * Returns a copy of the collection with the remaining collections merged in. From 563fec3f48cfc07656f114a54b113a803b7138e5 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sat, 22 Mar 2025 21:37:57 +0000 Subject: [PATCH 235/242] deploy: 53237d24a707e655ad060dd744a9bb9893915cba --- dist/immutable.es.js | 7 +++++++ dist/immutable.js | 7 +++++++ dist/immutable.min.js | 2 +- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/dist/immutable.es.js b/dist/immutable.es.js index 54809a9e84..71f359a42a 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -2317,6 +2317,13 @@ function updateInDeeply( ); } var key = keyPath[i]; + + if (typeof key === 'undefined') { + throw new TypeError( + 'Index can not be undefined in updateIn(). This should not happen' + ); + } + var nextExisting = wasNotSet ? NOT_SET : get(existing, key, NOT_SET); var nextUpdated = updateInDeeply( nextExisting === NOT_SET ? inImmutable : isImmutable(nextExisting), diff --git a/dist/immutable.js b/dist/immutable.js index 27da41634e..2438f20298 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -2323,6 +2323,13 @@ ); } var key = keyPath[i]; + + if (typeof key === 'undefined') { + throw new TypeError( + 'Index can not be undefined in updateIn(). This should not happen' + ); + } + var nextExisting = wasNotSet ? NOT_SET : get(existing, key, NOT_SET); var nextUpdated = updateInDeeply( nextExisting === NOT_SET ? inImmutable : isImmutable(nextExisting), diff --git a/dist/immutable.min.js b/dist/immutable.min.js index 4c6e288f7e..a62d2408be 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -22,4 +22,4 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).Immutable={})}(this,(function(t){"use strict";var e="delete",r=5,n=1<>>0;if(""+r!==e||4294967295===r)return NaN;e=r}return e<0?a(t)+e:e}function f(){return!0}function h(t,e,r){return(0===t&&!v(t)||void 0!==r&&t<=-r)&&(void 0===e||void 0!==r&&e>=r)}function p(t,e){return l(t,e,0)}function _(t,e){return l(t,e,e)}function l(t,e,r){return void 0===t?r:v(t)?e===1/0?e:0|Math.max(0,e+t):void 0===e||e===t?t:0|Math.min(e,t)}function v(t){return t<0||0===t&&1/t==-1/0}var y="@@__IMMUTABLE_ITERABLE__@@";function d(t){return Boolean(t&&t[y])}var g="@@__IMMUTABLE_KEYED__@@";function w(t){return Boolean(t&&t[g])}var m="@@__IMMUTABLE_INDEXED__@@";function b(t){return Boolean(t&&t[m])}function z(t){return w(t)||b(t)}var S=function(t){return d(t)?t:X(t)},I=function(t){function e(t){return w(t)?t:F(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(S),O=function(t){function e(t){return b(t)?t:G(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(S),E=function(t){function e(t){return d(t)&&!z(t)?t:Z(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(S);S.Keyed=I,S.Indexed=O,S.Set=E;var j="@@__IMMUTABLE_SEQ__@@";function q(t){return Boolean(t&&t[j])}var M="@@__IMMUTABLE_RECORD__@@";function D(t){return Boolean(t&&t[M])}function x(t){return d(t)||D(t)}var A="@@__IMMUTABLE_ORDERED__@@";function k(t){return Boolean(t&&t[A])}var R=0,U=1,T=2,B="function"==typeof Symbol&&Symbol.iterator,K="@@iterator",L=B||K,C=function(t){this.next=t};function P(t,e,r,n){var i=t===R?e:t===U?r:[e,r];return n?n.value=i:n={value:i,done:!1},n}function W(){return{value:void 0,done:!0}}function N(t){return!!Array.isArray(t)||!!V(t)}function H(t){return t&&"function"==typeof t.next}function J(t){var e=V(t);return e&&e.call(t)}function V(t){var e=t&&(B&&t[B]||t[K]);if("function"==typeof e)return e}C.prototype.toString=function(){return"[Iterator]"},C.KEYS=R,C.VALUES=U,C.ENTRIES=T,C.prototype.inspect=C.prototype.toSource=function(){return this.toString()},C.prototype[L]=function(){return this};var Y=Object.prototype.hasOwnProperty;function Q(t){return!(!Array.isArray(t)&&"string"!=typeof t)||t&&"object"==typeof t&&Number.isInteger(t.length)&&t.length>=0&&(0===t.length?1===Object.keys(t).length:t.hasOwnProperty(t.length-1))}var X=function(t){function e(t){return null==t?nt():x(t)?t.toSeq():function(t){var e=ut(t);if(e)return(n=V(r=t))&&n===r.entries?e.fromEntrySeq():function(t){var e=V(t);return e&&e===t.keys}(t)?e.toSetSeq():e;var r,n;if("object"==typeof t)return new tt(t);throw new TypeError("Expected Array or collection object of values, or keyed object: "+t)}(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq {","}")},e.prototype.cacheResult=function(){return!this._cache&&this.__iterateUncached&&(this._cache=this.entrySeq().toArray(),this.size=this._cache.length),this},e.prototype.__iterate=function(t,e){var r=this._cache;if(r){for(var n=r.length,i=0;i!==n;){var o=r[e?n-++i:i++];if(!1===t(o[1],o[0],this))break}return i}return this.__iterateUncached(t,e)},e.prototype.__iterator=function(t,e){var r=this._cache;if(r){var n=r.length,i=0;return new C((function(){if(i===n)return{value:void 0,done:!0};var o=r[e?n-++i:i++];return P(t,o[0],o[1])}))}return this.__iteratorUncached(t,e)},e}(S),F=function(t){function e(t){return null==t?nt().toKeyedSeq():d(t)?w(t)?t.toSeq():t.fromEntrySeq():D(t)?t.toSeq():it(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toKeyedSeq=function(){return this},e}(X),G=function(t){function e(t){return null==t?nt():d(t)?w(t)?t.entrySeq():t.toIndexedSeq():D(t)?t.toSeq().entrySeq():ot(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return e(arguments)},e.prototype.toIndexedSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq [","]")},e}(X),Z=function(t){function e(t){return(d(t)&&!z(t)?t:G(t)).toSetSeq()}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return e(arguments)},e.prototype.toSetSeq=function(){return this},e}(X);X.isSeq=q,X.Keyed=F,X.Set=Z,X.Indexed=G,X.prototype[j]=!0;var $=function(t){function e(t){this._array=t,this.size=t.length}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t,e){return this.has(t)?this._array[c(this,t)]:e},e.prototype.__iterate=function(t,e){for(var r=this._array,n=r.length,i=0;i!==n;){var o=e?n-++i:i++;if(!1===t(r[o],o,this))break}return i},e.prototype.__iterator=function(t,e){var r=this._array,n=r.length,i=0;return new C((function(){if(i===n)return{value:void 0,done:!0};var o=e?n-++i:i++;return P(t,o,r[o])}))},e}(G),tt=function(t){function e(t){var e=Object.keys(t).concat(Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(t):[]);this._object=t,this._keys=e,this.size=e.length}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t,e){return void 0===e||this.has(t)?this._object[t]:e},e.prototype.has=function(t){return Y.call(this._object,t)},e.prototype.__iterate=function(t,e){for(var r=this._object,n=this._keys,i=n.length,o=0;o!==i;){var u=n[e?i-++o:o++];if(!1===t(r[u],u,this))break}return o},e.prototype.__iterator=function(t,e){var r=this._object,n=this._keys,i=n.length,o=0;return new C((function(){if(o===i)return{value:void 0,done:!0};var u=n[e?i-++o:o++];return P(t,u,r[u])}))},e}(F);tt.prototype[A]=!0;var et,rt=function(t){function e(t){this._collection=t,this.size=t.length||t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.__iterateUncached=function(t,e){if(e)return this.cacheResult().__iterate(t,e);var r=J(this._collection),n=0;if(H(r))for(var i;!(i=r.next()).done&&!1!==t(i.value,n++,this););return n},e.prototype.__iteratorUncached=function(t,e){if(e)return this.cacheResult().__iterator(t,e);var r=J(this._collection);if(!H(r))return new C(W);var n=0;return new C((function(){var e=r.next();return e.done?e:P(t,n++,e.value)}))},e}(G);function nt(){return et||(et=new $([]))}function it(t){var e=ut(t);if(e)return e.fromEntrySeq();if("object"==typeof t)return new tt(t);throw new TypeError("Expected Array or collection object of [k, v] entries, or keyed object: "+t)}function ot(t){var e=ut(t);if(e)return e;throw new TypeError("Expected Array or collection object of values: "+t)}function ut(t){return Q(t)?new $(t):N(t)?new rt(t):void 0}var st="@@__IMMUTABLE_MAP__@@";function at(t){return Boolean(t&&t[st])}function ct(t){return at(t)&&k(t)}function ft(t){return Boolean(t&&"function"==typeof t.equals&&"function"==typeof t.hashCode)}function ht(t,e){if(t===e||t!=t&&e!=e)return!0;if(!t||!e)return!1;if("function"==typeof t.valueOf&&"function"==typeof e.valueOf){if((t=t.valueOf())===(e=e.valueOf())||t!=t&&e!=e)return!0;if(!t||!e)return!1}return!!(ft(t)&&ft(e)&&t.equals(e))}var pt="function"==typeof Math.imul&&-2===Math.imul(4294967295,2)?Math.imul:function(t,e){var r=65535&(t|=0),n=65535&(e|=0);return r*n+((t>>>16)*n+r*(e>>>16)<<16>>>0)|0};function _t(t){return t>>>1&1073741824|3221225471&t}var lt=Object.prototype.valueOf;function vt(t){if(null==t)return yt(t);if("function"==typeof t.hashCode)return _t(t.hashCode(t));var e,r=(e=t).valueOf!==lt&&"function"==typeof e.valueOf?e.valueOf(e):e;if(null==r)return yt(r);switch(typeof r){case"boolean":return r?1108378657:1108378656;case"number":return function(t){if(t!=t||t===1/0)return 0;var e=0|t;e!==t&&(e^=4294967295*t);for(;t>4294967295;)e^=t/=4294967295;return _t(e)}(r);case"string":return r.length>Et?function(t){var e=Mt[t];void 0===e&&(e=dt(t),qt===jt&&(qt=0,Mt={}),qt++,Mt[t]=e);return e}(r):dt(r);case"object":case"function":return function(t){var e;if(zt&&void 0!==(e=bt.get(t)))return e;if(e=t[Ot],void 0!==e)return e;if(!wt){if(void 0!==(e=t.propertyIsEnumerable&&t.propertyIsEnumerable[Ot]))return e;if(void 0!==(e=function(t){if(t&&t.nodeType>0)switch(t.nodeType){case 1:return t.uniqueID;case 9:return t.documentElement&&t.documentElement.uniqueID}}(t)))return e}if(e=mt(),zt)bt.set(t,e);else{if(void 0!==gt&&!1===gt(t))throw new Error("Non-extensible objects are not allowed as keys.");if(wt)Object.defineProperty(t,Ot,{enumerable:!1,configurable:!1,writable:!1,value:e});else if(void 0!==t.propertyIsEnumerable&&t.propertyIsEnumerable===t.constructor.prototype.propertyIsEnumerable)t.propertyIsEnumerable=function(){return this.constructor.prototype.propertyIsEnumerable.apply(this,arguments)},t.propertyIsEnumerable[Ot]=e;else{if(void 0===t.nodeType)throw new Error("Unable to set a non-enumerable property on object.");t[Ot]=e}}return e}(r);case"symbol":return function(t){var e=St[t];if(void 0!==e)return e;return e=mt(),St[t]=e,e}(r);default:if("function"==typeof r.toString)return dt(r.toString());throw new Error("Value type "+typeof r+" cannot be hashed.")}}function yt(t){return null===t?1108378658:1108378659}function dt(t){for(var e=0,r=0;r=0&&(a.get=function(e,r){return(e=c(this,e))>=0&&eo)return{value:void 0,done:!0};var t=i.next();return n||e===U||t.done?t:P(e,a-1,e===R?void 0:t.value[1],t)}))},a}function Lt(t,e,r,n){var i=Xt(t);return i.__iterateUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterate(i,o);var s=!0,a=0;return t.__iterate((function(t,o,c){if(!s||!(s=e.call(r,t,o,c)))return a++,i(t,n?o:a-1,u)})),a},i.__iteratorUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterator(i,o);var s=t.__iterator(T,o),a=!0,c=0;return new C((function(){var t,o,f;do{if((t=s.next()).done)return n||i===U?t:P(i,c++,i===R?void 0:t.value[1],t);var h=t.value;o=h[0],f=h[1],a&&(a=e.call(r,f,o,u))}while(a);return i===T?t:P(i,o,f,t)}))},i}xt.prototype.cacheResult=Dt.prototype.cacheResult=At.prototype.cacheResult=kt.prototype.cacheResult=Ft;var Ct=function(t){function e(t){this._wrappedIterables=t.flatMap((function(t){return t._wrappedIterables?t._wrappedIterables:[t]})),this.size=this._wrappedIterables.reduce((function(t,e){if(void 0!==t){var r=e.size;if(void 0!==r)return t+r}}),0),this[g]=this._wrappedIterables[0][g],this[m]=this._wrappedIterables[0][m],this[A]=this._wrappedIterables[0][A]}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.__iterateUncached=function(t,e){if(0!==this._wrappedIterables.length){if(e)return this.cacheResult().__iterate(t,e);for(var r=0,n=w(this),i=n?T:U,o=this._wrappedIterables[r].__iterator(i,e),u=!0,s=0;u;){for(var a=o.next();a.done;){if(++r===this._wrappedIterables.length)return s;a=(o=this._wrappedIterables[r].__iterator(i,e)).next()}u=!1!==(n?t(a.value[1],a.value[0],this):t(a.value,s,this)),s++}return s}},e.prototype.__iteratorUncached=function(t,e){var r=this;if(0===this._wrappedIterables.length)return new C(W);if(e)return this.cacheResult().__iterator(t,e);var n=0,i=this._wrappedIterables[n].__iterator(t,e);return new C((function(){for(var o=i.next();o.done;){if(++n===r._wrappedIterables.length)return o;o=(i=r._wrappedIterables[n].__iterator(t,e)).next()}return o}))},e}(X);function Pt(t,e,r){var n=Xt(t);return n.__iterateUncached=function(i,o){if(o)return this.cacheResult().__iterate(i,o);var u=0,s=!1;return function t(a,c){a.__iterate((function(o,a){return(!e||c0}function Jt(t,e,r,n){var i=Xt(t),o=new $(r).map((function(t){return t.size}));return i.size=n?o.max():o.min(),i.__iterate=function(t,e){for(var r,n=this.__iterator(U,e),i=0;!(r=n.next()).done&&!1!==t(r.value,i++,this););return i},i.__iteratorUncached=function(t,i){var o=r.map((function(t){return t=S(t),J(i?t.reverse():t)})),u=0,s=!1;return new C((function(){var r;return s||(r=o.map((function(t){return t.next()})),s=n?r.every((function(t){return t.done})):r.some((function(t){return t.done}))),s?{value:void 0,done:!0}:P(t,u++,e.apply(null,r.map((function(t){return t.value}))))}))},i}function Vt(t,e){return t===e?t:q(t)?e:t.constructor(e)}function Yt(t){if(t!==Object(t))throw new TypeError("Expected [K, V] tuple: "+t)}function Qt(t){return w(t)?I:b(t)?O:E}function Xt(t){return Object.create((w(t)?F:b(t)?G:Z).prototype)}function Ft(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size,this):X.prototype.cacheResult.call(this)}function Gt(t,e){return void 0===t&&void 0===e?0:void 0===t?1:void 0===e?-1:t>e?1:t0;)e[r]=arguments[r+1];if("function"!=typeof t)throw new TypeError("Invalid merger function: "+t);return ze(this,e,t)}function ze(t,e,r){for(var n=[],i=0;i0;)e[r]=arguments[r+1];return Se(this,e,t)}function je(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return he(this,t,Je(),(function(t){return Ie(t,e)}))}function qe(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return he(this,t,Je(),(function(t){return Se(t,e)}))}function Me(t){var e=this.asMutable();return t(e),e.wasAltered()?e.__ensureOwner(this.__ownerID):this}function De(){return this.__ownerID?this:this.__ensureOwner(new s)}function xe(){return this.__ensureOwner()}function Ae(){return this.__altered}var ke=function(t){function e(e){return null==e?Je():at(e)&&!k(e)?e:Je().withMutations((function(r){var n=t(e);te(n.size),n.forEach((function(t,e){return r.set(e,t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toString=function(){return this.__toString("Map {","}")},e.prototype.get=function(t,e){return this._root?this._root.get(0,void 0,t,e):e},e.prototype.set=function(t,e){return Ve(this,t,e)},e.prototype.remove=function(t){return Ve(this,t,o)},e.prototype.deleteAll=function(t){var e=S(t);return 0===e.size?this:this.withMutations((function(t){e.forEach((function(e){return t.remove(e)}))}))},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):Je()},e.prototype.sort=function(t){return yr(Wt(this,t))},e.prototype.sortBy=function(t,e){return yr(Wt(this,e,t))},e.prototype.map=function(t,e){var r=this;return this.withMutations((function(n){n.forEach((function(i,o){n.set(o,t.call(e,i,o,r))}))}))},e.prototype.__iterator=function(t,e){return new Pe(this,t,e)},e.prototype.__iterate=function(t,e){var r=this,n=0;return this._root&&this._root.iterate((function(e){return n++,t(e[1],e[0],r)}),e),n},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?He(this.size,this._root,t,this.__hash):0===this.size?Je():(this.__ownerID=t,this.__altered=!1,this)},e}(I);ke.isMap=at;var Re=ke.prototype;Re[st]=!0,Re[e]=Re.remove,Re.removeAll=Re.deleteAll,Re.setIn=le,Re.removeIn=Re.deleteIn=ye,Re.update=ge,Re.updateIn=we,Re.merge=Re.concat=me,Re.mergeWith=be,Re.mergeDeep=Oe,Re.mergeDeepWith=Ee,Re.mergeIn=je,Re.mergeDeepIn=qe,Re.withMutations=Me,Re.wasAltered=Ae,Re.asImmutable=xe,Re["@@transducer/init"]=Re.asMutable=De,Re["@@transducer/step"]=function(t,e){return t.set(e[0],e[1])},Re["@@transducer/result"]=function(t){return t.asImmutable()};var Ue=function(t,e){this.ownerID=t,this.entries=e};Ue.prototype.get=function(t,e,r,n){for(var i=this.entries,o=0,u=i.length;o=Ze)return function(t,e,r,n){t||(t=new s);for(var i=new Le(t,vt(r),[r,n]),o=0;o>>t)&i),s=this.bitmap;return 0==(s&u)?o:this.nodes[Fe(s&u-1)].get(t+r,e,n,o)},Te.prototype.update=function(t,e,u,s,a,c,f){void 0===u&&(u=vt(s));var h=(0===e?u:u>>>e)&i,p=1<=$e)return function(t,e,r,i,o){for(var u=0,s=new Array(n),a=0;0!==r;a++,r>>>=1)s[a]=1&r?e[u++]:void 0;return s[i]=o,new Be(t,u+1,s)}(t,y,_,h,g);if(l&&!g&&2===y.length&&Qe(y[1^v]))return y[1^v];if(l&&g&&1===y.length&&Qe(g))return g;var w=t&&t===this.ownerID,m=l?g?_:_^p:_|p,b=l?g?Ge(y,v,g,w):function(t,e,r){var n=t.length-1;if(r&&e===n)return t.pop(),t;for(var i=new Array(n),o=0,u=0;u>>t)&i,s=this.nodes[u];return s?s.get(t+r,e,n,o):o},Be.prototype.update=function(t,e,n,u,s,a,c){void 0===n&&(n=vt(u));var f=(0===e?n:n>>>e)&i,h=s===o,p=this.nodes,_=p[f];if(h&&!_)return this;var l=Ye(_,t,e+r,n,u,s,a,c);if(l===_)return this;var v=this.count;if(_){if(!l&&--v>>n)&i,c=(0===n?o:o>>>n)&i,f=a===c?[Xe(t,e,n+r,o,u)]:(s=new Le(e,o,u),a>1&1431655765))+(t>>2&858993459))+(t>>4)&252645135,t+=t>>8,127&(t+=t>>16)}function Ge(t,e,r,n){var i=n?t:Zt(t);return i[e]=r,i}var Ze=n/4,$e=n/2,tr=n/4,er="@@__IMMUTABLE_LIST__@@";function rr(t){return Boolean(t&&t[er])}var nr=function(t){function e(e){var i=cr();if(null==e)return i;if(rr(e))return e;var o=t(e),u=o.size;return 0===u?i:(te(u),u>0&&u=0&&t=t.size||e<0)return t.withMutations((function(t){e<0?_r(t,e).set(0,r):_r(t,0,e+1).set(e,r)}));e+=t._origin;var n=t._tail,i=t._root,o={value:!1};e>=lr(t._capacity)?n=fr(n,t.__ownerID,0,e,r,o):i=fr(i,t.__ownerID,t._level,e,r,o);if(!o.value)return t;if(t.__ownerID)return t._root=i,t._tail=n,t.__hash=void 0,t.__altered=!0,t;return ar(t._origin,t._capacity,t._level,i,n)}(this,t,e)},e.prototype.remove=function(t){return this.has(t)?0===t?this.shift():t===this.size-1?this.pop():this.splice(t,1):this},e.prototype.insert=function(t,e){return this.splice(t,0,e)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=this._origin=this._capacity=0,this._level=r,this._root=this._tail=this.__hash=void 0,this.__altered=!0,this):cr()},e.prototype.push=function(){var t=arguments,e=this.size;return this.withMutations((function(r){_r(r,0,e+t.length);for(var n=0;n>>e&i;if(o>=this.array.length)return new or([],t);var u,s=0===o;if(e>0){var a=this.array[o];if((u=a&&a.removeBefore(t,e-r,n))===a&&s)return this}if(s&&!u)return this;var c=hr(this,t);if(!s)for(var f=0;f>>e&i;if(s>=this.array.length)return this;if(e>0){var a=this.array[s];if((u=a&&a.removeAfter(t,e-r,o))===a&&s===this.array.length-1)return this}var c=hr(this,t);return c.array.splice(s+1),u&&(c.array[s]=u),c};var ur={};function sr(t,e){var i=t._origin,o=t._capacity,u=lr(o),s=t._tail;return a(t._root,t._level,0);function a(t,c,f){return 0===c?function(t,r){var a=r===u?s&&s.array:t&&t.array,c=r>i?0:i-r,f=o-r;f>n&&(f=n);return function(){if(c===f)return ur;var t=e?--f:c++;return a&&a[t]}}(t,f):function(t,u,s){var c,f=t&&t.array,h=s>i?0:i-s>>u,p=1+(o-s>>u);p>n&&(p=n);return function(){for(;;){if(c){var t=c();if(t!==ur)return t;c=null}if(h===p)return ur;var n=e?--p:h++;c=a(f&&f[n],u-r,s+(n<>>n&i,h=t&&f0){var p=t&&t.array[f],_=fr(p,e,n-r,o,s,a);return _===p?t:((c=hr(t,e)).array[f]=_,c)}return h&&t.array[f]===s?t:(a&&u(a),c=hr(t,e),void 0===s&&f===c.array.length-1?c.array.pop():c.array[f]=s,c)}function hr(t,e){return e&&t&&e===t.ownerID?t:new or(t?t.array.slice():[],e)}function pr(t,e){if(e>=lr(t._capacity))return t._tail;if(e<1<0;)n=n.array[e>>>o&i],o-=r;return n}}function _r(t,e,n){void 0!==e&&(e|=0),void 0!==n&&(n|=0);var o=t.__ownerID||new s,u=t._origin,a=t._capacity,c=u+e,f=void 0===n?a:n<0?a+n:u+n;if(c===u&&f===a)return t;if(c>=f)return t.clear();for(var h=t._level,p=t._root,_=0;c+_<0;)p=new or(p&&p.array.length?[void 0,p]:[],o),_+=1<<(h+=r);_&&(c+=_,u+=_,f+=_,a+=_);for(var l=lr(a),v=lr(f);v>=1<l?new or([],o):y;if(y&&v>l&&cr;w-=r){var m=l>>>w&i;g=g.array[m]=hr(g.array[m],o)}g.array[l>>>r&i]=y}if(f=v)c-=v,f-=v,h=r,p=null,d=d&&d.removeBefore(o,0,c);else if(c>u||v>>h&i;if(b!==v>>>h&i)break;b&&(_+=(1<u&&(p=p.removeBefore(o,h,c-_)),p&&v>>r<=n&&a.size>=2*s.size?(i=(u=a.filter((function(t,e){return void 0!==t&&c!==e}))).toKeyedSeq().map((function(t){return t[0]})).flip().toMap(),t.__ownerID&&(i.__ownerID=u.__ownerID=t.__ownerID)):(i=s.remove(e),u=c===a.size-1?a.pop():a.set(c,void 0))}else if(f){if(r===a.get(c)[1])return t;i=s,u=a.set(c,[e,r])}else i=s.set(e,a.size),u=a.set(a.size,[e,r]);return t.__ownerID?(t.size=i.size,t._map=i,t._list=u,t.__hash=void 0,t.__altered=!0,t):dr(i,u)}yr.isOrderedMap=ct,yr.prototype[A]=!0,yr.prototype[e]=yr.prototype.remove;var mr="@@__IMMUTABLE_STACK__@@";function br(t){return Boolean(t&&t[mr])}var zr=function(t){function e(t){return null==t?Er():br(t)?t:Er().pushAll(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("Stack [","]")},e.prototype.get=function(t,e){var r=this._head;for(t=c(this,t);r&&t--;)r=r.next;return r?r.value:e},e.prototype.peek=function(){return this._head&&this._head.value},e.prototype.push=function(){var t=arguments;if(0===arguments.length)return this;for(var e=this.size+arguments.length,r=this._head,n=arguments.length-1;n>=0;n--)r={value:t[n],next:r};return this.__ownerID?(this.size=e,this._head=r,this.__hash=void 0,this.__altered=!0,this):Or(e,r)},e.prototype.pushAll=function(e){if(0===(e=t(e)).size)return this;if(0===this.size&&br(e))return e;te(e.size);var r=this.size,n=this._head;return e.__iterate((function(t){r++,n={value:t,next:n}}),!0),this.__ownerID?(this.size=r,this._head=n,this.__hash=void 0,this.__altered=!0,this):Or(r,n)},e.prototype.pop=function(){return this.slice(1)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):Er()},e.prototype.slice=function(e,r){if(h(e,r,this.size))return this;var n=p(e,this.size);if(_(r,this.size)!==this.size)return t.prototype.slice.call(this,e,r);for(var i=this.size-n,o=this._head;n--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):Or(i,o)},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Or(this.size,this._head,t,this.__hash):0===this.size?Er():(this.__ownerID=t,this.__altered=!1,this)},e.prototype.__iterate=function(t,e){var r=this;if(e)return new $(this.toArray()).__iterate((function(e,n){return t(e,n,r)}),e);for(var n=0,i=this._head;i&&!1!==t(i.value,n++,this);)i=i.next;return n},e.prototype.__iterator=function(t,e){if(e)return new $(this.toArray()).__iterator(t,e);var r=0,n=this._head;return new C((function(){if(n){var e=n.value;return n=n.next,P(t,r++,e)}return{value:void 0,done:!0}}))},e}(O);zr.isStack=br;var Sr,Ir=zr.prototype;function Or(t,e,r,n){var i=Object.create(Ir);return i.size=t,i._head=e,i.__ownerID=r,i.__hash=n,i.__altered=!1,i}function Er(){return Sr||(Sr=Or(0))}Ir[mr]=!0,Ir.shift=Ir.pop,Ir.unshift=Ir.push,Ir.unshiftAll=Ir.pushAll,Ir.withMutations=Me,Ir.wasAltered=Ae,Ir.asImmutable=xe,Ir["@@transducer/init"]=Ir.asMutable=De,Ir["@@transducer/step"]=function(t,e){return t.unshift(e)},Ir["@@transducer/result"]=function(t){return t.asImmutable()};var jr="@@__IMMUTABLE_SET__@@";function qr(t){return Boolean(t&&t[jr])}function Mr(t){return qr(t)&&k(t)}function Dr(t,e){if(t===e)return!0;if(!d(e)||void 0!==t.size&&void 0!==e.size&&t.size!==e.size||void 0!==t.__hash&&void 0!==e.__hash&&t.__hash!==e.__hash||w(t)!==w(e)||b(t)!==b(e)||k(t)!==k(e))return!1;if(0===t.size&&0===e.size)return!0;var r=!z(t);if(k(t)){var n=t.entries();return e.every((function(t,e){var i=n.next().value;return i&&ht(i[1],t)&&(r||ht(i[0],e))}))&&n.next().done}var i=!1;if(void 0===t.size)if(void 0===e.size)"function"==typeof t.cacheResult&&t.cacheResult();else{i=!0;var u=t;t=e,e=u}var s=!0,a=e.__iterate((function(e,n){if(r?!t.has(e):i?!ht(e,t.get(n,o)):!ht(t.get(n,o),e))return s=!1,!1}));return s&&t.size===a}function xr(t,e){var r=function(r){t.prototype[r]=e[r]};return Object.keys(e).forEach(r),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(e).forEach(r),t}function Ar(t){if(!t||"object"!=typeof t)return t;if(!d(t)){if(!ie(t))return t;t=X(t)}if(w(t)){var e={};return t.__iterate((function(t,r){e[r]=Ar(t)})),e}var r=[];return t.__iterate((function(t){r.push(Ar(t))})),r}var kr=function(t){function e(e){return null==e?Kr():qr(e)&&!k(e)?e:Kr().withMutations((function(r){var n=t(e);te(n.size),n.forEach((function(t){return r.add(t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(I(t).keySeq())},e.intersect=function(t){return(t=S(t).toArray()).length?Ur.intersect.apply(e(t.pop()),t):Kr()},e.union=function(t){return(t=S(t).toArray()).length?Ur.union.apply(e(t.pop()),t):Kr()},e.prototype.toString=function(){return this.__toString("Set {","}")},e.prototype.has=function(t){return this._map.has(t)},e.prototype.add=function(t){return Tr(this,this._map.set(t,t))},e.prototype.remove=function(t){return Tr(this,this._map.remove(t))},e.prototype.clear=function(){return Tr(this,this._map.clear())},e.prototype.map=function(t,e){var r=this,n=!1,i=Tr(this,this._map.mapEntries((function(i){var o=i[1],u=t.call(e,o,o,r);return u!==o&&(n=!0),[u,u]}),e));return n?i:this},e.prototype.union=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return 0===(e=e.filter((function(t){return 0!==t.size}))).length?this:0!==this.size||this.__ownerID||1!==e.length?this.withMutations((function(r){for(var n=0;n=0&&e=0&&r>>-15,461845907),e=pt(e<<13|e>>>-13,5),e=pt((e=(e+3864292196|0)^t)^e>>>16,2246822507),e=_t((e=pt(e^e>>>13,3266489909))^e>>>16)}(t.size,n)}(this))}});var Jr=S.prototype;Jr[y]=!0,Jr[L]=Jr.values,Jr.toJSON=Jr.toArray,Jr.__toStringMapper=oe,Jr.inspect=Jr.toSource=function(){return this.toString()},Jr.chain=Jr.flatMap,Jr.contains=Jr.includes,xr(I,{flip:function(){return Vt(this,Rt(this))},mapEntries:function(t,e){var r=this,n=0;return Vt(this,this.toSeq().map((function(i,o){return t.call(e,[o,i],n++,r)})).fromEntrySeq())},mapKeys:function(t,e){var r=this;return Vt(this,this.toSeq().flip().map((function(n,i){return t.call(e,n,i,r)})).flip())}});var Vr=I.prototype;Vr[g]=!0,Vr[L]=Jr.entries,Vr.toJSON=Hr,Vr.__toStringMapper=function(t,e){return oe(e)+": "+oe(t)},xr(O,{toKeyedSeq:function(){return new Dt(this,!1)},filter:function(t,e){return Vt(this,Bt(this,t,e,!1))},findIndex:function(t,e){var r=this.findEntry(t,e);return r?r[0]:-1},indexOf:function(t){var e=this.keyOf(t);return void 0===e?-1:e},lastIndexOf:function(t){var e=this.lastKeyOf(t);return void 0===e?-1:e},reverse:function(){return Vt(this,Tt(this,!1))},slice:function(t,e){return Vt(this,Kt(this,t,e,!1))},splice:function(t,e){var r=arguments.length;if(e=Math.max(e||0,0),0===r||2===r&&!e)return this;t=p(t,t<0?this.count():this.size);var n=this.slice(0,t);return Vt(this,1===r?n:n.concat(Zt(arguments,2),this.slice(t+e)))},findLastIndex:function(t,e){var r=this.findLastEntry(t,e);return r?r[0]:-1},first:function(t){return this.get(0,t)},flatten:function(t){return Vt(this,Pt(this,t,!1))},get:function(t,e){return(t=c(this,t))<0||this.size===1/0||void 0!==this.size&&t>this.size?e:this.find((function(e,r){return r===t}),void 0,e)},has:function(t){return(t=c(this,t))>=0&&(void 0!==this.size?this.size===1/0||te?-1:0}function rn(t,e){return t^e+2654435769+(t<<6)+(t>>2)|0}Qr.has=Jr.includes,Qr.contains=Qr.includes,Qr.keys=Qr.values,xr(F,Vr),xr(G,Yr),xr(Z,Qr);var nn=function(t){function e(t){return null==t?an():Mr(t)?t:an().withMutations((function(e){var r=E(t);te(r.size),r.forEach((function(t){return e.add(t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(I(t).keySeq())},e.prototype.toString=function(){return this.__toString("OrderedSet {","}")},e}(kr);nn.isOrderedSet=Mr;var on,un=nn.prototype;function sn(t,e){var r=Object.create(un);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function an(){return on||(on=sn(gr()))}un[A]=!0,un.zip=Yr.zip,un.zipWith=Yr.zipWith,un.zipAll=Yr.zipAll,un.__empty=an,un.__make=sn;var cn=function(t,e){var r;!function(t){if(D(t))throw new Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(x(t))throw new Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(null===t||"object"!=typeof t)throw new Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}(t);var n=function(o){var u=this;if(o instanceof n)return o;if(!(this instanceof n))return new n(o);if(!r){r=!0;var s=Object.keys(t),a=i._indices={};i._name=e,i._keys=s,i._defaultValues=t;for(var c=0;c2?[]:void 0,{"":t})},t.get=se,t.getIn=Pr,t.has=ue,t.hasIn=Nr,t.hash=vt,t.is=ht,t.isAssociative=z,t.isCollection=d,t.isImmutable=x,t.isIndexed=b,t.isKeyed=w,t.isList=rr,t.isMap=at,t.isOrdered=k,t.isOrderedMap=ct,t.isOrderedSet=Mr,t.isPlainObject=ne,t.isRecord=D,t.isSeq=q,t.isSet=qr,t.isStack=br,t.isValueObject=ft,t.merge=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Ie(t,e)},t.mergeDeep=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Se(t,e)},t.mergeDeepWith=function(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];return Se(e,r,t)},t.mergeWith=function(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];return Ie(e,r,t)},t.remove=ce,t.removeIn=ve,t.set=fe,t.setIn=_e,t.update=de,t.updateIn=he,t.version="5.0.3"})); +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).Immutable={})}(this,(function(t){"use strict";var e="delete",r=5,n=1<>>0;if(""+r!==e||4294967295===r)return NaN;e=r}return e<0?a(t)+e:e}function f(){return!0}function h(t,e,r){return(0===t&&!v(t)||void 0!==r&&t<=-r)&&(void 0===e||void 0!==r&&e>=r)}function p(t,e){return l(t,e,0)}function _(t,e){return l(t,e,e)}function l(t,e,r){return void 0===t?r:v(t)?e===1/0?e:0|Math.max(0,e+t):void 0===e||e===t?t:0|Math.min(e,t)}function v(t){return t<0||0===t&&1/t==-1/0}var y="@@__IMMUTABLE_ITERABLE__@@";function d(t){return Boolean(t&&t[y])}var g="@@__IMMUTABLE_KEYED__@@";function w(t){return Boolean(t&&t[g])}var m="@@__IMMUTABLE_INDEXED__@@";function b(t){return Boolean(t&&t[m])}function z(t){return w(t)||b(t)}var S=function(t){return d(t)?t:X(t)},I=function(t){function e(t){return w(t)?t:F(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(S),O=function(t){function e(t){return b(t)?t:G(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(S),E=function(t){function e(t){return d(t)&&!z(t)?t:Z(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(S);S.Keyed=I,S.Indexed=O,S.Set=E;var j="@@__IMMUTABLE_SEQ__@@";function q(t){return Boolean(t&&t[j])}var M="@@__IMMUTABLE_RECORD__@@";function D(t){return Boolean(t&&t[M])}function x(t){return d(t)||D(t)}var A="@@__IMMUTABLE_ORDERED__@@";function k(t){return Boolean(t&&t[A])}var R=0,U=1,T=2,B="function"==typeof Symbol&&Symbol.iterator,K="@@iterator",L=B||K,C=function(t){this.next=t};function P(t,e,r,n){var i=t===R?e:t===U?r:[e,r];return n?n.value=i:n={value:i,done:!1},n}function W(){return{value:void 0,done:!0}}function N(t){return!!Array.isArray(t)||!!V(t)}function H(t){return t&&"function"==typeof t.next}function J(t){var e=V(t);return e&&e.call(t)}function V(t){var e=t&&(B&&t[B]||t[K]);if("function"==typeof e)return e}C.prototype.toString=function(){return"[Iterator]"},C.KEYS=R,C.VALUES=U,C.ENTRIES=T,C.prototype.inspect=C.prototype.toSource=function(){return this.toString()},C.prototype[L]=function(){return this};var Y=Object.prototype.hasOwnProperty;function Q(t){return!(!Array.isArray(t)&&"string"!=typeof t)||t&&"object"==typeof t&&Number.isInteger(t.length)&&t.length>=0&&(0===t.length?1===Object.keys(t).length:t.hasOwnProperty(t.length-1))}var X=function(t){function e(t){return null==t?nt():x(t)?t.toSeq():function(t){var e=ut(t);if(e)return(n=V(r=t))&&n===r.entries?e.fromEntrySeq():function(t){var e=V(t);return e&&e===t.keys}(t)?e.toSetSeq():e;var r,n;if("object"==typeof t)return new tt(t);throw new TypeError("Expected Array or collection object of values, or keyed object: "+t)}(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq {","}")},e.prototype.cacheResult=function(){return!this._cache&&this.__iterateUncached&&(this._cache=this.entrySeq().toArray(),this.size=this._cache.length),this},e.prototype.__iterate=function(t,e){var r=this._cache;if(r){for(var n=r.length,i=0;i!==n;){var o=r[e?n-++i:i++];if(!1===t(o[1],o[0],this))break}return i}return this.__iterateUncached(t,e)},e.prototype.__iterator=function(t,e){var r=this._cache;if(r){var n=r.length,i=0;return new C((function(){if(i===n)return{value:void 0,done:!0};var o=r[e?n-++i:i++];return P(t,o[0],o[1])}))}return this.__iteratorUncached(t,e)},e}(S),F=function(t){function e(t){return null==t?nt().toKeyedSeq():d(t)?w(t)?t.toSeq():t.fromEntrySeq():D(t)?t.toSeq():it(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toKeyedSeq=function(){return this},e}(X),G=function(t){function e(t){return null==t?nt():d(t)?w(t)?t.entrySeq():t.toIndexedSeq():D(t)?t.toSeq().entrySeq():ot(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return e(arguments)},e.prototype.toIndexedSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq [","]")},e}(X),Z=function(t){function e(t){return(d(t)&&!z(t)?t:G(t)).toSetSeq()}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return e(arguments)},e.prototype.toSetSeq=function(){return this},e}(X);X.isSeq=q,X.Keyed=F,X.Set=Z,X.Indexed=G,X.prototype[j]=!0;var $=function(t){function e(t){this._array=t,this.size=t.length}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t,e){return this.has(t)?this._array[c(this,t)]:e},e.prototype.__iterate=function(t,e){for(var r=this._array,n=r.length,i=0;i!==n;){var o=e?n-++i:i++;if(!1===t(r[o],o,this))break}return i},e.prototype.__iterator=function(t,e){var r=this._array,n=r.length,i=0;return new C((function(){if(i===n)return{value:void 0,done:!0};var o=e?n-++i:i++;return P(t,o,r[o])}))},e}(G),tt=function(t){function e(t){var e=Object.keys(t).concat(Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(t):[]);this._object=t,this._keys=e,this.size=e.length}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t,e){return void 0===e||this.has(t)?this._object[t]:e},e.prototype.has=function(t){return Y.call(this._object,t)},e.prototype.__iterate=function(t,e){for(var r=this._object,n=this._keys,i=n.length,o=0;o!==i;){var u=n[e?i-++o:o++];if(!1===t(r[u],u,this))break}return o},e.prototype.__iterator=function(t,e){var r=this._object,n=this._keys,i=n.length,o=0;return new C((function(){if(o===i)return{value:void 0,done:!0};var u=n[e?i-++o:o++];return P(t,u,r[u])}))},e}(F);tt.prototype[A]=!0;var et,rt=function(t){function e(t){this._collection=t,this.size=t.length||t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.__iterateUncached=function(t,e){if(e)return this.cacheResult().__iterate(t,e);var r=J(this._collection),n=0;if(H(r))for(var i;!(i=r.next()).done&&!1!==t(i.value,n++,this););return n},e.prototype.__iteratorUncached=function(t,e){if(e)return this.cacheResult().__iterator(t,e);var r=J(this._collection);if(!H(r))return new C(W);var n=0;return new C((function(){var e=r.next();return e.done?e:P(t,n++,e.value)}))},e}(G);function nt(){return et||(et=new $([]))}function it(t){var e=ut(t);if(e)return e.fromEntrySeq();if("object"==typeof t)return new tt(t);throw new TypeError("Expected Array or collection object of [k, v] entries, or keyed object: "+t)}function ot(t){var e=ut(t);if(e)return e;throw new TypeError("Expected Array or collection object of values: "+t)}function ut(t){return Q(t)?new $(t):N(t)?new rt(t):void 0}var st="@@__IMMUTABLE_MAP__@@";function at(t){return Boolean(t&&t[st])}function ct(t){return at(t)&&k(t)}function ft(t){return Boolean(t&&"function"==typeof t.equals&&"function"==typeof t.hashCode)}function ht(t,e){if(t===e||t!=t&&e!=e)return!0;if(!t||!e)return!1;if("function"==typeof t.valueOf&&"function"==typeof e.valueOf){if((t=t.valueOf())===(e=e.valueOf())||t!=t&&e!=e)return!0;if(!t||!e)return!1}return!!(ft(t)&&ft(e)&&t.equals(e))}var pt="function"==typeof Math.imul&&-2===Math.imul(4294967295,2)?Math.imul:function(t,e){var r=65535&(t|=0),n=65535&(e|=0);return r*n+((t>>>16)*n+r*(e>>>16)<<16>>>0)|0};function _t(t){return t>>>1&1073741824|3221225471&t}var lt=Object.prototype.valueOf;function vt(t){if(null==t)return yt(t);if("function"==typeof t.hashCode)return _t(t.hashCode(t));var e,r=(e=t).valueOf!==lt&&"function"==typeof e.valueOf?e.valueOf(e):e;if(null==r)return yt(r);switch(typeof r){case"boolean":return r?1108378657:1108378656;case"number":return function(t){if(t!=t||t===1/0)return 0;var e=0|t;e!==t&&(e^=4294967295*t);for(;t>4294967295;)e^=t/=4294967295;return _t(e)}(r);case"string":return r.length>Et?function(t){var e=Mt[t];void 0===e&&(e=dt(t),qt===jt&&(qt=0,Mt={}),qt++,Mt[t]=e);return e}(r):dt(r);case"object":case"function":return function(t){var e;if(zt&&void 0!==(e=bt.get(t)))return e;if(e=t[Ot],void 0!==e)return e;if(!wt){if(void 0!==(e=t.propertyIsEnumerable&&t.propertyIsEnumerable[Ot]))return e;if(void 0!==(e=function(t){if(t&&t.nodeType>0)switch(t.nodeType){case 1:return t.uniqueID;case 9:return t.documentElement&&t.documentElement.uniqueID}}(t)))return e}if(e=mt(),zt)bt.set(t,e);else{if(void 0!==gt&&!1===gt(t))throw new Error("Non-extensible objects are not allowed as keys.");if(wt)Object.defineProperty(t,Ot,{enumerable:!1,configurable:!1,writable:!1,value:e});else if(void 0!==t.propertyIsEnumerable&&t.propertyIsEnumerable===t.constructor.prototype.propertyIsEnumerable)t.propertyIsEnumerable=function(){return this.constructor.prototype.propertyIsEnumerable.apply(this,arguments)},t.propertyIsEnumerable[Ot]=e;else{if(void 0===t.nodeType)throw new Error("Unable to set a non-enumerable property on object.");t[Ot]=e}}return e}(r);case"symbol":return function(t){var e=St[t];if(void 0!==e)return e;return e=mt(),St[t]=e,e}(r);default:if("function"==typeof r.toString)return dt(r.toString());throw new Error("Value type "+typeof r+" cannot be hashed.")}}function yt(t){return null===t?1108378658:1108378659}function dt(t){for(var e=0,r=0;r=0&&(a.get=function(e,r){return(e=c(this,e))>=0&&eo)return{value:void 0,done:!0};var t=i.next();return n||e===U||t.done?t:P(e,a-1,e===R?void 0:t.value[1],t)}))},a}function Lt(t,e,r,n){var i=Xt(t);return i.__iterateUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterate(i,o);var s=!0,a=0;return t.__iterate((function(t,o,c){if(!s||!(s=e.call(r,t,o,c)))return a++,i(t,n?o:a-1,u)})),a},i.__iteratorUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterator(i,o);var s=t.__iterator(T,o),a=!0,c=0;return new C((function(){var t,o,f;do{if((t=s.next()).done)return n||i===U?t:P(i,c++,i===R?void 0:t.value[1],t);var h=t.value;o=h[0],f=h[1],a&&(a=e.call(r,f,o,u))}while(a);return i===T?t:P(i,o,f,t)}))},i}xt.prototype.cacheResult=Dt.prototype.cacheResult=At.prototype.cacheResult=kt.prototype.cacheResult=Ft;var Ct=function(t){function e(t){this._wrappedIterables=t.flatMap((function(t){return t._wrappedIterables?t._wrappedIterables:[t]})),this.size=this._wrappedIterables.reduce((function(t,e){if(void 0!==t){var r=e.size;if(void 0!==r)return t+r}}),0),this[g]=this._wrappedIterables[0][g],this[m]=this._wrappedIterables[0][m],this[A]=this._wrappedIterables[0][A]}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.__iterateUncached=function(t,e){if(0!==this._wrappedIterables.length){if(e)return this.cacheResult().__iterate(t,e);for(var r=0,n=w(this),i=n?T:U,o=this._wrappedIterables[r].__iterator(i,e),u=!0,s=0;u;){for(var a=o.next();a.done;){if(++r===this._wrappedIterables.length)return s;a=(o=this._wrappedIterables[r].__iterator(i,e)).next()}u=!1!==(n?t(a.value[1],a.value[0],this):t(a.value,s,this)),s++}return s}},e.prototype.__iteratorUncached=function(t,e){var r=this;if(0===this._wrappedIterables.length)return new C(W);if(e)return this.cacheResult().__iterator(t,e);var n=0,i=this._wrappedIterables[n].__iterator(t,e);return new C((function(){for(var o=i.next();o.done;){if(++n===r._wrappedIterables.length)return o;o=(i=r._wrappedIterables[n].__iterator(t,e)).next()}return o}))},e}(X);function Pt(t,e,r){var n=Xt(t);return n.__iterateUncached=function(i,o){if(o)return this.cacheResult().__iterate(i,o);var u=0,s=!1;return function t(a,c){a.__iterate((function(o,a){return(!e||c0}function Jt(t,e,r,n){var i=Xt(t),o=new $(r).map((function(t){return t.size}));return i.size=n?o.max():o.min(),i.__iterate=function(t,e){for(var r,n=this.__iterator(U,e),i=0;!(r=n.next()).done&&!1!==t(r.value,i++,this););return i},i.__iteratorUncached=function(t,i){var o=r.map((function(t){return t=S(t),J(i?t.reverse():t)})),u=0,s=!1;return new C((function(){var r;return s||(r=o.map((function(t){return t.next()})),s=n?r.every((function(t){return t.done})):r.some((function(t){return t.done}))),s?{value:void 0,done:!0}:P(t,u++,e.apply(null,r.map((function(t){return t.value}))))}))},i}function Vt(t,e){return t===e?t:q(t)?e:t.constructor(e)}function Yt(t){if(t!==Object(t))throw new TypeError("Expected [K, V] tuple: "+t)}function Qt(t){return w(t)?I:b(t)?O:E}function Xt(t){return Object.create((w(t)?F:b(t)?G:Z).prototype)}function Ft(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size,this):X.prototype.cacheResult.call(this)}function Gt(t,e){return void 0===t&&void 0===e?0:void 0===t?1:void 0===e?-1:t>e?1:t0;)e[r]=arguments[r+1];if("function"!=typeof t)throw new TypeError("Invalid merger function: "+t);return ze(this,e,t)}function ze(t,e,r){for(var n=[],i=0;i0;)e[r]=arguments[r+1];return Se(this,e,t)}function je(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return he(this,t,Je(),(function(t){return Ie(t,e)}))}function qe(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return he(this,t,Je(),(function(t){return Se(t,e)}))}function Me(t){var e=this.asMutable();return t(e),e.wasAltered()?e.__ensureOwner(this.__ownerID):this}function De(){return this.__ownerID?this:this.__ensureOwner(new s)}function xe(){return this.__ensureOwner()}function Ae(){return this.__altered}var ke=function(t){function e(e){return null==e?Je():at(e)&&!k(e)?e:Je().withMutations((function(r){var n=t(e);te(n.size),n.forEach((function(t,e){return r.set(e,t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toString=function(){return this.__toString("Map {","}")},e.prototype.get=function(t,e){return this._root?this._root.get(0,void 0,t,e):e},e.prototype.set=function(t,e){return Ve(this,t,e)},e.prototype.remove=function(t){return Ve(this,t,o)},e.prototype.deleteAll=function(t){var e=S(t);return 0===e.size?this:this.withMutations((function(t){e.forEach((function(e){return t.remove(e)}))}))},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):Je()},e.prototype.sort=function(t){return yr(Wt(this,t))},e.prototype.sortBy=function(t,e){return yr(Wt(this,e,t))},e.prototype.map=function(t,e){var r=this;return this.withMutations((function(n){n.forEach((function(i,o){n.set(o,t.call(e,i,o,r))}))}))},e.prototype.__iterator=function(t,e){return new Pe(this,t,e)},e.prototype.__iterate=function(t,e){var r=this,n=0;return this._root&&this._root.iterate((function(e){return n++,t(e[1],e[0],r)}),e),n},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?He(this.size,this._root,t,this.__hash):0===this.size?Je():(this.__ownerID=t,this.__altered=!1,this)},e}(I);ke.isMap=at;var Re=ke.prototype;Re[st]=!0,Re[e]=Re.remove,Re.removeAll=Re.deleteAll,Re.setIn=le,Re.removeIn=Re.deleteIn=ye,Re.update=ge,Re.updateIn=we,Re.merge=Re.concat=me,Re.mergeWith=be,Re.mergeDeep=Oe,Re.mergeDeepWith=Ee,Re.mergeIn=je,Re.mergeDeepIn=qe,Re.withMutations=Me,Re.wasAltered=Ae,Re.asImmutable=xe,Re["@@transducer/init"]=Re.asMutable=De,Re["@@transducer/step"]=function(t,e){return t.set(e[0],e[1])},Re["@@transducer/result"]=function(t){return t.asImmutable()};var Ue=function(t,e){this.ownerID=t,this.entries=e};Ue.prototype.get=function(t,e,r,n){for(var i=this.entries,o=0,u=i.length;o=Ze)return function(t,e,r,n){t||(t=new s);for(var i=new Le(t,vt(r),[r,n]),o=0;o>>t)&i),s=this.bitmap;return 0==(s&u)?o:this.nodes[Fe(s&u-1)].get(t+r,e,n,o)},Te.prototype.update=function(t,e,u,s,a,c,f){void 0===u&&(u=vt(s));var h=(0===e?u:u>>>e)&i,p=1<=$e)return function(t,e,r,i,o){for(var u=0,s=new Array(n),a=0;0!==r;a++,r>>>=1)s[a]=1&r?e[u++]:void 0;return s[i]=o,new Be(t,u+1,s)}(t,y,_,h,g);if(l&&!g&&2===y.length&&Qe(y[1^v]))return y[1^v];if(l&&g&&1===y.length&&Qe(g))return g;var w=t&&t===this.ownerID,m=l?g?_:_^p:_|p,b=l?g?Ge(y,v,g,w):function(t,e,r){var n=t.length-1;if(r&&e===n)return t.pop(),t;for(var i=new Array(n),o=0,u=0;u>>t)&i,s=this.nodes[u];return s?s.get(t+r,e,n,o):o},Be.prototype.update=function(t,e,n,u,s,a,c){void 0===n&&(n=vt(u));var f=(0===e?n:n>>>e)&i,h=s===o,p=this.nodes,_=p[f];if(h&&!_)return this;var l=Ye(_,t,e+r,n,u,s,a,c);if(l===_)return this;var v=this.count;if(_){if(!l&&--v>>n)&i,c=(0===n?o:o>>>n)&i,f=a===c?[Xe(t,e,n+r,o,u)]:(s=new Le(e,o,u),a>1&1431655765))+(t>>2&858993459))+(t>>4)&252645135,t+=t>>8,127&(t+=t>>16)}function Ge(t,e,r,n){var i=n?t:Zt(t);return i[e]=r,i}var Ze=n/4,$e=n/2,tr=n/4,er="@@__IMMUTABLE_LIST__@@";function rr(t){return Boolean(t&&t[er])}var nr=function(t){function e(e){var i=cr();if(null==e)return i;if(rr(e))return e;var o=t(e),u=o.size;return 0===u?i:(te(u),u>0&&u=0&&t=t.size||e<0)return t.withMutations((function(t){e<0?_r(t,e).set(0,r):_r(t,0,e+1).set(e,r)}));e+=t._origin;var n=t._tail,i=t._root,o={value:!1};e>=lr(t._capacity)?n=fr(n,t.__ownerID,0,e,r,o):i=fr(i,t.__ownerID,t._level,e,r,o);if(!o.value)return t;if(t.__ownerID)return t._root=i,t._tail=n,t.__hash=void 0,t.__altered=!0,t;return ar(t._origin,t._capacity,t._level,i,n)}(this,t,e)},e.prototype.remove=function(t){return this.has(t)?0===t?this.shift():t===this.size-1?this.pop():this.splice(t,1):this},e.prototype.insert=function(t,e){return this.splice(t,0,e)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=this._origin=this._capacity=0,this._level=r,this._root=this._tail=this.__hash=void 0,this.__altered=!0,this):cr()},e.prototype.push=function(){var t=arguments,e=this.size;return this.withMutations((function(r){_r(r,0,e+t.length);for(var n=0;n>>e&i;if(o>=this.array.length)return new or([],t);var u,s=0===o;if(e>0){var a=this.array[o];if((u=a&&a.removeBefore(t,e-r,n))===a&&s)return this}if(s&&!u)return this;var c=hr(this,t);if(!s)for(var f=0;f>>e&i;if(s>=this.array.length)return this;if(e>0){var a=this.array[s];if((u=a&&a.removeAfter(t,e-r,o))===a&&s===this.array.length-1)return this}var c=hr(this,t);return c.array.splice(s+1),u&&(c.array[s]=u),c};var ur={};function sr(t,e){var i=t._origin,o=t._capacity,u=lr(o),s=t._tail;return a(t._root,t._level,0);function a(t,c,f){return 0===c?function(t,r){var a=r===u?s&&s.array:t&&t.array,c=r>i?0:i-r,f=o-r;f>n&&(f=n);return function(){if(c===f)return ur;var t=e?--f:c++;return a&&a[t]}}(t,f):function(t,u,s){var c,f=t&&t.array,h=s>i?0:i-s>>u,p=1+(o-s>>u);p>n&&(p=n);return function(){for(;;){if(c){var t=c();if(t!==ur)return t;c=null}if(h===p)return ur;var n=e?--p:h++;c=a(f&&f[n],u-r,s+(n<>>n&i,h=t&&f0){var p=t&&t.array[f],_=fr(p,e,n-r,o,s,a);return _===p?t:((c=hr(t,e)).array[f]=_,c)}return h&&t.array[f]===s?t:(a&&u(a),c=hr(t,e),void 0===s&&f===c.array.length-1?c.array.pop():c.array[f]=s,c)}function hr(t,e){return e&&t&&e===t.ownerID?t:new or(t?t.array.slice():[],e)}function pr(t,e){if(e>=lr(t._capacity))return t._tail;if(e<1<0;)n=n.array[e>>>o&i],o-=r;return n}}function _r(t,e,n){void 0!==e&&(e|=0),void 0!==n&&(n|=0);var o=t.__ownerID||new s,u=t._origin,a=t._capacity,c=u+e,f=void 0===n?a:n<0?a+n:u+n;if(c===u&&f===a)return t;if(c>=f)return t.clear();for(var h=t._level,p=t._root,_=0;c+_<0;)p=new or(p&&p.array.length?[void 0,p]:[],o),_+=1<<(h+=r);_&&(c+=_,u+=_,f+=_,a+=_);for(var l=lr(a),v=lr(f);v>=1<l?new or([],o):y;if(y&&v>l&&cr;w-=r){var m=l>>>w&i;g=g.array[m]=hr(g.array[m],o)}g.array[l>>>r&i]=y}if(f=v)c-=v,f-=v,h=r,p=null,d=d&&d.removeBefore(o,0,c);else if(c>u||v>>h&i;if(b!==v>>>h&i)break;b&&(_+=(1<u&&(p=p.removeBefore(o,h,c-_)),p&&v>>r<=n&&a.size>=2*s.size?(i=(u=a.filter((function(t,e){return void 0!==t&&c!==e}))).toKeyedSeq().map((function(t){return t[0]})).flip().toMap(),t.__ownerID&&(i.__ownerID=u.__ownerID=t.__ownerID)):(i=s.remove(e),u=c===a.size-1?a.pop():a.set(c,void 0))}else if(f){if(r===a.get(c)[1])return t;i=s,u=a.set(c,[e,r])}else i=s.set(e,a.size),u=a.set(a.size,[e,r]);return t.__ownerID?(t.size=i.size,t._map=i,t._list=u,t.__hash=void 0,t.__altered=!0,t):dr(i,u)}yr.isOrderedMap=ct,yr.prototype[A]=!0,yr.prototype[e]=yr.prototype.remove;var mr="@@__IMMUTABLE_STACK__@@";function br(t){return Boolean(t&&t[mr])}var zr=function(t){function e(t){return null==t?Er():br(t)?t:Er().pushAll(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("Stack [","]")},e.prototype.get=function(t,e){var r=this._head;for(t=c(this,t);r&&t--;)r=r.next;return r?r.value:e},e.prototype.peek=function(){return this._head&&this._head.value},e.prototype.push=function(){var t=arguments;if(0===arguments.length)return this;for(var e=this.size+arguments.length,r=this._head,n=arguments.length-1;n>=0;n--)r={value:t[n],next:r};return this.__ownerID?(this.size=e,this._head=r,this.__hash=void 0,this.__altered=!0,this):Or(e,r)},e.prototype.pushAll=function(e){if(0===(e=t(e)).size)return this;if(0===this.size&&br(e))return e;te(e.size);var r=this.size,n=this._head;return e.__iterate((function(t){r++,n={value:t,next:n}}),!0),this.__ownerID?(this.size=r,this._head=n,this.__hash=void 0,this.__altered=!0,this):Or(r,n)},e.prototype.pop=function(){return this.slice(1)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):Er()},e.prototype.slice=function(e,r){if(h(e,r,this.size))return this;var n=p(e,this.size);if(_(r,this.size)!==this.size)return t.prototype.slice.call(this,e,r);for(var i=this.size-n,o=this._head;n--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):Or(i,o)},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Or(this.size,this._head,t,this.__hash):0===this.size?Er():(this.__ownerID=t,this.__altered=!1,this)},e.prototype.__iterate=function(t,e){var r=this;if(e)return new $(this.toArray()).__iterate((function(e,n){return t(e,n,r)}),e);for(var n=0,i=this._head;i&&!1!==t(i.value,n++,this);)i=i.next;return n},e.prototype.__iterator=function(t,e){if(e)return new $(this.toArray()).__iterator(t,e);var r=0,n=this._head;return new C((function(){if(n){var e=n.value;return n=n.next,P(t,r++,e)}return{value:void 0,done:!0}}))},e}(O);zr.isStack=br;var Sr,Ir=zr.prototype;function Or(t,e,r,n){var i=Object.create(Ir);return i.size=t,i._head=e,i.__ownerID=r,i.__hash=n,i.__altered=!1,i}function Er(){return Sr||(Sr=Or(0))}Ir[mr]=!0,Ir.shift=Ir.pop,Ir.unshift=Ir.push,Ir.unshiftAll=Ir.pushAll,Ir.withMutations=Me,Ir.wasAltered=Ae,Ir.asImmutable=xe,Ir["@@transducer/init"]=Ir.asMutable=De,Ir["@@transducer/step"]=function(t,e){return t.unshift(e)},Ir["@@transducer/result"]=function(t){return t.asImmutable()};var jr="@@__IMMUTABLE_SET__@@";function qr(t){return Boolean(t&&t[jr])}function Mr(t){return qr(t)&&k(t)}function Dr(t,e){if(t===e)return!0;if(!d(e)||void 0!==t.size&&void 0!==e.size&&t.size!==e.size||void 0!==t.__hash&&void 0!==e.__hash&&t.__hash!==e.__hash||w(t)!==w(e)||b(t)!==b(e)||k(t)!==k(e))return!1;if(0===t.size&&0===e.size)return!0;var r=!z(t);if(k(t)){var n=t.entries();return e.every((function(t,e){var i=n.next().value;return i&&ht(i[1],t)&&(r||ht(i[0],e))}))&&n.next().done}var i=!1;if(void 0===t.size)if(void 0===e.size)"function"==typeof t.cacheResult&&t.cacheResult();else{i=!0;var u=t;t=e,e=u}var s=!0,a=e.__iterate((function(e,n){if(r?!t.has(e):i?!ht(e,t.get(n,o)):!ht(t.get(n,o),e))return s=!1,!1}));return s&&t.size===a}function xr(t,e){var r=function(r){t.prototype[r]=e[r]};return Object.keys(e).forEach(r),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(e).forEach(r),t}function Ar(t){if(!t||"object"!=typeof t)return t;if(!d(t)){if(!ie(t))return t;t=X(t)}if(w(t)){var e={};return t.__iterate((function(t,r){e[r]=Ar(t)})),e}var r=[];return t.__iterate((function(t){r.push(Ar(t))})),r}var kr=function(t){function e(e){return null==e?Kr():qr(e)&&!k(e)?e:Kr().withMutations((function(r){var n=t(e);te(n.size),n.forEach((function(t){return r.add(t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(I(t).keySeq())},e.intersect=function(t){return(t=S(t).toArray()).length?Ur.intersect.apply(e(t.pop()),t):Kr()},e.union=function(t){return(t=S(t).toArray()).length?Ur.union.apply(e(t.pop()),t):Kr()},e.prototype.toString=function(){return this.__toString("Set {","}")},e.prototype.has=function(t){return this._map.has(t)},e.prototype.add=function(t){return Tr(this,this._map.set(t,t))},e.prototype.remove=function(t){return Tr(this,this._map.remove(t))},e.prototype.clear=function(){return Tr(this,this._map.clear())},e.prototype.map=function(t,e){var r=this,n=!1,i=Tr(this,this._map.mapEntries((function(i){var o=i[1],u=t.call(e,o,o,r);return u!==o&&(n=!0),[u,u]}),e));return n?i:this},e.prototype.union=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return 0===(e=e.filter((function(t){return 0!==t.size}))).length?this:0!==this.size||this.__ownerID||1!==e.length?this.withMutations((function(r){for(var n=0;n=0&&e=0&&r>>-15,461845907),e=pt(e<<13|e>>>-13,5),e=pt((e=(e+3864292196|0)^t)^e>>>16,2246822507),e=_t((e=pt(e^e>>>13,3266489909))^e>>>16)}(t.size,n)}(this))}});var Jr=S.prototype;Jr[y]=!0,Jr[L]=Jr.values,Jr.toJSON=Jr.toArray,Jr.__toStringMapper=oe,Jr.inspect=Jr.toSource=function(){return this.toString()},Jr.chain=Jr.flatMap,Jr.contains=Jr.includes,xr(I,{flip:function(){return Vt(this,Rt(this))},mapEntries:function(t,e){var r=this,n=0;return Vt(this,this.toSeq().map((function(i,o){return t.call(e,[o,i],n++,r)})).fromEntrySeq())},mapKeys:function(t,e){var r=this;return Vt(this,this.toSeq().flip().map((function(n,i){return t.call(e,n,i,r)})).flip())}});var Vr=I.prototype;Vr[g]=!0,Vr[L]=Jr.entries,Vr.toJSON=Hr,Vr.__toStringMapper=function(t,e){return oe(e)+": "+oe(t)},xr(O,{toKeyedSeq:function(){return new Dt(this,!1)},filter:function(t,e){return Vt(this,Bt(this,t,e,!1))},findIndex:function(t,e){var r=this.findEntry(t,e);return r?r[0]:-1},indexOf:function(t){var e=this.keyOf(t);return void 0===e?-1:e},lastIndexOf:function(t){var e=this.lastKeyOf(t);return void 0===e?-1:e},reverse:function(){return Vt(this,Tt(this,!1))},slice:function(t,e){return Vt(this,Kt(this,t,e,!1))},splice:function(t,e){var r=arguments.length;if(e=Math.max(e||0,0),0===r||2===r&&!e)return this;t=p(t,t<0?this.count():this.size);var n=this.slice(0,t);return Vt(this,1===r?n:n.concat(Zt(arguments,2),this.slice(t+e)))},findLastIndex:function(t,e){var r=this.findLastEntry(t,e);return r?r[0]:-1},first:function(t){return this.get(0,t)},flatten:function(t){return Vt(this,Pt(this,t,!1))},get:function(t,e){return(t=c(this,t))<0||this.size===1/0||void 0!==this.size&&t>this.size?e:this.find((function(e,r){return r===t}),void 0,e)},has:function(t){return(t=c(this,t))>=0&&(void 0!==this.size?this.size===1/0||te?-1:0}function rn(t,e){return t^e+2654435769+(t<<6)+(t>>2)|0}Qr.has=Jr.includes,Qr.contains=Qr.includes,Qr.keys=Qr.values,xr(F,Vr),xr(G,Yr),xr(Z,Qr);var nn=function(t){function e(t){return null==t?an():Mr(t)?t:an().withMutations((function(e){var r=E(t);te(r.size),r.forEach((function(t){return e.add(t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(I(t).keySeq())},e.prototype.toString=function(){return this.__toString("OrderedSet {","}")},e}(kr);nn.isOrderedSet=Mr;var on,un=nn.prototype;function sn(t,e){var r=Object.create(un);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function an(){return on||(on=sn(gr()))}un[A]=!0,un.zip=Yr.zip,un.zipWith=Yr.zipWith,un.zipAll=Yr.zipAll,un.__empty=an,un.__make=sn;var cn=function(t,e){var r;!function(t){if(D(t))throw new Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(x(t))throw new Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(null===t||"object"!=typeof t)throw new Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}(t);var n=function(o){var u=this;if(o instanceof n)return o;if(!(this instanceof n))return new n(o);if(!r){r=!0;var s=Object.keys(t),a=i._indices={};i._name=e,i._keys=s,i._defaultValues=t;for(var c=0;c2?[]:void 0,{"":t})},t.get=se,t.getIn=Pr,t.has=ue,t.hasIn=Nr,t.hash=vt,t.is=ht,t.isAssociative=z,t.isCollection=d,t.isImmutable=x,t.isIndexed=b,t.isKeyed=w,t.isList=rr,t.isMap=at,t.isOrdered=k,t.isOrderedMap=ct,t.isOrderedSet=Mr,t.isPlainObject=ne,t.isRecord=D,t.isSeq=q,t.isSet=qr,t.isStack=br,t.isValueObject=ft,t.merge=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Ie(t,e)},t.mergeDeep=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Se(t,e)},t.mergeDeepWith=function(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];return Se(e,r,t)},t.mergeWith=function(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];return Ie(e,r,t)},t.remove=ce,t.removeIn=ve,t.set=fe,t.setIn=_e,t.update=de,t.updateIn=he,t.version="5.0.3"})); From b2d633e5e9027984b77280b1ae045431bca2085e Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sat, 22 Mar 2025 21:41:54 +0000 Subject: [PATCH 236/242] deploy: 70826e6436a81d4a2344439af0fab57c3db50b50 --- dist/immutable.es.js | 271 ++++++++++++++++++++++++++----------------- dist/immutable.js | 271 ++++++++++++++++++++++++++----------------- 2 files changed, 328 insertions(+), 214 deletions(-) diff --git a/dist/immutable.es.js b/dist/immutable.es.js index 71f359a42a..4e31a8d419 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -2197,11 +2197,29 @@ function quoteString(value) { } } +/** + * Returns true if the key is defined in the provided collection. + * + * A functional alternative to `collection.has(key)` which will also work with + * plain Objects and Arrays as an alternative for + * `collection.hasOwnProperty(key)`. + * + * + * ```js + * import { has } from 'immutable'; + * + * has([ 'dog', 'frog', 'cat' ], 2) // true + * has([ 'dog', 'frog', 'cat' ], 5) // false + * has({ x: 123, y: 456 }, 'x') // true + * has({ x: 123, y: 456 }, 'z') // false + * ``` + */ function has(collection, key) { return isImmutable(collection) ? // @ts-expect-error key might be a number or symbol, which is not handled be Record key type collection.has(key) - : isDataStructure(collection) && hasOwnProperty.call(collection, key); + : // @ts-expect-error key might be anything else than PropertyKey, and will return false in that case but runtime is OK + isDataStructure(collection) && hasOwnProperty.call(collection, key); } function get(collection, key, notSetValue) { @@ -2231,129 +2249,137 @@ function shallowCopy(from) { } function remove(collection, key) { - if (!isDataStructure(collection)) { - throw new TypeError( - 'Cannot update non-data-structure value: ' + collection - ); - } - if (isImmutable(collection)) { - if (!collection.remove) { - throw new TypeError( - 'Cannot update immutable value without .remove() method: ' + collection - ); + if (!isDataStructure(collection)) { + throw new TypeError('Cannot update non-data-structure value: ' + collection); } - return collection.remove(key); - } - if (!hasOwnProperty.call(collection, key)) { - return collection; - } - var collectionCopy = shallowCopy(collection); - if (Array.isArray(collectionCopy)) { - collectionCopy.splice(key, 1); - } else { - delete collectionCopy[key]; - } - return collectionCopy; + if (isImmutable(collection)) { + // @ts-expect-error weird "remove" here, + if (!collection.remove) { + throw new TypeError('Cannot update immutable value without .remove() method: ' + collection); + } + // @ts-expect-error weird "remove" here, + return collection.remove(key); + } + if (!hasOwnProperty.call(collection, key)) { + return collection; + } + var collectionCopy = shallowCopy(collection); + if (Array.isArray(collectionCopy)) { + // @ts-expect-error assert that key is a number here + collectionCopy.splice(key, 1); + } + else { + delete collectionCopy[key]; + } + return collectionCopy; } function set(collection, key, value) { - if (!isDataStructure(collection)) { - throw new TypeError( - 'Cannot update non-data-structure value: ' + collection - ); - } - if (isImmutable(collection)) { - if (!collection.set) { - throw new TypeError( - 'Cannot update immutable value without .set() method: ' + collection - ); + if (!isDataStructure(collection)) { + throw new TypeError('Cannot update non-data-structure value: ' + collection); } - return collection.set(key, value); - } - if (hasOwnProperty.call(collection, key) && value === collection[key]) { - return collection; - } - var collectionCopy = shallowCopy(collection); - collectionCopy[key] = value; - return collectionCopy; + if (isImmutable(collection)) { + // @ts-expect-error weird "set" here, + if (!collection.set) { + throw new TypeError('Cannot update immutable value without .set() method: ' + collection); + } + // @ts-expect-error weird "set" here, + return collection.set(key, value); + } + // @ts-expect-error mix of key and string here. Probably need a more fine type here + if (hasOwnProperty.call(collection, key) && value === collection[key]) { + return collection; + } + var collectionCopy = shallowCopy(collection); + // @ts-expect-error mix of key and string here. Probably need a more fine type here + collectionCopy[key] = value; + return collectionCopy; } function updateIn$1(collection, keyPath, notSetValue, updater) { - if (!updater) { - updater = notSetValue; - notSetValue = undefined; - } - var updatedValue = updateInDeeply( - isImmutable(collection), - collection, - coerceKeyPath(keyPath), - 0, - notSetValue, - updater - ); - return updatedValue === NOT_SET ? notSetValue : updatedValue; -} - -function updateInDeeply( - inImmutable, - existing, - keyPath, - i, - notSetValue, - updater -) { - var wasNotSet = existing === NOT_SET; - if (i === keyPath.length) { - var existingValue = wasNotSet ? notSetValue : existing; - var newValue = updater(existingValue); - return newValue === existingValue ? existing : newValue; - } - if (!wasNotSet && !isDataStructure(existing)) { - throw new TypeError( - 'Cannot update within non-data-structure value in path [' + - Array.from(keyPath).slice(0, i).map(quoteString) + - ']: ' + - existing - ); - } - var key = keyPath[i]; - - if (typeof key === 'undefined') { - throw new TypeError( - 'Index can not be undefined in updateIn(). This should not happen' - ); - } - - var nextExisting = wasNotSet ? NOT_SET : get(existing, key, NOT_SET); - var nextUpdated = updateInDeeply( - nextExisting === NOT_SET ? inImmutable : isImmutable(nextExisting), - nextExisting, - keyPath, - i + 1, - notSetValue, - updater - ); - return nextUpdated === nextExisting - ? existing - : nextUpdated === NOT_SET - ? remove(existing, key) - : set( - wasNotSet ? (inImmutable ? emptyMap() : {}) : existing, - key, - nextUpdated - ); + if (!updater) { + // handle the fact that `notSetValue` is optional here, in that case `updater` is the updater function + // @ts-expect-error updater is a function here + updater = notSetValue; + notSetValue = undefined; + } + var updatedValue = updateInDeeply(isImmutable(collection), + // @ts-expect-error type issues with Record and mixed types + collection, coerceKeyPath(keyPath), 0, notSetValue, updater); + // @ts-expect-error mixed return type + return updatedValue === NOT_SET ? notSetValue : updatedValue; +} +function updateInDeeply(inImmutable, existing, keyPath, i, notSetValue, updater) { + var wasNotSet = existing === NOT_SET; + if (i === keyPath.length) { + var existingValue = wasNotSet ? notSetValue : existing; + // @ts-expect-error mixed type with optional value + var newValue = updater(existingValue); + // @ts-expect-error mixed type + return newValue === existingValue ? existing : newValue; + } + if (!wasNotSet && !isDataStructure(existing)) { + throw new TypeError('Cannot update within non-data-structure value in path [' + + Array.from(keyPath).slice(0, i).map(quoteString) + + ']: ' + + existing); + } + var key = keyPath[i]; + if (typeof key === 'undefined') { + throw new TypeError('Index can not be undefined in updateIn(). This should not happen'); + } + var nextExisting = wasNotSet ? NOT_SET : get(existing, key, NOT_SET); + var nextUpdated = updateInDeeply(nextExisting === NOT_SET ? inImmutable : isImmutable(nextExisting), + // @ts-expect-error mixed type + nextExisting, keyPath, i + 1, notSetValue, updater); + return nextUpdated === nextExisting + ? existing + : nextUpdated === NOT_SET + ? remove(existing, key) + : set(wasNotSet ? (inImmutable ? emptyMap() : {}) : existing, key, nextUpdated); } +/** + * Returns a copy of the collection with the value at the key path set to the + * provided value. + * + * A functional alternative to `collection.setIn(keypath)` which will also + * work with plain Objects and Arrays. + * + * + * ```js + * import { setIn } from 'immutable'; + * + * const original = { x: { y: { z: 123 }}} + * setIn(original, ['x', 'y', 'z'], 456) // { x: { y: { z: 456 }}} + * console.log(original) // { x: { y: { z: 123 }}} + * ``` + */ function setIn$1(collection, keyPath, value) { - return updateIn$1(collection, keyPath, NOT_SET, function () { return value; }); + return updateIn$1(collection, keyPath, NOT_SET, function () { return value; }); } function setIn(keyPath, v) { return setIn$1(this, keyPath, v); } +/** + * Returns a copy of the collection with the value at the key path removed. + * + * A functional alternative to `collection.removeIn(keypath)` which will also + * work with plain Objects and Arrays. + * + * + * ```js + * import { removeIn } from 'immutable'; + * + * const original = { x: { y: { z: 123 }}} + * removeIn(original, ['x', 'y', 'z']) // { x: { y: {}}} + * console.log(original) // { x: { y: { z: 123 }}} + * ``` + */ function removeIn(collection, keyPath) { - return updateIn$1(collection, keyPath, function () { return NOT_SET; }); + return updateIn$1(collection, keyPath, function () { return NOT_SET; }); } function deleteIn(keyPath) { @@ -2361,7 +2387,9 @@ function deleteIn(keyPath) { } function update$1(collection, key, notSetValue, updater) { - return updateIn$1(collection, [key], notSetValue, updater); + return updateIn$1( + // @ts-expect-error Index signature for type string is missing in type V[] + collection, [key], notSetValue, updater); } function update(key, notSetValue, updater) { @@ -4957,6 +4985,21 @@ var Range = /*@__PURE__*/(function (IndexedSeq) { var EMPTY_RANGE; +/** + * Returns the value at the provided key path starting at the provided + * collection, or notSetValue if the key path is not defined. + * + * A functional alternative to `collection.getIn(keypath)` which will also + * work with plain Objects and Arrays. + * + * + * ```js + * import { getIn } from 'immutable'; + * + * getIn({ x: { y: { z: 123 }}}, ['x', 'y', 'z']) // 123 + * getIn({ x: { y: { z: 123 }}}, ['x', 'q', 'p'], 'ifNotSet') // 'ifNotSet' + * ``` + */ function getIn$1(collection, searchKeyPath, notSetValue) { var keyPath = coerceKeyPath(searchKeyPath); var i = 0; @@ -4974,6 +5017,20 @@ function getIn(searchKeyPath, notSetValue) { return getIn$1(this, searchKeyPath, notSetValue); } +/** + * Returns true if the key path is defined in the provided collection. + * + * A functional alternative to `collection.hasIn(keypath)` which will also + * work with plain Objects and Arrays. + * + * + * ```js + * import { hasIn } from 'immutable'; + * + * hasIn({ x: { y: { z: 123 }}}, ['x', 'y', 'z']) // true + * hasIn({ x: { y: { z: 123 }}}, ['x', 'q', 'p']) // false + * ``` + */ function hasIn$1(collection, keyPath) { return getIn$1(collection, keyPath, NOT_SET) !== NOT_SET; } diff --git a/dist/immutable.js b/dist/immutable.js index 2438f20298..9770900559 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -2203,11 +2203,29 @@ } } + /** + * Returns true if the key is defined in the provided collection. + * + * A functional alternative to `collection.has(key)` which will also work with + * plain Objects and Arrays as an alternative for + * `collection.hasOwnProperty(key)`. + * + * + * ```js + * import { has } from 'immutable'; + * + * has([ 'dog', 'frog', 'cat' ], 2) // true + * has([ 'dog', 'frog', 'cat' ], 5) // false + * has({ x: 123, y: 456 }, 'x') // true + * has({ x: 123, y: 456 }, 'z') // false + * ``` + */ function has(collection, key) { return isImmutable(collection) ? // @ts-expect-error key might be a number or symbol, which is not handled be Record key type collection.has(key) - : isDataStructure(collection) && hasOwnProperty.call(collection, key); + : // @ts-expect-error key might be anything else than PropertyKey, and will return false in that case but runtime is OK + isDataStructure(collection) && hasOwnProperty.call(collection, key); } function get(collection, key, notSetValue) { @@ -2237,129 +2255,137 @@ } function remove(collection, key) { - if (!isDataStructure(collection)) { - throw new TypeError( - 'Cannot update non-data-structure value: ' + collection - ); - } - if (isImmutable(collection)) { - if (!collection.remove) { - throw new TypeError( - 'Cannot update immutable value without .remove() method: ' + collection - ); + if (!isDataStructure(collection)) { + throw new TypeError('Cannot update non-data-structure value: ' + collection); } - return collection.remove(key); - } - if (!hasOwnProperty.call(collection, key)) { - return collection; - } - var collectionCopy = shallowCopy(collection); - if (Array.isArray(collectionCopy)) { - collectionCopy.splice(key, 1); - } else { - delete collectionCopy[key]; - } - return collectionCopy; + if (isImmutable(collection)) { + // @ts-expect-error weird "remove" here, + if (!collection.remove) { + throw new TypeError('Cannot update immutable value without .remove() method: ' + collection); + } + // @ts-expect-error weird "remove" here, + return collection.remove(key); + } + if (!hasOwnProperty.call(collection, key)) { + return collection; + } + var collectionCopy = shallowCopy(collection); + if (Array.isArray(collectionCopy)) { + // @ts-expect-error assert that key is a number here + collectionCopy.splice(key, 1); + } + else { + delete collectionCopy[key]; + } + return collectionCopy; } function set(collection, key, value) { - if (!isDataStructure(collection)) { - throw new TypeError( - 'Cannot update non-data-structure value: ' + collection - ); - } - if (isImmutable(collection)) { - if (!collection.set) { - throw new TypeError( - 'Cannot update immutable value without .set() method: ' + collection - ); + if (!isDataStructure(collection)) { + throw new TypeError('Cannot update non-data-structure value: ' + collection); } - return collection.set(key, value); - } - if (hasOwnProperty.call(collection, key) && value === collection[key]) { - return collection; - } - var collectionCopy = shallowCopy(collection); - collectionCopy[key] = value; - return collectionCopy; + if (isImmutable(collection)) { + // @ts-expect-error weird "set" here, + if (!collection.set) { + throw new TypeError('Cannot update immutable value without .set() method: ' + collection); + } + // @ts-expect-error weird "set" here, + return collection.set(key, value); + } + // @ts-expect-error mix of key and string here. Probably need a more fine type here + if (hasOwnProperty.call(collection, key) && value === collection[key]) { + return collection; + } + var collectionCopy = shallowCopy(collection); + // @ts-expect-error mix of key and string here. Probably need a more fine type here + collectionCopy[key] = value; + return collectionCopy; } function updateIn$1(collection, keyPath, notSetValue, updater) { - if (!updater) { - updater = notSetValue; - notSetValue = undefined; - } - var updatedValue = updateInDeeply( - isImmutable(collection), - collection, - coerceKeyPath(keyPath), - 0, - notSetValue, - updater - ); - return updatedValue === NOT_SET ? notSetValue : updatedValue; - } - - function updateInDeeply( - inImmutable, - existing, - keyPath, - i, - notSetValue, - updater - ) { - var wasNotSet = existing === NOT_SET; - if (i === keyPath.length) { - var existingValue = wasNotSet ? notSetValue : existing; - var newValue = updater(existingValue); - return newValue === existingValue ? existing : newValue; - } - if (!wasNotSet && !isDataStructure(existing)) { - throw new TypeError( - 'Cannot update within non-data-structure value in path [' + - Array.from(keyPath).slice(0, i).map(quoteString) + - ']: ' + - existing - ); - } - var key = keyPath[i]; - - if (typeof key === 'undefined') { - throw new TypeError( - 'Index can not be undefined in updateIn(). This should not happen' - ); - } - - var nextExisting = wasNotSet ? NOT_SET : get(existing, key, NOT_SET); - var nextUpdated = updateInDeeply( - nextExisting === NOT_SET ? inImmutable : isImmutable(nextExisting), - nextExisting, - keyPath, - i + 1, - notSetValue, - updater - ); - return nextUpdated === nextExisting - ? existing - : nextUpdated === NOT_SET - ? remove(existing, key) - : set( - wasNotSet ? (inImmutable ? emptyMap() : {}) : existing, - key, - nextUpdated - ); + if (!updater) { + // handle the fact that `notSetValue` is optional here, in that case `updater` is the updater function + // @ts-expect-error updater is a function here + updater = notSetValue; + notSetValue = undefined; + } + var updatedValue = updateInDeeply(isImmutable(collection), + // @ts-expect-error type issues with Record and mixed types + collection, coerceKeyPath(keyPath), 0, notSetValue, updater); + // @ts-expect-error mixed return type + return updatedValue === NOT_SET ? notSetValue : updatedValue; + } + function updateInDeeply(inImmutable, existing, keyPath, i, notSetValue, updater) { + var wasNotSet = existing === NOT_SET; + if (i === keyPath.length) { + var existingValue = wasNotSet ? notSetValue : existing; + // @ts-expect-error mixed type with optional value + var newValue = updater(existingValue); + // @ts-expect-error mixed type + return newValue === existingValue ? existing : newValue; + } + if (!wasNotSet && !isDataStructure(existing)) { + throw new TypeError('Cannot update within non-data-structure value in path [' + + Array.from(keyPath).slice(0, i).map(quoteString) + + ']: ' + + existing); + } + var key = keyPath[i]; + if (typeof key === 'undefined') { + throw new TypeError('Index can not be undefined in updateIn(). This should not happen'); + } + var nextExisting = wasNotSet ? NOT_SET : get(existing, key, NOT_SET); + var nextUpdated = updateInDeeply(nextExisting === NOT_SET ? inImmutable : isImmutable(nextExisting), + // @ts-expect-error mixed type + nextExisting, keyPath, i + 1, notSetValue, updater); + return nextUpdated === nextExisting + ? existing + : nextUpdated === NOT_SET + ? remove(existing, key) + : set(wasNotSet ? (inImmutable ? emptyMap() : {}) : existing, key, nextUpdated); } + /** + * Returns a copy of the collection with the value at the key path set to the + * provided value. + * + * A functional alternative to `collection.setIn(keypath)` which will also + * work with plain Objects and Arrays. + * + * + * ```js + * import { setIn } from 'immutable'; + * + * const original = { x: { y: { z: 123 }}} + * setIn(original, ['x', 'y', 'z'], 456) // { x: { y: { z: 456 }}} + * console.log(original) // { x: { y: { z: 123 }}} + * ``` + */ function setIn$1(collection, keyPath, value) { - return updateIn$1(collection, keyPath, NOT_SET, function () { return value; }); + return updateIn$1(collection, keyPath, NOT_SET, function () { return value; }); } function setIn(keyPath, v) { return setIn$1(this, keyPath, v); } + /** + * Returns a copy of the collection with the value at the key path removed. + * + * A functional alternative to `collection.removeIn(keypath)` which will also + * work with plain Objects and Arrays. + * + * + * ```js + * import { removeIn } from 'immutable'; + * + * const original = { x: { y: { z: 123 }}} + * removeIn(original, ['x', 'y', 'z']) // { x: { y: {}}} + * console.log(original) // { x: { y: { z: 123 }}} + * ``` + */ function removeIn(collection, keyPath) { - return updateIn$1(collection, keyPath, function () { return NOT_SET; }); + return updateIn$1(collection, keyPath, function () { return NOT_SET; }); } function deleteIn(keyPath) { @@ -2367,7 +2393,9 @@ } function update$1(collection, key, notSetValue, updater) { - return updateIn$1(collection, [key], notSetValue, updater); + return updateIn$1( + // @ts-expect-error Index signature for type string is missing in type V[] + collection, [key], notSetValue, updater); } function update(key, notSetValue, updater) { @@ -4963,6 +4991,21 @@ var EMPTY_RANGE; + /** + * Returns the value at the provided key path starting at the provided + * collection, or notSetValue if the key path is not defined. + * + * A functional alternative to `collection.getIn(keypath)` which will also + * work with plain Objects and Arrays. + * + * + * ```js + * import { getIn } from 'immutable'; + * + * getIn({ x: { y: { z: 123 }}}, ['x', 'y', 'z']) // 123 + * getIn({ x: { y: { z: 123 }}}, ['x', 'q', 'p'], 'ifNotSet') // 'ifNotSet' + * ``` + */ function getIn$1(collection, searchKeyPath, notSetValue) { var keyPath = coerceKeyPath(searchKeyPath); var i = 0; @@ -4980,6 +5023,20 @@ return getIn$1(this, searchKeyPath, notSetValue); } + /** + * Returns true if the key path is defined in the provided collection. + * + * A functional alternative to `collection.hasIn(keypath)` which will also + * work with plain Objects and Arrays. + * + * + * ```js + * import { hasIn } from 'immutable'; + * + * hasIn({ x: { y: { z: 123 }}}, ['x', 'y', 'z']) // true + * hasIn({ x: { y: { z: 123 }}}, ['x', 'q', 'p']) // false + * ``` + */ function hasIn$1(collection, keyPath) { return getIn$1(collection, keyPath, NOT_SET) !== NOT_SET; } From 4f2d3b2050cc5f3b7fbbcf1d07fca7278883805b Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 25 Mar 2025 19:39:11 +0000 Subject: [PATCH 237/242] deploy: d4189ab12e44e44b5f9ec724b303df5115f44e07 --- dist/immutable.es.js | 14 +++----------- dist/immutable.js | 14 +++----------- 2 files changed, 6 insertions(+), 22 deletions(-) diff --git a/dist/immutable.es.js b/dist/immutable.es.js index 4e31a8d419..e2fff970d3 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -4884,17 +4884,9 @@ var Range = /*@__PURE__*/(function (IndexedSeq) { Range.prototype.constructor = Range; Range.prototype.toString = function toString () { - if (this.size === 0) { - return 'Range []'; - } - return ( - 'Range [ ' + - this._start + - '...' + - this._end + - (this._step !== 1 ? ' by ' + this._step : '') + - ' ]' - ); + return this.size === 0 + ? 'Range []' + : ("Range [ " + (this._start) + "..." + (this._end) + (this._step !== 1 ? ' by ' + this._step : '') + " ]"); }; Range.prototype.get = function get (index, notSetValue) { diff --git a/dist/immutable.js b/dist/immutable.js index 9770900559..ebcf0220b4 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -4890,17 +4890,9 @@ Range.prototype.constructor = Range; Range.prototype.toString = function toString () { - if (this.size === 0) { - return 'Range []'; - } - return ( - 'Range [ ' + - this._start + - '...' + - this._end + - (this._step !== 1 ? ' by ' + this._step : '') + - ' ]' - ); + return this.size === 0 + ? 'Range []' + : ("Range [ " + (this._start) + "..." + (this._end) + (this._step !== 1 ? ' by ' + this._step : '') + " ]"); }; Range.prototype.get = function get (index, notSetValue) { From b18aeb6cdbd32616750e35570de7769fafd97871 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 25 Mar 2025 19:48:14 +0000 Subject: [PATCH 238/242] deploy: bed5ccd6676e84e43fc1055005ec4d6dc82e9106 --- bower.json | 2 +- dist/immutable.es.js | 2 +- dist/immutable.js | 2 +- dist/immutable.min.js | 2 +- package.json | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/bower.json b/bower.json index 0eda1b7fa3..2db591e9b1 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "immutable", - "version": "5.0.3", + "version": "5.1.0", "description": "Immutable Data Collections", "license": "MIT", "homepage": "https://immutable-js.com", diff --git a/dist/immutable.es.js b/dist/immutable.es.js index e2fff970d3..c43edf507c 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -6217,7 +6217,7 @@ function defaultConverter(k, v) { return isIndexed(v) ? v.toList() : isKeyed(v) ? v.toMap() : v.toSet(); } -var version = "5.0.3"; +var version = "5.1.0"; // Note: Iterable is deprecated var Iterable = Collection; diff --git a/dist/immutable.js b/dist/immutable.js index ebcf0220b4..49cf57d770 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -6223,7 +6223,7 @@ return isIndexed(v) ? v.toList() : isKeyed(v) ? v.toMap() : v.toSet(); } - var version = "5.0.3"; + var version = "5.1.0"; // Note: Iterable is deprecated var Iterable = Collection; diff --git a/dist/immutable.min.js b/dist/immutable.min.js index a62d2408be..78316346a8 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -22,4 +22,4 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).Immutable={})}(this,(function(t){"use strict";var e="delete",r=5,n=1<>>0;if(""+r!==e||4294967295===r)return NaN;e=r}return e<0?a(t)+e:e}function f(){return!0}function h(t,e,r){return(0===t&&!v(t)||void 0!==r&&t<=-r)&&(void 0===e||void 0!==r&&e>=r)}function p(t,e){return l(t,e,0)}function _(t,e){return l(t,e,e)}function l(t,e,r){return void 0===t?r:v(t)?e===1/0?e:0|Math.max(0,e+t):void 0===e||e===t?t:0|Math.min(e,t)}function v(t){return t<0||0===t&&1/t==-1/0}var y="@@__IMMUTABLE_ITERABLE__@@";function d(t){return Boolean(t&&t[y])}var g="@@__IMMUTABLE_KEYED__@@";function w(t){return Boolean(t&&t[g])}var m="@@__IMMUTABLE_INDEXED__@@";function b(t){return Boolean(t&&t[m])}function z(t){return w(t)||b(t)}var S=function(t){return d(t)?t:X(t)},I=function(t){function e(t){return w(t)?t:F(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(S),O=function(t){function e(t){return b(t)?t:G(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(S),E=function(t){function e(t){return d(t)&&!z(t)?t:Z(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(S);S.Keyed=I,S.Indexed=O,S.Set=E;var j="@@__IMMUTABLE_SEQ__@@";function q(t){return Boolean(t&&t[j])}var M="@@__IMMUTABLE_RECORD__@@";function D(t){return Boolean(t&&t[M])}function x(t){return d(t)||D(t)}var A="@@__IMMUTABLE_ORDERED__@@";function k(t){return Boolean(t&&t[A])}var R=0,U=1,T=2,B="function"==typeof Symbol&&Symbol.iterator,K="@@iterator",L=B||K,C=function(t){this.next=t};function P(t,e,r,n){var i=t===R?e:t===U?r:[e,r];return n?n.value=i:n={value:i,done:!1},n}function W(){return{value:void 0,done:!0}}function N(t){return!!Array.isArray(t)||!!V(t)}function H(t){return t&&"function"==typeof t.next}function J(t){var e=V(t);return e&&e.call(t)}function V(t){var e=t&&(B&&t[B]||t[K]);if("function"==typeof e)return e}C.prototype.toString=function(){return"[Iterator]"},C.KEYS=R,C.VALUES=U,C.ENTRIES=T,C.prototype.inspect=C.prototype.toSource=function(){return this.toString()},C.prototype[L]=function(){return this};var Y=Object.prototype.hasOwnProperty;function Q(t){return!(!Array.isArray(t)&&"string"!=typeof t)||t&&"object"==typeof t&&Number.isInteger(t.length)&&t.length>=0&&(0===t.length?1===Object.keys(t).length:t.hasOwnProperty(t.length-1))}var X=function(t){function e(t){return null==t?nt():x(t)?t.toSeq():function(t){var e=ut(t);if(e)return(n=V(r=t))&&n===r.entries?e.fromEntrySeq():function(t){var e=V(t);return e&&e===t.keys}(t)?e.toSetSeq():e;var r,n;if("object"==typeof t)return new tt(t);throw new TypeError("Expected Array or collection object of values, or keyed object: "+t)}(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq {","}")},e.prototype.cacheResult=function(){return!this._cache&&this.__iterateUncached&&(this._cache=this.entrySeq().toArray(),this.size=this._cache.length),this},e.prototype.__iterate=function(t,e){var r=this._cache;if(r){for(var n=r.length,i=0;i!==n;){var o=r[e?n-++i:i++];if(!1===t(o[1],o[0],this))break}return i}return this.__iterateUncached(t,e)},e.prototype.__iterator=function(t,e){var r=this._cache;if(r){var n=r.length,i=0;return new C((function(){if(i===n)return{value:void 0,done:!0};var o=r[e?n-++i:i++];return P(t,o[0],o[1])}))}return this.__iteratorUncached(t,e)},e}(S),F=function(t){function e(t){return null==t?nt().toKeyedSeq():d(t)?w(t)?t.toSeq():t.fromEntrySeq():D(t)?t.toSeq():it(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toKeyedSeq=function(){return this},e}(X),G=function(t){function e(t){return null==t?nt():d(t)?w(t)?t.entrySeq():t.toIndexedSeq():D(t)?t.toSeq().entrySeq():ot(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return e(arguments)},e.prototype.toIndexedSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq [","]")},e}(X),Z=function(t){function e(t){return(d(t)&&!z(t)?t:G(t)).toSetSeq()}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return e(arguments)},e.prototype.toSetSeq=function(){return this},e}(X);X.isSeq=q,X.Keyed=F,X.Set=Z,X.Indexed=G,X.prototype[j]=!0;var $=function(t){function e(t){this._array=t,this.size=t.length}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t,e){return this.has(t)?this._array[c(this,t)]:e},e.prototype.__iterate=function(t,e){for(var r=this._array,n=r.length,i=0;i!==n;){var o=e?n-++i:i++;if(!1===t(r[o],o,this))break}return i},e.prototype.__iterator=function(t,e){var r=this._array,n=r.length,i=0;return new C((function(){if(i===n)return{value:void 0,done:!0};var o=e?n-++i:i++;return P(t,o,r[o])}))},e}(G),tt=function(t){function e(t){var e=Object.keys(t).concat(Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(t):[]);this._object=t,this._keys=e,this.size=e.length}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t,e){return void 0===e||this.has(t)?this._object[t]:e},e.prototype.has=function(t){return Y.call(this._object,t)},e.prototype.__iterate=function(t,e){for(var r=this._object,n=this._keys,i=n.length,o=0;o!==i;){var u=n[e?i-++o:o++];if(!1===t(r[u],u,this))break}return o},e.prototype.__iterator=function(t,e){var r=this._object,n=this._keys,i=n.length,o=0;return new C((function(){if(o===i)return{value:void 0,done:!0};var u=n[e?i-++o:o++];return P(t,u,r[u])}))},e}(F);tt.prototype[A]=!0;var et,rt=function(t){function e(t){this._collection=t,this.size=t.length||t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.__iterateUncached=function(t,e){if(e)return this.cacheResult().__iterate(t,e);var r=J(this._collection),n=0;if(H(r))for(var i;!(i=r.next()).done&&!1!==t(i.value,n++,this););return n},e.prototype.__iteratorUncached=function(t,e){if(e)return this.cacheResult().__iterator(t,e);var r=J(this._collection);if(!H(r))return new C(W);var n=0;return new C((function(){var e=r.next();return e.done?e:P(t,n++,e.value)}))},e}(G);function nt(){return et||(et=new $([]))}function it(t){var e=ut(t);if(e)return e.fromEntrySeq();if("object"==typeof t)return new tt(t);throw new TypeError("Expected Array or collection object of [k, v] entries, or keyed object: "+t)}function ot(t){var e=ut(t);if(e)return e;throw new TypeError("Expected Array or collection object of values: "+t)}function ut(t){return Q(t)?new $(t):N(t)?new rt(t):void 0}var st="@@__IMMUTABLE_MAP__@@";function at(t){return Boolean(t&&t[st])}function ct(t){return at(t)&&k(t)}function ft(t){return Boolean(t&&"function"==typeof t.equals&&"function"==typeof t.hashCode)}function ht(t,e){if(t===e||t!=t&&e!=e)return!0;if(!t||!e)return!1;if("function"==typeof t.valueOf&&"function"==typeof e.valueOf){if((t=t.valueOf())===(e=e.valueOf())||t!=t&&e!=e)return!0;if(!t||!e)return!1}return!!(ft(t)&&ft(e)&&t.equals(e))}var pt="function"==typeof Math.imul&&-2===Math.imul(4294967295,2)?Math.imul:function(t,e){var r=65535&(t|=0),n=65535&(e|=0);return r*n+((t>>>16)*n+r*(e>>>16)<<16>>>0)|0};function _t(t){return t>>>1&1073741824|3221225471&t}var lt=Object.prototype.valueOf;function vt(t){if(null==t)return yt(t);if("function"==typeof t.hashCode)return _t(t.hashCode(t));var e,r=(e=t).valueOf!==lt&&"function"==typeof e.valueOf?e.valueOf(e):e;if(null==r)return yt(r);switch(typeof r){case"boolean":return r?1108378657:1108378656;case"number":return function(t){if(t!=t||t===1/0)return 0;var e=0|t;e!==t&&(e^=4294967295*t);for(;t>4294967295;)e^=t/=4294967295;return _t(e)}(r);case"string":return r.length>Et?function(t){var e=Mt[t];void 0===e&&(e=dt(t),qt===jt&&(qt=0,Mt={}),qt++,Mt[t]=e);return e}(r):dt(r);case"object":case"function":return function(t){var e;if(zt&&void 0!==(e=bt.get(t)))return e;if(e=t[Ot],void 0!==e)return e;if(!wt){if(void 0!==(e=t.propertyIsEnumerable&&t.propertyIsEnumerable[Ot]))return e;if(void 0!==(e=function(t){if(t&&t.nodeType>0)switch(t.nodeType){case 1:return t.uniqueID;case 9:return t.documentElement&&t.documentElement.uniqueID}}(t)))return e}if(e=mt(),zt)bt.set(t,e);else{if(void 0!==gt&&!1===gt(t))throw new Error("Non-extensible objects are not allowed as keys.");if(wt)Object.defineProperty(t,Ot,{enumerable:!1,configurable:!1,writable:!1,value:e});else if(void 0!==t.propertyIsEnumerable&&t.propertyIsEnumerable===t.constructor.prototype.propertyIsEnumerable)t.propertyIsEnumerable=function(){return this.constructor.prototype.propertyIsEnumerable.apply(this,arguments)},t.propertyIsEnumerable[Ot]=e;else{if(void 0===t.nodeType)throw new Error("Unable to set a non-enumerable property on object.");t[Ot]=e}}return e}(r);case"symbol":return function(t){var e=St[t];if(void 0!==e)return e;return e=mt(),St[t]=e,e}(r);default:if("function"==typeof r.toString)return dt(r.toString());throw new Error("Value type "+typeof r+" cannot be hashed.")}}function yt(t){return null===t?1108378658:1108378659}function dt(t){for(var e=0,r=0;r=0&&(a.get=function(e,r){return(e=c(this,e))>=0&&eo)return{value:void 0,done:!0};var t=i.next();return n||e===U||t.done?t:P(e,a-1,e===R?void 0:t.value[1],t)}))},a}function Lt(t,e,r,n){var i=Xt(t);return i.__iterateUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterate(i,o);var s=!0,a=0;return t.__iterate((function(t,o,c){if(!s||!(s=e.call(r,t,o,c)))return a++,i(t,n?o:a-1,u)})),a},i.__iteratorUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterator(i,o);var s=t.__iterator(T,o),a=!0,c=0;return new C((function(){var t,o,f;do{if((t=s.next()).done)return n||i===U?t:P(i,c++,i===R?void 0:t.value[1],t);var h=t.value;o=h[0],f=h[1],a&&(a=e.call(r,f,o,u))}while(a);return i===T?t:P(i,o,f,t)}))},i}xt.prototype.cacheResult=Dt.prototype.cacheResult=At.prototype.cacheResult=kt.prototype.cacheResult=Ft;var Ct=function(t){function e(t){this._wrappedIterables=t.flatMap((function(t){return t._wrappedIterables?t._wrappedIterables:[t]})),this.size=this._wrappedIterables.reduce((function(t,e){if(void 0!==t){var r=e.size;if(void 0!==r)return t+r}}),0),this[g]=this._wrappedIterables[0][g],this[m]=this._wrappedIterables[0][m],this[A]=this._wrappedIterables[0][A]}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.__iterateUncached=function(t,e){if(0!==this._wrappedIterables.length){if(e)return this.cacheResult().__iterate(t,e);for(var r=0,n=w(this),i=n?T:U,o=this._wrappedIterables[r].__iterator(i,e),u=!0,s=0;u;){for(var a=o.next();a.done;){if(++r===this._wrappedIterables.length)return s;a=(o=this._wrappedIterables[r].__iterator(i,e)).next()}u=!1!==(n?t(a.value[1],a.value[0],this):t(a.value,s,this)),s++}return s}},e.prototype.__iteratorUncached=function(t,e){var r=this;if(0===this._wrappedIterables.length)return new C(W);if(e)return this.cacheResult().__iterator(t,e);var n=0,i=this._wrappedIterables[n].__iterator(t,e);return new C((function(){for(var o=i.next();o.done;){if(++n===r._wrappedIterables.length)return o;o=(i=r._wrappedIterables[n].__iterator(t,e)).next()}return o}))},e}(X);function Pt(t,e,r){var n=Xt(t);return n.__iterateUncached=function(i,o){if(o)return this.cacheResult().__iterate(i,o);var u=0,s=!1;return function t(a,c){a.__iterate((function(o,a){return(!e||c0}function Jt(t,e,r,n){var i=Xt(t),o=new $(r).map((function(t){return t.size}));return i.size=n?o.max():o.min(),i.__iterate=function(t,e){for(var r,n=this.__iterator(U,e),i=0;!(r=n.next()).done&&!1!==t(r.value,i++,this););return i},i.__iteratorUncached=function(t,i){var o=r.map((function(t){return t=S(t),J(i?t.reverse():t)})),u=0,s=!1;return new C((function(){var r;return s||(r=o.map((function(t){return t.next()})),s=n?r.every((function(t){return t.done})):r.some((function(t){return t.done}))),s?{value:void 0,done:!0}:P(t,u++,e.apply(null,r.map((function(t){return t.value}))))}))},i}function Vt(t,e){return t===e?t:q(t)?e:t.constructor(e)}function Yt(t){if(t!==Object(t))throw new TypeError("Expected [K, V] tuple: "+t)}function Qt(t){return w(t)?I:b(t)?O:E}function Xt(t){return Object.create((w(t)?F:b(t)?G:Z).prototype)}function Ft(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size,this):X.prototype.cacheResult.call(this)}function Gt(t,e){return void 0===t&&void 0===e?0:void 0===t?1:void 0===e?-1:t>e?1:t0;)e[r]=arguments[r+1];if("function"!=typeof t)throw new TypeError("Invalid merger function: "+t);return ze(this,e,t)}function ze(t,e,r){for(var n=[],i=0;i0;)e[r]=arguments[r+1];return Se(this,e,t)}function je(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return he(this,t,Je(),(function(t){return Ie(t,e)}))}function qe(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return he(this,t,Je(),(function(t){return Se(t,e)}))}function Me(t){var e=this.asMutable();return t(e),e.wasAltered()?e.__ensureOwner(this.__ownerID):this}function De(){return this.__ownerID?this:this.__ensureOwner(new s)}function xe(){return this.__ensureOwner()}function Ae(){return this.__altered}var ke=function(t){function e(e){return null==e?Je():at(e)&&!k(e)?e:Je().withMutations((function(r){var n=t(e);te(n.size),n.forEach((function(t,e){return r.set(e,t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toString=function(){return this.__toString("Map {","}")},e.prototype.get=function(t,e){return this._root?this._root.get(0,void 0,t,e):e},e.prototype.set=function(t,e){return Ve(this,t,e)},e.prototype.remove=function(t){return Ve(this,t,o)},e.prototype.deleteAll=function(t){var e=S(t);return 0===e.size?this:this.withMutations((function(t){e.forEach((function(e){return t.remove(e)}))}))},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):Je()},e.prototype.sort=function(t){return yr(Wt(this,t))},e.prototype.sortBy=function(t,e){return yr(Wt(this,e,t))},e.prototype.map=function(t,e){var r=this;return this.withMutations((function(n){n.forEach((function(i,o){n.set(o,t.call(e,i,o,r))}))}))},e.prototype.__iterator=function(t,e){return new Pe(this,t,e)},e.prototype.__iterate=function(t,e){var r=this,n=0;return this._root&&this._root.iterate((function(e){return n++,t(e[1],e[0],r)}),e),n},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?He(this.size,this._root,t,this.__hash):0===this.size?Je():(this.__ownerID=t,this.__altered=!1,this)},e}(I);ke.isMap=at;var Re=ke.prototype;Re[st]=!0,Re[e]=Re.remove,Re.removeAll=Re.deleteAll,Re.setIn=le,Re.removeIn=Re.deleteIn=ye,Re.update=ge,Re.updateIn=we,Re.merge=Re.concat=me,Re.mergeWith=be,Re.mergeDeep=Oe,Re.mergeDeepWith=Ee,Re.mergeIn=je,Re.mergeDeepIn=qe,Re.withMutations=Me,Re.wasAltered=Ae,Re.asImmutable=xe,Re["@@transducer/init"]=Re.asMutable=De,Re["@@transducer/step"]=function(t,e){return t.set(e[0],e[1])},Re["@@transducer/result"]=function(t){return t.asImmutable()};var Ue=function(t,e){this.ownerID=t,this.entries=e};Ue.prototype.get=function(t,e,r,n){for(var i=this.entries,o=0,u=i.length;o=Ze)return function(t,e,r,n){t||(t=new s);for(var i=new Le(t,vt(r),[r,n]),o=0;o>>t)&i),s=this.bitmap;return 0==(s&u)?o:this.nodes[Fe(s&u-1)].get(t+r,e,n,o)},Te.prototype.update=function(t,e,u,s,a,c,f){void 0===u&&(u=vt(s));var h=(0===e?u:u>>>e)&i,p=1<=$e)return function(t,e,r,i,o){for(var u=0,s=new Array(n),a=0;0!==r;a++,r>>>=1)s[a]=1&r?e[u++]:void 0;return s[i]=o,new Be(t,u+1,s)}(t,y,_,h,g);if(l&&!g&&2===y.length&&Qe(y[1^v]))return y[1^v];if(l&&g&&1===y.length&&Qe(g))return g;var w=t&&t===this.ownerID,m=l?g?_:_^p:_|p,b=l?g?Ge(y,v,g,w):function(t,e,r){var n=t.length-1;if(r&&e===n)return t.pop(),t;for(var i=new Array(n),o=0,u=0;u>>t)&i,s=this.nodes[u];return s?s.get(t+r,e,n,o):o},Be.prototype.update=function(t,e,n,u,s,a,c){void 0===n&&(n=vt(u));var f=(0===e?n:n>>>e)&i,h=s===o,p=this.nodes,_=p[f];if(h&&!_)return this;var l=Ye(_,t,e+r,n,u,s,a,c);if(l===_)return this;var v=this.count;if(_){if(!l&&--v>>n)&i,c=(0===n?o:o>>>n)&i,f=a===c?[Xe(t,e,n+r,o,u)]:(s=new Le(e,o,u),a>1&1431655765))+(t>>2&858993459))+(t>>4)&252645135,t+=t>>8,127&(t+=t>>16)}function Ge(t,e,r,n){var i=n?t:Zt(t);return i[e]=r,i}var Ze=n/4,$e=n/2,tr=n/4,er="@@__IMMUTABLE_LIST__@@";function rr(t){return Boolean(t&&t[er])}var nr=function(t){function e(e){var i=cr();if(null==e)return i;if(rr(e))return e;var o=t(e),u=o.size;return 0===u?i:(te(u),u>0&&u=0&&t=t.size||e<0)return t.withMutations((function(t){e<0?_r(t,e).set(0,r):_r(t,0,e+1).set(e,r)}));e+=t._origin;var n=t._tail,i=t._root,o={value:!1};e>=lr(t._capacity)?n=fr(n,t.__ownerID,0,e,r,o):i=fr(i,t.__ownerID,t._level,e,r,o);if(!o.value)return t;if(t.__ownerID)return t._root=i,t._tail=n,t.__hash=void 0,t.__altered=!0,t;return ar(t._origin,t._capacity,t._level,i,n)}(this,t,e)},e.prototype.remove=function(t){return this.has(t)?0===t?this.shift():t===this.size-1?this.pop():this.splice(t,1):this},e.prototype.insert=function(t,e){return this.splice(t,0,e)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=this._origin=this._capacity=0,this._level=r,this._root=this._tail=this.__hash=void 0,this.__altered=!0,this):cr()},e.prototype.push=function(){var t=arguments,e=this.size;return this.withMutations((function(r){_r(r,0,e+t.length);for(var n=0;n>>e&i;if(o>=this.array.length)return new or([],t);var u,s=0===o;if(e>0){var a=this.array[o];if((u=a&&a.removeBefore(t,e-r,n))===a&&s)return this}if(s&&!u)return this;var c=hr(this,t);if(!s)for(var f=0;f>>e&i;if(s>=this.array.length)return this;if(e>0){var a=this.array[s];if((u=a&&a.removeAfter(t,e-r,o))===a&&s===this.array.length-1)return this}var c=hr(this,t);return c.array.splice(s+1),u&&(c.array[s]=u),c};var ur={};function sr(t,e){var i=t._origin,o=t._capacity,u=lr(o),s=t._tail;return a(t._root,t._level,0);function a(t,c,f){return 0===c?function(t,r){var a=r===u?s&&s.array:t&&t.array,c=r>i?0:i-r,f=o-r;f>n&&(f=n);return function(){if(c===f)return ur;var t=e?--f:c++;return a&&a[t]}}(t,f):function(t,u,s){var c,f=t&&t.array,h=s>i?0:i-s>>u,p=1+(o-s>>u);p>n&&(p=n);return function(){for(;;){if(c){var t=c();if(t!==ur)return t;c=null}if(h===p)return ur;var n=e?--p:h++;c=a(f&&f[n],u-r,s+(n<>>n&i,h=t&&f0){var p=t&&t.array[f],_=fr(p,e,n-r,o,s,a);return _===p?t:((c=hr(t,e)).array[f]=_,c)}return h&&t.array[f]===s?t:(a&&u(a),c=hr(t,e),void 0===s&&f===c.array.length-1?c.array.pop():c.array[f]=s,c)}function hr(t,e){return e&&t&&e===t.ownerID?t:new or(t?t.array.slice():[],e)}function pr(t,e){if(e>=lr(t._capacity))return t._tail;if(e<1<0;)n=n.array[e>>>o&i],o-=r;return n}}function _r(t,e,n){void 0!==e&&(e|=0),void 0!==n&&(n|=0);var o=t.__ownerID||new s,u=t._origin,a=t._capacity,c=u+e,f=void 0===n?a:n<0?a+n:u+n;if(c===u&&f===a)return t;if(c>=f)return t.clear();for(var h=t._level,p=t._root,_=0;c+_<0;)p=new or(p&&p.array.length?[void 0,p]:[],o),_+=1<<(h+=r);_&&(c+=_,u+=_,f+=_,a+=_);for(var l=lr(a),v=lr(f);v>=1<l?new or([],o):y;if(y&&v>l&&cr;w-=r){var m=l>>>w&i;g=g.array[m]=hr(g.array[m],o)}g.array[l>>>r&i]=y}if(f=v)c-=v,f-=v,h=r,p=null,d=d&&d.removeBefore(o,0,c);else if(c>u||v>>h&i;if(b!==v>>>h&i)break;b&&(_+=(1<u&&(p=p.removeBefore(o,h,c-_)),p&&v>>r<=n&&a.size>=2*s.size?(i=(u=a.filter((function(t,e){return void 0!==t&&c!==e}))).toKeyedSeq().map((function(t){return t[0]})).flip().toMap(),t.__ownerID&&(i.__ownerID=u.__ownerID=t.__ownerID)):(i=s.remove(e),u=c===a.size-1?a.pop():a.set(c,void 0))}else if(f){if(r===a.get(c)[1])return t;i=s,u=a.set(c,[e,r])}else i=s.set(e,a.size),u=a.set(a.size,[e,r]);return t.__ownerID?(t.size=i.size,t._map=i,t._list=u,t.__hash=void 0,t.__altered=!0,t):dr(i,u)}yr.isOrderedMap=ct,yr.prototype[A]=!0,yr.prototype[e]=yr.prototype.remove;var mr="@@__IMMUTABLE_STACK__@@";function br(t){return Boolean(t&&t[mr])}var zr=function(t){function e(t){return null==t?Er():br(t)?t:Er().pushAll(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("Stack [","]")},e.prototype.get=function(t,e){var r=this._head;for(t=c(this,t);r&&t--;)r=r.next;return r?r.value:e},e.prototype.peek=function(){return this._head&&this._head.value},e.prototype.push=function(){var t=arguments;if(0===arguments.length)return this;for(var e=this.size+arguments.length,r=this._head,n=arguments.length-1;n>=0;n--)r={value:t[n],next:r};return this.__ownerID?(this.size=e,this._head=r,this.__hash=void 0,this.__altered=!0,this):Or(e,r)},e.prototype.pushAll=function(e){if(0===(e=t(e)).size)return this;if(0===this.size&&br(e))return e;te(e.size);var r=this.size,n=this._head;return e.__iterate((function(t){r++,n={value:t,next:n}}),!0),this.__ownerID?(this.size=r,this._head=n,this.__hash=void 0,this.__altered=!0,this):Or(r,n)},e.prototype.pop=function(){return this.slice(1)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):Er()},e.prototype.slice=function(e,r){if(h(e,r,this.size))return this;var n=p(e,this.size);if(_(r,this.size)!==this.size)return t.prototype.slice.call(this,e,r);for(var i=this.size-n,o=this._head;n--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):Or(i,o)},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Or(this.size,this._head,t,this.__hash):0===this.size?Er():(this.__ownerID=t,this.__altered=!1,this)},e.prototype.__iterate=function(t,e){var r=this;if(e)return new $(this.toArray()).__iterate((function(e,n){return t(e,n,r)}),e);for(var n=0,i=this._head;i&&!1!==t(i.value,n++,this);)i=i.next;return n},e.prototype.__iterator=function(t,e){if(e)return new $(this.toArray()).__iterator(t,e);var r=0,n=this._head;return new C((function(){if(n){var e=n.value;return n=n.next,P(t,r++,e)}return{value:void 0,done:!0}}))},e}(O);zr.isStack=br;var Sr,Ir=zr.prototype;function Or(t,e,r,n){var i=Object.create(Ir);return i.size=t,i._head=e,i.__ownerID=r,i.__hash=n,i.__altered=!1,i}function Er(){return Sr||(Sr=Or(0))}Ir[mr]=!0,Ir.shift=Ir.pop,Ir.unshift=Ir.push,Ir.unshiftAll=Ir.pushAll,Ir.withMutations=Me,Ir.wasAltered=Ae,Ir.asImmutable=xe,Ir["@@transducer/init"]=Ir.asMutable=De,Ir["@@transducer/step"]=function(t,e){return t.unshift(e)},Ir["@@transducer/result"]=function(t){return t.asImmutable()};var jr="@@__IMMUTABLE_SET__@@";function qr(t){return Boolean(t&&t[jr])}function Mr(t){return qr(t)&&k(t)}function Dr(t,e){if(t===e)return!0;if(!d(e)||void 0!==t.size&&void 0!==e.size&&t.size!==e.size||void 0!==t.__hash&&void 0!==e.__hash&&t.__hash!==e.__hash||w(t)!==w(e)||b(t)!==b(e)||k(t)!==k(e))return!1;if(0===t.size&&0===e.size)return!0;var r=!z(t);if(k(t)){var n=t.entries();return e.every((function(t,e){var i=n.next().value;return i&&ht(i[1],t)&&(r||ht(i[0],e))}))&&n.next().done}var i=!1;if(void 0===t.size)if(void 0===e.size)"function"==typeof t.cacheResult&&t.cacheResult();else{i=!0;var u=t;t=e,e=u}var s=!0,a=e.__iterate((function(e,n){if(r?!t.has(e):i?!ht(e,t.get(n,o)):!ht(t.get(n,o),e))return s=!1,!1}));return s&&t.size===a}function xr(t,e){var r=function(r){t.prototype[r]=e[r]};return Object.keys(e).forEach(r),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(e).forEach(r),t}function Ar(t){if(!t||"object"!=typeof t)return t;if(!d(t)){if(!ie(t))return t;t=X(t)}if(w(t)){var e={};return t.__iterate((function(t,r){e[r]=Ar(t)})),e}var r=[];return t.__iterate((function(t){r.push(Ar(t))})),r}var kr=function(t){function e(e){return null==e?Kr():qr(e)&&!k(e)?e:Kr().withMutations((function(r){var n=t(e);te(n.size),n.forEach((function(t){return r.add(t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(I(t).keySeq())},e.intersect=function(t){return(t=S(t).toArray()).length?Ur.intersect.apply(e(t.pop()),t):Kr()},e.union=function(t){return(t=S(t).toArray()).length?Ur.union.apply(e(t.pop()),t):Kr()},e.prototype.toString=function(){return this.__toString("Set {","}")},e.prototype.has=function(t){return this._map.has(t)},e.prototype.add=function(t){return Tr(this,this._map.set(t,t))},e.prototype.remove=function(t){return Tr(this,this._map.remove(t))},e.prototype.clear=function(){return Tr(this,this._map.clear())},e.prototype.map=function(t,e){var r=this,n=!1,i=Tr(this,this._map.mapEntries((function(i){var o=i[1],u=t.call(e,o,o,r);return u!==o&&(n=!0),[u,u]}),e));return n?i:this},e.prototype.union=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return 0===(e=e.filter((function(t){return 0!==t.size}))).length?this:0!==this.size||this.__ownerID||1!==e.length?this.withMutations((function(r){for(var n=0;n=0&&e=0&&r>>-15,461845907),e=pt(e<<13|e>>>-13,5),e=pt((e=(e+3864292196|0)^t)^e>>>16,2246822507),e=_t((e=pt(e^e>>>13,3266489909))^e>>>16)}(t.size,n)}(this))}});var Jr=S.prototype;Jr[y]=!0,Jr[L]=Jr.values,Jr.toJSON=Jr.toArray,Jr.__toStringMapper=oe,Jr.inspect=Jr.toSource=function(){return this.toString()},Jr.chain=Jr.flatMap,Jr.contains=Jr.includes,xr(I,{flip:function(){return Vt(this,Rt(this))},mapEntries:function(t,e){var r=this,n=0;return Vt(this,this.toSeq().map((function(i,o){return t.call(e,[o,i],n++,r)})).fromEntrySeq())},mapKeys:function(t,e){var r=this;return Vt(this,this.toSeq().flip().map((function(n,i){return t.call(e,n,i,r)})).flip())}});var Vr=I.prototype;Vr[g]=!0,Vr[L]=Jr.entries,Vr.toJSON=Hr,Vr.__toStringMapper=function(t,e){return oe(e)+": "+oe(t)},xr(O,{toKeyedSeq:function(){return new Dt(this,!1)},filter:function(t,e){return Vt(this,Bt(this,t,e,!1))},findIndex:function(t,e){var r=this.findEntry(t,e);return r?r[0]:-1},indexOf:function(t){var e=this.keyOf(t);return void 0===e?-1:e},lastIndexOf:function(t){var e=this.lastKeyOf(t);return void 0===e?-1:e},reverse:function(){return Vt(this,Tt(this,!1))},slice:function(t,e){return Vt(this,Kt(this,t,e,!1))},splice:function(t,e){var r=arguments.length;if(e=Math.max(e||0,0),0===r||2===r&&!e)return this;t=p(t,t<0?this.count():this.size);var n=this.slice(0,t);return Vt(this,1===r?n:n.concat(Zt(arguments,2),this.slice(t+e)))},findLastIndex:function(t,e){var r=this.findLastEntry(t,e);return r?r[0]:-1},first:function(t){return this.get(0,t)},flatten:function(t){return Vt(this,Pt(this,t,!1))},get:function(t,e){return(t=c(this,t))<0||this.size===1/0||void 0!==this.size&&t>this.size?e:this.find((function(e,r){return r===t}),void 0,e)},has:function(t){return(t=c(this,t))>=0&&(void 0!==this.size?this.size===1/0||te?-1:0}function rn(t,e){return t^e+2654435769+(t<<6)+(t>>2)|0}Qr.has=Jr.includes,Qr.contains=Qr.includes,Qr.keys=Qr.values,xr(F,Vr),xr(G,Yr),xr(Z,Qr);var nn=function(t){function e(t){return null==t?an():Mr(t)?t:an().withMutations((function(e){var r=E(t);te(r.size),r.forEach((function(t){return e.add(t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(I(t).keySeq())},e.prototype.toString=function(){return this.__toString("OrderedSet {","}")},e}(kr);nn.isOrderedSet=Mr;var on,un=nn.prototype;function sn(t,e){var r=Object.create(un);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function an(){return on||(on=sn(gr()))}un[A]=!0,un.zip=Yr.zip,un.zipWith=Yr.zipWith,un.zipAll=Yr.zipAll,un.__empty=an,un.__make=sn;var cn=function(t,e){var r;!function(t){if(D(t))throw new Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(x(t))throw new Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(null===t||"object"!=typeof t)throw new Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}(t);var n=function(o){var u=this;if(o instanceof n)return o;if(!(this instanceof n))return new n(o);if(!r){r=!0;var s=Object.keys(t),a=i._indices={};i._name=e,i._keys=s,i._defaultValues=t;for(var c=0;c2?[]:void 0,{"":t})},t.get=se,t.getIn=Pr,t.has=ue,t.hasIn=Nr,t.hash=vt,t.is=ht,t.isAssociative=z,t.isCollection=d,t.isImmutable=x,t.isIndexed=b,t.isKeyed=w,t.isList=rr,t.isMap=at,t.isOrdered=k,t.isOrderedMap=ct,t.isOrderedSet=Mr,t.isPlainObject=ne,t.isRecord=D,t.isSeq=q,t.isSet=qr,t.isStack=br,t.isValueObject=ft,t.merge=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Ie(t,e)},t.mergeDeep=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Se(t,e)},t.mergeDeepWith=function(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];return Se(e,r,t)},t.mergeWith=function(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];return Ie(e,r,t)},t.remove=ce,t.removeIn=ve,t.set=fe,t.setIn=_e,t.update=de,t.updateIn=he,t.version="5.0.3"})); +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).Immutable={})}(this,(function(t){"use strict";var e="delete",r=5,n=1<>>0;if(""+r!==e||4294967295===r)return NaN;e=r}return e<0?a(t)+e:e}function f(){return!0}function h(t,e,r){return(0===t&&!v(t)||void 0!==r&&t<=-r)&&(void 0===e||void 0!==r&&e>=r)}function p(t,e){return l(t,e,0)}function _(t,e){return l(t,e,e)}function l(t,e,r){return void 0===t?r:v(t)?e===1/0?e:0|Math.max(0,e+t):void 0===e||e===t?t:0|Math.min(e,t)}function v(t){return t<0||0===t&&1/t==-1/0}var y="@@__IMMUTABLE_ITERABLE__@@";function d(t){return Boolean(t&&t[y])}var g="@@__IMMUTABLE_KEYED__@@";function w(t){return Boolean(t&&t[g])}var m="@@__IMMUTABLE_INDEXED__@@";function b(t){return Boolean(t&&t[m])}function z(t){return w(t)||b(t)}var S=function(t){return d(t)?t:X(t)},I=function(t){function e(t){return w(t)?t:F(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(S),O=function(t){function e(t){return b(t)?t:G(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(S),E=function(t){function e(t){return d(t)&&!z(t)?t:Z(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(S);S.Keyed=I,S.Indexed=O,S.Set=E;var j="@@__IMMUTABLE_SEQ__@@";function q(t){return Boolean(t&&t[j])}var M="@@__IMMUTABLE_RECORD__@@";function D(t){return Boolean(t&&t[M])}function x(t){return d(t)||D(t)}var A="@@__IMMUTABLE_ORDERED__@@";function k(t){return Boolean(t&&t[A])}var R=0,U=1,T=2,B="function"==typeof Symbol&&Symbol.iterator,K="@@iterator",L=B||K,C=function(t){this.next=t};function P(t,e,r,n){var i=t===R?e:t===U?r:[e,r];return n?n.value=i:n={value:i,done:!1},n}function W(){return{value:void 0,done:!0}}function N(t){return!!Array.isArray(t)||!!V(t)}function H(t){return t&&"function"==typeof t.next}function J(t){var e=V(t);return e&&e.call(t)}function V(t){var e=t&&(B&&t[B]||t[K]);if("function"==typeof e)return e}C.prototype.toString=function(){return"[Iterator]"},C.KEYS=R,C.VALUES=U,C.ENTRIES=T,C.prototype.inspect=C.prototype.toSource=function(){return this.toString()},C.prototype[L]=function(){return this};var Y=Object.prototype.hasOwnProperty;function Q(t){return!(!Array.isArray(t)&&"string"!=typeof t)||t&&"object"==typeof t&&Number.isInteger(t.length)&&t.length>=0&&(0===t.length?1===Object.keys(t).length:t.hasOwnProperty(t.length-1))}var X=function(t){function e(t){return null==t?nt():x(t)?t.toSeq():function(t){var e=ut(t);if(e)return(n=V(r=t))&&n===r.entries?e.fromEntrySeq():function(t){var e=V(t);return e&&e===t.keys}(t)?e.toSetSeq():e;var r,n;if("object"==typeof t)return new tt(t);throw new TypeError("Expected Array or collection object of values, or keyed object: "+t)}(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq {","}")},e.prototype.cacheResult=function(){return!this._cache&&this.__iterateUncached&&(this._cache=this.entrySeq().toArray(),this.size=this._cache.length),this},e.prototype.__iterate=function(t,e){var r=this._cache;if(r){for(var n=r.length,i=0;i!==n;){var o=r[e?n-++i:i++];if(!1===t(o[1],o[0],this))break}return i}return this.__iterateUncached(t,e)},e.prototype.__iterator=function(t,e){var r=this._cache;if(r){var n=r.length,i=0;return new C((function(){if(i===n)return{value:void 0,done:!0};var o=r[e?n-++i:i++];return P(t,o[0],o[1])}))}return this.__iteratorUncached(t,e)},e}(S),F=function(t){function e(t){return null==t?nt().toKeyedSeq():d(t)?w(t)?t.toSeq():t.fromEntrySeq():D(t)?t.toSeq():it(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toKeyedSeq=function(){return this},e}(X),G=function(t){function e(t){return null==t?nt():d(t)?w(t)?t.entrySeq():t.toIndexedSeq():D(t)?t.toSeq().entrySeq():ot(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return e(arguments)},e.prototype.toIndexedSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq [","]")},e}(X),Z=function(t){function e(t){return(d(t)&&!z(t)?t:G(t)).toSetSeq()}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return e(arguments)},e.prototype.toSetSeq=function(){return this},e}(X);X.isSeq=q,X.Keyed=F,X.Set=Z,X.Indexed=G,X.prototype[j]=!0;var $=function(t){function e(t){this._array=t,this.size=t.length}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t,e){return this.has(t)?this._array[c(this,t)]:e},e.prototype.__iterate=function(t,e){for(var r=this._array,n=r.length,i=0;i!==n;){var o=e?n-++i:i++;if(!1===t(r[o],o,this))break}return i},e.prototype.__iterator=function(t,e){var r=this._array,n=r.length,i=0;return new C((function(){if(i===n)return{value:void 0,done:!0};var o=e?n-++i:i++;return P(t,o,r[o])}))},e}(G),tt=function(t){function e(t){var e=Object.keys(t).concat(Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(t):[]);this._object=t,this._keys=e,this.size=e.length}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t,e){return void 0===e||this.has(t)?this._object[t]:e},e.prototype.has=function(t){return Y.call(this._object,t)},e.prototype.__iterate=function(t,e){for(var r=this._object,n=this._keys,i=n.length,o=0;o!==i;){var u=n[e?i-++o:o++];if(!1===t(r[u],u,this))break}return o},e.prototype.__iterator=function(t,e){var r=this._object,n=this._keys,i=n.length,o=0;return new C((function(){if(o===i)return{value:void 0,done:!0};var u=n[e?i-++o:o++];return P(t,u,r[u])}))},e}(F);tt.prototype[A]=!0;var et,rt=function(t){function e(t){this._collection=t,this.size=t.length||t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.__iterateUncached=function(t,e){if(e)return this.cacheResult().__iterate(t,e);var r=J(this._collection),n=0;if(H(r))for(var i;!(i=r.next()).done&&!1!==t(i.value,n++,this););return n},e.prototype.__iteratorUncached=function(t,e){if(e)return this.cacheResult().__iterator(t,e);var r=J(this._collection);if(!H(r))return new C(W);var n=0;return new C((function(){var e=r.next();return e.done?e:P(t,n++,e.value)}))},e}(G);function nt(){return et||(et=new $([]))}function it(t){var e=ut(t);if(e)return e.fromEntrySeq();if("object"==typeof t)return new tt(t);throw new TypeError("Expected Array or collection object of [k, v] entries, or keyed object: "+t)}function ot(t){var e=ut(t);if(e)return e;throw new TypeError("Expected Array or collection object of values: "+t)}function ut(t){return Q(t)?new $(t):N(t)?new rt(t):void 0}var st="@@__IMMUTABLE_MAP__@@";function at(t){return Boolean(t&&t[st])}function ct(t){return at(t)&&k(t)}function ft(t){return Boolean(t&&"function"==typeof t.equals&&"function"==typeof t.hashCode)}function ht(t,e){if(t===e||t!=t&&e!=e)return!0;if(!t||!e)return!1;if("function"==typeof t.valueOf&&"function"==typeof e.valueOf){if((t=t.valueOf())===(e=e.valueOf())||t!=t&&e!=e)return!0;if(!t||!e)return!1}return!!(ft(t)&&ft(e)&&t.equals(e))}var pt="function"==typeof Math.imul&&-2===Math.imul(4294967295,2)?Math.imul:function(t,e){var r=65535&(t|=0),n=65535&(e|=0);return r*n+((t>>>16)*n+r*(e>>>16)<<16>>>0)|0};function _t(t){return t>>>1&1073741824|3221225471&t}var lt=Object.prototype.valueOf;function vt(t){if(null==t)return yt(t);if("function"==typeof t.hashCode)return _t(t.hashCode(t));var e,r=(e=t).valueOf!==lt&&"function"==typeof e.valueOf?e.valueOf(e):e;if(null==r)return yt(r);switch(typeof r){case"boolean":return r?1108378657:1108378656;case"number":return function(t){if(t!=t||t===1/0)return 0;var e=0|t;e!==t&&(e^=4294967295*t);for(;t>4294967295;)e^=t/=4294967295;return _t(e)}(r);case"string":return r.length>Et?function(t){var e=Mt[t];void 0===e&&(e=dt(t),qt===jt&&(qt=0,Mt={}),qt++,Mt[t]=e);return e}(r):dt(r);case"object":case"function":return function(t){var e;if(zt&&void 0!==(e=bt.get(t)))return e;if(e=t[Ot],void 0!==e)return e;if(!wt){if(void 0!==(e=t.propertyIsEnumerable&&t.propertyIsEnumerable[Ot]))return e;if(void 0!==(e=function(t){if(t&&t.nodeType>0)switch(t.nodeType){case 1:return t.uniqueID;case 9:return t.documentElement&&t.documentElement.uniqueID}}(t)))return e}if(e=mt(),zt)bt.set(t,e);else{if(void 0!==gt&&!1===gt(t))throw new Error("Non-extensible objects are not allowed as keys.");if(wt)Object.defineProperty(t,Ot,{enumerable:!1,configurable:!1,writable:!1,value:e});else if(void 0!==t.propertyIsEnumerable&&t.propertyIsEnumerable===t.constructor.prototype.propertyIsEnumerable)t.propertyIsEnumerable=function(){return this.constructor.prototype.propertyIsEnumerable.apply(this,arguments)},t.propertyIsEnumerable[Ot]=e;else{if(void 0===t.nodeType)throw new Error("Unable to set a non-enumerable property on object.");t[Ot]=e}}return e}(r);case"symbol":return function(t){var e=St[t];if(void 0!==e)return e;return e=mt(),St[t]=e,e}(r);default:if("function"==typeof r.toString)return dt(r.toString());throw new Error("Value type "+typeof r+" cannot be hashed.")}}function yt(t){return null===t?1108378658:1108378659}function dt(t){for(var e=0,r=0;r=0&&(a.get=function(e,r){return(e=c(this,e))>=0&&eo)return{value:void 0,done:!0};var t=i.next();return n||e===U||t.done?t:P(e,a-1,e===R?void 0:t.value[1],t)}))},a}function Lt(t,e,r,n){var i=Xt(t);return i.__iterateUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterate(i,o);var s=!0,a=0;return t.__iterate((function(t,o,c){if(!s||!(s=e.call(r,t,o,c)))return a++,i(t,n?o:a-1,u)})),a},i.__iteratorUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterator(i,o);var s=t.__iterator(T,o),a=!0,c=0;return new C((function(){var t,o,f;do{if((t=s.next()).done)return n||i===U?t:P(i,c++,i===R?void 0:t.value[1],t);var h=t.value;o=h[0],f=h[1],a&&(a=e.call(r,f,o,u))}while(a);return i===T?t:P(i,o,f,t)}))},i}xt.prototype.cacheResult=Dt.prototype.cacheResult=At.prototype.cacheResult=kt.prototype.cacheResult=Ft;var Ct=function(t){function e(t){this._wrappedIterables=t.flatMap((function(t){return t._wrappedIterables?t._wrappedIterables:[t]})),this.size=this._wrappedIterables.reduce((function(t,e){if(void 0!==t){var r=e.size;if(void 0!==r)return t+r}}),0),this[g]=this._wrappedIterables[0][g],this[m]=this._wrappedIterables[0][m],this[A]=this._wrappedIterables[0][A]}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.__iterateUncached=function(t,e){if(0!==this._wrappedIterables.length){if(e)return this.cacheResult().__iterate(t,e);for(var r=0,n=w(this),i=n?T:U,o=this._wrappedIterables[r].__iterator(i,e),u=!0,s=0;u;){for(var a=o.next();a.done;){if(++r===this._wrappedIterables.length)return s;a=(o=this._wrappedIterables[r].__iterator(i,e)).next()}u=!1!==(n?t(a.value[1],a.value[0],this):t(a.value,s,this)),s++}return s}},e.prototype.__iteratorUncached=function(t,e){var r=this;if(0===this._wrappedIterables.length)return new C(W);if(e)return this.cacheResult().__iterator(t,e);var n=0,i=this._wrappedIterables[n].__iterator(t,e);return new C((function(){for(var o=i.next();o.done;){if(++n===r._wrappedIterables.length)return o;o=(i=r._wrappedIterables[n].__iterator(t,e)).next()}return o}))},e}(X);function Pt(t,e,r){var n=Xt(t);return n.__iterateUncached=function(i,o){if(o)return this.cacheResult().__iterate(i,o);var u=0,s=!1;return function t(a,c){a.__iterate((function(o,a){return(!e||c0}function Jt(t,e,r,n){var i=Xt(t),o=new $(r).map((function(t){return t.size}));return i.size=n?o.max():o.min(),i.__iterate=function(t,e){for(var r,n=this.__iterator(U,e),i=0;!(r=n.next()).done&&!1!==t(r.value,i++,this););return i},i.__iteratorUncached=function(t,i){var o=r.map((function(t){return t=S(t),J(i?t.reverse():t)})),u=0,s=!1;return new C((function(){var r;return s||(r=o.map((function(t){return t.next()})),s=n?r.every((function(t){return t.done})):r.some((function(t){return t.done}))),s?{value:void 0,done:!0}:P(t,u++,e.apply(null,r.map((function(t){return t.value}))))}))},i}function Vt(t,e){return t===e?t:q(t)?e:t.constructor(e)}function Yt(t){if(t!==Object(t))throw new TypeError("Expected [K, V] tuple: "+t)}function Qt(t){return w(t)?I:b(t)?O:E}function Xt(t){return Object.create((w(t)?F:b(t)?G:Z).prototype)}function Ft(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size,this):X.prototype.cacheResult.call(this)}function Gt(t,e){return void 0===t&&void 0===e?0:void 0===t?1:void 0===e?-1:t>e?1:t0;)e[r]=arguments[r+1];if("function"!=typeof t)throw new TypeError("Invalid merger function: "+t);return ze(this,e,t)}function ze(t,e,r){for(var n=[],i=0;i0;)e[r]=arguments[r+1];return Se(this,e,t)}function je(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return he(this,t,Je(),(function(t){return Ie(t,e)}))}function qe(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return he(this,t,Je(),(function(t){return Se(t,e)}))}function Me(t){var e=this.asMutable();return t(e),e.wasAltered()?e.__ensureOwner(this.__ownerID):this}function De(){return this.__ownerID?this:this.__ensureOwner(new s)}function xe(){return this.__ensureOwner()}function Ae(){return this.__altered}var ke=function(t){function e(e){return null==e?Je():at(e)&&!k(e)?e:Je().withMutations((function(r){var n=t(e);te(n.size),n.forEach((function(t,e){return r.set(e,t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toString=function(){return this.__toString("Map {","}")},e.prototype.get=function(t,e){return this._root?this._root.get(0,void 0,t,e):e},e.prototype.set=function(t,e){return Ve(this,t,e)},e.prototype.remove=function(t){return Ve(this,t,o)},e.prototype.deleteAll=function(t){var e=S(t);return 0===e.size?this:this.withMutations((function(t){e.forEach((function(e){return t.remove(e)}))}))},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):Je()},e.prototype.sort=function(t){return yr(Wt(this,t))},e.prototype.sortBy=function(t,e){return yr(Wt(this,e,t))},e.prototype.map=function(t,e){var r=this;return this.withMutations((function(n){n.forEach((function(i,o){n.set(o,t.call(e,i,o,r))}))}))},e.prototype.__iterator=function(t,e){return new Pe(this,t,e)},e.prototype.__iterate=function(t,e){var r=this,n=0;return this._root&&this._root.iterate((function(e){return n++,t(e[1],e[0],r)}),e),n},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?He(this.size,this._root,t,this.__hash):0===this.size?Je():(this.__ownerID=t,this.__altered=!1,this)},e}(I);ke.isMap=at;var Re=ke.prototype;Re[st]=!0,Re[e]=Re.remove,Re.removeAll=Re.deleteAll,Re.setIn=le,Re.removeIn=Re.deleteIn=ye,Re.update=ge,Re.updateIn=we,Re.merge=Re.concat=me,Re.mergeWith=be,Re.mergeDeep=Oe,Re.mergeDeepWith=Ee,Re.mergeIn=je,Re.mergeDeepIn=qe,Re.withMutations=Me,Re.wasAltered=Ae,Re.asImmutable=xe,Re["@@transducer/init"]=Re.asMutable=De,Re["@@transducer/step"]=function(t,e){return t.set(e[0],e[1])},Re["@@transducer/result"]=function(t){return t.asImmutable()};var Ue=function(t,e){this.ownerID=t,this.entries=e};Ue.prototype.get=function(t,e,r,n){for(var i=this.entries,o=0,u=i.length;o=Ze)return function(t,e,r,n){t||(t=new s);for(var i=new Le(t,vt(r),[r,n]),o=0;o>>t)&i),s=this.bitmap;return 0==(s&u)?o:this.nodes[Fe(s&u-1)].get(t+r,e,n,o)},Te.prototype.update=function(t,e,u,s,a,c,f){void 0===u&&(u=vt(s));var h=(0===e?u:u>>>e)&i,p=1<=$e)return function(t,e,r,i,o){for(var u=0,s=new Array(n),a=0;0!==r;a++,r>>>=1)s[a]=1&r?e[u++]:void 0;return s[i]=o,new Be(t,u+1,s)}(t,y,_,h,g);if(l&&!g&&2===y.length&&Qe(y[1^v]))return y[1^v];if(l&&g&&1===y.length&&Qe(g))return g;var w=t&&t===this.ownerID,m=l?g?_:_^p:_|p,b=l?g?Ge(y,v,g,w):function(t,e,r){var n=t.length-1;if(r&&e===n)return t.pop(),t;for(var i=new Array(n),o=0,u=0;u>>t)&i,s=this.nodes[u];return s?s.get(t+r,e,n,o):o},Be.prototype.update=function(t,e,n,u,s,a,c){void 0===n&&(n=vt(u));var f=(0===e?n:n>>>e)&i,h=s===o,p=this.nodes,_=p[f];if(h&&!_)return this;var l=Ye(_,t,e+r,n,u,s,a,c);if(l===_)return this;var v=this.count;if(_){if(!l&&--v>>n)&i,c=(0===n?o:o>>>n)&i,f=a===c?[Xe(t,e,n+r,o,u)]:(s=new Le(e,o,u),a>1&1431655765))+(t>>2&858993459))+(t>>4)&252645135,t+=t>>8,127&(t+=t>>16)}function Ge(t,e,r,n){var i=n?t:Zt(t);return i[e]=r,i}var Ze=n/4,$e=n/2,tr=n/4,er="@@__IMMUTABLE_LIST__@@";function rr(t){return Boolean(t&&t[er])}var nr=function(t){function e(e){var i=cr();if(null==e)return i;if(rr(e))return e;var o=t(e),u=o.size;return 0===u?i:(te(u),u>0&&u=0&&t=t.size||e<0)return t.withMutations((function(t){e<0?_r(t,e).set(0,r):_r(t,0,e+1).set(e,r)}));e+=t._origin;var n=t._tail,i=t._root,o={value:!1};e>=lr(t._capacity)?n=fr(n,t.__ownerID,0,e,r,o):i=fr(i,t.__ownerID,t._level,e,r,o);if(!o.value)return t;if(t.__ownerID)return t._root=i,t._tail=n,t.__hash=void 0,t.__altered=!0,t;return ar(t._origin,t._capacity,t._level,i,n)}(this,t,e)},e.prototype.remove=function(t){return this.has(t)?0===t?this.shift():t===this.size-1?this.pop():this.splice(t,1):this},e.prototype.insert=function(t,e){return this.splice(t,0,e)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=this._origin=this._capacity=0,this._level=r,this._root=this._tail=this.__hash=void 0,this.__altered=!0,this):cr()},e.prototype.push=function(){var t=arguments,e=this.size;return this.withMutations((function(r){_r(r,0,e+t.length);for(var n=0;n>>e&i;if(o>=this.array.length)return new or([],t);var u,s=0===o;if(e>0){var a=this.array[o];if((u=a&&a.removeBefore(t,e-r,n))===a&&s)return this}if(s&&!u)return this;var c=hr(this,t);if(!s)for(var f=0;f>>e&i;if(s>=this.array.length)return this;if(e>0){var a=this.array[s];if((u=a&&a.removeAfter(t,e-r,o))===a&&s===this.array.length-1)return this}var c=hr(this,t);return c.array.splice(s+1),u&&(c.array[s]=u),c};var ur={};function sr(t,e){var i=t._origin,o=t._capacity,u=lr(o),s=t._tail;return a(t._root,t._level,0);function a(t,c,f){return 0===c?function(t,r){var a=r===u?s&&s.array:t&&t.array,c=r>i?0:i-r,f=o-r;f>n&&(f=n);return function(){if(c===f)return ur;var t=e?--f:c++;return a&&a[t]}}(t,f):function(t,u,s){var c,f=t&&t.array,h=s>i?0:i-s>>u,p=1+(o-s>>u);p>n&&(p=n);return function(){for(;;){if(c){var t=c();if(t!==ur)return t;c=null}if(h===p)return ur;var n=e?--p:h++;c=a(f&&f[n],u-r,s+(n<>>n&i,h=t&&f0){var p=t&&t.array[f],_=fr(p,e,n-r,o,s,a);return _===p?t:((c=hr(t,e)).array[f]=_,c)}return h&&t.array[f]===s?t:(a&&u(a),c=hr(t,e),void 0===s&&f===c.array.length-1?c.array.pop():c.array[f]=s,c)}function hr(t,e){return e&&t&&e===t.ownerID?t:new or(t?t.array.slice():[],e)}function pr(t,e){if(e>=lr(t._capacity))return t._tail;if(e<1<0;)n=n.array[e>>>o&i],o-=r;return n}}function _r(t,e,n){void 0!==e&&(e|=0),void 0!==n&&(n|=0);var o=t.__ownerID||new s,u=t._origin,a=t._capacity,c=u+e,f=void 0===n?a:n<0?a+n:u+n;if(c===u&&f===a)return t;if(c>=f)return t.clear();for(var h=t._level,p=t._root,_=0;c+_<0;)p=new or(p&&p.array.length?[void 0,p]:[],o),_+=1<<(h+=r);_&&(c+=_,u+=_,f+=_,a+=_);for(var l=lr(a),v=lr(f);v>=1<l?new or([],o):y;if(y&&v>l&&cr;w-=r){var m=l>>>w&i;g=g.array[m]=hr(g.array[m],o)}g.array[l>>>r&i]=y}if(f=v)c-=v,f-=v,h=r,p=null,d=d&&d.removeBefore(o,0,c);else if(c>u||v>>h&i;if(b!==v>>>h&i)break;b&&(_+=(1<u&&(p=p.removeBefore(o,h,c-_)),p&&v>>r<=n&&a.size>=2*s.size?(i=(u=a.filter((function(t,e){return void 0!==t&&c!==e}))).toKeyedSeq().map((function(t){return t[0]})).flip().toMap(),t.__ownerID&&(i.__ownerID=u.__ownerID=t.__ownerID)):(i=s.remove(e),u=c===a.size-1?a.pop():a.set(c,void 0))}else if(f){if(r===a.get(c)[1])return t;i=s,u=a.set(c,[e,r])}else i=s.set(e,a.size),u=a.set(a.size,[e,r]);return t.__ownerID?(t.size=i.size,t._map=i,t._list=u,t.__hash=void 0,t.__altered=!0,t):dr(i,u)}yr.isOrderedMap=ct,yr.prototype[A]=!0,yr.prototype[e]=yr.prototype.remove;var mr="@@__IMMUTABLE_STACK__@@";function br(t){return Boolean(t&&t[mr])}var zr=function(t){function e(t){return null==t?Er():br(t)?t:Er().pushAll(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("Stack [","]")},e.prototype.get=function(t,e){var r=this._head;for(t=c(this,t);r&&t--;)r=r.next;return r?r.value:e},e.prototype.peek=function(){return this._head&&this._head.value},e.prototype.push=function(){var t=arguments;if(0===arguments.length)return this;for(var e=this.size+arguments.length,r=this._head,n=arguments.length-1;n>=0;n--)r={value:t[n],next:r};return this.__ownerID?(this.size=e,this._head=r,this.__hash=void 0,this.__altered=!0,this):Or(e,r)},e.prototype.pushAll=function(e){if(0===(e=t(e)).size)return this;if(0===this.size&&br(e))return e;te(e.size);var r=this.size,n=this._head;return e.__iterate((function(t){r++,n={value:t,next:n}}),!0),this.__ownerID?(this.size=r,this._head=n,this.__hash=void 0,this.__altered=!0,this):Or(r,n)},e.prototype.pop=function(){return this.slice(1)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):Er()},e.prototype.slice=function(e,r){if(h(e,r,this.size))return this;var n=p(e,this.size);if(_(r,this.size)!==this.size)return t.prototype.slice.call(this,e,r);for(var i=this.size-n,o=this._head;n--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):Or(i,o)},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Or(this.size,this._head,t,this.__hash):0===this.size?Er():(this.__ownerID=t,this.__altered=!1,this)},e.prototype.__iterate=function(t,e){var r=this;if(e)return new $(this.toArray()).__iterate((function(e,n){return t(e,n,r)}),e);for(var n=0,i=this._head;i&&!1!==t(i.value,n++,this);)i=i.next;return n},e.prototype.__iterator=function(t,e){if(e)return new $(this.toArray()).__iterator(t,e);var r=0,n=this._head;return new C((function(){if(n){var e=n.value;return n=n.next,P(t,r++,e)}return{value:void 0,done:!0}}))},e}(O);zr.isStack=br;var Sr,Ir=zr.prototype;function Or(t,e,r,n){var i=Object.create(Ir);return i.size=t,i._head=e,i.__ownerID=r,i.__hash=n,i.__altered=!1,i}function Er(){return Sr||(Sr=Or(0))}Ir[mr]=!0,Ir.shift=Ir.pop,Ir.unshift=Ir.push,Ir.unshiftAll=Ir.pushAll,Ir.withMutations=Me,Ir.wasAltered=Ae,Ir.asImmutable=xe,Ir["@@transducer/init"]=Ir.asMutable=De,Ir["@@transducer/step"]=function(t,e){return t.unshift(e)},Ir["@@transducer/result"]=function(t){return t.asImmutable()};var jr="@@__IMMUTABLE_SET__@@";function qr(t){return Boolean(t&&t[jr])}function Mr(t){return qr(t)&&k(t)}function Dr(t,e){if(t===e)return!0;if(!d(e)||void 0!==t.size&&void 0!==e.size&&t.size!==e.size||void 0!==t.__hash&&void 0!==e.__hash&&t.__hash!==e.__hash||w(t)!==w(e)||b(t)!==b(e)||k(t)!==k(e))return!1;if(0===t.size&&0===e.size)return!0;var r=!z(t);if(k(t)){var n=t.entries();return e.every((function(t,e){var i=n.next().value;return i&&ht(i[1],t)&&(r||ht(i[0],e))}))&&n.next().done}var i=!1;if(void 0===t.size)if(void 0===e.size)"function"==typeof t.cacheResult&&t.cacheResult();else{i=!0;var u=t;t=e,e=u}var s=!0,a=e.__iterate((function(e,n){if(r?!t.has(e):i?!ht(e,t.get(n,o)):!ht(t.get(n,o),e))return s=!1,!1}));return s&&t.size===a}function xr(t,e){var r=function(r){t.prototype[r]=e[r]};return Object.keys(e).forEach(r),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(e).forEach(r),t}function Ar(t){if(!t||"object"!=typeof t)return t;if(!d(t)){if(!ie(t))return t;t=X(t)}if(w(t)){var e={};return t.__iterate((function(t,r){e[r]=Ar(t)})),e}var r=[];return t.__iterate((function(t){r.push(Ar(t))})),r}var kr=function(t){function e(e){return null==e?Kr():qr(e)&&!k(e)?e:Kr().withMutations((function(r){var n=t(e);te(n.size),n.forEach((function(t){return r.add(t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(I(t).keySeq())},e.intersect=function(t){return(t=S(t).toArray()).length?Ur.intersect.apply(e(t.pop()),t):Kr()},e.union=function(t){return(t=S(t).toArray()).length?Ur.union.apply(e(t.pop()),t):Kr()},e.prototype.toString=function(){return this.__toString("Set {","}")},e.prototype.has=function(t){return this._map.has(t)},e.prototype.add=function(t){return Tr(this,this._map.set(t,t))},e.prototype.remove=function(t){return Tr(this,this._map.remove(t))},e.prototype.clear=function(){return Tr(this,this._map.clear())},e.prototype.map=function(t,e){var r=this,n=!1,i=Tr(this,this._map.mapEntries((function(i){var o=i[1],u=t.call(e,o,o,r);return u!==o&&(n=!0),[u,u]}),e));return n?i:this},e.prototype.union=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return 0===(e=e.filter((function(t){return 0!==t.size}))).length?this:0!==this.size||this.__ownerID||1!==e.length?this.withMutations((function(r){for(var n=0;n=0&&e=0&&r>>-15,461845907),e=pt(e<<13|e>>>-13,5),e=pt((e=(e+3864292196|0)^t)^e>>>16,2246822507),e=_t((e=pt(e^e>>>13,3266489909))^e>>>16)}(t.size,n)}(this))}});var Jr=S.prototype;Jr[y]=!0,Jr[L]=Jr.values,Jr.toJSON=Jr.toArray,Jr.__toStringMapper=oe,Jr.inspect=Jr.toSource=function(){return this.toString()},Jr.chain=Jr.flatMap,Jr.contains=Jr.includes,xr(I,{flip:function(){return Vt(this,Rt(this))},mapEntries:function(t,e){var r=this,n=0;return Vt(this,this.toSeq().map((function(i,o){return t.call(e,[o,i],n++,r)})).fromEntrySeq())},mapKeys:function(t,e){var r=this;return Vt(this,this.toSeq().flip().map((function(n,i){return t.call(e,n,i,r)})).flip())}});var Vr=I.prototype;Vr[g]=!0,Vr[L]=Jr.entries,Vr.toJSON=Hr,Vr.__toStringMapper=function(t,e){return oe(e)+": "+oe(t)},xr(O,{toKeyedSeq:function(){return new Dt(this,!1)},filter:function(t,e){return Vt(this,Bt(this,t,e,!1))},findIndex:function(t,e){var r=this.findEntry(t,e);return r?r[0]:-1},indexOf:function(t){var e=this.keyOf(t);return void 0===e?-1:e},lastIndexOf:function(t){var e=this.lastKeyOf(t);return void 0===e?-1:e},reverse:function(){return Vt(this,Tt(this,!1))},slice:function(t,e){return Vt(this,Kt(this,t,e,!1))},splice:function(t,e){var r=arguments.length;if(e=Math.max(e||0,0),0===r||2===r&&!e)return this;t=p(t,t<0?this.count():this.size);var n=this.slice(0,t);return Vt(this,1===r?n:n.concat(Zt(arguments,2),this.slice(t+e)))},findLastIndex:function(t,e){var r=this.findLastEntry(t,e);return r?r[0]:-1},first:function(t){return this.get(0,t)},flatten:function(t){return Vt(this,Pt(this,t,!1))},get:function(t,e){return(t=c(this,t))<0||this.size===1/0||void 0!==this.size&&t>this.size?e:this.find((function(e,r){return r===t}),void 0,e)},has:function(t){return(t=c(this,t))>=0&&(void 0!==this.size?this.size===1/0||te?-1:0}function rn(t,e){return t^e+2654435769+(t<<6)+(t>>2)|0}Qr.has=Jr.includes,Qr.contains=Qr.includes,Qr.keys=Qr.values,xr(F,Vr),xr(G,Yr),xr(Z,Qr);var nn=function(t){function e(t){return null==t?an():Mr(t)?t:an().withMutations((function(e){var r=E(t);te(r.size),r.forEach((function(t){return e.add(t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(I(t).keySeq())},e.prototype.toString=function(){return this.__toString("OrderedSet {","}")},e}(kr);nn.isOrderedSet=Mr;var on,un=nn.prototype;function sn(t,e){var r=Object.create(un);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function an(){return on||(on=sn(gr()))}un[A]=!0,un.zip=Yr.zip,un.zipWith=Yr.zipWith,un.zipAll=Yr.zipAll,un.__empty=an,un.__make=sn;var cn=function(t,e){var r;!function(t){if(D(t))throw new Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(x(t))throw new Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(null===t||"object"!=typeof t)throw new Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}(t);var n=function(o){var u=this;if(o instanceof n)return o;if(!(this instanceof n))return new n(o);if(!r){r=!0;var s=Object.keys(t),a=i._indices={};i._name=e,i._keys=s,i._defaultValues=t;for(var c=0;c2?[]:void 0,{"":t})},t.get=se,t.getIn=Pr,t.has=ue,t.hasIn=Nr,t.hash=vt,t.is=ht,t.isAssociative=z,t.isCollection=d,t.isImmutable=x,t.isIndexed=b,t.isKeyed=w,t.isList=rr,t.isMap=at,t.isOrdered=k,t.isOrderedMap=ct,t.isOrderedSet=Mr,t.isPlainObject=ne,t.isRecord=D,t.isSeq=q,t.isSet=qr,t.isStack=br,t.isValueObject=ft,t.merge=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Ie(t,e)},t.mergeDeep=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Se(t,e)},t.mergeDeepWith=function(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];return Se(e,r,t)},t.mergeWith=function(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];return Ie(e,r,t)},t.remove=ce,t.removeIn=ve,t.set=fe,t.setIn=_e,t.update=de,t.updateIn=he,t.version="5.1.0"})); diff --git a/package.json b/package.json index 0eda1b7fa3..2db591e9b1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "immutable", - "version": "5.0.3", + "version": "5.1.0", "description": "Immutable Data Collections", "license": "MIT", "homepage": "https://immutable-js.com", From 9382db833af1dac82b636aa5b34c21b4b0ecdc33 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 26 Mar 2025 00:02:06 +0000 Subject: [PATCH 239/242] deploy: 829b2ee566bb8fe5e487b1593e2011d8058cf9c1 --- bower.json | 2 +- dist/{type-definitions => }/immutable.d.ts | 0 dist/immutable.es.js | 2 +- dist/immutable.js | 2 +- dist/{type-definitions => }/immutable.js.flow | 0 dist/immutable.min.js | 2 +- package.json | 2 +- 7 files changed, 5 insertions(+), 5 deletions(-) rename dist/{type-definitions => }/immutable.d.ts (100%) rename dist/{type-definitions => }/immutable.js.flow (100%) diff --git a/bower.json b/bower.json index 2db591e9b1..b43c22ad2c 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "immutable", - "version": "5.1.0", + "version": "5.1.1", "description": "Immutable Data Collections", "license": "MIT", "homepage": "https://immutable-js.com", diff --git a/dist/type-definitions/immutable.d.ts b/dist/immutable.d.ts similarity index 100% rename from dist/type-definitions/immutable.d.ts rename to dist/immutable.d.ts diff --git a/dist/immutable.es.js b/dist/immutable.es.js index c43edf507c..8cf8322ad7 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -6217,7 +6217,7 @@ function defaultConverter(k, v) { return isIndexed(v) ? v.toList() : isKeyed(v) ? v.toMap() : v.toSet(); } -var version = "5.1.0"; +var version = "5.1.1"; // Note: Iterable is deprecated var Iterable = Collection; diff --git a/dist/immutable.js b/dist/immutable.js index 49cf57d770..2c024cb937 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -6223,7 +6223,7 @@ return isIndexed(v) ? v.toList() : isKeyed(v) ? v.toMap() : v.toSet(); } - var version = "5.1.0"; + var version = "5.1.1"; // Note: Iterable is deprecated var Iterable = Collection; diff --git a/dist/type-definitions/immutable.js.flow b/dist/immutable.js.flow similarity index 100% rename from dist/type-definitions/immutable.js.flow rename to dist/immutable.js.flow diff --git a/dist/immutable.min.js b/dist/immutable.min.js index 78316346a8..91c0b317af 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -22,4 +22,4 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).Immutable={})}(this,(function(t){"use strict";var e="delete",r=5,n=1<>>0;if(""+r!==e||4294967295===r)return NaN;e=r}return e<0?a(t)+e:e}function f(){return!0}function h(t,e,r){return(0===t&&!v(t)||void 0!==r&&t<=-r)&&(void 0===e||void 0!==r&&e>=r)}function p(t,e){return l(t,e,0)}function _(t,e){return l(t,e,e)}function l(t,e,r){return void 0===t?r:v(t)?e===1/0?e:0|Math.max(0,e+t):void 0===e||e===t?t:0|Math.min(e,t)}function v(t){return t<0||0===t&&1/t==-1/0}var y="@@__IMMUTABLE_ITERABLE__@@";function d(t){return Boolean(t&&t[y])}var g="@@__IMMUTABLE_KEYED__@@";function w(t){return Boolean(t&&t[g])}var m="@@__IMMUTABLE_INDEXED__@@";function b(t){return Boolean(t&&t[m])}function z(t){return w(t)||b(t)}var S=function(t){return d(t)?t:X(t)},I=function(t){function e(t){return w(t)?t:F(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(S),O=function(t){function e(t){return b(t)?t:G(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(S),E=function(t){function e(t){return d(t)&&!z(t)?t:Z(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(S);S.Keyed=I,S.Indexed=O,S.Set=E;var j="@@__IMMUTABLE_SEQ__@@";function q(t){return Boolean(t&&t[j])}var M="@@__IMMUTABLE_RECORD__@@";function D(t){return Boolean(t&&t[M])}function x(t){return d(t)||D(t)}var A="@@__IMMUTABLE_ORDERED__@@";function k(t){return Boolean(t&&t[A])}var R=0,U=1,T=2,B="function"==typeof Symbol&&Symbol.iterator,K="@@iterator",L=B||K,C=function(t){this.next=t};function P(t,e,r,n){var i=t===R?e:t===U?r:[e,r];return n?n.value=i:n={value:i,done:!1},n}function W(){return{value:void 0,done:!0}}function N(t){return!!Array.isArray(t)||!!V(t)}function H(t){return t&&"function"==typeof t.next}function J(t){var e=V(t);return e&&e.call(t)}function V(t){var e=t&&(B&&t[B]||t[K]);if("function"==typeof e)return e}C.prototype.toString=function(){return"[Iterator]"},C.KEYS=R,C.VALUES=U,C.ENTRIES=T,C.prototype.inspect=C.prototype.toSource=function(){return this.toString()},C.prototype[L]=function(){return this};var Y=Object.prototype.hasOwnProperty;function Q(t){return!(!Array.isArray(t)&&"string"!=typeof t)||t&&"object"==typeof t&&Number.isInteger(t.length)&&t.length>=0&&(0===t.length?1===Object.keys(t).length:t.hasOwnProperty(t.length-1))}var X=function(t){function e(t){return null==t?nt():x(t)?t.toSeq():function(t){var e=ut(t);if(e)return(n=V(r=t))&&n===r.entries?e.fromEntrySeq():function(t){var e=V(t);return e&&e===t.keys}(t)?e.toSetSeq():e;var r,n;if("object"==typeof t)return new tt(t);throw new TypeError("Expected Array or collection object of values, or keyed object: "+t)}(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq {","}")},e.prototype.cacheResult=function(){return!this._cache&&this.__iterateUncached&&(this._cache=this.entrySeq().toArray(),this.size=this._cache.length),this},e.prototype.__iterate=function(t,e){var r=this._cache;if(r){for(var n=r.length,i=0;i!==n;){var o=r[e?n-++i:i++];if(!1===t(o[1],o[0],this))break}return i}return this.__iterateUncached(t,e)},e.prototype.__iterator=function(t,e){var r=this._cache;if(r){var n=r.length,i=0;return new C((function(){if(i===n)return{value:void 0,done:!0};var o=r[e?n-++i:i++];return P(t,o[0],o[1])}))}return this.__iteratorUncached(t,e)},e}(S),F=function(t){function e(t){return null==t?nt().toKeyedSeq():d(t)?w(t)?t.toSeq():t.fromEntrySeq():D(t)?t.toSeq():it(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toKeyedSeq=function(){return this},e}(X),G=function(t){function e(t){return null==t?nt():d(t)?w(t)?t.entrySeq():t.toIndexedSeq():D(t)?t.toSeq().entrySeq():ot(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return e(arguments)},e.prototype.toIndexedSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq [","]")},e}(X),Z=function(t){function e(t){return(d(t)&&!z(t)?t:G(t)).toSetSeq()}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return e(arguments)},e.prototype.toSetSeq=function(){return this},e}(X);X.isSeq=q,X.Keyed=F,X.Set=Z,X.Indexed=G,X.prototype[j]=!0;var $=function(t){function e(t){this._array=t,this.size=t.length}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t,e){return this.has(t)?this._array[c(this,t)]:e},e.prototype.__iterate=function(t,e){for(var r=this._array,n=r.length,i=0;i!==n;){var o=e?n-++i:i++;if(!1===t(r[o],o,this))break}return i},e.prototype.__iterator=function(t,e){var r=this._array,n=r.length,i=0;return new C((function(){if(i===n)return{value:void 0,done:!0};var o=e?n-++i:i++;return P(t,o,r[o])}))},e}(G),tt=function(t){function e(t){var e=Object.keys(t).concat(Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(t):[]);this._object=t,this._keys=e,this.size=e.length}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t,e){return void 0===e||this.has(t)?this._object[t]:e},e.prototype.has=function(t){return Y.call(this._object,t)},e.prototype.__iterate=function(t,e){for(var r=this._object,n=this._keys,i=n.length,o=0;o!==i;){var u=n[e?i-++o:o++];if(!1===t(r[u],u,this))break}return o},e.prototype.__iterator=function(t,e){var r=this._object,n=this._keys,i=n.length,o=0;return new C((function(){if(o===i)return{value:void 0,done:!0};var u=n[e?i-++o:o++];return P(t,u,r[u])}))},e}(F);tt.prototype[A]=!0;var et,rt=function(t){function e(t){this._collection=t,this.size=t.length||t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.__iterateUncached=function(t,e){if(e)return this.cacheResult().__iterate(t,e);var r=J(this._collection),n=0;if(H(r))for(var i;!(i=r.next()).done&&!1!==t(i.value,n++,this););return n},e.prototype.__iteratorUncached=function(t,e){if(e)return this.cacheResult().__iterator(t,e);var r=J(this._collection);if(!H(r))return new C(W);var n=0;return new C((function(){var e=r.next();return e.done?e:P(t,n++,e.value)}))},e}(G);function nt(){return et||(et=new $([]))}function it(t){var e=ut(t);if(e)return e.fromEntrySeq();if("object"==typeof t)return new tt(t);throw new TypeError("Expected Array or collection object of [k, v] entries, or keyed object: "+t)}function ot(t){var e=ut(t);if(e)return e;throw new TypeError("Expected Array or collection object of values: "+t)}function ut(t){return Q(t)?new $(t):N(t)?new rt(t):void 0}var st="@@__IMMUTABLE_MAP__@@";function at(t){return Boolean(t&&t[st])}function ct(t){return at(t)&&k(t)}function ft(t){return Boolean(t&&"function"==typeof t.equals&&"function"==typeof t.hashCode)}function ht(t,e){if(t===e||t!=t&&e!=e)return!0;if(!t||!e)return!1;if("function"==typeof t.valueOf&&"function"==typeof e.valueOf){if((t=t.valueOf())===(e=e.valueOf())||t!=t&&e!=e)return!0;if(!t||!e)return!1}return!!(ft(t)&&ft(e)&&t.equals(e))}var pt="function"==typeof Math.imul&&-2===Math.imul(4294967295,2)?Math.imul:function(t,e){var r=65535&(t|=0),n=65535&(e|=0);return r*n+((t>>>16)*n+r*(e>>>16)<<16>>>0)|0};function _t(t){return t>>>1&1073741824|3221225471&t}var lt=Object.prototype.valueOf;function vt(t){if(null==t)return yt(t);if("function"==typeof t.hashCode)return _t(t.hashCode(t));var e,r=(e=t).valueOf!==lt&&"function"==typeof e.valueOf?e.valueOf(e):e;if(null==r)return yt(r);switch(typeof r){case"boolean":return r?1108378657:1108378656;case"number":return function(t){if(t!=t||t===1/0)return 0;var e=0|t;e!==t&&(e^=4294967295*t);for(;t>4294967295;)e^=t/=4294967295;return _t(e)}(r);case"string":return r.length>Et?function(t){var e=Mt[t];void 0===e&&(e=dt(t),qt===jt&&(qt=0,Mt={}),qt++,Mt[t]=e);return e}(r):dt(r);case"object":case"function":return function(t){var e;if(zt&&void 0!==(e=bt.get(t)))return e;if(e=t[Ot],void 0!==e)return e;if(!wt){if(void 0!==(e=t.propertyIsEnumerable&&t.propertyIsEnumerable[Ot]))return e;if(void 0!==(e=function(t){if(t&&t.nodeType>0)switch(t.nodeType){case 1:return t.uniqueID;case 9:return t.documentElement&&t.documentElement.uniqueID}}(t)))return e}if(e=mt(),zt)bt.set(t,e);else{if(void 0!==gt&&!1===gt(t))throw new Error("Non-extensible objects are not allowed as keys.");if(wt)Object.defineProperty(t,Ot,{enumerable:!1,configurable:!1,writable:!1,value:e});else if(void 0!==t.propertyIsEnumerable&&t.propertyIsEnumerable===t.constructor.prototype.propertyIsEnumerable)t.propertyIsEnumerable=function(){return this.constructor.prototype.propertyIsEnumerable.apply(this,arguments)},t.propertyIsEnumerable[Ot]=e;else{if(void 0===t.nodeType)throw new Error("Unable to set a non-enumerable property on object.");t[Ot]=e}}return e}(r);case"symbol":return function(t){var e=St[t];if(void 0!==e)return e;return e=mt(),St[t]=e,e}(r);default:if("function"==typeof r.toString)return dt(r.toString());throw new Error("Value type "+typeof r+" cannot be hashed.")}}function yt(t){return null===t?1108378658:1108378659}function dt(t){for(var e=0,r=0;r=0&&(a.get=function(e,r){return(e=c(this,e))>=0&&eo)return{value:void 0,done:!0};var t=i.next();return n||e===U||t.done?t:P(e,a-1,e===R?void 0:t.value[1],t)}))},a}function Lt(t,e,r,n){var i=Xt(t);return i.__iterateUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterate(i,o);var s=!0,a=0;return t.__iterate((function(t,o,c){if(!s||!(s=e.call(r,t,o,c)))return a++,i(t,n?o:a-1,u)})),a},i.__iteratorUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterator(i,o);var s=t.__iterator(T,o),a=!0,c=0;return new C((function(){var t,o,f;do{if((t=s.next()).done)return n||i===U?t:P(i,c++,i===R?void 0:t.value[1],t);var h=t.value;o=h[0],f=h[1],a&&(a=e.call(r,f,o,u))}while(a);return i===T?t:P(i,o,f,t)}))},i}xt.prototype.cacheResult=Dt.prototype.cacheResult=At.prototype.cacheResult=kt.prototype.cacheResult=Ft;var Ct=function(t){function e(t){this._wrappedIterables=t.flatMap((function(t){return t._wrappedIterables?t._wrappedIterables:[t]})),this.size=this._wrappedIterables.reduce((function(t,e){if(void 0!==t){var r=e.size;if(void 0!==r)return t+r}}),0),this[g]=this._wrappedIterables[0][g],this[m]=this._wrappedIterables[0][m],this[A]=this._wrappedIterables[0][A]}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.__iterateUncached=function(t,e){if(0!==this._wrappedIterables.length){if(e)return this.cacheResult().__iterate(t,e);for(var r=0,n=w(this),i=n?T:U,o=this._wrappedIterables[r].__iterator(i,e),u=!0,s=0;u;){for(var a=o.next();a.done;){if(++r===this._wrappedIterables.length)return s;a=(o=this._wrappedIterables[r].__iterator(i,e)).next()}u=!1!==(n?t(a.value[1],a.value[0],this):t(a.value,s,this)),s++}return s}},e.prototype.__iteratorUncached=function(t,e){var r=this;if(0===this._wrappedIterables.length)return new C(W);if(e)return this.cacheResult().__iterator(t,e);var n=0,i=this._wrappedIterables[n].__iterator(t,e);return new C((function(){for(var o=i.next();o.done;){if(++n===r._wrappedIterables.length)return o;o=(i=r._wrappedIterables[n].__iterator(t,e)).next()}return o}))},e}(X);function Pt(t,e,r){var n=Xt(t);return n.__iterateUncached=function(i,o){if(o)return this.cacheResult().__iterate(i,o);var u=0,s=!1;return function t(a,c){a.__iterate((function(o,a){return(!e||c0}function Jt(t,e,r,n){var i=Xt(t),o=new $(r).map((function(t){return t.size}));return i.size=n?o.max():o.min(),i.__iterate=function(t,e){for(var r,n=this.__iterator(U,e),i=0;!(r=n.next()).done&&!1!==t(r.value,i++,this););return i},i.__iteratorUncached=function(t,i){var o=r.map((function(t){return t=S(t),J(i?t.reverse():t)})),u=0,s=!1;return new C((function(){var r;return s||(r=o.map((function(t){return t.next()})),s=n?r.every((function(t){return t.done})):r.some((function(t){return t.done}))),s?{value:void 0,done:!0}:P(t,u++,e.apply(null,r.map((function(t){return t.value}))))}))},i}function Vt(t,e){return t===e?t:q(t)?e:t.constructor(e)}function Yt(t){if(t!==Object(t))throw new TypeError("Expected [K, V] tuple: "+t)}function Qt(t){return w(t)?I:b(t)?O:E}function Xt(t){return Object.create((w(t)?F:b(t)?G:Z).prototype)}function Ft(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size,this):X.prototype.cacheResult.call(this)}function Gt(t,e){return void 0===t&&void 0===e?0:void 0===t?1:void 0===e?-1:t>e?1:t0;)e[r]=arguments[r+1];if("function"!=typeof t)throw new TypeError("Invalid merger function: "+t);return ze(this,e,t)}function ze(t,e,r){for(var n=[],i=0;i0;)e[r]=arguments[r+1];return Se(this,e,t)}function je(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return he(this,t,Je(),(function(t){return Ie(t,e)}))}function qe(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return he(this,t,Je(),(function(t){return Se(t,e)}))}function Me(t){var e=this.asMutable();return t(e),e.wasAltered()?e.__ensureOwner(this.__ownerID):this}function De(){return this.__ownerID?this:this.__ensureOwner(new s)}function xe(){return this.__ensureOwner()}function Ae(){return this.__altered}var ke=function(t){function e(e){return null==e?Je():at(e)&&!k(e)?e:Je().withMutations((function(r){var n=t(e);te(n.size),n.forEach((function(t,e){return r.set(e,t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toString=function(){return this.__toString("Map {","}")},e.prototype.get=function(t,e){return this._root?this._root.get(0,void 0,t,e):e},e.prototype.set=function(t,e){return Ve(this,t,e)},e.prototype.remove=function(t){return Ve(this,t,o)},e.prototype.deleteAll=function(t){var e=S(t);return 0===e.size?this:this.withMutations((function(t){e.forEach((function(e){return t.remove(e)}))}))},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):Je()},e.prototype.sort=function(t){return yr(Wt(this,t))},e.prototype.sortBy=function(t,e){return yr(Wt(this,e,t))},e.prototype.map=function(t,e){var r=this;return this.withMutations((function(n){n.forEach((function(i,o){n.set(o,t.call(e,i,o,r))}))}))},e.prototype.__iterator=function(t,e){return new Pe(this,t,e)},e.prototype.__iterate=function(t,e){var r=this,n=0;return this._root&&this._root.iterate((function(e){return n++,t(e[1],e[0],r)}),e),n},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?He(this.size,this._root,t,this.__hash):0===this.size?Je():(this.__ownerID=t,this.__altered=!1,this)},e}(I);ke.isMap=at;var Re=ke.prototype;Re[st]=!0,Re[e]=Re.remove,Re.removeAll=Re.deleteAll,Re.setIn=le,Re.removeIn=Re.deleteIn=ye,Re.update=ge,Re.updateIn=we,Re.merge=Re.concat=me,Re.mergeWith=be,Re.mergeDeep=Oe,Re.mergeDeepWith=Ee,Re.mergeIn=je,Re.mergeDeepIn=qe,Re.withMutations=Me,Re.wasAltered=Ae,Re.asImmutable=xe,Re["@@transducer/init"]=Re.asMutable=De,Re["@@transducer/step"]=function(t,e){return t.set(e[0],e[1])},Re["@@transducer/result"]=function(t){return t.asImmutable()};var Ue=function(t,e){this.ownerID=t,this.entries=e};Ue.prototype.get=function(t,e,r,n){for(var i=this.entries,o=0,u=i.length;o=Ze)return function(t,e,r,n){t||(t=new s);for(var i=new Le(t,vt(r),[r,n]),o=0;o>>t)&i),s=this.bitmap;return 0==(s&u)?o:this.nodes[Fe(s&u-1)].get(t+r,e,n,o)},Te.prototype.update=function(t,e,u,s,a,c,f){void 0===u&&(u=vt(s));var h=(0===e?u:u>>>e)&i,p=1<=$e)return function(t,e,r,i,o){for(var u=0,s=new Array(n),a=0;0!==r;a++,r>>>=1)s[a]=1&r?e[u++]:void 0;return s[i]=o,new Be(t,u+1,s)}(t,y,_,h,g);if(l&&!g&&2===y.length&&Qe(y[1^v]))return y[1^v];if(l&&g&&1===y.length&&Qe(g))return g;var w=t&&t===this.ownerID,m=l?g?_:_^p:_|p,b=l?g?Ge(y,v,g,w):function(t,e,r){var n=t.length-1;if(r&&e===n)return t.pop(),t;for(var i=new Array(n),o=0,u=0;u>>t)&i,s=this.nodes[u];return s?s.get(t+r,e,n,o):o},Be.prototype.update=function(t,e,n,u,s,a,c){void 0===n&&(n=vt(u));var f=(0===e?n:n>>>e)&i,h=s===o,p=this.nodes,_=p[f];if(h&&!_)return this;var l=Ye(_,t,e+r,n,u,s,a,c);if(l===_)return this;var v=this.count;if(_){if(!l&&--v>>n)&i,c=(0===n?o:o>>>n)&i,f=a===c?[Xe(t,e,n+r,o,u)]:(s=new Le(e,o,u),a>1&1431655765))+(t>>2&858993459))+(t>>4)&252645135,t+=t>>8,127&(t+=t>>16)}function Ge(t,e,r,n){var i=n?t:Zt(t);return i[e]=r,i}var Ze=n/4,$e=n/2,tr=n/4,er="@@__IMMUTABLE_LIST__@@";function rr(t){return Boolean(t&&t[er])}var nr=function(t){function e(e){var i=cr();if(null==e)return i;if(rr(e))return e;var o=t(e),u=o.size;return 0===u?i:(te(u),u>0&&u=0&&t=t.size||e<0)return t.withMutations((function(t){e<0?_r(t,e).set(0,r):_r(t,0,e+1).set(e,r)}));e+=t._origin;var n=t._tail,i=t._root,o={value:!1};e>=lr(t._capacity)?n=fr(n,t.__ownerID,0,e,r,o):i=fr(i,t.__ownerID,t._level,e,r,o);if(!o.value)return t;if(t.__ownerID)return t._root=i,t._tail=n,t.__hash=void 0,t.__altered=!0,t;return ar(t._origin,t._capacity,t._level,i,n)}(this,t,e)},e.prototype.remove=function(t){return this.has(t)?0===t?this.shift():t===this.size-1?this.pop():this.splice(t,1):this},e.prototype.insert=function(t,e){return this.splice(t,0,e)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=this._origin=this._capacity=0,this._level=r,this._root=this._tail=this.__hash=void 0,this.__altered=!0,this):cr()},e.prototype.push=function(){var t=arguments,e=this.size;return this.withMutations((function(r){_r(r,0,e+t.length);for(var n=0;n>>e&i;if(o>=this.array.length)return new or([],t);var u,s=0===o;if(e>0){var a=this.array[o];if((u=a&&a.removeBefore(t,e-r,n))===a&&s)return this}if(s&&!u)return this;var c=hr(this,t);if(!s)for(var f=0;f>>e&i;if(s>=this.array.length)return this;if(e>0){var a=this.array[s];if((u=a&&a.removeAfter(t,e-r,o))===a&&s===this.array.length-1)return this}var c=hr(this,t);return c.array.splice(s+1),u&&(c.array[s]=u),c};var ur={};function sr(t,e){var i=t._origin,o=t._capacity,u=lr(o),s=t._tail;return a(t._root,t._level,0);function a(t,c,f){return 0===c?function(t,r){var a=r===u?s&&s.array:t&&t.array,c=r>i?0:i-r,f=o-r;f>n&&(f=n);return function(){if(c===f)return ur;var t=e?--f:c++;return a&&a[t]}}(t,f):function(t,u,s){var c,f=t&&t.array,h=s>i?0:i-s>>u,p=1+(o-s>>u);p>n&&(p=n);return function(){for(;;){if(c){var t=c();if(t!==ur)return t;c=null}if(h===p)return ur;var n=e?--p:h++;c=a(f&&f[n],u-r,s+(n<>>n&i,h=t&&f0){var p=t&&t.array[f],_=fr(p,e,n-r,o,s,a);return _===p?t:((c=hr(t,e)).array[f]=_,c)}return h&&t.array[f]===s?t:(a&&u(a),c=hr(t,e),void 0===s&&f===c.array.length-1?c.array.pop():c.array[f]=s,c)}function hr(t,e){return e&&t&&e===t.ownerID?t:new or(t?t.array.slice():[],e)}function pr(t,e){if(e>=lr(t._capacity))return t._tail;if(e<1<0;)n=n.array[e>>>o&i],o-=r;return n}}function _r(t,e,n){void 0!==e&&(e|=0),void 0!==n&&(n|=0);var o=t.__ownerID||new s,u=t._origin,a=t._capacity,c=u+e,f=void 0===n?a:n<0?a+n:u+n;if(c===u&&f===a)return t;if(c>=f)return t.clear();for(var h=t._level,p=t._root,_=0;c+_<0;)p=new or(p&&p.array.length?[void 0,p]:[],o),_+=1<<(h+=r);_&&(c+=_,u+=_,f+=_,a+=_);for(var l=lr(a),v=lr(f);v>=1<l?new or([],o):y;if(y&&v>l&&cr;w-=r){var m=l>>>w&i;g=g.array[m]=hr(g.array[m],o)}g.array[l>>>r&i]=y}if(f=v)c-=v,f-=v,h=r,p=null,d=d&&d.removeBefore(o,0,c);else if(c>u||v>>h&i;if(b!==v>>>h&i)break;b&&(_+=(1<u&&(p=p.removeBefore(o,h,c-_)),p&&v>>r<=n&&a.size>=2*s.size?(i=(u=a.filter((function(t,e){return void 0!==t&&c!==e}))).toKeyedSeq().map((function(t){return t[0]})).flip().toMap(),t.__ownerID&&(i.__ownerID=u.__ownerID=t.__ownerID)):(i=s.remove(e),u=c===a.size-1?a.pop():a.set(c,void 0))}else if(f){if(r===a.get(c)[1])return t;i=s,u=a.set(c,[e,r])}else i=s.set(e,a.size),u=a.set(a.size,[e,r]);return t.__ownerID?(t.size=i.size,t._map=i,t._list=u,t.__hash=void 0,t.__altered=!0,t):dr(i,u)}yr.isOrderedMap=ct,yr.prototype[A]=!0,yr.prototype[e]=yr.prototype.remove;var mr="@@__IMMUTABLE_STACK__@@";function br(t){return Boolean(t&&t[mr])}var zr=function(t){function e(t){return null==t?Er():br(t)?t:Er().pushAll(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("Stack [","]")},e.prototype.get=function(t,e){var r=this._head;for(t=c(this,t);r&&t--;)r=r.next;return r?r.value:e},e.prototype.peek=function(){return this._head&&this._head.value},e.prototype.push=function(){var t=arguments;if(0===arguments.length)return this;for(var e=this.size+arguments.length,r=this._head,n=arguments.length-1;n>=0;n--)r={value:t[n],next:r};return this.__ownerID?(this.size=e,this._head=r,this.__hash=void 0,this.__altered=!0,this):Or(e,r)},e.prototype.pushAll=function(e){if(0===(e=t(e)).size)return this;if(0===this.size&&br(e))return e;te(e.size);var r=this.size,n=this._head;return e.__iterate((function(t){r++,n={value:t,next:n}}),!0),this.__ownerID?(this.size=r,this._head=n,this.__hash=void 0,this.__altered=!0,this):Or(r,n)},e.prototype.pop=function(){return this.slice(1)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):Er()},e.prototype.slice=function(e,r){if(h(e,r,this.size))return this;var n=p(e,this.size);if(_(r,this.size)!==this.size)return t.prototype.slice.call(this,e,r);for(var i=this.size-n,o=this._head;n--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):Or(i,o)},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Or(this.size,this._head,t,this.__hash):0===this.size?Er():(this.__ownerID=t,this.__altered=!1,this)},e.prototype.__iterate=function(t,e){var r=this;if(e)return new $(this.toArray()).__iterate((function(e,n){return t(e,n,r)}),e);for(var n=0,i=this._head;i&&!1!==t(i.value,n++,this);)i=i.next;return n},e.prototype.__iterator=function(t,e){if(e)return new $(this.toArray()).__iterator(t,e);var r=0,n=this._head;return new C((function(){if(n){var e=n.value;return n=n.next,P(t,r++,e)}return{value:void 0,done:!0}}))},e}(O);zr.isStack=br;var Sr,Ir=zr.prototype;function Or(t,e,r,n){var i=Object.create(Ir);return i.size=t,i._head=e,i.__ownerID=r,i.__hash=n,i.__altered=!1,i}function Er(){return Sr||(Sr=Or(0))}Ir[mr]=!0,Ir.shift=Ir.pop,Ir.unshift=Ir.push,Ir.unshiftAll=Ir.pushAll,Ir.withMutations=Me,Ir.wasAltered=Ae,Ir.asImmutable=xe,Ir["@@transducer/init"]=Ir.asMutable=De,Ir["@@transducer/step"]=function(t,e){return t.unshift(e)},Ir["@@transducer/result"]=function(t){return t.asImmutable()};var jr="@@__IMMUTABLE_SET__@@";function qr(t){return Boolean(t&&t[jr])}function Mr(t){return qr(t)&&k(t)}function Dr(t,e){if(t===e)return!0;if(!d(e)||void 0!==t.size&&void 0!==e.size&&t.size!==e.size||void 0!==t.__hash&&void 0!==e.__hash&&t.__hash!==e.__hash||w(t)!==w(e)||b(t)!==b(e)||k(t)!==k(e))return!1;if(0===t.size&&0===e.size)return!0;var r=!z(t);if(k(t)){var n=t.entries();return e.every((function(t,e){var i=n.next().value;return i&&ht(i[1],t)&&(r||ht(i[0],e))}))&&n.next().done}var i=!1;if(void 0===t.size)if(void 0===e.size)"function"==typeof t.cacheResult&&t.cacheResult();else{i=!0;var u=t;t=e,e=u}var s=!0,a=e.__iterate((function(e,n){if(r?!t.has(e):i?!ht(e,t.get(n,o)):!ht(t.get(n,o),e))return s=!1,!1}));return s&&t.size===a}function xr(t,e){var r=function(r){t.prototype[r]=e[r]};return Object.keys(e).forEach(r),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(e).forEach(r),t}function Ar(t){if(!t||"object"!=typeof t)return t;if(!d(t)){if(!ie(t))return t;t=X(t)}if(w(t)){var e={};return t.__iterate((function(t,r){e[r]=Ar(t)})),e}var r=[];return t.__iterate((function(t){r.push(Ar(t))})),r}var kr=function(t){function e(e){return null==e?Kr():qr(e)&&!k(e)?e:Kr().withMutations((function(r){var n=t(e);te(n.size),n.forEach((function(t){return r.add(t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(I(t).keySeq())},e.intersect=function(t){return(t=S(t).toArray()).length?Ur.intersect.apply(e(t.pop()),t):Kr()},e.union=function(t){return(t=S(t).toArray()).length?Ur.union.apply(e(t.pop()),t):Kr()},e.prototype.toString=function(){return this.__toString("Set {","}")},e.prototype.has=function(t){return this._map.has(t)},e.prototype.add=function(t){return Tr(this,this._map.set(t,t))},e.prototype.remove=function(t){return Tr(this,this._map.remove(t))},e.prototype.clear=function(){return Tr(this,this._map.clear())},e.prototype.map=function(t,e){var r=this,n=!1,i=Tr(this,this._map.mapEntries((function(i){var o=i[1],u=t.call(e,o,o,r);return u!==o&&(n=!0),[u,u]}),e));return n?i:this},e.prototype.union=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return 0===(e=e.filter((function(t){return 0!==t.size}))).length?this:0!==this.size||this.__ownerID||1!==e.length?this.withMutations((function(r){for(var n=0;n=0&&e=0&&r>>-15,461845907),e=pt(e<<13|e>>>-13,5),e=pt((e=(e+3864292196|0)^t)^e>>>16,2246822507),e=_t((e=pt(e^e>>>13,3266489909))^e>>>16)}(t.size,n)}(this))}});var Jr=S.prototype;Jr[y]=!0,Jr[L]=Jr.values,Jr.toJSON=Jr.toArray,Jr.__toStringMapper=oe,Jr.inspect=Jr.toSource=function(){return this.toString()},Jr.chain=Jr.flatMap,Jr.contains=Jr.includes,xr(I,{flip:function(){return Vt(this,Rt(this))},mapEntries:function(t,e){var r=this,n=0;return Vt(this,this.toSeq().map((function(i,o){return t.call(e,[o,i],n++,r)})).fromEntrySeq())},mapKeys:function(t,e){var r=this;return Vt(this,this.toSeq().flip().map((function(n,i){return t.call(e,n,i,r)})).flip())}});var Vr=I.prototype;Vr[g]=!0,Vr[L]=Jr.entries,Vr.toJSON=Hr,Vr.__toStringMapper=function(t,e){return oe(e)+": "+oe(t)},xr(O,{toKeyedSeq:function(){return new Dt(this,!1)},filter:function(t,e){return Vt(this,Bt(this,t,e,!1))},findIndex:function(t,e){var r=this.findEntry(t,e);return r?r[0]:-1},indexOf:function(t){var e=this.keyOf(t);return void 0===e?-1:e},lastIndexOf:function(t){var e=this.lastKeyOf(t);return void 0===e?-1:e},reverse:function(){return Vt(this,Tt(this,!1))},slice:function(t,e){return Vt(this,Kt(this,t,e,!1))},splice:function(t,e){var r=arguments.length;if(e=Math.max(e||0,0),0===r||2===r&&!e)return this;t=p(t,t<0?this.count():this.size);var n=this.slice(0,t);return Vt(this,1===r?n:n.concat(Zt(arguments,2),this.slice(t+e)))},findLastIndex:function(t,e){var r=this.findLastEntry(t,e);return r?r[0]:-1},first:function(t){return this.get(0,t)},flatten:function(t){return Vt(this,Pt(this,t,!1))},get:function(t,e){return(t=c(this,t))<0||this.size===1/0||void 0!==this.size&&t>this.size?e:this.find((function(e,r){return r===t}),void 0,e)},has:function(t){return(t=c(this,t))>=0&&(void 0!==this.size?this.size===1/0||te?-1:0}function rn(t,e){return t^e+2654435769+(t<<6)+(t>>2)|0}Qr.has=Jr.includes,Qr.contains=Qr.includes,Qr.keys=Qr.values,xr(F,Vr),xr(G,Yr),xr(Z,Qr);var nn=function(t){function e(t){return null==t?an():Mr(t)?t:an().withMutations((function(e){var r=E(t);te(r.size),r.forEach((function(t){return e.add(t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(I(t).keySeq())},e.prototype.toString=function(){return this.__toString("OrderedSet {","}")},e}(kr);nn.isOrderedSet=Mr;var on,un=nn.prototype;function sn(t,e){var r=Object.create(un);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function an(){return on||(on=sn(gr()))}un[A]=!0,un.zip=Yr.zip,un.zipWith=Yr.zipWith,un.zipAll=Yr.zipAll,un.__empty=an,un.__make=sn;var cn=function(t,e){var r;!function(t){if(D(t))throw new Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(x(t))throw new Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(null===t||"object"!=typeof t)throw new Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}(t);var n=function(o){var u=this;if(o instanceof n)return o;if(!(this instanceof n))return new n(o);if(!r){r=!0;var s=Object.keys(t),a=i._indices={};i._name=e,i._keys=s,i._defaultValues=t;for(var c=0;c2?[]:void 0,{"":t})},t.get=se,t.getIn=Pr,t.has=ue,t.hasIn=Nr,t.hash=vt,t.is=ht,t.isAssociative=z,t.isCollection=d,t.isImmutable=x,t.isIndexed=b,t.isKeyed=w,t.isList=rr,t.isMap=at,t.isOrdered=k,t.isOrderedMap=ct,t.isOrderedSet=Mr,t.isPlainObject=ne,t.isRecord=D,t.isSeq=q,t.isSet=qr,t.isStack=br,t.isValueObject=ft,t.merge=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Ie(t,e)},t.mergeDeep=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Se(t,e)},t.mergeDeepWith=function(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];return Se(e,r,t)},t.mergeWith=function(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];return Ie(e,r,t)},t.remove=ce,t.removeIn=ve,t.set=fe,t.setIn=_e,t.update=de,t.updateIn=he,t.version="5.1.0"})); +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).Immutable={})}(this,(function(t){"use strict";var e="delete",r=5,n=1<>>0;if(""+r!==e||4294967295===r)return NaN;e=r}return e<0?a(t)+e:e}function f(){return!0}function h(t,e,r){return(0===t&&!v(t)||void 0!==r&&t<=-r)&&(void 0===e||void 0!==r&&e>=r)}function p(t,e){return l(t,e,0)}function _(t,e){return l(t,e,e)}function l(t,e,r){return void 0===t?r:v(t)?e===1/0?e:0|Math.max(0,e+t):void 0===e||e===t?t:0|Math.min(e,t)}function v(t){return t<0||0===t&&1/t==-1/0}var y="@@__IMMUTABLE_ITERABLE__@@";function d(t){return Boolean(t&&t[y])}var g="@@__IMMUTABLE_KEYED__@@";function w(t){return Boolean(t&&t[g])}var m="@@__IMMUTABLE_INDEXED__@@";function b(t){return Boolean(t&&t[m])}function z(t){return w(t)||b(t)}var S=function(t){return d(t)?t:X(t)},I=function(t){function e(t){return w(t)?t:F(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(S),O=function(t){function e(t){return b(t)?t:G(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(S),E=function(t){function e(t){return d(t)&&!z(t)?t:Z(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(S);S.Keyed=I,S.Indexed=O,S.Set=E;var j="@@__IMMUTABLE_SEQ__@@";function q(t){return Boolean(t&&t[j])}var M="@@__IMMUTABLE_RECORD__@@";function D(t){return Boolean(t&&t[M])}function x(t){return d(t)||D(t)}var A="@@__IMMUTABLE_ORDERED__@@";function k(t){return Boolean(t&&t[A])}var R=0,U=1,T=2,B="function"==typeof Symbol&&Symbol.iterator,K="@@iterator",L=B||K,C=function(t){this.next=t};function P(t,e,r,n){var i=t===R?e:t===U?r:[e,r];return n?n.value=i:n={value:i,done:!1},n}function W(){return{value:void 0,done:!0}}function N(t){return!!Array.isArray(t)||!!V(t)}function H(t){return t&&"function"==typeof t.next}function J(t){var e=V(t);return e&&e.call(t)}function V(t){var e=t&&(B&&t[B]||t[K]);if("function"==typeof e)return e}C.prototype.toString=function(){return"[Iterator]"},C.KEYS=R,C.VALUES=U,C.ENTRIES=T,C.prototype.inspect=C.prototype.toSource=function(){return this.toString()},C.prototype[L]=function(){return this};var Y=Object.prototype.hasOwnProperty;function Q(t){return!(!Array.isArray(t)&&"string"!=typeof t)||t&&"object"==typeof t&&Number.isInteger(t.length)&&t.length>=0&&(0===t.length?1===Object.keys(t).length:t.hasOwnProperty(t.length-1))}var X=function(t){function e(t){return null==t?nt():x(t)?t.toSeq():function(t){var e=ut(t);if(e)return(n=V(r=t))&&n===r.entries?e.fromEntrySeq():function(t){var e=V(t);return e&&e===t.keys}(t)?e.toSetSeq():e;var r,n;if("object"==typeof t)return new tt(t);throw new TypeError("Expected Array or collection object of values, or keyed object: "+t)}(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq {","}")},e.prototype.cacheResult=function(){return!this._cache&&this.__iterateUncached&&(this._cache=this.entrySeq().toArray(),this.size=this._cache.length),this},e.prototype.__iterate=function(t,e){var r=this._cache;if(r){for(var n=r.length,i=0;i!==n;){var o=r[e?n-++i:i++];if(!1===t(o[1],o[0],this))break}return i}return this.__iterateUncached(t,e)},e.prototype.__iterator=function(t,e){var r=this._cache;if(r){var n=r.length,i=0;return new C((function(){if(i===n)return{value:void 0,done:!0};var o=r[e?n-++i:i++];return P(t,o[0],o[1])}))}return this.__iteratorUncached(t,e)},e}(S),F=function(t){function e(t){return null==t?nt().toKeyedSeq():d(t)?w(t)?t.toSeq():t.fromEntrySeq():D(t)?t.toSeq():it(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toKeyedSeq=function(){return this},e}(X),G=function(t){function e(t){return null==t?nt():d(t)?w(t)?t.entrySeq():t.toIndexedSeq():D(t)?t.toSeq().entrySeq():ot(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return e(arguments)},e.prototype.toIndexedSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq [","]")},e}(X),Z=function(t){function e(t){return(d(t)&&!z(t)?t:G(t)).toSetSeq()}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return e(arguments)},e.prototype.toSetSeq=function(){return this},e}(X);X.isSeq=q,X.Keyed=F,X.Set=Z,X.Indexed=G,X.prototype[j]=!0;var $=function(t){function e(t){this._array=t,this.size=t.length}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t,e){return this.has(t)?this._array[c(this,t)]:e},e.prototype.__iterate=function(t,e){for(var r=this._array,n=r.length,i=0;i!==n;){var o=e?n-++i:i++;if(!1===t(r[o],o,this))break}return i},e.prototype.__iterator=function(t,e){var r=this._array,n=r.length,i=0;return new C((function(){if(i===n)return{value:void 0,done:!0};var o=e?n-++i:i++;return P(t,o,r[o])}))},e}(G),tt=function(t){function e(t){var e=Object.keys(t).concat(Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(t):[]);this._object=t,this._keys=e,this.size=e.length}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t,e){return void 0===e||this.has(t)?this._object[t]:e},e.prototype.has=function(t){return Y.call(this._object,t)},e.prototype.__iterate=function(t,e){for(var r=this._object,n=this._keys,i=n.length,o=0;o!==i;){var u=n[e?i-++o:o++];if(!1===t(r[u],u,this))break}return o},e.prototype.__iterator=function(t,e){var r=this._object,n=this._keys,i=n.length,o=0;return new C((function(){if(o===i)return{value:void 0,done:!0};var u=n[e?i-++o:o++];return P(t,u,r[u])}))},e}(F);tt.prototype[A]=!0;var et,rt=function(t){function e(t){this._collection=t,this.size=t.length||t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.__iterateUncached=function(t,e){if(e)return this.cacheResult().__iterate(t,e);var r=J(this._collection),n=0;if(H(r))for(var i;!(i=r.next()).done&&!1!==t(i.value,n++,this););return n},e.prototype.__iteratorUncached=function(t,e){if(e)return this.cacheResult().__iterator(t,e);var r=J(this._collection);if(!H(r))return new C(W);var n=0;return new C((function(){var e=r.next();return e.done?e:P(t,n++,e.value)}))},e}(G);function nt(){return et||(et=new $([]))}function it(t){var e=ut(t);if(e)return e.fromEntrySeq();if("object"==typeof t)return new tt(t);throw new TypeError("Expected Array or collection object of [k, v] entries, or keyed object: "+t)}function ot(t){var e=ut(t);if(e)return e;throw new TypeError("Expected Array or collection object of values: "+t)}function ut(t){return Q(t)?new $(t):N(t)?new rt(t):void 0}var st="@@__IMMUTABLE_MAP__@@";function at(t){return Boolean(t&&t[st])}function ct(t){return at(t)&&k(t)}function ft(t){return Boolean(t&&"function"==typeof t.equals&&"function"==typeof t.hashCode)}function ht(t,e){if(t===e||t!=t&&e!=e)return!0;if(!t||!e)return!1;if("function"==typeof t.valueOf&&"function"==typeof e.valueOf){if((t=t.valueOf())===(e=e.valueOf())||t!=t&&e!=e)return!0;if(!t||!e)return!1}return!!(ft(t)&&ft(e)&&t.equals(e))}var pt="function"==typeof Math.imul&&-2===Math.imul(4294967295,2)?Math.imul:function(t,e){var r=65535&(t|=0),n=65535&(e|=0);return r*n+((t>>>16)*n+r*(e>>>16)<<16>>>0)|0};function _t(t){return t>>>1&1073741824|3221225471&t}var lt=Object.prototype.valueOf;function vt(t){if(null==t)return yt(t);if("function"==typeof t.hashCode)return _t(t.hashCode(t));var e,r=(e=t).valueOf!==lt&&"function"==typeof e.valueOf?e.valueOf(e):e;if(null==r)return yt(r);switch(typeof r){case"boolean":return r?1108378657:1108378656;case"number":return function(t){if(t!=t||t===1/0)return 0;var e=0|t;e!==t&&(e^=4294967295*t);for(;t>4294967295;)e^=t/=4294967295;return _t(e)}(r);case"string":return r.length>Et?function(t){var e=Mt[t];void 0===e&&(e=dt(t),qt===jt&&(qt=0,Mt={}),qt++,Mt[t]=e);return e}(r):dt(r);case"object":case"function":return function(t){var e;if(zt&&void 0!==(e=bt.get(t)))return e;if(e=t[Ot],void 0!==e)return e;if(!wt){if(void 0!==(e=t.propertyIsEnumerable&&t.propertyIsEnumerable[Ot]))return e;if(void 0!==(e=function(t){if(t&&t.nodeType>0)switch(t.nodeType){case 1:return t.uniqueID;case 9:return t.documentElement&&t.documentElement.uniqueID}}(t)))return e}if(e=mt(),zt)bt.set(t,e);else{if(void 0!==gt&&!1===gt(t))throw new Error("Non-extensible objects are not allowed as keys.");if(wt)Object.defineProperty(t,Ot,{enumerable:!1,configurable:!1,writable:!1,value:e});else if(void 0!==t.propertyIsEnumerable&&t.propertyIsEnumerable===t.constructor.prototype.propertyIsEnumerable)t.propertyIsEnumerable=function(){return this.constructor.prototype.propertyIsEnumerable.apply(this,arguments)},t.propertyIsEnumerable[Ot]=e;else{if(void 0===t.nodeType)throw new Error("Unable to set a non-enumerable property on object.");t[Ot]=e}}return e}(r);case"symbol":return function(t){var e=St[t];if(void 0!==e)return e;return e=mt(),St[t]=e,e}(r);default:if("function"==typeof r.toString)return dt(r.toString());throw new Error("Value type "+typeof r+" cannot be hashed.")}}function yt(t){return null===t?1108378658:1108378659}function dt(t){for(var e=0,r=0;r=0&&(a.get=function(e,r){return(e=c(this,e))>=0&&eo)return{value:void 0,done:!0};var t=i.next();return n||e===U||t.done?t:P(e,a-1,e===R?void 0:t.value[1],t)}))},a}function Lt(t,e,r,n){var i=Xt(t);return i.__iterateUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterate(i,o);var s=!0,a=0;return t.__iterate((function(t,o,c){if(!s||!(s=e.call(r,t,o,c)))return a++,i(t,n?o:a-1,u)})),a},i.__iteratorUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterator(i,o);var s=t.__iterator(T,o),a=!0,c=0;return new C((function(){var t,o,f;do{if((t=s.next()).done)return n||i===U?t:P(i,c++,i===R?void 0:t.value[1],t);var h=t.value;o=h[0],f=h[1],a&&(a=e.call(r,f,o,u))}while(a);return i===T?t:P(i,o,f,t)}))},i}xt.prototype.cacheResult=Dt.prototype.cacheResult=At.prototype.cacheResult=kt.prototype.cacheResult=Ft;var Ct=function(t){function e(t){this._wrappedIterables=t.flatMap((function(t){return t._wrappedIterables?t._wrappedIterables:[t]})),this.size=this._wrappedIterables.reduce((function(t,e){if(void 0!==t){var r=e.size;if(void 0!==r)return t+r}}),0),this[g]=this._wrappedIterables[0][g],this[m]=this._wrappedIterables[0][m],this[A]=this._wrappedIterables[0][A]}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.__iterateUncached=function(t,e){if(0!==this._wrappedIterables.length){if(e)return this.cacheResult().__iterate(t,e);for(var r=0,n=w(this),i=n?T:U,o=this._wrappedIterables[r].__iterator(i,e),u=!0,s=0;u;){for(var a=o.next();a.done;){if(++r===this._wrappedIterables.length)return s;a=(o=this._wrappedIterables[r].__iterator(i,e)).next()}u=!1!==(n?t(a.value[1],a.value[0],this):t(a.value,s,this)),s++}return s}},e.prototype.__iteratorUncached=function(t,e){var r=this;if(0===this._wrappedIterables.length)return new C(W);if(e)return this.cacheResult().__iterator(t,e);var n=0,i=this._wrappedIterables[n].__iterator(t,e);return new C((function(){for(var o=i.next();o.done;){if(++n===r._wrappedIterables.length)return o;o=(i=r._wrappedIterables[n].__iterator(t,e)).next()}return o}))},e}(X);function Pt(t,e,r){var n=Xt(t);return n.__iterateUncached=function(i,o){if(o)return this.cacheResult().__iterate(i,o);var u=0,s=!1;return function t(a,c){a.__iterate((function(o,a){return(!e||c0}function Jt(t,e,r,n){var i=Xt(t),o=new $(r).map((function(t){return t.size}));return i.size=n?o.max():o.min(),i.__iterate=function(t,e){for(var r,n=this.__iterator(U,e),i=0;!(r=n.next()).done&&!1!==t(r.value,i++,this););return i},i.__iteratorUncached=function(t,i){var o=r.map((function(t){return t=S(t),J(i?t.reverse():t)})),u=0,s=!1;return new C((function(){var r;return s||(r=o.map((function(t){return t.next()})),s=n?r.every((function(t){return t.done})):r.some((function(t){return t.done}))),s?{value:void 0,done:!0}:P(t,u++,e.apply(null,r.map((function(t){return t.value}))))}))},i}function Vt(t,e){return t===e?t:q(t)?e:t.constructor(e)}function Yt(t){if(t!==Object(t))throw new TypeError("Expected [K, V] tuple: "+t)}function Qt(t){return w(t)?I:b(t)?O:E}function Xt(t){return Object.create((w(t)?F:b(t)?G:Z).prototype)}function Ft(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size,this):X.prototype.cacheResult.call(this)}function Gt(t,e){return void 0===t&&void 0===e?0:void 0===t?1:void 0===e?-1:t>e?1:t0;)e[r]=arguments[r+1];if("function"!=typeof t)throw new TypeError("Invalid merger function: "+t);return ze(this,e,t)}function ze(t,e,r){for(var n=[],i=0;i0;)e[r]=arguments[r+1];return Se(this,e,t)}function je(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return he(this,t,Je(),(function(t){return Ie(t,e)}))}function qe(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return he(this,t,Je(),(function(t){return Se(t,e)}))}function Me(t){var e=this.asMutable();return t(e),e.wasAltered()?e.__ensureOwner(this.__ownerID):this}function De(){return this.__ownerID?this:this.__ensureOwner(new s)}function xe(){return this.__ensureOwner()}function Ae(){return this.__altered}var ke=function(t){function e(e){return null==e?Je():at(e)&&!k(e)?e:Je().withMutations((function(r){var n=t(e);te(n.size),n.forEach((function(t,e){return r.set(e,t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toString=function(){return this.__toString("Map {","}")},e.prototype.get=function(t,e){return this._root?this._root.get(0,void 0,t,e):e},e.prototype.set=function(t,e){return Ve(this,t,e)},e.prototype.remove=function(t){return Ve(this,t,o)},e.prototype.deleteAll=function(t){var e=S(t);return 0===e.size?this:this.withMutations((function(t){e.forEach((function(e){return t.remove(e)}))}))},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):Je()},e.prototype.sort=function(t){return yr(Wt(this,t))},e.prototype.sortBy=function(t,e){return yr(Wt(this,e,t))},e.prototype.map=function(t,e){var r=this;return this.withMutations((function(n){n.forEach((function(i,o){n.set(o,t.call(e,i,o,r))}))}))},e.prototype.__iterator=function(t,e){return new Pe(this,t,e)},e.prototype.__iterate=function(t,e){var r=this,n=0;return this._root&&this._root.iterate((function(e){return n++,t(e[1],e[0],r)}),e),n},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?He(this.size,this._root,t,this.__hash):0===this.size?Je():(this.__ownerID=t,this.__altered=!1,this)},e}(I);ke.isMap=at;var Re=ke.prototype;Re[st]=!0,Re[e]=Re.remove,Re.removeAll=Re.deleteAll,Re.setIn=le,Re.removeIn=Re.deleteIn=ye,Re.update=ge,Re.updateIn=we,Re.merge=Re.concat=me,Re.mergeWith=be,Re.mergeDeep=Oe,Re.mergeDeepWith=Ee,Re.mergeIn=je,Re.mergeDeepIn=qe,Re.withMutations=Me,Re.wasAltered=Ae,Re.asImmutable=xe,Re["@@transducer/init"]=Re.asMutable=De,Re["@@transducer/step"]=function(t,e){return t.set(e[0],e[1])},Re["@@transducer/result"]=function(t){return t.asImmutable()};var Ue=function(t,e){this.ownerID=t,this.entries=e};Ue.prototype.get=function(t,e,r,n){for(var i=this.entries,o=0,u=i.length;o=Ze)return function(t,e,r,n){t||(t=new s);for(var i=new Le(t,vt(r),[r,n]),o=0;o>>t)&i),s=this.bitmap;return 0==(s&u)?o:this.nodes[Fe(s&u-1)].get(t+r,e,n,o)},Te.prototype.update=function(t,e,u,s,a,c,f){void 0===u&&(u=vt(s));var h=(0===e?u:u>>>e)&i,p=1<=$e)return function(t,e,r,i,o){for(var u=0,s=new Array(n),a=0;0!==r;a++,r>>>=1)s[a]=1&r?e[u++]:void 0;return s[i]=o,new Be(t,u+1,s)}(t,y,_,h,g);if(l&&!g&&2===y.length&&Qe(y[1^v]))return y[1^v];if(l&&g&&1===y.length&&Qe(g))return g;var w=t&&t===this.ownerID,m=l?g?_:_^p:_|p,b=l?g?Ge(y,v,g,w):function(t,e,r){var n=t.length-1;if(r&&e===n)return t.pop(),t;for(var i=new Array(n),o=0,u=0;u>>t)&i,s=this.nodes[u];return s?s.get(t+r,e,n,o):o},Be.prototype.update=function(t,e,n,u,s,a,c){void 0===n&&(n=vt(u));var f=(0===e?n:n>>>e)&i,h=s===o,p=this.nodes,_=p[f];if(h&&!_)return this;var l=Ye(_,t,e+r,n,u,s,a,c);if(l===_)return this;var v=this.count;if(_){if(!l&&--v>>n)&i,c=(0===n?o:o>>>n)&i,f=a===c?[Xe(t,e,n+r,o,u)]:(s=new Le(e,o,u),a>1&1431655765))+(t>>2&858993459))+(t>>4)&252645135,t+=t>>8,127&(t+=t>>16)}function Ge(t,e,r,n){var i=n?t:Zt(t);return i[e]=r,i}var Ze=n/4,$e=n/2,tr=n/4,er="@@__IMMUTABLE_LIST__@@";function rr(t){return Boolean(t&&t[er])}var nr=function(t){function e(e){var i=cr();if(null==e)return i;if(rr(e))return e;var o=t(e),u=o.size;return 0===u?i:(te(u),u>0&&u=0&&t=t.size||e<0)return t.withMutations((function(t){e<0?_r(t,e).set(0,r):_r(t,0,e+1).set(e,r)}));e+=t._origin;var n=t._tail,i=t._root,o={value:!1};e>=lr(t._capacity)?n=fr(n,t.__ownerID,0,e,r,o):i=fr(i,t.__ownerID,t._level,e,r,o);if(!o.value)return t;if(t.__ownerID)return t._root=i,t._tail=n,t.__hash=void 0,t.__altered=!0,t;return ar(t._origin,t._capacity,t._level,i,n)}(this,t,e)},e.prototype.remove=function(t){return this.has(t)?0===t?this.shift():t===this.size-1?this.pop():this.splice(t,1):this},e.prototype.insert=function(t,e){return this.splice(t,0,e)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=this._origin=this._capacity=0,this._level=r,this._root=this._tail=this.__hash=void 0,this.__altered=!0,this):cr()},e.prototype.push=function(){var t=arguments,e=this.size;return this.withMutations((function(r){_r(r,0,e+t.length);for(var n=0;n>>e&i;if(o>=this.array.length)return new or([],t);var u,s=0===o;if(e>0){var a=this.array[o];if((u=a&&a.removeBefore(t,e-r,n))===a&&s)return this}if(s&&!u)return this;var c=hr(this,t);if(!s)for(var f=0;f>>e&i;if(s>=this.array.length)return this;if(e>0){var a=this.array[s];if((u=a&&a.removeAfter(t,e-r,o))===a&&s===this.array.length-1)return this}var c=hr(this,t);return c.array.splice(s+1),u&&(c.array[s]=u),c};var ur={};function sr(t,e){var i=t._origin,o=t._capacity,u=lr(o),s=t._tail;return a(t._root,t._level,0);function a(t,c,f){return 0===c?function(t,r){var a=r===u?s&&s.array:t&&t.array,c=r>i?0:i-r,f=o-r;f>n&&(f=n);return function(){if(c===f)return ur;var t=e?--f:c++;return a&&a[t]}}(t,f):function(t,u,s){var c,f=t&&t.array,h=s>i?0:i-s>>u,p=1+(o-s>>u);p>n&&(p=n);return function(){for(;;){if(c){var t=c();if(t!==ur)return t;c=null}if(h===p)return ur;var n=e?--p:h++;c=a(f&&f[n],u-r,s+(n<>>n&i,h=t&&f0){var p=t&&t.array[f],_=fr(p,e,n-r,o,s,a);return _===p?t:((c=hr(t,e)).array[f]=_,c)}return h&&t.array[f]===s?t:(a&&u(a),c=hr(t,e),void 0===s&&f===c.array.length-1?c.array.pop():c.array[f]=s,c)}function hr(t,e){return e&&t&&e===t.ownerID?t:new or(t?t.array.slice():[],e)}function pr(t,e){if(e>=lr(t._capacity))return t._tail;if(e<1<0;)n=n.array[e>>>o&i],o-=r;return n}}function _r(t,e,n){void 0!==e&&(e|=0),void 0!==n&&(n|=0);var o=t.__ownerID||new s,u=t._origin,a=t._capacity,c=u+e,f=void 0===n?a:n<0?a+n:u+n;if(c===u&&f===a)return t;if(c>=f)return t.clear();for(var h=t._level,p=t._root,_=0;c+_<0;)p=new or(p&&p.array.length?[void 0,p]:[],o),_+=1<<(h+=r);_&&(c+=_,u+=_,f+=_,a+=_);for(var l=lr(a),v=lr(f);v>=1<l?new or([],o):y;if(y&&v>l&&cr;w-=r){var m=l>>>w&i;g=g.array[m]=hr(g.array[m],o)}g.array[l>>>r&i]=y}if(f=v)c-=v,f-=v,h=r,p=null,d=d&&d.removeBefore(o,0,c);else if(c>u||v>>h&i;if(b!==v>>>h&i)break;b&&(_+=(1<u&&(p=p.removeBefore(o,h,c-_)),p&&v>>r<=n&&a.size>=2*s.size?(i=(u=a.filter((function(t,e){return void 0!==t&&c!==e}))).toKeyedSeq().map((function(t){return t[0]})).flip().toMap(),t.__ownerID&&(i.__ownerID=u.__ownerID=t.__ownerID)):(i=s.remove(e),u=c===a.size-1?a.pop():a.set(c,void 0))}else if(f){if(r===a.get(c)[1])return t;i=s,u=a.set(c,[e,r])}else i=s.set(e,a.size),u=a.set(a.size,[e,r]);return t.__ownerID?(t.size=i.size,t._map=i,t._list=u,t.__hash=void 0,t.__altered=!0,t):dr(i,u)}yr.isOrderedMap=ct,yr.prototype[A]=!0,yr.prototype[e]=yr.prototype.remove;var mr="@@__IMMUTABLE_STACK__@@";function br(t){return Boolean(t&&t[mr])}var zr=function(t){function e(t){return null==t?Er():br(t)?t:Er().pushAll(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("Stack [","]")},e.prototype.get=function(t,e){var r=this._head;for(t=c(this,t);r&&t--;)r=r.next;return r?r.value:e},e.prototype.peek=function(){return this._head&&this._head.value},e.prototype.push=function(){var t=arguments;if(0===arguments.length)return this;for(var e=this.size+arguments.length,r=this._head,n=arguments.length-1;n>=0;n--)r={value:t[n],next:r};return this.__ownerID?(this.size=e,this._head=r,this.__hash=void 0,this.__altered=!0,this):Or(e,r)},e.prototype.pushAll=function(e){if(0===(e=t(e)).size)return this;if(0===this.size&&br(e))return e;te(e.size);var r=this.size,n=this._head;return e.__iterate((function(t){r++,n={value:t,next:n}}),!0),this.__ownerID?(this.size=r,this._head=n,this.__hash=void 0,this.__altered=!0,this):Or(r,n)},e.prototype.pop=function(){return this.slice(1)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):Er()},e.prototype.slice=function(e,r){if(h(e,r,this.size))return this;var n=p(e,this.size);if(_(r,this.size)!==this.size)return t.prototype.slice.call(this,e,r);for(var i=this.size-n,o=this._head;n--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):Or(i,o)},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Or(this.size,this._head,t,this.__hash):0===this.size?Er():(this.__ownerID=t,this.__altered=!1,this)},e.prototype.__iterate=function(t,e){var r=this;if(e)return new $(this.toArray()).__iterate((function(e,n){return t(e,n,r)}),e);for(var n=0,i=this._head;i&&!1!==t(i.value,n++,this);)i=i.next;return n},e.prototype.__iterator=function(t,e){if(e)return new $(this.toArray()).__iterator(t,e);var r=0,n=this._head;return new C((function(){if(n){var e=n.value;return n=n.next,P(t,r++,e)}return{value:void 0,done:!0}}))},e}(O);zr.isStack=br;var Sr,Ir=zr.prototype;function Or(t,e,r,n){var i=Object.create(Ir);return i.size=t,i._head=e,i.__ownerID=r,i.__hash=n,i.__altered=!1,i}function Er(){return Sr||(Sr=Or(0))}Ir[mr]=!0,Ir.shift=Ir.pop,Ir.unshift=Ir.push,Ir.unshiftAll=Ir.pushAll,Ir.withMutations=Me,Ir.wasAltered=Ae,Ir.asImmutable=xe,Ir["@@transducer/init"]=Ir.asMutable=De,Ir["@@transducer/step"]=function(t,e){return t.unshift(e)},Ir["@@transducer/result"]=function(t){return t.asImmutable()};var jr="@@__IMMUTABLE_SET__@@";function qr(t){return Boolean(t&&t[jr])}function Mr(t){return qr(t)&&k(t)}function Dr(t,e){if(t===e)return!0;if(!d(e)||void 0!==t.size&&void 0!==e.size&&t.size!==e.size||void 0!==t.__hash&&void 0!==e.__hash&&t.__hash!==e.__hash||w(t)!==w(e)||b(t)!==b(e)||k(t)!==k(e))return!1;if(0===t.size&&0===e.size)return!0;var r=!z(t);if(k(t)){var n=t.entries();return e.every((function(t,e){var i=n.next().value;return i&&ht(i[1],t)&&(r||ht(i[0],e))}))&&n.next().done}var i=!1;if(void 0===t.size)if(void 0===e.size)"function"==typeof t.cacheResult&&t.cacheResult();else{i=!0;var u=t;t=e,e=u}var s=!0,a=e.__iterate((function(e,n){if(r?!t.has(e):i?!ht(e,t.get(n,o)):!ht(t.get(n,o),e))return s=!1,!1}));return s&&t.size===a}function xr(t,e){var r=function(r){t.prototype[r]=e[r]};return Object.keys(e).forEach(r),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(e).forEach(r),t}function Ar(t){if(!t||"object"!=typeof t)return t;if(!d(t)){if(!ie(t))return t;t=X(t)}if(w(t)){var e={};return t.__iterate((function(t,r){e[r]=Ar(t)})),e}var r=[];return t.__iterate((function(t){r.push(Ar(t))})),r}var kr=function(t){function e(e){return null==e?Kr():qr(e)&&!k(e)?e:Kr().withMutations((function(r){var n=t(e);te(n.size),n.forEach((function(t){return r.add(t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(I(t).keySeq())},e.intersect=function(t){return(t=S(t).toArray()).length?Ur.intersect.apply(e(t.pop()),t):Kr()},e.union=function(t){return(t=S(t).toArray()).length?Ur.union.apply(e(t.pop()),t):Kr()},e.prototype.toString=function(){return this.__toString("Set {","}")},e.prototype.has=function(t){return this._map.has(t)},e.prototype.add=function(t){return Tr(this,this._map.set(t,t))},e.prototype.remove=function(t){return Tr(this,this._map.remove(t))},e.prototype.clear=function(){return Tr(this,this._map.clear())},e.prototype.map=function(t,e){var r=this,n=!1,i=Tr(this,this._map.mapEntries((function(i){var o=i[1],u=t.call(e,o,o,r);return u!==o&&(n=!0),[u,u]}),e));return n?i:this},e.prototype.union=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return 0===(e=e.filter((function(t){return 0!==t.size}))).length?this:0!==this.size||this.__ownerID||1!==e.length?this.withMutations((function(r){for(var n=0;n=0&&e=0&&r>>-15,461845907),e=pt(e<<13|e>>>-13,5),e=pt((e=(e+3864292196|0)^t)^e>>>16,2246822507),e=_t((e=pt(e^e>>>13,3266489909))^e>>>16)}(t.size,n)}(this))}});var Jr=S.prototype;Jr[y]=!0,Jr[L]=Jr.values,Jr.toJSON=Jr.toArray,Jr.__toStringMapper=oe,Jr.inspect=Jr.toSource=function(){return this.toString()},Jr.chain=Jr.flatMap,Jr.contains=Jr.includes,xr(I,{flip:function(){return Vt(this,Rt(this))},mapEntries:function(t,e){var r=this,n=0;return Vt(this,this.toSeq().map((function(i,o){return t.call(e,[o,i],n++,r)})).fromEntrySeq())},mapKeys:function(t,e){var r=this;return Vt(this,this.toSeq().flip().map((function(n,i){return t.call(e,n,i,r)})).flip())}});var Vr=I.prototype;Vr[g]=!0,Vr[L]=Jr.entries,Vr.toJSON=Hr,Vr.__toStringMapper=function(t,e){return oe(e)+": "+oe(t)},xr(O,{toKeyedSeq:function(){return new Dt(this,!1)},filter:function(t,e){return Vt(this,Bt(this,t,e,!1))},findIndex:function(t,e){var r=this.findEntry(t,e);return r?r[0]:-1},indexOf:function(t){var e=this.keyOf(t);return void 0===e?-1:e},lastIndexOf:function(t){var e=this.lastKeyOf(t);return void 0===e?-1:e},reverse:function(){return Vt(this,Tt(this,!1))},slice:function(t,e){return Vt(this,Kt(this,t,e,!1))},splice:function(t,e){var r=arguments.length;if(e=Math.max(e||0,0),0===r||2===r&&!e)return this;t=p(t,t<0?this.count():this.size);var n=this.slice(0,t);return Vt(this,1===r?n:n.concat(Zt(arguments,2),this.slice(t+e)))},findLastIndex:function(t,e){var r=this.findLastEntry(t,e);return r?r[0]:-1},first:function(t){return this.get(0,t)},flatten:function(t){return Vt(this,Pt(this,t,!1))},get:function(t,e){return(t=c(this,t))<0||this.size===1/0||void 0!==this.size&&t>this.size?e:this.find((function(e,r){return r===t}),void 0,e)},has:function(t){return(t=c(this,t))>=0&&(void 0!==this.size?this.size===1/0||te?-1:0}function rn(t,e){return t^e+2654435769+(t<<6)+(t>>2)|0}Qr.has=Jr.includes,Qr.contains=Qr.includes,Qr.keys=Qr.values,xr(F,Vr),xr(G,Yr),xr(Z,Qr);var nn=function(t){function e(t){return null==t?an():Mr(t)?t:an().withMutations((function(e){var r=E(t);te(r.size),r.forEach((function(t){return e.add(t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(I(t).keySeq())},e.prototype.toString=function(){return this.__toString("OrderedSet {","}")},e}(kr);nn.isOrderedSet=Mr;var on,un=nn.prototype;function sn(t,e){var r=Object.create(un);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function an(){return on||(on=sn(gr()))}un[A]=!0,un.zip=Yr.zip,un.zipWith=Yr.zipWith,un.zipAll=Yr.zipAll,un.__empty=an,un.__make=sn;var cn=function(t,e){var r;!function(t){if(D(t))throw new Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(x(t))throw new Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(null===t||"object"!=typeof t)throw new Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}(t);var n=function(o){var u=this;if(o instanceof n)return o;if(!(this instanceof n))return new n(o);if(!r){r=!0;var s=Object.keys(t),a=i._indices={};i._name=e,i._keys=s,i._defaultValues=t;for(var c=0;c2?[]:void 0,{"":t})},t.get=se,t.getIn=Pr,t.has=ue,t.hasIn=Nr,t.hash=vt,t.is=ht,t.isAssociative=z,t.isCollection=d,t.isImmutable=x,t.isIndexed=b,t.isKeyed=w,t.isList=rr,t.isMap=at,t.isOrdered=k,t.isOrderedMap=ct,t.isOrderedSet=Mr,t.isPlainObject=ne,t.isRecord=D,t.isSeq=q,t.isSet=qr,t.isStack=br,t.isValueObject=ft,t.merge=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Ie(t,e)},t.mergeDeep=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Se(t,e)},t.mergeDeepWith=function(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];return Se(e,r,t)},t.mergeWith=function(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];return Ie(e,r,t)},t.remove=ce,t.removeIn=ve,t.set=fe,t.setIn=_e,t.update=de,t.updateIn=he,t.version="5.1.1"})); diff --git a/package.json b/package.json index 2db591e9b1..b43c22ad2c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "immutable", - "version": "5.1.0", + "version": "5.1.1", "description": "Immutable Data Collections", "license": "MIT", "homepage": "https://immutable-js.com", From 1f86530763ae1b1ddf8e819f3df9c89025e121a6 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 5 May 2025 21:55:51 +0000 Subject: [PATCH 240/242] deploy: 29431bd51516fa72dbc656a3e32a31cdb3d7db7b --- dist/immutable.d.ts | 2 +- dist/immutable.es.js | 5 ++--- dist/immutable.js | 5 ++--- dist/immutable.min.js | 2 +- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/dist/immutable.d.ts b/dist/immutable.d.ts index 622fb01cfa..331dc2c6a8 100644 --- a/dist/immutable.d.ts +++ b/dist/immutable.d.ts @@ -949,7 +949,7 @@ declare namespace Immutable { never; /** @ignore */ - type RetrievePath> = P extends [] + type RetrievePath> = P extends [] ? P : RetrievePathReducer, Tail

>; diff --git a/dist/immutable.es.js b/dist/immutable.es.js index 8cf8322ad7..9ad755ace2 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -2260,6 +2260,7 @@ function remove(collection, key) { // @ts-expect-error weird "remove" here, return collection.remove(key); } + // @ts-expect-error assert that key is a string, a number or a symbol here if (!hasOwnProperty.call(collection, key)) { return collection; } @@ -2269,6 +2270,7 @@ function remove(collection, key) { collectionCopy.splice(key, 1); } else { + // @ts-expect-error assert that key is a string, a number or a symbol here delete collectionCopy[key]; } return collectionCopy; @@ -2325,9 +2327,6 @@ function updateInDeeply(inImmutable, existing, keyPath, i, notSetValue, updater) existing); } var key = keyPath[i]; - if (typeof key === 'undefined') { - throw new TypeError('Index can not be undefined in updateIn(). This should not happen'); - } var nextExisting = wasNotSet ? NOT_SET : get(existing, key, NOT_SET); var nextUpdated = updateInDeeply(nextExisting === NOT_SET ? inImmutable : isImmutable(nextExisting), // @ts-expect-error mixed type diff --git a/dist/immutable.js b/dist/immutable.js index 2c024cb937..db05103be9 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -2266,6 +2266,7 @@ // @ts-expect-error weird "remove" here, return collection.remove(key); } + // @ts-expect-error assert that key is a string, a number or a symbol here if (!hasOwnProperty.call(collection, key)) { return collection; } @@ -2275,6 +2276,7 @@ collectionCopy.splice(key, 1); } else { + // @ts-expect-error assert that key is a string, a number or a symbol here delete collectionCopy[key]; } return collectionCopy; @@ -2331,9 +2333,6 @@ existing); } var key = keyPath[i]; - if (typeof key === 'undefined') { - throw new TypeError('Index can not be undefined in updateIn(). This should not happen'); - } var nextExisting = wasNotSet ? NOT_SET : get(existing, key, NOT_SET); var nextUpdated = updateInDeeply(nextExisting === NOT_SET ? inImmutable : isImmutable(nextExisting), // @ts-expect-error mixed type diff --git a/dist/immutable.min.js b/dist/immutable.min.js index 91c0b317af..3d6439a381 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -22,4 +22,4 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).Immutable={})}(this,(function(t){"use strict";var e="delete",r=5,n=1<>>0;if(""+r!==e||4294967295===r)return NaN;e=r}return e<0?a(t)+e:e}function f(){return!0}function h(t,e,r){return(0===t&&!v(t)||void 0!==r&&t<=-r)&&(void 0===e||void 0!==r&&e>=r)}function p(t,e){return l(t,e,0)}function _(t,e){return l(t,e,e)}function l(t,e,r){return void 0===t?r:v(t)?e===1/0?e:0|Math.max(0,e+t):void 0===e||e===t?t:0|Math.min(e,t)}function v(t){return t<0||0===t&&1/t==-1/0}var y="@@__IMMUTABLE_ITERABLE__@@";function d(t){return Boolean(t&&t[y])}var g="@@__IMMUTABLE_KEYED__@@";function w(t){return Boolean(t&&t[g])}var m="@@__IMMUTABLE_INDEXED__@@";function b(t){return Boolean(t&&t[m])}function z(t){return w(t)||b(t)}var S=function(t){return d(t)?t:X(t)},I=function(t){function e(t){return w(t)?t:F(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(S),O=function(t){function e(t){return b(t)?t:G(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(S),E=function(t){function e(t){return d(t)&&!z(t)?t:Z(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(S);S.Keyed=I,S.Indexed=O,S.Set=E;var j="@@__IMMUTABLE_SEQ__@@";function q(t){return Boolean(t&&t[j])}var M="@@__IMMUTABLE_RECORD__@@";function D(t){return Boolean(t&&t[M])}function x(t){return d(t)||D(t)}var A="@@__IMMUTABLE_ORDERED__@@";function k(t){return Boolean(t&&t[A])}var R=0,U=1,T=2,B="function"==typeof Symbol&&Symbol.iterator,K="@@iterator",L=B||K,C=function(t){this.next=t};function P(t,e,r,n){var i=t===R?e:t===U?r:[e,r];return n?n.value=i:n={value:i,done:!1},n}function W(){return{value:void 0,done:!0}}function N(t){return!!Array.isArray(t)||!!V(t)}function H(t){return t&&"function"==typeof t.next}function J(t){var e=V(t);return e&&e.call(t)}function V(t){var e=t&&(B&&t[B]||t[K]);if("function"==typeof e)return e}C.prototype.toString=function(){return"[Iterator]"},C.KEYS=R,C.VALUES=U,C.ENTRIES=T,C.prototype.inspect=C.prototype.toSource=function(){return this.toString()},C.prototype[L]=function(){return this};var Y=Object.prototype.hasOwnProperty;function Q(t){return!(!Array.isArray(t)&&"string"!=typeof t)||t&&"object"==typeof t&&Number.isInteger(t.length)&&t.length>=0&&(0===t.length?1===Object.keys(t).length:t.hasOwnProperty(t.length-1))}var X=function(t){function e(t){return null==t?nt():x(t)?t.toSeq():function(t){var e=ut(t);if(e)return(n=V(r=t))&&n===r.entries?e.fromEntrySeq():function(t){var e=V(t);return e&&e===t.keys}(t)?e.toSetSeq():e;var r,n;if("object"==typeof t)return new tt(t);throw new TypeError("Expected Array or collection object of values, or keyed object: "+t)}(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq {","}")},e.prototype.cacheResult=function(){return!this._cache&&this.__iterateUncached&&(this._cache=this.entrySeq().toArray(),this.size=this._cache.length),this},e.prototype.__iterate=function(t,e){var r=this._cache;if(r){for(var n=r.length,i=0;i!==n;){var o=r[e?n-++i:i++];if(!1===t(o[1],o[0],this))break}return i}return this.__iterateUncached(t,e)},e.prototype.__iterator=function(t,e){var r=this._cache;if(r){var n=r.length,i=0;return new C((function(){if(i===n)return{value:void 0,done:!0};var o=r[e?n-++i:i++];return P(t,o[0],o[1])}))}return this.__iteratorUncached(t,e)},e}(S),F=function(t){function e(t){return null==t?nt().toKeyedSeq():d(t)?w(t)?t.toSeq():t.fromEntrySeq():D(t)?t.toSeq():it(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toKeyedSeq=function(){return this},e}(X),G=function(t){function e(t){return null==t?nt():d(t)?w(t)?t.entrySeq():t.toIndexedSeq():D(t)?t.toSeq().entrySeq():ot(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return e(arguments)},e.prototype.toIndexedSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq [","]")},e}(X),Z=function(t){function e(t){return(d(t)&&!z(t)?t:G(t)).toSetSeq()}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return e(arguments)},e.prototype.toSetSeq=function(){return this},e}(X);X.isSeq=q,X.Keyed=F,X.Set=Z,X.Indexed=G,X.prototype[j]=!0;var $=function(t){function e(t){this._array=t,this.size=t.length}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t,e){return this.has(t)?this._array[c(this,t)]:e},e.prototype.__iterate=function(t,e){for(var r=this._array,n=r.length,i=0;i!==n;){var o=e?n-++i:i++;if(!1===t(r[o],o,this))break}return i},e.prototype.__iterator=function(t,e){var r=this._array,n=r.length,i=0;return new C((function(){if(i===n)return{value:void 0,done:!0};var o=e?n-++i:i++;return P(t,o,r[o])}))},e}(G),tt=function(t){function e(t){var e=Object.keys(t).concat(Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(t):[]);this._object=t,this._keys=e,this.size=e.length}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t,e){return void 0===e||this.has(t)?this._object[t]:e},e.prototype.has=function(t){return Y.call(this._object,t)},e.prototype.__iterate=function(t,e){for(var r=this._object,n=this._keys,i=n.length,o=0;o!==i;){var u=n[e?i-++o:o++];if(!1===t(r[u],u,this))break}return o},e.prototype.__iterator=function(t,e){var r=this._object,n=this._keys,i=n.length,o=0;return new C((function(){if(o===i)return{value:void 0,done:!0};var u=n[e?i-++o:o++];return P(t,u,r[u])}))},e}(F);tt.prototype[A]=!0;var et,rt=function(t){function e(t){this._collection=t,this.size=t.length||t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.__iterateUncached=function(t,e){if(e)return this.cacheResult().__iterate(t,e);var r=J(this._collection),n=0;if(H(r))for(var i;!(i=r.next()).done&&!1!==t(i.value,n++,this););return n},e.prototype.__iteratorUncached=function(t,e){if(e)return this.cacheResult().__iterator(t,e);var r=J(this._collection);if(!H(r))return new C(W);var n=0;return new C((function(){var e=r.next();return e.done?e:P(t,n++,e.value)}))},e}(G);function nt(){return et||(et=new $([]))}function it(t){var e=ut(t);if(e)return e.fromEntrySeq();if("object"==typeof t)return new tt(t);throw new TypeError("Expected Array or collection object of [k, v] entries, or keyed object: "+t)}function ot(t){var e=ut(t);if(e)return e;throw new TypeError("Expected Array or collection object of values: "+t)}function ut(t){return Q(t)?new $(t):N(t)?new rt(t):void 0}var st="@@__IMMUTABLE_MAP__@@";function at(t){return Boolean(t&&t[st])}function ct(t){return at(t)&&k(t)}function ft(t){return Boolean(t&&"function"==typeof t.equals&&"function"==typeof t.hashCode)}function ht(t,e){if(t===e||t!=t&&e!=e)return!0;if(!t||!e)return!1;if("function"==typeof t.valueOf&&"function"==typeof e.valueOf){if((t=t.valueOf())===(e=e.valueOf())||t!=t&&e!=e)return!0;if(!t||!e)return!1}return!!(ft(t)&&ft(e)&&t.equals(e))}var pt="function"==typeof Math.imul&&-2===Math.imul(4294967295,2)?Math.imul:function(t,e){var r=65535&(t|=0),n=65535&(e|=0);return r*n+((t>>>16)*n+r*(e>>>16)<<16>>>0)|0};function _t(t){return t>>>1&1073741824|3221225471&t}var lt=Object.prototype.valueOf;function vt(t){if(null==t)return yt(t);if("function"==typeof t.hashCode)return _t(t.hashCode(t));var e,r=(e=t).valueOf!==lt&&"function"==typeof e.valueOf?e.valueOf(e):e;if(null==r)return yt(r);switch(typeof r){case"boolean":return r?1108378657:1108378656;case"number":return function(t){if(t!=t||t===1/0)return 0;var e=0|t;e!==t&&(e^=4294967295*t);for(;t>4294967295;)e^=t/=4294967295;return _t(e)}(r);case"string":return r.length>Et?function(t){var e=Mt[t];void 0===e&&(e=dt(t),qt===jt&&(qt=0,Mt={}),qt++,Mt[t]=e);return e}(r):dt(r);case"object":case"function":return function(t){var e;if(zt&&void 0!==(e=bt.get(t)))return e;if(e=t[Ot],void 0!==e)return e;if(!wt){if(void 0!==(e=t.propertyIsEnumerable&&t.propertyIsEnumerable[Ot]))return e;if(void 0!==(e=function(t){if(t&&t.nodeType>0)switch(t.nodeType){case 1:return t.uniqueID;case 9:return t.documentElement&&t.documentElement.uniqueID}}(t)))return e}if(e=mt(),zt)bt.set(t,e);else{if(void 0!==gt&&!1===gt(t))throw new Error("Non-extensible objects are not allowed as keys.");if(wt)Object.defineProperty(t,Ot,{enumerable:!1,configurable:!1,writable:!1,value:e});else if(void 0!==t.propertyIsEnumerable&&t.propertyIsEnumerable===t.constructor.prototype.propertyIsEnumerable)t.propertyIsEnumerable=function(){return this.constructor.prototype.propertyIsEnumerable.apply(this,arguments)},t.propertyIsEnumerable[Ot]=e;else{if(void 0===t.nodeType)throw new Error("Unable to set a non-enumerable property on object.");t[Ot]=e}}return e}(r);case"symbol":return function(t){var e=St[t];if(void 0!==e)return e;return e=mt(),St[t]=e,e}(r);default:if("function"==typeof r.toString)return dt(r.toString());throw new Error("Value type "+typeof r+" cannot be hashed.")}}function yt(t){return null===t?1108378658:1108378659}function dt(t){for(var e=0,r=0;r=0&&(a.get=function(e,r){return(e=c(this,e))>=0&&eo)return{value:void 0,done:!0};var t=i.next();return n||e===U||t.done?t:P(e,a-1,e===R?void 0:t.value[1],t)}))},a}function Lt(t,e,r,n){var i=Xt(t);return i.__iterateUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterate(i,o);var s=!0,a=0;return t.__iterate((function(t,o,c){if(!s||!(s=e.call(r,t,o,c)))return a++,i(t,n?o:a-1,u)})),a},i.__iteratorUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterator(i,o);var s=t.__iterator(T,o),a=!0,c=0;return new C((function(){var t,o,f;do{if((t=s.next()).done)return n||i===U?t:P(i,c++,i===R?void 0:t.value[1],t);var h=t.value;o=h[0],f=h[1],a&&(a=e.call(r,f,o,u))}while(a);return i===T?t:P(i,o,f,t)}))},i}xt.prototype.cacheResult=Dt.prototype.cacheResult=At.prototype.cacheResult=kt.prototype.cacheResult=Ft;var Ct=function(t){function e(t){this._wrappedIterables=t.flatMap((function(t){return t._wrappedIterables?t._wrappedIterables:[t]})),this.size=this._wrappedIterables.reduce((function(t,e){if(void 0!==t){var r=e.size;if(void 0!==r)return t+r}}),0),this[g]=this._wrappedIterables[0][g],this[m]=this._wrappedIterables[0][m],this[A]=this._wrappedIterables[0][A]}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.__iterateUncached=function(t,e){if(0!==this._wrappedIterables.length){if(e)return this.cacheResult().__iterate(t,e);for(var r=0,n=w(this),i=n?T:U,o=this._wrappedIterables[r].__iterator(i,e),u=!0,s=0;u;){for(var a=o.next();a.done;){if(++r===this._wrappedIterables.length)return s;a=(o=this._wrappedIterables[r].__iterator(i,e)).next()}u=!1!==(n?t(a.value[1],a.value[0],this):t(a.value,s,this)),s++}return s}},e.prototype.__iteratorUncached=function(t,e){var r=this;if(0===this._wrappedIterables.length)return new C(W);if(e)return this.cacheResult().__iterator(t,e);var n=0,i=this._wrappedIterables[n].__iterator(t,e);return new C((function(){for(var o=i.next();o.done;){if(++n===r._wrappedIterables.length)return o;o=(i=r._wrappedIterables[n].__iterator(t,e)).next()}return o}))},e}(X);function Pt(t,e,r){var n=Xt(t);return n.__iterateUncached=function(i,o){if(o)return this.cacheResult().__iterate(i,o);var u=0,s=!1;return function t(a,c){a.__iterate((function(o,a){return(!e||c0}function Jt(t,e,r,n){var i=Xt(t),o=new $(r).map((function(t){return t.size}));return i.size=n?o.max():o.min(),i.__iterate=function(t,e){for(var r,n=this.__iterator(U,e),i=0;!(r=n.next()).done&&!1!==t(r.value,i++,this););return i},i.__iteratorUncached=function(t,i){var o=r.map((function(t){return t=S(t),J(i?t.reverse():t)})),u=0,s=!1;return new C((function(){var r;return s||(r=o.map((function(t){return t.next()})),s=n?r.every((function(t){return t.done})):r.some((function(t){return t.done}))),s?{value:void 0,done:!0}:P(t,u++,e.apply(null,r.map((function(t){return t.value}))))}))},i}function Vt(t,e){return t===e?t:q(t)?e:t.constructor(e)}function Yt(t){if(t!==Object(t))throw new TypeError("Expected [K, V] tuple: "+t)}function Qt(t){return w(t)?I:b(t)?O:E}function Xt(t){return Object.create((w(t)?F:b(t)?G:Z).prototype)}function Ft(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size,this):X.prototype.cacheResult.call(this)}function Gt(t,e){return void 0===t&&void 0===e?0:void 0===t?1:void 0===e?-1:t>e?1:t0;)e[r]=arguments[r+1];if("function"!=typeof t)throw new TypeError("Invalid merger function: "+t);return ze(this,e,t)}function ze(t,e,r){for(var n=[],i=0;i0;)e[r]=arguments[r+1];return Se(this,e,t)}function je(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return he(this,t,Je(),(function(t){return Ie(t,e)}))}function qe(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return he(this,t,Je(),(function(t){return Se(t,e)}))}function Me(t){var e=this.asMutable();return t(e),e.wasAltered()?e.__ensureOwner(this.__ownerID):this}function De(){return this.__ownerID?this:this.__ensureOwner(new s)}function xe(){return this.__ensureOwner()}function Ae(){return this.__altered}var ke=function(t){function e(e){return null==e?Je():at(e)&&!k(e)?e:Je().withMutations((function(r){var n=t(e);te(n.size),n.forEach((function(t,e){return r.set(e,t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toString=function(){return this.__toString("Map {","}")},e.prototype.get=function(t,e){return this._root?this._root.get(0,void 0,t,e):e},e.prototype.set=function(t,e){return Ve(this,t,e)},e.prototype.remove=function(t){return Ve(this,t,o)},e.prototype.deleteAll=function(t){var e=S(t);return 0===e.size?this:this.withMutations((function(t){e.forEach((function(e){return t.remove(e)}))}))},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):Je()},e.prototype.sort=function(t){return yr(Wt(this,t))},e.prototype.sortBy=function(t,e){return yr(Wt(this,e,t))},e.prototype.map=function(t,e){var r=this;return this.withMutations((function(n){n.forEach((function(i,o){n.set(o,t.call(e,i,o,r))}))}))},e.prototype.__iterator=function(t,e){return new Pe(this,t,e)},e.prototype.__iterate=function(t,e){var r=this,n=0;return this._root&&this._root.iterate((function(e){return n++,t(e[1],e[0],r)}),e),n},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?He(this.size,this._root,t,this.__hash):0===this.size?Je():(this.__ownerID=t,this.__altered=!1,this)},e}(I);ke.isMap=at;var Re=ke.prototype;Re[st]=!0,Re[e]=Re.remove,Re.removeAll=Re.deleteAll,Re.setIn=le,Re.removeIn=Re.deleteIn=ye,Re.update=ge,Re.updateIn=we,Re.merge=Re.concat=me,Re.mergeWith=be,Re.mergeDeep=Oe,Re.mergeDeepWith=Ee,Re.mergeIn=je,Re.mergeDeepIn=qe,Re.withMutations=Me,Re.wasAltered=Ae,Re.asImmutable=xe,Re["@@transducer/init"]=Re.asMutable=De,Re["@@transducer/step"]=function(t,e){return t.set(e[0],e[1])},Re["@@transducer/result"]=function(t){return t.asImmutable()};var Ue=function(t,e){this.ownerID=t,this.entries=e};Ue.prototype.get=function(t,e,r,n){for(var i=this.entries,o=0,u=i.length;o=Ze)return function(t,e,r,n){t||(t=new s);for(var i=new Le(t,vt(r),[r,n]),o=0;o>>t)&i),s=this.bitmap;return 0==(s&u)?o:this.nodes[Fe(s&u-1)].get(t+r,e,n,o)},Te.prototype.update=function(t,e,u,s,a,c,f){void 0===u&&(u=vt(s));var h=(0===e?u:u>>>e)&i,p=1<=$e)return function(t,e,r,i,o){for(var u=0,s=new Array(n),a=0;0!==r;a++,r>>>=1)s[a]=1&r?e[u++]:void 0;return s[i]=o,new Be(t,u+1,s)}(t,y,_,h,g);if(l&&!g&&2===y.length&&Qe(y[1^v]))return y[1^v];if(l&&g&&1===y.length&&Qe(g))return g;var w=t&&t===this.ownerID,m=l?g?_:_^p:_|p,b=l?g?Ge(y,v,g,w):function(t,e,r){var n=t.length-1;if(r&&e===n)return t.pop(),t;for(var i=new Array(n),o=0,u=0;u>>t)&i,s=this.nodes[u];return s?s.get(t+r,e,n,o):o},Be.prototype.update=function(t,e,n,u,s,a,c){void 0===n&&(n=vt(u));var f=(0===e?n:n>>>e)&i,h=s===o,p=this.nodes,_=p[f];if(h&&!_)return this;var l=Ye(_,t,e+r,n,u,s,a,c);if(l===_)return this;var v=this.count;if(_){if(!l&&--v>>n)&i,c=(0===n?o:o>>>n)&i,f=a===c?[Xe(t,e,n+r,o,u)]:(s=new Le(e,o,u),a>1&1431655765))+(t>>2&858993459))+(t>>4)&252645135,t+=t>>8,127&(t+=t>>16)}function Ge(t,e,r,n){var i=n?t:Zt(t);return i[e]=r,i}var Ze=n/4,$e=n/2,tr=n/4,er="@@__IMMUTABLE_LIST__@@";function rr(t){return Boolean(t&&t[er])}var nr=function(t){function e(e){var i=cr();if(null==e)return i;if(rr(e))return e;var o=t(e),u=o.size;return 0===u?i:(te(u),u>0&&u=0&&t=t.size||e<0)return t.withMutations((function(t){e<0?_r(t,e).set(0,r):_r(t,0,e+1).set(e,r)}));e+=t._origin;var n=t._tail,i=t._root,o={value:!1};e>=lr(t._capacity)?n=fr(n,t.__ownerID,0,e,r,o):i=fr(i,t.__ownerID,t._level,e,r,o);if(!o.value)return t;if(t.__ownerID)return t._root=i,t._tail=n,t.__hash=void 0,t.__altered=!0,t;return ar(t._origin,t._capacity,t._level,i,n)}(this,t,e)},e.prototype.remove=function(t){return this.has(t)?0===t?this.shift():t===this.size-1?this.pop():this.splice(t,1):this},e.prototype.insert=function(t,e){return this.splice(t,0,e)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=this._origin=this._capacity=0,this._level=r,this._root=this._tail=this.__hash=void 0,this.__altered=!0,this):cr()},e.prototype.push=function(){var t=arguments,e=this.size;return this.withMutations((function(r){_r(r,0,e+t.length);for(var n=0;n>>e&i;if(o>=this.array.length)return new or([],t);var u,s=0===o;if(e>0){var a=this.array[o];if((u=a&&a.removeBefore(t,e-r,n))===a&&s)return this}if(s&&!u)return this;var c=hr(this,t);if(!s)for(var f=0;f>>e&i;if(s>=this.array.length)return this;if(e>0){var a=this.array[s];if((u=a&&a.removeAfter(t,e-r,o))===a&&s===this.array.length-1)return this}var c=hr(this,t);return c.array.splice(s+1),u&&(c.array[s]=u),c};var ur={};function sr(t,e){var i=t._origin,o=t._capacity,u=lr(o),s=t._tail;return a(t._root,t._level,0);function a(t,c,f){return 0===c?function(t,r){var a=r===u?s&&s.array:t&&t.array,c=r>i?0:i-r,f=o-r;f>n&&(f=n);return function(){if(c===f)return ur;var t=e?--f:c++;return a&&a[t]}}(t,f):function(t,u,s){var c,f=t&&t.array,h=s>i?0:i-s>>u,p=1+(o-s>>u);p>n&&(p=n);return function(){for(;;){if(c){var t=c();if(t!==ur)return t;c=null}if(h===p)return ur;var n=e?--p:h++;c=a(f&&f[n],u-r,s+(n<>>n&i,h=t&&f0){var p=t&&t.array[f],_=fr(p,e,n-r,o,s,a);return _===p?t:((c=hr(t,e)).array[f]=_,c)}return h&&t.array[f]===s?t:(a&&u(a),c=hr(t,e),void 0===s&&f===c.array.length-1?c.array.pop():c.array[f]=s,c)}function hr(t,e){return e&&t&&e===t.ownerID?t:new or(t?t.array.slice():[],e)}function pr(t,e){if(e>=lr(t._capacity))return t._tail;if(e<1<0;)n=n.array[e>>>o&i],o-=r;return n}}function _r(t,e,n){void 0!==e&&(e|=0),void 0!==n&&(n|=0);var o=t.__ownerID||new s,u=t._origin,a=t._capacity,c=u+e,f=void 0===n?a:n<0?a+n:u+n;if(c===u&&f===a)return t;if(c>=f)return t.clear();for(var h=t._level,p=t._root,_=0;c+_<0;)p=new or(p&&p.array.length?[void 0,p]:[],o),_+=1<<(h+=r);_&&(c+=_,u+=_,f+=_,a+=_);for(var l=lr(a),v=lr(f);v>=1<l?new or([],o):y;if(y&&v>l&&cr;w-=r){var m=l>>>w&i;g=g.array[m]=hr(g.array[m],o)}g.array[l>>>r&i]=y}if(f=v)c-=v,f-=v,h=r,p=null,d=d&&d.removeBefore(o,0,c);else if(c>u||v>>h&i;if(b!==v>>>h&i)break;b&&(_+=(1<u&&(p=p.removeBefore(o,h,c-_)),p&&v>>r<=n&&a.size>=2*s.size?(i=(u=a.filter((function(t,e){return void 0!==t&&c!==e}))).toKeyedSeq().map((function(t){return t[0]})).flip().toMap(),t.__ownerID&&(i.__ownerID=u.__ownerID=t.__ownerID)):(i=s.remove(e),u=c===a.size-1?a.pop():a.set(c,void 0))}else if(f){if(r===a.get(c)[1])return t;i=s,u=a.set(c,[e,r])}else i=s.set(e,a.size),u=a.set(a.size,[e,r]);return t.__ownerID?(t.size=i.size,t._map=i,t._list=u,t.__hash=void 0,t.__altered=!0,t):dr(i,u)}yr.isOrderedMap=ct,yr.prototype[A]=!0,yr.prototype[e]=yr.prototype.remove;var mr="@@__IMMUTABLE_STACK__@@";function br(t){return Boolean(t&&t[mr])}var zr=function(t){function e(t){return null==t?Er():br(t)?t:Er().pushAll(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("Stack [","]")},e.prototype.get=function(t,e){var r=this._head;for(t=c(this,t);r&&t--;)r=r.next;return r?r.value:e},e.prototype.peek=function(){return this._head&&this._head.value},e.prototype.push=function(){var t=arguments;if(0===arguments.length)return this;for(var e=this.size+arguments.length,r=this._head,n=arguments.length-1;n>=0;n--)r={value:t[n],next:r};return this.__ownerID?(this.size=e,this._head=r,this.__hash=void 0,this.__altered=!0,this):Or(e,r)},e.prototype.pushAll=function(e){if(0===(e=t(e)).size)return this;if(0===this.size&&br(e))return e;te(e.size);var r=this.size,n=this._head;return e.__iterate((function(t){r++,n={value:t,next:n}}),!0),this.__ownerID?(this.size=r,this._head=n,this.__hash=void 0,this.__altered=!0,this):Or(r,n)},e.prototype.pop=function(){return this.slice(1)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):Er()},e.prototype.slice=function(e,r){if(h(e,r,this.size))return this;var n=p(e,this.size);if(_(r,this.size)!==this.size)return t.prototype.slice.call(this,e,r);for(var i=this.size-n,o=this._head;n--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):Or(i,o)},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Or(this.size,this._head,t,this.__hash):0===this.size?Er():(this.__ownerID=t,this.__altered=!1,this)},e.prototype.__iterate=function(t,e){var r=this;if(e)return new $(this.toArray()).__iterate((function(e,n){return t(e,n,r)}),e);for(var n=0,i=this._head;i&&!1!==t(i.value,n++,this);)i=i.next;return n},e.prototype.__iterator=function(t,e){if(e)return new $(this.toArray()).__iterator(t,e);var r=0,n=this._head;return new C((function(){if(n){var e=n.value;return n=n.next,P(t,r++,e)}return{value:void 0,done:!0}}))},e}(O);zr.isStack=br;var Sr,Ir=zr.prototype;function Or(t,e,r,n){var i=Object.create(Ir);return i.size=t,i._head=e,i.__ownerID=r,i.__hash=n,i.__altered=!1,i}function Er(){return Sr||(Sr=Or(0))}Ir[mr]=!0,Ir.shift=Ir.pop,Ir.unshift=Ir.push,Ir.unshiftAll=Ir.pushAll,Ir.withMutations=Me,Ir.wasAltered=Ae,Ir.asImmutable=xe,Ir["@@transducer/init"]=Ir.asMutable=De,Ir["@@transducer/step"]=function(t,e){return t.unshift(e)},Ir["@@transducer/result"]=function(t){return t.asImmutable()};var jr="@@__IMMUTABLE_SET__@@";function qr(t){return Boolean(t&&t[jr])}function Mr(t){return qr(t)&&k(t)}function Dr(t,e){if(t===e)return!0;if(!d(e)||void 0!==t.size&&void 0!==e.size&&t.size!==e.size||void 0!==t.__hash&&void 0!==e.__hash&&t.__hash!==e.__hash||w(t)!==w(e)||b(t)!==b(e)||k(t)!==k(e))return!1;if(0===t.size&&0===e.size)return!0;var r=!z(t);if(k(t)){var n=t.entries();return e.every((function(t,e){var i=n.next().value;return i&&ht(i[1],t)&&(r||ht(i[0],e))}))&&n.next().done}var i=!1;if(void 0===t.size)if(void 0===e.size)"function"==typeof t.cacheResult&&t.cacheResult();else{i=!0;var u=t;t=e,e=u}var s=!0,a=e.__iterate((function(e,n){if(r?!t.has(e):i?!ht(e,t.get(n,o)):!ht(t.get(n,o),e))return s=!1,!1}));return s&&t.size===a}function xr(t,e){var r=function(r){t.prototype[r]=e[r]};return Object.keys(e).forEach(r),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(e).forEach(r),t}function Ar(t){if(!t||"object"!=typeof t)return t;if(!d(t)){if(!ie(t))return t;t=X(t)}if(w(t)){var e={};return t.__iterate((function(t,r){e[r]=Ar(t)})),e}var r=[];return t.__iterate((function(t){r.push(Ar(t))})),r}var kr=function(t){function e(e){return null==e?Kr():qr(e)&&!k(e)?e:Kr().withMutations((function(r){var n=t(e);te(n.size),n.forEach((function(t){return r.add(t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(I(t).keySeq())},e.intersect=function(t){return(t=S(t).toArray()).length?Ur.intersect.apply(e(t.pop()),t):Kr()},e.union=function(t){return(t=S(t).toArray()).length?Ur.union.apply(e(t.pop()),t):Kr()},e.prototype.toString=function(){return this.__toString("Set {","}")},e.prototype.has=function(t){return this._map.has(t)},e.prototype.add=function(t){return Tr(this,this._map.set(t,t))},e.prototype.remove=function(t){return Tr(this,this._map.remove(t))},e.prototype.clear=function(){return Tr(this,this._map.clear())},e.prototype.map=function(t,e){var r=this,n=!1,i=Tr(this,this._map.mapEntries((function(i){var o=i[1],u=t.call(e,o,o,r);return u!==o&&(n=!0),[u,u]}),e));return n?i:this},e.prototype.union=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return 0===(e=e.filter((function(t){return 0!==t.size}))).length?this:0!==this.size||this.__ownerID||1!==e.length?this.withMutations((function(r){for(var n=0;n=0&&e=0&&r>>-15,461845907),e=pt(e<<13|e>>>-13,5),e=pt((e=(e+3864292196|0)^t)^e>>>16,2246822507),e=_t((e=pt(e^e>>>13,3266489909))^e>>>16)}(t.size,n)}(this))}});var Jr=S.prototype;Jr[y]=!0,Jr[L]=Jr.values,Jr.toJSON=Jr.toArray,Jr.__toStringMapper=oe,Jr.inspect=Jr.toSource=function(){return this.toString()},Jr.chain=Jr.flatMap,Jr.contains=Jr.includes,xr(I,{flip:function(){return Vt(this,Rt(this))},mapEntries:function(t,e){var r=this,n=0;return Vt(this,this.toSeq().map((function(i,o){return t.call(e,[o,i],n++,r)})).fromEntrySeq())},mapKeys:function(t,e){var r=this;return Vt(this,this.toSeq().flip().map((function(n,i){return t.call(e,n,i,r)})).flip())}});var Vr=I.prototype;Vr[g]=!0,Vr[L]=Jr.entries,Vr.toJSON=Hr,Vr.__toStringMapper=function(t,e){return oe(e)+": "+oe(t)},xr(O,{toKeyedSeq:function(){return new Dt(this,!1)},filter:function(t,e){return Vt(this,Bt(this,t,e,!1))},findIndex:function(t,e){var r=this.findEntry(t,e);return r?r[0]:-1},indexOf:function(t){var e=this.keyOf(t);return void 0===e?-1:e},lastIndexOf:function(t){var e=this.lastKeyOf(t);return void 0===e?-1:e},reverse:function(){return Vt(this,Tt(this,!1))},slice:function(t,e){return Vt(this,Kt(this,t,e,!1))},splice:function(t,e){var r=arguments.length;if(e=Math.max(e||0,0),0===r||2===r&&!e)return this;t=p(t,t<0?this.count():this.size);var n=this.slice(0,t);return Vt(this,1===r?n:n.concat(Zt(arguments,2),this.slice(t+e)))},findLastIndex:function(t,e){var r=this.findLastEntry(t,e);return r?r[0]:-1},first:function(t){return this.get(0,t)},flatten:function(t){return Vt(this,Pt(this,t,!1))},get:function(t,e){return(t=c(this,t))<0||this.size===1/0||void 0!==this.size&&t>this.size?e:this.find((function(e,r){return r===t}),void 0,e)},has:function(t){return(t=c(this,t))>=0&&(void 0!==this.size?this.size===1/0||te?-1:0}function rn(t,e){return t^e+2654435769+(t<<6)+(t>>2)|0}Qr.has=Jr.includes,Qr.contains=Qr.includes,Qr.keys=Qr.values,xr(F,Vr),xr(G,Yr),xr(Z,Qr);var nn=function(t){function e(t){return null==t?an():Mr(t)?t:an().withMutations((function(e){var r=E(t);te(r.size),r.forEach((function(t){return e.add(t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(I(t).keySeq())},e.prototype.toString=function(){return this.__toString("OrderedSet {","}")},e}(kr);nn.isOrderedSet=Mr;var on,un=nn.prototype;function sn(t,e){var r=Object.create(un);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function an(){return on||(on=sn(gr()))}un[A]=!0,un.zip=Yr.zip,un.zipWith=Yr.zipWith,un.zipAll=Yr.zipAll,un.__empty=an,un.__make=sn;var cn=function(t,e){var r;!function(t){if(D(t))throw new Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(x(t))throw new Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(null===t||"object"!=typeof t)throw new Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}(t);var n=function(o){var u=this;if(o instanceof n)return o;if(!(this instanceof n))return new n(o);if(!r){r=!0;var s=Object.keys(t),a=i._indices={};i._name=e,i._keys=s,i._defaultValues=t;for(var c=0;c2?[]:void 0,{"":t})},t.get=se,t.getIn=Pr,t.has=ue,t.hasIn=Nr,t.hash=vt,t.is=ht,t.isAssociative=z,t.isCollection=d,t.isImmutable=x,t.isIndexed=b,t.isKeyed=w,t.isList=rr,t.isMap=at,t.isOrdered=k,t.isOrderedMap=ct,t.isOrderedSet=Mr,t.isPlainObject=ne,t.isRecord=D,t.isSeq=q,t.isSet=qr,t.isStack=br,t.isValueObject=ft,t.merge=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Ie(t,e)},t.mergeDeep=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Se(t,e)},t.mergeDeepWith=function(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];return Se(e,r,t)},t.mergeWith=function(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];return Ie(e,r,t)},t.remove=ce,t.removeIn=ve,t.set=fe,t.setIn=_e,t.update=de,t.updateIn=he,t.version="5.1.1"})); +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).Immutable={})}(this,(function(t){"use strict";var e="delete",r=5,n=1<>>0;if(""+r!==e||4294967295===r)return NaN;e=r}return e<0?a(t)+e:e}function f(){return!0}function h(t,e,r){return(0===t&&!v(t)||void 0!==r&&t<=-r)&&(void 0===e||void 0!==r&&e>=r)}function p(t,e){return l(t,e,0)}function _(t,e){return l(t,e,e)}function l(t,e,r){return void 0===t?r:v(t)?e===1/0?e:0|Math.max(0,e+t):void 0===e||e===t?t:0|Math.min(e,t)}function v(t){return t<0||0===t&&1/t==-1/0}var y="@@__IMMUTABLE_ITERABLE__@@";function d(t){return Boolean(t&&t[y])}var g="@@__IMMUTABLE_KEYED__@@";function w(t){return Boolean(t&&t[g])}var m="@@__IMMUTABLE_INDEXED__@@";function b(t){return Boolean(t&&t[m])}function z(t){return w(t)||b(t)}var S=function(t){return d(t)?t:X(t)},I=function(t){function e(t){return w(t)?t:F(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(S),O=function(t){function e(t){return b(t)?t:G(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(S),E=function(t){function e(t){return d(t)&&!z(t)?t:Z(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(S);S.Keyed=I,S.Indexed=O,S.Set=E;var j="@@__IMMUTABLE_SEQ__@@";function q(t){return Boolean(t&&t[j])}var M="@@__IMMUTABLE_RECORD__@@";function D(t){return Boolean(t&&t[M])}function x(t){return d(t)||D(t)}var A="@@__IMMUTABLE_ORDERED__@@";function k(t){return Boolean(t&&t[A])}var R=0,U=1,T=2,B="function"==typeof Symbol&&Symbol.iterator,K="@@iterator",L=B||K,C=function(t){this.next=t};function P(t,e,r,n){var i=t===R?e:t===U?r:[e,r];return n?n.value=i:n={value:i,done:!1},n}function W(){return{value:void 0,done:!0}}function N(t){return!!Array.isArray(t)||!!V(t)}function H(t){return t&&"function"==typeof t.next}function J(t){var e=V(t);return e&&e.call(t)}function V(t){var e=t&&(B&&t[B]||t[K]);if("function"==typeof e)return e}C.prototype.toString=function(){return"[Iterator]"},C.KEYS=R,C.VALUES=U,C.ENTRIES=T,C.prototype.inspect=C.prototype.toSource=function(){return this.toString()},C.prototype[L]=function(){return this};var Y=Object.prototype.hasOwnProperty;function Q(t){return!(!Array.isArray(t)&&"string"!=typeof t)||t&&"object"==typeof t&&Number.isInteger(t.length)&&t.length>=0&&(0===t.length?1===Object.keys(t).length:t.hasOwnProperty(t.length-1))}var X=function(t){function e(t){return null==t?nt():x(t)?t.toSeq():function(t){var e=ut(t);if(e)return(n=V(r=t))&&n===r.entries?e.fromEntrySeq():function(t){var e=V(t);return e&&e===t.keys}(t)?e.toSetSeq():e;var r,n;if("object"==typeof t)return new tt(t);throw new TypeError("Expected Array or collection object of values, or keyed object: "+t)}(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq {","}")},e.prototype.cacheResult=function(){return!this._cache&&this.__iterateUncached&&(this._cache=this.entrySeq().toArray(),this.size=this._cache.length),this},e.prototype.__iterate=function(t,e){var r=this._cache;if(r){for(var n=r.length,i=0;i!==n;){var o=r[e?n-++i:i++];if(!1===t(o[1],o[0],this))break}return i}return this.__iterateUncached(t,e)},e.prototype.__iterator=function(t,e){var r=this._cache;if(r){var n=r.length,i=0;return new C((function(){if(i===n)return{value:void 0,done:!0};var o=r[e?n-++i:i++];return P(t,o[0],o[1])}))}return this.__iteratorUncached(t,e)},e}(S),F=function(t){function e(t){return null==t?nt().toKeyedSeq():d(t)?w(t)?t.toSeq():t.fromEntrySeq():D(t)?t.toSeq():it(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toKeyedSeq=function(){return this},e}(X),G=function(t){function e(t){return null==t?nt():d(t)?w(t)?t.entrySeq():t.toIndexedSeq():D(t)?t.toSeq().entrySeq():ot(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return e(arguments)},e.prototype.toIndexedSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq [","]")},e}(X),Z=function(t){function e(t){return(d(t)&&!z(t)?t:G(t)).toSetSeq()}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return e(arguments)},e.prototype.toSetSeq=function(){return this},e}(X);X.isSeq=q,X.Keyed=F,X.Set=Z,X.Indexed=G,X.prototype[j]=!0;var $=function(t){function e(t){this._array=t,this.size=t.length}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t,e){return this.has(t)?this._array[c(this,t)]:e},e.prototype.__iterate=function(t,e){for(var r=this._array,n=r.length,i=0;i!==n;){var o=e?n-++i:i++;if(!1===t(r[o],o,this))break}return i},e.prototype.__iterator=function(t,e){var r=this._array,n=r.length,i=0;return new C((function(){if(i===n)return{value:void 0,done:!0};var o=e?n-++i:i++;return P(t,o,r[o])}))},e}(G),tt=function(t){function e(t){var e=Object.keys(t).concat(Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(t):[]);this._object=t,this._keys=e,this.size=e.length}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t,e){return void 0===e||this.has(t)?this._object[t]:e},e.prototype.has=function(t){return Y.call(this._object,t)},e.prototype.__iterate=function(t,e){for(var r=this._object,n=this._keys,i=n.length,o=0;o!==i;){var u=n[e?i-++o:o++];if(!1===t(r[u],u,this))break}return o},e.prototype.__iterator=function(t,e){var r=this._object,n=this._keys,i=n.length,o=0;return new C((function(){if(o===i)return{value:void 0,done:!0};var u=n[e?i-++o:o++];return P(t,u,r[u])}))},e}(F);tt.prototype[A]=!0;var et,rt=function(t){function e(t){this._collection=t,this.size=t.length||t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.__iterateUncached=function(t,e){if(e)return this.cacheResult().__iterate(t,e);var r=J(this._collection),n=0;if(H(r))for(var i;!(i=r.next()).done&&!1!==t(i.value,n++,this););return n},e.prototype.__iteratorUncached=function(t,e){if(e)return this.cacheResult().__iterator(t,e);var r=J(this._collection);if(!H(r))return new C(W);var n=0;return new C((function(){var e=r.next();return e.done?e:P(t,n++,e.value)}))},e}(G);function nt(){return et||(et=new $([]))}function it(t){var e=ut(t);if(e)return e.fromEntrySeq();if("object"==typeof t)return new tt(t);throw new TypeError("Expected Array or collection object of [k, v] entries, or keyed object: "+t)}function ot(t){var e=ut(t);if(e)return e;throw new TypeError("Expected Array or collection object of values: "+t)}function ut(t){return Q(t)?new $(t):N(t)?new rt(t):void 0}var st="@@__IMMUTABLE_MAP__@@";function at(t){return Boolean(t&&t[st])}function ct(t){return at(t)&&k(t)}function ft(t){return Boolean(t&&"function"==typeof t.equals&&"function"==typeof t.hashCode)}function ht(t,e){if(t===e||t!=t&&e!=e)return!0;if(!t||!e)return!1;if("function"==typeof t.valueOf&&"function"==typeof e.valueOf){if((t=t.valueOf())===(e=e.valueOf())||t!=t&&e!=e)return!0;if(!t||!e)return!1}return!!(ft(t)&&ft(e)&&t.equals(e))}var pt="function"==typeof Math.imul&&-2===Math.imul(4294967295,2)?Math.imul:function(t,e){var r=65535&(t|=0),n=65535&(e|=0);return r*n+((t>>>16)*n+r*(e>>>16)<<16>>>0)|0};function _t(t){return t>>>1&1073741824|3221225471&t}var lt=Object.prototype.valueOf;function vt(t){if(null==t)return yt(t);if("function"==typeof t.hashCode)return _t(t.hashCode(t));var e,r=(e=t).valueOf!==lt&&"function"==typeof e.valueOf?e.valueOf(e):e;if(null==r)return yt(r);switch(typeof r){case"boolean":return r?1108378657:1108378656;case"number":return function(t){if(t!=t||t===1/0)return 0;var e=0|t;e!==t&&(e^=4294967295*t);for(;t>4294967295;)e^=t/=4294967295;return _t(e)}(r);case"string":return r.length>Et?function(t){var e=Mt[t];void 0===e&&(e=dt(t),qt===jt&&(qt=0,Mt={}),qt++,Mt[t]=e);return e}(r):dt(r);case"object":case"function":return function(t){var e;if(zt&&void 0!==(e=bt.get(t)))return e;if(e=t[Ot],void 0!==e)return e;if(!wt){if(void 0!==(e=t.propertyIsEnumerable&&t.propertyIsEnumerable[Ot]))return e;if(void 0!==(e=function(t){if(t&&t.nodeType>0)switch(t.nodeType){case 1:return t.uniqueID;case 9:return t.documentElement&&t.documentElement.uniqueID}}(t)))return e}if(e=mt(),zt)bt.set(t,e);else{if(void 0!==gt&&!1===gt(t))throw new Error("Non-extensible objects are not allowed as keys.");if(wt)Object.defineProperty(t,Ot,{enumerable:!1,configurable:!1,writable:!1,value:e});else if(void 0!==t.propertyIsEnumerable&&t.propertyIsEnumerable===t.constructor.prototype.propertyIsEnumerable)t.propertyIsEnumerable=function(){return this.constructor.prototype.propertyIsEnumerable.apply(this,arguments)},t.propertyIsEnumerable[Ot]=e;else{if(void 0===t.nodeType)throw new Error("Unable to set a non-enumerable property on object.");t[Ot]=e}}return e}(r);case"symbol":return function(t){var e=St[t];if(void 0!==e)return e;return e=mt(),St[t]=e,e}(r);default:if("function"==typeof r.toString)return dt(r.toString());throw new Error("Value type "+typeof r+" cannot be hashed.")}}function yt(t){return null===t?1108378658:1108378659}function dt(t){for(var e=0,r=0;r=0&&(a.get=function(e,r){return(e=c(this,e))>=0&&eo)return{value:void 0,done:!0};var t=i.next();return n||e===U||t.done?t:P(e,a-1,e===R?void 0:t.value[1],t)}))},a}function Lt(t,e,r,n){var i=Xt(t);return i.__iterateUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterate(i,o);var s=!0,a=0;return t.__iterate((function(t,o,c){if(!s||!(s=e.call(r,t,o,c)))return a++,i(t,n?o:a-1,u)})),a},i.__iteratorUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterator(i,o);var s=t.__iterator(T,o),a=!0,c=0;return new C((function(){var t,o,f;do{if((t=s.next()).done)return n||i===U?t:P(i,c++,i===R?void 0:t.value[1],t);var h=t.value;o=h[0],f=h[1],a&&(a=e.call(r,f,o,u))}while(a);return i===T?t:P(i,o,f,t)}))},i}xt.prototype.cacheResult=Dt.prototype.cacheResult=At.prototype.cacheResult=kt.prototype.cacheResult=Ft;var Ct=function(t){function e(t){this._wrappedIterables=t.flatMap((function(t){return t._wrappedIterables?t._wrappedIterables:[t]})),this.size=this._wrappedIterables.reduce((function(t,e){if(void 0!==t){var r=e.size;if(void 0!==r)return t+r}}),0),this[g]=this._wrappedIterables[0][g],this[m]=this._wrappedIterables[0][m],this[A]=this._wrappedIterables[0][A]}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.__iterateUncached=function(t,e){if(0!==this._wrappedIterables.length){if(e)return this.cacheResult().__iterate(t,e);for(var r=0,n=w(this),i=n?T:U,o=this._wrappedIterables[r].__iterator(i,e),u=!0,s=0;u;){for(var a=o.next();a.done;){if(++r===this._wrappedIterables.length)return s;a=(o=this._wrappedIterables[r].__iterator(i,e)).next()}u=!1!==(n?t(a.value[1],a.value[0],this):t(a.value,s,this)),s++}return s}},e.prototype.__iteratorUncached=function(t,e){var r=this;if(0===this._wrappedIterables.length)return new C(W);if(e)return this.cacheResult().__iterator(t,e);var n=0,i=this._wrappedIterables[n].__iterator(t,e);return new C((function(){for(var o=i.next();o.done;){if(++n===r._wrappedIterables.length)return o;o=(i=r._wrappedIterables[n].__iterator(t,e)).next()}return o}))},e}(X);function Pt(t,e,r){var n=Xt(t);return n.__iterateUncached=function(i,o){if(o)return this.cacheResult().__iterate(i,o);var u=0,s=!1;return function t(a,c){a.__iterate((function(o,a){return(!e||c0}function Jt(t,e,r,n){var i=Xt(t),o=new $(r).map((function(t){return t.size}));return i.size=n?o.max():o.min(),i.__iterate=function(t,e){for(var r,n=this.__iterator(U,e),i=0;!(r=n.next()).done&&!1!==t(r.value,i++,this););return i},i.__iteratorUncached=function(t,i){var o=r.map((function(t){return t=S(t),J(i?t.reverse():t)})),u=0,s=!1;return new C((function(){var r;return s||(r=o.map((function(t){return t.next()})),s=n?r.every((function(t){return t.done})):r.some((function(t){return t.done}))),s?{value:void 0,done:!0}:P(t,u++,e.apply(null,r.map((function(t){return t.value}))))}))},i}function Vt(t,e){return t===e?t:q(t)?e:t.constructor(e)}function Yt(t){if(t!==Object(t))throw new TypeError("Expected [K, V] tuple: "+t)}function Qt(t){return w(t)?I:b(t)?O:E}function Xt(t){return Object.create((w(t)?F:b(t)?G:Z).prototype)}function Ft(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size,this):X.prototype.cacheResult.call(this)}function Gt(t,e){return void 0===t&&void 0===e?0:void 0===t?1:void 0===e?-1:t>e?1:t0;)e[r]=arguments[r+1];if("function"!=typeof t)throw new TypeError("Invalid merger function: "+t);return ze(this,e,t)}function ze(t,e,r){for(var n=[],i=0;i0;)e[r]=arguments[r+1];return Se(this,e,t)}function je(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return he(this,t,Je(),(function(t){return Ie(t,e)}))}function qe(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return he(this,t,Je(),(function(t){return Se(t,e)}))}function Me(t){var e=this.asMutable();return t(e),e.wasAltered()?e.__ensureOwner(this.__ownerID):this}function De(){return this.__ownerID?this:this.__ensureOwner(new s)}function xe(){return this.__ensureOwner()}function Ae(){return this.__altered}var ke=function(t){function e(e){return null==e?Je():at(e)&&!k(e)?e:Je().withMutations((function(r){var n=t(e);te(n.size),n.forEach((function(t,e){return r.set(e,t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toString=function(){return this.__toString("Map {","}")},e.prototype.get=function(t,e){return this._root?this._root.get(0,void 0,t,e):e},e.prototype.set=function(t,e){return Ve(this,t,e)},e.prototype.remove=function(t){return Ve(this,t,o)},e.prototype.deleteAll=function(t){var e=S(t);return 0===e.size?this:this.withMutations((function(t){e.forEach((function(e){return t.remove(e)}))}))},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):Je()},e.prototype.sort=function(t){return yr(Wt(this,t))},e.prototype.sortBy=function(t,e){return yr(Wt(this,e,t))},e.prototype.map=function(t,e){var r=this;return this.withMutations((function(n){n.forEach((function(i,o){n.set(o,t.call(e,i,o,r))}))}))},e.prototype.__iterator=function(t,e){return new Pe(this,t,e)},e.prototype.__iterate=function(t,e){var r=this,n=0;return this._root&&this._root.iterate((function(e){return n++,t(e[1],e[0],r)}),e),n},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?He(this.size,this._root,t,this.__hash):0===this.size?Je():(this.__ownerID=t,this.__altered=!1,this)},e}(I);ke.isMap=at;var Re=ke.prototype;Re[st]=!0,Re[e]=Re.remove,Re.removeAll=Re.deleteAll,Re.setIn=le,Re.removeIn=Re.deleteIn=ye,Re.update=ge,Re.updateIn=we,Re.merge=Re.concat=me,Re.mergeWith=be,Re.mergeDeep=Oe,Re.mergeDeepWith=Ee,Re.mergeIn=je,Re.mergeDeepIn=qe,Re.withMutations=Me,Re.wasAltered=Ae,Re.asImmutable=xe,Re["@@transducer/init"]=Re.asMutable=De,Re["@@transducer/step"]=function(t,e){return t.set(e[0],e[1])},Re["@@transducer/result"]=function(t){return t.asImmutable()};var Ue=function(t,e){this.ownerID=t,this.entries=e};Ue.prototype.get=function(t,e,r,n){for(var i=this.entries,o=0,u=i.length;o=Ze)return function(t,e,r,n){t||(t=new s);for(var i=new Le(t,vt(r),[r,n]),o=0;o>>t)&i),s=this.bitmap;return 0==(s&u)?o:this.nodes[Fe(s&u-1)].get(t+r,e,n,o)},Te.prototype.update=function(t,e,u,s,a,c,f){void 0===u&&(u=vt(s));var h=(0===e?u:u>>>e)&i,p=1<=$e)return function(t,e,r,i,o){for(var u=0,s=new Array(n),a=0;0!==r;a++,r>>>=1)s[a]=1&r?e[u++]:void 0;return s[i]=o,new Be(t,u+1,s)}(t,y,_,h,g);if(l&&!g&&2===y.length&&Qe(y[1^v]))return y[1^v];if(l&&g&&1===y.length&&Qe(g))return g;var w=t&&t===this.ownerID,m=l?g?_:_^p:_|p,b=l?g?Ge(y,v,g,w):function(t,e,r){var n=t.length-1;if(r&&e===n)return t.pop(),t;for(var i=new Array(n),o=0,u=0;u>>t)&i,s=this.nodes[u];return s?s.get(t+r,e,n,o):o},Be.prototype.update=function(t,e,n,u,s,a,c){void 0===n&&(n=vt(u));var f=(0===e?n:n>>>e)&i,h=s===o,p=this.nodes,_=p[f];if(h&&!_)return this;var l=Ye(_,t,e+r,n,u,s,a,c);if(l===_)return this;var v=this.count;if(_){if(!l&&--v>>n)&i,c=(0===n?o:o>>>n)&i,f=a===c?[Xe(t,e,n+r,o,u)]:(s=new Le(e,o,u),a>1&1431655765))+(t>>2&858993459))+(t>>4)&252645135,t+=t>>8,127&(t+=t>>16)}function Ge(t,e,r,n){var i=n?t:Zt(t);return i[e]=r,i}var Ze=n/4,$e=n/2,tr=n/4,er="@@__IMMUTABLE_LIST__@@";function rr(t){return Boolean(t&&t[er])}var nr=function(t){function e(e){var i=cr();if(null==e)return i;if(rr(e))return e;var o=t(e),u=o.size;return 0===u?i:(te(u),u>0&&u=0&&t=t.size||e<0)return t.withMutations((function(t){e<0?_r(t,e).set(0,r):_r(t,0,e+1).set(e,r)}));e+=t._origin;var n=t._tail,i=t._root,o={value:!1};e>=lr(t._capacity)?n=fr(n,t.__ownerID,0,e,r,o):i=fr(i,t.__ownerID,t._level,e,r,o);if(!o.value)return t;if(t.__ownerID)return t._root=i,t._tail=n,t.__hash=void 0,t.__altered=!0,t;return ar(t._origin,t._capacity,t._level,i,n)}(this,t,e)},e.prototype.remove=function(t){return this.has(t)?0===t?this.shift():t===this.size-1?this.pop():this.splice(t,1):this},e.prototype.insert=function(t,e){return this.splice(t,0,e)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=this._origin=this._capacity=0,this._level=r,this._root=this._tail=this.__hash=void 0,this.__altered=!0,this):cr()},e.prototype.push=function(){var t=arguments,e=this.size;return this.withMutations((function(r){_r(r,0,e+t.length);for(var n=0;n>>e&i;if(o>=this.array.length)return new or([],t);var u,s=0===o;if(e>0){var a=this.array[o];if((u=a&&a.removeBefore(t,e-r,n))===a&&s)return this}if(s&&!u)return this;var c=hr(this,t);if(!s)for(var f=0;f>>e&i;if(s>=this.array.length)return this;if(e>0){var a=this.array[s];if((u=a&&a.removeAfter(t,e-r,o))===a&&s===this.array.length-1)return this}var c=hr(this,t);return c.array.splice(s+1),u&&(c.array[s]=u),c};var ur={};function sr(t,e){var i=t._origin,o=t._capacity,u=lr(o),s=t._tail;return a(t._root,t._level,0);function a(t,c,f){return 0===c?function(t,r){var a=r===u?s&&s.array:t&&t.array,c=r>i?0:i-r,f=o-r;f>n&&(f=n);return function(){if(c===f)return ur;var t=e?--f:c++;return a&&a[t]}}(t,f):function(t,u,s){var c,f=t&&t.array,h=s>i?0:i-s>>u,p=1+(o-s>>u);p>n&&(p=n);return function(){for(;;){if(c){var t=c();if(t!==ur)return t;c=null}if(h===p)return ur;var n=e?--p:h++;c=a(f&&f[n],u-r,s+(n<>>n&i,h=t&&f0){var p=t&&t.array[f],_=fr(p,e,n-r,o,s,a);return _===p?t:((c=hr(t,e)).array[f]=_,c)}return h&&t.array[f]===s?t:(a&&u(a),c=hr(t,e),void 0===s&&f===c.array.length-1?c.array.pop():c.array[f]=s,c)}function hr(t,e){return e&&t&&e===t.ownerID?t:new or(t?t.array.slice():[],e)}function pr(t,e){if(e>=lr(t._capacity))return t._tail;if(e<1<0;)n=n.array[e>>>o&i],o-=r;return n}}function _r(t,e,n){void 0!==e&&(e|=0),void 0!==n&&(n|=0);var o=t.__ownerID||new s,u=t._origin,a=t._capacity,c=u+e,f=void 0===n?a:n<0?a+n:u+n;if(c===u&&f===a)return t;if(c>=f)return t.clear();for(var h=t._level,p=t._root,_=0;c+_<0;)p=new or(p&&p.array.length?[void 0,p]:[],o),_+=1<<(h+=r);_&&(c+=_,u+=_,f+=_,a+=_);for(var l=lr(a),v=lr(f);v>=1<l?new or([],o):y;if(y&&v>l&&cr;w-=r){var m=l>>>w&i;g=g.array[m]=hr(g.array[m],o)}g.array[l>>>r&i]=y}if(f=v)c-=v,f-=v,h=r,p=null,d=d&&d.removeBefore(o,0,c);else if(c>u||v>>h&i;if(b!==v>>>h&i)break;b&&(_+=(1<u&&(p=p.removeBefore(o,h,c-_)),p&&v>>r<=n&&a.size>=2*s.size?(i=(u=a.filter((function(t,e){return void 0!==t&&c!==e}))).toKeyedSeq().map((function(t){return t[0]})).flip().toMap(),t.__ownerID&&(i.__ownerID=u.__ownerID=t.__ownerID)):(i=s.remove(e),u=c===a.size-1?a.pop():a.set(c,void 0))}else if(f){if(r===a.get(c)[1])return t;i=s,u=a.set(c,[e,r])}else i=s.set(e,a.size),u=a.set(a.size,[e,r]);return t.__ownerID?(t.size=i.size,t._map=i,t._list=u,t.__hash=void 0,t.__altered=!0,t):dr(i,u)}yr.isOrderedMap=ct,yr.prototype[A]=!0,yr.prototype[e]=yr.prototype.remove;var mr="@@__IMMUTABLE_STACK__@@";function br(t){return Boolean(t&&t[mr])}var zr=function(t){function e(t){return null==t?Er():br(t)?t:Er().pushAll(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("Stack [","]")},e.prototype.get=function(t,e){var r=this._head;for(t=c(this,t);r&&t--;)r=r.next;return r?r.value:e},e.prototype.peek=function(){return this._head&&this._head.value},e.prototype.push=function(){var t=arguments;if(0===arguments.length)return this;for(var e=this.size+arguments.length,r=this._head,n=arguments.length-1;n>=0;n--)r={value:t[n],next:r};return this.__ownerID?(this.size=e,this._head=r,this.__hash=void 0,this.__altered=!0,this):Or(e,r)},e.prototype.pushAll=function(e){if(0===(e=t(e)).size)return this;if(0===this.size&&br(e))return e;te(e.size);var r=this.size,n=this._head;return e.__iterate((function(t){r++,n={value:t,next:n}}),!0),this.__ownerID?(this.size=r,this._head=n,this.__hash=void 0,this.__altered=!0,this):Or(r,n)},e.prototype.pop=function(){return this.slice(1)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):Er()},e.prototype.slice=function(e,r){if(h(e,r,this.size))return this;var n=p(e,this.size);if(_(r,this.size)!==this.size)return t.prototype.slice.call(this,e,r);for(var i=this.size-n,o=this._head;n--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):Or(i,o)},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Or(this.size,this._head,t,this.__hash):0===this.size?Er():(this.__ownerID=t,this.__altered=!1,this)},e.prototype.__iterate=function(t,e){var r=this;if(e)return new $(this.toArray()).__iterate((function(e,n){return t(e,n,r)}),e);for(var n=0,i=this._head;i&&!1!==t(i.value,n++,this);)i=i.next;return n},e.prototype.__iterator=function(t,e){if(e)return new $(this.toArray()).__iterator(t,e);var r=0,n=this._head;return new C((function(){if(n){var e=n.value;return n=n.next,P(t,r++,e)}return{value:void 0,done:!0}}))},e}(O);zr.isStack=br;var Sr,Ir=zr.prototype;function Or(t,e,r,n){var i=Object.create(Ir);return i.size=t,i._head=e,i.__ownerID=r,i.__hash=n,i.__altered=!1,i}function Er(){return Sr||(Sr=Or(0))}Ir[mr]=!0,Ir.shift=Ir.pop,Ir.unshift=Ir.push,Ir.unshiftAll=Ir.pushAll,Ir.withMutations=Me,Ir.wasAltered=Ae,Ir.asImmutable=xe,Ir["@@transducer/init"]=Ir.asMutable=De,Ir["@@transducer/step"]=function(t,e){return t.unshift(e)},Ir["@@transducer/result"]=function(t){return t.asImmutable()};var jr="@@__IMMUTABLE_SET__@@";function qr(t){return Boolean(t&&t[jr])}function Mr(t){return qr(t)&&k(t)}function Dr(t,e){if(t===e)return!0;if(!d(e)||void 0!==t.size&&void 0!==e.size&&t.size!==e.size||void 0!==t.__hash&&void 0!==e.__hash&&t.__hash!==e.__hash||w(t)!==w(e)||b(t)!==b(e)||k(t)!==k(e))return!1;if(0===t.size&&0===e.size)return!0;var r=!z(t);if(k(t)){var n=t.entries();return e.every((function(t,e){var i=n.next().value;return i&&ht(i[1],t)&&(r||ht(i[0],e))}))&&n.next().done}var i=!1;if(void 0===t.size)if(void 0===e.size)"function"==typeof t.cacheResult&&t.cacheResult();else{i=!0;var u=t;t=e,e=u}var s=!0,a=e.__iterate((function(e,n){if(r?!t.has(e):i?!ht(e,t.get(n,o)):!ht(t.get(n,o),e))return s=!1,!1}));return s&&t.size===a}function xr(t,e){var r=function(r){t.prototype[r]=e[r]};return Object.keys(e).forEach(r),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(e).forEach(r),t}function Ar(t){if(!t||"object"!=typeof t)return t;if(!d(t)){if(!ie(t))return t;t=X(t)}if(w(t)){var e={};return t.__iterate((function(t,r){e[r]=Ar(t)})),e}var r=[];return t.__iterate((function(t){r.push(Ar(t))})),r}var kr=function(t){function e(e){return null==e?Kr():qr(e)&&!k(e)?e:Kr().withMutations((function(r){var n=t(e);te(n.size),n.forEach((function(t){return r.add(t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(I(t).keySeq())},e.intersect=function(t){return(t=S(t).toArray()).length?Ur.intersect.apply(e(t.pop()),t):Kr()},e.union=function(t){return(t=S(t).toArray()).length?Ur.union.apply(e(t.pop()),t):Kr()},e.prototype.toString=function(){return this.__toString("Set {","}")},e.prototype.has=function(t){return this._map.has(t)},e.prototype.add=function(t){return Tr(this,this._map.set(t,t))},e.prototype.remove=function(t){return Tr(this,this._map.remove(t))},e.prototype.clear=function(){return Tr(this,this._map.clear())},e.prototype.map=function(t,e){var r=this,n=!1,i=Tr(this,this._map.mapEntries((function(i){var o=i[1],u=t.call(e,o,o,r);return u!==o&&(n=!0),[u,u]}),e));return n?i:this},e.prototype.union=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return 0===(e=e.filter((function(t){return 0!==t.size}))).length?this:0!==this.size||this.__ownerID||1!==e.length?this.withMutations((function(r){for(var n=0;n=0&&e=0&&r>>-15,461845907),e=pt(e<<13|e>>>-13,5),e=pt((e=(e+3864292196|0)^t)^e>>>16,2246822507),e=_t((e=pt(e^e>>>13,3266489909))^e>>>16)}(t.size,n)}(this))}});var Jr=S.prototype;Jr[y]=!0,Jr[L]=Jr.values,Jr.toJSON=Jr.toArray,Jr.__toStringMapper=oe,Jr.inspect=Jr.toSource=function(){return this.toString()},Jr.chain=Jr.flatMap,Jr.contains=Jr.includes,xr(I,{flip:function(){return Vt(this,Rt(this))},mapEntries:function(t,e){var r=this,n=0;return Vt(this,this.toSeq().map((function(i,o){return t.call(e,[o,i],n++,r)})).fromEntrySeq())},mapKeys:function(t,e){var r=this;return Vt(this,this.toSeq().flip().map((function(n,i){return t.call(e,n,i,r)})).flip())}});var Vr=I.prototype;Vr[g]=!0,Vr[L]=Jr.entries,Vr.toJSON=Hr,Vr.__toStringMapper=function(t,e){return oe(e)+": "+oe(t)},xr(O,{toKeyedSeq:function(){return new Dt(this,!1)},filter:function(t,e){return Vt(this,Bt(this,t,e,!1))},findIndex:function(t,e){var r=this.findEntry(t,e);return r?r[0]:-1},indexOf:function(t){var e=this.keyOf(t);return void 0===e?-1:e},lastIndexOf:function(t){var e=this.lastKeyOf(t);return void 0===e?-1:e},reverse:function(){return Vt(this,Tt(this,!1))},slice:function(t,e){return Vt(this,Kt(this,t,e,!1))},splice:function(t,e){var r=arguments.length;if(e=Math.max(e||0,0),0===r||2===r&&!e)return this;t=p(t,t<0?this.count():this.size);var n=this.slice(0,t);return Vt(this,1===r?n:n.concat(Zt(arguments,2),this.slice(t+e)))},findLastIndex:function(t,e){var r=this.findLastEntry(t,e);return r?r[0]:-1},first:function(t){return this.get(0,t)},flatten:function(t){return Vt(this,Pt(this,t,!1))},get:function(t,e){return(t=c(this,t))<0||this.size===1/0||void 0!==this.size&&t>this.size?e:this.find((function(e,r){return r===t}),void 0,e)},has:function(t){return(t=c(this,t))>=0&&(void 0!==this.size?this.size===1/0||te?-1:0}function rn(t,e){return t^e+2654435769+(t<<6)+(t>>2)|0}Qr.has=Jr.includes,Qr.contains=Qr.includes,Qr.keys=Qr.values,xr(F,Vr),xr(G,Yr),xr(Z,Qr);var nn=function(t){function e(t){return null==t?an():Mr(t)?t:an().withMutations((function(e){var r=E(t);te(r.size),r.forEach((function(t){return e.add(t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(I(t).keySeq())},e.prototype.toString=function(){return this.__toString("OrderedSet {","}")},e}(kr);nn.isOrderedSet=Mr;var on,un=nn.prototype;function sn(t,e){var r=Object.create(un);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function an(){return on||(on=sn(gr()))}un[A]=!0,un.zip=Yr.zip,un.zipWith=Yr.zipWith,un.zipAll=Yr.zipAll,un.__empty=an,un.__make=sn;var cn=function(t,e){var r;!function(t){if(D(t))throw new Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(x(t))throw new Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(null===t||"object"!=typeof t)throw new Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}(t);var n=function(o){var u=this;if(o instanceof n)return o;if(!(this instanceof n))return new n(o);if(!r){r=!0;var s=Object.keys(t),a=i._indices={};i._name=e,i._keys=s,i._defaultValues=t;for(var c=0;c2?[]:void 0,{"":t})},t.get=se,t.getIn=Pr,t.has=ue,t.hasIn=Nr,t.hash=vt,t.is=ht,t.isAssociative=z,t.isCollection=d,t.isImmutable=x,t.isIndexed=b,t.isKeyed=w,t.isList=rr,t.isMap=at,t.isOrdered=k,t.isOrderedMap=ct,t.isOrderedSet=Mr,t.isPlainObject=ne,t.isRecord=D,t.isSeq=q,t.isSet=qr,t.isStack=br,t.isValueObject=ft,t.merge=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Ie(t,e)},t.mergeDeep=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Se(t,e)},t.mergeDeepWith=function(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];return Se(e,r,t)},t.mergeWith=function(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];return Ie(e,r,t)},t.remove=ce,t.removeIn=ve,t.set=fe,t.setIn=_e,t.update=de,t.updateIn=he,t.version="5.1.1"})); From 3292755eb08d56f3b92a40f39bdb1c9bf0757716 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 5 May 2025 22:25:57 +0000 Subject: [PATCH 241/242] deploy: ec2ba80fe791f58ffbc0930d357f2712b2baed45 --- dist/immutable.es.js | 4 +++- dist/immutable.js | 4 +++- dist/immutable.min.js | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/dist/immutable.es.js b/dist/immutable.es.js index 9ad755ace2..825944c049 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -2434,7 +2434,9 @@ function mergeIntoKeyedWith(collection, collections, merger) { !collection.__ownerID && iters.length === 1 ) { - return collection.constructor(iters[0]); + return isRecord(collection) + ? collection // Record is empty and will not be updated: return the same instance + : collection.constructor(iters[0]); } return collection.withMutations(function (collection) { var mergeIntoCollection = merger diff --git a/dist/immutable.js b/dist/immutable.js index db05103be9..a935c1cae7 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -2440,7 +2440,9 @@ !collection.__ownerID && iters.length === 1 ) { - return collection.constructor(iters[0]); + return isRecord(collection) + ? collection // Record is empty and will not be updated: return the same instance + : collection.constructor(iters[0]); } return collection.withMutations(function (collection) { var mergeIntoCollection = merger diff --git a/dist/immutable.min.js b/dist/immutable.min.js index 3d6439a381..3465f4120b 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -22,4 +22,4 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).Immutable={})}(this,(function(t){"use strict";var e="delete",r=5,n=1<>>0;if(""+r!==e||4294967295===r)return NaN;e=r}return e<0?a(t)+e:e}function f(){return!0}function h(t,e,r){return(0===t&&!v(t)||void 0!==r&&t<=-r)&&(void 0===e||void 0!==r&&e>=r)}function p(t,e){return l(t,e,0)}function _(t,e){return l(t,e,e)}function l(t,e,r){return void 0===t?r:v(t)?e===1/0?e:0|Math.max(0,e+t):void 0===e||e===t?t:0|Math.min(e,t)}function v(t){return t<0||0===t&&1/t==-1/0}var y="@@__IMMUTABLE_ITERABLE__@@";function d(t){return Boolean(t&&t[y])}var g="@@__IMMUTABLE_KEYED__@@";function w(t){return Boolean(t&&t[g])}var m="@@__IMMUTABLE_INDEXED__@@";function b(t){return Boolean(t&&t[m])}function z(t){return w(t)||b(t)}var S=function(t){return d(t)?t:X(t)},I=function(t){function e(t){return w(t)?t:F(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(S),O=function(t){function e(t){return b(t)?t:G(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(S),E=function(t){function e(t){return d(t)&&!z(t)?t:Z(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(S);S.Keyed=I,S.Indexed=O,S.Set=E;var j="@@__IMMUTABLE_SEQ__@@";function q(t){return Boolean(t&&t[j])}var M="@@__IMMUTABLE_RECORD__@@";function D(t){return Boolean(t&&t[M])}function x(t){return d(t)||D(t)}var A="@@__IMMUTABLE_ORDERED__@@";function k(t){return Boolean(t&&t[A])}var R=0,U=1,T=2,B="function"==typeof Symbol&&Symbol.iterator,K="@@iterator",L=B||K,C=function(t){this.next=t};function P(t,e,r,n){var i=t===R?e:t===U?r:[e,r];return n?n.value=i:n={value:i,done:!1},n}function W(){return{value:void 0,done:!0}}function N(t){return!!Array.isArray(t)||!!V(t)}function H(t){return t&&"function"==typeof t.next}function J(t){var e=V(t);return e&&e.call(t)}function V(t){var e=t&&(B&&t[B]||t[K]);if("function"==typeof e)return e}C.prototype.toString=function(){return"[Iterator]"},C.KEYS=R,C.VALUES=U,C.ENTRIES=T,C.prototype.inspect=C.prototype.toSource=function(){return this.toString()},C.prototype[L]=function(){return this};var Y=Object.prototype.hasOwnProperty;function Q(t){return!(!Array.isArray(t)&&"string"!=typeof t)||t&&"object"==typeof t&&Number.isInteger(t.length)&&t.length>=0&&(0===t.length?1===Object.keys(t).length:t.hasOwnProperty(t.length-1))}var X=function(t){function e(t){return null==t?nt():x(t)?t.toSeq():function(t){var e=ut(t);if(e)return(n=V(r=t))&&n===r.entries?e.fromEntrySeq():function(t){var e=V(t);return e&&e===t.keys}(t)?e.toSetSeq():e;var r,n;if("object"==typeof t)return new tt(t);throw new TypeError("Expected Array or collection object of values, or keyed object: "+t)}(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq {","}")},e.prototype.cacheResult=function(){return!this._cache&&this.__iterateUncached&&(this._cache=this.entrySeq().toArray(),this.size=this._cache.length),this},e.prototype.__iterate=function(t,e){var r=this._cache;if(r){for(var n=r.length,i=0;i!==n;){var o=r[e?n-++i:i++];if(!1===t(o[1],o[0],this))break}return i}return this.__iterateUncached(t,e)},e.prototype.__iterator=function(t,e){var r=this._cache;if(r){var n=r.length,i=0;return new C((function(){if(i===n)return{value:void 0,done:!0};var o=r[e?n-++i:i++];return P(t,o[0],o[1])}))}return this.__iteratorUncached(t,e)},e}(S),F=function(t){function e(t){return null==t?nt().toKeyedSeq():d(t)?w(t)?t.toSeq():t.fromEntrySeq():D(t)?t.toSeq():it(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toKeyedSeq=function(){return this},e}(X),G=function(t){function e(t){return null==t?nt():d(t)?w(t)?t.entrySeq():t.toIndexedSeq():D(t)?t.toSeq().entrySeq():ot(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return e(arguments)},e.prototype.toIndexedSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq [","]")},e}(X),Z=function(t){function e(t){return(d(t)&&!z(t)?t:G(t)).toSetSeq()}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return e(arguments)},e.prototype.toSetSeq=function(){return this},e}(X);X.isSeq=q,X.Keyed=F,X.Set=Z,X.Indexed=G,X.prototype[j]=!0;var $=function(t){function e(t){this._array=t,this.size=t.length}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t,e){return this.has(t)?this._array[c(this,t)]:e},e.prototype.__iterate=function(t,e){for(var r=this._array,n=r.length,i=0;i!==n;){var o=e?n-++i:i++;if(!1===t(r[o],o,this))break}return i},e.prototype.__iterator=function(t,e){var r=this._array,n=r.length,i=0;return new C((function(){if(i===n)return{value:void 0,done:!0};var o=e?n-++i:i++;return P(t,o,r[o])}))},e}(G),tt=function(t){function e(t){var e=Object.keys(t).concat(Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(t):[]);this._object=t,this._keys=e,this.size=e.length}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t,e){return void 0===e||this.has(t)?this._object[t]:e},e.prototype.has=function(t){return Y.call(this._object,t)},e.prototype.__iterate=function(t,e){for(var r=this._object,n=this._keys,i=n.length,o=0;o!==i;){var u=n[e?i-++o:o++];if(!1===t(r[u],u,this))break}return o},e.prototype.__iterator=function(t,e){var r=this._object,n=this._keys,i=n.length,o=0;return new C((function(){if(o===i)return{value:void 0,done:!0};var u=n[e?i-++o:o++];return P(t,u,r[u])}))},e}(F);tt.prototype[A]=!0;var et,rt=function(t){function e(t){this._collection=t,this.size=t.length||t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.__iterateUncached=function(t,e){if(e)return this.cacheResult().__iterate(t,e);var r=J(this._collection),n=0;if(H(r))for(var i;!(i=r.next()).done&&!1!==t(i.value,n++,this););return n},e.prototype.__iteratorUncached=function(t,e){if(e)return this.cacheResult().__iterator(t,e);var r=J(this._collection);if(!H(r))return new C(W);var n=0;return new C((function(){var e=r.next();return e.done?e:P(t,n++,e.value)}))},e}(G);function nt(){return et||(et=new $([]))}function it(t){var e=ut(t);if(e)return e.fromEntrySeq();if("object"==typeof t)return new tt(t);throw new TypeError("Expected Array or collection object of [k, v] entries, or keyed object: "+t)}function ot(t){var e=ut(t);if(e)return e;throw new TypeError("Expected Array or collection object of values: "+t)}function ut(t){return Q(t)?new $(t):N(t)?new rt(t):void 0}var st="@@__IMMUTABLE_MAP__@@";function at(t){return Boolean(t&&t[st])}function ct(t){return at(t)&&k(t)}function ft(t){return Boolean(t&&"function"==typeof t.equals&&"function"==typeof t.hashCode)}function ht(t,e){if(t===e||t!=t&&e!=e)return!0;if(!t||!e)return!1;if("function"==typeof t.valueOf&&"function"==typeof e.valueOf){if((t=t.valueOf())===(e=e.valueOf())||t!=t&&e!=e)return!0;if(!t||!e)return!1}return!!(ft(t)&&ft(e)&&t.equals(e))}var pt="function"==typeof Math.imul&&-2===Math.imul(4294967295,2)?Math.imul:function(t,e){var r=65535&(t|=0),n=65535&(e|=0);return r*n+((t>>>16)*n+r*(e>>>16)<<16>>>0)|0};function _t(t){return t>>>1&1073741824|3221225471&t}var lt=Object.prototype.valueOf;function vt(t){if(null==t)return yt(t);if("function"==typeof t.hashCode)return _t(t.hashCode(t));var e,r=(e=t).valueOf!==lt&&"function"==typeof e.valueOf?e.valueOf(e):e;if(null==r)return yt(r);switch(typeof r){case"boolean":return r?1108378657:1108378656;case"number":return function(t){if(t!=t||t===1/0)return 0;var e=0|t;e!==t&&(e^=4294967295*t);for(;t>4294967295;)e^=t/=4294967295;return _t(e)}(r);case"string":return r.length>Et?function(t){var e=Mt[t];void 0===e&&(e=dt(t),qt===jt&&(qt=0,Mt={}),qt++,Mt[t]=e);return e}(r):dt(r);case"object":case"function":return function(t){var e;if(zt&&void 0!==(e=bt.get(t)))return e;if(e=t[Ot],void 0!==e)return e;if(!wt){if(void 0!==(e=t.propertyIsEnumerable&&t.propertyIsEnumerable[Ot]))return e;if(void 0!==(e=function(t){if(t&&t.nodeType>0)switch(t.nodeType){case 1:return t.uniqueID;case 9:return t.documentElement&&t.documentElement.uniqueID}}(t)))return e}if(e=mt(),zt)bt.set(t,e);else{if(void 0!==gt&&!1===gt(t))throw new Error("Non-extensible objects are not allowed as keys.");if(wt)Object.defineProperty(t,Ot,{enumerable:!1,configurable:!1,writable:!1,value:e});else if(void 0!==t.propertyIsEnumerable&&t.propertyIsEnumerable===t.constructor.prototype.propertyIsEnumerable)t.propertyIsEnumerable=function(){return this.constructor.prototype.propertyIsEnumerable.apply(this,arguments)},t.propertyIsEnumerable[Ot]=e;else{if(void 0===t.nodeType)throw new Error("Unable to set a non-enumerable property on object.");t[Ot]=e}}return e}(r);case"symbol":return function(t){var e=St[t];if(void 0!==e)return e;return e=mt(),St[t]=e,e}(r);default:if("function"==typeof r.toString)return dt(r.toString());throw new Error("Value type "+typeof r+" cannot be hashed.")}}function yt(t){return null===t?1108378658:1108378659}function dt(t){for(var e=0,r=0;r=0&&(a.get=function(e,r){return(e=c(this,e))>=0&&eo)return{value:void 0,done:!0};var t=i.next();return n||e===U||t.done?t:P(e,a-1,e===R?void 0:t.value[1],t)}))},a}function Lt(t,e,r,n){var i=Xt(t);return i.__iterateUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterate(i,o);var s=!0,a=0;return t.__iterate((function(t,o,c){if(!s||!(s=e.call(r,t,o,c)))return a++,i(t,n?o:a-1,u)})),a},i.__iteratorUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterator(i,o);var s=t.__iterator(T,o),a=!0,c=0;return new C((function(){var t,o,f;do{if((t=s.next()).done)return n||i===U?t:P(i,c++,i===R?void 0:t.value[1],t);var h=t.value;o=h[0],f=h[1],a&&(a=e.call(r,f,o,u))}while(a);return i===T?t:P(i,o,f,t)}))},i}xt.prototype.cacheResult=Dt.prototype.cacheResult=At.prototype.cacheResult=kt.prototype.cacheResult=Ft;var Ct=function(t){function e(t){this._wrappedIterables=t.flatMap((function(t){return t._wrappedIterables?t._wrappedIterables:[t]})),this.size=this._wrappedIterables.reduce((function(t,e){if(void 0!==t){var r=e.size;if(void 0!==r)return t+r}}),0),this[g]=this._wrappedIterables[0][g],this[m]=this._wrappedIterables[0][m],this[A]=this._wrappedIterables[0][A]}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.__iterateUncached=function(t,e){if(0!==this._wrappedIterables.length){if(e)return this.cacheResult().__iterate(t,e);for(var r=0,n=w(this),i=n?T:U,o=this._wrappedIterables[r].__iterator(i,e),u=!0,s=0;u;){for(var a=o.next();a.done;){if(++r===this._wrappedIterables.length)return s;a=(o=this._wrappedIterables[r].__iterator(i,e)).next()}u=!1!==(n?t(a.value[1],a.value[0],this):t(a.value,s,this)),s++}return s}},e.prototype.__iteratorUncached=function(t,e){var r=this;if(0===this._wrappedIterables.length)return new C(W);if(e)return this.cacheResult().__iterator(t,e);var n=0,i=this._wrappedIterables[n].__iterator(t,e);return new C((function(){for(var o=i.next();o.done;){if(++n===r._wrappedIterables.length)return o;o=(i=r._wrappedIterables[n].__iterator(t,e)).next()}return o}))},e}(X);function Pt(t,e,r){var n=Xt(t);return n.__iterateUncached=function(i,o){if(o)return this.cacheResult().__iterate(i,o);var u=0,s=!1;return function t(a,c){a.__iterate((function(o,a){return(!e||c0}function Jt(t,e,r,n){var i=Xt(t),o=new $(r).map((function(t){return t.size}));return i.size=n?o.max():o.min(),i.__iterate=function(t,e){for(var r,n=this.__iterator(U,e),i=0;!(r=n.next()).done&&!1!==t(r.value,i++,this););return i},i.__iteratorUncached=function(t,i){var o=r.map((function(t){return t=S(t),J(i?t.reverse():t)})),u=0,s=!1;return new C((function(){var r;return s||(r=o.map((function(t){return t.next()})),s=n?r.every((function(t){return t.done})):r.some((function(t){return t.done}))),s?{value:void 0,done:!0}:P(t,u++,e.apply(null,r.map((function(t){return t.value}))))}))},i}function Vt(t,e){return t===e?t:q(t)?e:t.constructor(e)}function Yt(t){if(t!==Object(t))throw new TypeError("Expected [K, V] tuple: "+t)}function Qt(t){return w(t)?I:b(t)?O:E}function Xt(t){return Object.create((w(t)?F:b(t)?G:Z).prototype)}function Ft(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size,this):X.prototype.cacheResult.call(this)}function Gt(t,e){return void 0===t&&void 0===e?0:void 0===t?1:void 0===e?-1:t>e?1:t0;)e[r]=arguments[r+1];if("function"!=typeof t)throw new TypeError("Invalid merger function: "+t);return ze(this,e,t)}function ze(t,e,r){for(var n=[],i=0;i0;)e[r]=arguments[r+1];return Se(this,e,t)}function je(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return he(this,t,Je(),(function(t){return Ie(t,e)}))}function qe(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return he(this,t,Je(),(function(t){return Se(t,e)}))}function Me(t){var e=this.asMutable();return t(e),e.wasAltered()?e.__ensureOwner(this.__ownerID):this}function De(){return this.__ownerID?this:this.__ensureOwner(new s)}function xe(){return this.__ensureOwner()}function Ae(){return this.__altered}var ke=function(t){function e(e){return null==e?Je():at(e)&&!k(e)?e:Je().withMutations((function(r){var n=t(e);te(n.size),n.forEach((function(t,e){return r.set(e,t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toString=function(){return this.__toString("Map {","}")},e.prototype.get=function(t,e){return this._root?this._root.get(0,void 0,t,e):e},e.prototype.set=function(t,e){return Ve(this,t,e)},e.prototype.remove=function(t){return Ve(this,t,o)},e.prototype.deleteAll=function(t){var e=S(t);return 0===e.size?this:this.withMutations((function(t){e.forEach((function(e){return t.remove(e)}))}))},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):Je()},e.prototype.sort=function(t){return yr(Wt(this,t))},e.prototype.sortBy=function(t,e){return yr(Wt(this,e,t))},e.prototype.map=function(t,e){var r=this;return this.withMutations((function(n){n.forEach((function(i,o){n.set(o,t.call(e,i,o,r))}))}))},e.prototype.__iterator=function(t,e){return new Pe(this,t,e)},e.prototype.__iterate=function(t,e){var r=this,n=0;return this._root&&this._root.iterate((function(e){return n++,t(e[1],e[0],r)}),e),n},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?He(this.size,this._root,t,this.__hash):0===this.size?Je():(this.__ownerID=t,this.__altered=!1,this)},e}(I);ke.isMap=at;var Re=ke.prototype;Re[st]=!0,Re[e]=Re.remove,Re.removeAll=Re.deleteAll,Re.setIn=le,Re.removeIn=Re.deleteIn=ye,Re.update=ge,Re.updateIn=we,Re.merge=Re.concat=me,Re.mergeWith=be,Re.mergeDeep=Oe,Re.mergeDeepWith=Ee,Re.mergeIn=je,Re.mergeDeepIn=qe,Re.withMutations=Me,Re.wasAltered=Ae,Re.asImmutable=xe,Re["@@transducer/init"]=Re.asMutable=De,Re["@@transducer/step"]=function(t,e){return t.set(e[0],e[1])},Re["@@transducer/result"]=function(t){return t.asImmutable()};var Ue=function(t,e){this.ownerID=t,this.entries=e};Ue.prototype.get=function(t,e,r,n){for(var i=this.entries,o=0,u=i.length;o=Ze)return function(t,e,r,n){t||(t=new s);for(var i=new Le(t,vt(r),[r,n]),o=0;o>>t)&i),s=this.bitmap;return 0==(s&u)?o:this.nodes[Fe(s&u-1)].get(t+r,e,n,o)},Te.prototype.update=function(t,e,u,s,a,c,f){void 0===u&&(u=vt(s));var h=(0===e?u:u>>>e)&i,p=1<=$e)return function(t,e,r,i,o){for(var u=0,s=new Array(n),a=0;0!==r;a++,r>>>=1)s[a]=1&r?e[u++]:void 0;return s[i]=o,new Be(t,u+1,s)}(t,y,_,h,g);if(l&&!g&&2===y.length&&Qe(y[1^v]))return y[1^v];if(l&&g&&1===y.length&&Qe(g))return g;var w=t&&t===this.ownerID,m=l?g?_:_^p:_|p,b=l?g?Ge(y,v,g,w):function(t,e,r){var n=t.length-1;if(r&&e===n)return t.pop(),t;for(var i=new Array(n),o=0,u=0;u>>t)&i,s=this.nodes[u];return s?s.get(t+r,e,n,o):o},Be.prototype.update=function(t,e,n,u,s,a,c){void 0===n&&(n=vt(u));var f=(0===e?n:n>>>e)&i,h=s===o,p=this.nodes,_=p[f];if(h&&!_)return this;var l=Ye(_,t,e+r,n,u,s,a,c);if(l===_)return this;var v=this.count;if(_){if(!l&&--v>>n)&i,c=(0===n?o:o>>>n)&i,f=a===c?[Xe(t,e,n+r,o,u)]:(s=new Le(e,o,u),a>1&1431655765))+(t>>2&858993459))+(t>>4)&252645135,t+=t>>8,127&(t+=t>>16)}function Ge(t,e,r,n){var i=n?t:Zt(t);return i[e]=r,i}var Ze=n/4,$e=n/2,tr=n/4,er="@@__IMMUTABLE_LIST__@@";function rr(t){return Boolean(t&&t[er])}var nr=function(t){function e(e){var i=cr();if(null==e)return i;if(rr(e))return e;var o=t(e),u=o.size;return 0===u?i:(te(u),u>0&&u=0&&t=t.size||e<0)return t.withMutations((function(t){e<0?_r(t,e).set(0,r):_r(t,0,e+1).set(e,r)}));e+=t._origin;var n=t._tail,i=t._root,o={value:!1};e>=lr(t._capacity)?n=fr(n,t.__ownerID,0,e,r,o):i=fr(i,t.__ownerID,t._level,e,r,o);if(!o.value)return t;if(t.__ownerID)return t._root=i,t._tail=n,t.__hash=void 0,t.__altered=!0,t;return ar(t._origin,t._capacity,t._level,i,n)}(this,t,e)},e.prototype.remove=function(t){return this.has(t)?0===t?this.shift():t===this.size-1?this.pop():this.splice(t,1):this},e.prototype.insert=function(t,e){return this.splice(t,0,e)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=this._origin=this._capacity=0,this._level=r,this._root=this._tail=this.__hash=void 0,this.__altered=!0,this):cr()},e.prototype.push=function(){var t=arguments,e=this.size;return this.withMutations((function(r){_r(r,0,e+t.length);for(var n=0;n>>e&i;if(o>=this.array.length)return new or([],t);var u,s=0===o;if(e>0){var a=this.array[o];if((u=a&&a.removeBefore(t,e-r,n))===a&&s)return this}if(s&&!u)return this;var c=hr(this,t);if(!s)for(var f=0;f>>e&i;if(s>=this.array.length)return this;if(e>0){var a=this.array[s];if((u=a&&a.removeAfter(t,e-r,o))===a&&s===this.array.length-1)return this}var c=hr(this,t);return c.array.splice(s+1),u&&(c.array[s]=u),c};var ur={};function sr(t,e){var i=t._origin,o=t._capacity,u=lr(o),s=t._tail;return a(t._root,t._level,0);function a(t,c,f){return 0===c?function(t,r){var a=r===u?s&&s.array:t&&t.array,c=r>i?0:i-r,f=o-r;f>n&&(f=n);return function(){if(c===f)return ur;var t=e?--f:c++;return a&&a[t]}}(t,f):function(t,u,s){var c,f=t&&t.array,h=s>i?0:i-s>>u,p=1+(o-s>>u);p>n&&(p=n);return function(){for(;;){if(c){var t=c();if(t!==ur)return t;c=null}if(h===p)return ur;var n=e?--p:h++;c=a(f&&f[n],u-r,s+(n<>>n&i,h=t&&f0){var p=t&&t.array[f],_=fr(p,e,n-r,o,s,a);return _===p?t:((c=hr(t,e)).array[f]=_,c)}return h&&t.array[f]===s?t:(a&&u(a),c=hr(t,e),void 0===s&&f===c.array.length-1?c.array.pop():c.array[f]=s,c)}function hr(t,e){return e&&t&&e===t.ownerID?t:new or(t?t.array.slice():[],e)}function pr(t,e){if(e>=lr(t._capacity))return t._tail;if(e<1<0;)n=n.array[e>>>o&i],o-=r;return n}}function _r(t,e,n){void 0!==e&&(e|=0),void 0!==n&&(n|=0);var o=t.__ownerID||new s,u=t._origin,a=t._capacity,c=u+e,f=void 0===n?a:n<0?a+n:u+n;if(c===u&&f===a)return t;if(c>=f)return t.clear();for(var h=t._level,p=t._root,_=0;c+_<0;)p=new or(p&&p.array.length?[void 0,p]:[],o),_+=1<<(h+=r);_&&(c+=_,u+=_,f+=_,a+=_);for(var l=lr(a),v=lr(f);v>=1<l?new or([],o):y;if(y&&v>l&&cr;w-=r){var m=l>>>w&i;g=g.array[m]=hr(g.array[m],o)}g.array[l>>>r&i]=y}if(f=v)c-=v,f-=v,h=r,p=null,d=d&&d.removeBefore(o,0,c);else if(c>u||v>>h&i;if(b!==v>>>h&i)break;b&&(_+=(1<u&&(p=p.removeBefore(o,h,c-_)),p&&v>>r<=n&&a.size>=2*s.size?(i=(u=a.filter((function(t,e){return void 0!==t&&c!==e}))).toKeyedSeq().map((function(t){return t[0]})).flip().toMap(),t.__ownerID&&(i.__ownerID=u.__ownerID=t.__ownerID)):(i=s.remove(e),u=c===a.size-1?a.pop():a.set(c,void 0))}else if(f){if(r===a.get(c)[1])return t;i=s,u=a.set(c,[e,r])}else i=s.set(e,a.size),u=a.set(a.size,[e,r]);return t.__ownerID?(t.size=i.size,t._map=i,t._list=u,t.__hash=void 0,t.__altered=!0,t):dr(i,u)}yr.isOrderedMap=ct,yr.prototype[A]=!0,yr.prototype[e]=yr.prototype.remove;var mr="@@__IMMUTABLE_STACK__@@";function br(t){return Boolean(t&&t[mr])}var zr=function(t){function e(t){return null==t?Er():br(t)?t:Er().pushAll(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("Stack [","]")},e.prototype.get=function(t,e){var r=this._head;for(t=c(this,t);r&&t--;)r=r.next;return r?r.value:e},e.prototype.peek=function(){return this._head&&this._head.value},e.prototype.push=function(){var t=arguments;if(0===arguments.length)return this;for(var e=this.size+arguments.length,r=this._head,n=arguments.length-1;n>=0;n--)r={value:t[n],next:r};return this.__ownerID?(this.size=e,this._head=r,this.__hash=void 0,this.__altered=!0,this):Or(e,r)},e.prototype.pushAll=function(e){if(0===(e=t(e)).size)return this;if(0===this.size&&br(e))return e;te(e.size);var r=this.size,n=this._head;return e.__iterate((function(t){r++,n={value:t,next:n}}),!0),this.__ownerID?(this.size=r,this._head=n,this.__hash=void 0,this.__altered=!0,this):Or(r,n)},e.prototype.pop=function(){return this.slice(1)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):Er()},e.prototype.slice=function(e,r){if(h(e,r,this.size))return this;var n=p(e,this.size);if(_(r,this.size)!==this.size)return t.prototype.slice.call(this,e,r);for(var i=this.size-n,o=this._head;n--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):Or(i,o)},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Or(this.size,this._head,t,this.__hash):0===this.size?Er():(this.__ownerID=t,this.__altered=!1,this)},e.prototype.__iterate=function(t,e){var r=this;if(e)return new $(this.toArray()).__iterate((function(e,n){return t(e,n,r)}),e);for(var n=0,i=this._head;i&&!1!==t(i.value,n++,this);)i=i.next;return n},e.prototype.__iterator=function(t,e){if(e)return new $(this.toArray()).__iterator(t,e);var r=0,n=this._head;return new C((function(){if(n){var e=n.value;return n=n.next,P(t,r++,e)}return{value:void 0,done:!0}}))},e}(O);zr.isStack=br;var Sr,Ir=zr.prototype;function Or(t,e,r,n){var i=Object.create(Ir);return i.size=t,i._head=e,i.__ownerID=r,i.__hash=n,i.__altered=!1,i}function Er(){return Sr||(Sr=Or(0))}Ir[mr]=!0,Ir.shift=Ir.pop,Ir.unshift=Ir.push,Ir.unshiftAll=Ir.pushAll,Ir.withMutations=Me,Ir.wasAltered=Ae,Ir.asImmutable=xe,Ir["@@transducer/init"]=Ir.asMutable=De,Ir["@@transducer/step"]=function(t,e){return t.unshift(e)},Ir["@@transducer/result"]=function(t){return t.asImmutable()};var jr="@@__IMMUTABLE_SET__@@";function qr(t){return Boolean(t&&t[jr])}function Mr(t){return qr(t)&&k(t)}function Dr(t,e){if(t===e)return!0;if(!d(e)||void 0!==t.size&&void 0!==e.size&&t.size!==e.size||void 0!==t.__hash&&void 0!==e.__hash&&t.__hash!==e.__hash||w(t)!==w(e)||b(t)!==b(e)||k(t)!==k(e))return!1;if(0===t.size&&0===e.size)return!0;var r=!z(t);if(k(t)){var n=t.entries();return e.every((function(t,e){var i=n.next().value;return i&&ht(i[1],t)&&(r||ht(i[0],e))}))&&n.next().done}var i=!1;if(void 0===t.size)if(void 0===e.size)"function"==typeof t.cacheResult&&t.cacheResult();else{i=!0;var u=t;t=e,e=u}var s=!0,a=e.__iterate((function(e,n){if(r?!t.has(e):i?!ht(e,t.get(n,o)):!ht(t.get(n,o),e))return s=!1,!1}));return s&&t.size===a}function xr(t,e){var r=function(r){t.prototype[r]=e[r]};return Object.keys(e).forEach(r),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(e).forEach(r),t}function Ar(t){if(!t||"object"!=typeof t)return t;if(!d(t)){if(!ie(t))return t;t=X(t)}if(w(t)){var e={};return t.__iterate((function(t,r){e[r]=Ar(t)})),e}var r=[];return t.__iterate((function(t){r.push(Ar(t))})),r}var kr=function(t){function e(e){return null==e?Kr():qr(e)&&!k(e)?e:Kr().withMutations((function(r){var n=t(e);te(n.size),n.forEach((function(t){return r.add(t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(I(t).keySeq())},e.intersect=function(t){return(t=S(t).toArray()).length?Ur.intersect.apply(e(t.pop()),t):Kr()},e.union=function(t){return(t=S(t).toArray()).length?Ur.union.apply(e(t.pop()),t):Kr()},e.prototype.toString=function(){return this.__toString("Set {","}")},e.prototype.has=function(t){return this._map.has(t)},e.prototype.add=function(t){return Tr(this,this._map.set(t,t))},e.prototype.remove=function(t){return Tr(this,this._map.remove(t))},e.prototype.clear=function(){return Tr(this,this._map.clear())},e.prototype.map=function(t,e){var r=this,n=!1,i=Tr(this,this._map.mapEntries((function(i){var o=i[1],u=t.call(e,o,o,r);return u!==o&&(n=!0),[u,u]}),e));return n?i:this},e.prototype.union=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return 0===(e=e.filter((function(t){return 0!==t.size}))).length?this:0!==this.size||this.__ownerID||1!==e.length?this.withMutations((function(r){for(var n=0;n=0&&e=0&&r>>-15,461845907),e=pt(e<<13|e>>>-13,5),e=pt((e=(e+3864292196|0)^t)^e>>>16,2246822507),e=_t((e=pt(e^e>>>13,3266489909))^e>>>16)}(t.size,n)}(this))}});var Jr=S.prototype;Jr[y]=!0,Jr[L]=Jr.values,Jr.toJSON=Jr.toArray,Jr.__toStringMapper=oe,Jr.inspect=Jr.toSource=function(){return this.toString()},Jr.chain=Jr.flatMap,Jr.contains=Jr.includes,xr(I,{flip:function(){return Vt(this,Rt(this))},mapEntries:function(t,e){var r=this,n=0;return Vt(this,this.toSeq().map((function(i,o){return t.call(e,[o,i],n++,r)})).fromEntrySeq())},mapKeys:function(t,e){var r=this;return Vt(this,this.toSeq().flip().map((function(n,i){return t.call(e,n,i,r)})).flip())}});var Vr=I.prototype;Vr[g]=!0,Vr[L]=Jr.entries,Vr.toJSON=Hr,Vr.__toStringMapper=function(t,e){return oe(e)+": "+oe(t)},xr(O,{toKeyedSeq:function(){return new Dt(this,!1)},filter:function(t,e){return Vt(this,Bt(this,t,e,!1))},findIndex:function(t,e){var r=this.findEntry(t,e);return r?r[0]:-1},indexOf:function(t){var e=this.keyOf(t);return void 0===e?-1:e},lastIndexOf:function(t){var e=this.lastKeyOf(t);return void 0===e?-1:e},reverse:function(){return Vt(this,Tt(this,!1))},slice:function(t,e){return Vt(this,Kt(this,t,e,!1))},splice:function(t,e){var r=arguments.length;if(e=Math.max(e||0,0),0===r||2===r&&!e)return this;t=p(t,t<0?this.count():this.size);var n=this.slice(0,t);return Vt(this,1===r?n:n.concat(Zt(arguments,2),this.slice(t+e)))},findLastIndex:function(t,e){var r=this.findLastEntry(t,e);return r?r[0]:-1},first:function(t){return this.get(0,t)},flatten:function(t){return Vt(this,Pt(this,t,!1))},get:function(t,e){return(t=c(this,t))<0||this.size===1/0||void 0!==this.size&&t>this.size?e:this.find((function(e,r){return r===t}),void 0,e)},has:function(t){return(t=c(this,t))>=0&&(void 0!==this.size?this.size===1/0||te?-1:0}function rn(t,e){return t^e+2654435769+(t<<6)+(t>>2)|0}Qr.has=Jr.includes,Qr.contains=Qr.includes,Qr.keys=Qr.values,xr(F,Vr),xr(G,Yr),xr(Z,Qr);var nn=function(t){function e(t){return null==t?an():Mr(t)?t:an().withMutations((function(e){var r=E(t);te(r.size),r.forEach((function(t){return e.add(t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(I(t).keySeq())},e.prototype.toString=function(){return this.__toString("OrderedSet {","}")},e}(kr);nn.isOrderedSet=Mr;var on,un=nn.prototype;function sn(t,e){var r=Object.create(un);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function an(){return on||(on=sn(gr()))}un[A]=!0,un.zip=Yr.zip,un.zipWith=Yr.zipWith,un.zipAll=Yr.zipAll,un.__empty=an,un.__make=sn;var cn=function(t,e){var r;!function(t){if(D(t))throw new Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(x(t))throw new Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(null===t||"object"!=typeof t)throw new Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}(t);var n=function(o){var u=this;if(o instanceof n)return o;if(!(this instanceof n))return new n(o);if(!r){r=!0;var s=Object.keys(t),a=i._indices={};i._name=e,i._keys=s,i._defaultValues=t;for(var c=0;c2?[]:void 0,{"":t})},t.get=se,t.getIn=Pr,t.has=ue,t.hasIn=Nr,t.hash=vt,t.is=ht,t.isAssociative=z,t.isCollection=d,t.isImmutable=x,t.isIndexed=b,t.isKeyed=w,t.isList=rr,t.isMap=at,t.isOrdered=k,t.isOrderedMap=ct,t.isOrderedSet=Mr,t.isPlainObject=ne,t.isRecord=D,t.isSeq=q,t.isSet=qr,t.isStack=br,t.isValueObject=ft,t.merge=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Ie(t,e)},t.mergeDeep=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Se(t,e)},t.mergeDeepWith=function(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];return Se(e,r,t)},t.mergeWith=function(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];return Ie(e,r,t)},t.remove=ce,t.removeIn=ve,t.set=fe,t.setIn=_e,t.update=de,t.updateIn=he,t.version="5.1.1"})); +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).Immutable={})}(this,(function(t){"use strict";var e="delete",r=5,n=1<>>0;if(""+r!==e||4294967295===r)return NaN;e=r}return e<0?a(t)+e:e}function f(){return!0}function h(t,e,r){return(0===t&&!v(t)||void 0!==r&&t<=-r)&&(void 0===e||void 0!==r&&e>=r)}function p(t,e){return l(t,e,0)}function _(t,e){return l(t,e,e)}function l(t,e,r){return void 0===t?r:v(t)?e===1/0?e:0|Math.max(0,e+t):void 0===e||e===t?t:0|Math.min(e,t)}function v(t){return t<0||0===t&&1/t==-1/0}var y="@@__IMMUTABLE_ITERABLE__@@";function d(t){return Boolean(t&&t[y])}var g="@@__IMMUTABLE_KEYED__@@";function w(t){return Boolean(t&&t[g])}var m="@@__IMMUTABLE_INDEXED__@@";function b(t){return Boolean(t&&t[m])}function z(t){return w(t)||b(t)}var S=function(t){return d(t)?t:X(t)},I=function(t){function e(t){return w(t)?t:F(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(S),O=function(t){function e(t){return b(t)?t:G(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(S),E=function(t){function e(t){return d(t)&&!z(t)?t:Z(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(S);S.Keyed=I,S.Indexed=O,S.Set=E;var j="@@__IMMUTABLE_SEQ__@@";function q(t){return Boolean(t&&t[j])}var M="@@__IMMUTABLE_RECORD__@@";function D(t){return Boolean(t&&t[M])}function x(t){return d(t)||D(t)}var A="@@__IMMUTABLE_ORDERED__@@";function k(t){return Boolean(t&&t[A])}var R=0,U=1,T=2,B="function"==typeof Symbol&&Symbol.iterator,K="@@iterator",L=B||K,C=function(t){this.next=t};function P(t,e,r,n){var i=t===R?e:t===U?r:[e,r];return n?n.value=i:n={value:i,done:!1},n}function W(){return{value:void 0,done:!0}}function N(t){return!!Array.isArray(t)||!!V(t)}function H(t){return t&&"function"==typeof t.next}function J(t){var e=V(t);return e&&e.call(t)}function V(t){var e=t&&(B&&t[B]||t[K]);if("function"==typeof e)return e}C.prototype.toString=function(){return"[Iterator]"},C.KEYS=R,C.VALUES=U,C.ENTRIES=T,C.prototype.inspect=C.prototype.toSource=function(){return this.toString()},C.prototype[L]=function(){return this};var Y=Object.prototype.hasOwnProperty;function Q(t){return!(!Array.isArray(t)&&"string"!=typeof t)||t&&"object"==typeof t&&Number.isInteger(t.length)&&t.length>=0&&(0===t.length?1===Object.keys(t).length:t.hasOwnProperty(t.length-1))}var X=function(t){function e(t){return null==t?nt():x(t)?t.toSeq():function(t){var e=ut(t);if(e)return(n=V(r=t))&&n===r.entries?e.fromEntrySeq():function(t){var e=V(t);return e&&e===t.keys}(t)?e.toSetSeq():e;var r,n;if("object"==typeof t)return new tt(t);throw new TypeError("Expected Array or collection object of values, or keyed object: "+t)}(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq {","}")},e.prototype.cacheResult=function(){return!this._cache&&this.__iterateUncached&&(this._cache=this.entrySeq().toArray(),this.size=this._cache.length),this},e.prototype.__iterate=function(t,e){var r=this._cache;if(r){for(var n=r.length,i=0;i!==n;){var o=r[e?n-++i:i++];if(!1===t(o[1],o[0],this))break}return i}return this.__iterateUncached(t,e)},e.prototype.__iterator=function(t,e){var r=this._cache;if(r){var n=r.length,i=0;return new C((function(){if(i===n)return{value:void 0,done:!0};var o=r[e?n-++i:i++];return P(t,o[0],o[1])}))}return this.__iteratorUncached(t,e)},e}(S),F=function(t){function e(t){return null==t?nt().toKeyedSeq():d(t)?w(t)?t.toSeq():t.fromEntrySeq():D(t)?t.toSeq():it(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toKeyedSeq=function(){return this},e}(X),G=function(t){function e(t){return null==t?nt():d(t)?w(t)?t.entrySeq():t.toIndexedSeq():D(t)?t.toSeq().entrySeq():ot(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return e(arguments)},e.prototype.toIndexedSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq [","]")},e}(X),Z=function(t){function e(t){return(d(t)&&!z(t)?t:G(t)).toSetSeq()}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return e(arguments)},e.prototype.toSetSeq=function(){return this},e}(X);X.isSeq=q,X.Keyed=F,X.Set=Z,X.Indexed=G,X.prototype[j]=!0;var $=function(t){function e(t){this._array=t,this.size=t.length}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t,e){return this.has(t)?this._array[c(this,t)]:e},e.prototype.__iterate=function(t,e){for(var r=this._array,n=r.length,i=0;i!==n;){var o=e?n-++i:i++;if(!1===t(r[o],o,this))break}return i},e.prototype.__iterator=function(t,e){var r=this._array,n=r.length,i=0;return new C((function(){if(i===n)return{value:void 0,done:!0};var o=e?n-++i:i++;return P(t,o,r[o])}))},e}(G),tt=function(t){function e(t){var e=Object.keys(t).concat(Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(t):[]);this._object=t,this._keys=e,this.size=e.length}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t,e){return void 0===e||this.has(t)?this._object[t]:e},e.prototype.has=function(t){return Y.call(this._object,t)},e.prototype.__iterate=function(t,e){for(var r=this._object,n=this._keys,i=n.length,o=0;o!==i;){var u=n[e?i-++o:o++];if(!1===t(r[u],u,this))break}return o},e.prototype.__iterator=function(t,e){var r=this._object,n=this._keys,i=n.length,o=0;return new C((function(){if(o===i)return{value:void 0,done:!0};var u=n[e?i-++o:o++];return P(t,u,r[u])}))},e}(F);tt.prototype[A]=!0;var et,rt=function(t){function e(t){this._collection=t,this.size=t.length||t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.__iterateUncached=function(t,e){if(e)return this.cacheResult().__iterate(t,e);var r=J(this._collection),n=0;if(H(r))for(var i;!(i=r.next()).done&&!1!==t(i.value,n++,this););return n},e.prototype.__iteratorUncached=function(t,e){if(e)return this.cacheResult().__iterator(t,e);var r=J(this._collection);if(!H(r))return new C(W);var n=0;return new C((function(){var e=r.next();return e.done?e:P(t,n++,e.value)}))},e}(G);function nt(){return et||(et=new $([]))}function it(t){var e=ut(t);if(e)return e.fromEntrySeq();if("object"==typeof t)return new tt(t);throw new TypeError("Expected Array or collection object of [k, v] entries, or keyed object: "+t)}function ot(t){var e=ut(t);if(e)return e;throw new TypeError("Expected Array or collection object of values: "+t)}function ut(t){return Q(t)?new $(t):N(t)?new rt(t):void 0}var st="@@__IMMUTABLE_MAP__@@";function at(t){return Boolean(t&&t[st])}function ct(t){return at(t)&&k(t)}function ft(t){return Boolean(t&&"function"==typeof t.equals&&"function"==typeof t.hashCode)}function ht(t,e){if(t===e||t!=t&&e!=e)return!0;if(!t||!e)return!1;if("function"==typeof t.valueOf&&"function"==typeof e.valueOf){if((t=t.valueOf())===(e=e.valueOf())||t!=t&&e!=e)return!0;if(!t||!e)return!1}return!!(ft(t)&&ft(e)&&t.equals(e))}var pt="function"==typeof Math.imul&&-2===Math.imul(4294967295,2)?Math.imul:function(t,e){var r=65535&(t|=0),n=65535&(e|=0);return r*n+((t>>>16)*n+r*(e>>>16)<<16>>>0)|0};function _t(t){return t>>>1&1073741824|3221225471&t}var lt=Object.prototype.valueOf;function vt(t){if(null==t)return yt(t);if("function"==typeof t.hashCode)return _t(t.hashCode(t));var e,r=(e=t).valueOf!==lt&&"function"==typeof e.valueOf?e.valueOf(e):e;if(null==r)return yt(r);switch(typeof r){case"boolean":return r?1108378657:1108378656;case"number":return function(t){if(t!=t||t===1/0)return 0;var e=0|t;e!==t&&(e^=4294967295*t);for(;t>4294967295;)e^=t/=4294967295;return _t(e)}(r);case"string":return r.length>Et?function(t){var e=Mt[t];void 0===e&&(e=dt(t),qt===jt&&(qt=0,Mt={}),qt++,Mt[t]=e);return e}(r):dt(r);case"object":case"function":return function(t){var e;if(zt&&void 0!==(e=bt.get(t)))return e;if(e=t[Ot],void 0!==e)return e;if(!wt){if(void 0!==(e=t.propertyIsEnumerable&&t.propertyIsEnumerable[Ot]))return e;if(void 0!==(e=function(t){if(t&&t.nodeType>0)switch(t.nodeType){case 1:return t.uniqueID;case 9:return t.documentElement&&t.documentElement.uniqueID}}(t)))return e}if(e=mt(),zt)bt.set(t,e);else{if(void 0!==gt&&!1===gt(t))throw new Error("Non-extensible objects are not allowed as keys.");if(wt)Object.defineProperty(t,Ot,{enumerable:!1,configurable:!1,writable:!1,value:e});else if(void 0!==t.propertyIsEnumerable&&t.propertyIsEnumerable===t.constructor.prototype.propertyIsEnumerable)t.propertyIsEnumerable=function(){return this.constructor.prototype.propertyIsEnumerable.apply(this,arguments)},t.propertyIsEnumerable[Ot]=e;else{if(void 0===t.nodeType)throw new Error("Unable to set a non-enumerable property on object.");t[Ot]=e}}return e}(r);case"symbol":return function(t){var e=St[t];if(void 0!==e)return e;return e=mt(),St[t]=e,e}(r);default:if("function"==typeof r.toString)return dt(r.toString());throw new Error("Value type "+typeof r+" cannot be hashed.")}}function yt(t){return null===t?1108378658:1108378659}function dt(t){for(var e=0,r=0;r=0&&(a.get=function(e,r){return(e=c(this,e))>=0&&eo)return{value:void 0,done:!0};var t=i.next();return n||e===U||t.done?t:P(e,a-1,e===R?void 0:t.value[1],t)}))},a}function Lt(t,e,r,n){var i=Xt(t);return i.__iterateUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterate(i,o);var s=!0,a=0;return t.__iterate((function(t,o,c){if(!s||!(s=e.call(r,t,o,c)))return a++,i(t,n?o:a-1,u)})),a},i.__iteratorUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterator(i,o);var s=t.__iterator(T,o),a=!0,c=0;return new C((function(){var t,o,f;do{if((t=s.next()).done)return n||i===U?t:P(i,c++,i===R?void 0:t.value[1],t);var h=t.value;o=h[0],f=h[1],a&&(a=e.call(r,f,o,u))}while(a);return i===T?t:P(i,o,f,t)}))},i}xt.prototype.cacheResult=Dt.prototype.cacheResult=At.prototype.cacheResult=kt.prototype.cacheResult=Ft;var Ct=function(t){function e(t){this._wrappedIterables=t.flatMap((function(t){return t._wrappedIterables?t._wrappedIterables:[t]})),this.size=this._wrappedIterables.reduce((function(t,e){if(void 0!==t){var r=e.size;if(void 0!==r)return t+r}}),0),this[g]=this._wrappedIterables[0][g],this[m]=this._wrappedIterables[0][m],this[A]=this._wrappedIterables[0][A]}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.__iterateUncached=function(t,e){if(0!==this._wrappedIterables.length){if(e)return this.cacheResult().__iterate(t,e);for(var r=0,n=w(this),i=n?T:U,o=this._wrappedIterables[r].__iterator(i,e),u=!0,s=0;u;){for(var a=o.next();a.done;){if(++r===this._wrappedIterables.length)return s;a=(o=this._wrappedIterables[r].__iterator(i,e)).next()}u=!1!==(n?t(a.value[1],a.value[0],this):t(a.value,s,this)),s++}return s}},e.prototype.__iteratorUncached=function(t,e){var r=this;if(0===this._wrappedIterables.length)return new C(W);if(e)return this.cacheResult().__iterator(t,e);var n=0,i=this._wrappedIterables[n].__iterator(t,e);return new C((function(){for(var o=i.next();o.done;){if(++n===r._wrappedIterables.length)return o;o=(i=r._wrappedIterables[n].__iterator(t,e)).next()}return o}))},e}(X);function Pt(t,e,r){var n=Xt(t);return n.__iterateUncached=function(i,o){if(o)return this.cacheResult().__iterate(i,o);var u=0,s=!1;return function t(a,c){a.__iterate((function(o,a){return(!e||c0}function Jt(t,e,r,n){var i=Xt(t),o=new $(r).map((function(t){return t.size}));return i.size=n?o.max():o.min(),i.__iterate=function(t,e){for(var r,n=this.__iterator(U,e),i=0;!(r=n.next()).done&&!1!==t(r.value,i++,this););return i},i.__iteratorUncached=function(t,i){var o=r.map((function(t){return t=S(t),J(i?t.reverse():t)})),u=0,s=!1;return new C((function(){var r;return s||(r=o.map((function(t){return t.next()})),s=n?r.every((function(t){return t.done})):r.some((function(t){return t.done}))),s?{value:void 0,done:!0}:P(t,u++,e.apply(null,r.map((function(t){return t.value}))))}))},i}function Vt(t,e){return t===e?t:q(t)?e:t.constructor(e)}function Yt(t){if(t!==Object(t))throw new TypeError("Expected [K, V] tuple: "+t)}function Qt(t){return w(t)?I:b(t)?O:E}function Xt(t){return Object.create((w(t)?F:b(t)?G:Z).prototype)}function Ft(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size,this):X.prototype.cacheResult.call(this)}function Gt(t,e){return void 0===t&&void 0===e?0:void 0===t?1:void 0===e?-1:t>e?1:t0;)e[r]=arguments[r+1];if("function"!=typeof t)throw new TypeError("Invalid merger function: "+t);return ze(this,e,t)}function ze(t,e,r){for(var n=[],i=0;i0;)e[r]=arguments[r+1];return Se(this,e,t)}function je(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return he(this,t,Je(),(function(t){return Ie(t,e)}))}function qe(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return he(this,t,Je(),(function(t){return Se(t,e)}))}function Me(t){var e=this.asMutable();return t(e),e.wasAltered()?e.__ensureOwner(this.__ownerID):this}function De(){return this.__ownerID?this:this.__ensureOwner(new s)}function xe(){return this.__ensureOwner()}function Ae(){return this.__altered}var ke=function(t){function e(e){return null==e?Je():at(e)&&!k(e)?e:Je().withMutations((function(r){var n=t(e);te(n.size),n.forEach((function(t,e){return r.set(e,t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toString=function(){return this.__toString("Map {","}")},e.prototype.get=function(t,e){return this._root?this._root.get(0,void 0,t,e):e},e.prototype.set=function(t,e){return Ve(this,t,e)},e.prototype.remove=function(t){return Ve(this,t,o)},e.prototype.deleteAll=function(t){var e=S(t);return 0===e.size?this:this.withMutations((function(t){e.forEach((function(e){return t.remove(e)}))}))},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):Je()},e.prototype.sort=function(t){return yr(Wt(this,t))},e.prototype.sortBy=function(t,e){return yr(Wt(this,e,t))},e.prototype.map=function(t,e){var r=this;return this.withMutations((function(n){n.forEach((function(i,o){n.set(o,t.call(e,i,o,r))}))}))},e.prototype.__iterator=function(t,e){return new Pe(this,t,e)},e.prototype.__iterate=function(t,e){var r=this,n=0;return this._root&&this._root.iterate((function(e){return n++,t(e[1],e[0],r)}),e),n},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?He(this.size,this._root,t,this.__hash):0===this.size?Je():(this.__ownerID=t,this.__altered=!1,this)},e}(I);ke.isMap=at;var Re=ke.prototype;Re[st]=!0,Re[e]=Re.remove,Re.removeAll=Re.deleteAll,Re.setIn=le,Re.removeIn=Re.deleteIn=ye,Re.update=ge,Re.updateIn=we,Re.merge=Re.concat=me,Re.mergeWith=be,Re.mergeDeep=Oe,Re.mergeDeepWith=Ee,Re.mergeIn=je,Re.mergeDeepIn=qe,Re.withMutations=Me,Re.wasAltered=Ae,Re.asImmutable=xe,Re["@@transducer/init"]=Re.asMutable=De,Re["@@transducer/step"]=function(t,e){return t.set(e[0],e[1])},Re["@@transducer/result"]=function(t){return t.asImmutable()};var Ue=function(t,e){this.ownerID=t,this.entries=e};Ue.prototype.get=function(t,e,r,n){for(var i=this.entries,o=0,u=i.length;o=Ze)return function(t,e,r,n){t||(t=new s);for(var i=new Le(t,vt(r),[r,n]),o=0;o>>t)&i),s=this.bitmap;return 0==(s&u)?o:this.nodes[Fe(s&u-1)].get(t+r,e,n,o)},Te.prototype.update=function(t,e,u,s,a,c,f){void 0===u&&(u=vt(s));var h=(0===e?u:u>>>e)&i,p=1<=$e)return function(t,e,r,i,o){for(var u=0,s=new Array(n),a=0;0!==r;a++,r>>>=1)s[a]=1&r?e[u++]:void 0;return s[i]=o,new Be(t,u+1,s)}(t,y,_,h,g);if(l&&!g&&2===y.length&&Qe(y[1^v]))return y[1^v];if(l&&g&&1===y.length&&Qe(g))return g;var w=t&&t===this.ownerID,m=l?g?_:_^p:_|p,b=l?g?Ge(y,v,g,w):function(t,e,r){var n=t.length-1;if(r&&e===n)return t.pop(),t;for(var i=new Array(n),o=0,u=0;u>>t)&i,s=this.nodes[u];return s?s.get(t+r,e,n,o):o},Be.prototype.update=function(t,e,n,u,s,a,c){void 0===n&&(n=vt(u));var f=(0===e?n:n>>>e)&i,h=s===o,p=this.nodes,_=p[f];if(h&&!_)return this;var l=Ye(_,t,e+r,n,u,s,a,c);if(l===_)return this;var v=this.count;if(_){if(!l&&--v>>n)&i,c=(0===n?o:o>>>n)&i,f=a===c?[Xe(t,e,n+r,o,u)]:(s=new Le(e,o,u),a>1&1431655765))+(t>>2&858993459))+(t>>4)&252645135,t+=t>>8,127&(t+=t>>16)}function Ge(t,e,r,n){var i=n?t:Zt(t);return i[e]=r,i}var Ze=n/4,$e=n/2,tr=n/4,er="@@__IMMUTABLE_LIST__@@";function rr(t){return Boolean(t&&t[er])}var nr=function(t){function e(e){var i=cr();if(null==e)return i;if(rr(e))return e;var o=t(e),u=o.size;return 0===u?i:(te(u),u>0&&u=0&&t=t.size||e<0)return t.withMutations((function(t){e<0?_r(t,e).set(0,r):_r(t,0,e+1).set(e,r)}));e+=t._origin;var n=t._tail,i=t._root,o={value:!1};e>=lr(t._capacity)?n=fr(n,t.__ownerID,0,e,r,o):i=fr(i,t.__ownerID,t._level,e,r,o);if(!o.value)return t;if(t.__ownerID)return t._root=i,t._tail=n,t.__hash=void 0,t.__altered=!0,t;return ar(t._origin,t._capacity,t._level,i,n)}(this,t,e)},e.prototype.remove=function(t){return this.has(t)?0===t?this.shift():t===this.size-1?this.pop():this.splice(t,1):this},e.prototype.insert=function(t,e){return this.splice(t,0,e)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=this._origin=this._capacity=0,this._level=r,this._root=this._tail=this.__hash=void 0,this.__altered=!0,this):cr()},e.prototype.push=function(){var t=arguments,e=this.size;return this.withMutations((function(r){_r(r,0,e+t.length);for(var n=0;n>>e&i;if(o>=this.array.length)return new or([],t);var u,s=0===o;if(e>0){var a=this.array[o];if((u=a&&a.removeBefore(t,e-r,n))===a&&s)return this}if(s&&!u)return this;var c=hr(this,t);if(!s)for(var f=0;f>>e&i;if(s>=this.array.length)return this;if(e>0){var a=this.array[s];if((u=a&&a.removeAfter(t,e-r,o))===a&&s===this.array.length-1)return this}var c=hr(this,t);return c.array.splice(s+1),u&&(c.array[s]=u),c};var ur={};function sr(t,e){var i=t._origin,o=t._capacity,u=lr(o),s=t._tail;return a(t._root,t._level,0);function a(t,c,f){return 0===c?function(t,r){var a=r===u?s&&s.array:t&&t.array,c=r>i?0:i-r,f=o-r;f>n&&(f=n);return function(){if(c===f)return ur;var t=e?--f:c++;return a&&a[t]}}(t,f):function(t,u,s){var c,f=t&&t.array,h=s>i?0:i-s>>u,p=1+(o-s>>u);p>n&&(p=n);return function(){for(;;){if(c){var t=c();if(t!==ur)return t;c=null}if(h===p)return ur;var n=e?--p:h++;c=a(f&&f[n],u-r,s+(n<>>n&i,h=t&&f0){var p=t&&t.array[f],_=fr(p,e,n-r,o,s,a);return _===p?t:((c=hr(t,e)).array[f]=_,c)}return h&&t.array[f]===s?t:(a&&u(a),c=hr(t,e),void 0===s&&f===c.array.length-1?c.array.pop():c.array[f]=s,c)}function hr(t,e){return e&&t&&e===t.ownerID?t:new or(t?t.array.slice():[],e)}function pr(t,e){if(e>=lr(t._capacity))return t._tail;if(e<1<0;)n=n.array[e>>>o&i],o-=r;return n}}function _r(t,e,n){void 0!==e&&(e|=0),void 0!==n&&(n|=0);var o=t.__ownerID||new s,u=t._origin,a=t._capacity,c=u+e,f=void 0===n?a:n<0?a+n:u+n;if(c===u&&f===a)return t;if(c>=f)return t.clear();for(var h=t._level,p=t._root,_=0;c+_<0;)p=new or(p&&p.array.length?[void 0,p]:[],o),_+=1<<(h+=r);_&&(c+=_,u+=_,f+=_,a+=_);for(var l=lr(a),v=lr(f);v>=1<l?new or([],o):y;if(y&&v>l&&cr;w-=r){var m=l>>>w&i;g=g.array[m]=hr(g.array[m],o)}g.array[l>>>r&i]=y}if(f=v)c-=v,f-=v,h=r,p=null,d=d&&d.removeBefore(o,0,c);else if(c>u||v>>h&i;if(b!==v>>>h&i)break;b&&(_+=(1<u&&(p=p.removeBefore(o,h,c-_)),p&&v>>r<=n&&a.size>=2*s.size?(i=(u=a.filter((function(t,e){return void 0!==t&&c!==e}))).toKeyedSeq().map((function(t){return t[0]})).flip().toMap(),t.__ownerID&&(i.__ownerID=u.__ownerID=t.__ownerID)):(i=s.remove(e),u=c===a.size-1?a.pop():a.set(c,void 0))}else if(f){if(r===a.get(c)[1])return t;i=s,u=a.set(c,[e,r])}else i=s.set(e,a.size),u=a.set(a.size,[e,r]);return t.__ownerID?(t.size=i.size,t._map=i,t._list=u,t.__hash=void 0,t.__altered=!0,t):dr(i,u)}yr.isOrderedMap=ct,yr.prototype[A]=!0,yr.prototype[e]=yr.prototype.remove;var mr="@@__IMMUTABLE_STACK__@@";function br(t){return Boolean(t&&t[mr])}var zr=function(t){function e(t){return null==t?Er():br(t)?t:Er().pushAll(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("Stack [","]")},e.prototype.get=function(t,e){var r=this._head;for(t=c(this,t);r&&t--;)r=r.next;return r?r.value:e},e.prototype.peek=function(){return this._head&&this._head.value},e.prototype.push=function(){var t=arguments;if(0===arguments.length)return this;for(var e=this.size+arguments.length,r=this._head,n=arguments.length-1;n>=0;n--)r={value:t[n],next:r};return this.__ownerID?(this.size=e,this._head=r,this.__hash=void 0,this.__altered=!0,this):Or(e,r)},e.prototype.pushAll=function(e){if(0===(e=t(e)).size)return this;if(0===this.size&&br(e))return e;te(e.size);var r=this.size,n=this._head;return e.__iterate((function(t){r++,n={value:t,next:n}}),!0),this.__ownerID?(this.size=r,this._head=n,this.__hash=void 0,this.__altered=!0,this):Or(r,n)},e.prototype.pop=function(){return this.slice(1)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):Er()},e.prototype.slice=function(e,r){if(h(e,r,this.size))return this;var n=p(e,this.size);if(_(r,this.size)!==this.size)return t.prototype.slice.call(this,e,r);for(var i=this.size-n,o=this._head;n--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):Or(i,o)},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Or(this.size,this._head,t,this.__hash):0===this.size?Er():(this.__ownerID=t,this.__altered=!1,this)},e.prototype.__iterate=function(t,e){var r=this;if(e)return new $(this.toArray()).__iterate((function(e,n){return t(e,n,r)}),e);for(var n=0,i=this._head;i&&!1!==t(i.value,n++,this);)i=i.next;return n},e.prototype.__iterator=function(t,e){if(e)return new $(this.toArray()).__iterator(t,e);var r=0,n=this._head;return new C((function(){if(n){var e=n.value;return n=n.next,P(t,r++,e)}return{value:void 0,done:!0}}))},e}(O);zr.isStack=br;var Sr,Ir=zr.prototype;function Or(t,e,r,n){var i=Object.create(Ir);return i.size=t,i._head=e,i.__ownerID=r,i.__hash=n,i.__altered=!1,i}function Er(){return Sr||(Sr=Or(0))}Ir[mr]=!0,Ir.shift=Ir.pop,Ir.unshift=Ir.push,Ir.unshiftAll=Ir.pushAll,Ir.withMutations=Me,Ir.wasAltered=Ae,Ir.asImmutable=xe,Ir["@@transducer/init"]=Ir.asMutable=De,Ir["@@transducer/step"]=function(t,e){return t.unshift(e)},Ir["@@transducer/result"]=function(t){return t.asImmutable()};var jr="@@__IMMUTABLE_SET__@@";function qr(t){return Boolean(t&&t[jr])}function Mr(t){return qr(t)&&k(t)}function Dr(t,e){if(t===e)return!0;if(!d(e)||void 0!==t.size&&void 0!==e.size&&t.size!==e.size||void 0!==t.__hash&&void 0!==e.__hash&&t.__hash!==e.__hash||w(t)!==w(e)||b(t)!==b(e)||k(t)!==k(e))return!1;if(0===t.size&&0===e.size)return!0;var r=!z(t);if(k(t)){var n=t.entries();return e.every((function(t,e){var i=n.next().value;return i&&ht(i[1],t)&&(r||ht(i[0],e))}))&&n.next().done}var i=!1;if(void 0===t.size)if(void 0===e.size)"function"==typeof t.cacheResult&&t.cacheResult();else{i=!0;var u=t;t=e,e=u}var s=!0,a=e.__iterate((function(e,n){if(r?!t.has(e):i?!ht(e,t.get(n,o)):!ht(t.get(n,o),e))return s=!1,!1}));return s&&t.size===a}function xr(t,e){var r=function(r){t.prototype[r]=e[r]};return Object.keys(e).forEach(r),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(e).forEach(r),t}function Ar(t){if(!t||"object"!=typeof t)return t;if(!d(t)){if(!ie(t))return t;t=X(t)}if(w(t)){var e={};return t.__iterate((function(t,r){e[r]=Ar(t)})),e}var r=[];return t.__iterate((function(t){r.push(Ar(t))})),r}var kr=function(t){function e(e){return null==e?Kr():qr(e)&&!k(e)?e:Kr().withMutations((function(r){var n=t(e);te(n.size),n.forEach((function(t){return r.add(t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(I(t).keySeq())},e.intersect=function(t){return(t=S(t).toArray()).length?Ur.intersect.apply(e(t.pop()),t):Kr()},e.union=function(t){return(t=S(t).toArray()).length?Ur.union.apply(e(t.pop()),t):Kr()},e.prototype.toString=function(){return this.__toString("Set {","}")},e.prototype.has=function(t){return this._map.has(t)},e.prototype.add=function(t){return Tr(this,this._map.set(t,t))},e.prototype.remove=function(t){return Tr(this,this._map.remove(t))},e.prototype.clear=function(){return Tr(this,this._map.clear())},e.prototype.map=function(t,e){var r=this,n=!1,i=Tr(this,this._map.mapEntries((function(i){var o=i[1],u=t.call(e,o,o,r);return u!==o&&(n=!0),[u,u]}),e));return n?i:this},e.prototype.union=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return 0===(e=e.filter((function(t){return 0!==t.size}))).length?this:0!==this.size||this.__ownerID||1!==e.length?this.withMutations((function(r){for(var n=0;n=0&&e=0&&r>>-15,461845907),e=pt(e<<13|e>>>-13,5),e=pt((e=(e+3864292196|0)^t)^e>>>16,2246822507),e=_t((e=pt(e^e>>>13,3266489909))^e>>>16)}(t.size,n)}(this))}});var Jr=S.prototype;Jr[y]=!0,Jr[L]=Jr.values,Jr.toJSON=Jr.toArray,Jr.__toStringMapper=oe,Jr.inspect=Jr.toSource=function(){return this.toString()},Jr.chain=Jr.flatMap,Jr.contains=Jr.includes,xr(I,{flip:function(){return Vt(this,Rt(this))},mapEntries:function(t,e){var r=this,n=0;return Vt(this,this.toSeq().map((function(i,o){return t.call(e,[o,i],n++,r)})).fromEntrySeq())},mapKeys:function(t,e){var r=this;return Vt(this,this.toSeq().flip().map((function(n,i){return t.call(e,n,i,r)})).flip())}});var Vr=I.prototype;Vr[g]=!0,Vr[L]=Jr.entries,Vr.toJSON=Hr,Vr.__toStringMapper=function(t,e){return oe(e)+": "+oe(t)},xr(O,{toKeyedSeq:function(){return new Dt(this,!1)},filter:function(t,e){return Vt(this,Bt(this,t,e,!1))},findIndex:function(t,e){var r=this.findEntry(t,e);return r?r[0]:-1},indexOf:function(t){var e=this.keyOf(t);return void 0===e?-1:e},lastIndexOf:function(t){var e=this.lastKeyOf(t);return void 0===e?-1:e},reverse:function(){return Vt(this,Tt(this,!1))},slice:function(t,e){return Vt(this,Kt(this,t,e,!1))},splice:function(t,e){var r=arguments.length;if(e=Math.max(e||0,0),0===r||2===r&&!e)return this;t=p(t,t<0?this.count():this.size);var n=this.slice(0,t);return Vt(this,1===r?n:n.concat(Zt(arguments,2),this.slice(t+e)))},findLastIndex:function(t,e){var r=this.findLastEntry(t,e);return r?r[0]:-1},first:function(t){return this.get(0,t)},flatten:function(t){return Vt(this,Pt(this,t,!1))},get:function(t,e){return(t=c(this,t))<0||this.size===1/0||void 0!==this.size&&t>this.size?e:this.find((function(e,r){return r===t}),void 0,e)},has:function(t){return(t=c(this,t))>=0&&(void 0!==this.size?this.size===1/0||te?-1:0}function rn(t,e){return t^e+2654435769+(t<<6)+(t>>2)|0}Qr.has=Jr.includes,Qr.contains=Qr.includes,Qr.keys=Qr.values,xr(F,Vr),xr(G,Yr),xr(Z,Qr);var nn=function(t){function e(t){return null==t?an():Mr(t)?t:an().withMutations((function(e){var r=E(t);te(r.size),r.forEach((function(t){return e.add(t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(I(t).keySeq())},e.prototype.toString=function(){return this.__toString("OrderedSet {","}")},e}(kr);nn.isOrderedSet=Mr;var on,un=nn.prototype;function sn(t,e){var r=Object.create(un);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function an(){return on||(on=sn(gr()))}un[A]=!0,un.zip=Yr.zip,un.zipWith=Yr.zipWith,un.zipAll=Yr.zipAll,un.__empty=an,un.__make=sn;var cn=function(t,e){var r;!function(t){if(D(t))throw new Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(x(t))throw new Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(null===t||"object"!=typeof t)throw new Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}(t);var n=function(o){var u=this;if(o instanceof n)return o;if(!(this instanceof n))return new n(o);if(!r){r=!0;var s=Object.keys(t),a=i._indices={};i._name=e,i._keys=s,i._defaultValues=t;for(var c=0;c2?[]:void 0,{"":t})},t.get=se,t.getIn=Pr,t.has=ue,t.hasIn=Nr,t.hash=vt,t.is=ht,t.isAssociative=z,t.isCollection=d,t.isImmutable=x,t.isIndexed=b,t.isKeyed=w,t.isList=rr,t.isMap=at,t.isOrdered=k,t.isOrderedMap=ct,t.isOrderedSet=Mr,t.isPlainObject=ne,t.isRecord=D,t.isSeq=q,t.isSet=qr,t.isStack=br,t.isValueObject=ft,t.merge=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Ie(t,e)},t.mergeDeep=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Se(t,e)},t.mergeDeepWith=function(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];return Se(e,r,t)},t.mergeWith=function(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];return Ie(e,r,t)},t.remove=ce,t.removeIn=ve,t.set=fe,t.setIn=_e,t.update=de,t.updateIn=he,t.version="5.1.1"})); From ef4cedda9f6110b0014c9fdc784626ffc0b6d70d Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 5 May 2025 22:28:21 +0000 Subject: [PATCH 242/242] deploy: e8106161fea7256d6f390dc646a2920473c2fd7b --- bower.json | 2 +- dist/immutable.es.js | 2 +- dist/immutable.js | 2 +- dist/immutable.min.js | 2 +- package.json | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/bower.json b/bower.json index b43c22ad2c..c7f90ff5ff 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "immutable", - "version": "5.1.1", + "version": "5.1.2", "description": "Immutable Data Collections", "license": "MIT", "homepage": "https://immutable-js.com", diff --git a/dist/immutable.es.js b/dist/immutable.es.js index 825944c049..13e407417e 100644 --- a/dist/immutable.es.js +++ b/dist/immutable.es.js @@ -6218,7 +6218,7 @@ function defaultConverter(k, v) { return isIndexed(v) ? v.toList() : isKeyed(v) ? v.toMap() : v.toSet(); } -var version = "5.1.1"; +var version = "5.1.2"; // Note: Iterable is deprecated var Iterable = Collection; diff --git a/dist/immutable.js b/dist/immutable.js index a935c1cae7..ca162e4bce 100644 --- a/dist/immutable.js +++ b/dist/immutable.js @@ -6224,7 +6224,7 @@ return isIndexed(v) ? v.toList() : isKeyed(v) ? v.toMap() : v.toSet(); } - var version = "5.1.1"; + var version = "5.1.2"; // Note: Iterable is deprecated var Iterable = Collection; diff --git a/dist/immutable.min.js b/dist/immutable.min.js index 3465f4120b..d0db132cfc 100644 --- a/dist/immutable.min.js +++ b/dist/immutable.min.js @@ -22,4 +22,4 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).Immutable={})}(this,(function(t){"use strict";var e="delete",r=5,n=1<>>0;if(""+r!==e||4294967295===r)return NaN;e=r}return e<0?a(t)+e:e}function f(){return!0}function h(t,e,r){return(0===t&&!v(t)||void 0!==r&&t<=-r)&&(void 0===e||void 0!==r&&e>=r)}function p(t,e){return l(t,e,0)}function _(t,e){return l(t,e,e)}function l(t,e,r){return void 0===t?r:v(t)?e===1/0?e:0|Math.max(0,e+t):void 0===e||e===t?t:0|Math.min(e,t)}function v(t){return t<0||0===t&&1/t==-1/0}var y="@@__IMMUTABLE_ITERABLE__@@";function d(t){return Boolean(t&&t[y])}var g="@@__IMMUTABLE_KEYED__@@";function w(t){return Boolean(t&&t[g])}var m="@@__IMMUTABLE_INDEXED__@@";function b(t){return Boolean(t&&t[m])}function z(t){return w(t)||b(t)}var S=function(t){return d(t)?t:X(t)},I=function(t){function e(t){return w(t)?t:F(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(S),O=function(t){function e(t){return b(t)?t:G(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(S),E=function(t){function e(t){return d(t)&&!z(t)?t:Z(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(S);S.Keyed=I,S.Indexed=O,S.Set=E;var j="@@__IMMUTABLE_SEQ__@@";function q(t){return Boolean(t&&t[j])}var M="@@__IMMUTABLE_RECORD__@@";function D(t){return Boolean(t&&t[M])}function x(t){return d(t)||D(t)}var A="@@__IMMUTABLE_ORDERED__@@";function k(t){return Boolean(t&&t[A])}var R=0,U=1,T=2,B="function"==typeof Symbol&&Symbol.iterator,K="@@iterator",L=B||K,C=function(t){this.next=t};function P(t,e,r,n){var i=t===R?e:t===U?r:[e,r];return n?n.value=i:n={value:i,done:!1},n}function W(){return{value:void 0,done:!0}}function N(t){return!!Array.isArray(t)||!!V(t)}function H(t){return t&&"function"==typeof t.next}function J(t){var e=V(t);return e&&e.call(t)}function V(t){var e=t&&(B&&t[B]||t[K]);if("function"==typeof e)return e}C.prototype.toString=function(){return"[Iterator]"},C.KEYS=R,C.VALUES=U,C.ENTRIES=T,C.prototype.inspect=C.prototype.toSource=function(){return this.toString()},C.prototype[L]=function(){return this};var Y=Object.prototype.hasOwnProperty;function Q(t){return!(!Array.isArray(t)&&"string"!=typeof t)||t&&"object"==typeof t&&Number.isInteger(t.length)&&t.length>=0&&(0===t.length?1===Object.keys(t).length:t.hasOwnProperty(t.length-1))}var X=function(t){function e(t){return null==t?nt():x(t)?t.toSeq():function(t){var e=ut(t);if(e)return(n=V(r=t))&&n===r.entries?e.fromEntrySeq():function(t){var e=V(t);return e&&e===t.keys}(t)?e.toSetSeq():e;var r,n;if("object"==typeof t)return new tt(t);throw new TypeError("Expected Array or collection object of values, or keyed object: "+t)}(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq {","}")},e.prototype.cacheResult=function(){return!this._cache&&this.__iterateUncached&&(this._cache=this.entrySeq().toArray(),this.size=this._cache.length),this},e.prototype.__iterate=function(t,e){var r=this._cache;if(r){for(var n=r.length,i=0;i!==n;){var o=r[e?n-++i:i++];if(!1===t(o[1],o[0],this))break}return i}return this.__iterateUncached(t,e)},e.prototype.__iterator=function(t,e){var r=this._cache;if(r){var n=r.length,i=0;return new C((function(){if(i===n)return{value:void 0,done:!0};var o=r[e?n-++i:i++];return P(t,o[0],o[1])}))}return this.__iteratorUncached(t,e)},e}(S),F=function(t){function e(t){return null==t?nt().toKeyedSeq():d(t)?w(t)?t.toSeq():t.fromEntrySeq():D(t)?t.toSeq():it(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toKeyedSeq=function(){return this},e}(X),G=function(t){function e(t){return null==t?nt():d(t)?w(t)?t.entrySeq():t.toIndexedSeq():D(t)?t.toSeq().entrySeq():ot(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return e(arguments)},e.prototype.toIndexedSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq [","]")},e}(X),Z=function(t){function e(t){return(d(t)&&!z(t)?t:G(t)).toSetSeq()}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return e(arguments)},e.prototype.toSetSeq=function(){return this},e}(X);X.isSeq=q,X.Keyed=F,X.Set=Z,X.Indexed=G,X.prototype[j]=!0;var $=function(t){function e(t){this._array=t,this.size=t.length}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t,e){return this.has(t)?this._array[c(this,t)]:e},e.prototype.__iterate=function(t,e){for(var r=this._array,n=r.length,i=0;i!==n;){var o=e?n-++i:i++;if(!1===t(r[o],o,this))break}return i},e.prototype.__iterator=function(t,e){var r=this._array,n=r.length,i=0;return new C((function(){if(i===n)return{value:void 0,done:!0};var o=e?n-++i:i++;return P(t,o,r[o])}))},e}(G),tt=function(t){function e(t){var e=Object.keys(t).concat(Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(t):[]);this._object=t,this._keys=e,this.size=e.length}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t,e){return void 0===e||this.has(t)?this._object[t]:e},e.prototype.has=function(t){return Y.call(this._object,t)},e.prototype.__iterate=function(t,e){for(var r=this._object,n=this._keys,i=n.length,o=0;o!==i;){var u=n[e?i-++o:o++];if(!1===t(r[u],u,this))break}return o},e.prototype.__iterator=function(t,e){var r=this._object,n=this._keys,i=n.length,o=0;return new C((function(){if(o===i)return{value:void 0,done:!0};var u=n[e?i-++o:o++];return P(t,u,r[u])}))},e}(F);tt.prototype[A]=!0;var et,rt=function(t){function e(t){this._collection=t,this.size=t.length||t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.__iterateUncached=function(t,e){if(e)return this.cacheResult().__iterate(t,e);var r=J(this._collection),n=0;if(H(r))for(var i;!(i=r.next()).done&&!1!==t(i.value,n++,this););return n},e.prototype.__iteratorUncached=function(t,e){if(e)return this.cacheResult().__iterator(t,e);var r=J(this._collection);if(!H(r))return new C(W);var n=0;return new C((function(){var e=r.next();return e.done?e:P(t,n++,e.value)}))},e}(G);function nt(){return et||(et=new $([]))}function it(t){var e=ut(t);if(e)return e.fromEntrySeq();if("object"==typeof t)return new tt(t);throw new TypeError("Expected Array or collection object of [k, v] entries, or keyed object: "+t)}function ot(t){var e=ut(t);if(e)return e;throw new TypeError("Expected Array or collection object of values: "+t)}function ut(t){return Q(t)?new $(t):N(t)?new rt(t):void 0}var st="@@__IMMUTABLE_MAP__@@";function at(t){return Boolean(t&&t[st])}function ct(t){return at(t)&&k(t)}function ft(t){return Boolean(t&&"function"==typeof t.equals&&"function"==typeof t.hashCode)}function ht(t,e){if(t===e||t!=t&&e!=e)return!0;if(!t||!e)return!1;if("function"==typeof t.valueOf&&"function"==typeof e.valueOf){if((t=t.valueOf())===(e=e.valueOf())||t!=t&&e!=e)return!0;if(!t||!e)return!1}return!!(ft(t)&&ft(e)&&t.equals(e))}var pt="function"==typeof Math.imul&&-2===Math.imul(4294967295,2)?Math.imul:function(t,e){var r=65535&(t|=0),n=65535&(e|=0);return r*n+((t>>>16)*n+r*(e>>>16)<<16>>>0)|0};function _t(t){return t>>>1&1073741824|3221225471&t}var lt=Object.prototype.valueOf;function vt(t){if(null==t)return yt(t);if("function"==typeof t.hashCode)return _t(t.hashCode(t));var e,r=(e=t).valueOf!==lt&&"function"==typeof e.valueOf?e.valueOf(e):e;if(null==r)return yt(r);switch(typeof r){case"boolean":return r?1108378657:1108378656;case"number":return function(t){if(t!=t||t===1/0)return 0;var e=0|t;e!==t&&(e^=4294967295*t);for(;t>4294967295;)e^=t/=4294967295;return _t(e)}(r);case"string":return r.length>Et?function(t){var e=Mt[t];void 0===e&&(e=dt(t),qt===jt&&(qt=0,Mt={}),qt++,Mt[t]=e);return e}(r):dt(r);case"object":case"function":return function(t){var e;if(zt&&void 0!==(e=bt.get(t)))return e;if(e=t[Ot],void 0!==e)return e;if(!wt){if(void 0!==(e=t.propertyIsEnumerable&&t.propertyIsEnumerable[Ot]))return e;if(void 0!==(e=function(t){if(t&&t.nodeType>0)switch(t.nodeType){case 1:return t.uniqueID;case 9:return t.documentElement&&t.documentElement.uniqueID}}(t)))return e}if(e=mt(),zt)bt.set(t,e);else{if(void 0!==gt&&!1===gt(t))throw new Error("Non-extensible objects are not allowed as keys.");if(wt)Object.defineProperty(t,Ot,{enumerable:!1,configurable:!1,writable:!1,value:e});else if(void 0!==t.propertyIsEnumerable&&t.propertyIsEnumerable===t.constructor.prototype.propertyIsEnumerable)t.propertyIsEnumerable=function(){return this.constructor.prototype.propertyIsEnumerable.apply(this,arguments)},t.propertyIsEnumerable[Ot]=e;else{if(void 0===t.nodeType)throw new Error("Unable to set a non-enumerable property on object.");t[Ot]=e}}return e}(r);case"symbol":return function(t){var e=St[t];if(void 0!==e)return e;return e=mt(),St[t]=e,e}(r);default:if("function"==typeof r.toString)return dt(r.toString());throw new Error("Value type "+typeof r+" cannot be hashed.")}}function yt(t){return null===t?1108378658:1108378659}function dt(t){for(var e=0,r=0;r=0&&(a.get=function(e,r){return(e=c(this,e))>=0&&eo)return{value:void 0,done:!0};var t=i.next();return n||e===U||t.done?t:P(e,a-1,e===R?void 0:t.value[1],t)}))},a}function Lt(t,e,r,n){var i=Xt(t);return i.__iterateUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterate(i,o);var s=!0,a=0;return t.__iterate((function(t,o,c){if(!s||!(s=e.call(r,t,o,c)))return a++,i(t,n?o:a-1,u)})),a},i.__iteratorUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterator(i,o);var s=t.__iterator(T,o),a=!0,c=0;return new C((function(){var t,o,f;do{if((t=s.next()).done)return n||i===U?t:P(i,c++,i===R?void 0:t.value[1],t);var h=t.value;o=h[0],f=h[1],a&&(a=e.call(r,f,o,u))}while(a);return i===T?t:P(i,o,f,t)}))},i}xt.prototype.cacheResult=Dt.prototype.cacheResult=At.prototype.cacheResult=kt.prototype.cacheResult=Ft;var Ct=function(t){function e(t){this._wrappedIterables=t.flatMap((function(t){return t._wrappedIterables?t._wrappedIterables:[t]})),this.size=this._wrappedIterables.reduce((function(t,e){if(void 0!==t){var r=e.size;if(void 0!==r)return t+r}}),0),this[g]=this._wrappedIterables[0][g],this[m]=this._wrappedIterables[0][m],this[A]=this._wrappedIterables[0][A]}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.__iterateUncached=function(t,e){if(0!==this._wrappedIterables.length){if(e)return this.cacheResult().__iterate(t,e);for(var r=0,n=w(this),i=n?T:U,o=this._wrappedIterables[r].__iterator(i,e),u=!0,s=0;u;){for(var a=o.next();a.done;){if(++r===this._wrappedIterables.length)return s;a=(o=this._wrappedIterables[r].__iterator(i,e)).next()}u=!1!==(n?t(a.value[1],a.value[0],this):t(a.value,s,this)),s++}return s}},e.prototype.__iteratorUncached=function(t,e){var r=this;if(0===this._wrappedIterables.length)return new C(W);if(e)return this.cacheResult().__iterator(t,e);var n=0,i=this._wrappedIterables[n].__iterator(t,e);return new C((function(){for(var o=i.next();o.done;){if(++n===r._wrappedIterables.length)return o;o=(i=r._wrappedIterables[n].__iterator(t,e)).next()}return o}))},e}(X);function Pt(t,e,r){var n=Xt(t);return n.__iterateUncached=function(i,o){if(o)return this.cacheResult().__iterate(i,o);var u=0,s=!1;return function t(a,c){a.__iterate((function(o,a){return(!e||c0}function Jt(t,e,r,n){var i=Xt(t),o=new $(r).map((function(t){return t.size}));return i.size=n?o.max():o.min(),i.__iterate=function(t,e){for(var r,n=this.__iterator(U,e),i=0;!(r=n.next()).done&&!1!==t(r.value,i++,this););return i},i.__iteratorUncached=function(t,i){var o=r.map((function(t){return t=S(t),J(i?t.reverse():t)})),u=0,s=!1;return new C((function(){var r;return s||(r=o.map((function(t){return t.next()})),s=n?r.every((function(t){return t.done})):r.some((function(t){return t.done}))),s?{value:void 0,done:!0}:P(t,u++,e.apply(null,r.map((function(t){return t.value}))))}))},i}function Vt(t,e){return t===e?t:q(t)?e:t.constructor(e)}function Yt(t){if(t!==Object(t))throw new TypeError("Expected [K, V] tuple: "+t)}function Qt(t){return w(t)?I:b(t)?O:E}function Xt(t){return Object.create((w(t)?F:b(t)?G:Z).prototype)}function Ft(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size,this):X.prototype.cacheResult.call(this)}function Gt(t,e){return void 0===t&&void 0===e?0:void 0===t?1:void 0===e?-1:t>e?1:t0;)e[r]=arguments[r+1];if("function"!=typeof t)throw new TypeError("Invalid merger function: "+t);return ze(this,e,t)}function ze(t,e,r){for(var n=[],i=0;i0;)e[r]=arguments[r+1];return Se(this,e,t)}function je(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return he(this,t,Je(),(function(t){return Ie(t,e)}))}function qe(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return he(this,t,Je(),(function(t){return Se(t,e)}))}function Me(t){var e=this.asMutable();return t(e),e.wasAltered()?e.__ensureOwner(this.__ownerID):this}function De(){return this.__ownerID?this:this.__ensureOwner(new s)}function xe(){return this.__ensureOwner()}function Ae(){return this.__altered}var ke=function(t){function e(e){return null==e?Je():at(e)&&!k(e)?e:Je().withMutations((function(r){var n=t(e);te(n.size),n.forEach((function(t,e){return r.set(e,t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toString=function(){return this.__toString("Map {","}")},e.prototype.get=function(t,e){return this._root?this._root.get(0,void 0,t,e):e},e.prototype.set=function(t,e){return Ve(this,t,e)},e.prototype.remove=function(t){return Ve(this,t,o)},e.prototype.deleteAll=function(t){var e=S(t);return 0===e.size?this:this.withMutations((function(t){e.forEach((function(e){return t.remove(e)}))}))},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):Je()},e.prototype.sort=function(t){return yr(Wt(this,t))},e.prototype.sortBy=function(t,e){return yr(Wt(this,e,t))},e.prototype.map=function(t,e){var r=this;return this.withMutations((function(n){n.forEach((function(i,o){n.set(o,t.call(e,i,o,r))}))}))},e.prototype.__iterator=function(t,e){return new Pe(this,t,e)},e.prototype.__iterate=function(t,e){var r=this,n=0;return this._root&&this._root.iterate((function(e){return n++,t(e[1],e[0],r)}),e),n},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?He(this.size,this._root,t,this.__hash):0===this.size?Je():(this.__ownerID=t,this.__altered=!1,this)},e}(I);ke.isMap=at;var Re=ke.prototype;Re[st]=!0,Re[e]=Re.remove,Re.removeAll=Re.deleteAll,Re.setIn=le,Re.removeIn=Re.deleteIn=ye,Re.update=ge,Re.updateIn=we,Re.merge=Re.concat=me,Re.mergeWith=be,Re.mergeDeep=Oe,Re.mergeDeepWith=Ee,Re.mergeIn=je,Re.mergeDeepIn=qe,Re.withMutations=Me,Re.wasAltered=Ae,Re.asImmutable=xe,Re["@@transducer/init"]=Re.asMutable=De,Re["@@transducer/step"]=function(t,e){return t.set(e[0],e[1])},Re["@@transducer/result"]=function(t){return t.asImmutable()};var Ue=function(t,e){this.ownerID=t,this.entries=e};Ue.prototype.get=function(t,e,r,n){for(var i=this.entries,o=0,u=i.length;o=Ze)return function(t,e,r,n){t||(t=new s);for(var i=new Le(t,vt(r),[r,n]),o=0;o>>t)&i),s=this.bitmap;return 0==(s&u)?o:this.nodes[Fe(s&u-1)].get(t+r,e,n,o)},Te.prototype.update=function(t,e,u,s,a,c,f){void 0===u&&(u=vt(s));var h=(0===e?u:u>>>e)&i,p=1<=$e)return function(t,e,r,i,o){for(var u=0,s=new Array(n),a=0;0!==r;a++,r>>>=1)s[a]=1&r?e[u++]:void 0;return s[i]=o,new Be(t,u+1,s)}(t,y,_,h,g);if(l&&!g&&2===y.length&&Qe(y[1^v]))return y[1^v];if(l&&g&&1===y.length&&Qe(g))return g;var w=t&&t===this.ownerID,m=l?g?_:_^p:_|p,b=l?g?Ge(y,v,g,w):function(t,e,r){var n=t.length-1;if(r&&e===n)return t.pop(),t;for(var i=new Array(n),o=0,u=0;u>>t)&i,s=this.nodes[u];return s?s.get(t+r,e,n,o):o},Be.prototype.update=function(t,e,n,u,s,a,c){void 0===n&&(n=vt(u));var f=(0===e?n:n>>>e)&i,h=s===o,p=this.nodes,_=p[f];if(h&&!_)return this;var l=Ye(_,t,e+r,n,u,s,a,c);if(l===_)return this;var v=this.count;if(_){if(!l&&--v>>n)&i,c=(0===n?o:o>>>n)&i,f=a===c?[Xe(t,e,n+r,o,u)]:(s=new Le(e,o,u),a>1&1431655765))+(t>>2&858993459))+(t>>4)&252645135,t+=t>>8,127&(t+=t>>16)}function Ge(t,e,r,n){var i=n?t:Zt(t);return i[e]=r,i}var Ze=n/4,$e=n/2,tr=n/4,er="@@__IMMUTABLE_LIST__@@";function rr(t){return Boolean(t&&t[er])}var nr=function(t){function e(e){var i=cr();if(null==e)return i;if(rr(e))return e;var o=t(e),u=o.size;return 0===u?i:(te(u),u>0&&u=0&&t=t.size||e<0)return t.withMutations((function(t){e<0?_r(t,e).set(0,r):_r(t,0,e+1).set(e,r)}));e+=t._origin;var n=t._tail,i=t._root,o={value:!1};e>=lr(t._capacity)?n=fr(n,t.__ownerID,0,e,r,o):i=fr(i,t.__ownerID,t._level,e,r,o);if(!o.value)return t;if(t.__ownerID)return t._root=i,t._tail=n,t.__hash=void 0,t.__altered=!0,t;return ar(t._origin,t._capacity,t._level,i,n)}(this,t,e)},e.prototype.remove=function(t){return this.has(t)?0===t?this.shift():t===this.size-1?this.pop():this.splice(t,1):this},e.prototype.insert=function(t,e){return this.splice(t,0,e)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=this._origin=this._capacity=0,this._level=r,this._root=this._tail=this.__hash=void 0,this.__altered=!0,this):cr()},e.prototype.push=function(){var t=arguments,e=this.size;return this.withMutations((function(r){_r(r,0,e+t.length);for(var n=0;n>>e&i;if(o>=this.array.length)return new or([],t);var u,s=0===o;if(e>0){var a=this.array[o];if((u=a&&a.removeBefore(t,e-r,n))===a&&s)return this}if(s&&!u)return this;var c=hr(this,t);if(!s)for(var f=0;f>>e&i;if(s>=this.array.length)return this;if(e>0){var a=this.array[s];if((u=a&&a.removeAfter(t,e-r,o))===a&&s===this.array.length-1)return this}var c=hr(this,t);return c.array.splice(s+1),u&&(c.array[s]=u),c};var ur={};function sr(t,e){var i=t._origin,o=t._capacity,u=lr(o),s=t._tail;return a(t._root,t._level,0);function a(t,c,f){return 0===c?function(t,r){var a=r===u?s&&s.array:t&&t.array,c=r>i?0:i-r,f=o-r;f>n&&(f=n);return function(){if(c===f)return ur;var t=e?--f:c++;return a&&a[t]}}(t,f):function(t,u,s){var c,f=t&&t.array,h=s>i?0:i-s>>u,p=1+(o-s>>u);p>n&&(p=n);return function(){for(;;){if(c){var t=c();if(t!==ur)return t;c=null}if(h===p)return ur;var n=e?--p:h++;c=a(f&&f[n],u-r,s+(n<>>n&i,h=t&&f0){var p=t&&t.array[f],_=fr(p,e,n-r,o,s,a);return _===p?t:((c=hr(t,e)).array[f]=_,c)}return h&&t.array[f]===s?t:(a&&u(a),c=hr(t,e),void 0===s&&f===c.array.length-1?c.array.pop():c.array[f]=s,c)}function hr(t,e){return e&&t&&e===t.ownerID?t:new or(t?t.array.slice():[],e)}function pr(t,e){if(e>=lr(t._capacity))return t._tail;if(e<1<0;)n=n.array[e>>>o&i],o-=r;return n}}function _r(t,e,n){void 0!==e&&(e|=0),void 0!==n&&(n|=0);var o=t.__ownerID||new s,u=t._origin,a=t._capacity,c=u+e,f=void 0===n?a:n<0?a+n:u+n;if(c===u&&f===a)return t;if(c>=f)return t.clear();for(var h=t._level,p=t._root,_=0;c+_<0;)p=new or(p&&p.array.length?[void 0,p]:[],o),_+=1<<(h+=r);_&&(c+=_,u+=_,f+=_,a+=_);for(var l=lr(a),v=lr(f);v>=1<l?new or([],o):y;if(y&&v>l&&cr;w-=r){var m=l>>>w&i;g=g.array[m]=hr(g.array[m],o)}g.array[l>>>r&i]=y}if(f=v)c-=v,f-=v,h=r,p=null,d=d&&d.removeBefore(o,0,c);else if(c>u||v>>h&i;if(b!==v>>>h&i)break;b&&(_+=(1<u&&(p=p.removeBefore(o,h,c-_)),p&&v>>r<=n&&a.size>=2*s.size?(i=(u=a.filter((function(t,e){return void 0!==t&&c!==e}))).toKeyedSeq().map((function(t){return t[0]})).flip().toMap(),t.__ownerID&&(i.__ownerID=u.__ownerID=t.__ownerID)):(i=s.remove(e),u=c===a.size-1?a.pop():a.set(c,void 0))}else if(f){if(r===a.get(c)[1])return t;i=s,u=a.set(c,[e,r])}else i=s.set(e,a.size),u=a.set(a.size,[e,r]);return t.__ownerID?(t.size=i.size,t._map=i,t._list=u,t.__hash=void 0,t.__altered=!0,t):dr(i,u)}yr.isOrderedMap=ct,yr.prototype[A]=!0,yr.prototype[e]=yr.prototype.remove;var mr="@@__IMMUTABLE_STACK__@@";function br(t){return Boolean(t&&t[mr])}var zr=function(t){function e(t){return null==t?Er():br(t)?t:Er().pushAll(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("Stack [","]")},e.prototype.get=function(t,e){var r=this._head;for(t=c(this,t);r&&t--;)r=r.next;return r?r.value:e},e.prototype.peek=function(){return this._head&&this._head.value},e.prototype.push=function(){var t=arguments;if(0===arguments.length)return this;for(var e=this.size+arguments.length,r=this._head,n=arguments.length-1;n>=0;n--)r={value:t[n],next:r};return this.__ownerID?(this.size=e,this._head=r,this.__hash=void 0,this.__altered=!0,this):Or(e,r)},e.prototype.pushAll=function(e){if(0===(e=t(e)).size)return this;if(0===this.size&&br(e))return e;te(e.size);var r=this.size,n=this._head;return e.__iterate((function(t){r++,n={value:t,next:n}}),!0),this.__ownerID?(this.size=r,this._head=n,this.__hash=void 0,this.__altered=!0,this):Or(r,n)},e.prototype.pop=function(){return this.slice(1)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):Er()},e.prototype.slice=function(e,r){if(h(e,r,this.size))return this;var n=p(e,this.size);if(_(r,this.size)!==this.size)return t.prototype.slice.call(this,e,r);for(var i=this.size-n,o=this._head;n--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):Or(i,o)},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Or(this.size,this._head,t,this.__hash):0===this.size?Er():(this.__ownerID=t,this.__altered=!1,this)},e.prototype.__iterate=function(t,e){var r=this;if(e)return new $(this.toArray()).__iterate((function(e,n){return t(e,n,r)}),e);for(var n=0,i=this._head;i&&!1!==t(i.value,n++,this);)i=i.next;return n},e.prototype.__iterator=function(t,e){if(e)return new $(this.toArray()).__iterator(t,e);var r=0,n=this._head;return new C((function(){if(n){var e=n.value;return n=n.next,P(t,r++,e)}return{value:void 0,done:!0}}))},e}(O);zr.isStack=br;var Sr,Ir=zr.prototype;function Or(t,e,r,n){var i=Object.create(Ir);return i.size=t,i._head=e,i.__ownerID=r,i.__hash=n,i.__altered=!1,i}function Er(){return Sr||(Sr=Or(0))}Ir[mr]=!0,Ir.shift=Ir.pop,Ir.unshift=Ir.push,Ir.unshiftAll=Ir.pushAll,Ir.withMutations=Me,Ir.wasAltered=Ae,Ir.asImmutable=xe,Ir["@@transducer/init"]=Ir.asMutable=De,Ir["@@transducer/step"]=function(t,e){return t.unshift(e)},Ir["@@transducer/result"]=function(t){return t.asImmutable()};var jr="@@__IMMUTABLE_SET__@@";function qr(t){return Boolean(t&&t[jr])}function Mr(t){return qr(t)&&k(t)}function Dr(t,e){if(t===e)return!0;if(!d(e)||void 0!==t.size&&void 0!==e.size&&t.size!==e.size||void 0!==t.__hash&&void 0!==e.__hash&&t.__hash!==e.__hash||w(t)!==w(e)||b(t)!==b(e)||k(t)!==k(e))return!1;if(0===t.size&&0===e.size)return!0;var r=!z(t);if(k(t)){var n=t.entries();return e.every((function(t,e){var i=n.next().value;return i&&ht(i[1],t)&&(r||ht(i[0],e))}))&&n.next().done}var i=!1;if(void 0===t.size)if(void 0===e.size)"function"==typeof t.cacheResult&&t.cacheResult();else{i=!0;var u=t;t=e,e=u}var s=!0,a=e.__iterate((function(e,n){if(r?!t.has(e):i?!ht(e,t.get(n,o)):!ht(t.get(n,o),e))return s=!1,!1}));return s&&t.size===a}function xr(t,e){var r=function(r){t.prototype[r]=e[r]};return Object.keys(e).forEach(r),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(e).forEach(r),t}function Ar(t){if(!t||"object"!=typeof t)return t;if(!d(t)){if(!ie(t))return t;t=X(t)}if(w(t)){var e={};return t.__iterate((function(t,r){e[r]=Ar(t)})),e}var r=[];return t.__iterate((function(t){r.push(Ar(t))})),r}var kr=function(t){function e(e){return null==e?Kr():qr(e)&&!k(e)?e:Kr().withMutations((function(r){var n=t(e);te(n.size),n.forEach((function(t){return r.add(t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(I(t).keySeq())},e.intersect=function(t){return(t=S(t).toArray()).length?Ur.intersect.apply(e(t.pop()),t):Kr()},e.union=function(t){return(t=S(t).toArray()).length?Ur.union.apply(e(t.pop()),t):Kr()},e.prototype.toString=function(){return this.__toString("Set {","}")},e.prototype.has=function(t){return this._map.has(t)},e.prototype.add=function(t){return Tr(this,this._map.set(t,t))},e.prototype.remove=function(t){return Tr(this,this._map.remove(t))},e.prototype.clear=function(){return Tr(this,this._map.clear())},e.prototype.map=function(t,e){var r=this,n=!1,i=Tr(this,this._map.mapEntries((function(i){var o=i[1],u=t.call(e,o,o,r);return u!==o&&(n=!0),[u,u]}),e));return n?i:this},e.prototype.union=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return 0===(e=e.filter((function(t){return 0!==t.size}))).length?this:0!==this.size||this.__ownerID||1!==e.length?this.withMutations((function(r){for(var n=0;n=0&&e=0&&r>>-15,461845907),e=pt(e<<13|e>>>-13,5),e=pt((e=(e+3864292196|0)^t)^e>>>16,2246822507),e=_t((e=pt(e^e>>>13,3266489909))^e>>>16)}(t.size,n)}(this))}});var Jr=S.prototype;Jr[y]=!0,Jr[L]=Jr.values,Jr.toJSON=Jr.toArray,Jr.__toStringMapper=oe,Jr.inspect=Jr.toSource=function(){return this.toString()},Jr.chain=Jr.flatMap,Jr.contains=Jr.includes,xr(I,{flip:function(){return Vt(this,Rt(this))},mapEntries:function(t,e){var r=this,n=0;return Vt(this,this.toSeq().map((function(i,o){return t.call(e,[o,i],n++,r)})).fromEntrySeq())},mapKeys:function(t,e){var r=this;return Vt(this,this.toSeq().flip().map((function(n,i){return t.call(e,n,i,r)})).flip())}});var Vr=I.prototype;Vr[g]=!0,Vr[L]=Jr.entries,Vr.toJSON=Hr,Vr.__toStringMapper=function(t,e){return oe(e)+": "+oe(t)},xr(O,{toKeyedSeq:function(){return new Dt(this,!1)},filter:function(t,e){return Vt(this,Bt(this,t,e,!1))},findIndex:function(t,e){var r=this.findEntry(t,e);return r?r[0]:-1},indexOf:function(t){var e=this.keyOf(t);return void 0===e?-1:e},lastIndexOf:function(t){var e=this.lastKeyOf(t);return void 0===e?-1:e},reverse:function(){return Vt(this,Tt(this,!1))},slice:function(t,e){return Vt(this,Kt(this,t,e,!1))},splice:function(t,e){var r=arguments.length;if(e=Math.max(e||0,0),0===r||2===r&&!e)return this;t=p(t,t<0?this.count():this.size);var n=this.slice(0,t);return Vt(this,1===r?n:n.concat(Zt(arguments,2),this.slice(t+e)))},findLastIndex:function(t,e){var r=this.findLastEntry(t,e);return r?r[0]:-1},first:function(t){return this.get(0,t)},flatten:function(t){return Vt(this,Pt(this,t,!1))},get:function(t,e){return(t=c(this,t))<0||this.size===1/0||void 0!==this.size&&t>this.size?e:this.find((function(e,r){return r===t}),void 0,e)},has:function(t){return(t=c(this,t))>=0&&(void 0!==this.size?this.size===1/0||te?-1:0}function rn(t,e){return t^e+2654435769+(t<<6)+(t>>2)|0}Qr.has=Jr.includes,Qr.contains=Qr.includes,Qr.keys=Qr.values,xr(F,Vr),xr(G,Yr),xr(Z,Qr);var nn=function(t){function e(t){return null==t?an():Mr(t)?t:an().withMutations((function(e){var r=E(t);te(r.size),r.forEach((function(t){return e.add(t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(I(t).keySeq())},e.prototype.toString=function(){return this.__toString("OrderedSet {","}")},e}(kr);nn.isOrderedSet=Mr;var on,un=nn.prototype;function sn(t,e){var r=Object.create(un);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function an(){return on||(on=sn(gr()))}un[A]=!0,un.zip=Yr.zip,un.zipWith=Yr.zipWith,un.zipAll=Yr.zipAll,un.__empty=an,un.__make=sn;var cn=function(t,e){var r;!function(t){if(D(t))throw new Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(x(t))throw new Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(null===t||"object"!=typeof t)throw new Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}(t);var n=function(o){var u=this;if(o instanceof n)return o;if(!(this instanceof n))return new n(o);if(!r){r=!0;var s=Object.keys(t),a=i._indices={};i._name=e,i._keys=s,i._defaultValues=t;for(var c=0;c2?[]:void 0,{"":t})},t.get=se,t.getIn=Pr,t.has=ue,t.hasIn=Nr,t.hash=vt,t.is=ht,t.isAssociative=z,t.isCollection=d,t.isImmutable=x,t.isIndexed=b,t.isKeyed=w,t.isList=rr,t.isMap=at,t.isOrdered=k,t.isOrderedMap=ct,t.isOrderedSet=Mr,t.isPlainObject=ne,t.isRecord=D,t.isSeq=q,t.isSet=qr,t.isStack=br,t.isValueObject=ft,t.merge=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Ie(t,e)},t.mergeDeep=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Se(t,e)},t.mergeDeepWith=function(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];return Se(e,r,t)},t.mergeWith=function(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];return Ie(e,r,t)},t.remove=ce,t.removeIn=ve,t.set=fe,t.setIn=_e,t.update=de,t.updateIn=he,t.version="5.1.1"})); +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).Immutable={})}(this,(function(t){"use strict";var e="delete",r=5,n=1<>>0;if(""+r!==e||4294967295===r)return NaN;e=r}return e<0?a(t)+e:e}function f(){return!0}function h(t,e,r){return(0===t&&!v(t)||void 0!==r&&t<=-r)&&(void 0===e||void 0!==r&&e>=r)}function p(t,e){return l(t,e,0)}function _(t,e){return l(t,e,e)}function l(t,e,r){return void 0===t?r:v(t)?e===1/0?e:0|Math.max(0,e+t):void 0===e||e===t?t:0|Math.min(e,t)}function v(t){return t<0||0===t&&1/t==-1/0}var y="@@__IMMUTABLE_ITERABLE__@@";function d(t){return Boolean(t&&t[y])}var g="@@__IMMUTABLE_KEYED__@@";function w(t){return Boolean(t&&t[g])}var m="@@__IMMUTABLE_INDEXED__@@";function b(t){return Boolean(t&&t[m])}function z(t){return w(t)||b(t)}var S=function(t){return d(t)?t:X(t)},I=function(t){function e(t){return w(t)?t:F(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(S),O=function(t){function e(t){return b(t)?t:G(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(S),E=function(t){function e(t){return d(t)&&!z(t)?t:Z(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e}(S);S.Keyed=I,S.Indexed=O,S.Set=E;var j="@@__IMMUTABLE_SEQ__@@";function q(t){return Boolean(t&&t[j])}var M="@@__IMMUTABLE_RECORD__@@";function D(t){return Boolean(t&&t[M])}function x(t){return d(t)||D(t)}var A="@@__IMMUTABLE_ORDERED__@@";function k(t){return Boolean(t&&t[A])}var R=0,U=1,T=2,B="function"==typeof Symbol&&Symbol.iterator,K="@@iterator",L=B||K,C=function(t){this.next=t};function P(t,e,r,n){var i=t===R?e:t===U?r:[e,r];return n?n.value=i:n={value:i,done:!1},n}function W(){return{value:void 0,done:!0}}function N(t){return!!Array.isArray(t)||!!V(t)}function H(t){return t&&"function"==typeof t.next}function J(t){var e=V(t);return e&&e.call(t)}function V(t){var e=t&&(B&&t[B]||t[K]);if("function"==typeof e)return e}C.prototype.toString=function(){return"[Iterator]"},C.KEYS=R,C.VALUES=U,C.ENTRIES=T,C.prototype.inspect=C.prototype.toSource=function(){return this.toString()},C.prototype[L]=function(){return this};var Y=Object.prototype.hasOwnProperty;function Q(t){return!(!Array.isArray(t)&&"string"!=typeof t)||t&&"object"==typeof t&&Number.isInteger(t.length)&&t.length>=0&&(0===t.length?1===Object.keys(t).length:t.hasOwnProperty(t.length-1))}var X=function(t){function e(t){return null==t?nt():x(t)?t.toSeq():function(t){var e=ut(t);if(e)return(n=V(r=t))&&n===r.entries?e.fromEntrySeq():function(t){var e=V(t);return e&&e===t.keys}(t)?e.toSetSeq():e;var r,n;if("object"==typeof t)return new tt(t);throw new TypeError("Expected Array or collection object of values, or keyed object: "+t)}(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq {","}")},e.prototype.cacheResult=function(){return!this._cache&&this.__iterateUncached&&(this._cache=this.entrySeq().toArray(),this.size=this._cache.length),this},e.prototype.__iterate=function(t,e){var r=this._cache;if(r){for(var n=r.length,i=0;i!==n;){var o=r[e?n-++i:i++];if(!1===t(o[1],o[0],this))break}return i}return this.__iterateUncached(t,e)},e.prototype.__iterator=function(t,e){var r=this._cache;if(r){var n=r.length,i=0;return new C((function(){if(i===n)return{value:void 0,done:!0};var o=r[e?n-++i:i++];return P(t,o[0],o[1])}))}return this.__iteratorUncached(t,e)},e}(S),F=function(t){function e(t){return null==t?nt().toKeyedSeq():d(t)?w(t)?t.toSeq():t.fromEntrySeq():D(t)?t.toSeq():it(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toKeyedSeq=function(){return this},e}(X),G=function(t){function e(t){return null==t?nt():d(t)?w(t)?t.entrySeq():t.toIndexedSeq():D(t)?t.toSeq().entrySeq():ot(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return e(arguments)},e.prototype.toIndexedSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq [","]")},e}(X),Z=function(t){function e(t){return(d(t)&&!z(t)?t:G(t)).toSetSeq()}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return e(arguments)},e.prototype.toSetSeq=function(){return this},e}(X);X.isSeq=q,X.Keyed=F,X.Set=Z,X.Indexed=G,X.prototype[j]=!0;var $=function(t){function e(t){this._array=t,this.size=t.length}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t,e){return this.has(t)?this._array[c(this,t)]:e},e.prototype.__iterate=function(t,e){for(var r=this._array,n=r.length,i=0;i!==n;){var o=e?n-++i:i++;if(!1===t(r[o],o,this))break}return i},e.prototype.__iterator=function(t,e){var r=this._array,n=r.length,i=0;return new C((function(){if(i===n)return{value:void 0,done:!0};var o=e?n-++i:i++;return P(t,o,r[o])}))},e}(G),tt=function(t){function e(t){var e=Object.keys(t).concat(Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(t):[]);this._object=t,this._keys=e,this.size=e.length}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(t,e){return void 0===e||this.has(t)?this._object[t]:e},e.prototype.has=function(t){return Y.call(this._object,t)},e.prototype.__iterate=function(t,e){for(var r=this._object,n=this._keys,i=n.length,o=0;o!==i;){var u=n[e?i-++o:o++];if(!1===t(r[u],u,this))break}return o},e.prototype.__iterator=function(t,e){var r=this._object,n=this._keys,i=n.length,o=0;return new C((function(){if(o===i)return{value:void 0,done:!0};var u=n[e?i-++o:o++];return P(t,u,r[u])}))},e}(F);tt.prototype[A]=!0;var et,rt=function(t){function e(t){this._collection=t,this.size=t.length||t.size}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.__iterateUncached=function(t,e){if(e)return this.cacheResult().__iterate(t,e);var r=J(this._collection),n=0;if(H(r))for(var i;!(i=r.next()).done&&!1!==t(i.value,n++,this););return n},e.prototype.__iteratorUncached=function(t,e){if(e)return this.cacheResult().__iterator(t,e);var r=J(this._collection);if(!H(r))return new C(W);var n=0;return new C((function(){var e=r.next();return e.done?e:P(t,n++,e.value)}))},e}(G);function nt(){return et||(et=new $([]))}function it(t){var e=ut(t);if(e)return e.fromEntrySeq();if("object"==typeof t)return new tt(t);throw new TypeError("Expected Array or collection object of [k, v] entries, or keyed object: "+t)}function ot(t){var e=ut(t);if(e)return e;throw new TypeError("Expected Array or collection object of values: "+t)}function ut(t){return Q(t)?new $(t):N(t)?new rt(t):void 0}var st="@@__IMMUTABLE_MAP__@@";function at(t){return Boolean(t&&t[st])}function ct(t){return at(t)&&k(t)}function ft(t){return Boolean(t&&"function"==typeof t.equals&&"function"==typeof t.hashCode)}function ht(t,e){if(t===e||t!=t&&e!=e)return!0;if(!t||!e)return!1;if("function"==typeof t.valueOf&&"function"==typeof e.valueOf){if((t=t.valueOf())===(e=e.valueOf())||t!=t&&e!=e)return!0;if(!t||!e)return!1}return!!(ft(t)&&ft(e)&&t.equals(e))}var pt="function"==typeof Math.imul&&-2===Math.imul(4294967295,2)?Math.imul:function(t,e){var r=65535&(t|=0),n=65535&(e|=0);return r*n+((t>>>16)*n+r*(e>>>16)<<16>>>0)|0};function _t(t){return t>>>1&1073741824|3221225471&t}var lt=Object.prototype.valueOf;function vt(t){if(null==t)return yt(t);if("function"==typeof t.hashCode)return _t(t.hashCode(t));var e,r=(e=t).valueOf!==lt&&"function"==typeof e.valueOf?e.valueOf(e):e;if(null==r)return yt(r);switch(typeof r){case"boolean":return r?1108378657:1108378656;case"number":return function(t){if(t!=t||t===1/0)return 0;var e=0|t;e!==t&&(e^=4294967295*t);for(;t>4294967295;)e^=t/=4294967295;return _t(e)}(r);case"string":return r.length>Et?function(t){var e=Mt[t];void 0===e&&(e=dt(t),qt===jt&&(qt=0,Mt={}),qt++,Mt[t]=e);return e}(r):dt(r);case"object":case"function":return function(t){var e;if(zt&&void 0!==(e=bt.get(t)))return e;if(e=t[Ot],void 0!==e)return e;if(!wt){if(void 0!==(e=t.propertyIsEnumerable&&t.propertyIsEnumerable[Ot]))return e;if(void 0!==(e=function(t){if(t&&t.nodeType>0)switch(t.nodeType){case 1:return t.uniqueID;case 9:return t.documentElement&&t.documentElement.uniqueID}}(t)))return e}if(e=mt(),zt)bt.set(t,e);else{if(void 0!==gt&&!1===gt(t))throw new Error("Non-extensible objects are not allowed as keys.");if(wt)Object.defineProperty(t,Ot,{enumerable:!1,configurable:!1,writable:!1,value:e});else if(void 0!==t.propertyIsEnumerable&&t.propertyIsEnumerable===t.constructor.prototype.propertyIsEnumerable)t.propertyIsEnumerable=function(){return this.constructor.prototype.propertyIsEnumerable.apply(this,arguments)},t.propertyIsEnumerable[Ot]=e;else{if(void 0===t.nodeType)throw new Error("Unable to set a non-enumerable property on object.");t[Ot]=e}}return e}(r);case"symbol":return function(t){var e=St[t];if(void 0!==e)return e;return e=mt(),St[t]=e,e}(r);default:if("function"==typeof r.toString)return dt(r.toString());throw new Error("Value type "+typeof r+" cannot be hashed.")}}function yt(t){return null===t?1108378658:1108378659}function dt(t){for(var e=0,r=0;r=0&&(a.get=function(e,r){return(e=c(this,e))>=0&&eo)return{value:void 0,done:!0};var t=i.next();return n||e===U||t.done?t:P(e,a-1,e===R?void 0:t.value[1],t)}))},a}function Lt(t,e,r,n){var i=Xt(t);return i.__iterateUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterate(i,o);var s=!0,a=0;return t.__iterate((function(t,o,c){if(!s||!(s=e.call(r,t,o,c)))return a++,i(t,n?o:a-1,u)})),a},i.__iteratorUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterator(i,o);var s=t.__iterator(T,o),a=!0,c=0;return new C((function(){var t,o,f;do{if((t=s.next()).done)return n||i===U?t:P(i,c++,i===R?void 0:t.value[1],t);var h=t.value;o=h[0],f=h[1],a&&(a=e.call(r,f,o,u))}while(a);return i===T?t:P(i,o,f,t)}))},i}xt.prototype.cacheResult=Dt.prototype.cacheResult=At.prototype.cacheResult=kt.prototype.cacheResult=Ft;var Ct=function(t){function e(t){this._wrappedIterables=t.flatMap((function(t){return t._wrappedIterables?t._wrappedIterables:[t]})),this.size=this._wrappedIterables.reduce((function(t,e){if(void 0!==t){var r=e.size;if(void 0!==r)return t+r}}),0),this[g]=this._wrappedIterables[0][g],this[m]=this._wrappedIterables[0][m],this[A]=this._wrappedIterables[0][A]}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.__iterateUncached=function(t,e){if(0!==this._wrappedIterables.length){if(e)return this.cacheResult().__iterate(t,e);for(var r=0,n=w(this),i=n?T:U,o=this._wrappedIterables[r].__iterator(i,e),u=!0,s=0;u;){for(var a=o.next();a.done;){if(++r===this._wrappedIterables.length)return s;a=(o=this._wrappedIterables[r].__iterator(i,e)).next()}u=!1!==(n?t(a.value[1],a.value[0],this):t(a.value,s,this)),s++}return s}},e.prototype.__iteratorUncached=function(t,e){var r=this;if(0===this._wrappedIterables.length)return new C(W);if(e)return this.cacheResult().__iterator(t,e);var n=0,i=this._wrappedIterables[n].__iterator(t,e);return new C((function(){for(var o=i.next();o.done;){if(++n===r._wrappedIterables.length)return o;o=(i=r._wrappedIterables[n].__iterator(t,e)).next()}return o}))},e}(X);function Pt(t,e,r){var n=Xt(t);return n.__iterateUncached=function(i,o){if(o)return this.cacheResult().__iterate(i,o);var u=0,s=!1;return function t(a,c){a.__iterate((function(o,a){return(!e||c0}function Jt(t,e,r,n){var i=Xt(t),o=new $(r).map((function(t){return t.size}));return i.size=n?o.max():o.min(),i.__iterate=function(t,e){for(var r,n=this.__iterator(U,e),i=0;!(r=n.next()).done&&!1!==t(r.value,i++,this););return i},i.__iteratorUncached=function(t,i){var o=r.map((function(t){return t=S(t),J(i?t.reverse():t)})),u=0,s=!1;return new C((function(){var r;return s||(r=o.map((function(t){return t.next()})),s=n?r.every((function(t){return t.done})):r.some((function(t){return t.done}))),s?{value:void 0,done:!0}:P(t,u++,e.apply(null,r.map((function(t){return t.value}))))}))},i}function Vt(t,e){return t===e?t:q(t)?e:t.constructor(e)}function Yt(t){if(t!==Object(t))throw new TypeError("Expected [K, V] tuple: "+t)}function Qt(t){return w(t)?I:b(t)?O:E}function Xt(t){return Object.create((w(t)?F:b(t)?G:Z).prototype)}function Ft(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size,this):X.prototype.cacheResult.call(this)}function Gt(t,e){return void 0===t&&void 0===e?0:void 0===t?1:void 0===e?-1:t>e?1:t0;)e[r]=arguments[r+1];if("function"!=typeof t)throw new TypeError("Invalid merger function: "+t);return ze(this,e,t)}function ze(t,e,r){for(var n=[],i=0;i0;)e[r]=arguments[r+1];return Se(this,e,t)}function je(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return he(this,t,Je(),(function(t){return Ie(t,e)}))}function qe(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return he(this,t,Je(),(function(t){return Se(t,e)}))}function Me(t){var e=this.asMutable();return t(e),e.wasAltered()?e.__ensureOwner(this.__ownerID):this}function De(){return this.__ownerID?this:this.__ensureOwner(new s)}function xe(){return this.__ensureOwner()}function Ae(){return this.__altered}var ke=function(t){function e(e){return null==e?Je():at(e)&&!k(e)?e:Je().withMutations((function(r){var n=t(e);te(n.size),n.forEach((function(t,e){return r.set(e,t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.toString=function(){return this.__toString("Map {","}")},e.prototype.get=function(t,e){return this._root?this._root.get(0,void 0,t,e):e},e.prototype.set=function(t,e){return Ve(this,t,e)},e.prototype.remove=function(t){return Ve(this,t,o)},e.prototype.deleteAll=function(t){var e=S(t);return 0===e.size?this:this.withMutations((function(t){e.forEach((function(e){return t.remove(e)}))}))},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):Je()},e.prototype.sort=function(t){return yr(Wt(this,t))},e.prototype.sortBy=function(t,e){return yr(Wt(this,e,t))},e.prototype.map=function(t,e){var r=this;return this.withMutations((function(n){n.forEach((function(i,o){n.set(o,t.call(e,i,o,r))}))}))},e.prototype.__iterator=function(t,e){return new Pe(this,t,e)},e.prototype.__iterate=function(t,e){var r=this,n=0;return this._root&&this._root.iterate((function(e){return n++,t(e[1],e[0],r)}),e),n},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?He(this.size,this._root,t,this.__hash):0===this.size?Je():(this.__ownerID=t,this.__altered=!1,this)},e}(I);ke.isMap=at;var Re=ke.prototype;Re[st]=!0,Re[e]=Re.remove,Re.removeAll=Re.deleteAll,Re.setIn=le,Re.removeIn=Re.deleteIn=ye,Re.update=ge,Re.updateIn=we,Re.merge=Re.concat=me,Re.mergeWith=be,Re.mergeDeep=Oe,Re.mergeDeepWith=Ee,Re.mergeIn=je,Re.mergeDeepIn=qe,Re.withMutations=Me,Re.wasAltered=Ae,Re.asImmutable=xe,Re["@@transducer/init"]=Re.asMutable=De,Re["@@transducer/step"]=function(t,e){return t.set(e[0],e[1])},Re["@@transducer/result"]=function(t){return t.asImmutable()};var Ue=function(t,e){this.ownerID=t,this.entries=e};Ue.prototype.get=function(t,e,r,n){for(var i=this.entries,o=0,u=i.length;o=Ze)return function(t,e,r,n){t||(t=new s);for(var i=new Le(t,vt(r),[r,n]),o=0;o>>t)&i),s=this.bitmap;return 0==(s&u)?o:this.nodes[Fe(s&u-1)].get(t+r,e,n,o)},Te.prototype.update=function(t,e,u,s,a,c,f){void 0===u&&(u=vt(s));var h=(0===e?u:u>>>e)&i,p=1<=$e)return function(t,e,r,i,o){for(var u=0,s=new Array(n),a=0;0!==r;a++,r>>>=1)s[a]=1&r?e[u++]:void 0;return s[i]=o,new Be(t,u+1,s)}(t,y,_,h,g);if(l&&!g&&2===y.length&&Qe(y[1^v]))return y[1^v];if(l&&g&&1===y.length&&Qe(g))return g;var w=t&&t===this.ownerID,m=l?g?_:_^p:_|p,b=l?g?Ge(y,v,g,w):function(t,e,r){var n=t.length-1;if(r&&e===n)return t.pop(),t;for(var i=new Array(n),o=0,u=0;u>>t)&i,s=this.nodes[u];return s?s.get(t+r,e,n,o):o},Be.prototype.update=function(t,e,n,u,s,a,c){void 0===n&&(n=vt(u));var f=(0===e?n:n>>>e)&i,h=s===o,p=this.nodes,_=p[f];if(h&&!_)return this;var l=Ye(_,t,e+r,n,u,s,a,c);if(l===_)return this;var v=this.count;if(_){if(!l&&--v>>n)&i,c=(0===n?o:o>>>n)&i,f=a===c?[Xe(t,e,n+r,o,u)]:(s=new Le(e,o,u),a>1&1431655765))+(t>>2&858993459))+(t>>4)&252645135,t+=t>>8,127&(t+=t>>16)}function Ge(t,e,r,n){var i=n?t:Zt(t);return i[e]=r,i}var Ze=n/4,$e=n/2,tr=n/4,er="@@__IMMUTABLE_LIST__@@";function rr(t){return Boolean(t&&t[er])}var nr=function(t){function e(e){var i=cr();if(null==e)return i;if(rr(e))return e;var o=t(e),u=o.size;return 0===u?i:(te(u),u>0&&u=0&&t=t.size||e<0)return t.withMutations((function(t){e<0?_r(t,e).set(0,r):_r(t,0,e+1).set(e,r)}));e+=t._origin;var n=t._tail,i=t._root,o={value:!1};e>=lr(t._capacity)?n=fr(n,t.__ownerID,0,e,r,o):i=fr(i,t.__ownerID,t._level,e,r,o);if(!o.value)return t;if(t.__ownerID)return t._root=i,t._tail=n,t.__hash=void 0,t.__altered=!0,t;return ar(t._origin,t._capacity,t._level,i,n)}(this,t,e)},e.prototype.remove=function(t){return this.has(t)?0===t?this.shift():t===this.size-1?this.pop():this.splice(t,1):this},e.prototype.insert=function(t,e){return this.splice(t,0,e)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=this._origin=this._capacity=0,this._level=r,this._root=this._tail=this.__hash=void 0,this.__altered=!0,this):cr()},e.prototype.push=function(){var t=arguments,e=this.size;return this.withMutations((function(r){_r(r,0,e+t.length);for(var n=0;n>>e&i;if(o>=this.array.length)return new or([],t);var u,s=0===o;if(e>0){var a=this.array[o];if((u=a&&a.removeBefore(t,e-r,n))===a&&s)return this}if(s&&!u)return this;var c=hr(this,t);if(!s)for(var f=0;f>>e&i;if(s>=this.array.length)return this;if(e>0){var a=this.array[s];if((u=a&&a.removeAfter(t,e-r,o))===a&&s===this.array.length-1)return this}var c=hr(this,t);return c.array.splice(s+1),u&&(c.array[s]=u),c};var ur={};function sr(t,e){var i=t._origin,o=t._capacity,u=lr(o),s=t._tail;return a(t._root,t._level,0);function a(t,c,f){return 0===c?function(t,r){var a=r===u?s&&s.array:t&&t.array,c=r>i?0:i-r,f=o-r;f>n&&(f=n);return function(){if(c===f)return ur;var t=e?--f:c++;return a&&a[t]}}(t,f):function(t,u,s){var c,f=t&&t.array,h=s>i?0:i-s>>u,p=1+(o-s>>u);p>n&&(p=n);return function(){for(;;){if(c){var t=c();if(t!==ur)return t;c=null}if(h===p)return ur;var n=e?--p:h++;c=a(f&&f[n],u-r,s+(n<>>n&i,h=t&&f0){var p=t&&t.array[f],_=fr(p,e,n-r,o,s,a);return _===p?t:((c=hr(t,e)).array[f]=_,c)}return h&&t.array[f]===s?t:(a&&u(a),c=hr(t,e),void 0===s&&f===c.array.length-1?c.array.pop():c.array[f]=s,c)}function hr(t,e){return e&&t&&e===t.ownerID?t:new or(t?t.array.slice():[],e)}function pr(t,e){if(e>=lr(t._capacity))return t._tail;if(e<1<0;)n=n.array[e>>>o&i],o-=r;return n}}function _r(t,e,n){void 0!==e&&(e|=0),void 0!==n&&(n|=0);var o=t.__ownerID||new s,u=t._origin,a=t._capacity,c=u+e,f=void 0===n?a:n<0?a+n:u+n;if(c===u&&f===a)return t;if(c>=f)return t.clear();for(var h=t._level,p=t._root,_=0;c+_<0;)p=new or(p&&p.array.length?[void 0,p]:[],o),_+=1<<(h+=r);_&&(c+=_,u+=_,f+=_,a+=_);for(var l=lr(a),v=lr(f);v>=1<l?new or([],o):y;if(y&&v>l&&cr;w-=r){var m=l>>>w&i;g=g.array[m]=hr(g.array[m],o)}g.array[l>>>r&i]=y}if(f=v)c-=v,f-=v,h=r,p=null,d=d&&d.removeBefore(o,0,c);else if(c>u||v>>h&i;if(b!==v>>>h&i)break;b&&(_+=(1<u&&(p=p.removeBefore(o,h,c-_)),p&&v>>r<=n&&a.size>=2*s.size?(i=(u=a.filter((function(t,e){return void 0!==t&&c!==e}))).toKeyedSeq().map((function(t){return t[0]})).flip().toMap(),t.__ownerID&&(i.__ownerID=u.__ownerID=t.__ownerID)):(i=s.remove(e),u=c===a.size-1?a.pop():a.set(c,void 0))}else if(f){if(r===a.get(c)[1])return t;i=s,u=a.set(c,[e,r])}else i=s.set(e,a.size),u=a.set(a.size,[e,r]);return t.__ownerID?(t.size=i.size,t._map=i,t._list=u,t.__hash=void 0,t.__altered=!0,t):dr(i,u)}yr.isOrderedMap=ct,yr.prototype[A]=!0,yr.prototype[e]=yr.prototype.remove;var mr="@@__IMMUTABLE_STACK__@@";function br(t){return Boolean(t&&t[mr])}var zr=function(t){function e(t){return null==t?Er():br(t)?t:Er().pushAll(t)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("Stack [","]")},e.prototype.get=function(t,e){var r=this._head;for(t=c(this,t);r&&t--;)r=r.next;return r?r.value:e},e.prototype.peek=function(){return this._head&&this._head.value},e.prototype.push=function(){var t=arguments;if(0===arguments.length)return this;for(var e=this.size+arguments.length,r=this._head,n=arguments.length-1;n>=0;n--)r={value:t[n],next:r};return this.__ownerID?(this.size=e,this._head=r,this.__hash=void 0,this.__altered=!0,this):Or(e,r)},e.prototype.pushAll=function(e){if(0===(e=t(e)).size)return this;if(0===this.size&&br(e))return e;te(e.size);var r=this.size,n=this._head;return e.__iterate((function(t){r++,n={value:t,next:n}}),!0),this.__ownerID?(this.size=r,this._head=n,this.__hash=void 0,this.__altered=!0,this):Or(r,n)},e.prototype.pop=function(){return this.slice(1)},e.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):Er()},e.prototype.slice=function(e,r){if(h(e,r,this.size))return this;var n=p(e,this.size);if(_(r,this.size)!==this.size)return t.prototype.slice.call(this,e,r);for(var i=this.size-n,o=this._head;n--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):Or(i,o)},e.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Or(this.size,this._head,t,this.__hash):0===this.size?Er():(this.__ownerID=t,this.__altered=!1,this)},e.prototype.__iterate=function(t,e){var r=this;if(e)return new $(this.toArray()).__iterate((function(e,n){return t(e,n,r)}),e);for(var n=0,i=this._head;i&&!1!==t(i.value,n++,this);)i=i.next;return n},e.prototype.__iterator=function(t,e){if(e)return new $(this.toArray()).__iterator(t,e);var r=0,n=this._head;return new C((function(){if(n){var e=n.value;return n=n.next,P(t,r++,e)}return{value:void 0,done:!0}}))},e}(O);zr.isStack=br;var Sr,Ir=zr.prototype;function Or(t,e,r,n){var i=Object.create(Ir);return i.size=t,i._head=e,i.__ownerID=r,i.__hash=n,i.__altered=!1,i}function Er(){return Sr||(Sr=Or(0))}Ir[mr]=!0,Ir.shift=Ir.pop,Ir.unshift=Ir.push,Ir.unshiftAll=Ir.pushAll,Ir.withMutations=Me,Ir.wasAltered=Ae,Ir.asImmutable=xe,Ir["@@transducer/init"]=Ir.asMutable=De,Ir["@@transducer/step"]=function(t,e){return t.unshift(e)},Ir["@@transducer/result"]=function(t){return t.asImmutable()};var jr="@@__IMMUTABLE_SET__@@";function qr(t){return Boolean(t&&t[jr])}function Mr(t){return qr(t)&&k(t)}function Dr(t,e){if(t===e)return!0;if(!d(e)||void 0!==t.size&&void 0!==e.size&&t.size!==e.size||void 0!==t.__hash&&void 0!==e.__hash&&t.__hash!==e.__hash||w(t)!==w(e)||b(t)!==b(e)||k(t)!==k(e))return!1;if(0===t.size&&0===e.size)return!0;var r=!z(t);if(k(t)){var n=t.entries();return e.every((function(t,e){var i=n.next().value;return i&&ht(i[1],t)&&(r||ht(i[0],e))}))&&n.next().done}var i=!1;if(void 0===t.size)if(void 0===e.size)"function"==typeof t.cacheResult&&t.cacheResult();else{i=!0;var u=t;t=e,e=u}var s=!0,a=e.__iterate((function(e,n){if(r?!t.has(e):i?!ht(e,t.get(n,o)):!ht(t.get(n,o),e))return s=!1,!1}));return s&&t.size===a}function xr(t,e){var r=function(r){t.prototype[r]=e[r]};return Object.keys(e).forEach(r),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(e).forEach(r),t}function Ar(t){if(!t||"object"!=typeof t)return t;if(!d(t)){if(!ie(t))return t;t=X(t)}if(w(t)){var e={};return t.__iterate((function(t,r){e[r]=Ar(t)})),e}var r=[];return t.__iterate((function(t){r.push(Ar(t))})),r}var kr=function(t){function e(e){return null==e?Kr():qr(e)&&!k(e)?e:Kr().withMutations((function(r){var n=t(e);te(n.size),n.forEach((function(t){return r.add(t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(I(t).keySeq())},e.intersect=function(t){return(t=S(t).toArray()).length?Ur.intersect.apply(e(t.pop()),t):Kr()},e.union=function(t){return(t=S(t).toArray()).length?Ur.union.apply(e(t.pop()),t):Kr()},e.prototype.toString=function(){return this.__toString("Set {","}")},e.prototype.has=function(t){return this._map.has(t)},e.prototype.add=function(t){return Tr(this,this._map.set(t,t))},e.prototype.remove=function(t){return Tr(this,this._map.remove(t))},e.prototype.clear=function(){return Tr(this,this._map.clear())},e.prototype.map=function(t,e){var r=this,n=!1,i=Tr(this,this._map.mapEntries((function(i){var o=i[1],u=t.call(e,o,o,r);return u!==o&&(n=!0),[u,u]}),e));return n?i:this},e.prototype.union=function(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];return 0===(e=e.filter((function(t){return 0!==t.size}))).length?this:0!==this.size||this.__ownerID||1!==e.length?this.withMutations((function(r){for(var n=0;n=0&&e=0&&r>>-15,461845907),e=pt(e<<13|e>>>-13,5),e=pt((e=(e+3864292196|0)^t)^e>>>16,2246822507),e=_t((e=pt(e^e>>>13,3266489909))^e>>>16)}(t.size,n)}(this))}});var Jr=S.prototype;Jr[y]=!0,Jr[L]=Jr.values,Jr.toJSON=Jr.toArray,Jr.__toStringMapper=oe,Jr.inspect=Jr.toSource=function(){return this.toString()},Jr.chain=Jr.flatMap,Jr.contains=Jr.includes,xr(I,{flip:function(){return Vt(this,Rt(this))},mapEntries:function(t,e){var r=this,n=0;return Vt(this,this.toSeq().map((function(i,o){return t.call(e,[o,i],n++,r)})).fromEntrySeq())},mapKeys:function(t,e){var r=this;return Vt(this,this.toSeq().flip().map((function(n,i){return t.call(e,n,i,r)})).flip())}});var Vr=I.prototype;Vr[g]=!0,Vr[L]=Jr.entries,Vr.toJSON=Hr,Vr.__toStringMapper=function(t,e){return oe(e)+": "+oe(t)},xr(O,{toKeyedSeq:function(){return new Dt(this,!1)},filter:function(t,e){return Vt(this,Bt(this,t,e,!1))},findIndex:function(t,e){var r=this.findEntry(t,e);return r?r[0]:-1},indexOf:function(t){var e=this.keyOf(t);return void 0===e?-1:e},lastIndexOf:function(t){var e=this.lastKeyOf(t);return void 0===e?-1:e},reverse:function(){return Vt(this,Tt(this,!1))},slice:function(t,e){return Vt(this,Kt(this,t,e,!1))},splice:function(t,e){var r=arguments.length;if(e=Math.max(e||0,0),0===r||2===r&&!e)return this;t=p(t,t<0?this.count():this.size);var n=this.slice(0,t);return Vt(this,1===r?n:n.concat(Zt(arguments,2),this.slice(t+e)))},findLastIndex:function(t,e){var r=this.findLastEntry(t,e);return r?r[0]:-1},first:function(t){return this.get(0,t)},flatten:function(t){return Vt(this,Pt(this,t,!1))},get:function(t,e){return(t=c(this,t))<0||this.size===1/0||void 0!==this.size&&t>this.size?e:this.find((function(e,r){return r===t}),void 0,e)},has:function(t){return(t=c(this,t))>=0&&(void 0!==this.size?this.size===1/0||te?-1:0}function rn(t,e){return t^e+2654435769+(t<<6)+(t>>2)|0}Qr.has=Jr.includes,Qr.contains=Qr.includes,Qr.keys=Qr.values,xr(F,Vr),xr(G,Yr),xr(Z,Qr);var nn=function(t){function e(t){return null==t?an():Mr(t)?t:an().withMutations((function(e){var r=E(t);te(r.size),r.forEach((function(t){return e.add(t)}))}))}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(t){return this(I(t).keySeq())},e.prototype.toString=function(){return this.__toString("OrderedSet {","}")},e}(kr);nn.isOrderedSet=Mr;var on,un=nn.prototype;function sn(t,e){var r=Object.create(un);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function an(){return on||(on=sn(gr()))}un[A]=!0,un.zip=Yr.zip,un.zipWith=Yr.zipWith,un.zipAll=Yr.zipAll,un.__empty=an,un.__make=sn;var cn=function(t,e){var r;!function(t){if(D(t))throw new Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(x(t))throw new Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(null===t||"object"!=typeof t)throw new Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}(t);var n=function(o){var u=this;if(o instanceof n)return o;if(!(this instanceof n))return new n(o);if(!r){r=!0;var s=Object.keys(t),a=i._indices={};i._name=e,i._keys=s,i._defaultValues=t;for(var c=0;c2?[]:void 0,{"":t})},t.get=se,t.getIn=Pr,t.has=ue,t.hasIn=Nr,t.hash=vt,t.is=ht,t.isAssociative=z,t.isCollection=d,t.isImmutable=x,t.isIndexed=b,t.isKeyed=w,t.isList=rr,t.isMap=at,t.isOrdered=k,t.isOrderedMap=ct,t.isOrderedSet=Mr,t.isPlainObject=ne,t.isRecord=D,t.isSeq=q,t.isSet=qr,t.isStack=br,t.isValueObject=ft,t.merge=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Ie(t,e)},t.mergeDeep=function(t){for(var e=[],r=arguments.length-1;r-- >0;)e[r]=arguments[r+1];return Se(t,e)},t.mergeDeepWith=function(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];return Se(e,r,t)},t.mergeWith=function(t,e){for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];return Ie(e,r,t)},t.remove=ce,t.removeIn=ve,t.set=fe,t.setIn=_e,t.update=de,t.updateIn=he,t.version="5.1.2"})); diff --git a/package.json b/package.json index b43c22ad2c..c7f90ff5ff 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "immutable", - "version": "5.1.1", + "version": "5.1.2", "description": "Immutable Data Collections", "license": "MIT", "homepage": "https://immutable-js.com",